Skip to content
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

Bug 1806779: Mirroring from custom directory via oc adm release mirror fails #424

Merged
merged 1 commit into from
May 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion pkg/cli/admin/release/extract.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@ type ExtractOptions struct {

Output string

From string
FromDir string
From string

Tools bool
Command string
Expand Down Expand Up @@ -193,6 +194,7 @@ func (o *ExtractOptions) Run() error {
return err
}
opts := extract.NewOptions(genericclioptions.IOStreams{Out: o.Out, ErrOut: o.ErrOut})
opts.ParallelOptions = o.ParallelOptions
opts.SecurityOptions = o.SecurityOptions
opts.FileDir = o.FileDir

Expand Down
5 changes: 4 additions & 1 deletion pkg/cli/admin/release/mirror.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ func NewMirror(f kcmdutil.Factory, parentName string, streams genericclioptions.
flags.StringVar(&o.From, "from", o.From, "Image containing the release payload.")
flags.StringVar(&o.To, "to", o.To, "An image repository to push to.")
flags.StringVar(&o.ToImageStream, "to-image-stream", o.ToImageStream, "An image stream to tag images into.")
flags.StringVar(&o.FromDir, "from-dir", o.ToDir, "A directory to import images from.")
flags.StringVar(&o.FromDir, "from-dir", o.FromDir, "A directory to import images from.")
flags.StringVar(&o.ToDir, "to-dir", o.ToDir, "A directory to export images to.")
flags.BoolVar(&o.ToMirror, "to-mirror", o.ToMirror, "Output the mirror mappings instead of mirroring.")
flags.BoolVar(&o.DryRun, "dry-run", o.DryRun, "Display information about the mirror without actually executing it.")
Expand Down Expand Up @@ -464,11 +464,13 @@ func (o *MirrorOptions) Run() error {
// load image references
buf := &bytes.Buffer{}
extractOpts := NewExtractOptions(genericclioptions.IOStreams{Out: buf, ErrOut: o.ErrOut}, true)
extractOpts.ParallelOptions = o.ParallelOptions
extractOpts.SecurityOptions = o.SecurityOptions
extractOpts.ImageMetadataCallback = func(m *extract.Mapping, dgst, contentDigest digest.Digest, config *dockerv1client.DockerImageConfig) {
releaseDigest = contentDigest.String()
verifier.Verify(dgst, contentDigest)
}
extractOpts.FileDir = o.FromDir
extractOpts.From = o.From
extractOpts.File = "image-references"
if err := extractOpts.Run(); err != nil {
Expand Down Expand Up @@ -728,6 +730,7 @@ func (o *MirrorOptions) Run() error {
opts.SecurityOptions = o.SecurityOptions
opts.ParallelOptions = o.ParallelOptions
opts.Mappings = mappings
opts.FromFileDir = o.FromDir
opts.FileDir = o.ToDir
opts.DryRun = o.DryRun
opts.ManifestUpdateCallback = func(registry string, manifests map[digest.Digest]digest.Digest) error {
Expand Down
5 changes: 4 additions & 1 deletion pkg/cli/admin/release/new.go
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,7 @@ func (o *NewOptions) Run() error {

buf := &bytes.Buffer{}
extractOpts := extract.NewOptions(genericclioptions.IOStreams{Out: buf, ErrOut: o.ErrOut})
extractOpts.ParallelOptions = o.ParallelOptions
extractOpts.SecurityOptions = o.SecurityOptions
extractOpts.OnlyFiles = true
extractOpts.Mappings = []extract.Mapping{
Expand Down Expand Up @@ -926,9 +927,9 @@ func (o *NewOptions) extractManifests(is *imageapi.ImageStream, name string, met
verifier := imagemanifest.NewVerifier()
var lock sync.Mutex
opts := extract.NewOptions(genericclioptions.IOStreams{Out: o.Out, ErrOut: o.ErrOut})
opts.ParallelOptions = o.ParallelOptions
opts.SecurityOptions = o.SecurityOptions
opts.OnlyFiles = true
opts.ParallelOptions = o.ParallelOptions
opts.ImageMetadataCallback = func(m *extract.Mapping, dgst, contentDigest digest.Digest, config *dockerv1client.DockerImageConfig) {
verifier.Verify(dgst, contentDigest)

Expand Down Expand Up @@ -1053,6 +1054,7 @@ func (o *NewOptions) mirrorImages(is *imageapi.ImageStream) error {
opts.ImageStream = copied
opts.To = o.Mirror
opts.SkipRelease = true
opts.ParallelOptions = o.ParallelOptions
opts.SecurityOptions = o.SecurityOptions

if err := opts.Run(); err != nil {
Expand Down Expand Up @@ -1183,6 +1185,7 @@ func (o *NewOptions) write(r io.Reader, is *imageapi.ImageStream, now time.Time)

verifier := imagemanifest.NewVerifier()
options := imageappend.NewAppendImageOptions(genericclioptions.IOStreams{Out: ioutil.Discard, ErrOut: o.ErrOut})
options.ParallelOptions = o.ParallelOptions
options.SecurityOptions = o.SecurityOptions
options.DryRun = o.DryRun
options.From = toImageBase
Expand Down