Skip to content

Commit

Permalink
feat(pulumi): enable new varfile schema for modules (#6735)
Browse files Browse the repository at this point in the history
feat(pulumi): nable new varfile schema for modules
  • Loading branch information
thsig authored Dec 20, 2024
1 parent dd1167e commit bf74500
Show file tree
Hide file tree
Showing 12 changed files with 2,410 additions and 25 deletions.
1 change: 1 addition & 0 deletions plugins/pulumi/src/action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export interface PulumiDeploySpec {
stackReferences: string[]
deployFromPreview: boolean
root: string
useNewPulumiVarfileSchema: boolean
stack?: string
showSecretsInOutput: boolean
}
Expand Down
2 changes: 1 addition & 1 deletion plugins/pulumi/src/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ export async function applyConfig(params: PulumiParams & { previewDirPath?: stri
// Pulumi variables (from action.spec.pulumiVariables) take precedence over any variables declared in pulumi varfiles.
let vars: DeepPrimitiveMap = {}

if (action.getSpec()["useNewPulumiVarfileSchema"] || provider.config.useNewPulumiVarfileSchema) {
if (action.getSpec().useNewPulumiVarfileSchema || provider.config.useNewPulumiVarfileSchema) {
for (const varfileVars of varfileContents) {
vars = <DeepPrimitiveMap>merge(vars, varfileVars)
}
Expand Down
1 change: 1 addition & 0 deletions plugins/pulumi/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ export const gardenPlugin = () =>
cacheStatus: module.spec.cacheStatus || false,
stackReferences: module.spec.stackReferences || [],
deployFromPreview: module.spec.deployFromPreview || false,
useNewPulumiVarfileSchema: module.spec.useNewPulumiVarfileSchema || false,
showSecretsInOutput: module.spec.showSecretsInOutput || false,
root: module.spec.root || ".",
...omit(module.spec, ["build", "dependencies"]),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
config:
pulumi-k8s-test:namespace: pulumi-test
pulumi-k8s-test:appName: app-name-from-pulumi-varfile
pulumi-k8s-test:orgName: foobar123
pulumi-k8s-test:isMinikube: 'true'
backend:
url: https://api.pulumi.com
test: foo
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
name: pulumi-k8s-test
runtime: nodejs
description: A minimal Kubernetes TypeScript Pulumi program
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
kind: Module
type: pulumi
name: k8s-namespace-new-module
description: Creates a Namespace
useNewPulumiVarfileSchema: true
pulumiVarfiles: [varfile-new-schema.yaml]
createStack: true
cacheStatus: true
allowDestroy: true
pulumiVariables:
pulumi-k8s-test:orgName: ${var.orgName}
pulumi-k8s-test:namespace: pulumi-test
pulumi-k8s-test:isMinikube: "true"


Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*
* Copyright (C) 2018-2024 Garden Technologies, Inc. <info@garden.io>
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/

import * as pulumi from "@pulumi/pulumi"
import * as k8s from "@pulumi/kubernetes"

// Minikube does not implement services of type `LoadBalancer`; require the user to specify if we're
// running on minikube, and if so, create only services of type ClusterIP.
const config = new pulumi.Config()

const name = config.require("namespace")

const ns = new k8s.core.v1.Namespace(config.require("namespace"), { metadata: { name } })
export const namespace = ns.metadata.name
Loading

0 comments on commit bf74500

Please sign in to comment.