Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

importer-rest-api-specs - producing duplicate DirectAssignment mappings when create and read property payloads become optional #3588

Open
stephybun opened this issue Jan 9, 2024 · 0 comments
Labels
tool/data-api Issues with the Data API

Comments

@stephybun
Copy link
Member

To support generating simple resources that contain a resource ID segment of type scope we've had to introduce the changes in #3586.

One of the changes reverses the logic for when we set the Create and Read property payload and model names, no longer throwing an error if they are missing. As a result these properties are no longer required and have become optional. This change should also be reflected in the model for the operationPayloads, making the properties pointers:

type operationPayloads struct {
createModelName string
createPayload resourcemanager.ModelDetails
createPropertiesModelName string
createPropertiesPayload resourcemanager.ModelDetails
readModelName string
readPayload resourcemanager.ModelDetails
readPropertiesModelName string
readPropertiesPayload resourcemanager.ModelDetails
updateModelName *string
updatePayload *resourcemanager.ModelDetails
updatePropertiesModelName *string
updatePropertiesPayload *resourcemanager.ModelDetails
}

Making this change results in duplicate DirectAssignment definitions in all the existing generated resources
e.g. the fieldMappings field in KubernetesClusterTrustedAccessRoleBinding-Resource-Mappings.json now looks like so:

"fieldMappings": [
		{
			"type": "DirectAssignment",
			"directAssignment": {
				"schemaModelName": "KubernetesClusterTrustedAccessRoleBindingResourceSchema",
				"schemaFieldPath": "Roles",
				"sdkModelName": "TrustedAccessRoleBindingProperties",
				"sdkFieldPath": "Roles"
			}
		},
		{
			"type": "DirectAssignment",
			"directAssignment": {
				"schemaModelName": "KubernetesClusterTrustedAccessRoleBindingResourceSchema",
				"schemaFieldPath": "Roles",
				"sdkModelName": "TrustedAccessRoleBindingProperties",
				"sdkFieldPath": "Roles"
			}
		},
		{
			"type": "DirectAssignment",
			"directAssignment": {
				"schemaModelName": "KubernetesClusterTrustedAccessRoleBindingResourceSchema",
				"schemaFieldPath": "SourceResourceId",
				"sdkModelName": "TrustedAccessRoleBindingProperties",
				"sdkFieldPath": "SourceResourceId"
			}
		},
		{
			"type": "DirectAssignment",
			"directAssignment": {
				"schemaModelName": "KubernetesClusterTrustedAccessRoleBindingResourceSchema",
				"schemaFieldPath": "SourceResourceId",
				"sdkModelName": "TrustedAccessRoleBindingProperties",
				"sdkFieldPath": "SourceResourceId"
			}
		},
		{
			"type": "ModelToModel",
			"modelToModel": {
				"schemaModelName": "KubernetesClusterTrustedAccessRoleBindingResourceSchema",
				"sdkModelName": "TrustedAccessRoleBinding",
				"sdkFieldName": "Properties"
			}
		}
	],

Whereas it should actually remain like so

"fieldMappings": [
		{
			"type": "DirectAssignment",
			"directAssignment": {
				"schemaModelName": "KubernetesClusterTrustedAccessRoleBindingResourceSchema",
				"schemaFieldPath": "Roles",
				"sdkModelName": "TrustedAccessRoleBindingProperties",
				"sdkFieldPath": "Roles"
			}
		},
		{
			"type": "DirectAssignment",
			"directAssignment": {
				"schemaModelName": "KubernetesClusterTrustedAccessRoleBindingResourceSchema",
				"schemaFieldPath": "SourceResourceId",
				"sdkModelName": "TrustedAccessRoleBindingProperties",
				"sdkFieldPath": "SourceResourceId"
			}
		},
		{
			"type": "ModelToModel",
			"modelToModel": {
				"schemaModelName": "KubernetesClusterTrustedAccessRoleBindingResourceSchema",
				"sdkModelName": "TrustedAccessRoleBinding",
				"sdkFieldName": "Properties"
			}
		}
	],
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tool/data-api Issues with the Data API
Projects
None yet
Development

No branches or pull requests

1 participant