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
|
// Authentication
|
||||||
auth?: {
|
auth?: {
|
||||||
username: string
|
username: string
|
||||||
secret: string | #Secret
|
secret: #Secret
|
||||||
}
|
}
|
||||||
|
|
||||||
// Root filesystem of downloaded image
|
// Root filesystem of downloaded image
|
||||||
@ -96,11 +96,10 @@ package engine
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Authentication
|
// Authentication
|
||||||
auth: [...{
|
auth: [registry=string]: {
|
||||||
target: string
|
|
||||||
username: string
|
username: string
|
||||||
secret: string | #Secret
|
secret: #Secret
|
||||||
}]
|
}
|
||||||
|
|
||||||
platforms?: [...string]
|
platforms?: [...string]
|
||||||
target?: 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) {
|
func (t *dockerfileTask) Run(ctx context.Context, pctx *plancontext.Context, s solver.Solver, v *compiler.Value) (*compiler.Value, error) {
|
||||||
lg := log.Ctx(ctx)
|
lg := log.Ctx(ctx)
|
||||||
|
auths, err := v.Lookup("auth").Fields()
|
||||||
// Read auth info
|
|
||||||
auth, err := decodeAuthValue(pctx, v.Lookup("auth"))
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
for _, a := range auth {
|
|
||||||
s.AddCredentials(a.Target, a.Username, a.Secret.PlainText())
|
for _, auth := range auths {
|
||||||
lg.Debug().Str("target", a.Target).Msg("add target credentials")
|
// 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"))
|
source, err := pctx.FS.FromValue(v.Lookup("source"))
|
||||||
|
@ -22,12 +22,10 @@ engine.#Plan & {
|
|||||||
|
|
||||||
build: engine.#Dockerfile & {
|
build: engine.#Dockerfile & {
|
||||||
source: inputs.directories.testdata.contents
|
source: inputs.directories.testdata.contents
|
||||||
auth: [{
|
auth: "daggerio/ci-test:private-pull": {
|
||||||
target: "daggerio/ci-test:private-pull"
|
|
||||||
username: "daggertest"
|
username: "daggertest"
|
||||||
|
|
||||||
secret: sopsSecrets.output.DOCKERHUB_TOKEN.contents
|
secret: sopsSecrets.output.DOCKERHUB_TOKEN.contents
|
||||||
}]
|
}
|
||||||
dockerfile: contents: """
|
dockerfile: contents: """
|
||||||
FROM daggerio/ci-test:private-pull@sha256:c74f1b1166784193ea6c8f9440263b9be6cae07dfe35e32a5df7a31358ac2060
|
FROM daggerio/ci-test:private-pull@sha256:c74f1b1166784193ea6c8f9440263b9be6cae07dfe35e32a5df7a31358ac2060
|
||||||
"""
|
"""
|
||||||
|
Reference in New Issue
Block a user