8000 feat: Read params from file for template/workspace creation by AbhineetJain · Pull Request #1541 · coder/coder · GitHub
[go: up one dir, main page]

Skip to content

feat: Read params from file for template/workspace creation #1541

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

Merged
merged 13 commits into from
May 20, 2022
Merged
Prev Previous commit
Next Next commit
Rename variable
  • Loading branch information
AbhineetJain committed May 20, 2022
commit 8a075f45fa07dfc3f5145c040b555b2137ad9614
8 changes: 4 additions & 4 deletions cli/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,11 @@ func create() *cobra.Command {
return err
}

// parameterMap can be nil if the file is not specified or invalid
var parameterMap map[string]string
// parameterMapFromFile can be nil if the file is not specified or invalid
var parameterMapFromFile map[string]string
if parameterFile != "" {
_, _ = fmt.Fprintln(cmd.OutOrStdout(), cliui.Styles.Paragraph.Render("Attempting to read the variables from the parameter file.")+"\r\n")
parameterMap, err = createParameterMapFromFile(parameterFile)
parameterMapFromFile, err = createParameterMapFromFile(parameterFile)
if err != nil {
return err
}
Expand All @@ -137,7 +137,7 @@ func create() *cobra.Command {
_, _ = fmt.Fprintln(cmd.OutOrStdout(), cliui.Styles.Paragraph.Render("This template has customizable parameters. Values can be changed after create, but may have unintended side effects (like data loss).")+"\r\n")
disclaimerPrinted = true
}
parameterValue, err := getParameterValueFromMapOrInput(cmd, parameterMap, parameterSchema)
parameterValue, err := getParameterValueFromMapOrInput(cmd, parameterMapFromFile, parameterSchema)
if err != nil {
return err
}
Expand Down
8 changes: 4 additions & 4 deletions cli/templatecreate.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,17 +187,17 @@ func createValidTemplateVersion(cmd *cobra.Command, client *codersdk.Client, org
}
_, _ = fmt.Fprintln(cmd.OutOrStdout(), cliui.Styles.Paragraph.Render("This template has required variables! They are scoped to the template, and not viewable after being set.")+"\r\n")

// parameterMap can be nil if the file is not specified or invalid
var parameterMap map[string]string
// parameterMapFromFile can be nil if the file is not specified or invalid
var parameterMapFromFile map[string]string
if parameterFile != "" {
_, _ = fmt.Fprintln(cmd.OutOrStdout(), cliui.Styles.Paragraph.Render("Attempting to read the variables from the parameter file.")+"\r\n")
parameterMap, err = createParameterMapFromFile(parameterFile)
parameterMapFromFile, err = createParameterMapFromFile(parameterFile)
if err != nil {
return nil, nil, err
}
}
for _, parameterSchema := range missingSchemas {
parameterValue, err := getParameterValueFromMapOrInput(cmd, parameterMap, parameterSchema)
parameterValue, err := getParameterValueFromMapOrInput(cmd, parameterMapFromFile, parameterSchema)
if err != nil {
return nil, nil, err
}
Expand Down
0