Skip to content

Commit

Permalink
fix(oci): Fully enable using config auths (#1836)
Browse files Browse the repository at this point in the history
Reviewed-by: Alexander Jung <alex@unikraft.io>
Approved-by: Alexander Jung <alex@unikraft.io>
  • Loading branch information
nderjung authored Aug 9, 2024
2 parents e7bad5c + 53dd066 commit e7842df
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions oci/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ func RegisterPackageManager() func(u *packmanager.UmbrellaManager) error {
return u.RegisterPackageManager(
OCIFormat,
NewOCIManager,
WithDefaultAuth(),
WithDefaultRegistries(),
WithDetectHandler(),
)
Expand Down
19 changes: 19 additions & 0 deletions oci/manager_options.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,3 +171,22 @@ func WithDockerConfig(auth regtypes.AuthConfig) OCIManagerOption {
return nil
}
}

// WithAuth sets the authentication configuration to use when making calls to
// authenticated registries.
func WithAuth(auths map[string]config.AuthConfig) OCIManagerOption {
return func(ctx context.Context, manager *ociManager) error {
manager.auths = auths
return nil
}
}

// WithDefaultAuth uses the KraftKit-set configuration for authentication
// against remote registries.
func WithDefaultAuth() OCIManagerOption {
return func(ctx context.Context, manager *ociManager) error {
manager.auths = config.G[config.KraftKit](ctx).Auth

return nil
}
}

0 comments on commit e7842df

Please sign in to comment.