@adpt/cloud
Version:
AdaptJS cloud component library
64 lines • 2.12 kB
JavaScript
;
/*
* Copyright 2018-2020 Unbounded Systems, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
Object.defineProperty(exports, "__esModule", { value: true });
const core_1 = require("@adpt/core");
/**
* Abstract component representing a container.
* @public
*/
class Container extends core_1.PrimitiveComponent {
}
Container.defaultProps = {
dockerHost: "unix:///var/run/docker.sock",
autoRemove: true,
ports: [],
stdinOpen: false,
tty: false,
portBindings: {},
environment: {},
links: {},
imagePullPolicy: "IfNotPresent",
};
Container.displayName = "cloud.Container";
exports.Container = Container;
exports.default = Container;
/**
* Function to check whether an {@link @adpt/core#AdaptElement} is an
* abstract {@link Container}.
* @public
*/
function isContainerElement(el) {
return el.componentType === Container;
}
exports.isContainerElement = isContainerElement;
/**
* Hook function to translate an {@link ImageId} (which can be either a
* Handle or an image name string) into an image name string.
* @beta
*/
function useLatestImageFrom(source) {
// useMethod hook must be called unconditionally, even if source isn't a handle
const hand = core_1.isHandle(source) ? source : null;
const image = core_1.useMethod(hand, "latestImage");
if (image && !image.nameTag)
throw new Error(`Built image info has no nameTag`);
return (typeof source === "string") ? source :
image ? image.nameTag :
undefined;
}
exports.useLatestImageFrom = useLatestImageFrom;
//# sourceMappingURL=Container.js.map