func()

in mmv1/api/type.go [971:1009]


func (t *Type) validateLabelsField() {
	productName := t.ResourceMetadata.ProductMetadata.Name
	resourceName := t.ResourceMetadata.Name
	lineage := t.Lineage()
	if lineage == "labels" || lineage == "metadata.labels" || lineage == "configuration.labels" {
		if !t.IsA("KeyValueLabels") &&
			// The label value must be empty string, so skip this resource
			!(productName == "CloudIdentity" && resourceName == "Group") &&

			// The "labels" field has type Array, so skip this resource
			!(productName == "DeploymentManager" && resourceName == "Deployment") &&

			// https://github.com/hashicorp/terraform-provider-google/issues/16219
			!(productName == "Edgenetwork" && resourceName == "Network") &&

			// https://github.com/hashicorp/terraform-provider-google/issues/16219
			!(productName == "Edgenetwork" && resourceName == "Subnet") &&

			// "userLabels" is the resource labels field
			!(productName == "Monitoring" && resourceName == "NotificationChannel") &&

			// The "labels" field has type Array, so skip this resource
			!(productName == "Monitoring" && resourceName == "MetricDescriptor") {
			log.Fatalf("Please use type KeyValueLabels for field %s in resource %s/%s", lineage, productName, resourceName)
		}
	} else if t.IsA("KeyValueLabels") {
		log.Fatalf("Please don't use type KeyValueLabels for field %s in resource %s/%s", lineage, productName, resourceName)
	}

	if lineage == "annotations" || lineage == "metadata.annotations" {
		if !t.IsA("KeyValueAnnotations") &&
			// The "annotations" field has "ouput: true", so skip this eap resource
			!(productName == "Gkeonprem" && resourceName == "BareMetalAdminClusterEnrollment") {
			log.Fatalf("Please use type KeyValueAnnotations for field %s in resource %s/%s", lineage, productName, resourceName)
		}
	} else if t.IsA("KeyValueAnnotations") {
		log.Fatalf("Please don't use type KeyValueAnnotations for field %s in resource %s/%s", lineage, productName, resourceName)
	}
}