pulumi/pkg
Joe Duffy 12e5e46c73
Handle blank project names in 'new' (#5504)
The logic for validating prompted values in 'new' wasn't quite right,
leading to the possibility of creating Pulumi.yaml files with blank
project names.

This manifests in various ways and I've hit it a number of times
over the past few months because of the way we handle project/stack
name conflicts in 'new' -- which itself is a bit annoying too:

https://github.com/pulumi/pulumi/blob/master/pkg/cmd/pulumi/new.go#L206-L207

Because we substitue a default value of "", and because the prompting
logic assumed default values are always valid, we would skip validation
and therefore accept a blank Pulumi.yaml file.

This generates an invalid project which causes errors elsewhere, such as

    error: failed to load Pulumi project located at ".../Pulumi.yaml":
        project is missing a 'name' attribute

I hit this all the time with our getting started guide because I've
gone through it so many times and have leftover stacks from prior
run-throughs. I wouldn't be surprised if a lot of people hit this.

The solution here validates all values, including the default.

Note also that we failed to validate the value used by 'new --yes'
which meant you could bypass all validation by passing --yes, leading
to similar outcomes.

I've added a couple new tests for these cases. There is a risk we
depend on illegal default values somewhere which will now be rejected,
but that would seem strange, and assuming the tests pass, I would
assume that's not true. Let me know if that's wrong.

Fixes pulumi/pulumi#3255.
2020-10-05 13:40:24 -07:00
..
backend Fix panic with logs (#5503) 2020-10-02 14:09:34 -07:00
cmd/pulumi Handle blank project names in 'new' (#5504) 2020-10-05 13:40:24 -07:00
codegen Ensure top-level precedence to avoid flaky tests (#5508) 2020-10-05 19:50:51 +02:00
engine Revise host mode. (#5317) 2020-09-14 17:40:17 -07:00
graph Breaking changes due to Feature 2.0 work 2020-04-14 09:30:25 +01:00
operations Breaking changes due to Feature 2.0 work 2020-04-14 09:30:25 +01:00
resource Revise host mode. (#5317) 2020-09-14 17:40:17 -07:00
secrets Breaking changes due to Feature 2.0 work 2020-04-14 09:30:25 +01:00
testing/integration Support remote components in Python (#5375) 2020-09-30 14:09:20 -07:00
util Breaking changes due to Feature 2.0 work 2020-04-14 09:30:25 +01:00
version duplicate version to ensure linking is properly handled 2020-03-19 12:49:34 -07:00
go.mod Merge branch 'master' of https://github.com/pulumi/pulumi into evan/auto 2020-08-24 17:51:40 -07:00
go.sum Support recursive object types in pkg/codegen model (#5404) 2020-09-18 17:29:21 -07:00