steep-translator-9040
05/17/2022, 7:54 AMpulumi-project-name
), I then provide RequireObject the key of the object I want to load from configuration (in my example stack
), and it should deserialise it accordingly.
import (
"<http://github.com/pulumi/pulumi/pkg/v3/testing/integration|github.com/pulumi/pulumi/pkg/v3/testing/integration>"
"<http://github.com/pulumi/pulumi/sdk/v3/go/pulumi|github.com/pulumi/pulumi/sdk/v3/go/pulumi>"
"os"
"testing"
)
type Configuration struct {
Project string
Region
Ephemeral bool
}
type Region struct {
LongName string
ShortName string
}
// Pulumi.test.yaml
// encryptionsalt: ...........
// config:
// gcp:project: my-gcp-project-name
// pulumi-project-name:stack:
// project: my-gcp-project-name
// region:
// long: us-east1-b
// short: US
// ephemeral: false
// results in error:
// panic: missing required configuration variable 'pulumi-project-name:stack'; run `pulumi config` to set
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
var configuration Configuration
cfg := config.New(ctx, "")
cfg.RequireObject("stack", &configuration)
})
}
func TestExamples(t *testing.T) {
cwd, _ := os.Getwd()
integration.ProgramTest(t, &integration.ProgramTestOptions{
Quick: true,
SkipRefresh: true,
Dir: cwd,
Config: map[string]string{
"gcp:project": "my-gcp-project-name",
"pulumi-project-name:stack.project": "my-gcp-project-name",
"pulumi-project-name:stack.region.short": "US",
"pulumi-project-name:stack.region.long": "us-east1-b",
"pulumi-project-name:stack.ephemeral": "true",
},
})
}
func TestExamples(t *testing.T) {
cwd, _ := os.Getwd()
integration.ProgramTest(t, &integration.ProgramTestOptions{
Quick: true,
SkipRefresh: true,
Dir: cwd,
Config: map[string]string{
"gcp:project": "my-gcp-project-name",
"stack": `{
"project": "my-gcp-project-name",
"ephemeral": true,
"region": {
"short": "US",
"long": "us-east1-b"
}
}`,
},
})
}