func NavigateToNestedBlock()

in provider-schema/result.go [66:92]


func NavigateToNestedBlock(objectName, path string) (*schema.SchemaAttribute, error) {
	resource, exists := GetFinalTerraformObject()[objectName]
	if !exists {
		return nil, fmt.Errorf("resource/data source '%s' not found", objectName)
	}

	parts := strings.Split(path, ".")
	if len(parts) == 0 {
		return nil, fmt.Errorf("invalid path '%s'", path)
	}

	curFields := resource.Fields
	var result *schema.SchemaAttribute
	for _, part := range parts {
		result, exists = curFields[part]
		if !exists {
			return nil, fmt.Errorf("path '%s' not found in resource/data source '%s'", path, objectName)
		}
		curFields = result.Fields
	}

	if result == nil {
		return nil, fmt.Errorf("path '%s' is nil in resource/data source '%s'", path, objectName)
	}

	return result, nil
}