Skip to content

Commit

Permalink
Make meta data converter mapping generic and populate provisioner met…
Browse files Browse the repository at this point in the history
…a info

Signed-off-by: Shobha M <mshobha@vmware.com>
  • Loading branch information
shobha2626 committed Feb 20, 2024
1 parent aa47e00 commit c178b75
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
12 changes: 6 additions & 6 deletions internal/resources/common/objectmeta_schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,17 +171,17 @@ func GetTypeIntMapData(data map[string]interface{}) map[string]int {
}

// GetMetaConverterMap returns mapping for converter.
func GetMetaConverterMap(modelPathSeparator string) *converter.BlockToStruct {
func GetMetaConverterMap(modelPathSeparator string, modelPath ...string) *converter.BlockToStruct {
var MetaConverterMap = &converter.BlockToStruct{
AnnotationsKey: &converter.Map{
converter.AllMapKeysFieldMarker: converter.BuildModelPath(modelPathSeparator, "meta", "annotations", converter.AllMapKeysFieldMarker),
converter.AllMapKeysFieldMarker: converter.BuildModelPath(modelPathSeparator, append(modelPath, "meta", "annotations", converter.AllMapKeysFieldMarker)...),
},
LabelsKey: &converter.Map{
converter.AllMapKeysFieldMarker: converter.BuildModelPath(modelPathSeparator, "meta", "labels", converter.AllMapKeysFieldMarker),
converter.AllMapKeysFieldMarker: converter.BuildModelPath(modelPathSeparator, append(modelPath, "meta", "labels", converter.AllMapKeysFieldMarker)...),
},
DescriptionKey: converter.BuildModelPath(modelPathSeparator, "meta", "description"),
resourceVersionKey: converter.BuildModelPath(modelPathSeparator, "meta", "resourceVersion"),
uidKey: converter.BuildModelPath(modelPathSeparator, "meta", "uid"),
DescriptionKey: converter.BuildModelPath(modelPathSeparator, append(modelPath, "meta", "description")...),
resourceVersionKey: converter.BuildModelPath(modelPathSeparator, append(modelPath, "meta", "resourceVersion")...),
uidKey: converter.BuildModelPath(modelPathSeparator, append(modelPath, "meta", "uid")...),
}

return MetaConverterMap
Expand Down
2 changes: 1 addition & 1 deletion internal/resources/provisioner/converter_mapping.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ var tfDataModelMap = &tfModelConverterHelper.BlockToStruct{
{
managementClusterNameKey: tfModelConverterHelper.BuildDefaultModelPath(provisionerArrayField, "fullName", "managementClusterName"),
nameKey: tfModelConverterHelper.BuildDefaultModelPath(provisionerArrayField, "fullName", "name"),
common.MetaKey: common.GetMetaConverterMap(tfModelConverterHelper.DefaultModelPathSeparator),
common.MetaKey: common.GetMetaConverterMap(tfModelConverterHelper.DefaultModelPathSeparator, provisionerArrayField),
},
},
}
Expand Down

0 comments on commit c178b75

Please sign in to comment.