INNER CODE UNIT · Go

convertPayloadToLocalStateDataValue

dikhan/terraform-provider-openapi · openapi/common.go:197

func convertPayloadToLocalStateDataValue(property *SpecSchemaDefinitionProperty, propertyValue interface{}) (interface{}, error) {
	if propertyValue == nil {
		return nil, nil
	}
	dataValueKind := reflect.TypeOf(propertyValue).Kind()
	switch dataValueKind {
	case reflect.Map:
		objectInput := map[string]interface{}{}
		mapValue := propertyValue.(map[string]interface{})
		for propertyName, propertyValue := range mapValue {
			schemaDefinitionProperty, err := property.SpecSchemaDefinition.getProperty(propertyName)
			if err != nil {
				return nil, err
			}
			var propValue interface{}
			// Here we are processing the items of the list which are objects. In this case we need to keep the original
			// types as Terraform honors property types for resource schemas attached to TypeList properties
			propValue, err = convertPayloadToLocalStateDataValue(schemaDefinitionProperty, propertyValue)

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…