UNPKG

@pulumi/kubernetes

Version:

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

126 lines 5.07 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. 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 (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; 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 = __importStar(require("@pulumi/pulumi")); const yaml = __importStar(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