Skip to content

Commit 167ed93

Browse files
authored
Fix authentication error with dockerAuthConfig (#669)
1 parent 030cc31 commit 167ed93

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

internal/digest/digest.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,17 @@ func DirSha256(dirPath string, excludePaths []string, logger *logger.Logger) (st
8585
func OciSha256(artifactName string, registryUsername string, registryPassword string) (string, error) {
8686
imageName := fmt.Sprintf("//%s", artifactName)
8787
ctx := context.Background()
88-
sysCtx := &types.SystemContext{
89-
DockerAuthConfig: &types.DockerAuthConfig{
88+
sysCtx := &types.SystemContext{}
89+
// Only set explicit credentials when provided. When DockerAuthConfig is nil,
90+
// the containers/image library falls back to credential discovery from auth
91+
// files (~/.docker/config.json, ~/.config/containers/auth.json) and credential
92+
// helpers (e.g. docker-credential-ecr-login), which is needed when Docker is
93+
// not installed or when using Podman with a private registry like ECR.
94+
if registryUsername != "" || registryPassword != "" {
95+
sysCtx.DockerAuthConfig = &types.DockerAuthConfig{
9096
Username: registryUsername,
9197
Password: registryPassword,
92-
},
98+
}
9399
}
94100

95101
// Parse image reference

0 commit comments

Comments
 (0)