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

Add state section to porter.yaml #1743

Merged
merged 8 commits into from
Sep 14, 2021
Merged

Conversation

carolynvs
Copy link
Member

@carolynvs carolynvs commented Aug 26, 2021

What does this change

  • Allow bundle authors to flag files as "state" that should be persisted by the bundle, but not exposed to the user (like a parameter or output is).

  • Allow file parameters to be optional. When injecting a parameter into the bundle and the type is "file" do not inject the word null into the file in the bundle, omit it. I have an open issue to correct this in upstream cnab-go Optional parameters are not injected properly cnabio/cnab-go#266.

  • Hide porter internal from explain command. Some outputs and parameters are really porter "plumbing". They are used by porter to implement things, like state or persistent parameters, but aren't intended to be set or used by the end-user.

    When we print out how to use a bundle with porter explain, those shouldn't be displayed.

    • Parameters with sources - these will be set by Porter internally.
    • Outputs and Parameters that support bundle state.

What issue does it fix

Implements the new state section proposed in #1672.

Notes for the reviewer

Preview of the state docs @ https://deploy-preview-1743--porter.netlify.app/author-bundles/#state

Checklist

  • Unit Tests
  • Documentation TODO
  • Schema (porter.yaml) TODO

@carolynvs carolynvs force-pushed the state2 branch 4 times, most recently from 4805848 to eda56ee Compare August 31, 2021 18:18
@carolynvs
Copy link
Member Author

/azp run porter-integration

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Allow bundle authors to flag files as "state" that should be persisted
by the bundle, but not exposed to the user (like a parameter or output
is).

Signed-off-by: Carolyn Van Slyck <me@carolynvanslyck.com>
Signed-off-by: Carolyn Van Slyck <me@carolynvanslyck.com>
Some outputs and parameters are really porter "plumbing". They are used
by porter to implement things, like state or persistent parameters, but
aren't intended to be set or used by the end-user.

When we print out how to use a bundle with porter explain, those
shoudn't be displayed.

* Parameters with sources - these will be set by Porter internally.
* Outputs and Parameters that support bundle state.

Signed-off-by: Carolyn Van Slyck <me@carolynvanslyck.com>
@carolynvs
Copy link
Member Author

/azp run porter-integration

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Allow integration tests to also use run commands using the porter CLI.

Signed-off-by: Carolyn Van Slyck <me@carolynvanslyck.com>
Signed-off-by: Carolyn Van Slyck <me@carolynvanslyck.com>
Signed-off-by: Carolyn Van Slyck <me@carolynvanslyck.com>
Signed-off-by: Carolyn Van Slyck <me@carolynvanslyck.com>
@carolynvs
Copy link
Member Author

/azp run porter

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@carolynvs
Copy link
Member Author

/azp run porter-integration

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@@ -179,7 +181,7 @@ func (c *ManifestConverter) generateBundleParameters(defs *definition.Definition
if !param.Destination.IsEmpty() {
p.Destination = &bundle.Location{
EnvironmentVariable: param.Destination.EnvironmentVariable,
Path: param.Destination.Path,
Path: manifest.ResolvePath(param.Destination.Path),
Copy link
Member Author

Choose a reason for hiding this comment

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

In a follow-up PR I want to use this function so that people can use relative paths not just for the state files, but for params and creds. That way we should see a lot less of hard-coding absolute paths like /cnab/app/mystuff, when they just use "mystuff" and assume that everything is relative to the bundle directory.

@@ -59,7 +59,7 @@ func TestPorter_Build(t *testing.T) {

stamp, err := configadapter.LoadStamp(bun)
require.NoError(t, err)
assert.Equal(t, "d421a6249dfbdba79e26e866da7533d59590565708dfdb32423cf989f588d0ea", stamp.ManifestDigest)
assert.NotEmpty(t, stamp.ManifestDigest)
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 gotten super tired of checking and updating the exact manifest digest. We just update it every time we tweak the bundle which isn't helpful.

}

// TODO(carolynvs): hack around parameters ALWAYS being injected even when empty files mess things up
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 logged a bug against cnab-go cnabio/cnab-go#266 and will work on fixing this after I get this stuff in.

@carolynvs carolynvs marked this pull request as ready for review September 9, 2021 22:23
Copy link
Member

@vdice vdice left a comment

Choose a reason for hiding this comment

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

Awesome UX improvement with these changes! LGTM.

return bigErr.ErrorOrNil()
}

// applyUnboundBundleOutputs find outputs that haven't been bound yet by a step,
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// applyUnboundBundleOutputs find outputs that haven't been bound yet by a step,
// applyUnboundBundleOutputs finds outputs that haven't been bound yet by a step,

Signed-off-by: Carolyn Van Slyck <me@carolynvanslyck.com>
@carolynvs carolynvs merged commit daa8983 into getporter:release/v1 Sep 14, 2021
@carolynvs carolynvs deleted the state2 branch September 14, 2021 17:00
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.

None yet

2 participants