mirror of
https://github.com/linuxkit/linuxkit.git
synced 2025-07-21 10:09:07 +00:00
push arch-specific tags optional
Signed-off-by: Avi Deitcher <avi@deitcher.net>
This commit is contained in:
parent
c72f700910
commit
51a4c3b3eb
11
src/cmd/linuxkit/cache/push.go
vendored
11
src/cmd/linuxkit/cache/push.go
vendored
@ -15,7 +15,10 @@ import (
|
|||||||
// Push push an image along with a multi-arch index.
|
// Push push an image along with a multi-arch index.
|
||||||
// name is the name as referenced in the local cache, remoteName is the name to give it remotely.
|
// name is the name as referenced in the local cache, remoteName is the name to give it remotely.
|
||||||
// If remoteName is empty, it is the same as name.
|
// If remoteName is empty, it is the same as name.
|
||||||
func (p *Provider) Push(name, remoteName string, withManifest bool) error {
|
// If withArchSpecificTags is true, it will push all arch-specific images in the index, each as
|
||||||
|
// their own tag with the same name as the index, but with the architecture appended, e.g.
|
||||||
|
// image:foo will have image:foo-amd64, image:foo-arm64, etc.
|
||||||
|
func (p *Provider) Push(name, remoteName string, withArchSpecificTags bool) error {
|
||||||
var (
|
var (
|
||||||
err error
|
err error
|
||||||
options []remote.Option
|
options []remote.Option
|
||||||
@ -89,7 +92,8 @@ func (p *Provider) Push(name, remoteName string, withManifest bool) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
fmt.Printf("Pushed index %s\n", name)
|
fmt.Printf("Pushed index %s\n", name)
|
||||||
log.Debugf("pushing individual images in the index %s", name)
|
if withArchSpecificTags {
|
||||||
|
fmt.Printf("pushing individual images in the index %s", name)
|
||||||
for _, m := range manifest.Manifests {
|
for _, m := range manifest.Manifests {
|
||||||
if m.Platform == nil || m.Platform.Architecture == "" {
|
if m.Platform == nil || m.Platform.Architecture == "" {
|
||||||
continue
|
continue
|
||||||
@ -126,6 +130,9 @@ func (p *Provider) Push(name, remoteName string, withManifest bool) error {
|
|||||||
return fmt.Errorf("error creating tag %s: %v", archTag, err)
|
return fmt.Errorf("error creating tag %s: %v", archTag, err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
fmt.Printf("Skipping push of individual images in the index %s\n", name)
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
return fmt.Errorf("name %s unknown in cache", name)
|
return fmt.Errorf("name %s unknown in cache", name)
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,10 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func cachePushCmd() *cobra.Command {
|
func cachePushCmd() *cobra.Command {
|
||||||
var remoteName string
|
var (
|
||||||
|
remoteName string
|
||||||
|
pushArchSpecificTags bool
|
||||||
|
)
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
Use: "push",
|
Use: "push",
|
||||||
Short: "push images from the linuxkit cache",
|
Short: "push images from the linuxkit cache",
|
||||||
@ -26,7 +29,7 @@ func cachePushCmd() *cobra.Command {
|
|||||||
log.Fatalf("unable to read a local cache: %v", err)
|
log.Fatalf("unable to read a local cache: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := p.Push(fullname, remoteName, true); err != nil {
|
if err := p.Push(fullname, remoteName, pushArchSpecificTags); err != nil {
|
||||||
log.Fatalf("unable to push image named %s: %v", name, err)
|
log.Fatalf("unable to push image named %s: %v", name, err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -34,6 +37,6 @@ func cachePushCmd() *cobra.Command {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
cmd.Flags().StringVar(&remoteName, "remote-name", "", "Push it under a different name, e.g. push local image foo/bar:mine as baz/bee:yours. If blank, uses same local name.")
|
cmd.Flags().StringVar(&remoteName, "remote-name", "", "Push it under a different name, e.g. push local image foo/bar:mine as baz/bee:yours. If blank, uses same local name.")
|
||||||
|
cmd.Flags().BoolVar(&pushArchSpecificTags, "with-arch-tags", false, "When the local reference is an index, add to the remote arch-specific tags for each arch in the index, each as their own tag with the same name as the index, but with the architecture appended, e.g. image:foo will have image:foo-amd64, image:foo-arm64, etc.")
|
||||||
return cmd
|
return cmd
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user