-
Notifications
You must be signed in to change notification settings - Fork 203
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
Migrate invocation image push to porter publish
#365
Migrate invocation image push to porter publish
#365
Conversation
Need to update the docs still! |
cmd/porter/bundle.go
Outdated
cmd := cobra.Command{ | ||
Use: "publish", | ||
Short: "Publish a bundle", | ||
Long: "Publishes a bundle by pushing the invocation image, updating the reference in the CNAB bundle.json, and publishing to an OCI registry.", |
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.
We don't normally put the technical implementation into the help text. I recommend putting this into the documentation, and then putting a more general description here like
"Publishes a bundle by pushing the invocation image and bundle to a registry"
cmd/porter/bundle.go
Outdated
|
||
f := cmd.Flags() | ||
f.StringVarP(&opts.File, "file", "f", "", "Path to the Porter manifest. Defaults to `porter.yaml` in the current directory.") | ||
f.StringVarP(&opts.Tag, "tag", "t", "", "Tag to apply to the CNAB invocation image. Defaults to the value currently in the Porter manifest.") |
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.
This isn't what was specified in the OP issue #254. That was calling for a new field tag
(format registry/image:tag) to be added to the manifest that the bundle will be pushed to).
So this should say
"Tag to apply to the bundle when pushing to the registry. Defaults to the value defined in the Porter manifest."
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.
👍 i misread that.
pkg/porter/publish.go
Outdated
if err != nil { | ||
return errors.Wrap(err, "could not get current working directory") | ||
} | ||
fmt.Println(pwd) |
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 like a leftover debug statement that should be removed?
pkg/porter/publish.go
Outdated
return errors.Wrap(err, "could not get current working directory") | ||
} | ||
fmt.Println(pwd) | ||
files, err := fs.ReadDir(pwd) |
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.
Why not use fs.Exists
to check if porter.yaml is in the current directory?
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.
I copied this from the existing validation code (that wasn't directly reusable) and then removed something and was lazy. I'll update.
pkg/porter/publish.go
Outdated
|
||
func (p PublishOptions) Validate(porter *Porter) error { | ||
if p.File != "" { | ||
return 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.
This is skipping the Tag
validation entirely. I think the logic below around checking if porter.yaml is present should be in the if/else instead of doing a hard return, no?
pkg/porter/publish.go
Outdated
if err != nil { | ||
return err | ||
} | ||
if opts.Tag != "" { |
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.
Yeah this entire part I think should be removed since tag = bundle tag, not invocation image tag. Feel free to give things better names anywhere you like. 😀
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.
I think we should still validate that the tag given is a valid OCI tag no?
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.
Yes, in the PublishOptions.Validate
method. I was just referring to the lines 81-83 here where we are changing the invocation image tag.
pkg/porter/publish_test.go
Outdated
opts.Tag = "someinvalid/repo/thing:10:10" | ||
|
||
err = opts.Validate(p.Porter) | ||
require.Error(t, err, "should have no error") |
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.
the error message here is confusing, can you remove it or fix it? We actually do want an error.
pkg/porter/publish_test.go
Outdated
p.TestConfig.SetupPorterHome() | ||
opts := PublishOptions{} | ||
err := opts.Validate(p.Porter) | ||
require.Error(t, err, "should have no error") |
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.
the error message here is confusing, can you remove it or fix it? We actually do want an error.
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.
sorry just one nit and then the rubber stamps will fly! 💸
pkg/porter/publish.go
Outdated
if p.Tag != "" { | ||
_, err := reference.ParseNormalizedNamed(p.Tag) | ||
if err != nil { | ||
return err | ||
return errors.Wrap(err, "invalid bundle tag value") |
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.
nit: Normally in the validate methods we tell them the flag that they need to fix, so the error looks like "invalid --tag value, expected format is REGISTRY/IMAGE:TAG" or something along those lines.
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.
$ porter publish --tag jeremyrickard/super-cool-app-image:v1.0:1010
Error: invalid --tag value. expected format is REGISTRY/IMAGE:TAG: invalid reference format
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.
This PR migrates the image push functionality to a new command
porter publish
(the command doesn't actually publish the bundle itself to OCI yet). Now when you do aporter build
the invocation image is still built, but it is not pushed to a registry. The bundle.json is generated with whatever tag is present in theporter.yaml
.To push the image and regenerate the bundle.json, you now do a
porter publish
.Command outputs below:
Then a
porter publish
Closes: #354