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

Simplify configuration #149

Merged
merged 11 commits into from
Apr 21, 2022
Merged
Show file tree
Hide file tree
Changes from 9 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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ bin/*
# Other cannot be downloaded, as it does not correspond to a real package.
!pkg/pulumiyaml/testing/test/testdata/other.json
pkg/pulumiyaml/testing/test/testdata/*.json
pkg/tests/transpiled_examples/**/tsconfig.json

command-output/
obj/
Expand Down
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ GO := go
.phony: .EXPORT_ALL_VARIABLES
.EXPORT_ALL_VARIABLES:

default: ensure build

get_plugins::
pulumi plugin install resource aws ${PLUGIN_VERSION_AWS}
pulumi plugin install resource random ${PLUGIN_VERSION_RANDOM}
Expand Down
12 changes: 2 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,7 @@ runtime: yaml
description: Basic example of an AWS web server accessible over HTTP
configuration:
InstanceType:
type: String
default: t3.micro
allowedValues:
- t3.micro
- t3.small
- m4.large
description: Enter t3.micro, t3.small, or m4.large. Default is t3.micro.
variables:
AmazonLinuxAmi:
Fn::Invoke:
Expand Down Expand Up @@ -129,14 +123,12 @@ The supported expression forms for each of these is detailed below.

### Configuration

The value of `configuration` is an object whose keys are logical names by which the config input will be referenced in expressions within the program, and whose values are elements of the schema below. Each item in this object represents an independent config input.
The value of `configuration` is an object whose keys are logical names by which the config input will be referenced in expressions within the program, and whose values are elements of the schema below. Each item in this object represents an independent config input. Either `type` or `default` is required.

| Property | Type | Required | Expression | Description |
| ------------- |---|-------------| -----|---|
| `type` | string | Yes | No | Type is the (required) data type for the parameter. It can be one of: `String`, `Number`, `List<Number>`, or `CommaDelimitedList`. |
| `type` | string | No | No | Type is the (required) data type for the parameter. It can be one of: `String`, `Number`, `List<Number>`, or `List<String>`. |
| `default` | any | No | No | Default is a value of the appropriate type for the template to use if no value is specified. |
| `default` | any | No | No | Default is a value of the appropriate type for the template to use if no value is specified. |
| `secret` | bool | No | No | Secret masks the parameter by marking it a secret. |

### Resources

