in scripts/pusher/main.go [127:175]
func push(ctx context.Context, src, repo string, tags []string) error {
pusher, err := remote.NewPusher(remote.WithAuthFromKeychain(authn.DefaultKeychain))
if err != nil {
return fmt.Errorf("creating pusher: %w", err)
}
dir, err := extract(src)
if err != nil {
return fmt.Errorf("extracting oci-layout tar: %w", err)
}
defer os.RemoveAll(dir)
// fix oci archive
if err := fixOCIArchive(dir); err != nil {
return fmt.Errorf("fixing archive %v: %w", dir, err)
}
ociLayout, err := layout.FromPath(dir)
if err != nil {
return fmt.Errorf("opening oci-layout: %w", err)
}
index, err := ociLayout.ImageIndex()
if err != nil {
return fmt.Errorf("getting image index: %w", err)
}
for _, tag := range tags {
ref, err := name.ParseReference(repo + ":" + tag)
if err != nil {
return fmt.Errorf("parsing dst reference: %w", err)
}
fmt.Printf("[%v] %v => %v\n", src, repo, tag)
if dry {
continue
}
now := time.Now()
if err := pusher.Push(ctx, ref, index); err != nil {
return fmt.Errorf("pusing image %v: %w", ref, err)
}
fmt.Printf("[%v] %v => %v (%v)\n", src, repo, tag, time.Since(now))
}
return nil
}