UNPKG

@adpt/cloud

Version:
63 lines 2.48 kB
"use strict"; /* * Copyright 2019 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 tslib_1 = require("tslib"); const core_1 = tslib_1.__importStar(require("@adpt/core")); const Container_1 = require("../Container"); const NetworkService_1 = require("../NetworkService"); const Service_1 = require("../Service"); const testMongoDefaultProps = { image: "mongo:latest", imagePullPolicy: "Always", port: 27017 }; /** * Test {@link https://www.mongodb.com | MongoDB} Service * * @remarks * * Uses an abstract {@link Service}, {@link NetworkService}, and {@link Container} * component that must be substituted in a style sheet. * * See {@link mongodb.TestMongoDBProps}. * * @public */ function TestMongoDB(props) { const lprops = props; const svc = core_1.handle(); const mongo = core_1.handle(); core_1.useImperativeMethods(() => ({ connectEnv: (scope) => { const hostname = core_1.callInstanceMethod(svc, undefined, "hostname", scope); const port = core_1.callInstanceMethod(svc, undefined, "port"); if (!hostname || !port) return undefined; return { MONGODB_URI: `mongodb://${hostname}:${port}` }; }, image: () => lprops.image })); return core_1.default.createElement(Service_1.Service, null, core_1.default.createElement(NetworkService_1.NetworkService, { handle: svc, endpoint: mongo, port: lprops.port, targetPort: 27017 }), core_1.default.createElement(Container_1.Container, { handle: mongo, name: "mongodb", image: lprops.image, ports: [27017], imagePullPolicy: lprops.imagePullPolicy })); } exports.TestMongoDB = TestMongoDB; // TODO: The "as any" is a workaround for an api-extractor bug. See issue #185. TestMongoDB.defaultProps = testMongoDefaultProps; //# sourceMappingURL=TestMongoDB.js.map