Skip to content

Commit

Permalink
Fixes HTTP 401 issues when several catalogs are being mirrored and ne…
Browse files Browse the repository at this point in the history
…ed to be rendered using operator-registry (#704) (#706)
  • Loading branch information
sherine-k committed Oct 9, 2023
1 parent b45e623 commit 68cf97e
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions pkg/cli/mirror/operator.go
Expand Up @@ -155,33 +155,36 @@ func (o *OperatorOptions) run(
defer cleanup()
}

reg, err := o.createRegistry()
if err != nil {
return nil, fmt.Errorf("error creating container registry: %v", err)
}
defer reg.Destroy()

mmapping := image.TypedImageMapping{}
for _, ctlg := range cfg.Mirror.Operators {
reg, err := o.createRegistry()
if err != nil {
return nil, fmt.Errorf("error creating container registry: %v", err)
}

ctlgRef, err := image.ParseReference(ctlg.Catalog)
if err != nil {
reg.Destroy()
return nil, err
}
targetName, err := ctlg.GetUniqueName()
if err != nil {
reg.Destroy()
return nil, err
}
if ctlg.IsFBCOCI() {
targetName = v1alpha2.OCITransportPrefix + "//" + targetName
}
targetCtlg, err := image.ParseReference(targetName)
if err != nil {
reg.Destroy()
return nil, fmt.Errorf("error parsing catalog: %v", err)
}

// Render the catalog to mirror into a declarative config.
dc, ic, err := renderDC(ctx, reg, ctlg)
if err != nil {
reg.Destroy()
return nil, o.checkValidationErr(err)
}

Expand All @@ -193,15 +196,17 @@ func (o *OperatorOptions) run(
}
err = extractOPMAndCache(ctx, ctlgRef, ctlgSrcDir, o.SourceSkipTLS)
if err != nil {
reg.Destroy()
return nil, fmt.Errorf("unable to extract OPM binary from catalog %s: %v", targetName, err)
}

mappings, err := o.plan(ctx, dc, ic, ctlgRef, targetCtlg)
if err != nil {
reg.Destroy()
return nil, err
}
mmapping.Merge(mappings)

reg.Destroy()
}

return mmapping, nil
Expand Down

0 comments on commit 68cf97e

Please sign in to comment.