UNPKG

@pulumi/kubernetes

Version:

[![Build Status](https://travis-ci.com/pulumi/pulumi-kubernetes.svg?token=eHg7Zp5zdDDJfTjY8ejq&branch=master)](https://travis-ci.com/pulumi/pulumi-kubernetes) [![Slack](http://www.pulumi.com/images/docs/badges/slack.svg)](https://slack.pulumi.com) [![NPM

103 lines 4.01 kB
"use strict"; // Copyright 2016-2022, 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. Object.defineProperty(exports, "__esModule", { value: true }); exports.Directory = void 0; // *** WARNING: this file was generated by pulumigen. *** // *** Do not edit by hand unless you're certain you know what you are doing! *** const pulumi = require("@pulumi/pulumi"); const yaml = require("../yaml"); /** * Directory is a component representing a collection of resources described by a kustomize directory (kustomization). * * ## Example Usage * ### Local Kustomize Directory * * ```typescript * import * as k8s from "@pulumi/kubernetes"; * * const helloWorld = new k8s.kustomize.Directory("helloWorldLocal", { * directory: "./helloWorld", * }); * ``` * ### Kustomize Directory from a Git Repo * * ```typescript * import * as k8s from "@pulumi/kubernetes"; * * const helloWorld = new k8s.kustomize.Directory("helloWorldRemote", { * directory: "https://github.com/kubernetes-sigs/kustomize/tree/v3.3.1/examples/helloWorld", * }); * ``` * ### Kustomize Directory with Transformations * * ```typescript * import * as k8s from "@pulumi/kubernetes"; * * const helloWorld = new k8s.kustomize.Directory("helloWorldRemote", { * directory: "https://github.com/kubernetes-sigs/kustomize/tree/v3.3.1/examples/helloWorld", * transformations: [ * // Make every service private to the cluster, i.e., turn all services into ClusterIP instead of LoadBalancer. * (obj: any, opts: pulumi.CustomResourceOptions) => { * if (obj.kind === "Service" && obj.apiVersion === "v1") { * if (obj.spec && obj.spec.type && obj.spec.type === "LoadBalancer") { * obj.spec.type = "ClusterIP"; * } * } * }, * * // Set a resource alias for a previous name. * (obj: any, opts: pulumi.CustomResourceOptions) => { * if (obj.kind === "Deployment") { * opts.aliases = [{ name: "oldName" }] * } * }, * * // Omit a resource from the Chart by transforming the specified resource definition to an empty List. * (obj: any, opts: pulumi.CustomResourceOptions) => { * if (obj.kind === "Pod" && obj.metadata.name === "test") { * obj.apiVersion = "v1" * obj.kind = "List" * } * }, * ], * }); * ``` */ class Directory extends yaml.CollectionComponentResource { /** * Create an instance of the specified kustomize directory. * * @param name Name of the kustomization (e.g., nginx-ingress). * @param config Configuration options for the kustomization. * @param opts A bag of options that control this resource's behavior. */ constructor(name, config, opts) { if (config.resourcePrefix !== undefined) { name = `${config.resourcePrefix}-${name}`; } super("kubernetes:kustomize:Directory", name, config, opts); const directory = config.directory; const childOpts = yaml.getChildOpts(this, opts); const invokeOpts = yaml.getInvokeOpts(childOpts); const promise = pulumi.runtime.invoke("kubernetes:kustomize:directory", { directory }, invokeOpts); this.resources = pulumi.output(promise).apply(p => yaml.parse({ resourcePrefix: config.resourcePrefix, objs: p.result, transformations: config.transformations || [], }, childOpts)); } } exports.Directory = Directory; //# sourceMappingURL=kustomize.js.map