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

Handle write-only properties #1377

Merged
merged 4 commits into from
Feb 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
- See PR for a complete list of resources affected (512)
- [Add types for 9 untyped properties](https://github.com/pulumi/pulumi-aws-native/pull/1365)
- [Fix generating types for refs to map types](https://github.com/pulumi/pulumi-aws-native/pull/1363)
- [Implement defaultTags configuration](https://github.com/pulumi/pulumi-aws-native/issues/1369)
- [Fix handling of write-only properties](https://github.com/pulumi/pulumi-aws-native/pull/1377)

## 0.97.0 (2024-02-21)

Expand Down
36 changes: 35 additions & 1 deletion examples/examples_go_test.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
// Copyright 2016-2021, Pulumi Corporation. All rights reserved.
//go:build go || all
// +build go all

package examples

import (
"fmt"
"path/filepath"
"testing"

"github.com/pulumi/pulumi/pkg/v3/testing/integration"
"github.com/stretchr/testify/assert"
)

func TestSimpleGo(t *testing.T) {
Expand All @@ -19,12 +22,43 @@ func TestSimpleGo(t *testing.T) {
integration.ProgramTest(t, &test)
}

func TestWriteOnlyGo(t *testing.T) {
test := getGoBaseOptions(t).
With(integration.ProgramTestOptions{
SkipRefresh: false,
ExpectRefreshChanges: false,
Dir: filepath.Join(getCwd(t), "write-only-go"),
Config: map[string]string{
"aws-native:defaultTags": `{
"defaultTag": "defaultTagValue"
}`,
},
ExtraRuntimeValidation: func(t *testing.T, stack integration.RuntimeValidationStackInfo) {
// We should see both the default tag and the local tag in the log group tags.
// If the default tag is missing, it's because there was a missing output from the provider and the SDK filled in the value with the original input.
tags := stack.Outputs["tags"].(map[string]interface{})
assert.Equal(t, map[string]interface{}{
"defaultTag": "defaultTagValue",
"localTag": "localTagValue",
}, tags)
},
})

integration.ProgramTest(t, &test)
}

func getGoBaseOptions(t *testing.T) integration.ProgramTestOptions {
base := getBaseOptions(t)

sdkPath, err := filepath.Abs("../sdk")
if err != nil {
t.Fatal(err)
}

baseGo := base.With(integration.ProgramTestOptions{
Verbose: true,
Dependencies: []string{
"github.com/pulumi/pulumi-aws-native/sdk",
fmt.Sprintf("github.com/pulumi/pulumi-aws-native/sdk=%s", sdkPath),
Copy link
Contributor

@thomas11 thomas11 Feb 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought this shouldn't be necessary, and I'm surprised it even works. ProgramTest already creates the mod replace entries for each of the Dependencies here.

In pulumi-aws, e.g., we just pass the name of the dependency.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That code only works if the PULUMI_DEP_ROOT env is set, so fails for running tests in the IDE. This is a much more reliable approach.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah. It would be more concise then to have a ProgramTest option equivalent to PULUMI_DEP_ROOT, and just pass in the plain dependencies to be replaced.

},
})

Expand Down
4 changes: 1 addition & 3 deletions examples/examples_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,7 @@ func getBaseOptions(t *testing.T) integration.ProgramTestOptions {
Config: map[string]string{
"aws-native:region": envRegion,
},
ExpectRefreshChanges: true,
SkipRefresh: true,
Quick: true,
Quick: true,
LocalProviders: []integration.LocalDependency{
{
Package: "aws-native",
Expand Down
3 changes: 3 additions & 0 deletions examples/write-only-go/Pulumi.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
name: aws-simple-go
runtime: go
description: A Go Pulumi program with AWS Native provider
92 changes: 92 additions & 0 deletions examples/write-only-go/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
module github.com/pulumi/pulumi-aws-native/examples/simple-go

go 1.21

require (
github.com/pulumi/pulumi-aws-native/sdk v0.1.0
github.com/pulumi/pulumi/sdk/v3 v3.105.0
)

require (
dario.cat/mergo v1.0.0 // indirect
github.com/Microsoft/go-winio v0.6.1 // indirect
github.com/ProtonMail/go-crypto v0.0.0-20230828082145-3c4c8a2d2371 // indirect
github.com/aead/chacha20 v0.0.0-20180709150244-8b13a72661da // indirect
github.com/agext/levenshtein v1.2.3 // indirect
github.com/apparentlymart/go-textseg/v13 v13.0.0 // indirect
github.com/atotto/clipboard v0.1.4 // indirect
github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect
github.com/blang/semver v3.5.1+incompatible // indirect
github.com/charmbracelet/bubbles v0.16.1 // indirect
github.com/charmbracelet/bubbletea v0.24.2 // indirect
github.com/charmbracelet/lipgloss v0.7.1 // indirect
github.com/cheggaaa/pb v1.0.29 // indirect
github.com/cloudflare/circl v1.3.7 // indirect
github.com/containerd/console v1.0.4-0.20230313162750-1ae8d489ac81 // indirect
github.com/cyphar/filepath-securejoin v0.2.4 // indirect
github.com/djherbis/times v1.5.0 // indirect
github.com/emirpasic/gods v1.18.1 // indirect
github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect
github.com/go-git/go-billy/v5 v5.5.0 // indirect
github.com/go-git/go-git/v5 v5.11.0 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/glog v1.1.2 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/grpc-ecosystem/grpc-opentracing v0.0.0-20180507213350-8e809c8a8645 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-multierror v1.1.1 // indirect
github.com/hashicorp/hcl/v2 v2.17.0 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect
github.com/kevinburke/ssh_config v1.2.0 // indirect
github.com/lucasb-eyer/go-colorful v1.2.0 // indirect
github.com/mattn/go-isatty v0.0.19 // indirect
github.com/mattn/go-localereader v0.0.1 // indirect
github.com/mattn/go-runewidth v0.0.15 // indirect
github.com/mitchellh/go-ps v1.0.0 // indirect
github.com/mitchellh/go-wordwrap v1.0.1 // indirect
github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6 // indirect
github.com/muesli/cancelreader v0.2.2 // indirect
github.com/muesli/reflow v0.3.0 // indirect
github.com/muesli/termenv v0.15.2 // indirect
github.com/opentracing/basictracer-go v1.1.0 // indirect
github.com/opentracing/opentracing-go v1.2.0 // indirect
github.com/pgavlin/fx v0.1.6 // indirect
github.com/pjbgf/sha1cd v0.3.0 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pkg/term v1.1.0 // indirect
github.com/pulumi/appdash v0.0.0-20231130102222-75f619a67231 // indirect
github.com/pulumi/esc v0.6.2 // indirect
github.com/rivo/uniseg v0.4.4 // indirect
github.com/rogpeppe/go-internal v1.11.0 // indirect
github.com/sabhiram/go-gitignore v0.0.0-20210923224102-525f6e181f06 // indirect
github.com/santhosh-tekuri/jsonschema/v5 v5.0.0 // indirect
github.com/sergi/go-diff v1.3.1 // indirect
github.com/skeema/knownhosts v1.2.1 // indirect
github.com/spf13/cobra v1.7.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/texttheater/golang-levenshtein v1.0.1 // indirect
github.com/tweekmonster/luser v0.0.0-20161003172636-3fa38070dbd7 // indirect
github.com/uber/jaeger-client-go v2.30.0+incompatible // indirect
github.com/uber/jaeger-lib v2.4.1+incompatible // indirect
github.com/xanzy/ssh-agent v0.3.3 // indirect
github.com/zclconf/go-cty v1.13.2 // indirect
go.uber.org/atomic v1.9.0 // indirect
golang.org/x/crypto v0.17.0 // indirect
golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa // indirect
golang.org/x/mod v0.14.0 // indirect
golang.org/x/net v0.19.0 // indirect
golang.org/x/sync v0.5.0 // indirect
golang.org/x/sys v0.15.0 // indirect
golang.org/x/term v0.15.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/tools v0.15.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20231120223509-83a465c0220f // indirect
google.golang.org/grpc v1.59.0 // indirect
google.golang.org/protobuf v1.31.0 // indirect
gopkg.in/warnings.v0 v0.1.2 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
lukechampine.com/frand v1.4.2 // indirect
pgregory.net/rapid v0.6.1 // indirect
)
Loading
Loading