func unmarshalToNestedStruct()

in pkg/config/metadata.go [148:166]


func unmarshalToNestedStruct(originalValue interface{}, unmarshalToStruct interface{}) (interface{}, error) {
	valAsJson, err := json.Marshal(originalValue)
	if err != nil {
		return nil, err
	}

	// all supported nested structs
	switch unmarshalToStruct.(type) {
	case types.ElasticInferenceAccelerator:
		nestedStruct, ok := unmarshalToStruct.(types.ElasticInferenceAccelerator)
		if ok {
			if err = json.Unmarshal(valAsJson, &nestedStruct); err != nil {
				return nil, err
			}
			return nestedStruct, nil
		}
	}
	return nil, nil
}