Skip to content
This repository was archived by the owner on Jul 18, 2025. It is now read-only.

Commit 008ec34

Browse files
author
Ian Campbell
committed
Define constants for all custom credentials
So far this is only `docker.context`. Signed-off-by: Ian Campbell <ijc@docker.com>
1 parent 5edcd80 commit 008ec34

3 files changed

Lines changed: 7 additions & 4 deletions

File tree

internal/commands/cnab.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,10 @@ func prepareCredentialSet(contextName string, contextStore store.Store, b *bundl
6363
if err != nil {
6464
return nil, err
6565
}
66-
creds["docker.context"] = string(data)
66+
creds[internal.CredentialDockerContextName] = string(data)
6767
}
68-
_, requiresDockerContext := b.Credentials["docker.context"]
69-
_, hasDockerContext := creds["docker.context"]
68+
_, requiresDockerContext := b.Credentials[internal.CredentialDockerContextName]
69+
_, hasDockerContext := creds[internal.CredentialDockerContextName]
7070
if requiresDockerContext && !hasDockerContext {
7171
return nil, errors.New("no target context specified. Use --target-context= or DOCKER_TARGET_CONTEXT= to define it")
7272
}

internal/names.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ const (
3232
// ActionRenderName is the name of the custom "render" action
3333
ActionRenderName = Namespace + "render"
3434

35+
// CredentialDockerContextName is the name of the credential containing a Docker context
36+
CredentialDockerContextName = "docker.context"
37+
3538
// DockerStackOrchestratorEnvVar is the environment variable set by the CNAB runtime to select
3639
// the stack orchestrator.
3740
DockerStackOrchestratorEnvVar = "DOCKER_STACK_ORCHESTRATOR"

internal/packager/cnab.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ func ToCNAB(app *types.App, invocationImageName string) (*bundle.Bundle, error)
9191

9292
return &bundle.Bundle{
9393
Credentials: map[string]bundle.Location{
94-
"docker.context": {
94+
internal.CredentialDockerContextName: {
9595
Path: "/cnab/app/context.dockercontext",
9696
},
9797
},

0 commit comments

Comments
 (0)