Expand Down
4 changes: 1 addition & 3 deletions examples/webserver-json/Main.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
"Configuration": {
"InstanceType": {
"type": "String",
"default": "t3.micro",
"allowedValues": ["t3.micro", "t3.small", "m4.large"],
"description": "Enter t3.micro, t3.small, or m4.large. Default is t3.micro."
"default": "t3.micro"
}
},
"Resources": {
Expand Down
11 changes: 3 additions & 8 deletions examples/webserver/Pulumi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,6 @@ configuration:
InstanceType:
type: String
default: t3.micro
allowedValues:
- t3.micro
- t3.small
- m4.large
description: Enter t3.micro, t3.small, or m4.large. Default is t3.micro.
variables:
ec2ami:
Fn::Invoke:
Expand All @@ -36,9 +31,9 @@ resources:
instanceType: ${InstanceType}
ami: ${ec2ami}
userData: |-
#!/bin/bash
echo 'Hello, World from ${WebSecGrp.arn}!' > index.html
nohup python -m SimpleHTTPServer 80 &
#!/bin/bash
echo 'Hello, World from ${WebSecGrp.arn}!' > index.html
nohup python -m SimpleHTTPServer 80 &
vpcSecurityGroupIds:
- ${WebSecGrp}
UsEast2Provider:
Expand Down
8 changes: 4 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,10 @@ require (
github.com/hexops/autogold v1.3.0
github.com/iancoleman/strcase v0.2.0
github.com/pkg/errors v0.9.1
github.com/pulumi/pulumi/pkg/v3 v3.28.1-0.20220403145459-1d215c2c0c99
github.com/pulumi/pulumi/sdk/v3 v3.28.1-0.20220403145459-1d215c2c0c99
github.com/spf13/cast v1.4.1
github.com/pulumi/pulumi/pkg/v3 v3.29.2-0.20220419113532-59a4786a5f98
github.com/pulumi/pulumi/sdk/v3 v3.29.2-0.20220419113532-59a4786a5f98
github.com/spf13/cobra v1.4.0
github.com/stretchr/testify v1.7.0
github.com/stretchr/testify v1.7.1
github.com/zclconf/go-cty v1.10.0
google.golang.org/grpc v1.44.0
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b
Expand Down Expand Up @@ -116,6 +115,7 @@ require (
github.com/santhosh-tekuri/jsonschema/v5 v5.0.0 // indirect
github.com/sergi/go-diff v1.2.0 // indirect
github.com/shurcooL/go-goon v0.0.0-20210110234559-7585751d9a17 // indirect
github.com/spf13/cast v1.4.1 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/src-d/gcfg v1.4.0 // indirect
github.com/texttheater/golang-levenshtein v1.0.1 // indirect
Expand Down
31 changes: 19 additions & 12 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@ github.com/Microsoft/hcsshim v0.8.9/go.mod h1:5692vkUqntj1idxauYlpoINNKeqCiG6Sg3
github.com/Netflix/go-expect v0.0.0-20180615182759-c93bf25de8e8 h1:xzYJEypr/85nBpB11F9br+3HUrpgb+fcm5iADzXXYEw=
github.com/Netflix/go-expect v0.0.0-20180615182759-c93bf25de8e8/go.mod h1:oX5x61PbNXchhh0oikYAH+4Pcfw5LKv21+Jnpr6r6Pc=
github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
github.com/StackExchange/wmi v1.2.1/go.mod h1:rcmrprowKIVzvc+NUiLncP2uuArMWLCbu9SBzvHz7e8=
github.com/agext/levenshtein v1.2.1/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558=
github.com/agext/levenshtein v1.2.3 h1:YB2fHEn0UJagG8T1rrWknE3ZQzWM06O8AMAatNn7lmo=
github.com/agext/levenshtein v1.2.3/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558=
Expand Down Expand Up @@ -272,7 +271,7 @@ github.com/go-ldap/ldap/v3 v3.1.3/go.mod h1:3rbOH3jRS2u6jg2rJnKAMLE/xQyCKIveG2Sa
github.com/go-ldap/ldap/v3 v3.1.10/go.mod h1:5Zun81jBTabRaI8lzN7E1JjyEl1g6zI6u9pd8luAK4Q=
github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE=
github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk=
github.com/go-ole/go-ole v1.2.5/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0=
github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0=
github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4=
github.com/go-playground/locales v0.13.0/go.mod h1:taPMhCMXrRLJO55olJkUXHZBHCxTMfnGwq/HNwmWNS8=
github.com/go-playground/universal-translator v0.17.0/go.mod h1:UkSxE5sNxxRwHyU+Scu5vgOQjsIJAF8j9muTVoKLVtA=
Expand Down Expand Up @@ -522,6 +521,7 @@ github.com/kylelemons/godebug v0.0.0-20170820004349-d65d576e9348/go.mod h1:B69LE
github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII=
github.com/lib/pq v1.10.0/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
github.com/lib/pq v1.10.1/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0/go.mod h1:zJYVVT2jmtg6P3p1VtQj7WsuWi/y4VnjVBn7F8KPB3I=
github.com/lyft/protoc-gen-star v0.5.3/go.mod h1:V0xaHgaf5oCCqmcxYcWiDfTiKsZsRc87/1qhoTACD8w=
github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE=
Expand Down Expand Up @@ -622,6 +622,7 @@ github.com/pkg/term v1.1.0/go.mod h1:E25nymQcrSllhX42Ok8MRm1+hyBdHY0dCeiKZ9jpNGw
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI=
github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c/go.mod h1:OmDBASR4679mdNQnz2pUhc2G8CO2JrUAVFDRBDP/hJE=
github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
github.com/prometheus/client_golang v0.9.2/go.mod h1:OsXs2jCmiKlQ1lTBmv21f2mNfw4xf/QclQDMrYNZzcM=
github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo=
Expand All @@ -638,11 +639,15 @@ github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R
github.com/prometheus/procfs v0.0.0-20181204211112-1dc9a6cbc91a/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA=
github.com/prometheus/procfs v0.0.8/go.mod h1:7Qr8sr6344vo1JqZ6HhLceV9o3AJ1Ff+GxbHq6oeK9A=
github.com/pulumi/pulumi/pkg/v3 v3.28.1-0.20220403145459-1d215c2c0c99 h1:NWjuJtb9vCYC8vs0ahzD9vzoBnKgeihzlGA5cGPRRgI=
github.com/pulumi/pulumi/pkg/v3 v3.28.1-0.20220403145459-1d215c2c0c99/go.mod h1:9ekPDFJQh5JAD+D77PKZ9zxz07Z7F5uf0NRIlb48nYM=
github.com/pulumi/pulumi/sdk/v3 v3.28.0/go.mod h1:Oe6AnW5MjJE5X2UJeqeXm1Al7qahdLVhIPeiKuoqxAw=
github.com/pulumi/pulumi/sdk/v3 v3.28.1-0.20220403145459-1d215c2c0c99 h1:VCgDjpYMgatjqqOvYUMzb60Lxa8FsRHkEIkpJfEoEmg=
github.com/pulumi/pulumi/sdk/v3 v3.28.1-0.20220403145459-1d215c2c0c99/go.mod h1:zCgseXSeBSkoQujmOF1z90+jFEvoRxN9JsGYy8wDwfo=
github.com/pulumi/pulumi/pkg/v3 v3.29.2-0.20220419100654-c15e62af0f85 h1:iJvRDQA7zq8ZrCM051ypOkrlm36+GCCjRG2/ZWozcsc=
github.com/pulumi/pulumi/pkg/v3 v3.29.2-0.20220419100654-c15e62af0f85/go.mod h1:wOTTW/ULc8G+3A1I5UJG8r+pRiKmVJ+j+9N4PNZQQbc=
github.com/pulumi/pulumi/pkg/v3 v3.29.2-0.20220419113532-59a4786a5f98 h1:3qiOiL5WOfOA1gYOVsxSj8GV82cGYceNRxOOpQ5lU1g=
github.com/pulumi/pulumi/pkg/v3 v3.29.2-0.20220419113532-59a4786a5f98/go.mod h1:wOTTW/ULc8G+3A1I5UJG8r+pRiKmVJ+j+9N4PNZQQbc=
github.com/pulumi/pulumi/sdk/v3 v3.29.1/go.mod h1:X0d8KA7ik+LeX8iMrAOueFjMi8tA8uRCzbItyuwCjIQ=
github.com/pulumi/pulumi/sdk/v3 v3.29.2-0.20220419100654-c15e62af0f85 h1:tLuF7YHiwpIPiRCn84RvVRYqOBJ04uhjpRjvWrMl8U0=
github.com/pulumi/pulumi/sdk/v3 v3.29.2-0.20220419100654-c15e62af0f85/go.mod h1:hGo/+AL1L4sPL9Ukd/i5bNFM3WHs3dHcA+GKEW7M3RA=
github.com/pulumi/pulumi/sdk/v3 v3.29.2-0.20220419113532-59a4786a5f98 h1:76Kma4Qji+vjmb9n0pPLEvt9FTECeNsu0UK6W7ChP6s=
github.com/pulumi/pulumi/sdk/v3 v3.29.2-0.20220419113532-59a4786a5f98/go.mod h1:hGo/+AL1L4sPL9Ukd/i5bNFM3WHs3dHcA+GKEW7M3RA=
github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY=
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
github.com/rjeczalik/notify v0.9.2 h1:MiTWrPj55mNDHEiIX5YUSKefw/+lCQVoAFmD6oQm5w8=
Expand All @@ -665,7 +670,7 @@ github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAm
github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM=
github.com/sergi/go-diff v1.2.0 h1:XU+rvMAioB0UC3q1MFrIQy4Vo5/4VsRDQQXHsEya6xQ=
github.com/sergi/go-diff v1.2.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM=
github.com/shirou/gopsutil v3.21.7+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA=
github.com/shirou/gopsutil/v3 v3.22.3/go.mod h1:D01hZJ4pVHPpCTZ3m3T2+wDF2YAGfd+H4ifUguaQzHM=
github.com/shurcooL/go-goon v0.0.0-20170922171312-37c2f522c041/go.mod h1:N5mDOmsrJOB+vfqUK+7DmDyjhSLIIBnXo9lvZJj3MWQ=
github.com/shurcooL/go-goon v0.0.0-20210110234559-7585751d9a17 h1:lRAUE0dIvigSSFAmaM2dfg7OH8T+a8zJ5smEh09a/GI=
github.com/shurcooL/go-goon v0.0.0-20210110234559-7585751d9a17/go.mod h1:N5mDOmsrJOB+vfqUK+7DmDyjhSLIIBnXo9lvZJj3MWQ=
Expand Down Expand Up @@ -703,13 +708,14 @@ github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UV
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.1 h1:5TQK59W5E3v0r2duFAb7P95B6hEeOyEnHRa8MjYSMTY=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/texttheater/golang-levenshtein v0.0.0-20191208221605-eb6844b05fc6/go.mod h1:XDKHRm5ThF8YJjx001LtgelzsoaEcvnA7lVWz9EeX3g=
github.com/texttheater/golang-levenshtein v1.0.1 h1:+cRNoVrfiwufQPhoMzB6N0Yf/Mqajr6t1lOv8GyGE2U=
github.com/texttheater/golang-levenshtein v1.0.1/go.mod h1:PYAKrbF5sAiq9wd+H82hs7gNaen0CplQ9uvm6+enD/8=
github.com/tklauser/go-sysconf v0.3.8/go.mod h1:z4zYWRS+X53WUKtBcmDg1comV3fPhdQnzasnIHUoLDU=
github.com/tklauser/numcpus v0.2.3/go.mod h1:vpEPS/JC+oZGGQ/My/vJnNsvMDQL6PwOqt8dsCw5j+E=
github.com/tklauser/go-sysconf v0.3.10/go.mod h1:C8XykCvCb+Gn0oNCWPIlcb0RuglQTYaQ2hGm7jmxEFk=
github.com/tklauser/numcpus v0.4.0/go.mod h1:1+UI3pD8NW14VMwdgJNJ1ESk2UnwhAnz5hMwiKKqXCQ=
github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM=
github.com/tweekmonster/luser v0.0.0-20161003172636-3fa38070dbd7 h1:X9dsIWPuuEJlPX//UmRKophhOKCGXc46RVIGuttks68=
github.com/tweekmonster/luser v0.0.0-20161003172636-3fa38070dbd7/go.mod h1:UxoP3EypF8JfGEjAII8jx1q8rQyDnX8qdTCs/UQBVIE=
Expand Down Expand Up @@ -739,6 +745,7 @@ github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9de
github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
github.com/yusufpapurcu/wmi v1.2.2/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0=
github.com/zclconf/go-cty v1.2.0/go.mod h1:hOPWgoHbaTUnI5k4D2ld+GRpFJSCe6bCM7m1q/N4PQ8=
github.com/zclconf/go-cty v1.3.1/go.mod h1:YO23e2L18AG+ZYQfSobnY4G65nvwvprPCxBHkufUH1k=
github.com/zclconf/go-cty v1.8.0/go.mod h1:vVKLxnk3puL4qRAv72AO+W99LUD4da90g3uUAzyuvAk=
Expand Down Expand Up @@ -966,6 +973,7 @@ golang.org/x/sys v0.0.0-20200909081042-eff7692f9009/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201201145000-ef89a241ccb3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201204225414-ed752295db88/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210104204734-6f8348627aad/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
Expand All @@ -989,7 +997,6 @@ golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.0.0-20210616094352-59db8d763f22/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210806184541-e5e7981a1069/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210816074244-15123e1e1f71/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210816183151-1e6c022a8912/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210817190340-bfb29a6856f2/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210823070655-63515b42dcdf/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
Expand Down
5 changes: 2 additions & 3 deletions pkg/pulumiyaml/analyser.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,11 +223,10 @@ func (e walker) EvalConfig(r *runner, node configNode) bool {
if !e.walk(ctx, node.Key) {
return false
}
c := node.Value
if !e.walk(ctx, c.Secret) {
if !e.walk(ctx, node.Value.Default) {
return false
}
if !e.walk(ctx, c.Default) {
if !e.walk(ctx, node.Value.Secret) {
return false
}
}
Expand Down
25 changes: 6 additions & 19 deletions pkg/pulumiyaml/ast/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -248,40 +248,27 @@ type ConfigParamDecl struct {
declNode

Type *StringExpr
Default *StringExpr
Secret *BooleanExpr

// TODO:

// List copied from template.go. While these fields are not currently used,
// they are necessary to avoid invalid field errors.
AllowedPattern *StringExpr
AllowedValues *ListExpr
ConstraintDescription *StringExpr
Description *StringExpr
MaxLength *NumberExpr
MaxValue *NumberExpr
MinLength *NumberExpr
MinValue *NumberExpr
Default Expr
}

func (d *ConfigParamDecl) recordSyntax() *syntax.Node {
return &d.syntax
}

func ConfigParamSyntax(node *syntax.ObjectNode, typ *StringExpr, defaultValue *StringExpr,
secret *BooleanExpr) *ConfigParamDecl {
func ConfigParamSyntax(node *syntax.ObjectNode, typ *StringExpr,
secret *BooleanExpr, defaultValue Expr) *ConfigParamDecl {

return &ConfigParamDecl{
declNode: decl(node),
Type: typ,
Default: defaultValue,
Secret: secret,
Default: defaultValue,
}
}

func ConfigParam(typ *StringExpr, defaultValue *StringExpr, secret *BooleanExpr) *ConfigParamDecl {
return ConfigParamSyntax(nil, typ, defaultValue, secret)
func ConfigParam(typ *StringExpr, defaultValue Expr, secret *BooleanExpr) *ConfigParamDecl {
return ConfigParamSyntax(nil, typ, secret, defaultValue)
}

type ResourceOptionsDecl struct {
Expand Down
2 changes: 2 additions & 0 deletions pkg/pulumiyaml/codegen/gen_program_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,8 @@ func TestGenerateProgram(t *testing.T) {
// Note: aws-s3-folder errors with
// 14,27-52: the asset parameter must be a string literal; the asset parameter must be a string literal
// But the actual error is that it is using a Splat operator.
case "python-resource-names":
// Reason: A python only test.
default:
l = append(l, tt)
}
Expand Down
38 changes: 31 additions & 7 deletions pkg/pulumiyaml/codegen/load.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,25 +209,43 @@ func (imp *importer) importJoin(node *ast.JoinExpr) (model.Expression, syntax.Di
//
func (imp *importer) importBuiltin(node ast.BuiltinExpr) (model.Expression, syntax.Diagnostics) {
switch node := node.(type) {
case *ast.StringAssetExpr:
path, pdiags := imp.importExpr(node.Source, nil)
return &model.FunctionCallExpression{
Name: "stringAsset",
Args: []model.Expression{path},
}, pdiags

case *ast.FileAssetExpr:
path, pdiags := imp.importExpr(node.Source, nil)
return &model.FunctionCallExpression{
Name: "fileAsset",
Args: []model.Expression{path},
}, pdiags
case *ast.RemoteAssetExpr:
path, pdiags := imp.importExpr(node.Source, nil)
return &model.FunctionCallExpression{
Name: "remoteAsset",
Args: []model.Expression{path},
}, pdiags
case *ast.FileArchiveExpr:
path, pdiags := imp.importExpr(node.Source, nil)
return &model.FunctionCallExpression{
Name: "fileArchive",
Args: []model.Expression{path},
}, pdiags
case *ast.StringAssetExpr:
case *ast.RemoteArchiveExpr:
path, pdiags := imp.importExpr(node.Source, nil)
return &model.FunctionCallExpression{
Name: "fileArchive",
Name: "remoteArchive",
Args: []model.Expression{path},
}, pdiags
case *ast.AssetArchiveExpr:
path, pdiags := imp.importExpr(node.Args(), nil)
return &model.FunctionCallExpression{
Name: "assetArchive",
Args: []model.Expression{path},
}, pdiags

case *ast.InvokeExpr:
var diags syntax.Diagnostics

Expand Down Expand Up @@ -395,7 +413,7 @@ func importParameterType(s string) (string, bool) {
return "number", true
case "List<Number>":
return "list(number)", true
case "CommaDelimitedList", "List<String>":
case "List<String>":
return "list(string)", true
default:
return "", false
Expand All @@ -406,9 +424,15 @@ func importParameterType(s string) (string, bool) {
func (imp *importer) importConfig(kvp ast.ConfigMapEntry) (model.BodyItem, syntax.Diagnostics) {
name, config := kvp.Key.Value, kvp.Value

typeExpr, ok := importParameterType(config.Type.Value)
if !ok {
return nil, syntax.Diagnostics{ast.ExprError(config.Type, fmt.Sprintf("unrecognized type '%v' for config variable '%s'", config.Type.Value, name), "")}
var typeExpr string
if config.Type != nil {
var ok bool
typeExpr, ok = importParameterType(config.Type.Value)
if !ok {
return nil, syntax.Diagnostics{ast.ExprError(config.Type, fmt.Sprintf("unrecognized type '%v' for config variable '%s'", config.Type.Value, name), "")}
}
} else {
typeExpr = "string"
}

configVar, ok := imp.configuration[name]
Expand Down
Loading