Add the config array option to the preview command. (#3271)
* Add the config array option to the preview command. * Update changelog
This commit is contained in:
parent
4404dfb470
commit
a0a86155c1
|
@ -15,6 +15,7 @@ CHANGELOG
|
|||
that contain secret values.
|
||||
[#3183](https://github.com/pulumi/pulumi/pull/3183)
|
||||
- Add Codefresh CI detection.
|
||||
- Add `-c` (config array) flag to the `preview` command.
|
||||
|
||||
## 1.1.0 (2019-09-11)
|
||||
|
||||
|
|
|
@ -30,6 +30,7 @@ func newPreviewCmd() *cobra.Command {
|
|||
var expectNop bool
|
||||
var message string
|
||||
var stack string
|
||||
var configArray []string
|
||||
|
||||
// Flags for engine.UpdateOptions.
|
||||
var policyPackPaths []string
|
||||
|
@ -93,6 +94,11 @@ func newPreviewCmd() *cobra.Command {
|
|||
return result.FromError(err)
|
||||
}
|
||||
|
||||
// Save any config values passed via flags.
|
||||
if err := parseAndSaveConfigArray(s, configArray); err != nil {
|
||||
return result.FromError(err)
|
||||
}
|
||||
|
||||
proj, root, err := readProject(pulumiAppProj)
|
||||
if err != nil {
|
||||
return result.FromError(err)
|
||||
|
@ -146,6 +152,9 @@ func newPreviewCmd() *cobra.Command {
|
|||
cmd.PersistentFlags().StringVar(
|
||||
&stackConfigFile, "config-file", "",
|
||||
"Use the configuration values in the specified file rather than detecting the file name")
|
||||
cmd.PersistentFlags().StringArrayVarP(
|
||||
&configArray, "config", "c", []string{},
|
||||
"Config to use during the preview")
|
||||
|
||||
cmd.PersistentFlags().StringVarP(
|
||||
&message, "message", "m", "",
|
||||
|
|
11
cmd/up.go
11
cmd/up.go
|
@ -74,15 +74,8 @@ func newUpCmd() *cobra.Command {
|
|||
}
|
||||
|
||||
// Save any config values passed via flags.
|
||||
if len(configArray) > 0 {
|
||||
commandLineConfig, err := parseConfig(configArray)
|
||||
if err != nil {
|
||||
return result.FromError(err)
|
||||
}
|
||||
|
||||
if err = saveConfig(s, commandLineConfig); err != nil {
|
||||
return result.FromError(errors.Wrap(err, "saving config"))
|
||||
}
|
||||
if err := parseAndSaveConfigArray(s, configArray); err != nil {
|
||||
return result.FromError(err)
|
||||
}
|
||||
|
||||
proj, root, err := readProject(pulumiAppProj)
|
||||
|
|
17
cmd/util.go
17
cmd/util.go
|
@ -324,6 +324,23 @@ const (
|
|||
pulumiPolicyProj projType = "pulumi-policy"
|
||||
)
|
||||
|
||||
// parseAndSaveConfigArray parses the config array and saves it as a config for
|
||||
// the provided stack.
|
||||
func parseAndSaveConfigArray(s backend.Stack, configArray []string) error {
|
||||
if len(configArray) == 0 {
|
||||
return nil
|
||||
}
|
||||
commandLineConfig, err := parseConfig(configArray)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err = saveConfig(s, commandLineConfig); err != nil {
|
||||
return errors.Wrap(err, "saving config")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// readProject attempts to detect and read a project of type `projType` for the current workspace.
|
||||
// If the project is successfully detected and read, it is returned along with the path to its
|
||||
// containing directory, which will be used as the root of the project's Pulumi program.
|
||||
|
|
Loading…
Reference in a new issue