MCPcopy
hub / github.com/TomWright/dasel / variableExprExecutor

Function variableExprExecutor

execution/execute.go:183–199  ·  view source on GitHub ↗
(e ast.VariableExpr)

Source from the content-addressed store, hash-verified

181}
182
183func variableExprExecutor(e ast.VariableExpr) (expressionExecutor, error) {
184 return func(ctx context.Context, options *Options, data *model.Value) (*model.Value, error) {
185 //ctx = WithExecutorID(ctx, "variableExpr")
186 varName := e.Name
187 res, ok := options.Vars[varName]
188 if ok {
189 return res, nil
190 }
191
192 envVarValue := os.Getenv(varName)
193 if envVarValue != "" {
194 return model.NewStringValue(envVarValue), nil
195 }
196
197 return nil, fmt.Errorf("variable %s not found", varName)
198 }, nil
199}

Callers 1

exprExecutorFunction · 0.85

Calls 1

NewStringValueFunction · 0.92

Tested by

no test coverage detected