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

pulumi about outputs the fully qualified stack reference #11387

Merged
merged 5 commits into from Nov 30, 2022
Merged

Conversation

AaronFriel
Copy link
Member

@AaronFriel AaronFriel commented Nov 16, 2022

Resolves #11386

$ pulumi about 
# current output would go here until after this line:
Current Stack: dev

Fully qualified stack name: Fully qualified stack name: friel/tmp.knCczy5IiO/dev

Found no resources associated with dev

Found no pending operations associated with dev
# and regular output
$ pulumi about --json | jq '.currentStack.fullyQualifiedName'
"friel/tmp.knCczy5IiO/dev"

When there is no valid stack, the currentStack value is null.

Due to an existing bug, when the backend is filestate the currentStack value is null. It appears on filestate backends we do not render the current stack.

@pulumi-bot
Copy link
Contributor

pulumi-bot commented Nov 16, 2022

Changelog

[uncommitted] (2022-11-29)

Features

  • [cli/about] Add fully qualified stack name to current stack.
    #11387

result.StackReference = fmt.Sprintf("%v/%v/%v", parts[0], proj.Name, parts[1])
} else if result.CurrentStack != nil && result.Backend != nil {
// the stack name is $stack with the current user as the org
result.StackReference = fmt.Sprintf("%v/%v/%v", result.Backend.User, proj.Name, result.CurrentStack.Name)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't correct for filestate, also we should probably just ask the StackReference for the qualified name, rather than trying to reconstruct it.
Something like FullyQualifiedName() tokens.QName, which for filestate just returns the same as Name but for httpstate returns the full name regardless of the current defaults for org and project.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still want to implement stack refs for filestate, so for now would it be OK for filestate stacks (localBackend) to return nil or "" while we decide on how to handle the org?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've implemented this and (overdue? or duplicate?) opened #11390 so we can formally decide on this.

For local backends, we just don't render a fully qualified stack name.

@AaronFriel
Copy link
Member Author

@iwahbe @Frassle I made the change suggested to add FullyQualifiedName() to the StackReference interface, but as I'm OOO I'm OK with either of you taking over this branch and PR if we want to solve the customer ask.

It looks like filestate backends aren't supported in getCurrentStackAbout today, so no regression in this PR to not support that case. #11390 should track us properly implementing that as we'll want a test on pulumi about behavior.

@iwahbe iwahbe self-assigned this Nov 17, 2022
@Frassle
Copy link
Member

Frassle commented Nov 17, 2022

It looks like filestate backends aren't supported in getCurrentStackAbout

What? They definitely are:

Current Stack: test

TYPE                  URN
pulumi:pulumi:Stack   urn:pulumi:test::examplets::pulumi:pulumi:Stack::examplets-test
pulumi:providers:aws  urn:pulumi:test::examplets::pulumi:providers:aws::default_5_20_0
aws:s3/bucket:Bucket  urn:pulumi:test::examplets::aws:s3/bucket:Bucket::my-bucket


Found no pending operations associated with test

Backend
Name           IBASA-PC
URL            file://
User           fraser
Organizations

pkg/backend/filestate/backend.go Outdated Show resolved Hide resolved
pkg/cmd/pulumi/about.go Outdated Show resolved Hide resolved
pkg/cmd/pulumi/about.go Outdated Show resolved Hide resolved
@iwahbe iwahbe force-pushed the friel/about-ref branch 2 times, most recently from 1dbd84d to c0c0455 Compare November 18, 2022 01:25
pkg/backend/backend.go Outdated Show resolved Hide resolved
pkg/cmd/pulumi/about.go Outdated Show resolved Hide resolved
if stackName != current.FullyQualifiedName {
stackName += fmt.Sprintf(" (fully qualified to %q)", current.FullyQualifiedName)
}
return fmt.Sprintf("Current Stack: %s\n\n%s\n%s", stackName, resources, pending)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So this prints like:

Current Stack: stack (fully qualified to org/proj/stack)

I wonder if the "fully qualified to" text is needed. I wonder if the non-qualified name is even needed if we're doing a text print, like we clearly want to keep it as is for the json case but maybe this should just always print the fully qualified name now.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. I'll just print out the FQN if it exists.

@iwahbe
Copy link
Member

iwahbe commented Nov 30, 2022

bors r+
Test failures should be fixed with #11490

@bors
Copy link
Contributor

bors bot commented Nov 30, 2022

Build succeeded:

@bors bors bot merged commit beaf07d into master Nov 30, 2022
@bors bors bot deleted the friel/about-ref branch November 30, 2022 18:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CLI command(s) to output fully qualified stack name
4 participants