Skip to content

Commit

Permalink
Add support for multiple varfiles
Browse files Browse the repository at this point in the history
Fixes #25
  • Loading branch information
rgreinho committed Mar 31, 2020
1 parent 1ddd8c9 commit c5c34b0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Added

* Support multiple varfiles when create/updating variables. [#]

### Fixed

* Incorrect enconding of HCL lists. [#27]
Expand Down Expand Up @@ -51,3 +55,4 @@ Initial version with support for managing:
[#20]: https://github.com/rgreinho/tfe-cli/pull/20
[#23]: https://github.com/rgreinho/tfe-cli/pull/23
[#27]: https://github.com/rgreinho/tfe-cli/pull/27
[#]: https://github.com/rgreinho/tfe-cli/pull/
6 changes: 3 additions & 3 deletions cmd/variable.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ var variableCreateCmd = &cobra.Command{
EnvVars, _ := cmd.Flags().GetStringArray("evar")
sEnvVars, _ := cmd.Flags().GetStringArray("sevar")
force, _ := cmd.Flags().GetBool("force")
varFile, _ := cmd.Flags().GetString("var-file")
varFiles, _ := cmd.Flags().GetStringArray("var-file")

// Setup the command.
organization, client, err := setup(cmd)
Expand All @@ -59,7 +59,7 @@ var variableCreateCmd = &cobra.Command{
varOptions = append(varOptions, createVariableOptions(sEnvVars, tfe.CategoryEnv, false, true)...)

// Read variables from file.
if varFile != "" {
for _, varFile := range varFiles {
// Read the content of the file.
FileContent, err := ioutil.ReadFile(varFile)
if err != nil {
Expand Down Expand Up @@ -233,7 +233,7 @@ func init() {
variableCreateCmd.Flags().StringArray("shvar", []string{}, "Create a sensitive HCL variable")
variableCreateCmd.Flags().StringArray("evar", []string{}, "Create an environment variable")
variableCreateCmd.Flags().StringArray("sevar", []string{}, "Create a sensitive environment variable")
variableCreateCmd.Flags().String("var-file", "", "Create non-sensitive regular and HCL variables from a file")
variableCreateCmd.Flags().StringArray("var-file", []string{}, "Create non-sensitive regular and HCL variables from a file")
variableCreateCmd.Flags().BoolP("force", "f", false, "Overwrite a variable if it exists")
}

Expand Down

0 comments on commit c5c34b0

Please sign in to comment.