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

36 lines
670 B
Go
Raw Permalink Normal View History

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
}