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

--stack option broken in pulumi CLI #2880

Closed
d-nishi opened this issue Jun 26, 2019 · 8 comments · Fixed by #3131
Closed

--stack option broken in pulumi CLI #2880

d-nishi opened this issue Jun 26, 2019 · 8 comments · Fixed by #3131
Assignees
Labels
kind/bug Some behavior is incorrect or out of spec
Milestone

Comments

@d-nishi
Copy link

d-nishi commented Jun 26, 2019

Use Case: In order to enable automation of multiple stacks within one project or multiple projects, a user may need to non-interactively program the stack option in 1 go.

$ mkdir myeks && cd myeks && pulumi new aws-typescript --name myeks --description "my eks cluster" -c aws:region=us-west-2 works as expected however

$ mkdir myeks && cd myeks && pulumi new aws-typescript --name myeks --description "my eks cluster" -c aws:region=us-west-2 --stack d-nishi/dev throws the following error:

error: no Pulumi project found in the current working directory.

@d-nishi
Copy link
Author

d-nishi commented Jun 26, 2019

@arun-gupta -- FYI.

@justinvp
Copy link
Member

justinvp commented Jun 27, 2019

There's a related discussion in #2614

This is fallout from changing stack identities to include the project name. The code we use to parse stack names, used throughout the CLI, will attempt to lookup the project name if it wasn't included in the stack name. It does this by looking for the project name in Pulumi.yaml, but in this case, the lookup fails because this is happening before we've laid down the project files, so Pulumi.yaml doesn't exist.

The fix is to be smarter about this in pulumi new. If we know what the project name is going to be (e.g. when --name is specified explicitly, or when --yes is used to accept the default suggested project name, etc.) we should just use that as the project in the stack name, rather than trying to look it up in a non-existent Pulumi.yaml file.

In the meantime, this can be worked around by specifying a fully qualified stack name that includes the project name, e.g.:

$ mkdir myeks && cd myeks && pulumi new aws-typescript --name myeks --description "my eks cluster" -c aws:region=us-west-2 --stack d-nishi/myeks/dev

@ellismg ellismg added this to the 0.25 milestone Jun 27, 2019
@ellismg ellismg added the kind/bug Some behavior is incorrect or out of spec label Jun 27, 2019
@stack72
Copy link
Contributor

stack72 commented Jun 28, 2019

@d-nishi is this also related to / duplicate of #2822 ?

@chrsmith chrsmith assigned chrsmith and unassigned ellismg Jul 19, 2019
@chrsmith
Copy link
Contributor

I'll take a swing at this while Matt is out.

@justinvp
Copy link
Member

@chrsmith, mind if I take this? I already have a bunch of context paged in memory.

@justinvp
Copy link
Member

Some cases to consider:

  • pulumi new typescript --name myproj --stack myorg/mystack: Project determined by --name
  • pulumi new typescript --yes --stack myorg/mystack: We could have this use the default value that would be used for the project name, but I'm leaning towards just not supporting this case as the behavior of using the default value is non-obvious.
  • pulumi new typescript --name foo --stack myorg/bar/mystack: Should we error since the project specified to --name doesn't match the project in the stack name?
  • pulumi new typescript --stack myorg/myproj/mystack: Should we extract the project name from the stack name in this case as if it was specified to --name?

@justinvp justinvp assigned mikhailshilkov and unassigned justinvp Aug 13, 2019
@mikhailshilkov
Copy link
Member

I'll be able to fix this with tests when #3065 is reviewed and merged

@mikhailshilkov
Copy link
Member

pulumi new typescript --name myproj --stack myorg/mystack

Agreed. Same for pulumi new typescript --name myproj --stack mystack

pulumi new typescript --yes --stack myorg/mystack: We could have this use the default value that would be used for the project name, but I'm leaning towards just not supporting this case as the behavior of using the default value is non-obvious.

Currently, it takes the default value of the folder name. I think this makes sense, at least I go forward with the suggested default most of the time. I suggest to keep it.

pulumi new typescript --name foo --stack myorg/bar/mystack: Should we error since the project specified to --name doesn't match the project in the stack name?
pulumi new typescript --stack myorg/myproj/mystack: Should we extract the project name from the stack name in this case as if it was specified to --name?

These are tricky:

  1. Project name is a part of the stack name only for the pulumi backend. Therefore, it's a black box for the pulumi new command: currently, it doesn't know about the project in there at all.
  2. The shape org/proj/stack is not allowed for the prompted stack name.

My preference would be bring stack argument on par with the prompted value and disallow the org/proj/stack shape. If we don't want to make breaking changes, we can keep the current status-quo, or maybe add a warning.

Keeping #3076 in mind, it makes sense to me to just have three independent arguments for the owner, project, and stack.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Some behavior is incorrect or out of spec
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants