UNPKG

@pulumi/awsx

Version:

[![Actions Status](https://github.com/pulumi/pulumi-awsx/workflows/master/badge.svg)](https://github.com/pulumi/pulumi-awsx/actions) [![Slack](http://www.pulumi.com/images/docs/badges/slack.svg)](https://slack.pulumi.com) [![NPM version](https://badge.fur

97 lines 4.59 kB
"use strict"; // Copyright 2016-2018, Pulumi Corporation. // // 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. var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; var desc = Object.getOwnPropertyDescriptor(m, k); if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { desc = { enumerable: true, get: function() { return m[k]; } }; } Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); }) : function(o, v) { o["default"] = v; }); var __importStar = (this && this.__importStar) || (function () { var ownKeys = function(o) { ownKeys = Object.getOwnPropertyNames || function (o) { var ar = []; for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; return ar; }; return ownKeys(o); }; return function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); __setModuleDefault(result, mod); return result; }; })(); Object.defineProperty(exports, "__esModule", { value: true }); exports.Repository = void 0; exports.buildAndPushImage = buildAndPushImage; const aws = __importStar(require("@pulumi/aws")); const pulumi = __importStar(require("@pulumi/pulumi")); const ecs_1 = require("../ecs"); const lifecyclePolicy_1 = require("./lifecyclePolicy"); const repositoryImage_1 = require("./repositoryImage"); /** * A [Repository] represents an [aws.ecr.Repository] along with an associated [LifecyclePolicy] * controlling how images are retained in the repo. * * Docker images can be built and pushed to the repo using the [buildAndPushImage] method. This * will call into the `@pulumi/docker/buildAndPushImage` function using this repo as the appropriate * destination registry. */ class Repository extends pulumi.ComponentResource { repository; lifecyclePolicy; constructor(name, args = {}, opts = {}) { super("awsx:ecr:Repository", name, undefined, opts); const lowerCaseName = name.toLowerCase(); this.repository = args.repository || new aws.ecr.Repository(lowerCaseName, args, { parent: this }); this.lifecyclePolicy = new lifecyclePolicy_1.LifecyclePolicy(lowerCaseName, this.repository, args.lifeCyclePolicyArgs, { parent: this }); this.registerOutputs(); } /** * Builds the docker container specified by [pathOrBuild] and pushes it to this repository. * The result is the unique ID pointing to that pushed image in this repo. This unique ID * can be passed as the value to `image: repo.buildAndPushImage(...)` in an `ecs.Container`. */ buildAndPushImage(pathOrBuild) { return pulumi.all([pathOrBuild, this.repository.repositoryUrl, this.repository.registryId]) .apply(([pathOrBuild, repositoryUrl, registryId]) => (0, ecs_1.computeImageFromAsset)(pathOrBuild, repositoryUrl, registryId, this)); } } exports.Repository = Repository; /** * Creates a new [Repository], optionally configured using [args], builds the docker container * specified by [pathOrBuild] and then pushes the built image to the repository. The result * contains both the Repository created as well as the unique ID referencing the built image in that * repo. This result type can be passed in as `image: ecr.buildAndPushImage(...)` for an * `ecs.Container` */ function buildAndPushImage(name, pathOrBuild, args, opts) { const repo = new Repository(name, args, opts); const image = repo.buildAndPushImage(pathOrBuild); return new repositoryImage_1.RepositoryImage(repo, image); } //# sourceMappingURL=repository.js.map