From e6674b7b7edcfd2de711d1670ec0ad913e3e21de Mon Sep 17 00:00:00 2001 From: Andrea Luzzardi Date: Tue, 30 Mar 2021 19:40:44 -0700 Subject: [PATCH] terminology: rename layout -> plan Signed-off-by: Andrea Luzzardi --- cmd/dagger/cmd/compute.go | 6 +-- cmd/dagger/cmd/new.go | 16 ++++---- cmd/dagger/cmd/{layout => plan}/dir.go | 4 +- cmd/dagger/cmd/{layout => plan}/file.go | 4 +- cmd/dagger/cmd/{layout => plan}/git.go | 4 +- cmd/dagger/cmd/{layout => plan}/package.go | 4 +- cmd/dagger/cmd/{layout => plan}/root.go | 6 +-- cmd/dagger/cmd/query.go | 2 +- cmd/dagger/cmd/root.go | 4 +- cmd/dagger/cmd/up.go | 2 +- dagger/client.go | 2 +- dagger/deployment.go | 44 +++++++++++----------- dagger/input_test.go | 2 +- dagger/store.go | 2 +- 14 files changed, 51 insertions(+), 51 deletions(-) rename cmd/dagger/cmd/{layout => plan}/dir.go (90%) rename cmd/dagger/cmd/{layout => plan}/file.go (91%) rename cmd/dagger/cmd/{layout => plan}/git.go (91%) rename cmd/dagger/cmd/{layout => plan}/package.go (91%) rename cmd/dagger/cmd/{layout => plan}/root.go (71%) diff --git a/cmd/dagger/cmd/compute.go b/cmd/dagger/cmd/compute.go index 91c83ec7..32a7a5e9 100644 --- a/cmd/dagger/cmd/compute.go +++ b/cmd/dagger/cmd/compute.go @@ -33,9 +33,9 @@ var computeCmd = &cobra.Command{ ctx := lg.WithContext(cmd.Context()) st := &dagger.DeploymentState{ - ID: uuid.New().String(), - Name: "FIXME", - LayoutSource: dagger.DirInput(args[0], []string{"*.cue", "cue.mod"}), + ID: uuid.New().String(), + Name: "FIXME", + PlanSource: dagger.DirInput(args[0], []string{"*.cue", "cue.mod"}), } for _, input := range viper.GetStringSlice("input-string") { diff --git a/cmd/dagger/cmd/new.go b/cmd/dagger/cmd/new.go index 7860aa2e..197d9abf 100644 --- a/cmd/dagger/cmd/new.go +++ b/cmd/dagger/cmd/new.go @@ -34,8 +34,8 @@ var newCmd = &cobra.Command{ } st := &dagger.DeploymentState{ - Name: getNewDeploymentName(ctx), - LayoutSource: getLayoutSource(ctx), + Name: getNewDeploymentName(ctx), + PlanSource: getPlanSource(ctx), } err = store.CreateDeployment(ctx, st) @@ -86,8 +86,8 @@ func getNewDeploymentName(ctx context.Context) string { return currentDir } -// FIXME: Implement options: --layout-* -func getLayoutSource(ctx context.Context) dagger.Input { +// FIXME: Implement options: --plan-* +func getPlanSource(ctx context.Context) dagger.Input { lg := log.Ctx(ctx) wd, err := os.Getwd() @@ -102,10 +102,10 @@ func init() { newCmd.Flags().StringP("name", "n", "", "Specify a deployment name") newCmd.Flags().BoolP("up", "u", false, "Bring the deployment online") - newCmd.Flags().String("layout-dir", "", "Load layout from a local directory") - newCmd.Flags().String("layout-git", "", "Load layout from a git repository") - newCmd.Flags().String("layout-package", "", "Load layout from a cue package") - newCmd.Flags().String("layout-file", "", "Load layout from a cue or json file") + newCmd.Flags().String("plan-dir", "", "Load plan from a local directory") + newCmd.Flags().String("plan-git", "", "Load plan from a git repository") + newCmd.Flags().String("plan-package", "", "Load plan from a cue package") + newCmd.Flags().String("plan-file", "", "Load plan from a cue or json file") newCmd.Flags().String("setup", "auto", "Specify whether to prompt user for initial setup (no|yes|auto)") diff --git a/cmd/dagger/cmd/layout/dir.go b/cmd/dagger/cmd/plan/dir.go similarity index 90% rename from cmd/dagger/cmd/layout/dir.go rename to cmd/dagger/cmd/plan/dir.go index 21a1fc4f..ee3410bd 100644 --- a/cmd/dagger/cmd/layout/dir.go +++ b/cmd/dagger/cmd/plan/dir.go @@ -1,4 +1,4 @@ -package layout +package plan import ( "github.com/spf13/cobra" @@ -7,7 +7,7 @@ import ( var dirCmd = &cobra.Command{ Use: "dir PATH", - Short: "Load layout from a local directory", + Short: "Load plan from a local directory", Args: cobra.ExactArgs(1), PreRun: func(cmd *cobra.Command, args []string) { // Fix Viper bug for duplicate flags: diff --git a/cmd/dagger/cmd/layout/file.go b/cmd/dagger/cmd/plan/file.go similarity index 91% rename from cmd/dagger/cmd/layout/file.go rename to cmd/dagger/cmd/plan/file.go index de503531..39f12a1b 100644 --- a/cmd/dagger/cmd/layout/file.go +++ b/cmd/dagger/cmd/plan/file.go @@ -1,4 +1,4 @@ -package layout +package plan import ( "github.com/spf13/cobra" @@ -7,7 +7,7 @@ import ( var fileCmd = &cobra.Command{ Use: "file PATH|-", - Short: "Load layout from a cue file", + Short: "Load plan from a cue file", Args: cobra.ExactArgs(1), PreRun: func(cmd *cobra.Command, args []string) { // Fix Viper bug for duplicate flags: diff --git a/cmd/dagger/cmd/layout/git.go b/cmd/dagger/cmd/plan/git.go similarity index 91% rename from cmd/dagger/cmd/layout/git.go rename to cmd/dagger/cmd/plan/git.go index dd4ca02d..8f9c3a1f 100644 --- a/cmd/dagger/cmd/layout/git.go +++ b/cmd/dagger/cmd/plan/git.go @@ -1,4 +1,4 @@ -package layout +package plan import ( "github.com/spf13/cobra" @@ -7,7 +7,7 @@ import ( var gitCmd = &cobra.Command{ Use: "git REMOTE REF [SUBDIR]", - Short: "Load layout from a git package", + Short: "Load plan from a git package", Args: cobra.MinimumNArgs(2), PreRun: func(cmd *cobra.Command, args []string) { // Fix Viper bug for duplicate flags: diff --git a/cmd/dagger/cmd/layout/package.go b/cmd/dagger/cmd/plan/package.go similarity index 91% rename from cmd/dagger/cmd/layout/package.go rename to cmd/dagger/cmd/plan/package.go index e8705d7a..215225cb 100644 --- a/cmd/dagger/cmd/layout/package.go +++ b/cmd/dagger/cmd/plan/package.go @@ -1,4 +1,4 @@ -package layout +package plan import ( "github.com/spf13/cobra" @@ -7,7 +7,7 @@ import ( var packageCmd = &cobra.Command{ Use: "package PKG", - Short: "Load layout from a cue package", + Short: "Load plan from a cue package", Args: cobra.ExactArgs(1), PreRun: func(cmd *cobra.Command, args []string) { // Fix Viper bug for duplicate flags: diff --git a/cmd/dagger/cmd/layout/root.go b/cmd/dagger/cmd/plan/root.go similarity index 71% rename from cmd/dagger/cmd/layout/root.go rename to cmd/dagger/cmd/plan/root.go index c47d8668..6e713d34 100644 --- a/cmd/dagger/cmd/layout/root.go +++ b/cmd/dagger/cmd/plan/root.go @@ -1,11 +1,11 @@ -package layout +package plan import "github.com/spf13/cobra" // Cmd exposes the top-level command var Cmd = &cobra.Command{ - Use: "layout", - Short: "Manage a deployment's layout", + Use: "plan", + Short: "Manage a deployment's plan", } func init() { diff --git a/cmd/dagger/cmd/query.go b/cmd/dagger/cmd/query.go index 646571b1..a0a7502c 100644 --- a/cmd/dagger/cmd/query.go +++ b/cmd/dagger/cmd/query.go @@ -57,7 +57,7 @@ func init() { queryCmd.Flags().BoolP("--no-input", "I", false, "Exclude inputs from query") queryCmd.Flags().BoolP("--no-output", "O", false, "Exclude outputs from query") - queryCmd.Flags().BoolP("--no-layout", "L", false, "Exclude outputs from query") + queryCmd.Flags().BoolP("--no-plan", "P", false, "Exclude outputs from query") if err := viper.BindPFlags(queryCmd.Flags()); err != nil { panic(err) diff --git a/cmd/dagger/cmd/root.go b/cmd/dagger/cmd/root.go index 5a6d904d..39d73ebf 100644 --- a/cmd/dagger/cmd/root.go +++ b/cmd/dagger/cmd/root.go @@ -5,8 +5,8 @@ import ( "strings" inputCmd "dagger.io/go/cmd/dagger/cmd/input" - "dagger.io/go/cmd/dagger/cmd/layout" "dagger.io/go/cmd/dagger/cmd/output" + "dagger.io/go/cmd/dagger/cmd/plan" "dagger.io/go/cmd/dagger/logger" "github.com/moby/buildkit/util/appcontext" "github.com/opentracing/opentracing-go" @@ -36,7 +36,7 @@ func init() { historyCmd, loginCmd, logoutCmd, - layout.Cmd, + plan.Cmd, inputCmd.Cmd, output.Cmd, ) diff --git a/cmd/dagger/cmd/up.go b/cmd/dagger/cmd/up.go index 07cc30f4..fdf43f57 100644 --- a/cmd/dagger/cmd/up.go +++ b/cmd/dagger/cmd/up.go @@ -11,7 +11,7 @@ import ( var upCmd = &cobra.Command{ Use: "up", - Short: "Bring a deployment online with latest layout and inputs", + Short: "Bring a deployment online with latest plan and inputs", Args: cobra.NoArgs, PreRun: func(cmd *cobra.Command, args []string) { // Fix Viper bug for duplicate flags: diff --git a/dagger/client.go b/dagger/client.go index 4a7b29f3..265ecffb 100644 --- a/dagger/client.go +++ b/dagger/client.go @@ -132,7 +132,7 @@ func (c *Client) buildfn(ctx context.Context, deployment *Deployment, ch chan *b s := NewSolver(c.c, gw, ch) lg.Debug().Msg("loading configuration") - if err := deployment.LoadLayout(ctx, s); err != nil { + if err := deployment.LoadPlan(ctx, s); err != nil { return nil, err } diff --git a/dagger/deployment.go b/dagger/deployment.go index da00783a..e813d3a6 100644 --- a/dagger/deployment.go +++ b/dagger/deployment.go @@ -28,9 +28,9 @@ type DeploymentState struct { // FIXME: store multiple names? Name string `json:"name,omitempty"` - // Cue module containing the deployment layout + // Cue module containing the deployment plan // The input's top-level artifact is used as a module directory. - LayoutSource Input `json:"layout,omitempty"` + PlanSource Input `json:"plan,omitempty"` Inputs []inputKV `json:"inputs,omitempty"` } @@ -64,8 +64,8 @@ func (s *DeploymentState) RemoveInputs(key string) error { type Deployment struct { st *DeploymentState - // Layer 1: layout configuration - layout *compiler.Value + // Layer 1: plan configuration + plan *compiler.Value // Layer 2: user inputs input *compiler.Value @@ -73,7 +73,7 @@ type Deployment struct { // Layer 3: computed values output *compiler.Value - // All layers merged together: layout + input + output + // All layers merged together: plan + input + output state *compiler.Value } @@ -81,7 +81,7 @@ func NewDeployment(st *DeploymentState) (*Deployment, error) { empty := compiler.EmptyStruct() d := &Deployment{ st: st, - layout: empty, + plan: empty, input: empty, output: empty, } @@ -116,12 +116,12 @@ func (d *Deployment) Name() string { return d.st.Name } -func (d *Deployment) LayoutSource() Input { - return d.st.LayoutSource +func (d *Deployment) PlanSource() Input { + return d.st.PlanSource } -func (d *Deployment) Layout() *compiler.Value { - return d.layout +func (d *Deployment) Plan() *compiler.Value { + return d.plan } func (d *Deployment) Input() *compiler.Value { @@ -136,19 +136,19 @@ func (d *Deployment) State() *compiler.Value { return d.state } -// LoadLayout loads the layout -func (d *Deployment) LoadLayout(ctx context.Context, s Solver) error { - span, ctx := opentracing.StartSpanFromContext(ctx, "deployment.LoadLayout") +// LoadPlan loads the plan +func (d *Deployment) LoadPlan(ctx context.Context, s Solver) error { + span, ctx := opentracing.StartSpanFromContext(ctx, "deployment.LoadPlan") defer span.Finish() - layoutSource, err := d.st.LayoutSource.Compile() + planSource, err := d.st.PlanSource.Compile() if err != nil { return err } p := NewPipeline("[internal] source", s, nil) // execute updater script - if err := p.Do(ctx, layoutSource); err != nil { + if err := p.Do(ctx, planSource); err != nil { return err } @@ -157,11 +157,11 @@ func (d *Deployment) LoadLayout(ctx context.Context, s Solver) error { stdlib.Path: stdlib.FS, "/": p.FS(), } - layout, err := compiler.Build(sources) + plan, err := compiler.Build(sources) if err != nil { - return fmt.Errorf("layout config: %w", err) + return fmt.Errorf("plan config: %w", err) } - d.layout = layout + d.plan = plan // Commit return d.mergeState() @@ -202,12 +202,12 @@ func (d *Deployment) LocalDirs() map[string]string { localdirs(v.Get("#compute")) } - // 2. Scan the layout - layout, err := d.st.LayoutSource.Compile() + // 2. Scan the plan + plan, err := d.st.PlanSource.Compile() if err != nil { panic(err) } - localdirs(layout) + localdirs(plan) return dirs } @@ -225,7 +225,7 @@ func (d *Deployment) mergeState() error { err error ) - stateInst, err = stateInst.Fill(d.layout.Cue()) + stateInst, err = stateInst.Fill(d.plan.Cue()) if err != nil { return fmt.Errorf("merge base & input: %w", err) } diff --git a/dagger/input_test.go b/dagger/input_test.go index 5f61d0b5..c1089051 100644 --- a/dagger/input_test.go +++ b/dagger/input_test.go @@ -8,7 +8,7 @@ import ( func TestInputDir(t *testing.T) { st := &DeploymentState{ - LayoutSource: DirInput("/tmp/source", []string{}), + PlanSource: DirInput("/tmp/source", []string{}), } require.NoError(t, st.AddInput("www.source", DirInput(".", []string{}))) diff --git a/dagger/store.go b/dagger/store.go index 85bd81f8..cc1f22fd 100644 --- a/dagger/store.go +++ b/dagger/store.go @@ -120,7 +120,7 @@ func (s *Store) indexDeployment(r *DeploymentState) { s.pathsByDeployment[r.ID] = append(s.pathsByDeployment[r.ID], i.Dir.Path) } - mapPath(r.LayoutSource) + mapPath(r.PlanSource) for _, i := range r.Inputs { mapPath(i.Value) }