Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrorMessageFunc = function.New(&function.Spec{ Description: ` Given a reference to a step, error_message will return a string containing the first error message, if any. If there were no errors, it will return an empty string. This is useful for simple step primitives.`, Params: []function.Parameter{ { Name: "step", Type: cty.DynamicPseudoType, AllowUnknown: true, AllowDynamicType: true, AllowNull: true, }, }, Type: function.StaticReturnType(cty.String), Impl: func(args []cty.Value, retType cty.Type) (cty.Value, error) { if len(args) == 0 { return cty.StringVal(""), nil } val := args[0] valueMap := val.AsValueMap() if valueMap == nil { return cty.StringVal(""), nil } if valueMap["errors"].IsNull() { return cty.StringVal(""), nil } errors := valueMap["errors"].AsValueSlice() if len(errors) == 0 { return cty.StringVal(""), nil } firstError := errors[0] firstErrorMap := firstError.AsValueMap() return firstErrorMap[schema.AttributeTypeMessage], nil }, })
error_message: Given a reference to a step, error_message will return a string containing the first error message, if any. If there were no errors, it will return an empty string. This is useful for simple step primitives.
View Source
var IsErrorFunc = function.New(&function.Spec{ Description: `Given a reference to a step, is_error returns a boolean true if there are 1 or more errors, or false it there are no errors.`, Params: []function.Parameter{ { Name: "step", Type: cty.DynamicPseudoType, AllowUnknown: true, AllowDynamicType: true, AllowNull: true, }, }, Type: function.StaticReturnType(cty.Bool), Impl: func(args []cty.Value, retType cty.Type) (cty.Value, error) { val := args[0] valueMap := val.AsValueMap() if valueMap == nil { return cty.True, nil } if valueMap["errors"].IsNull() { return cty.False, nil } return cty.True, nil }, })
is_error: Given a reference to a step, is_error returns a boolean true if there are 1 or more errors, or false it there are no errors.
View Source
var ParseQueryString = function.New(&function.Spec{ Params: []function.Parameter{ { Name: "query", Type: cty.String, }, }, Type: function.StaticReturnType(cty.Map(cty.String)), Impl: func(args []cty.Value, retType cty.Type) (ret cty.Value, err error) { query := args[0].AsString() parsedQuery, err := url.ParseQuery(query) if err != nil { return cty.UnknownVal(cty.Map(cty.String)), err } result := make(map[string]cty.Value) for key, values := range parsedQuery { result[key] = cty.StringVal(values[len(values)-1]) } return cty.MapVal(result), nil }, })
Functions ¶
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.