Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for multiple varfiles #28

Merged
merged 1 commit into from
Mar 31, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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. [#28]

### 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
[#28]: https://github.com/rgreinho/tfe-cli/pull/28
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