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 testRedisDefaultProps = { image: "redis:buster", imagePullPolicy: "Always", port: 6379 }; /** * Deploys a {@link https://redis.io | Redis} container suitable for testing * * @remarks * * Uses an abstract {@link Service}, {@link NetworkService}, and {@link Container} * component that must be substituted in a style sheet. * * * See {@link redis.TestRedisProps}. * * @public */ function TestRedis(props) { const lprops = props; const svc = core_1.handle(); const redis = 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 { REDIS_URI: `redis://${hostname}:${port}` }; }, image: () => lprops.image })); return core_1.default.createElement(Service_1.Service, null, core_1.default.createElement(NetworkService_1.NetworkService, { handle: svc, endpoint: redis, port: lprops.port, targetPort: 6379 }), core_1.default.createElement(Container_1.Container, { handle: redis, name: "redis", image: lprops.image, ports: [6379], imagePullPolicy: lprops.imagePullPolicy })); } exports.TestRedis = TestRedis; // TODO: The "as any" is a workaround for an api-extractor bug. See issue #185. TestRedis.defaultProps = testRedisDefaultProps; //# sourceMappingURL=TestRedis.js.map