-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
manifest push using yaml file #866
base: master
Are you sure you want to change the base?
Conversation
I still need to add a test. If anyone wants to give this a quick once-over in the meantime feel free. |
Also, so I don't forget, I need to update the doc to add this, and and to include how to set the cli experimental. It's confusing, because it's "true" for the engine, but "enabled" for the cli. :D |
cli/command/manifest/push.go
Outdated
return cmd | ||
} | ||
|
||
func runPush(dockerCli command.Cli, opts pushOpts) error { | ||
|
||
if opts.target == "" && opts.file == "" { | ||
return errors.New("please specify either a file or local manifest name") |
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 believe we generally avoid "please" in error messages. Maybe "either a filename or local manifest name is required" or something like that?
cli/command/manifest/push.go
Outdated
} | ||
if err := annotateListFromYaml(dockerCli, yamlInput); err != nil { | ||
return err | ||
} |
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.
It seems a bit odd to me that push
would create local files. could this push directly from yaml without creating the files locally?
If we want to support "load defaults from yaml" or something like that we could have create
accept the same yaml format (either in this PR or a separate one).
cli/command/manifest/push.go
Outdated
flags.BoolVar(&opts.insecure, "insecure", false, "Allow push to an insecure registry") | ||
flags.BoolVarP(&opts.purge, "purge", "p", false, "remove the local manifest list after push") | ||
flags.BoolVar(&opts.insecure, "insecure", false, "allow push to an insecure registry") | ||
flags.StringVar(&opts.file, "filename", "", "create, annotate, and push using a yaml file") |
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 wonder if file
should be a boolean flag that changes the positional argument from a "local manifest target" to "a filepath". I'm not sure if that's more or less expected than having a conditional argument.
I think it would at least make the validation easier, because with a bool flag a positional argument would always be necessary.
cli/command/manifest/push.go
Outdated
|
||
if _, err := os.Stat(yamlFile); err != nil { | ||
return yamlManifestList{}, err | ||
} |
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.
Is this Stat necessary? I think you'd get the same error from ReadFile()
.
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.
nope, thanks!
cli/command/manifest/push.go
Outdated
if err != nil { | ||
return yamlManifestList{}, err | ||
} | ||
if err := yaml.UnmarshalStrict(yamlBuf, &yamlInput); err != 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 if
is unnecessary:
return yamlInput, yaml.UnmarshalStrict(yamlBuf, &yamlInput)
988d7e0
to
4c2bba3
Compare
Redid this (no longer uses local fs) but haven't tested the original path yet, so I'll get to that on Monday, and also take the rest of @dnephin's comments into account. Sorry for abandoning this for so long! |
c37ebc3
to
b25349f
Compare
tests added for yaml. removing @vdemeester @thaJeztah the week before dockercon, so, you've got time to take a look at this now right? 👼 |
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 really like the idea, but I feel docker push --file=true my.yaml
is not correct.
The current behavior is docker manifest push an-image-ref-which-is-a-list
, so… for the file, I really feels we should have something more like docker manifest push --file=my.yaml an-image-ref-which-is-a-list
.
Thanks @clnperez I'll look into it in the next days. Haven't looked into the details, but agree that pushing a yaml should be done with the |
@vdemeester i wasn't a huge fan of the file change but it grew on me and did make validation easier. i'm open to changes for sure. but i'm not sure i like having someone specify any information on the command line that could be also in a yaml file (in this case, the target ref). |
@clnperez I really like the file, but in the current proposal there is two things that I feel could be better
So my proposal is to make the file something like the following : manifests:
- image: test/hello-world-ppc64le:latest
platform:
architecture: ppc64le
- image: test/hello-world-amd64:latest
platform:
architecture: amd64
os: linux
- image: test/hello-world-s390x:latest
platform:
architecture: s390x
os: linux
osversion: 1.1
variant: xyz
osfeatures: [a,b,c] And have the cli being @thaJeztah wdyt ? |
I agree with @vdemeester |
@vdemeester can you clarify: |
@clnperez yes, my sugestion would be to not have the I updated my example above as I realized I did not remove that first line 😅. |
Thanks @vdemeester. That's a simple enough code change. I'd like to hear from some others before we get attached. :D |
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.
Some nits
cli/command/manifest/push.go
Outdated
if opts.file { | ||
return pushListFromYaml(dockerCli, opts.target, opts.insecure) | ||
} | ||
|
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: too much empty lines
cli/command/manifest/push.go
Outdated
return err | ||
} | ||
if len(yamlInput.Manifests) == 0 { | ||
return errors.Errorf("no manifests specified in file input") |
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: errors.Errorf
is not needed here. You can use errors.New
instead.
cli/command/manifest/push.go
Outdated
} | ||
|
||
func addYamlAnnotations(manifest *types.ImageManifest, ym yamlManifest) { | ||
|
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: empty line
cli/command/manifest/push.go
Outdated
@@ -271,3 +292,69 @@ func mountBlobs(ctx context.Context, client registryclient.RegistryClient, ref r | |||
} | |||
return nil | |||
} | |||
|
|||
func pushListFromYaml(dockerCli command.Cli, file string, insecure bool) 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.
nit: empty line
cli/command/manifest/push.go
Outdated
if opts.file { | ||
return pushListFromYaml(dockerCli, opts.target, opts.insecure) | ||
} | ||
|
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: empty line
cli/command/manifest/push.go
Outdated
} | ||
|
||
func getYamlManifestList(yamlFile string) (yamlManifestList, error) { | ||
var yamlInput yamlManifestList |
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: you can move the var declaration closer to where it is used.
I think it's relevant to bring up estesp/manifest-tool#23 (multiple tags pushed at once; estesp/manifest-tool#32) in the context of removing It probably won't be very useful for pushing to multiple registries though (hub+gcr.io for example), right? (since the manifest list image references still need to be on the same registry for cross-repository blob-mounting) estesp/manifest-tool#22 is also relevant for the official images use-case -- we have to wait to push the manifest lists until the full set of architectures have built (see docker-library/official-images#3835), so having It'd be neat to be able to specify this YAML content without needing a file on-disk, but that's more of a minor annoyance than a serious issue (since it's a matter of garbage collection after we build the appropriate YAML, push the bits, then clean up afterwards). |
b25349f
to
7bc7d2a
Compare
Thanks @tianon . I think for this PR, I can look at just redoing the
|
7bc7d2a
to
ae7bcd6
Compare
ae7bcd6
to
317c10b
Compare
@silvin-lubecki nits taken into account, thanks :) @vdemeester i'll have to redo this again if we go with #1156. Unless we want to merge this one first and make @dmcgowan rebase his. ;) for now though -- i can't get the vendor bit fixed |
368e4c9
to
c9a9950
Compare
figured out vendor. i think i had switched a commit. PTAL |
c9a9950
to
12b3a0f
Compare
Rebased against master post-merge of #1156 |
ping @thaJeztah @vdemeester |
12b3a0f
to
06cc41f
Compare
Codecov Report
@@ Coverage Diff @@
## master #866 +/- ##
=========================================
+ Coverage 54.63% 54.7% +0.07%
=========================================
Files 293 293
Lines 19369 19418 +49
=========================================
+ Hits 10582 10623 +41
- Misses 8126 8130 +4
- Partials 661 665 +4 |
Rebased. PTAL. |
paging @thaJeztah & @vdemeester |
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.
Design LGTM 👼
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.
LGTM, thank you @clnperez !
@thaJeztah are you ok to merge this PR? |
Instead of: manifest create list image1 image2 manifest annotate list image1 manifest push list You can do: manifiest push --file myfile.yaml registry/repo/image:tag Signed-off-by: Christy Norman <christy@linux.vnet.ibm.com>
06cc41f
to
dbd1fce
Compare
ping @thaJeztah . would love to close this 😇 |
@dnephin @vdemeester can chance of merging this one? |
ping @thaJeztah. I saw that #1252 was merged so I have a sliver of hope that someone will take a look at this again. |
Nice is very good idea. Would be nice to get this merged before #1355 |
Nice work @clnperez, great way to create manifests by yaml definition. |
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.
Still LGTM for me
cc @thaJeztah @andrewhsu
Instead of:
manifest create list image1 image2
manifest annotate list image1
manifest push list
You can do:
manifest push --file=myfile.yaml list:tag
Signed-off-by: Christy Norman christy@linux.vnet.ibm.com
- What I did
- How I did it
- How to verify it
- Description for the changelog
- A picture of a cute animal (not mandatory but encouraged)