INNER CODE UNIT · Go

dataSourceUpdateStateWithPayloadData

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

func dataSourceUpdateStateWithPayloadData(openAPIResource SpecResource, remoteData map[string]interface{}, resourceLocalData *schema.ResourceData) error {
	return updateStateWithPayloadDataAndOptions(openAPIResource, remoteData, resourceLocalData, false)
}

// updateStateWithPayloadDataAndOptions is in charge of saving the given payload into the state file AND if the ignoreListOrder is enabled
// it will go ahead and compare the items in the list (input vs remote) for properties of type list and the flag 'IgnoreItemsOrder' set to true
// The property names are converted into compliant terraform names if needed.
func updateStateWithPayloadDataAndOptions(openAPIResource SpecResource, remoteData map[string]interface{}, resourceLocalData *schema.ResourceData, ignoreListOrderEnabled bool) error {
	resourceSchema, err := openAPIResource.GetResourceSchema()
	if err != nil {
		return err
	}
	for propertyName, propertyRemoteValue := range remoteData {
		property, err := resourceSchema.getProperty(propertyName)
		if err != nil {
			log.Printf("[WARN] The API returned a property that is not specified in the resource's schema definition in the OpenAPI document - error = %s", err)
			continue
		}

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…