implemented --with to fill inputs.params
Signed-off-by: Richard Jones <richard@dagger.io>
This commit is contained in:
parent
8d8ec5c6b0
commit
1d8834b9b1
@ -24,6 +24,8 @@ import (
|
|||||||
"github.com/spf13/viper"
|
"github.com/spf13/viper"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var withParams []string
|
||||||
|
|
||||||
var upCmd = &cobra.Command{
|
var upCmd = &cobra.Command{
|
||||||
Use: "up",
|
Use: "up",
|
||||||
Short: "Bring an environment online with latest plan and inputs",
|
Short: "Bring an environment online with latest plan and inputs",
|
||||||
@ -142,7 +144,7 @@ func checkUniverseVersion(ctx context.Context, projectPath string) bool {
|
|||||||
func europaUp(ctx context.Context, cl *client.Client, args ...string) error {
|
func europaUp(ctx context.Context, cl *client.Client, args ...string) error {
|
||||||
lg := log.Ctx(ctx)
|
lg := log.Ctx(ctx)
|
||||||
|
|
||||||
p, err := plan.Load(ctx, args...)
|
p, err := plan.Load(ctx, withParams, args...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
lg.Fatal().Err(err).Msg("failed to load plan")
|
lg.Fatal().Err(err).Msg("failed to load plan")
|
||||||
}
|
}
|
||||||
@ -220,6 +222,7 @@ func checkInputs(ctx context.Context, env *environment.Environment) error {
|
|||||||
func init() {
|
func init() {
|
||||||
upCmd.Flags().BoolP("force", "f", false, "Force up, disable inputs check")
|
upCmd.Flags().BoolP("force", "f", false, "Force up, disable inputs check")
|
||||||
upCmd.Flags().String("output", "", "Write computed output. Prints on stdout if set to-")
|
upCmd.Flags().String("output", "", "Write computed output. Prints on stdout if set to-")
|
||||||
|
upCmd.Flags().StringArrayVarP(&withParams, "with", "w", []string{}, "")
|
||||||
|
|
||||||
if err := viper.BindPFlags(upCmd.Flags()); err != nil {
|
if err := viper.BindPFlags(upCmd.Flags()); err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
|
17
plan/plan.go
17
plan/plan.go
@ -23,7 +23,7 @@ type Plan struct {
|
|||||||
source *compiler.Value
|
source *compiler.Value
|
||||||
}
|
}
|
||||||
|
|
||||||
func Load(ctx context.Context, args ...string) (*Plan, error) {
|
func Load(ctx context.Context, withParams []string, args ...string) (*Plan, error) {
|
||||||
log.Ctx(ctx).Debug().Interface("args", args).Msg("loading plan")
|
log.Ctx(ctx).Debug().Interface("args", args).Msg("loading plan")
|
||||||
|
|
||||||
// FIXME: universe vendoring
|
// FIXME: universe vendoring
|
||||||
@ -36,6 +36,21 @@ func Load(ctx context.Context, args ...string) (*Plan, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if len(withParams) > 0 {
|
||||||
|
for i, param := range withParams {
|
||||||
|
log.Ctx(ctx).Debug().Interface("with", param).Msg("applying parameter")
|
||||||
|
paramV, err := compiler.Compile(fmt.Sprintf("with%v", i), param)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
fillErr := v.FillPath(cue.ParsePath("inputs.params"), paramV)
|
||||||
|
if fillErr != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
p := &Plan{
|
p := &Plan{
|
||||||
context: plancontext.New(),
|
context: plancontext.New(),
|
||||||
source: v,
|
source: v,
|
||||||
|
@ -12,10 +12,7 @@ package engine
|
|||||||
// Securely receive secrets
|
// Securely receive secrets
|
||||||
secrets: [name=string]: _#inputSecret
|
secrets: [name=string]: _#inputSecret
|
||||||
// Receive runtime parameters
|
// Receive runtime parameters
|
||||||
params: {
|
params: [name=string]: _
|
||||||
@dagger(notimplemented)
|
|
||||||
[name=string]: _
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Send outputs to the client
|
// Send outputs to the client
|
||||||
|
Reference in New Issue
Block a user