-
Notifications
You must be signed in to change notification settings - Fork 212
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
Refactoring before adding reconcilation #1753
Conversation
Installation.Parameters should reflect parameter values that the user selected, similar to --param on the command line. It shouldn't contain any resolved values, such as from parameter sets as we already track those on the Installation.ParameterSets field. Signed-off-by: Carolyn Van Slyck <[email protected]>
When we output an installation with porter installation show, the data available in the plaintext version should be comparable to what's in the json/yaml output. Now that we are displaying all resolved parameters, but only storing the user-provided parameters on the installation record, we need to output more than just the installation record for those output formats. I have changed DisplayInstallation to better wrap an Installation record, and then put all calculated fields into _calculated so that people can easily tell which fields are associated with the record (and can be changed when imported) and which ones are informational only. Signed-off-by: Carolyn Van Slyck <[email protected]>
Signed-off-by: Carolyn Van Slyck <[email protected]>
When I refactored, it causes a bunch of errors when running a bundle with dependencies because I wasn't creating an explicit installation record for the dependency. I have updated the code so that an installation is created and labled with sh.porter.parentInstallation = installation namespace/name so that later we can filter them out if we want to. Signed-off-by: Carolyn Van Slyck <[email protected]>
/azp run porter-integration |
Azure Pipelines successfully started running 1 pipeline(s). |
Signed-off-by: Carolyn Van Slyck <[email protected]>
Print the params and creds passed to a bundle, including their values. Make sure that sensitive values are censored. Signed-off-by: Carolyn Van Slyck <[email protected]>
/azp run porter-integration |
Azure Pipelines successfully started running 1 pipeline(s). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great, just a few questions.
@@ -239,6 +239,10 @@ func (o *bundleFileOptions) validateCNABFile(cxt *context.Context) error { | |||
// LoadParameters validates and resolves the parameters and sets. It must be | |||
// called after porter has loaded the bundle definition. | |||
func (o *sharedOptions) LoadParameters(p *Porter) error { | |||
if o.combinedParameters != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add a comment here around this logic? Do we return immediately because o.combinedParameters being non-nil means they've been processed sufficiently?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup, it's because I noticed that we were re-processing the parameters, so this detects if we've already done it. I'll add a comment.
resolvedparameters: | ||
- name: logLevel | ||
type: integer | ||
sensitive: false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When a resolved parameter is sensitive, is value omitted? Or perhaps populated with *******
?
Do we want/need to add a param of this type for these tests? Or covered sufficiently elsewhere?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in plain text output we *** out the value, in json/yaml we don't so that people can actually read and use it.
I had commented these out while refactoring, and forgot to add them back when I was done. Signed-off-by: Carolyn Van Slyck <[email protected]>
/azp run porter-integration |
Azure Pipelines successfully started running 1 pipeline(s). |
Signed-off-by: Carolyn Van Slyck <[email protected]>
/azp run porter-integration |
Azure Pipelines successfully started running 1 pipeline(s). |
I've fixed the merge conflict and found a few unit tests that I had commented out while refactoring, so I uncommented them out and re-kicked off all the builds to make sure I didn't break anything. |
The porter state file is not always present for bundles that do not use state. So skip over it when it's not found as a parameter. Signed-off-by: Carolyn Van Slyck <[email protected]>
What does this change
Only store parameter overrides on the installation record
Installation.Parameters should reflect parameter values that the user selected, similar to --param on the command line. It shouldn't contain any resolved values, such as from parameter sets as we already track those on the installation.ParameterSets field.
Include calculated parameters in the json/yaml output
When we output an installation with porter installation show, the data available in the plaintext version should be comparable to what's in the json/yaml output. Now that we are displaying all resolved parameters, but only storing the user-provided parameters on the installation record, we need to output more than just the installation record for those output formats.
I have changed DisplayInstallation to better wrap an Installation record, and then put all calculated fields into _calculated so that people can easily tell which fields are associated with the record (and can be changed when imported) and which ones are informational only.
Fix test database creation
The timeout was set to 0 when checking if there was an existing dev database that we could reuse. I thought 0 meant no timeout, but it means "timeout immediately". So we were always skipping the existing dev database. I've set a default in the database plugin so that we can't accidentally immediately timeout again.
Create an installation record for dependencies
When I refactored, it causes a bunch of errors when running a bundle with dependencies because I wasn't creating an explicit installation record for the dependency.
I have updated the code so that an installation is created and labeled with the following so that later we can filter them out if we want to:
Fix how we resolve parameters for dependencies
This ensures that we use the relocated resolveParameters function when running a dependency, and that the final set of parameter used for the root bundle includes resolved parameters from the dependencies.
Print params/creds before the bundle is run
Print the params and creds passed to a bundle, including their values. Make sure that sensitive values are censored.
I was having a hell of a time debugging and once we have #1729 merged, it's super useful.
What issue does it fix
This is refactoring prep-work for the new reconcillation capabilities of porter installation apply. The installation record should only contain desired state and not include any status values. Otherwise it's really hard to reconcile and determine when changes should be made.
Notes for the reviewer
N/A
Checklist