Skip to content

Commit

Permalink
✨ Use default creds if present for pulling catalog images (#416)
Browse files Browse the repository at this point in the history
  • Loading branch information
anik120 authored Sep 26, 2024
1 parent e57db1f commit a34f172
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion cmd/manager/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
"time"

"github.com/containers/image/v5/types"
"github.com/go-logr/logr"
"github.com/spf13/pflag"
"k8s.io/apimachinery/pkg/runtime"
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
Expand Down Expand Up @@ -58,7 +59,10 @@ var (
setupLog = ctrl.Log.WithName("setup")
)

const storageDir = "catalogs"
const (
storageDir = "catalogs"
authFilePath = "/etc/catalogd/auth.json"
)

func init() {
utilruntime.Must(clientgoscheme.AddToScheme(scheme))
Expand Down Expand Up @@ -188,6 +192,7 @@ func main() {
SourceContext: &types.SystemContext{
OCICertPath: caCertDir,
DockerCertPath: caCertDir,
AuthFilePath: authFilePathIfPresent(setupLog),
},
}

Expand Down Expand Up @@ -286,3 +291,15 @@ func podNamespace() string {
}
return string(namespace)
}

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)
os.Exit(1)
}
return authFilePath
}

0 comments on commit a34f172

Please sign in to comment.