Skip to content

Commit

Permalink
✨ Use creds if present for pulling bundle images
Browse files Browse the repository at this point in the history
  • Loading branch information
anik120 committed Sep 26, 2024
1 parent 62b5c53 commit e1b61aa
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions cmd/manager/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
"time"

"github.com/containers/image/v5/types"
"github.com/go-logr/logr"
"github.com/spf13/pflag"
"go.uber.org/zap/zapcore"
apiextensionsv1client "k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/typed/apiextensions/v1"
Expand Down Expand Up @@ -67,6 +68,8 @@ var (
defaultSystemNamespace = "olmv1-system"
)

const authFilePath = "/etc/operator-controller/auth.json"

// podNamespace checks whether the controller is running in a Pod vs.
// being run locally by inspecting the namespace file that gets mounted
// automatically for Pods at runtime. If that file doesn't exist, then
Expand Down Expand Up @@ -201,6 +204,7 @@ func main() {
SourceContext: &types.SystemContext{
DockerCertPath: caCertDir,
OCICertPath: caCertDir,
AuthFilePath: authFilePathIfPresent(setupLog),
},
}

Expand Down Expand Up @@ -311,3 +315,15 @@ type finalizerFunc func(ctx context.Context, obj client.Object) (crfinalizer.Res
func (f finalizerFunc) Finalize(ctx context.Context, obj client.Object) (crfinalizer.Result, error) {
return f(ctx, obj)
}

func authFilePathIfPresent(logger logr.Logger) string {
_, err := os.Stat(authFilePath)
if os.IsNotExist(err) {
return ""
}
if err != nil {
logger.Error(err, "could not stat auth file path", "path", authFilePath)
return ""
}
return authFilePath
}

0 comments on commit e1b61aa

Please sign in to comment.