Improve StackReference error message

Because of the change to include a stack's project as part of its
identity in the service, the names passed to StackReference now
require the project name as well.

Improve the error message when they do not include them.
This commit is contained in:
Matt Ellis 2019-01-30 15:57:44 -08:00
parent 1d5526d292
commit 50c2ebbdd5
2 changed files with 21 additions and 1 deletions

View file

@ -2,12 +2,16 @@
### Improvements
- Issue a more perscriptive error when using StackReference and the name of the stack to reference is not of the form `<organization>/<project>/<stack>`.
## 0.16.12 (Released January 25th, 2019)
### Major Changes
- When using the cloud backend, stack names now must only be unique within a project, instead of across your entire account. Starting with version of 0.16.12 the CLI, you can create stacks with duplicate names. If an account has multiple stacks with the same name across different projects, you must use 0.16.12 or later of the CLI to manage them.
**BREAKING CHANGE NOTICE**: As part of the above change, when using the 0.16.12 CLI (or a later version) the names passed to `StackReference` must be updated to be of the form (`<organization>/<project>/<stack>`) e.g. `acmecorp/infra/dev` to refer to the `dev` stack of the `infra` project in the `acmecorp` organization.
### Improvements
- Add `--json` to `pulumi config`, `pulumi config get`, `pulumi history` and `pulumi plugin ls` to request the output be in JSON.

View file

@ -47,6 +47,7 @@ import (
"github.com/pulumi/pulumi/pkg/diag/colors"
"github.com/pulumi/pulumi/pkg/engine"
"github.com/pulumi/pulumi/pkg/operations"
"github.com/pulumi/pulumi/pkg/resource"
"github.com/pulumi/pulumi/pkg/resource/config"
"github.com/pulumi/pulumi/pkg/resource/deploy"
"github.com/pulumi/pulumi/pkg/tokens"
@ -811,7 +812,7 @@ func (b *cloudBackend) runEngineAction(
Cancel: cancellationScope.Context(),
Events: engineEvents,
SnapshotManager: snapshotManager,
BackendClient: backend.NewBackendClient(b),
BackendClient: httpstateBackendClient{backend: b},
}
if parentSpan := opentracing.SpanFromContext(ctx); parentSpan != nil {
engineCtx.ParentSpan = parentSpan.Context()
@ -1222,3 +1223,18 @@ func (b *cloudBackend) UpdateStackTags(ctx context.Context,
return b.client.UpdateStackTags(ctx, stack, tags)
}
type httpstateBackendClient struct {
backend Backend
}
func (c httpstateBackendClient) GetStackOutputs(ctx context.Context, name string) (resource.PropertyMap, error) {
// When using the cloud backend, require that stack references are fully qualified so they
// look like "<org>/<project>/<stack>"
if strings.Count(name, "/") != 2 {
return nil, errors.Errorf("a stack reference's name should be of the form " +
"'<organization>/<project>/<stack>'. See https://pulumi.io/help/stack-reference for more information.")
}
return backend.NewBackendClient(c.backend).GetStackOutputs(ctx, name)
}