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

Only include required install params in explain command #1875

Merged
merged 1 commit into from
Jan 31, 2022

Conversation

carolynvs
Copy link
Member

What does this change

When porter explain prints a suggested installation command, it should
only include parameters that are required and apply to the install
command. Parameters can be limited to only apply to a particular action
and if it doesn't apply to install, we don't want to tell people to
specify in for porter install.

What issue does it fix

I found this when running porter explain on the operator bundle, which has a parameter that only applies to the configureNamespace action.

Notes for the reviewer

N/A

Checklist

  • Did you write tests?
  • Did you write documentation?
  • Did you change porter.yaml or a storage document record? Update the corresponding schema file.
  • If this is your first pull request, please add your name to the bottom of our Contributors list. Thank you for making Porter better! 🙇‍♀️

Reviewer Checklist

  • Comment with /azp run test-porter-release if a magefile or build script was modified
  • Comment with /azp run porter-integration if it's a non-trivial PR

@carolynvs
Copy link
Member Author

/azp run porter-integration

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@carolynvs carolynvs marked this pull request as ready for review January 27, 2022 23:06
When porter explain prints a suggested installation command, it should
only include parameters that are required _and_ apply to the install
command. Parameters can be limited to only apply to a particular action
and if it doesn't apply to install, we don't want to tell people to
specify in for porter install.

Signed-off-by: Carolyn Van Slyck <[email protected]>
@carolynvs carolynvs force-pushed the fix-explain-install-cmd branch from 0e5a31d to 65fa0e6 Compare January 28, 2022 23:40
@@ -230,6 +231,7 @@ func generatePrintable(bun cnab.ExtendedBundle, action string) (*PrintableBundle
sort.Sort(SortPrintableCredential(pb.Credentials))

for p, v := range bun.Parameters {
v := v // Go closures are funny like that
Copy link
Contributor

Choose a reason for hiding this comment

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

@carolynvs May I know the reason behind this one? Might be something that I haven't known yet about Go 😕

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah it's super obscure and a really annoying part of how Go handles "closures". If you search for "golang for loop closure" you'll find a lot of articles on it.

Without this hack, when I save off a reference to v on the display parameter, it ends up with all parameters having a reference to the same address instead of each display parameter getting a reference to its proper parameter.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, I just realized they mentioned it on the official repo. It's this one, right? Thank you for the nugget of knowledge, Carolyn! Appreciate it 😄

Copy link
Member Author

Choose a reason for hiding this comment

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

Yup! That is the problem I was working around. 👍

@carolynvs carolynvs merged commit 79ee7c3 into getporter:release/v1 Jan 31, 2022
@carolynvs carolynvs deleted the fix-explain-install-cmd branch January 31, 2022 15:25
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.

3 participants