MCPcopy Index your code
hub / github.com/coder/coder / createVariablesMapFromFile

Function createVariablesMapFromFile

codersdk/templatevariables.go:220–236  ·  view source on GitHub ↗

Reads a YAML file and populates a string -> string map. Throws an error if the file name is empty.

(variablesFile string)

Source from the content-addressed store, hash-verified

218// Reads a YAML file and populates a string -> string map.
219// Throws an error if the file name is empty.
220func createVariablesMapFromFile(variablesFile string) (map[string]string, error) {
221 if variablesFile == "" {
222 return nil, xerrors.Errorf("variable file name is not specified")
223 }
224
225 variablesMap := make(map[string]string)
226 variablesFileContents, err := os.ReadFile(variablesFile)
227 if err != nil {
228 return nil, err
229 }
230
231 err = yaml.Unmarshal(variablesFileContents, &variablesMap)
232 if err != nil {
233 return nil, err
234 }
235 return variablesMap, nil
236}
237
238func parseVariableValuesFromCommandLine(variables []string) ([]VariableValue, error) {
239 var values []VariableValue

Callers 1

Calls 3

ReadFileMethod · 0.65
ErrorfMethod · 0.45
UnmarshalMethod · 0.45

Tested by

no test coverage detected