Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add configMap option #645

Merged
merged 27 commits into from
Jul 8, 2022
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
906c8e1
chore(deps-dev): bump lint-staged from 12.3.8 to 12.4.0
dependabot[bot] Apr 21, 2022
d15ffbe
chore(dist): Update dist [automated commit]
mikhailshilkov Apr 21, 2022
205aa17
Modify action
SharaevN Apr 23, 2022
1dabbf6
Delete after disable workflow
Moon1706 Apr 29, 2022
bb48fab
Resolve
SharaevN May 24, 2022
9b84303
Merge branch 'pulumi-master'
SharaevN May 24, 2022
a5fd714
Add deps
SharaevN Jun 9, 2022
85ef821
Merge branch 'pulumi-master'
SharaevN Jun 9, 2022
88bbf66
# This is a combination of 3 commits.
SharaevN Jun 10, 2022
01fd1cf
Merge
SharaevN Jun 11, 2022
33c42b2
Test errors
SharaevN Jun 11, 2022
45c1b94
chore(dist): Update dist [automated commit]
Moon1706 Jun 11, 2022
7a403ab
Merge branch 'pulumi:master' into master
Moon1706 Jun 11, 2022
722c580
Fix
SharaevN Jun 11, 2022
534a5c6
Fix 2
SharaevN Jun 11, 2022
a5cce86
chore(dist): Update dist [automated commit]
Moon1706 Jun 11, 2022
dac17a1
chore: removed unrelated changes
simenandre Jun 11, 2022
63634f0
remove dists
simenandre Jun 11, 2022
807f486
reword CHANGELOG
simenandre Jun 11, 2022
cdf1bb5
remove package-lock
simenandre Jun 11, 2022
b515847
Merge branch 'master' into small-fixup-584
t0yv0 Jun 24, 2022
e8faae7
Fix JSON bad merge
t0yv0 Jun 24, 2022
046dbb7
Merge branch 'master' into small-fixup-584
RobbieMcKinstry Jul 8, 2022
2d99003
Regenerate the lockfile.
RobbieMcKinstry Jul 8, 2022
833b9e2
Fix broken test
RobbieMcKinstry Jul 8, 2022
be3fe91
Downgrade yarn lockfile to use yaml v1.0
RobbieMcKinstry Jul 8, 2022
4889a50
Bump YAML to ~v2.0.1
RobbieMcKinstry Jul 8, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .github/test-stacks/dotnet/MyStack.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ class MyStack : Stack
{
public MyStack()
{
var pet = new RandomPet("my-pet", new RandomPetArgs{});
var config = new Pulumi.Config();
var name = config.Require("name");
var pet = new RandomPet(name, new RandomPetArgs{});

this.PetName = pet.Id;
}
Expand Down
5 changes: 4 additions & 1 deletion .github/test-stacks/golang/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@ package main
import (
random "github.com/pulumi/pulumi-random/sdk/v4/go/random"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi/config"
)

func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
s, err := random.NewRandomString(ctx, "my-user-name", &random.RandomStringArgs{
conf := config.New(ctx, "")
name := conf.Require("name")
s, err := random.NewRandomString(ctx, name, &random.RandomStringArgs{
Length: pulumi.Int(60),
})
if err != nil {
Expand Down
5 changes: 4 additions & 1 deletion .github/test-stacks/nodejs/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import * as pulumi from '@pulumi/pulumi';
import * as random from "@pulumi/random";

const pet = new random.RandomPet("hostname");
let config = new pulumi.Config();
let name = config.require("name");
const pet = new random.RandomPet(name);

export const petName = pet.id;
8 changes: 5 additions & 3 deletions .github/test-stacks/python/__main__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import pulumi
import pulumi_random as random
from pulumi import export

random_host_name = random.RandomPet("hostname")
config = pulumi.Config()
name = config.require("name")
random_host_name = random.RandomPet(name)

export('name', random_host_name.id)
pulumi.export("name", random_host_name.id)
1 change: 1 addition & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,5 @@ jobs:
stack-name: dev
upsert: true
work-dir: .github/test-stacks/golang
configMap: "{name: {value: test, secret: false}}"
- run: echo "The random string is `${{ steps.pulumi.outputs.name }}`"
5 changes: 5 additions & 0 deletions .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ jobs:
upsert: true
stack-name: dev
work-dir: .github/test-stacks/dotnet
configMap: "{name: {value: my-pet, secret: false}}"

test-golang-stack:
needs: install-and-build
Expand Down Expand Up @@ -110,6 +111,7 @@ jobs:
stack-name: dev
upsert: true
work-dir: .github/test-stacks/golang
configMap: "{name: {value: my-user-name, secret: false}}"

test-nodejs-stack:
needs: install-and-build
Expand Down Expand Up @@ -159,6 +161,7 @@ jobs:
stack-name: dev
upsert: true
work-dir: .github/test-stacks/nodejs
configMap: "{name: {value: hostname, secret: false}}"
RobbieMcKinstry marked this conversation as resolved.
Show resolved Hide resolved

test-python-stack:
needs: install-and-build
Expand Down Expand Up @@ -219,6 +222,7 @@ jobs:
stack-name: dev
upsert: true
work-dir: .github/test-stacks/python
configMap: "{name: {value: hostname, secret: false}}"

test-generic-inputs:
needs: install-and-build
Expand Down Expand Up @@ -268,3 +272,4 @@ jobs:
work-dir: .github/test-stacks/nodejs
upsert: true
refresh: true
configMap: "{name: {value: hostname, secret: false}}"
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

- fix: update PR comments correctly when `edit-pr-comment` is true (fixes
[#633](https://github.com/pulumi/actions/issues/633))

- feat: add configuration of Pulumi stack by `configMap` field

- bump to runtime to node 16

---
Expand Down
13 changes: 8 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,10 @@ The action can be configured with the following arguments:
- `parallel` - (optional) Allow P resource operations to run in parallel at once
(1 for no parallelism). Defaults to unbounded.

- `message` - (optional) Optional message to associate with the update operation
- `message` - (optional) Optional message to associate with the update operation.

- `expect-no-changes` - (optional) Return an error if any changes occur during
this update
this update.

- `edit-pr-comment` - (optional) Edit previous PR comment instead of posting new
one.
Expand All @@ -81,16 +81,19 @@ The action can be configured with the following arguments:
PR run, please ensure that you set this to `false`.

- `diff` - (optional) Display operation as a rich diff showing the overall
change
change.

- `replace` - (optional) Specify resources to replace. Multiple resources can be
specified one per line
specified one per line (example: `<value | string>,...`).

- `target` - (optional) Specify a single resource URN to update. Other resources
will not be updated. Multiple resources can be specified one per line
will not be updated. Multiple resources can be specified one per line (example: `<value | string>,...`).

- `target-dependents` - (optional) Allows updating of dependent targets
discovered but not specified in target.

- `configMap` - (optional) Configuration of the stack. Format Yaml string: `{<key | string>: {value: <value | string>, secret: <is_secret | boolean> },}`.

- `upsert` - (optional) Allows the creation of the specified stack if it
currently doesn't exist.
**PLEASE NOTE:** This will create a `Pulumi.<stack-name>.yaml` file that you
Expand Down
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ inputs:
description: 'Optional message to associate with the update operation'
required: false
default: ''
configMap:
description: 'Config to use during the operations'
required: false
default: ''
expect-no-changes:
description: 'Return an error if any changes occur during this update'
required: false
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@
"got": "^11.8.3",
"runtypes": "^6.5.1",
"semver": "^7.3.7",
"ts-invariant": "^0.10.3",
"typescript": "~4.1.3"
"typescript": "~4.1.3",
"yaml": "^2.0.1",
"ts-invariant": "^0.10.3"
}
}
2 changes: 2 additions & 0 deletions src/__tests__/config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ describe('config.ts', () => {
"cloudUrl": "file://~",
"command": "up",
"commentOnPr": false,
"configMap": undefined,
"githubToken": "n/a",
"options": Object {
"diff": undefined,
Expand Down Expand Up @@ -85,6 +86,7 @@ describe('config.ts', () => {
"cloudUrl": "file://~",
"command": "up",
"commentOnPr": true,
"configMap": undefined,
"githubToken": "n/a",
"options": Object {
"diff": undefined,
Expand Down
2 changes: 2 additions & 0 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export const config = rt
rt.Partial({
// Optional options
cloudUrl: rt.String,
configMap: rt.String,
githubToken: rt.String,
upsert: rt.Boolean,
refresh: rt.Boolean,
Expand All @@ -57,6 +58,7 @@ export async function makeConfig(): Promise<Config> {
commentOnPr: parseBoolean(getInput('comment-on-pr')),
upsert: parseBoolean(getInput('upsert')),
refresh: parseBoolean(getInput('refresh')),
configMap: getInput('configMap'),
options: {
parallel: parseNumber(getInput('parallel')),
message: getInput('message'),
Expand Down
7 changes: 7 additions & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import { resolve } from 'path';
import * as core from '@actions/core';
import {
ConfigMap,
LocalProgramArgs,
LocalWorkspace,
LocalWorkspaceOptions,
} from '@pulumi/pulumi/automation';
import YAML from 'yaml';
import invariant from 'ts-invariant';
import { Commands, makeConfig } from './config';
import { environmentVariables } from './libs/envs';
Expand Down Expand Up @@ -52,6 +54,11 @@ const main = async () => {
core.info(msg);
};

if (config.configMap != '') {
const configMap: ConfigMap = YAML.parse(config.configMap);
await stack.setAllConfig(configMap);
}

if (config.refresh) {
core.startGroup(`Refresh stack on ${config.stackName}`);
await stack.refresh({ onOutput });
Expand Down
Loading