Skip to content

Commit

Permalink
Implement modifications for engine.#Dockerfile tests, and fix lint e…
Browse files Browse the repository at this point in the history
…rrors

Signed-off-by: guillaume <guillaume.derouville@gmail.com>
  • Loading branch information
grouville committed Jan 31, 2022
1 parent 7778389 commit d3dca12
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 16 deletions.
9 changes: 4 additions & 5 deletions pkg/dagger.io/dagger/engine/image.cue
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ package engine
// Authentication
auth?: {
username: string
secret: string | #Secret
secret: #Secret
}

// Root filesystem of downloaded image
Expand All @@ -96,11 +96,10 @@ package engine
}

// Authentication
auth: [...{
target: string
auth: [registry=string]: {
username: string
secret: string | #Secret
}]
secret: #Secret
}

platforms?: [...string]
target?: string
Expand Down
21 changes: 15 additions & 6 deletions plan/task/dockerfile.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,24 @@ type dockerfileTask struct {

func (t *dockerfileTask) Run(ctx context.Context, pctx *plancontext.Context, s solver.Solver, v *compiler.Value) (*compiler.Value, error) {
lg := log.Ctx(ctx)

// Read auth info
auth, err := decodeAuthValue(pctx, v.Lookup("auth"))
auths, err := v.Lookup("auth").Fields()
if err != nil {
return nil, err
}
for _, a := range auth {
s.AddCredentials(a.Target, a.Username, a.Secret.PlainText())
lg.Debug().Str("target", a.Target).Msg("add target credentials")

for _, auth := range auths {
// Read auth info
a, err := decodeAuthValue(pctx, auth.Value)
if err != nil {
return nil, err
}
// Extract registry target from dest
target, err := solver.ParseAuthHost(auth.Label())
if err != nil {
return nil, err
}
s.AddCredentials(target, a.Username, a.Secret.PlainText())
lg.Debug().Str("target", target).Msg("add target credentials")
}

source, err := pctx.FS.FromValue(v.Lookup("source"))
Expand Down
8 changes: 3 additions & 5 deletions tests/tasks/dockerfile/build_auth.cue
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,10 @@ engine.#Plan & {

build: engine.#Dockerfile & {
source: inputs.directories.testdata.contents
auth: [{
target: "daggerio/ci-test:private-pull"
auth: "daggerio/ci-test:private-pull": {
username: "daggertest"

secret: sopsSecrets.output.DOCKERHUB_TOKEN.contents
}]
secret: sopsSecrets.output.DOCKERHUB_TOKEN.contents
}
dockerfile: contents: """
FROM daggerio/ci-test:private-pull@sha256:c74f1b1166784193ea6c8f9440263b9be6cae07dfe35e32a5df7a31358ac2060
"""
Expand Down

0 comments on commit d3dca12

Please sign in to comment.