This repository has been archived on 2024-04-08. You can view files and clone it, but cannot push or open issues or pull requests.
dagger/plan/task/auth.go
guillaume ac30274d96 Implement modifications for engine.#Pull, engine.#Push, docker.#Push, docker.#Pull
Signed-off-by: guillaume <guillaume.derouville@gmail.com>
2022-01-31 23:14:35 +01:00

36 lines
670 B
Go

package task
import (
"go.dagger.io/dagger/compiler"
"go.dagger.io/dagger/plancontext"
)
type authValue struct {
Username string
Secret *plancontext.Secret
}
// Decodes an auth field value
//
// Cue format:
// auth: {
// username: string
// secret: string | #Secret
// }
func decodeAuthValue(pctx *plancontext.Context, v *compiler.Value) (*authValue, error) {
authVal := authValue{}
username, err := v.Lookup("username").String()
if err != nil {
return nil, err
}
authVal.Username = username
secret, err := pctx.Secrets.FromValue(v.Lookup("secret"))
if err != nil {
return nil, err
}
authVal.Secret = secret
return &authVal, nil
}