Updates to publishing: flags, invocation image tagging#1405
Updates to publishing: flags, invocation image tagging#1405vdice merged 8 commits intogetporter:mainfrom
Conversation
Signed-off-by: Vaughn Dice <vadice@microsoft.com>
Signed-off-by: Vaughn Dice <vadice@microsoft.com>
Signed-off-by: Vaughn Dice <vadice@microsoft.com>
|
Looks like the stamp constant changed for one of the tests, once that's updated the tests should pass. |
Signed-off-by: Vaughn Dice <vadice@microsoft.com>
carolynvs
left a comment
There was a problem hiding this comment.
Looks great! Thank you for the massive rename and logic switcharoo. Just had some questions to make sure I fully understand the change and then we are good to go.
| data = append(data, v...) | ||
|
|
||
| // (for instance, during publish), so add this to the data | ||
| data = append(data, c.Manifest.Image...) |
There was a problem hiding this comment.
Sorry I know we talked about this but I've gotten fuzzy over the holidays. Can you remind me why we can remove this? I am just wondering if the info is now in the generate manifest, or if we can't put it in anymore because the flag may have changed the value?
There was a problem hiding this comment.
I/we had added this previously to automatically trigger a rebuild whenever a bundle's image was updated. (Say, when a new registry or tag value is supplied on publish.) However, in this PR, instead of rebuilding the bundle, we re-tag images/bundle references and use these for publishing.
As noted elsewhere, it does mean that the actual contents (bundle.json/porter.yaml) included in the installer/invocation image may have different registry/reference values from the final published versions. For instance, the built bundle might have registry: myregistry.com but if I publish the bundle via porter publish --registry localhost:5000, the published invocation image (localhost:5000/mybuns:v0.1.0) will have a porter.yaml file with the original registry: myregistry.com field.
There was a problem hiding this comment.
Thanks for clearing that up. I know some users want to be able to publish to alternate locations, either because they moved it across an airgap or something else, and have the bundle not contain the original information. One workaround in that case would be to use non-sensitive information when building the bundle and then always set a --registry, etc during publish.
| @@ -47,6 +47,10 @@ type Manifest struct { | |||
| // and isn't meant to be user-specified | |||
| BundleTag string `yaml:"-"` | |||
There was a problem hiding this comment.
Do we use this field, BundleTag, to hold the final computed bundle reference? Or can we remove it?
There was a problem hiding this comment.
I see it used in code but it's super confusing and I think a relic from a previous config setting we removed. Now may be a real good time to get rid of it completely (in a follow-up).
There was a problem hiding this comment.
Do we use this field, BundleTag, to hold the final computed bundle reference? Or can we remove it?
Not anymore - now we use Reference to track the bundle reference. Indeed, BundleTag is ripe for removal. I can create an issue.
| if err := p.LoadManifestFrom(build.LOCAL_MANIFEST); err != nil { | ||
| return err | ||
| } | ||
| if err := p.LoadManifestFrom(build.LOCAL_MANIFEST); err != nil { |
There was a problem hiding this comment.
What is the flow when someone does publish --reference. Do we do a full rebuild, or do we only retag? I'm wondering why it's safe now to unconditionally load the generated manifest.
I'm not you asking to change anything, just making sure I understand the new workflow with these tags.
There was a problem hiding this comment.
Good question. Now, when a --reference override is supplied, we only retag (invocation image and final bundle reference). This does mean the bundle.json and porter.yaml files in the invocation image will be from the unchanged internal manifest.
There was a problem hiding this comment.
Can you document this new "re-tag not rebuild" behavior in the LongDescription of the porter publish command?
| porter bundle publish --file myapp/porter.yaml | ||
| porter bundle publish --archive /tmp/mybuns.tgz --tag myrepo/my-buns:0.1.0 | ||
| porter bundle publish --archive /tmp/mybuns.tgz --reference myrepo/my-buns:0.1.0 | ||
| porter bundle publish --tag latest |
There was a problem hiding this comment.
It's going to be a rough transition because we changed the meaning of this flag. How about in a follow-up we add validation for the publish options that checks if they are using --tag to specify the entire reference and error out explaining that the flags have changed?
We can identify that --tag contains a reference by checking for :/@, neither of which are allowed in a docker tag.
There was a problem hiding this comment.
Good point. I almost think it's warranted to delay this PR until another commit including this logic is pushed. WDYT? I can work on this.
There was a problem hiding this comment.
If you are up for it, that's great.
There was a problem hiding this comment.
Ok, I added logic to error accordingly for the tag option on publish.
Do we want to do something similar for the other commands that previously also had a tag opt (courtesy BundlePullOptions)? As it stands, users who try to invoke porter install --tag mybuns:v0.1.0 will just see a standard Error: unknown flag: --tag after this is merged (and need to check the docs to see --reference is the new opt). Naturally, in the release notes, we can note this breaking cli opt change... not sure if we should also bake in a deprecation warning or error.
There was a problem hiding this comment.
Yeah, we could add back a Tag field and flag definitions and then check if it was populated and give a better error message. It would just be temporary until 1.0 when hopefully we stop making breaking changes for a bit.
There was a problem hiding this comment.
Ok, added it back as a deprecated flag (in Cobra terms this means it'll hide the flag by default and produce a deprecation warning when a value is provided). When provided, we just assign reference to the value instead of explicitly erroring out -- WDYT?
Signed-off-by: Vaughn Dice <vadice@microsoft.com>
Signed-off-by: Vaughn Dice <vadice@microsoft.com>
| // A previous iteration of this flag was used to designate an entire bundle | ||
| // reference. If we detect this attempted use, we return an error and | ||
| // explanation | ||
| func (o *PublishOptions) validateTag() error { |
There was a problem hiding this comment.
Thanks for adding this! It will really help avoid a bunch of very unhappy users.
Signed-off-by: Vaughn Dice <vadice@microsoft.com>
|
|
||
| func addDeprecatedTagFlag(f *pflag.FlagSet, opts *porter.BundlePullOptions) { | ||
| f.StringVar(&opts.Tag, "tag", "", "") | ||
| f.MarkDeprecated("tag", "use --reference to declare a full bundle reference") |
There was a problem hiding this comment.
Will this print a warning so that they know it's been deprecated and that they should stop using it? If not, let's an the warning to where you do the reference = tag assignment.
There was a problem hiding this comment.
It will. This is what it currently looks like:
$ p install --tag localhost:5000/cert-manager:v0.1.0 -c mk -p cert-manager
Flag --tag has been deprecated, use --reference to declare a full bundle reference
installing cert-manager...
...
Do we want stronger verbiage (e.g. WARNING ...)?
There was a problem hiding this comment.
Nope! I just hadn't used the cobra deprecation flag and wasn't sure how it worked. 👍
Signed-off-by: Vaughn Dice <vadice@microsoft.com>
What does this change
Updates
porter publishper the manifest update epic in #1151:tagflag toreferencefor specifying a full bundle reference for publishingporter install --reference mybuns:v0.1.0tagflag to just designate the Docker tag portion of the published bundleregistryflag to designate the Docker registry (and org/subdomain) portion of the published bundledocker tag) an updated invocation image (say, if a new registry value is provided on publish), so that the image is found for publishing. Previously, a new invocation image name would trigger a full new re-build.Ref #1335
What issue does it fix
Closes #1335
Closes #1151
Notes for the reviewer
Checklist
If this is your first pull request, please add your name to the bottom of our Contributors list. Thank you for making Porter better! 🙇♀️