From 871b8ba9624a66aca509d0195655d30b6ff10451 Mon Sep 17 00:00:00 2001 From: Matt Ellis Date: Tue, 29 Aug 2017 17:57:01 -0700 Subject: [PATCH] Remove ability to specify a file name when saving an environment We'd like to abstract out environment CRUD operations and I'd prefer not to have to bake in the conspect of a file name like thing in the abstraction. Since we were not really using this feature many places, let's just get rid of it. --- cmd/lumi/deploy.go | 5 ----- pkg/engine/config_delete.go | 2 +- pkg/engine/config_set.go | 4 ++-- pkg/engine/deploy.go | 9 +++------ pkg/engine/env.go | 8 +++----- 5 files changed, 9 insertions(+), 19 deletions(-) diff --git a/cmd/lumi/deploy.go b/cmd/lumi/deploy.go index 55b81d2d3..74534e132 100644 --- a/cmd/lumi/deploy.go +++ b/cmd/lumi/deploy.go @@ -19,7 +19,6 @@ func newDeployCmd() *cobra.Command { var showReplacementSteps bool var showSames bool var summary bool - var output string var cmd = &cobra.Command{ Use: "deploy [] [-- []]", Aliases: []string{"run", "up", "update"}, @@ -47,7 +46,6 @@ func newDeployCmd() *cobra.Command { ShowReplacementSteps: showReplacementSteps, ShowSames: showSames, Summary: summary, - Output: output, }) }), } @@ -79,9 +77,6 @@ func newDeployCmd() *cobra.Command { cmd.PersistentFlags().BoolVarP( &summary, "summary", "s", false, "Only display summarization of resources and plan operations") - cmd.PersistentFlags().StringVarP( - &output, "output", "o", "", - "Serialize the resulting checkpoint to a specific file, instead of overwriting the existing one") return cmd } diff --git a/pkg/engine/config_delete.go b/pkg/engine/config_delete.go index e0d093828..d4efde0e0 100644 --- a/pkg/engine/config_delete.go +++ b/pkg/engine/config_delete.go @@ -15,7 +15,7 @@ func (eng *Engine) DeleteConfig(envName string, key string) error { if config != nil { delete(config, tokens.Token(key)) - if !eng.saveEnv(info.Target, info.Snapshot, "", true) { + if !eng.saveEnv(info.Target, info.Snapshot, true) { return errors.Errorf("could not save configuration value") } } diff --git a/pkg/engine/config_set.go b/pkg/engine/config_set.go index a74806053..bb4ed300d 100644 --- a/pkg/engine/config_set.go +++ b/pkg/engine/config_set.go @@ -20,7 +20,7 @@ func (eng *Engine) SetConfig(envName string, key string, value string) error { config[tokens.Token(key)] = value - if !eng.saveEnv(info.Target, info.Snapshot, "", true) { + if !eng.saveEnv(info.Target, info.Snapshot, true) { return errors.Errorf("could not save configuration value") } @@ -43,7 +43,7 @@ func (eng *Engine) ReplaceConfig(envName string, newConfig map[string]string) er info.Target.Config = config - if !eng.saveEnv(info.Target, info.Snapshot, "", true) { + if !eng.saveEnv(info.Target, info.Snapshot, true) { return errors.Errorf("could not save configuration value") } diff --git a/pkg/engine/deploy.go b/pkg/engine/deploy.go index 43dbef467..c3d6b7d07 100644 --- a/pkg/engine/deploy.go +++ b/pkg/engine/deploy.go @@ -17,7 +17,6 @@ type DeployOptions struct { Environment string // the environment we are deploying into Package string // the package we are deploying (or "" to use the default) Analyzers []string // an optional set of analyzers to run as part of this deployment. - Output string // the place to store the output, if any. Debug bool // true to enable resource debugging output. DryRun bool // true if we should just print the plan without performing it. ShowConfig bool // true to show the configuration variables being used. @@ -42,7 +41,6 @@ func (eng *Engine) Deploy(opts DeployOptions) error { ShowReplacementSteps: opts.ShowReplacementSteps, ShowSames: opts.ShowSames, Summary: opts.Summary, - Output: opts.Output, }) } @@ -58,7 +56,6 @@ type deployOptions struct { ShowSames bool // true to show the resources that aren't updated, in addition to those that are. Summary bool // true if we should only summarize resources and operations. DOT bool // true if we should print the DOT file for this plan. - Output string // the place to store the output, if any. } func (eng *Engine) deployLatest(info *envCmdInfo, opts deployOptions) error { @@ -104,10 +101,10 @@ func (eng *Engine) deployLatest(info *envCmdInfo, opts deployOptions) error { colors.SpecAttention, colors.Reset)) } - // Now save the updated snapshot to the specified output file, if any, or the standard location otherwise. - // Note that if a failure has occurred, the Apply routine above will have returned a safe checkpoint. + // Now save the updated snapshot Notee that if a failure has occurred, the Apply routine above will + // have returned a safe checkpoint. targ := result.Info.Target - eng.saveEnv(targ, summary.Snap(), opts.Output, true /*overwrite*/) + eng.saveEnv(targ, summary.Snap(), true /*overwrite*/) fmt.Fprint(eng.Stdout, colors.Colorize(&footer)) return err diff --git a/pkg/engine/env.go b/pkg/engine/env.go index d92cd03ac..10bb945d9 100644 --- a/pkg/engine/env.go +++ b/pkg/engine/env.go @@ -61,7 +61,7 @@ type envCmdInfo struct { // createEnv just creates a new empty environment without deploying anything into it. func (eng *Engine) createEnv(name tokens.QName) { env := &deploy.Target{Name: name} - if success := eng.saveEnv(env, nil, "", false); success { + if success := eng.saveEnv(env, nil, false); success { fmt.Fprintf(eng.Stdout, "Environment '%v' initialized; see `lumi deploy` to deploy into it\n", name) eng.setCurrentEnv(name, false) } @@ -190,11 +190,9 @@ func (eng *Engine) readEnv(name tokens.QName) (*deploy.Target, *deploy.Snapshot, } // saveEnv saves a new snapshot at the given location, backing up any existing ones. -func (eng *Engine) saveEnv(env *deploy.Target, snap *deploy.Snapshot, file string, existok bool) bool { +func (eng *Engine) saveEnv(env *deploy.Target, snap *deploy.Snapshot, existok bool) bool { contract.Require(env != nil, "env") - if file == "" { - file = workspace.EnvPath(env.Name) - } + file := workspace.EnvPath(env.Name) // Make a serializable LumiGL data structure and then use the encoder to encode it. m, ext := encoding.Detect(file)