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.
This commit is contained in:
Matt Ellis 2017-08-29 17:57:01 -07:00
parent 3becc6a4f4
commit 871b8ba962
5 changed files with 9 additions and 19 deletions

View file

@ -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 [<package>] [-- [<args>]]",
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
}

View file

@ -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")
}
}

View file

@ -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")
}

View file

@ -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

View file

@ -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)