Implement modifications for engine.#Dockerfile tests, and fix lint errors
Signed-off-by: guillaume <guillaume.derouville@gmail.com>
This commit is contained in:
parent
7778389de9
commit
d3dca120f7
@ -69,7 +69,7 @@ package engine
|
||||
// Authentication
|
||||
auth?: {
|
||||
username: string
|
||||
secret: string | #Secret
|
||||
secret: #Secret
|
||||
}
|
||||
|
||||
// Root filesystem of downloaded image
|
||||
@ -96,11 +96,10 @@ package engine
|
||||
}
|
||||
|
||||
// Authentication
|
||||
auth: [...{
|
||||
target: string
|
||||
auth: [registry=string]: {
|
||||
username: string
|
||||
secret: string | #Secret
|
||||
}]
|
||||
secret: #Secret
|
||||
}
|
||||
|
||||
platforms?: [...string]
|
||||
target?: string
|
||||
|
@ -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"))
|
||||
|
@ -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
|
||||
}]
|
||||
}
|
||||
dockerfile: contents: """
|
||||
FROM daggerio/ci-test:private-pull@sha256:c74f1b1166784193ea6c8f9440263b9be6cae07dfe35e32a5df7a31358ac2060
|
||||
"""
|
||||
|
Reference in New Issue
Block a user