mirror of
https://github.com/linuxkit/linuxkit.git
synced 2025-07-24 11:25:40 +00:00
add ability to just update manifest
Signed-off-by: Avi Deitcher <avi@deitcher.net>
This commit is contained in:
parent
239d4d9502
commit
b28621b95a
@ -32,6 +32,10 @@ func pkg(args []string) {
|
||||
pkgPush(args[1:])
|
||||
case "show-tag":
|
||||
pkgShowTag(args[1:])
|
||||
case "manifest":
|
||||
pkgManifest(args[1:])
|
||||
case "index":
|
||||
pkgIndex(args[1:])
|
||||
default:
|
||||
fmt.Printf("Unknown subcommand %q\n\n", args[0])
|
||||
pkgUsage()
|
||||
|
50
src/cmd/linuxkit/pkg_manifest.go
Normal file
50
src/cmd/linuxkit/pkg_manifest.go
Normal file
@ -0,0 +1,50 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/linuxkit/linuxkit/src/cmd/linuxkit/pkglib"
|
||||
)
|
||||
|
||||
func pkgManifest(args []string) {
|
||||
pkgIndex(args)
|
||||
}
|
||||
func pkgIndex(args []string) {
|
||||
flags := flag.NewFlagSet("pkg manifest", flag.ExitOnError)
|
||||
flags.Usage = func() {
|
||||
invoked := filepath.Base(os.Args[0])
|
||||
name := "manifest"
|
||||
fmt.Fprintf(os.Stderr, "USAGE: %s pkg %s [options] path\n\n", name, invoked)
|
||||
fmt.Fprintf(os.Stderr, "'path' specifies the path to the package source directory.\n")
|
||||
fmt.Fprintf(os.Stderr, "\n")
|
||||
fmt.Fprintf(os.Stderr, "Updates the manifest in the registry for the given path based on all known platforms. If none found, no manifest created.\n")
|
||||
flags.PrintDefaults()
|
||||
}
|
||||
release := flags.String("release", "", "Release the given version")
|
||||
|
||||
pkgs, err := pkglib.NewFromCLI(flags, args...)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "%v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
var opts []pkglib.BuildOpt
|
||||
if *release != "" {
|
||||
opts = append(opts, pkglib.WithRelease(*release))
|
||||
}
|
||||
|
||||
for _, p := range pkgs {
|
||||
msg := fmt.Sprintf("Updating index for %q", p.Tag())
|
||||
action := "building and pushing"
|
||||
|
||||
fmt.Println(msg)
|
||||
|
||||
if err := p.Index(opts...); err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Error %s %q: %v\n", action, p.Tag(), err)
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
}
|
50
src/cmd/linuxkit/pkglib/index.go
Normal file
50
src/cmd/linuxkit/pkglib/index.go
Normal file
@ -0,0 +1,50 @@
|
||||
package pkglib
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/linuxkit/linuxkit/src/cmd/linuxkit/registry"
|
||||
"github.com/linuxkit/linuxkit/src/cmd/linuxkit/util"
|
||||
)
|
||||
|
||||
// Index create an index for the package tag based on all arch-specific tags in the registry.
|
||||
func (p Pkg) Index(bos ...BuildOpt) error {
|
||||
var bo buildOpts
|
||||
for _, fn := range bos {
|
||||
if err := fn(&bo); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
name := p.FullTag()
|
||||
|
||||
// Even though we may have pushed the index, we want to be sure that we have an index that includes every architecture on the registry,
|
||||
// not just those that were in our local cache. So we use manifest-tool library to build a broad index
|
||||
auth, err := registry.GetDockerAuth()
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to get auth: %v", err)
|
||||
}
|
||||
|
||||
// push based on tag
|
||||
fmt.Printf("Pushing index based on all arch-specific images in registry %s\n", name)
|
||||
_, _, err = registry.PushManifest(name, auth)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// push based on release
|
||||
if bo.release != "" {
|
||||
relTag, err := p.ReleaseTag(bo.release)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
fullRelTag := util.ReferenceExpand(relTag)
|
||||
|
||||
fmt.Printf("Pushing index based on all arch-specific images in registry %s\n", fullRelTag)
|
||||
_, _, err = registry.PushManifest(fullRelTag, auth)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
Loading…
Reference in New Issue
Block a user