From 3ccb5ed1ee240dc4746e2795977a998c5ab7fd14 Mon Sep 17 00:00:00 2001 From: Matthew Christopher Date: Fri, 1 Sep 2023 14:29:27 -0700 Subject: [PATCH] Support arbitrary ARM ID owners This closes #2357. Nearly all resources now support being owned by an arbitrary ARM ID. Only database user resources (MySQLUser, PostgreSQLUser) do not allow ARM ID ownership. This is because those resources must extract certain connection information from their parents and so must have access to their parents via the Kubernetes API. ARM ID ownership behaves the following way: * Resources owned by an ARM ID will continue to attempt to reconcile if that ID doesn't exist. When the owning resource cannot be found, the resource will report a Ready=false with a "Warning" and additional details. If possible, avoid deleting the owning ARM resource without also deleting the resources in Kubernetes. * The credential being used for the resource must have the same subscription ID as the owning ARM resource. This means if your global credential is for Subscription A you cannot have ARM ID owners from subscription B unless you also create a serviceoperator.azure.com/credential-from for subscription B. --- .../configuration_store_types_gen.go | 21 +- .../configuration_store_types_gen.go | 6 +- .../configuration_store_types_gen.go | 21 +- .../configuration_store_types_gen.go | 6 +- .../role_assignment_types_gen.go | 6 +- .../role_assignment_types_gen.go | 6 +- .../role_assignment_types_gen.go | 6 +- .../role_assignment_types_gen.go | 6 +- .../v1api20210101/batch_account_types_gen.go | 24 +- .../batch_account_types_gen.go | 6 +- .../v1beta20210101/batch_account_types_gen.go | 24 +- .../batch_account_types_gen.go | 6 +- .../redis_firewall_rule_types_gen.go | 24 +- .../redis_linked_server_types_gen.go | 24 +- .../redis_patch_schedule_types_gen.go | 24 +- v2/api/cache/v1api20201201/redis_types_gen.go | 21 +- .../redis_firewall_rule_types_gen.go | 6 +- .../redis_linked_server_types_gen.go | 6 +- .../redis_patch_schedule_types_gen.go | 6 +- .../v1api20201201storage/redis_types_gen.go | 6 +- .../redis_enterprise_database_types_gen.go | 24 +- .../redis_enterprise_types_gen.go | 24 +- .../redis_enterprise_database_types_gen.go | 6 +- .../redis_enterprise_types_gen.go | 6 +- .../redis_firewall_rule_types_gen.go | 24 +- .../redis_linked_server_types_gen.go | 24 +- .../redis_patch_schedule_types_gen.go | 24 +- v2/api/cache/v1api20230401/redis_types_gen.go | 21 +- .../redis_firewall_rule_types_gen.go | 6 +- .../redis_linked_server_types_gen.go | 6 +- .../redis_patch_schedule_types_gen.go | 6 +- .../v1api20230401storage/redis_types_gen.go | 6 +- .../redis_enterprise_database_types_gen.go | 24 +- .../redis_enterprise_types_gen.go | 24 +- .../redis_enterprise_database_types_gen.go | 6 +- .../redis_enterprise_types_gen.go | 6 +- .../redis_firewall_rule_types_gen.go | 24 +- .../redis_linked_server_types_gen.go | 24 +- .../redis_patch_schedule_types_gen.go | 24 +- .../cache/v1beta20201201/redis_types_gen.go | 21 +- .../redis_firewall_rule_types_gen.go | 6 +- .../redis_linked_server_types_gen.go | 6 +- .../redis_patch_schedule_types_gen.go | 6 +- .../v1beta20201201storage/redis_types_gen.go | 6 +- .../redis_enterprise_database_types_gen.go | 24 +- .../redis_enterprise_types_gen.go | 24 +- .../redis_enterprise_database_types_gen.go | 6 +- .../redis_enterprise_types_gen.go | 6 +- v2/api/cdn/v1api20210601/profile_types_gen.go | 24 +- .../profiles_endpoint_types_gen.go | 24 +- .../v1api20210601storage/profile_types_gen.go | 6 +- .../profiles_endpoint_types_gen.go | 6 +- .../cdn/v1beta20210601/profile_types_gen.go | 24 +- .../profiles_endpoint_types_gen.go | 24 +- .../profile_types_gen.go | 6 +- .../profiles_endpoint_types_gen.go | 6 +- .../compute/v1api20200930/disk_types_gen.go | 24 +- .../v1api20200930/snapshot_types_gen.go | 24 +- .../v1api20200930storage/disk_types_gen.go | 6 +- .../snapshot_types_gen.go | 6 +- .../virtual_machine_scale_set_types_gen.go | 24 +- .../virtual_machine_types_gen.go | 24 +- .../virtual_machine_scale_set_types_gen.go | 6 +- .../virtual_machine_types_gen.go | 6 +- .../compute/v1api20210701/image_types_gen.go | 24 +- .../v1api20210701storage/image_types_gen.go | 6 +- .../compute/v1api20220301/image_types_gen.go | 24 +- .../virtual_machine_scale_set_types_gen.go | 24 +- .../virtual_machine_types_gen.go | 24 +- .../v1api20220301storage/image_types_gen.go | 6 +- .../virtual_machine_scale_set_types_gen.go | 6 +- .../virtual_machine_types_gen.go | 6 +- .../disk_encryption_set_types_gen.go | 21 +- .../disk_encryption_set_types_gen.go | 6 +- .../compute/v1beta20200930/disk_types_gen.go | 24 +- .../v1beta20200930/snapshot_types_gen.go | 24 +- .../v1beta20200930storage/disk_types_gen.go | 6 +- .../snapshot_types_gen.go | 6 +- .../virtual_machine_scale_set_types_gen.go | 24 +- .../virtual_machine_types_gen.go | 24 +- .../virtual_machine_scale_set_types_gen.go | 6 +- .../virtual_machine_types_gen.go | 6 +- .../compute/v1beta20210701/image_types_gen.go | 24 +- .../v1beta20210701storage/image_types_gen.go | 6 +- .../compute/v1beta20220301/image_types_gen.go | 24 +- .../virtual_machine_scale_set_types_gen.go | 24 +- .../virtual_machine_types_gen.go | 24 +- .../v1beta20220301storage/image_types_gen.go | 6 +- .../virtual_machine_scale_set_types_gen.go | 6 +- .../virtual_machine_types_gen.go | 6 +- .../container_group_types_gen.go | 24 +- .../container_group_types_gen.go | 6 +- .../container_group_types_gen.go | 24 +- .../container_group_types_gen.go | 6 +- .../v1api20210901/registry_types_gen.go | 24 +- .../registry_types_gen.go | 6 +- .../v1beta20210901/registry_types_gen.go | 24 +- .../registry_types_gen.go | 6 +- .../managed_cluster_types_gen.go | 21 +- .../managed_clusters_agent_pool_types_gen.go | 24 +- .../managed_cluster_types_gen.go | 6 +- .../managed_clusters_agent_pool_types_gen.go | 6 +- .../managed_cluster_types_gen.go | 21 +- .../managed_clusters_agent_pool_types_gen.go | 24 +- .../managed_cluster_types_gen.go | 6 +- .../managed_clusters_agent_pool_types_gen.go | 6 +- .../managed_cluster_types_gen.go | 21 +- .../managed_clusters_agent_pool_types_gen.go | 24 +- .../trusted_access_role_binding_types_gen.go | 24 +- .../managed_cluster_types_gen.go | 6 +- .../managed_clusters_agent_pool_types_gen.go | 6 +- .../trusted_access_role_binding_types_gen.go | 6 +- .../managed_cluster_types_gen.go | 21 +- .../managed_clusters_agent_pool_types_gen.go | 24 +- .../managed_cluster_types_gen.go | 6 +- .../managed_clusters_agent_pool_types_gen.go | 6 +- .../v1api20180601/factory_types_gen.go | 24 +- .../v1api20180601storage/factory_types_gen.go | 6 +- .../v1api20230101/backup_vault_types_gen.go | 24 +- .../backup_vaults_backup_policy_types_gen.go | 24 +- .../backup_vault_types_gen.go | 6 +- .../backup_vaults_backup_policy_types_gen.go | 6 +- .../v1api20180601/configuration_types_gen.go | 24 +- .../v1api20180601/database_types_gen.go | 24 +- .../v1api20180601/server_types_gen.go | 21 +- .../configuration_types_gen.go | 6 +- .../database_types_gen.go | 6 +- .../v1api20180601storage/server_types_gen.go | 6 +- .../v1beta20180601/configuration_types_gen.go | 24 +- .../v1beta20180601/database_types_gen.go | 24 +- .../v1beta20180601/server_types_gen.go | 21 +- .../configuration_types_gen.go | 6 +- .../database_types_gen.go | 6 +- .../v1beta20180601storage/server_types_gen.go | 6 +- v2/api/dbformysql/v1/user_types.go | 8 +- v2/api/dbformysql/v1/zz_generated.deepcopy.go | 2 +- .../flexible_server_types_gen.go | 21 +- .../flexible_servers_database_types_gen.go | 24 +- ...lexible_servers_firewall_rule_types_gen.go | 24 +- .../flexible_server_types_gen.go | 6 +- .../flexible_servers_database_types_gen.go | 6 +- ...lexible_servers_firewall_rule_types_gen.go | 6 +- ...lexible_servers_administrator_types_gen.go | 21 +- ...lexible_servers_configuration_types_gen.go | 24 +- ...lexible_servers_administrator_types_gen.go | 6 +- ...lexible_servers_configuration_types_gen.go | 6 +- v2/api/dbformysql/v1beta1/user_types.go | 8 +- .../v1beta1/zz_generated.deepcopy.go | 2 +- .../flexible_server_types_gen.go | 21 +- .../flexible_servers_database_types_gen.go | 24 +- ...lexible_servers_firewall_rule_types_gen.go | 24 +- .../flexible_server_types_gen.go | 6 +- .../flexible_servers_database_types_gen.go | 6 +- ...lexible_servers_firewall_rule_types_gen.go | 6 +- .../flexible_server_extensions.go | 2 +- .../flexible_servers_database_extensions.go | 4 + ...exible_servers_firewall_rule_extensions.go | 5 + v2/api/dbforpostgresql/v1/user_types.go | 8 +- .../v1/zz_generated.deepcopy.go | 2 +- .../flexible_server_types_gen.go | 21 +- ...lexible_servers_configuration_types_gen.go | 24 +- .../flexible_servers_database_types_gen.go | 24 +- ...lexible_servers_firewall_rule_types_gen.go | 24 +- .../flexible_server_types_gen.go | 6 +- ...lexible_servers_configuration_types_gen.go | 6 +- .../flexible_servers_database_types_gen.go | 6 +- ...lexible_servers_firewall_rule_types_gen.go | 6 +- .../flexible_server_types_gen.go | 21 +- ...lexible_servers_configuration_types_gen.go | 24 +- .../flexible_servers_database_types_gen.go | 24 +- ...lexible_servers_firewall_rule_types_gen.go | 24 +- .../flexible_server_types_gen.go | 6 +- ...lexible_servers_configuration_types_gen.go | 6 +- .../flexible_servers_database_types_gen.go | 6 +- ...lexible_servers_firewall_rule_types_gen.go | 6 +- .../flexible_server_types_gen.go | 21 +- ...lexible_servers_configuration_types_gen.go | 24 +- .../flexible_servers_database_types_gen.go | 24 +- ...lexible_servers_firewall_rule_types_gen.go | 24 +- .../flexible_server_types_gen.go | 6 +- ...lexible_servers_configuration_types_gen.go | 6 +- .../flexible_servers_database_types_gen.go | 6 +- ...lexible_servers_firewall_rule_types_gen.go | 6 +- .../flexible_server_types_gen.go | 21 +- ...lexible_servers_configuration_types_gen.go | 24 +- .../flexible_servers_database_types_gen.go | 24 +- ...lexible_servers_firewall_rule_types_gen.go | 24 +- .../flexible_server_types_gen.go | 6 +- ...lexible_servers_configuration_types_gen.go | 6 +- .../flexible_servers_database_types_gen.go | 6 +- ...lexible_servers_firewall_rule_types_gen.go | 6 +- .../v1api20210702/iot_hub_types_gen.go | 21 +- .../v1api20210702storage/iot_hub_types_gen.go | 6 +- .../database_account_types_gen.go | 21 +- ...collection_throughput_setting_types_gen.go | 24 +- .../mongodb_database_collection_types_gen.go | 24 +- ...b_database_throughput_setting_types_gen.go | 24 +- .../mongodb_database_types_gen.go | 24 +- ...se_container_stored_procedure_types_gen.go | 24 +- ..._container_throughput_setting_types_gen.go | 24 +- ...ql_database_container_trigger_types_gen.go | 24 +- .../sql_database_container_types_gen.go | 24 +- ...ntainer_user_defined_function_types_gen.go | 24 +- ...l_database_throughput_setting_types_gen.go | 24 +- .../v1api20210515/sql_database_types_gen.go | 24 +- .../sql_role_assignment_types_gen.go | 21 +- .../database_account_types_gen.go | 6 +- ...collection_throughput_setting_types_gen.go | 6 +- .../mongodb_database_collection_types_gen.go | 6 +- ...b_database_throughput_setting_types_gen.go | 6 +- .../mongodb_database_types_gen.go | 6 +- ...se_container_stored_procedure_types_gen.go | 6 +- ..._container_throughput_setting_types_gen.go | 6 +- ...ql_database_container_trigger_types_gen.go | 6 +- .../sql_database_container_types_gen.go | 6 +- ...ntainer_user_defined_function_types_gen.go | 6 +- ...l_database_throughput_setting_types_gen.go | 6 +- .../sql_database_types_gen.go | 6 +- .../sql_role_assignment_types_gen.go | 6 +- .../database_account_types_gen.go | 21 +- ...collection_throughput_setting_types_gen.go | 24 +- .../mongodb_database_collection_types_gen.go | 24 +- ...b_database_throughput_setting_types_gen.go | 24 +- .../mongodb_database_types_gen.go | 24 +- ...se_container_stored_procedure_types_gen.go | 24 +- ..._container_throughput_setting_types_gen.go | 24 +- ...ql_database_container_trigger_types_gen.go | 24 +- .../sql_database_container_types_gen.go | 24 +- ...ntainer_user_defined_function_types_gen.go | 24 +- ...l_database_throughput_setting_types_gen.go | 24 +- .../v1beta20210515/sql_database_types_gen.go | 24 +- .../sql_role_assignment_types_gen.go | 21 +- .../database_account_types_gen.go | 6 +- ...collection_throughput_setting_types_gen.go | 6 +- .../mongodb_database_collection_types_gen.go | 6 +- ...b_database_throughput_setting_types_gen.go | 6 +- .../mongodb_database_types_gen.go | 6 +- ...se_container_stored_procedure_types_gen.go | 6 +- ..._container_throughput_setting_types_gen.go | 6 +- ...ql_database_container_trigger_types_gen.go | 6 +- .../sql_database_container_types_gen.go | 6 +- ...ntainer_user_defined_function_types_gen.go | 6 +- ...l_database_throughput_setting_types_gen.go | 6 +- .../sql_database_types_gen.go | 6 +- .../sql_role_assignment_types_gen.go | 6 +- .../v1api20200601/domain_types_gen.go | 24 +- .../v1api20200601/domains_topic_types_gen.go | 24 +- .../event_subscription_types_gen.go | 6 +- .../v1api20200601/topic_types_gen.go | 24 +- .../v1api20200601storage/domain_types_gen.go | 6 +- .../domains_topic_types_gen.go | 6 +- .../event_subscription_types_gen.go | 6 +- .../v1api20200601storage/topic_types_gen.go | 6 +- .../v1beta20200601/domain_types_gen.go | 24 +- .../v1beta20200601/domains_topic_types_gen.go | 24 +- .../event_subscription_types_gen.go | 6 +- .../v1beta20200601/topic_types_gen.go | 24 +- .../v1beta20200601storage/domain_types_gen.go | 6 +- .../domains_topic_types_gen.go | 6 +- .../event_subscription_types_gen.go | 6 +- .../v1beta20200601storage/topic_types_gen.go | 6 +- .../v1api20211101/namespace_types_gen.go | 24 +- ...namespaces_authorization_rule_types_gen.go | 24 +- .../namespaces_eventhub_types_gen.go | 24 +- ..._eventhubs_authorization_rule_types_gen.go | 24 +- ...aces_eventhubs_consumer_group_types_gen.go | 24 +- .../namespace_types_gen.go | 6 +- ...namespaces_authorization_rule_types_gen.go | 6 +- .../namespaces_eventhub_types_gen.go | 6 +- ..._eventhubs_authorization_rule_types_gen.go | 6 +- ...aces_eventhubs_consumer_group_types_gen.go | 6 +- .../v1beta20211101/namespace_types_gen.go | 24 +- ...namespaces_authorization_rule_types_gen.go | 24 +- .../namespaces_eventhub_types_gen.go | 24 +- ..._eventhubs_authorization_rule_types_gen.go | 24 +- ...aces_eventhubs_consumer_group_types_gen.go | 24 +- .../namespace_types_gen.go | 6 +- ...namespaces_authorization_rule_types_gen.go | 6 +- .../namespaces_eventhub_types_gen.go | 6 +- ..._eventhubs_authorization_rule_types_gen.go | 6 +- ...aces_eventhubs_consumer_group_types_gen.go | 6 +- .../v1api20180501preview/webtest_types_gen.go | 24 +- .../webtest_types_gen.go | 6 +- .../v1api20200202/component_types_gen.go | 21 +- .../component_types_gen.go | 6 +- .../webtest_types_gen.go | 24 +- .../webtest_types_gen.go | 6 +- .../v1beta20200202/component_types_gen.go | 21 +- .../component_types_gen.go | 6 +- .../v1api20210401preview/vault_types_gen.go | 21 +- .../vault_types_gen.go | 6 +- .../v1beta20210401preview/vault_types_gen.go | 21 +- .../vault_types_gen.go | 6 +- .../v1api20210701/workspace_types_gen.go | 21 +- .../workspaces_compute_types_gen.go | 24 +- .../workspaces_connection_types_gen.go | 24 +- .../workspace_types_gen.go | 6 +- .../workspaces_compute_types_gen.go | 6 +- .../workspaces_connection_types_gen.go | 6 +- .../v1beta20210701/workspace_types_gen.go | 21 +- .../workspaces_compute_types_gen.go | 24 +- .../workspaces_connection_types_gen.go | 24 +- .../workspace_types_gen.go | 6 +- .../workspaces_compute_types_gen.go | 6 +- .../workspaces_connection_types_gen.go | 6 +- .../user_assigned_identity_types_gen.go | 21 +- .../user_assigned_identity_types_gen.go | 6 +- ...federated_identity_credential_types_gen.go | 21 +- ...federated_identity_credential_types_gen.go | 6 +- .../user_assigned_identity_types_gen.go | 21 +- .../user_assigned_identity_types_gen.go | 6 +- ...federated_identity_credential_types_gen.go | 21 +- ...federated_identity_credential_types_gen.go | 6 +- .../v1api20180501/dns_zone_types_gen.go | 24 +- .../dns_zones_a_record_types_gen.go | 24 +- .../dns_zones_aaaa_record_types_gen.go | 24 +- .../dns_zones_caa_record_types_gen.go | 24 +- .../dns_zones_cname_record_types_gen.go | 24 +- .../dns_zones_mx_record_types_gen.go | 24 +- .../dns_zones_ns_record_types_gen.go | 24 +- .../dns_zones_ptr_record_types_gen.go | 24 +- .../dns_zones_srv_record_types_gen.go | 24 +- .../dns_zones_txt_record_types_gen.go | 24 +- .../dns_zone_types_gen.go | 6 +- .../dns_zones_a_record_types_gen.go | 6 +- .../dns_zones_aaaa_record_types_gen.go | 6 +- .../dns_zones_caa_record_types_gen.go | 6 +- .../dns_zones_cname_record_types_gen.go | 6 +- .../dns_zones_mx_record_types_gen.go | 6 +- .../dns_zones_ns_record_types_gen.go | 6 +- .../dns_zones_ptr_record_types_gen.go | 6 +- .../dns_zones_srv_record_types_gen.go | 6 +- .../dns_zones_txt_record_types_gen.go | 6 +- .../private_dns_zone_types_gen.go | 24 +- .../private_dns_zone_types_gen.go | 6 +- .../private_dns_zones_a_record_types_gen.go | 24 +- ...private_dns_zones_aaaa_record_types_gen.go | 24 +- ...rivate_dns_zones_cname_record_types_gen.go | 24 +- .../private_dns_zones_mx_record_types_gen.go | 24 +- .../private_dns_zones_ptr_record_types_gen.go | 24 +- .../private_dns_zones_srv_record_types_gen.go | 24 +- .../private_dns_zones_txt_record_types_gen.go | 24 +- ...ns_zones_virtual_network_link_types_gen.go | 24 +- .../private_dns_zones_a_record_types_gen.go | 6 +- ...private_dns_zones_aaaa_record_types_gen.go | 6 +- ...rivate_dns_zones_cname_record_types_gen.go | 6 +- .../private_dns_zones_mx_record_types_gen.go | 6 +- .../private_dns_zones_ptr_record_types_gen.go | 6 +- .../private_dns_zones_srv_record_types_gen.go | 6 +- .../private_dns_zones_txt_record_types_gen.go | 6 +- ...ns_zones_virtual_network_link_types_gen.go | 6 +- .../v1api20201101/load_balancer_types_gen.go | 24 +- ...ad_balancers_inbound_nat_rule_types_gen.go | 24 +- .../network_interface_types_gen.go | 24 +- .../network_security_group_types_gen.go | 24 +- ...security_groups_security_rule_types_gen.go | 24 +- .../public_ip_address_types_gen.go | 24 +- .../v1api20201101/route_table_types_gen.go | 24 +- .../route_tables_route_types_gen.go | 24 +- .../virtual_network_gateway_types_gen.go | 24 +- .../virtual_network_types_gen.go | 24 +- .../virtual_networks_subnet_types_gen.go | 24 +- ...works_virtual_network_peering_types_gen.go | 24 +- .../load_balancer_types_gen.go | 6 +- ...ad_balancers_inbound_nat_rule_types_gen.go | 6 +- .../network_interface_types_gen.go | 6 +- .../network_security_group_types_gen.go | 6 +- ...security_groups_security_rule_types_gen.go | 6 +- .../public_ip_address_types_gen.go | 6 +- .../route_table_types_gen.go | 6 +- .../route_tables_route_types_gen.go | 6 +- .../virtual_network_gateway_types_gen.go | 6 +- .../virtual_network_types_gen.go | 6 +- .../virtual_networks_subnet_types_gen.go | 6 +- ...works_virtual_network_peering_types_gen.go | 6 +- .../v1api20220701/bastion_host_types_gen.go | 24 +- ...ing_rule_sets_forwarding_rule_types_gen.go | 21 +- .../dns_forwarding_ruleset_types_gen.go | 24 +- .../v1api20220701/dns_resolver_types_gen.go | 24 +- ...ns_resolvers_inbound_endpoint_types_gen.go | 24 +- ...s_resolvers_outbound_endpoint_types_gen.go | 24 +- .../v1api20220701/nat_gateway_types_gen.go | 24 +- .../private_endpoint_types_gen.go | 24 +- ...points_private_dns_zone_group_types_gen.go | 24 +- .../private_link_service_types_gen.go | 21 +- .../public_ip_prefix_types_gen.go | 24 +- .../bastion_host_types_gen.go | 6 +- ...ing_rule_sets_forwarding_rule_types_gen.go | 6 +- .../dns_forwarding_ruleset_types_gen.go | 6 +- .../dns_resolver_types_gen.go | 6 +- ...ns_resolvers_inbound_endpoint_types_gen.go | 6 +- ...s_resolvers_outbound_endpoint_types_gen.go | 6 +- .../nat_gateway_types_gen.go | 6 +- .../private_endpoint_types_gen.go | 6 +- ...points_private_dns_zone_group_types_gen.go | 6 +- .../private_link_service_types_gen.go | 6 +- .../public_ip_prefix_types_gen.go | 6 +- .../private_dns_zone_types_gen.go | 24 +- .../private_dns_zone_types_gen.go | 6 +- .../v1beta20201101/load_balancer_types_gen.go | 24 +- .../network_interface_types_gen.go | 24 +- .../network_security_group_types_gen.go | 24 +- ...security_groups_security_rule_types_gen.go | 24 +- .../public_ip_address_types_gen.go | 24 +- .../v1beta20201101/route_table_types_gen.go | 24 +- .../route_tables_route_types_gen.go | 24 +- .../virtual_network_gateway_types_gen.go | 24 +- .../virtual_network_types_gen.go | 24 +- .../virtual_networks_subnet_types_gen.go | 24 +- ...works_virtual_network_peering_types_gen.go | 24 +- .../load_balancer_types_gen.go | 6 +- .../network_interface_types_gen.go | 6 +- .../network_security_group_types_gen.go | 6 +- ...security_groups_security_rule_types_gen.go | 6 +- .../public_ip_address_types_gen.go | 6 +- .../route_table_types_gen.go | 6 +- .../route_tables_route_types_gen.go | 6 +- .../virtual_network_gateway_types_gen.go | 6 +- .../virtual_network_types_gen.go | 6 +- .../virtual_networks_subnet_types_gen.go | 6 +- ...works_virtual_network_peering_types_gen.go | 6 +- .../v1api20210601/workspace_types_gen.go | 24 +- .../workspace_types_gen.go | 6 +- .../v1beta20210601/workspace_types_gen.go | 24 +- .../workspace_types_gen.go | 6 +- .../v1api20220901/search_service_types_gen.go | 21 +- .../search_service_types_gen.go | 6 +- .../namespace_types_gen.go | 21 +- ...namespaces_authorization_rule_types_gen.go | 21 +- .../namespaces_queue_types_gen.go | 24 +- .../namespaces_topic_types_gen.go | 24 +- ...amespaces_topics_subscription_types_gen.go | 24 +- ...ces_topics_subscriptions_rule_types_gen.go | 24 +- .../namespace_types_gen.go | 6 +- ...namespaces_authorization_rule_types_gen.go | 6 +- .../namespaces_queue_types_gen.go | 6 +- .../namespaces_topic_types_gen.go | 6 +- ...amespaces_topics_subscription_types_gen.go | 6 +- ...ces_topics_subscriptions_rule_types_gen.go | 6 +- .../namespace_types_gen.go | 21 +- .../namespaces_queue_types_gen.go | 24 +- .../namespaces_topic_types_gen.go | 24 +- ...amespaces_topics_subscription_types_gen.go | 24 +- ...ces_topics_subscriptions_rule_types_gen.go | 24 +- .../namespace_types_gen.go | 6 +- .../namespaces_queue_types_gen.go | 6 +- .../namespaces_topic_types_gen.go | 6 +- ...amespaces_topics_subscription_types_gen.go | 6 +- ...ces_topics_subscriptions_rule_types_gen.go | 6 +- .../v1api20211001/signal_r_types_gen.go | 24 +- .../signal_r_types_gen.go | 6 +- .../v1beta20211001/signal_r_types_gen.go | 24 +- .../signal_r_types_gen.go | 6 +- v2/api/sql/v1api20211101/server_types_gen.go | 21 +- .../servers_administrator_types_gen.go | 21 +- ...ced_threat_protection_setting_types_gen.go | 24 +- .../servers_auditing_setting_types_gen.go | 24 +- ..._azure_ad_only_authentication_types_gen.go | 24 +- .../servers_connection_policy_types_gen.go | 24 +- .../servers_database_types_gen.go | 24 +- ...ced_threat_protection_setting_types_gen.go | 24 +- ...rs_databases_auditing_setting_types_gen.go | 24 +- ...up_long_term_retention_policy_types_gen.go | 24 +- ...p_short_term_retention_policy_types_gen.go | 24 +- ...tabases_security_alert_policy_types_gen.go | 24 +- ...s_transparent_data_encryption_types_gen.go | 24 +- ...ases_vulnerability_assessment_types_gen.go | 21 +- .../servers_elastic_pool_types_gen.go | 24 +- .../servers_failover_group_types_gen.go | 24 +- .../servers_firewall_rule_types_gen.go | 24 +- .../servers_ipv_6_firewall_rule_types_gen.go | 24 +- ...ervers_outbound_firewall_rule_types_gen.go | 24 +- ...servers_security_alert_policy_types_gen.go | 24 +- .../servers_virtual_network_rule_types_gen.go | 24 +- ...vers_vulnerability_assessment_types_gen.go | 21 +- .../v1api20211101storage/server_types_gen.go | 6 +- .../servers_administrator_types_gen.go | 6 +- ...ced_threat_protection_setting_types_gen.go | 6 +- .../servers_auditing_setting_types_gen.go | 6 +- ..._azure_ad_only_authentication_types_gen.go | 6 +- .../servers_connection_policy_types_gen.go | 6 +- .../servers_database_types_gen.go | 6 +- ...ced_threat_protection_setting_types_gen.go | 6 +- ...rs_databases_auditing_setting_types_gen.go | 6 +- ...up_long_term_retention_policy_types_gen.go | 6 +- ...p_short_term_retention_policy_types_gen.go | 6 +- ...tabases_security_alert_policy_types_gen.go | 6 +- ...s_transparent_data_encryption_types_gen.go | 6 +- ...ases_vulnerability_assessment_types_gen.go | 6 +- .../servers_elastic_pool_types_gen.go | 6 +- .../servers_failover_group_types_gen.go | 6 +- .../servers_firewall_rule_types_gen.go | 6 +- .../servers_ipv_6_firewall_rule_types_gen.go | 6 +- ...ervers_outbound_firewall_rule_types_gen.go | 6 +- ...servers_security_alert_policy_types_gen.go | 6 +- .../servers_virtual_network_rule_types_gen.go | 6 +- ...vers_vulnerability_assessment_types_gen.go | 6 +- .../storage_account_types_gen.go | 21 +- ...storage_accounts_blob_service_types_gen.go | 24 +- ...ounts_blob_services_container_types_gen.go | 24 +- ...ge_accounts_management_policy_types_gen.go | 24 +- ...torage_accounts_queue_service_types_gen.go | 24 +- ...accounts_queue_services_queue_types_gen.go | 24 +- .../storage_account_types_gen.go | 6 +- ...storage_accounts_blob_service_types_gen.go | 6 +- ...ounts_blob_services_container_types_gen.go | 6 +- ...ge_accounts_management_policy_types_gen.go | 6 +- ...torage_accounts_queue_service_types_gen.go | 6 +- ...accounts_queue_services_queue_types_gen.go | 6 +- .../storage_account_types_gen.go | 21 +- ...storage_accounts_blob_service_types_gen.go | 24 +- ...ounts_blob_services_container_types_gen.go | 24 +- ...storage_accounts_file_service_types_gen.go | 24 +- ..._accounts_file_services_share_types_gen.go | 24 +- ...ge_accounts_management_policy_types_gen.go | 24 +- ...torage_accounts_queue_service_types_gen.go | 24 +- ...accounts_queue_services_queue_types_gen.go | 24 +- ...torage_accounts_table_service_types_gen.go | 24 +- ...accounts_table_services_table_types_gen.go | 24 +- .../storage_account_types_gen.go | 6 +- ...storage_accounts_blob_service_types_gen.go | 6 +- ...ounts_blob_services_container_types_gen.go | 6 +- ...storage_accounts_file_service_types_gen.go | 6 +- ..._accounts_file_services_share_types_gen.go | 6 +- ...ge_accounts_management_policy_types_gen.go | 6 +- ...torage_accounts_queue_service_types_gen.go | 6 +- ...accounts_queue_services_queue_types_gen.go | 6 +- ...torage_accounts_table_service_types_gen.go | 6 +- ...accounts_table_services_table_types_gen.go | 6 +- .../storage_account_types_gen.go | 21 +- ...storage_accounts_blob_service_types_gen.go | 24 +- ...ounts_blob_services_container_types_gen.go | 24 +- ...ge_accounts_management_policy_types_gen.go | 24 +- ...torage_accounts_queue_service_types_gen.go | 24 +- ...accounts_queue_services_queue_types_gen.go | 24 +- .../storage_account_types_gen.go | 6 +- ...storage_accounts_blob_service_types_gen.go | 6 +- ...ounts_blob_services_container_types_gen.go | 6 +- ...ge_accounts_management_policy_types_gen.go | 6 +- ...torage_accounts_queue_service_types_gen.go | 6 +- ...accounts_queue_services_queue_types_gen.go | 6 +- .../v1api20210601/workspace_types_gen.go | 21 +- .../workspaces_big_data_pool_types_gen.go | 24 +- .../workspace_types_gen.go | 6 +- .../workspaces_big_data_pool_types_gen.go | 6 +- .../v1api20220301/server_farm_types_gen.go | 24 +- v2/api/web/v1api20220301/site_types_gen.go | 24 +- .../server_farm_types_gen.go | 6 +- .../v1api20220301storage/site_types_gen.go | 6 +- .../v1beta20220301/server_farm_types_gen.go | 24 +- v2/api/web/v1beta20220301/site_types_gen.go | 24 +- .../server_farm_types_gen.go | 6 +- .../v1beta20220301storage/site_types_gen.go | 6 +- ...rd_storage_storageaccount_20220901_test.go | 9 +- .../controllers/owner_arm_id_negative_test.go | 89 ++ v2/internal/controllers/owner_arm_id_test.go | 171 ++++ ...omDifferentSubscription_ResourceFails.yaml | 141 +++ ...t_ChildResourceSuccessfullyReconciled.yaml | 824 ++++++++++++++++++ ...eGroup_ResourceSuccessfullyReconciled.yaml | 429 +++++++++ ...Test_OwnerIsARMIDOfWrongType_Rejected.yaml | 141 +++ ...Test_OwnerIsARMIDSetWithName_Rejected.yaml | 141 +++ ...tensionResourceSuccessfullyReconciled.yaml | 789 +++++++++++++++++ .../azure_generic_arm_reconciler_instance.go | 10 +- v2/internal/reconcilers/common.go | 23 +- v2/internal/reconcilers/mysql/connector.go | 12 +- .../postgresql/postgresql_user_reconciler.go | 15 +- .../reflecthelpers/reflect_helpers_test.go | 2 +- v2/internal/resolver/resolver.go | 74 +- v2/internal/resolver/resolver_test.go | 67 +- v2/internal/resolver/resource_hierarchy.go | 138 ++- .../resolver/resource_hierarchy_test.go | 153 ++++ v2/internal/testcommon/creds.go | 43 + v2/internal/testcommon/kube_matcher.go | 11 +- .../testcommon/kube_per_test_context.go | 16 +- v2/internal/testcommon/kube_test_context.go | 12 + v2/internal/testcommon/sample_resource.go | 4 +- v2/pkg/genruntime/core/errors.go | 34 + v2/pkg/genruntime/kubernetes_resource.go | 16 + v2/pkg/genruntime/resource_reference.go | 134 ++- v2/pkg/genruntime/zz_generated.deepcopy.go | 15 + v2/test/mysql_aad_test.go | 10 +- v2/test/mysql_test.go | 4 +- v2/test/owner_arm_id_test.go | 92 ++ v2/test/postgresql_test.go | 4 +- v2/test/single_operator_multitenant_test.go | 38 +- .../convert_from_arm_function_builder.go | 1 + ...pply_defaulter_and_validator_interfaces.go | 9 + ...e_conversion_on_arm_type_only_azure.golden | 24 +- ...endent_resource_and_ownership_azure.golden | 96 +- ...rm_test_id_resource_reference_azure.golden | 24 +- ..._optional_resource_references_azure.golden | 24 +- ...ple_resource_array_properties_azure.golden | 24 +- ...e_resource_complex_properties_azure.golden | 24 +- ...t_simple_resource_json_fields_azure.golden | 24 +- ...imple_resource_map_properties_azure.golden | 24 +- ..._simple_resource_renders_spec_azure.golden | 24 +- .../Embedded_type_simple_resource.golden | 24 +- .../EnumNames/Multi_valued_enum_name.golden | 24 +- .../EnumNames/Single_valued_enum_name.golden | 24 +- .../kubernetes_admissions_validations.go | 45 + .../kubernetes_resource_interface.go | 34 +- 601 files changed, 8337 insertions(+), 3758 deletions(-) create mode 100644 v2/internal/controllers/owner_arm_id_negative_test.go create mode 100644 v2/internal/controllers/owner_arm_id_test.go create mode 100644 v2/internal/controllers/recordings/Test_OwnerIsARMIDFromDifferentSubscription_ResourceFails.yaml create mode 100644 v2/internal/controllers/recordings/Test_OwnerIsARMIDOfParent_ChildResourceSuccessfullyReconciled.yaml create mode 100644 v2/internal/controllers/recordings/Test_OwnerIsARMIDOfResourceGroup_ResourceSuccessfullyReconciled.yaml create mode 100644 v2/internal/controllers/recordings/Test_OwnerIsARMIDOfWrongType_Rejected.yaml create mode 100644 v2/internal/controllers/recordings/Test_OwnerIsARMIDSetWithName_Rejected.yaml create mode 100644 v2/internal/controllers/recordings/Test_OwnerIsARMID_ExtensionResourceSuccessfullyReconciled.yaml create mode 100644 v2/test/owner_arm_id_test.go diff --git a/v2/api/appconfiguration/v1api20220501/configuration_store_types_gen.go b/v2/api/appconfiguration/v1api20220501/configuration_store_types_gen.go index a31aa5a1319..d726efa2759 100644 --- a/v2/api/appconfiguration/v1api20220501/configuration_store_types_gen.go +++ b/v2/api/appconfiguration/v1api20220501/configuration_store_types_gen.go @@ -141,11 +141,7 @@ func (store *ConfigurationStore) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (store *ConfigurationStore) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(store.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: store.Spec.Owner.Name, - } + return store.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -203,7 +199,7 @@ func (store *ConfigurationStore) ValidateUpdate(old runtime.Object) (admission.W // createValidations validates the creation of the resource func (store *ConfigurationStore) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){store.validateResourceReferences, store.validateSecretDestinations} + return []func() (admission.Warnings, error){store.validateResourceReferences, store.validateOwnerReference, store.validateSecretDestinations} } // deleteValidations validates the deletion of the resource @@ -218,12 +214,20 @@ func (store *ConfigurationStore) updateValidations() []func(old runtime.Object) return store.validateResourceReferences() }, store.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return store.validateOwnerReference() + }, func(old runtime.Object) (admission.Warnings, error) { return store.validateSecretDestinations() }, } } +// validateOwnerReference validates the owner field +func (store *ConfigurationStore) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(store) +} + // validateResourceReferences validates all resource references func (store *ConfigurationStore) validateResourceReferences() (admission.Warnings, error) { refs, err := reflecthelpers.FindResourceReferences(&store.Spec) @@ -572,7 +576,10 @@ func (store *ConfigurationStore_Spec) PopulateFromARM(owner genruntime.Arbitrary // no assignment for property "OperatorSpec" // Set property "Owner": - store.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + store.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "PublicNetworkAccess": // copying flattened property: diff --git a/v2/api/appconfiguration/v1api20220501storage/configuration_store_types_gen.go b/v2/api/appconfiguration/v1api20220501storage/configuration_store_types_gen.go index 738d9f4f11f..123cf65988c 100644 --- a/v2/api/appconfiguration/v1api20220501storage/configuration_store_types_gen.go +++ b/v2/api/appconfiguration/v1api20220501storage/configuration_store_types_gen.go @@ -84,11 +84,7 @@ func (store *ConfigurationStore) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (store *ConfigurationStore) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(store.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: store.Spec.Owner.Name, - } + return store.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/appconfiguration/v1beta20220501/configuration_store_types_gen.go b/v2/api/appconfiguration/v1beta20220501/configuration_store_types_gen.go index 790d0213b63..d969e246302 100644 --- a/v2/api/appconfiguration/v1beta20220501/configuration_store_types_gen.go +++ b/v2/api/appconfiguration/v1beta20220501/configuration_store_types_gen.go @@ -142,11 +142,7 @@ func (store *ConfigurationStore) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (store *ConfigurationStore) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(store.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: store.Spec.Owner.Name, - } + return store.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -204,7 +200,7 @@ func (store *ConfigurationStore) ValidateUpdate(old runtime.Object) (admission.W // createValidations validates the creation of the resource func (store *ConfigurationStore) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){store.validateResourceReferences, store.validateSecretDestinations} + return []func() (admission.Warnings, error){store.validateResourceReferences, store.validateOwnerReference, store.validateSecretDestinations} } // deleteValidations validates the deletion of the resource @@ -219,12 +215,20 @@ func (store *ConfigurationStore) updateValidations() []func(old runtime.Object) return store.validateResourceReferences() }, store.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return store.validateOwnerReference() + }, func(old runtime.Object) (admission.Warnings, error) { return store.validateSecretDestinations() }, } } +// validateOwnerReference validates the owner field +func (store *ConfigurationStore) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(store) +} + // validateResourceReferences validates all resource references func (store *ConfigurationStore) validateResourceReferences() (admission.Warnings, error) { refs, err := reflecthelpers.FindResourceReferences(&store.Spec) @@ -550,7 +554,10 @@ func (store *ConfigurationStore_Spec) PopulateFromARM(owner genruntime.Arbitrary // no assignment for property "OperatorSpec" // Set property "Owner": - store.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + store.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "PublicNetworkAccess": // copying flattened property: diff --git a/v2/api/appconfiguration/v1beta20220501storage/configuration_store_types_gen.go b/v2/api/appconfiguration/v1beta20220501storage/configuration_store_types_gen.go index 60e4bccb783..4ab0fd34e73 100644 --- a/v2/api/appconfiguration/v1beta20220501storage/configuration_store_types_gen.go +++ b/v2/api/appconfiguration/v1beta20220501storage/configuration_store_types_gen.go @@ -103,11 +103,7 @@ func (store *ConfigurationStore) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (store *ConfigurationStore) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(store.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: store.Spec.Owner.Name, - } + return store.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/authorization/v1api20200801preview/role_assignment_types_gen.go b/v2/api/authorization/v1api20200801preview/role_assignment_types_gen.go index 88962744046..10d057b6887 100644 --- a/v2/api/authorization/v1api20200801preview/role_assignment_types_gen.go +++ b/v2/api/authorization/v1api20200801preview/role_assignment_types_gen.go @@ -133,11 +133,7 @@ func (assignment *RoleAssignment) NewEmptyStatus() genruntime.ConvertibleStatus // Owner returns the ResourceReference of the owner func (assignment *RoleAssignment) Owner() *genruntime.ResourceReference { - return &genruntime.ResourceReference{ - Group: assignment.Spec.Owner.Group, - Kind: assignment.Spec.Owner.Kind, - Name: assignment.Spec.Owner.Name, - } + return assignment.Spec.Owner.AsResourceReference() } // SetStatus sets the status of this resource diff --git a/v2/api/authorization/v1api20200801previewstorage/role_assignment_types_gen.go b/v2/api/authorization/v1api20200801previewstorage/role_assignment_types_gen.go index 13f662c8a5b..ae8e8708104 100644 --- a/v2/api/authorization/v1api20200801previewstorage/role_assignment_types_gen.go +++ b/v2/api/authorization/v1api20200801previewstorage/role_assignment_types_gen.go @@ -83,11 +83,7 @@ func (assignment *RoleAssignment) NewEmptyStatus() genruntime.ConvertibleStatus // Owner returns the ResourceReference of the owner func (assignment *RoleAssignment) Owner() *genruntime.ResourceReference { - return &genruntime.ResourceReference{ - Group: assignment.Spec.Owner.Group, - Kind: assignment.Spec.Owner.Kind, - Name: assignment.Spec.Owner.Name, - } + return assignment.Spec.Owner.AsResourceReference() } // SetStatus sets the status of this resource diff --git a/v2/api/authorization/v1beta20200801preview/role_assignment_types_gen.go b/v2/api/authorization/v1beta20200801preview/role_assignment_types_gen.go index bee89b1e9a5..30ff6b106c9 100644 --- a/v2/api/authorization/v1beta20200801preview/role_assignment_types_gen.go +++ b/v2/api/authorization/v1beta20200801preview/role_assignment_types_gen.go @@ -134,11 +134,7 @@ func (assignment *RoleAssignment) NewEmptyStatus() genruntime.ConvertibleStatus // Owner returns the ResourceReference of the owner func (assignment *RoleAssignment) Owner() *genruntime.ResourceReference { - return &genruntime.ResourceReference{ - Group: assignment.Spec.Owner.Group, - Kind: assignment.Spec.Owner.Kind, - Name: assignment.Spec.Owner.Name, - } + return assignment.Spec.Owner.AsResourceReference() } // SetStatus sets the status of this resource diff --git a/v2/api/authorization/v1beta20200801previewstorage/role_assignment_types_gen.go b/v2/api/authorization/v1beta20200801previewstorage/role_assignment_types_gen.go index 2733eacee96..f93069cb627 100644 --- a/v2/api/authorization/v1beta20200801previewstorage/role_assignment_types_gen.go +++ b/v2/api/authorization/v1beta20200801previewstorage/role_assignment_types_gen.go @@ -102,11 +102,7 @@ func (assignment *RoleAssignment) NewEmptyStatus() genruntime.ConvertibleStatus // Owner returns the ResourceReference of the owner func (assignment *RoleAssignment) Owner() *genruntime.ResourceReference { - return &genruntime.ResourceReference{ - Group: assignment.Spec.Owner.Group, - Kind: assignment.Spec.Owner.Kind, - Name: assignment.Spec.Owner.Name, - } + return assignment.Spec.Owner.AsResourceReference() } // SetStatus sets the status of this resource diff --git a/v2/api/batch/v1api20210101/batch_account_types_gen.go b/v2/api/batch/v1api20210101/batch_account_types_gen.go index 7a987fb6cd7..1c62db4f03f 100644 --- a/v2/api/batch/v1api20210101/batch_account_types_gen.go +++ b/v2/api/batch/v1api20210101/batch_account_types_gen.go @@ -141,11 +141,7 @@ func (account *BatchAccount) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (account *BatchAccount) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(account.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: account.Spec.Owner.Name, - } + return account.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -203,7 +199,7 @@ func (account *BatchAccount) ValidateUpdate(old runtime.Object) (admission.Warni // createValidations validates the creation of the resource func (account *BatchAccount) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){account.validateResourceReferences} + return []func() (admission.Warnings, error){account.validateResourceReferences, account.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -217,7 +213,16 @@ func (account *BatchAccount) updateValidations() []func(old runtime.Object) (adm func(old runtime.Object) (admission.Warnings, error) { return account.validateResourceReferences() }, - account.validateWriteOnceProperties} + account.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return account.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (account *BatchAccount) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(account) } // validateResourceReferences validates all resource references @@ -512,7 +517,10 @@ func (account *BatchAccount_Spec) PopulateFromARM(owner genruntime.ArbitraryOwne } // Set property "Owner": - account.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + account.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "PoolAllocationMode": // copying flattened property: diff --git a/v2/api/batch/v1api20210101storage/batch_account_types_gen.go b/v2/api/batch/v1api20210101storage/batch_account_types_gen.go index 5d8819d335e..719afdadad8 100644 --- a/v2/api/batch/v1api20210101storage/batch_account_types_gen.go +++ b/v2/api/batch/v1api20210101storage/batch_account_types_gen.go @@ -84,11 +84,7 @@ func (account *BatchAccount) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (account *BatchAccount) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(account.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: account.Spec.Owner.Name, - } + return account.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/batch/v1beta20210101/batch_account_types_gen.go b/v2/api/batch/v1beta20210101/batch_account_types_gen.go index 22cc24b7b52..24f74caeabc 100644 --- a/v2/api/batch/v1beta20210101/batch_account_types_gen.go +++ b/v2/api/batch/v1beta20210101/batch_account_types_gen.go @@ -142,11 +142,7 @@ func (account *BatchAccount) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (account *BatchAccount) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(account.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: account.Spec.Owner.Name, - } + return account.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -204,7 +200,7 @@ func (account *BatchAccount) ValidateUpdate(old runtime.Object) (admission.Warni // createValidations validates the creation of the resource func (account *BatchAccount) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){account.validateResourceReferences} + return []func() (admission.Warnings, error){account.validateResourceReferences, account.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -218,7 +214,16 @@ func (account *BatchAccount) updateValidations() []func(old runtime.Object) (adm func(old runtime.Object) (admission.Warnings, error) { return account.validateResourceReferences() }, - account.validateWriteOnceProperties} + account.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return account.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (account *BatchAccount) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(account) } // validateResourceReferences validates all resource references @@ -495,7 +500,10 @@ func (account *BatchAccount_Spec) PopulateFromARM(owner genruntime.ArbitraryOwne } // Set property "Owner": - account.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + account.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "PoolAllocationMode": // copying flattened property: diff --git a/v2/api/batch/v1beta20210101storage/batch_account_types_gen.go b/v2/api/batch/v1beta20210101storage/batch_account_types_gen.go index 910ed603e35..b9e8cd3b518 100644 --- a/v2/api/batch/v1beta20210101storage/batch_account_types_gen.go +++ b/v2/api/batch/v1beta20210101storage/batch_account_types_gen.go @@ -103,11 +103,7 @@ func (account *BatchAccount) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (account *BatchAccount) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(account.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: account.Spec.Owner.Name, - } + return account.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/cache/v1api20201201/redis_firewall_rule_types_gen.go b/v2/api/cache/v1api20201201/redis_firewall_rule_types_gen.go index c7911a8e950..34ea5531462 100644 --- a/v2/api/cache/v1api20201201/redis_firewall_rule_types_gen.go +++ b/v2/api/cache/v1api20201201/redis_firewall_rule_types_gen.go @@ -144,11 +144,7 @@ func (rule *RedisFirewallRule) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (rule *RedisFirewallRule) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(rule.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: rule.Spec.Owner.Name, - } + return rule.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -206,7 +202,7 @@ func (rule *RedisFirewallRule) ValidateUpdate(old runtime.Object) (admission.War // createValidations validates the creation of the resource func (rule *RedisFirewallRule) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){rule.validateResourceReferences} + return []func() (admission.Warnings, error){rule.validateResourceReferences, rule.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -220,7 +216,16 @@ func (rule *RedisFirewallRule) updateValidations() []func(old runtime.Object) (a func(old runtime.Object) (admission.Warnings, error) { return rule.validateResourceReferences() }, - rule.validateWriteOnceProperties} + rule.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return rule.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (rule *RedisFirewallRule) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(rule) } // validateResourceReferences validates all resource references @@ -385,7 +390,10 @@ func (rule *Redis_FirewallRule_Spec) PopulateFromARM(owner genruntime.ArbitraryO } // Set property "Owner": - rule.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + rule.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "StartIP": // copying flattened property: diff --git a/v2/api/cache/v1api20201201/redis_linked_server_types_gen.go b/v2/api/cache/v1api20201201/redis_linked_server_types_gen.go index 891171101e2..c05dbf12f5d 100644 --- a/v2/api/cache/v1api20201201/redis_linked_server_types_gen.go +++ b/v2/api/cache/v1api20201201/redis_linked_server_types_gen.go @@ -144,11 +144,7 @@ func (server *RedisLinkedServer) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (server *RedisLinkedServer) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(server.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: server.Spec.Owner.Name, - } + return server.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -206,7 +202,7 @@ func (server *RedisLinkedServer) ValidateUpdate(old runtime.Object) (admission.W // createValidations validates the creation of the resource func (server *RedisLinkedServer) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){server.validateResourceReferences} + return []func() (admission.Warnings, error){server.validateResourceReferences, server.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -220,7 +216,16 @@ func (server *RedisLinkedServer) updateValidations() []func(old runtime.Object) func(old runtime.Object) (admission.Warnings, error) { return server.validateResourceReferences() }, - server.validateWriteOnceProperties} + server.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return server.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (server *RedisLinkedServer) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(server) } // validateResourceReferences validates all resource references @@ -401,7 +406,10 @@ func (server *Redis_LinkedServer_Spec) PopulateFromARM(owner genruntime.Arbitrar // no assignment for property "LinkedRedisCacheReference" // Set property "Owner": - server.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + server.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "ServerRole": // copying flattened property: diff --git a/v2/api/cache/v1api20201201/redis_patch_schedule_types_gen.go b/v2/api/cache/v1api20201201/redis_patch_schedule_types_gen.go index 36da59ef6bb..3a5ce276d7a 100644 --- a/v2/api/cache/v1api20201201/redis_patch_schedule_types_gen.go +++ b/v2/api/cache/v1api20201201/redis_patch_schedule_types_gen.go @@ -137,11 +137,7 @@ func (schedule *RedisPatchSchedule) NewEmptyStatus() genruntime.ConvertibleStatu // Owner returns the ResourceReference of the owner func (schedule *RedisPatchSchedule) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(schedule.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: schedule.Spec.Owner.Name, - } + return schedule.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -199,7 +195,7 @@ func (schedule *RedisPatchSchedule) ValidateUpdate(old runtime.Object) (admissio // createValidations validates the creation of the resource func (schedule *RedisPatchSchedule) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){schedule.validateResourceReferences} + return []func() (admission.Warnings, error){schedule.validateResourceReferences, schedule.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -213,7 +209,16 @@ func (schedule *RedisPatchSchedule) updateValidations() []func(old runtime.Objec func(old runtime.Object) (admission.Warnings, error) { return schedule.validateResourceReferences() }, - schedule.validateWriteOnceProperties} + schedule.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return schedule.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (schedule *RedisPatchSchedule) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(schedule) } // validateResourceReferences validates all resource references @@ -357,7 +362,10 @@ func (schedule *Redis_PatchSchedule_Spec) PopulateFromARM(owner genruntime.Arbit } // Set property "Owner": - schedule.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + schedule.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "ScheduleEntries": // copying flattened property: diff --git a/v2/api/cache/v1api20201201/redis_types_gen.go b/v2/api/cache/v1api20201201/redis_types_gen.go index f0895312324..aca5bb54e0d 100644 --- a/v2/api/cache/v1api20201201/redis_types_gen.go +++ b/v2/api/cache/v1api20201201/redis_types_gen.go @@ -144,11 +144,7 @@ func (redis *Redis) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (redis *Redis) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(redis.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: redis.Spec.Owner.Name, - } + return redis.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -206,7 +202,7 @@ func (redis *Redis) ValidateUpdate(old runtime.Object) (admission.Warnings, erro // createValidations validates the creation of the resource func (redis *Redis) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){redis.validateResourceReferences, redis.validateSecretDestinations} + return []func() (admission.Warnings, error){redis.validateResourceReferences, redis.validateOwnerReference, redis.validateSecretDestinations} } // deleteValidations validates the deletion of the resource @@ -221,12 +217,20 @@ func (redis *Redis) updateValidations() []func(old runtime.Object) (admission.Wa return redis.validateResourceReferences() }, redis.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return redis.validateOwnerReference() + }, func(old runtime.Object) (admission.Warnings, error) { return redis.validateSecretDestinations() }, } } +// validateOwnerReference validates the owner field +func (redis *Redis) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(redis) +} + // validateResourceReferences validates all resource references func (redis *Redis) validateResourceReferences() (admission.Warnings, error) { refs, err := reflecthelpers.FindResourceReferences(&redis.Spec) @@ -566,7 +570,10 @@ func (redis *Redis_Spec) PopulateFromARM(owner genruntime.ArbitraryOwnerReferenc // no assignment for property "OperatorSpec" // Set property "Owner": - redis.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + redis.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "PublicNetworkAccess": // copying flattened property: diff --git a/v2/api/cache/v1api20201201storage/redis_firewall_rule_types_gen.go b/v2/api/cache/v1api20201201storage/redis_firewall_rule_types_gen.go index 12ff6ff76b5..58104e2f62c 100644 --- a/v2/api/cache/v1api20201201storage/redis_firewall_rule_types_gen.go +++ b/v2/api/cache/v1api20201201storage/redis_firewall_rule_types_gen.go @@ -105,11 +105,7 @@ func (rule *RedisFirewallRule) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (rule *RedisFirewallRule) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(rule.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: rule.Spec.Owner.Name, - } + return rule.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/cache/v1api20201201storage/redis_linked_server_types_gen.go b/v2/api/cache/v1api20201201storage/redis_linked_server_types_gen.go index ef2109c33fd..6210b10a92f 100644 --- a/v2/api/cache/v1api20201201storage/redis_linked_server_types_gen.go +++ b/v2/api/cache/v1api20201201storage/redis_linked_server_types_gen.go @@ -105,11 +105,7 @@ func (server *RedisLinkedServer) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (server *RedisLinkedServer) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(server.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: server.Spec.Owner.Name, - } + return server.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/cache/v1api20201201storage/redis_patch_schedule_types_gen.go b/v2/api/cache/v1api20201201storage/redis_patch_schedule_types_gen.go index f9a72431bc3..e8953d66666 100644 --- a/v2/api/cache/v1api20201201storage/redis_patch_schedule_types_gen.go +++ b/v2/api/cache/v1api20201201storage/redis_patch_schedule_types_gen.go @@ -105,11 +105,7 @@ func (schedule *RedisPatchSchedule) NewEmptyStatus() genruntime.ConvertibleStatu // Owner returns the ResourceReference of the owner func (schedule *RedisPatchSchedule) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(schedule.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: schedule.Spec.Owner.Name, - } + return schedule.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/cache/v1api20201201storage/redis_types_gen.go b/v2/api/cache/v1api20201201storage/redis_types_gen.go index dec1bf5ba37..d47f97cc068 100644 --- a/v2/api/cache/v1api20201201storage/redis_types_gen.go +++ b/v2/api/cache/v1api20201201storage/redis_types_gen.go @@ -106,11 +106,7 @@ func (redis *Redis) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (redis *Redis) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(redis.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: redis.Spec.Owner.Name, - } + return redis.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/cache/v1api20210301/redis_enterprise_database_types_gen.go b/v2/api/cache/v1api20210301/redis_enterprise_database_types_gen.go index eee5797b0fb..eeb1591525a 100644 --- a/v2/api/cache/v1api20210301/redis_enterprise_database_types_gen.go +++ b/v2/api/cache/v1api20210301/redis_enterprise_database_types_gen.go @@ -144,11 +144,7 @@ func (database *RedisEnterpriseDatabase) NewEmptyStatus() genruntime.Convertible // Owner returns the ResourceReference of the owner func (database *RedisEnterpriseDatabase) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(database.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: database.Spec.Owner.Name, - } + return database.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -206,7 +202,7 @@ func (database *RedisEnterpriseDatabase) ValidateUpdate(old runtime.Object) (adm // createValidations validates the creation of the resource func (database *RedisEnterpriseDatabase) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){database.validateResourceReferences} + return []func() (admission.Warnings, error){database.validateResourceReferences, database.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -220,7 +216,16 @@ func (database *RedisEnterpriseDatabase) updateValidations() []func(old runtime. func(old runtime.Object) (admission.Warnings, error) { return database.validateResourceReferences() }, - database.validateWriteOnceProperties} + database.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return database.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (database *RedisEnterpriseDatabase) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(database) } // validateResourceReferences validates all resource references @@ -455,7 +460,10 @@ func (database *RedisEnterprise_Database_Spec) PopulateFromARM(owner genruntime. } // Set property "Owner": - database.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + database.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "Persistence": // copying flattened property: diff --git a/v2/api/cache/v1api20210301/redis_enterprise_types_gen.go b/v2/api/cache/v1api20210301/redis_enterprise_types_gen.go index 6b873a26bbc..eddc217835b 100644 --- a/v2/api/cache/v1api20210301/redis_enterprise_types_gen.go +++ b/v2/api/cache/v1api20210301/redis_enterprise_types_gen.go @@ -144,11 +144,7 @@ func (enterprise *RedisEnterprise) NewEmptyStatus() genruntime.ConvertibleStatus // Owner returns the ResourceReference of the owner func (enterprise *RedisEnterprise) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(enterprise.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: enterprise.Spec.Owner.Name, - } + return enterprise.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -206,7 +202,7 @@ func (enterprise *RedisEnterprise) ValidateUpdate(old runtime.Object) (admission // createValidations validates the creation of the resource func (enterprise *RedisEnterprise) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){enterprise.validateResourceReferences} + return []func() (admission.Warnings, error){enterprise.validateResourceReferences, enterprise.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -220,7 +216,16 @@ func (enterprise *RedisEnterprise) updateValidations() []func(old runtime.Object func(old runtime.Object) (admission.Warnings, error) { return enterprise.validateResourceReferences() }, - enterprise.validateWriteOnceProperties} + enterprise.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return enterprise.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (enterprise *RedisEnterprise) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(enterprise) } // validateResourceReferences validates all resource references @@ -430,7 +435,10 @@ func (enterprise *RedisEnterprise_Spec) PopulateFromARM(owner genruntime.Arbitra } // Set property "Owner": - enterprise.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + enterprise.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "Sku": if typedInput.Sku != nil { diff --git a/v2/api/cache/v1api20210301storage/redis_enterprise_database_types_gen.go b/v2/api/cache/v1api20210301storage/redis_enterprise_database_types_gen.go index 6bcce054570..5ccec9b32a8 100644 --- a/v2/api/cache/v1api20210301storage/redis_enterprise_database_types_gen.go +++ b/v2/api/cache/v1api20210301storage/redis_enterprise_database_types_gen.go @@ -105,11 +105,7 @@ func (database *RedisEnterpriseDatabase) NewEmptyStatus() genruntime.Convertible // Owner returns the ResourceReference of the owner func (database *RedisEnterpriseDatabase) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(database.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: database.Spec.Owner.Name, - } + return database.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/cache/v1api20210301storage/redis_enterprise_types_gen.go b/v2/api/cache/v1api20210301storage/redis_enterprise_types_gen.go index 7913f2d1d5b..d6bb89c56c8 100644 --- a/v2/api/cache/v1api20210301storage/redis_enterprise_types_gen.go +++ b/v2/api/cache/v1api20210301storage/redis_enterprise_types_gen.go @@ -106,11 +106,7 @@ func (enterprise *RedisEnterprise) NewEmptyStatus() genruntime.ConvertibleStatus // Owner returns the ResourceReference of the owner func (enterprise *RedisEnterprise) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(enterprise.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: enterprise.Spec.Owner.Name, - } + return enterprise.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/cache/v1api20230401/redis_firewall_rule_types_gen.go b/v2/api/cache/v1api20230401/redis_firewall_rule_types_gen.go index ef99fe6ff95..bf1e9554ac3 100644 --- a/v2/api/cache/v1api20230401/redis_firewall_rule_types_gen.go +++ b/v2/api/cache/v1api20230401/redis_firewall_rule_types_gen.go @@ -141,11 +141,7 @@ func (rule *RedisFirewallRule) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (rule *RedisFirewallRule) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(rule.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: rule.Spec.Owner.Name, - } + return rule.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -203,7 +199,7 @@ func (rule *RedisFirewallRule) ValidateUpdate(old runtime.Object) (admission.War // createValidations validates the creation of the resource func (rule *RedisFirewallRule) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){rule.validateResourceReferences} + return []func() (admission.Warnings, error){rule.validateResourceReferences, rule.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -217,7 +213,16 @@ func (rule *RedisFirewallRule) updateValidations() []func(old runtime.Object) (a func(old runtime.Object) (admission.Warnings, error) { return rule.validateResourceReferences() }, - rule.validateWriteOnceProperties} + rule.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return rule.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (rule *RedisFirewallRule) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(rule) } // validateResourceReferences validates all resource references @@ -382,7 +387,10 @@ func (rule *Redis_FirewallRule_Spec) PopulateFromARM(owner genruntime.ArbitraryO } // Set property "Owner": - rule.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + rule.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "StartIP": // copying flattened property: diff --git a/v2/api/cache/v1api20230401/redis_linked_server_types_gen.go b/v2/api/cache/v1api20230401/redis_linked_server_types_gen.go index a26c22c9cfa..c3c144cc1ca 100644 --- a/v2/api/cache/v1api20230401/redis_linked_server_types_gen.go +++ b/v2/api/cache/v1api20230401/redis_linked_server_types_gen.go @@ -141,11 +141,7 @@ func (server *RedisLinkedServer) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (server *RedisLinkedServer) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(server.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: server.Spec.Owner.Name, - } + return server.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -203,7 +199,7 @@ func (server *RedisLinkedServer) ValidateUpdate(old runtime.Object) (admission.W // createValidations validates the creation of the resource func (server *RedisLinkedServer) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){server.validateResourceReferences} + return []func() (admission.Warnings, error){server.validateResourceReferences, server.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -217,7 +213,16 @@ func (server *RedisLinkedServer) updateValidations() []func(old runtime.Object) func(old runtime.Object) (admission.Warnings, error) { return server.validateResourceReferences() }, - server.validateWriteOnceProperties} + server.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return server.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (server *RedisLinkedServer) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(server) } // validateResourceReferences validates all resource references @@ -398,7 +403,10 @@ func (server *Redis_LinkedServer_Spec) PopulateFromARM(owner genruntime.Arbitrar // no assignment for property "LinkedRedisCacheReference" // Set property "Owner": - server.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + server.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "ServerRole": // copying flattened property: diff --git a/v2/api/cache/v1api20230401/redis_patch_schedule_types_gen.go b/v2/api/cache/v1api20230401/redis_patch_schedule_types_gen.go index 844dc43978f..d5ac550594a 100644 --- a/v2/api/cache/v1api20230401/redis_patch_schedule_types_gen.go +++ b/v2/api/cache/v1api20230401/redis_patch_schedule_types_gen.go @@ -134,11 +134,7 @@ func (schedule *RedisPatchSchedule) NewEmptyStatus() genruntime.ConvertibleStatu // Owner returns the ResourceReference of the owner func (schedule *RedisPatchSchedule) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(schedule.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: schedule.Spec.Owner.Name, - } + return schedule.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -196,7 +192,7 @@ func (schedule *RedisPatchSchedule) ValidateUpdate(old runtime.Object) (admissio // createValidations validates the creation of the resource func (schedule *RedisPatchSchedule) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){schedule.validateResourceReferences} + return []func() (admission.Warnings, error){schedule.validateResourceReferences, schedule.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -210,7 +206,16 @@ func (schedule *RedisPatchSchedule) updateValidations() []func(old runtime.Objec func(old runtime.Object) (admission.Warnings, error) { return schedule.validateResourceReferences() }, - schedule.validateWriteOnceProperties} + schedule.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return schedule.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (schedule *RedisPatchSchedule) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(schedule) } // validateResourceReferences validates all resource references @@ -354,7 +359,10 @@ func (schedule *Redis_PatchSchedule_Spec) PopulateFromARM(owner genruntime.Arbit } // Set property "Owner": - schedule.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + schedule.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "ScheduleEntries": // copying flattened property: diff --git a/v2/api/cache/v1api20230401/redis_types_gen.go b/v2/api/cache/v1api20230401/redis_types_gen.go index 73df0d2f5a5..0a79db6bd89 100644 --- a/v2/api/cache/v1api20230401/redis_types_gen.go +++ b/v2/api/cache/v1api20230401/redis_types_gen.go @@ -141,11 +141,7 @@ func (redis *Redis) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (redis *Redis) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(redis.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: redis.Spec.Owner.Name, - } + return redis.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -203,7 +199,7 @@ func (redis *Redis) ValidateUpdate(old runtime.Object) (admission.Warnings, erro // createValidations validates the creation of the resource func (redis *Redis) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){redis.validateResourceReferences, redis.validateSecretDestinations} + return []func() (admission.Warnings, error){redis.validateResourceReferences, redis.validateOwnerReference, redis.validateSecretDestinations} } // deleteValidations validates the deletion of the resource @@ -218,12 +214,20 @@ func (redis *Redis) updateValidations() []func(old runtime.Object) (admission.Wa return redis.validateResourceReferences() }, redis.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return redis.validateOwnerReference() + }, func(old runtime.Object) (admission.Warnings, error) { return redis.validateSecretDestinations() }, } } +// validateOwnerReference validates the owner field +func (redis *Redis) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(redis) +} + // validateResourceReferences validates all resource references func (redis *Redis) validateResourceReferences() (admission.Warnings, error) { refs, err := reflecthelpers.FindResourceReferences(&redis.Spec) @@ -587,7 +591,10 @@ func (redis *Redis_Spec) PopulateFromARM(owner genruntime.ArbitraryOwnerReferenc // no assignment for property "OperatorSpec" // Set property "Owner": - redis.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + redis.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "PublicNetworkAccess": // copying flattened property: diff --git a/v2/api/cache/v1api20230401storage/redis_firewall_rule_types_gen.go b/v2/api/cache/v1api20230401storage/redis_firewall_rule_types_gen.go index 49962bb44ee..e5a650f45b6 100644 --- a/v2/api/cache/v1api20230401storage/redis_firewall_rule_types_gen.go +++ b/v2/api/cache/v1api20230401storage/redis_firewall_rule_types_gen.go @@ -84,11 +84,7 @@ func (rule *RedisFirewallRule) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (rule *RedisFirewallRule) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(rule.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: rule.Spec.Owner.Name, - } + return rule.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/cache/v1api20230401storage/redis_linked_server_types_gen.go b/v2/api/cache/v1api20230401storage/redis_linked_server_types_gen.go index 8fdeb5aad33..16412728b55 100644 --- a/v2/api/cache/v1api20230401storage/redis_linked_server_types_gen.go +++ b/v2/api/cache/v1api20230401storage/redis_linked_server_types_gen.go @@ -84,11 +84,7 @@ func (server *RedisLinkedServer) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (server *RedisLinkedServer) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(server.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: server.Spec.Owner.Name, - } + return server.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/cache/v1api20230401storage/redis_patch_schedule_types_gen.go b/v2/api/cache/v1api20230401storage/redis_patch_schedule_types_gen.go index 6886ec21d36..a7d38a8e1e0 100644 --- a/v2/api/cache/v1api20230401storage/redis_patch_schedule_types_gen.go +++ b/v2/api/cache/v1api20230401storage/redis_patch_schedule_types_gen.go @@ -84,11 +84,7 @@ func (schedule *RedisPatchSchedule) NewEmptyStatus() genruntime.ConvertibleStatu // Owner returns the ResourceReference of the owner func (schedule *RedisPatchSchedule) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(schedule.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: schedule.Spec.Owner.Name, - } + return schedule.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/cache/v1api20230401storage/redis_types_gen.go b/v2/api/cache/v1api20230401storage/redis_types_gen.go index 73ee455b52c..a21cf316221 100644 --- a/v2/api/cache/v1api20230401storage/redis_types_gen.go +++ b/v2/api/cache/v1api20230401storage/redis_types_gen.go @@ -85,11 +85,7 @@ func (redis *Redis) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (redis *Redis) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(redis.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: redis.Spec.Owner.Name, - } + return redis.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/cache/v1api20230701/redis_enterprise_database_types_gen.go b/v2/api/cache/v1api20230701/redis_enterprise_database_types_gen.go index 9a90265b9cc..a4376a3c66b 100644 --- a/v2/api/cache/v1api20230701/redis_enterprise_database_types_gen.go +++ b/v2/api/cache/v1api20230701/redis_enterprise_database_types_gen.go @@ -141,11 +141,7 @@ func (database *RedisEnterpriseDatabase) NewEmptyStatus() genruntime.Convertible // Owner returns the ResourceReference of the owner func (database *RedisEnterpriseDatabase) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(database.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: database.Spec.Owner.Name, - } + return database.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -203,7 +199,7 @@ func (database *RedisEnterpriseDatabase) ValidateUpdate(old runtime.Object) (adm // createValidations validates the creation of the resource func (database *RedisEnterpriseDatabase) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){database.validateResourceReferences} + return []func() (admission.Warnings, error){database.validateResourceReferences, database.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -217,7 +213,16 @@ func (database *RedisEnterpriseDatabase) updateValidations() []func(old runtime. func(old runtime.Object) (admission.Warnings, error) { return database.validateResourceReferences() }, - database.validateWriteOnceProperties} + database.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return database.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (database *RedisEnterpriseDatabase) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(database) } // validateResourceReferences validates all resource references @@ -478,7 +483,10 @@ func (database *RedisEnterprise_Database_Spec) PopulateFromARM(owner genruntime. } // Set property "Owner": - database.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + database.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "Persistence": // copying flattened property: diff --git a/v2/api/cache/v1api20230701/redis_enterprise_types_gen.go b/v2/api/cache/v1api20230701/redis_enterprise_types_gen.go index eb84570d51b..bec5745e491 100644 --- a/v2/api/cache/v1api20230701/redis_enterprise_types_gen.go +++ b/v2/api/cache/v1api20230701/redis_enterprise_types_gen.go @@ -141,11 +141,7 @@ func (enterprise *RedisEnterprise) NewEmptyStatus() genruntime.ConvertibleStatus // Owner returns the ResourceReference of the owner func (enterprise *RedisEnterprise) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(enterprise.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: enterprise.Spec.Owner.Name, - } + return enterprise.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -203,7 +199,7 @@ func (enterprise *RedisEnterprise) ValidateUpdate(old runtime.Object) (admission // createValidations validates the creation of the resource func (enterprise *RedisEnterprise) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){enterprise.validateResourceReferences} + return []func() (admission.Warnings, error){enterprise.validateResourceReferences, enterprise.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -217,7 +213,16 @@ func (enterprise *RedisEnterprise) updateValidations() []func(old runtime.Object func(old runtime.Object) (admission.Warnings, error) { return enterprise.validateResourceReferences() }, - enterprise.validateWriteOnceProperties} + enterprise.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return enterprise.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (enterprise *RedisEnterprise) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(enterprise) } // validateResourceReferences validates all resource references @@ -427,7 +432,10 @@ func (enterprise *RedisEnterprise_Spec) PopulateFromARM(owner genruntime.Arbitra } // Set property "Owner": - enterprise.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + enterprise.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "Sku": if typedInput.Sku != nil { diff --git a/v2/api/cache/v1api20230701storage/redis_enterprise_database_types_gen.go b/v2/api/cache/v1api20230701storage/redis_enterprise_database_types_gen.go index cad89b8484a..6f0cb108dff 100644 --- a/v2/api/cache/v1api20230701storage/redis_enterprise_database_types_gen.go +++ b/v2/api/cache/v1api20230701storage/redis_enterprise_database_types_gen.go @@ -84,11 +84,7 @@ func (database *RedisEnterpriseDatabase) NewEmptyStatus() genruntime.Convertible // Owner returns the ResourceReference of the owner func (database *RedisEnterpriseDatabase) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(database.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: database.Spec.Owner.Name, - } + return database.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/cache/v1api20230701storage/redis_enterprise_types_gen.go b/v2/api/cache/v1api20230701storage/redis_enterprise_types_gen.go index c6c4f02373c..11fececbd63 100644 --- a/v2/api/cache/v1api20230701storage/redis_enterprise_types_gen.go +++ b/v2/api/cache/v1api20230701storage/redis_enterprise_types_gen.go @@ -84,11 +84,7 @@ func (enterprise *RedisEnterprise) NewEmptyStatus() genruntime.ConvertibleStatus // Owner returns the ResourceReference of the owner func (enterprise *RedisEnterprise) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(enterprise.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: enterprise.Spec.Owner.Name, - } + return enterprise.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/cache/v1beta20201201/redis_firewall_rule_types_gen.go b/v2/api/cache/v1beta20201201/redis_firewall_rule_types_gen.go index 1a3cf65d588..474b3c12d2b 100644 --- a/v2/api/cache/v1beta20201201/redis_firewall_rule_types_gen.go +++ b/v2/api/cache/v1beta20201201/redis_firewall_rule_types_gen.go @@ -142,11 +142,7 @@ func (rule *RedisFirewallRule) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (rule *RedisFirewallRule) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(rule.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: rule.Spec.Owner.Name, - } + return rule.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -204,7 +200,7 @@ func (rule *RedisFirewallRule) ValidateUpdate(old runtime.Object) (admission.War // createValidations validates the creation of the resource func (rule *RedisFirewallRule) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){rule.validateResourceReferences} + return []func() (admission.Warnings, error){rule.validateResourceReferences, rule.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -218,7 +214,16 @@ func (rule *RedisFirewallRule) updateValidations() []func(old runtime.Object) (a func(old runtime.Object) (admission.Warnings, error) { return rule.validateResourceReferences() }, - rule.validateWriteOnceProperties} + rule.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return rule.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (rule *RedisFirewallRule) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(rule) } // validateResourceReferences validates all resource references @@ -379,7 +384,10 @@ func (rule *Redis_FirewallRule_Spec) PopulateFromARM(owner genruntime.ArbitraryO } // Set property "Owner": - rule.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + rule.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "StartIP": // copying flattened property: diff --git a/v2/api/cache/v1beta20201201/redis_linked_server_types_gen.go b/v2/api/cache/v1beta20201201/redis_linked_server_types_gen.go index eb584417a91..d24dfca86e0 100644 --- a/v2/api/cache/v1beta20201201/redis_linked_server_types_gen.go +++ b/v2/api/cache/v1beta20201201/redis_linked_server_types_gen.go @@ -142,11 +142,7 @@ func (server *RedisLinkedServer) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (server *RedisLinkedServer) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(server.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: server.Spec.Owner.Name, - } + return server.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -204,7 +200,7 @@ func (server *RedisLinkedServer) ValidateUpdate(old runtime.Object) (admission.W // createValidations validates the creation of the resource func (server *RedisLinkedServer) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){server.validateResourceReferences} + return []func() (admission.Warnings, error){server.validateResourceReferences, server.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -218,7 +214,16 @@ func (server *RedisLinkedServer) updateValidations() []func(old runtime.Object) func(old runtime.Object) (admission.Warnings, error) { return server.validateResourceReferences() }, - server.validateWriteOnceProperties} + server.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return server.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (server *RedisLinkedServer) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(server) } // validateResourceReferences validates all resource references @@ -394,7 +399,10 @@ func (server *Redis_LinkedServer_Spec) PopulateFromARM(owner genruntime.Arbitrar // no assignment for property "LinkedRedisCacheReference" // Set property "Owner": - server.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + server.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "ServerRole": // copying flattened property: diff --git a/v2/api/cache/v1beta20201201/redis_patch_schedule_types_gen.go b/v2/api/cache/v1beta20201201/redis_patch_schedule_types_gen.go index 0caf7805a8e..ec87707a9af 100644 --- a/v2/api/cache/v1beta20201201/redis_patch_schedule_types_gen.go +++ b/v2/api/cache/v1beta20201201/redis_patch_schedule_types_gen.go @@ -135,11 +135,7 @@ func (schedule *RedisPatchSchedule) NewEmptyStatus() genruntime.ConvertibleStatu // Owner returns the ResourceReference of the owner func (schedule *RedisPatchSchedule) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(schedule.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: schedule.Spec.Owner.Name, - } + return schedule.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -197,7 +193,7 @@ func (schedule *RedisPatchSchedule) ValidateUpdate(old runtime.Object) (admissio // createValidations validates the creation of the resource func (schedule *RedisPatchSchedule) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){schedule.validateResourceReferences} + return []func() (admission.Warnings, error){schedule.validateResourceReferences, schedule.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -211,7 +207,16 @@ func (schedule *RedisPatchSchedule) updateValidations() []func(old runtime.Objec func(old runtime.Object) (admission.Warnings, error) { return schedule.validateResourceReferences() }, - schedule.validateWriteOnceProperties} + schedule.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return schedule.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (schedule *RedisPatchSchedule) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(schedule) } // validateResourceReferences validates all resource references @@ -352,7 +357,10 @@ func (schedule *Redis_PatchSchedule_Spec) PopulateFromARM(owner genruntime.Arbit } // Set property "Owner": - schedule.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + schedule.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "ScheduleEntries": // copying flattened property: diff --git a/v2/api/cache/v1beta20201201/redis_types_gen.go b/v2/api/cache/v1beta20201201/redis_types_gen.go index d3d16298dc5..42c5a893359 100644 --- a/v2/api/cache/v1beta20201201/redis_types_gen.go +++ b/v2/api/cache/v1beta20201201/redis_types_gen.go @@ -142,11 +142,7 @@ func (redis *Redis) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (redis *Redis) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(redis.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: redis.Spec.Owner.Name, - } + return redis.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -204,7 +200,7 @@ func (redis *Redis) ValidateUpdate(old runtime.Object) (admission.Warnings, erro // createValidations validates the creation of the resource func (redis *Redis) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){redis.validateResourceReferences, redis.validateSecretDestinations} + return []func() (admission.Warnings, error){redis.validateResourceReferences, redis.validateOwnerReference, redis.validateSecretDestinations} } // deleteValidations validates the deletion of the resource @@ -219,12 +215,20 @@ func (redis *Redis) updateValidations() []func(old runtime.Object) (admission.Wa return redis.validateResourceReferences() }, redis.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return redis.validateOwnerReference() + }, func(old runtime.Object) (admission.Warnings, error) { return redis.validateSecretDestinations() }, } } +// validateOwnerReference validates the owner field +func (redis *Redis) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(redis) +} + // validateResourceReferences validates all resource references func (redis *Redis) validateResourceReferences() (admission.Warnings, error) { refs, err := reflecthelpers.FindResourceReferences(&redis.Spec) @@ -527,7 +531,10 @@ func (redis *Redis_Spec) PopulateFromARM(owner genruntime.ArbitraryOwnerReferenc // no assignment for property "OperatorSpec" // Set property "Owner": - redis.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + redis.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "PublicNetworkAccess": // copying flattened property: diff --git a/v2/api/cache/v1beta20201201storage/redis_firewall_rule_types_gen.go b/v2/api/cache/v1beta20201201storage/redis_firewall_rule_types_gen.go index 70030f0999b..bbeaa83d2da 100644 --- a/v2/api/cache/v1beta20201201storage/redis_firewall_rule_types_gen.go +++ b/v2/api/cache/v1beta20201201storage/redis_firewall_rule_types_gen.go @@ -116,11 +116,7 @@ func (rule *RedisFirewallRule) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (rule *RedisFirewallRule) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(rule.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: rule.Spec.Owner.Name, - } + return rule.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/cache/v1beta20201201storage/redis_linked_server_types_gen.go b/v2/api/cache/v1beta20201201storage/redis_linked_server_types_gen.go index db7fcfd3d44..15c2be12d5e 100644 --- a/v2/api/cache/v1beta20201201storage/redis_linked_server_types_gen.go +++ b/v2/api/cache/v1beta20201201storage/redis_linked_server_types_gen.go @@ -116,11 +116,7 @@ func (server *RedisLinkedServer) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (server *RedisLinkedServer) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(server.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: server.Spec.Owner.Name, - } + return server.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/cache/v1beta20201201storage/redis_patch_schedule_types_gen.go b/v2/api/cache/v1beta20201201storage/redis_patch_schedule_types_gen.go index 3dae167d718..640e2ba34d5 100644 --- a/v2/api/cache/v1beta20201201storage/redis_patch_schedule_types_gen.go +++ b/v2/api/cache/v1beta20201201storage/redis_patch_schedule_types_gen.go @@ -116,11 +116,7 @@ func (schedule *RedisPatchSchedule) NewEmptyStatus() genruntime.ConvertibleStatu // Owner returns the ResourceReference of the owner func (schedule *RedisPatchSchedule) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(schedule.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: schedule.Spec.Owner.Name, - } + return schedule.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/cache/v1beta20201201storage/redis_types_gen.go b/v2/api/cache/v1beta20201201storage/redis_types_gen.go index 9638bc2249f..b34a8124de8 100644 --- a/v2/api/cache/v1beta20201201storage/redis_types_gen.go +++ b/v2/api/cache/v1beta20201201storage/redis_types_gen.go @@ -117,11 +117,7 @@ func (redis *Redis) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (redis *Redis) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(redis.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: redis.Spec.Owner.Name, - } + return redis.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/cache/v1beta20210301/redis_enterprise_database_types_gen.go b/v2/api/cache/v1beta20210301/redis_enterprise_database_types_gen.go index 934d23e93c7..a47341e58f1 100644 --- a/v2/api/cache/v1beta20210301/redis_enterprise_database_types_gen.go +++ b/v2/api/cache/v1beta20210301/redis_enterprise_database_types_gen.go @@ -142,11 +142,7 @@ func (database *RedisEnterpriseDatabase) NewEmptyStatus() genruntime.Convertible // Owner returns the ResourceReference of the owner func (database *RedisEnterpriseDatabase) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(database.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: database.Spec.Owner.Name, - } + return database.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -204,7 +200,7 @@ func (database *RedisEnterpriseDatabase) ValidateUpdate(old runtime.Object) (adm // createValidations validates the creation of the resource func (database *RedisEnterpriseDatabase) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){database.validateResourceReferences} + return []func() (admission.Warnings, error){database.validateResourceReferences, database.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -218,7 +214,16 @@ func (database *RedisEnterpriseDatabase) updateValidations() []func(old runtime. func(old runtime.Object) (admission.Warnings, error) { return database.validateResourceReferences() }, - database.validateWriteOnceProperties} + database.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return database.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (database *RedisEnterpriseDatabase) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(database) } // validateResourceReferences validates all resource references @@ -438,7 +443,10 @@ func (database *RedisEnterprise_Database_Spec) PopulateFromARM(owner genruntime. } // Set property "Owner": - database.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + database.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "Persistence": // copying flattened property: diff --git a/v2/api/cache/v1beta20210301/redis_enterprise_types_gen.go b/v2/api/cache/v1beta20210301/redis_enterprise_types_gen.go index a4a0f8e0ace..8b980f38759 100644 --- a/v2/api/cache/v1beta20210301/redis_enterprise_types_gen.go +++ b/v2/api/cache/v1beta20210301/redis_enterprise_types_gen.go @@ -142,11 +142,7 @@ func (enterprise *RedisEnterprise) NewEmptyStatus() genruntime.ConvertibleStatus // Owner returns the ResourceReference of the owner func (enterprise *RedisEnterprise) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(enterprise.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: enterprise.Spec.Owner.Name, - } + return enterprise.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -204,7 +200,7 @@ func (enterprise *RedisEnterprise) ValidateUpdate(old runtime.Object) (admission // createValidations validates the creation of the resource func (enterprise *RedisEnterprise) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){enterprise.validateResourceReferences} + return []func() (admission.Warnings, error){enterprise.validateResourceReferences, enterprise.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -218,7 +214,16 @@ func (enterprise *RedisEnterprise) updateValidations() []func(old runtime.Object func(old runtime.Object) (admission.Warnings, error) { return enterprise.validateResourceReferences() }, - enterprise.validateWriteOnceProperties} + enterprise.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return enterprise.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (enterprise *RedisEnterprise) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(enterprise) } // validateResourceReferences validates all resource references @@ -419,7 +424,10 @@ func (enterprise *RedisEnterprise_Spec) PopulateFromARM(owner genruntime.Arbitra } // Set property "Owner": - enterprise.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + enterprise.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "Sku": if typedInput.Sku != nil { diff --git a/v2/api/cache/v1beta20210301storage/redis_enterprise_database_types_gen.go b/v2/api/cache/v1beta20210301storage/redis_enterprise_database_types_gen.go index 5d011269ab4..03a81055d24 100644 --- a/v2/api/cache/v1beta20210301storage/redis_enterprise_database_types_gen.go +++ b/v2/api/cache/v1beta20210301storage/redis_enterprise_database_types_gen.go @@ -116,11 +116,7 @@ func (database *RedisEnterpriseDatabase) NewEmptyStatus() genruntime.Convertible // Owner returns the ResourceReference of the owner func (database *RedisEnterpriseDatabase) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(database.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: database.Spec.Owner.Name, - } + return database.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/cache/v1beta20210301storage/redis_enterprise_types_gen.go b/v2/api/cache/v1beta20210301storage/redis_enterprise_types_gen.go index aca51f22ef7..c742e4a919b 100644 --- a/v2/api/cache/v1beta20210301storage/redis_enterprise_types_gen.go +++ b/v2/api/cache/v1beta20210301storage/redis_enterprise_types_gen.go @@ -117,11 +117,7 @@ func (enterprise *RedisEnterprise) NewEmptyStatus() genruntime.ConvertibleStatus // Owner returns the ResourceReference of the owner func (enterprise *RedisEnterprise) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(enterprise.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: enterprise.Spec.Owner.Name, - } + return enterprise.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/cdn/v1api20210601/profile_types_gen.go b/v2/api/cdn/v1api20210601/profile_types_gen.go index 6d669f6e84b..0b5f48d4d82 100644 --- a/v2/api/cdn/v1api20210601/profile_types_gen.go +++ b/v2/api/cdn/v1api20210601/profile_types_gen.go @@ -141,11 +141,7 @@ func (profile *Profile) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (profile *Profile) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(profile.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: profile.Spec.Owner.Name, - } + return profile.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -203,7 +199,7 @@ func (profile *Profile) ValidateUpdate(old runtime.Object) (admission.Warnings, // createValidations validates the creation of the resource func (profile *Profile) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){profile.validateResourceReferences} + return []func() (admission.Warnings, error){profile.validateResourceReferences, profile.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -217,7 +213,16 @@ func (profile *Profile) updateValidations() []func(old runtime.Object) (admissio func(old runtime.Object) (admission.Warnings, error) { return profile.validateResourceReferences() }, - profile.validateWriteOnceProperties} + profile.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return profile.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (profile *Profile) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(profile) } // validateResourceReferences validates all resource references @@ -422,7 +427,10 @@ func (profile *Profile_Spec) PopulateFromARM(owner genruntime.ArbitraryOwnerRefe } // Set property "Owner": - profile.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + profile.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "Sku": if typedInput.Sku != nil { diff --git a/v2/api/cdn/v1api20210601/profiles_endpoint_types_gen.go b/v2/api/cdn/v1api20210601/profiles_endpoint_types_gen.go index a0f24dd2c65..915577d625a 100644 --- a/v2/api/cdn/v1api20210601/profiles_endpoint_types_gen.go +++ b/v2/api/cdn/v1api20210601/profiles_endpoint_types_gen.go @@ -141,11 +141,7 @@ func (endpoint *ProfilesEndpoint) NewEmptyStatus() genruntime.ConvertibleStatus // Owner returns the ResourceReference of the owner func (endpoint *ProfilesEndpoint) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(endpoint.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: endpoint.Spec.Owner.Name, - } + return endpoint.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -203,7 +199,7 @@ func (endpoint *ProfilesEndpoint) ValidateUpdate(old runtime.Object) (admission. // createValidations validates the creation of the resource func (endpoint *ProfilesEndpoint) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){endpoint.validateResourceReferences} + return []func() (admission.Warnings, error){endpoint.validateResourceReferences, endpoint.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -217,7 +213,16 @@ func (endpoint *ProfilesEndpoint) updateValidations() []func(old runtime.Object) func(old runtime.Object) (admission.Warnings, error) { return endpoint.validateResourceReferences() }, - endpoint.validateWriteOnceProperties} + endpoint.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return endpoint.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (endpoint *ProfilesEndpoint) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(endpoint) } // validateResourceReferences validates all resource references @@ -678,7 +683,10 @@ func (endpoint *Profiles_Endpoint_Spec) PopulateFromARM(owner genruntime.Arbitra } // Set property "Owner": - endpoint.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + endpoint.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "ProbePath": // copying flattened property: diff --git a/v2/api/cdn/v1api20210601storage/profile_types_gen.go b/v2/api/cdn/v1api20210601storage/profile_types_gen.go index 68d7477fbc5..5390fd337d4 100644 --- a/v2/api/cdn/v1api20210601storage/profile_types_gen.go +++ b/v2/api/cdn/v1api20210601storage/profile_types_gen.go @@ -84,11 +84,7 @@ func (profile *Profile) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (profile *Profile) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(profile.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: profile.Spec.Owner.Name, - } + return profile.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/cdn/v1api20210601storage/profiles_endpoint_types_gen.go b/v2/api/cdn/v1api20210601storage/profiles_endpoint_types_gen.go index 5fcbbacfe96..e4c463e32c4 100644 --- a/v2/api/cdn/v1api20210601storage/profiles_endpoint_types_gen.go +++ b/v2/api/cdn/v1api20210601storage/profiles_endpoint_types_gen.go @@ -84,11 +84,7 @@ func (endpoint *ProfilesEndpoint) NewEmptyStatus() genruntime.ConvertibleStatus // Owner returns the ResourceReference of the owner func (endpoint *ProfilesEndpoint) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(endpoint.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: endpoint.Spec.Owner.Name, - } + return endpoint.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/cdn/v1beta20210601/profile_types_gen.go b/v2/api/cdn/v1beta20210601/profile_types_gen.go index cef965861aa..86de3c61e2c 100644 --- a/v2/api/cdn/v1beta20210601/profile_types_gen.go +++ b/v2/api/cdn/v1beta20210601/profile_types_gen.go @@ -142,11 +142,7 @@ func (profile *Profile) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (profile *Profile) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(profile.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: profile.Spec.Owner.Name, - } + return profile.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -204,7 +200,7 @@ func (profile *Profile) ValidateUpdate(old runtime.Object) (admission.Warnings, // createValidations validates the creation of the resource func (profile *Profile) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){profile.validateResourceReferences} + return []func() (admission.Warnings, error){profile.validateResourceReferences, profile.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -218,7 +214,16 @@ func (profile *Profile) updateValidations() []func(old runtime.Object) (admissio func(old runtime.Object) (admission.Warnings, error) { return profile.validateResourceReferences() }, - profile.validateWriteOnceProperties} + profile.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return profile.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (profile *Profile) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(profile) } // validateResourceReferences validates all resource references @@ -415,7 +420,10 @@ func (profile *Profile_Spec) PopulateFromARM(owner genruntime.ArbitraryOwnerRefe } // Set property "Owner": - profile.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + profile.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "Sku": if typedInput.Sku != nil { diff --git a/v2/api/cdn/v1beta20210601/profiles_endpoint_types_gen.go b/v2/api/cdn/v1beta20210601/profiles_endpoint_types_gen.go index c109f03f368..579f5f9bc85 100644 --- a/v2/api/cdn/v1beta20210601/profiles_endpoint_types_gen.go +++ b/v2/api/cdn/v1beta20210601/profiles_endpoint_types_gen.go @@ -142,11 +142,7 @@ func (endpoint *ProfilesEndpoint) NewEmptyStatus() genruntime.ConvertibleStatus // Owner returns the ResourceReference of the owner func (endpoint *ProfilesEndpoint) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(endpoint.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: endpoint.Spec.Owner.Name, - } + return endpoint.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -204,7 +200,7 @@ func (endpoint *ProfilesEndpoint) ValidateUpdate(old runtime.Object) (admission. // createValidations validates the creation of the resource func (endpoint *ProfilesEndpoint) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){endpoint.validateResourceReferences} + return []func() (admission.Warnings, error){endpoint.validateResourceReferences, endpoint.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -218,7 +214,16 @@ func (endpoint *ProfilesEndpoint) updateValidations() []func(old runtime.Object) func(old runtime.Object) (admission.Warnings, error) { return endpoint.validateResourceReferences() }, - endpoint.validateWriteOnceProperties} + endpoint.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return endpoint.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (endpoint *ProfilesEndpoint) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(endpoint) } // validateResourceReferences validates all resource references @@ -629,7 +634,10 @@ func (endpoint *Profiles_Endpoint_Spec) PopulateFromARM(owner genruntime.Arbitra } // Set property "Owner": - endpoint.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + endpoint.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "ProbePath": // copying flattened property: diff --git a/v2/api/cdn/v1beta20210601storage/profile_types_gen.go b/v2/api/cdn/v1beta20210601storage/profile_types_gen.go index 5c95d57d79b..422e6f067f9 100644 --- a/v2/api/cdn/v1beta20210601storage/profile_types_gen.go +++ b/v2/api/cdn/v1beta20210601storage/profile_types_gen.go @@ -103,11 +103,7 @@ func (profile *Profile) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (profile *Profile) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(profile.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: profile.Spec.Owner.Name, - } + return profile.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/cdn/v1beta20210601storage/profiles_endpoint_types_gen.go b/v2/api/cdn/v1beta20210601storage/profiles_endpoint_types_gen.go index 8586842483b..2aa3f94b833 100644 --- a/v2/api/cdn/v1beta20210601storage/profiles_endpoint_types_gen.go +++ b/v2/api/cdn/v1beta20210601storage/profiles_endpoint_types_gen.go @@ -103,11 +103,7 @@ func (endpoint *ProfilesEndpoint) NewEmptyStatus() genruntime.ConvertibleStatus // Owner returns the ResourceReference of the owner func (endpoint *ProfilesEndpoint) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(endpoint.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: endpoint.Spec.Owner.Name, - } + return endpoint.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/compute/v1api20200930/disk_types_gen.go b/v2/api/compute/v1api20200930/disk_types_gen.go index cc95a11e5c3..62cb60f1e97 100644 --- a/v2/api/compute/v1api20200930/disk_types_gen.go +++ b/v2/api/compute/v1api20200930/disk_types_gen.go @@ -141,11 +141,7 @@ func (disk *Disk) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (disk *Disk) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(disk.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: disk.Spec.Owner.Name, - } + return disk.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -203,7 +199,7 @@ func (disk *Disk) ValidateUpdate(old runtime.Object) (admission.Warnings, error) // createValidations validates the creation of the resource func (disk *Disk) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){disk.validateResourceReferences} + return []func() (admission.Warnings, error){disk.validateResourceReferences, disk.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -217,7 +213,16 @@ func (disk *Disk) updateValidations() []func(old runtime.Object) (admission.Warn func(old runtime.Object) (admission.Warnings, error) { return disk.validateResourceReferences() }, - disk.validateWriteOnceProperties} + disk.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return disk.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (disk *Disk) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(disk) } // validateResourceReferences validates all resource references @@ -727,7 +732,10 @@ func (disk *Disk_Spec) PopulateFromARM(owner genruntime.ArbitraryOwnerReference, } // Set property "Owner": - disk.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + disk.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "PurchasePlan": // copying flattened property: diff --git a/v2/api/compute/v1api20200930/snapshot_types_gen.go b/v2/api/compute/v1api20200930/snapshot_types_gen.go index dd7d78da1af..3df6d698326 100644 --- a/v2/api/compute/v1api20200930/snapshot_types_gen.go +++ b/v2/api/compute/v1api20200930/snapshot_types_gen.go @@ -141,11 +141,7 @@ func (snapshot *Snapshot) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (snapshot *Snapshot) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(snapshot.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: snapshot.Spec.Owner.Name, - } + return snapshot.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -203,7 +199,7 @@ func (snapshot *Snapshot) ValidateUpdate(old runtime.Object) (admission.Warnings // createValidations validates the creation of the resource func (snapshot *Snapshot) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){snapshot.validateResourceReferences} + return []func() (admission.Warnings, error){snapshot.validateResourceReferences, snapshot.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -217,7 +213,16 @@ func (snapshot *Snapshot) updateValidations() []func(old runtime.Object) (admiss func(old runtime.Object) (admission.Warnings, error) { return snapshot.validateResourceReferences() }, - snapshot.validateWriteOnceProperties} + snapshot.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return snapshot.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (snapshot *Snapshot) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(snapshot) } // validateResourceReferences validates all resource references @@ -632,7 +637,10 @@ func (snapshot *Snapshot_Spec) PopulateFromARM(owner genruntime.ArbitraryOwnerRe } // Set property "Owner": - snapshot.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + snapshot.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "PurchasePlan": // copying flattened property: diff --git a/v2/api/compute/v1api20200930storage/disk_types_gen.go b/v2/api/compute/v1api20200930storage/disk_types_gen.go index 698cc86ed76..c3038ccb1f7 100644 --- a/v2/api/compute/v1api20200930storage/disk_types_gen.go +++ b/v2/api/compute/v1api20200930storage/disk_types_gen.go @@ -86,11 +86,7 @@ func (disk *Disk) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (disk *Disk) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(disk.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: disk.Spec.Owner.Name, - } + return disk.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/compute/v1api20200930storage/snapshot_types_gen.go b/v2/api/compute/v1api20200930storage/snapshot_types_gen.go index d8af91895f2..fdbfc9376e9 100644 --- a/v2/api/compute/v1api20200930storage/snapshot_types_gen.go +++ b/v2/api/compute/v1api20200930storage/snapshot_types_gen.go @@ -84,11 +84,7 @@ func (snapshot *Snapshot) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (snapshot *Snapshot) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(snapshot.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: snapshot.Spec.Owner.Name, - } + return snapshot.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/compute/v1api20201201/virtual_machine_scale_set_types_gen.go b/v2/api/compute/v1api20201201/virtual_machine_scale_set_types_gen.go index 446987c1336..e301c60a91e 100644 --- a/v2/api/compute/v1api20201201/virtual_machine_scale_set_types_gen.go +++ b/v2/api/compute/v1api20201201/virtual_machine_scale_set_types_gen.go @@ -145,11 +145,7 @@ func (scaleSet *VirtualMachineScaleSet) NewEmptyStatus() genruntime.ConvertibleS // Owner returns the ResourceReference of the owner func (scaleSet *VirtualMachineScaleSet) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(scaleSet.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: scaleSet.Spec.Owner.Name, - } + return scaleSet.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -207,7 +203,7 @@ func (scaleSet *VirtualMachineScaleSet) ValidateUpdate(old runtime.Object) (admi // createValidations validates the creation of the resource func (scaleSet *VirtualMachineScaleSet) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){scaleSet.validateResourceReferences} + return []func() (admission.Warnings, error){scaleSet.validateResourceReferences, scaleSet.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -221,7 +217,16 @@ func (scaleSet *VirtualMachineScaleSet) updateValidations() []func(old runtime.O func(old runtime.Object) (admission.Warnings, error) { return scaleSet.validateResourceReferences() }, - scaleSet.validateWriteOnceProperties} + scaleSet.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return scaleSet.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (scaleSet *VirtualMachineScaleSet) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(scaleSet) } // validateResourceReferences validates all resource references @@ -683,7 +688,10 @@ func (scaleSet *VirtualMachineScaleSet_Spec) PopulateFromARM(owner genruntime.Ar } // Set property "Owner": - scaleSet.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + scaleSet.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "Plan": if typedInput.Plan != nil { diff --git a/v2/api/compute/v1api20201201/virtual_machine_types_gen.go b/v2/api/compute/v1api20201201/virtual_machine_types_gen.go index c24d6868e16..bc5e05ec22f 100644 --- a/v2/api/compute/v1api20201201/virtual_machine_types_gen.go +++ b/v2/api/compute/v1api20201201/virtual_machine_types_gen.go @@ -145,11 +145,7 @@ func (machine *VirtualMachine) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (machine *VirtualMachine) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(machine.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: machine.Spec.Owner.Name, - } + return machine.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -207,7 +203,7 @@ func (machine *VirtualMachine) ValidateUpdate(old runtime.Object) (admission.War // createValidations validates the creation of the resource func (machine *VirtualMachine) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){machine.validateResourceReferences} + return []func() (admission.Warnings, error){machine.validateResourceReferences, machine.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -221,7 +217,16 @@ func (machine *VirtualMachine) updateValidations() []func(old runtime.Object) (a func(old runtime.Object) (admission.Warnings, error) { return machine.validateResourceReferences() }, - machine.validateWriteOnceProperties} + machine.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return machine.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (machine *VirtualMachine) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(machine) } // validateResourceReferences validates all resource references @@ -859,7 +864,10 @@ func (machine *VirtualMachine_Spec) PopulateFromARM(owner genruntime.ArbitraryOw } // Set property "Owner": - machine.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + machine.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "Plan": if typedInput.Plan != nil { diff --git a/v2/api/compute/v1api20201201storage/virtual_machine_scale_set_types_gen.go b/v2/api/compute/v1api20201201storage/virtual_machine_scale_set_types_gen.go index 53d275b2cae..07d3adf5c1a 100644 --- a/v2/api/compute/v1api20201201storage/virtual_machine_scale_set_types_gen.go +++ b/v2/api/compute/v1api20201201storage/virtual_machine_scale_set_types_gen.go @@ -107,11 +107,7 @@ func (scaleSet *VirtualMachineScaleSet) NewEmptyStatus() genruntime.ConvertibleS // Owner returns the ResourceReference of the owner func (scaleSet *VirtualMachineScaleSet) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(scaleSet.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: scaleSet.Spec.Owner.Name, - } + return scaleSet.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/compute/v1api20201201storage/virtual_machine_types_gen.go b/v2/api/compute/v1api20201201storage/virtual_machine_types_gen.go index 43fcec2c89d..530cfaf1032 100644 --- a/v2/api/compute/v1api20201201storage/virtual_machine_types_gen.go +++ b/v2/api/compute/v1api20201201storage/virtual_machine_types_gen.go @@ -107,11 +107,7 @@ func (machine *VirtualMachine) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (machine *VirtualMachine) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(machine.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: machine.Spec.Owner.Name, - } + return machine.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/compute/v1api20210701/image_types_gen.go b/v2/api/compute/v1api20210701/image_types_gen.go index 279c3a61d93..5a55fc76c2d 100644 --- a/v2/api/compute/v1api20210701/image_types_gen.go +++ b/v2/api/compute/v1api20210701/image_types_gen.go @@ -144,11 +144,7 @@ func (image *Image) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (image *Image) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(image.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: image.Spec.Owner.Name, - } + return image.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -206,7 +202,7 @@ func (image *Image) ValidateUpdate(old runtime.Object) (admission.Warnings, erro // createValidations validates the creation of the resource func (image *Image) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){image.validateResourceReferences} + return []func() (admission.Warnings, error){image.validateResourceReferences, image.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -220,7 +216,16 @@ func (image *Image) updateValidations() []func(old runtime.Object) (admission.Wa func(old runtime.Object) (admission.Warnings, error) { return image.validateResourceReferences() }, - image.validateWriteOnceProperties} + image.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return image.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (image *Image) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(image) } // validateResourceReferences validates all resource references @@ -459,7 +464,10 @@ func (image *Image_Spec) PopulateFromARM(owner genruntime.ArbitraryOwnerReferenc } // Set property "Owner": - image.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + image.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "SourceVirtualMachine": // copying flattened property: diff --git a/v2/api/compute/v1api20210701storage/image_types_gen.go b/v2/api/compute/v1api20210701storage/image_types_gen.go index becda755c02..75d99d5115b 100644 --- a/v2/api/compute/v1api20210701storage/image_types_gen.go +++ b/v2/api/compute/v1api20210701storage/image_types_gen.go @@ -105,11 +105,7 @@ func (image *Image) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (image *Image) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(image.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: image.Spec.Owner.Name, - } + return image.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/compute/v1api20220301/image_types_gen.go b/v2/api/compute/v1api20220301/image_types_gen.go index 8ab1062fba2..9cb54d8c7c0 100644 --- a/v2/api/compute/v1api20220301/image_types_gen.go +++ b/v2/api/compute/v1api20220301/image_types_gen.go @@ -141,11 +141,7 @@ func (image *Image) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (image *Image) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(image.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: image.Spec.Owner.Name, - } + return image.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -203,7 +199,7 @@ func (image *Image) ValidateUpdate(old runtime.Object) (admission.Warnings, erro // createValidations validates the creation of the resource func (image *Image) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){image.validateResourceReferences} + return []func() (admission.Warnings, error){image.validateResourceReferences, image.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -217,7 +213,16 @@ func (image *Image) updateValidations() []func(old runtime.Object) (admission.Wa func(old runtime.Object) (admission.Warnings, error) { return image.validateResourceReferences() }, - image.validateWriteOnceProperties} + image.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return image.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (image *Image) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(image) } // validateResourceReferences validates all resource references @@ -456,7 +461,10 @@ func (image *Image_Spec) PopulateFromARM(owner genruntime.ArbitraryOwnerReferenc } // Set property "Owner": - image.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + image.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "SourceVirtualMachine": // copying flattened property: diff --git a/v2/api/compute/v1api20220301/virtual_machine_scale_set_types_gen.go b/v2/api/compute/v1api20220301/virtual_machine_scale_set_types_gen.go index cdce781f770..09d9aa69e92 100644 --- a/v2/api/compute/v1api20220301/virtual_machine_scale_set_types_gen.go +++ b/v2/api/compute/v1api20220301/virtual_machine_scale_set_types_gen.go @@ -142,11 +142,7 @@ func (scaleSet *VirtualMachineScaleSet) NewEmptyStatus() genruntime.ConvertibleS // Owner returns the ResourceReference of the owner func (scaleSet *VirtualMachineScaleSet) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(scaleSet.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: scaleSet.Spec.Owner.Name, - } + return scaleSet.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -204,7 +200,7 @@ func (scaleSet *VirtualMachineScaleSet) ValidateUpdate(old runtime.Object) (admi // createValidations validates the creation of the resource func (scaleSet *VirtualMachineScaleSet) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){scaleSet.validateResourceReferences} + return []func() (admission.Warnings, error){scaleSet.validateResourceReferences, scaleSet.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -218,7 +214,16 @@ func (scaleSet *VirtualMachineScaleSet) updateValidations() []func(old runtime.O func(old runtime.Object) (admission.Warnings, error) { return scaleSet.validateResourceReferences() }, - scaleSet.validateWriteOnceProperties} + scaleSet.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return scaleSet.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (scaleSet *VirtualMachineScaleSet) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(scaleSet) } // validateResourceReferences validates all resource references @@ -693,7 +698,10 @@ func (scaleSet *VirtualMachineScaleSet_Spec) PopulateFromARM(owner genruntime.Ar } // Set property "Owner": - scaleSet.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + scaleSet.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "Plan": if typedInput.Plan != nil { diff --git a/v2/api/compute/v1api20220301/virtual_machine_types_gen.go b/v2/api/compute/v1api20220301/virtual_machine_types_gen.go index 7dc963c44b5..c0df63fc563 100644 --- a/v2/api/compute/v1api20220301/virtual_machine_types_gen.go +++ b/v2/api/compute/v1api20220301/virtual_machine_types_gen.go @@ -142,11 +142,7 @@ func (machine *VirtualMachine) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (machine *VirtualMachine) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(machine.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: machine.Spec.Owner.Name, - } + return machine.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -204,7 +200,7 @@ func (machine *VirtualMachine) ValidateUpdate(old runtime.Object) (admission.War // createValidations validates the creation of the resource func (machine *VirtualMachine) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){machine.validateResourceReferences} + return []func() (admission.Warnings, error){machine.validateResourceReferences, machine.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -218,7 +214,16 @@ func (machine *VirtualMachine) updateValidations() []func(old runtime.Object) (a func(old runtime.Object) (admission.Warnings, error) { return machine.validateResourceReferences() }, - machine.validateWriteOnceProperties} + machine.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return machine.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (machine *VirtualMachine) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(machine) } // validateResourceReferences validates all resource references @@ -925,7 +930,10 @@ func (machine *VirtualMachine_Spec) PopulateFromARM(owner genruntime.ArbitraryOw } // Set property "Owner": - machine.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + machine.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "Plan": if typedInput.Plan != nil { diff --git a/v2/api/compute/v1api20220301storage/image_types_gen.go b/v2/api/compute/v1api20220301storage/image_types_gen.go index 8eaa12e71b2..08e1bad0f8c 100644 --- a/v2/api/compute/v1api20220301storage/image_types_gen.go +++ b/v2/api/compute/v1api20220301storage/image_types_gen.go @@ -84,11 +84,7 @@ func (image *Image) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (image *Image) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(image.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: image.Spec.Owner.Name, - } + return image.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/compute/v1api20220301storage/virtual_machine_scale_set_types_gen.go b/v2/api/compute/v1api20220301storage/virtual_machine_scale_set_types_gen.go index 2610389052e..b91aa283bb5 100644 --- a/v2/api/compute/v1api20220301storage/virtual_machine_scale_set_types_gen.go +++ b/v2/api/compute/v1api20220301storage/virtual_machine_scale_set_types_gen.go @@ -85,11 +85,7 @@ func (scaleSet *VirtualMachineScaleSet) NewEmptyStatus() genruntime.ConvertibleS // Owner returns the ResourceReference of the owner func (scaleSet *VirtualMachineScaleSet) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(scaleSet.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: scaleSet.Spec.Owner.Name, - } + return scaleSet.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/compute/v1api20220301storage/virtual_machine_types_gen.go b/v2/api/compute/v1api20220301storage/virtual_machine_types_gen.go index b3e44d56cf8..f0bed0267fe 100644 --- a/v2/api/compute/v1api20220301storage/virtual_machine_types_gen.go +++ b/v2/api/compute/v1api20220301storage/virtual_machine_types_gen.go @@ -86,11 +86,7 @@ func (machine *VirtualMachine) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (machine *VirtualMachine) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(machine.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: machine.Spec.Owner.Name, - } + return machine.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/compute/v1api20220702/disk_encryption_set_types_gen.go b/v2/api/compute/v1api20220702/disk_encryption_set_types_gen.go index e70b194c4c8..b1694a8ef2e 100644 --- a/v2/api/compute/v1api20220702/disk_encryption_set_types_gen.go +++ b/v2/api/compute/v1api20220702/disk_encryption_set_types_gen.go @@ -141,11 +141,7 @@ func (encryptionSet *DiskEncryptionSet) NewEmptyStatus() genruntime.ConvertibleS // Owner returns the ResourceReference of the owner func (encryptionSet *DiskEncryptionSet) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(encryptionSet.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: encryptionSet.Spec.Owner.Name, - } + return encryptionSet.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -203,7 +199,7 @@ func (encryptionSet *DiskEncryptionSet) ValidateUpdate(old runtime.Object) (admi // createValidations validates the creation of the resource func (encryptionSet *DiskEncryptionSet) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){encryptionSet.validateResourceReferences, encryptionSet.validateOptionalConfigMapReferences} + return []func() (admission.Warnings, error){encryptionSet.validateResourceReferences, encryptionSet.validateOwnerReference, encryptionSet.validateOptionalConfigMapReferences} } // deleteValidations validates the deletion of the resource @@ -218,6 +214,9 @@ func (encryptionSet *DiskEncryptionSet) updateValidations() []func(old runtime.O return encryptionSet.validateResourceReferences() }, encryptionSet.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return encryptionSet.validateOwnerReference() + }, func(old runtime.Object) (admission.Warnings, error) { return encryptionSet.validateOptionalConfigMapReferences() }, @@ -233,6 +232,11 @@ func (encryptionSet *DiskEncryptionSet) validateOptionalConfigMapReferences() (a return genruntime.ValidateOptionalConfigMapReferences(refs) } +// validateOwnerReference validates the owner field +func (encryptionSet *DiskEncryptionSet) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(encryptionSet) +} + // validateResourceReferences validates all resource references func (encryptionSet *DiskEncryptionSet) validateResourceReferences() (admission.Warnings, error) { refs, err := reflecthelpers.FindResourceReferences(&encryptionSet.Spec) @@ -511,7 +515,10 @@ func (encryptionSet *DiskEncryptionSet_Spec) PopulateFromARM(owner genruntime.Ar } // Set property "Owner": - encryptionSet.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + encryptionSet.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "RotationToLatestKeyVersionEnabled": // copying flattened property: diff --git a/v2/api/compute/v1api20220702storage/disk_encryption_set_types_gen.go b/v2/api/compute/v1api20220702storage/disk_encryption_set_types_gen.go index 0cef61577c8..e2bc31e0094 100644 --- a/v2/api/compute/v1api20220702storage/disk_encryption_set_types_gen.go +++ b/v2/api/compute/v1api20220702storage/disk_encryption_set_types_gen.go @@ -84,11 +84,7 @@ func (encryptionSet *DiskEncryptionSet) NewEmptyStatus() genruntime.ConvertibleS // Owner returns the ResourceReference of the owner func (encryptionSet *DiskEncryptionSet) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(encryptionSet.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: encryptionSet.Spec.Owner.Name, - } + return encryptionSet.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/compute/v1beta20200930/disk_types_gen.go b/v2/api/compute/v1beta20200930/disk_types_gen.go index 7774f49a311..e32f5d87140 100644 --- a/v2/api/compute/v1beta20200930/disk_types_gen.go +++ b/v2/api/compute/v1beta20200930/disk_types_gen.go @@ -142,11 +142,7 @@ func (disk *Disk) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (disk *Disk) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(disk.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: disk.Spec.Owner.Name, - } + return disk.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -204,7 +200,7 @@ func (disk *Disk) ValidateUpdate(old runtime.Object) (admission.Warnings, error) // createValidations validates the creation of the resource func (disk *Disk) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){disk.validateResourceReferences} + return []func() (admission.Warnings, error){disk.validateResourceReferences, disk.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -218,7 +214,16 @@ func (disk *Disk) updateValidations() []func(old runtime.Object) (admission.Warn func(old runtime.Object) (admission.Warnings, error) { return disk.validateResourceReferences() }, - disk.validateWriteOnceProperties} + disk.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return disk.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (disk *Disk) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(disk) } // validateResourceReferences validates all resource references @@ -676,7 +681,10 @@ func (disk *Disk_Spec) PopulateFromARM(owner genruntime.ArbitraryOwnerReference, } // Set property "Owner": - disk.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + disk.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "PurchasePlan": // copying flattened property: diff --git a/v2/api/compute/v1beta20200930/snapshot_types_gen.go b/v2/api/compute/v1beta20200930/snapshot_types_gen.go index a48e40b5813..dbc042b1db1 100644 --- a/v2/api/compute/v1beta20200930/snapshot_types_gen.go +++ b/v2/api/compute/v1beta20200930/snapshot_types_gen.go @@ -142,11 +142,7 @@ func (snapshot *Snapshot) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (snapshot *Snapshot) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(snapshot.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: snapshot.Spec.Owner.Name, - } + return snapshot.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -204,7 +200,7 @@ func (snapshot *Snapshot) ValidateUpdate(old runtime.Object) (admission.Warnings // createValidations validates the creation of the resource func (snapshot *Snapshot) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){snapshot.validateResourceReferences} + return []func() (admission.Warnings, error){snapshot.validateResourceReferences, snapshot.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -218,7 +214,16 @@ func (snapshot *Snapshot) updateValidations() []func(old runtime.Object) (admiss func(old runtime.Object) (admission.Warnings, error) { return snapshot.validateResourceReferences() }, - snapshot.validateWriteOnceProperties} + snapshot.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return snapshot.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (snapshot *Snapshot) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(snapshot) } // validateResourceReferences validates all resource references @@ -598,7 +603,10 @@ func (snapshot *Snapshot_Spec) PopulateFromARM(owner genruntime.ArbitraryOwnerRe } // Set property "Owner": - snapshot.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + snapshot.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "PurchasePlan": // copying flattened property: diff --git a/v2/api/compute/v1beta20200930storage/disk_types_gen.go b/v2/api/compute/v1beta20200930storage/disk_types_gen.go index 187186c6540..14397cbf6a6 100644 --- a/v2/api/compute/v1beta20200930storage/disk_types_gen.go +++ b/v2/api/compute/v1beta20200930storage/disk_types_gen.go @@ -106,11 +106,7 @@ func (disk *Disk) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (disk *Disk) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(disk.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: disk.Spec.Owner.Name, - } + return disk.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/compute/v1beta20200930storage/snapshot_types_gen.go b/v2/api/compute/v1beta20200930storage/snapshot_types_gen.go index ebe131468d1..bb5f082ff34 100644 --- a/v2/api/compute/v1beta20200930storage/snapshot_types_gen.go +++ b/v2/api/compute/v1beta20200930storage/snapshot_types_gen.go @@ -106,11 +106,7 @@ func (snapshot *Snapshot) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (snapshot *Snapshot) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(snapshot.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: snapshot.Spec.Owner.Name, - } + return snapshot.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/compute/v1beta20201201/virtual_machine_scale_set_types_gen.go b/v2/api/compute/v1beta20201201/virtual_machine_scale_set_types_gen.go index a5f00d99323..83fd1b15dd6 100644 --- a/v2/api/compute/v1beta20201201/virtual_machine_scale_set_types_gen.go +++ b/v2/api/compute/v1beta20201201/virtual_machine_scale_set_types_gen.go @@ -143,11 +143,7 @@ func (scaleSet *VirtualMachineScaleSet) NewEmptyStatus() genruntime.ConvertibleS // Owner returns the ResourceReference of the owner func (scaleSet *VirtualMachineScaleSet) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(scaleSet.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: scaleSet.Spec.Owner.Name, - } + return scaleSet.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -205,7 +201,7 @@ func (scaleSet *VirtualMachineScaleSet) ValidateUpdate(old runtime.Object) (admi // createValidations validates the creation of the resource func (scaleSet *VirtualMachineScaleSet) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){scaleSet.validateResourceReferences} + return []func() (admission.Warnings, error){scaleSet.validateResourceReferences, scaleSet.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -219,7 +215,16 @@ func (scaleSet *VirtualMachineScaleSet) updateValidations() []func(old runtime.O func(old runtime.Object) (admission.Warnings, error) { return scaleSet.validateResourceReferences() }, - scaleSet.validateWriteOnceProperties} + scaleSet.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return scaleSet.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (scaleSet *VirtualMachineScaleSet) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(scaleSet) } // validateResourceReferences validates all resource references @@ -628,7 +633,10 @@ func (scaleSet *VirtualMachineScaleSet_Spec) PopulateFromARM(owner genruntime.Ar } // Set property "Owner": - scaleSet.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + scaleSet.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "Plan": if typedInput.Plan != nil { diff --git a/v2/api/compute/v1beta20201201/virtual_machine_types_gen.go b/v2/api/compute/v1beta20201201/virtual_machine_types_gen.go index 9c651aa3763..af4144a7a84 100644 --- a/v2/api/compute/v1beta20201201/virtual_machine_types_gen.go +++ b/v2/api/compute/v1beta20201201/virtual_machine_types_gen.go @@ -143,11 +143,7 @@ func (machine *VirtualMachine) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (machine *VirtualMachine) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(machine.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: machine.Spec.Owner.Name, - } + return machine.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -205,7 +201,7 @@ func (machine *VirtualMachine) ValidateUpdate(old runtime.Object) (admission.War // createValidations validates the creation of the resource func (machine *VirtualMachine) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){machine.validateResourceReferences} + return []func() (admission.Warnings, error){machine.validateResourceReferences, machine.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -219,7 +215,16 @@ func (machine *VirtualMachine) updateValidations() []func(old runtime.Object) (a func(old runtime.Object) (admission.Warnings, error) { return machine.validateResourceReferences() }, - machine.validateWriteOnceProperties} + machine.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return machine.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (machine *VirtualMachine) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(machine) } // validateResourceReferences validates all resource references @@ -761,7 +766,10 @@ func (machine *VirtualMachine_Spec) PopulateFromARM(owner genruntime.ArbitraryOw } // Set property "Owner": - machine.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + machine.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "Plan": if typedInput.Plan != nil { diff --git a/v2/api/compute/v1beta20201201storage/virtual_machine_scale_set_types_gen.go b/v2/api/compute/v1beta20201201storage/virtual_machine_scale_set_types_gen.go index 0917830dfb3..a0986563dd0 100644 --- a/v2/api/compute/v1beta20201201storage/virtual_machine_scale_set_types_gen.go +++ b/v2/api/compute/v1beta20201201storage/virtual_machine_scale_set_types_gen.go @@ -118,11 +118,7 @@ func (scaleSet *VirtualMachineScaleSet) NewEmptyStatus() genruntime.ConvertibleS // Owner returns the ResourceReference of the owner func (scaleSet *VirtualMachineScaleSet) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(scaleSet.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: scaleSet.Spec.Owner.Name, - } + return scaleSet.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/compute/v1beta20201201storage/virtual_machine_types_gen.go b/v2/api/compute/v1beta20201201storage/virtual_machine_types_gen.go index b8fadbba27d..949773c7969 100644 --- a/v2/api/compute/v1beta20201201storage/virtual_machine_types_gen.go +++ b/v2/api/compute/v1beta20201201storage/virtual_machine_types_gen.go @@ -118,11 +118,7 @@ func (machine *VirtualMachine) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (machine *VirtualMachine) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(machine.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: machine.Spec.Owner.Name, - } + return machine.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/compute/v1beta20210701/image_types_gen.go b/v2/api/compute/v1beta20210701/image_types_gen.go index 52aa548fccc..c24f1be5840 100644 --- a/v2/api/compute/v1beta20210701/image_types_gen.go +++ b/v2/api/compute/v1beta20210701/image_types_gen.go @@ -142,11 +142,7 @@ func (image *Image) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (image *Image) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(image.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: image.Spec.Owner.Name, - } + return image.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -204,7 +200,7 @@ func (image *Image) ValidateUpdate(old runtime.Object) (admission.Warnings, erro // createValidations validates the creation of the resource func (image *Image) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){image.validateResourceReferences} + return []func() (admission.Warnings, error){image.validateResourceReferences, image.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -218,7 +214,16 @@ func (image *Image) updateValidations() []func(old runtime.Object) (admission.Wa func(old runtime.Object) (admission.Warnings, error) { return image.validateResourceReferences() }, - image.validateWriteOnceProperties} + image.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return image.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (image *Image) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(image) } // validateResourceReferences validates all resource references @@ -442,7 +447,10 @@ func (image *Image_Spec) PopulateFromARM(owner genruntime.ArbitraryOwnerReferenc } // Set property "Owner": - image.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + image.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "SourceVirtualMachine": // copying flattened property: diff --git a/v2/api/compute/v1beta20210701storage/image_types_gen.go b/v2/api/compute/v1beta20210701storage/image_types_gen.go index b4e290bd0da..d48fd4f19c2 100644 --- a/v2/api/compute/v1beta20210701storage/image_types_gen.go +++ b/v2/api/compute/v1beta20210701storage/image_types_gen.go @@ -116,11 +116,7 @@ func (image *Image) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (image *Image) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(image.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: image.Spec.Owner.Name, - } + return image.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/compute/v1beta20220301/image_types_gen.go b/v2/api/compute/v1beta20220301/image_types_gen.go index 19d1b2d1b58..664a05dc3f3 100644 --- a/v2/api/compute/v1beta20220301/image_types_gen.go +++ b/v2/api/compute/v1beta20220301/image_types_gen.go @@ -142,11 +142,7 @@ func (image *Image) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (image *Image) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(image.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: image.Spec.Owner.Name, - } + return image.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -204,7 +200,7 @@ func (image *Image) ValidateUpdate(old runtime.Object) (admission.Warnings, erro // createValidations validates the creation of the resource func (image *Image) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){image.validateResourceReferences} + return []func() (admission.Warnings, error){image.validateResourceReferences, image.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -218,7 +214,16 @@ func (image *Image) updateValidations() []func(old runtime.Object) (admission.Wa func(old runtime.Object) (admission.Warnings, error) { return image.validateResourceReferences() }, - image.validateWriteOnceProperties} + image.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return image.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (image *Image) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(image) } // validateResourceReferences validates all resource references @@ -442,7 +447,10 @@ func (image *Image_Spec) PopulateFromARM(owner genruntime.ArbitraryOwnerReferenc } // Set property "Owner": - image.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + image.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "SourceVirtualMachine": // copying flattened property: diff --git a/v2/api/compute/v1beta20220301/virtual_machine_scale_set_types_gen.go b/v2/api/compute/v1beta20220301/virtual_machine_scale_set_types_gen.go index 97536806b22..d238ebd15e5 100644 --- a/v2/api/compute/v1beta20220301/virtual_machine_scale_set_types_gen.go +++ b/v2/api/compute/v1beta20220301/virtual_machine_scale_set_types_gen.go @@ -143,11 +143,7 @@ func (scaleSet *VirtualMachineScaleSet) NewEmptyStatus() genruntime.ConvertibleS // Owner returns the ResourceReference of the owner func (scaleSet *VirtualMachineScaleSet) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(scaleSet.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: scaleSet.Spec.Owner.Name, - } + return scaleSet.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -205,7 +201,7 @@ func (scaleSet *VirtualMachineScaleSet) ValidateUpdate(old runtime.Object) (admi // createValidations validates the creation of the resource func (scaleSet *VirtualMachineScaleSet) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){scaleSet.validateResourceReferences} + return []func() (admission.Warnings, error){scaleSet.validateResourceReferences, scaleSet.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -219,7 +215,16 @@ func (scaleSet *VirtualMachineScaleSet) updateValidations() []func(old runtime.O func(old runtime.Object) (admission.Warnings, error) { return scaleSet.validateResourceReferences() }, - scaleSet.validateWriteOnceProperties} + scaleSet.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return scaleSet.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (scaleSet *VirtualMachineScaleSet) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(scaleSet) } // validateResourceReferences validates all resource references @@ -638,7 +643,10 @@ func (scaleSet *VirtualMachineScaleSet_Spec) PopulateFromARM(owner genruntime.Ar } // Set property "Owner": - scaleSet.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + scaleSet.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "Plan": if typedInput.Plan != nil { diff --git a/v2/api/compute/v1beta20220301/virtual_machine_types_gen.go b/v2/api/compute/v1beta20220301/virtual_machine_types_gen.go index 6b493d7d18f..edaf8c7e995 100644 --- a/v2/api/compute/v1beta20220301/virtual_machine_types_gen.go +++ b/v2/api/compute/v1beta20220301/virtual_machine_types_gen.go @@ -143,11 +143,7 @@ func (machine *VirtualMachine) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (machine *VirtualMachine) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(machine.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: machine.Spec.Owner.Name, - } + return machine.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -205,7 +201,7 @@ func (machine *VirtualMachine) ValidateUpdate(old runtime.Object) (admission.War // createValidations validates the creation of the resource func (machine *VirtualMachine) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){machine.validateResourceReferences} + return []func() (admission.Warnings, error){machine.validateResourceReferences, machine.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -219,7 +215,16 @@ func (machine *VirtualMachine) updateValidations() []func(old runtime.Object) (a func(old runtime.Object) (admission.Warnings, error) { return machine.validateResourceReferences() }, - machine.validateWriteOnceProperties} + machine.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return machine.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (machine *VirtualMachine) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(machine) } // validateResourceReferences validates all resource references @@ -819,7 +824,10 @@ func (machine *VirtualMachine_Spec) PopulateFromARM(owner genruntime.ArbitraryOw } // Set property "Owner": - machine.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + machine.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "Plan": if typedInput.Plan != nil { diff --git a/v2/api/compute/v1beta20220301storage/image_types_gen.go b/v2/api/compute/v1beta20220301storage/image_types_gen.go index 6ae45d1b20d..5376fe73780 100644 --- a/v2/api/compute/v1beta20220301storage/image_types_gen.go +++ b/v2/api/compute/v1beta20220301storage/image_types_gen.go @@ -118,11 +118,7 @@ func (image *Image) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (image *Image) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(image.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: image.Spec.Owner.Name, - } + return image.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/compute/v1beta20220301storage/virtual_machine_scale_set_types_gen.go b/v2/api/compute/v1beta20220301storage/virtual_machine_scale_set_types_gen.go index 1866add1fb0..e5507e559ba 100644 --- a/v2/api/compute/v1beta20220301storage/virtual_machine_scale_set_types_gen.go +++ b/v2/api/compute/v1beta20220301storage/virtual_machine_scale_set_types_gen.go @@ -119,11 +119,7 @@ func (scaleSet *VirtualMachineScaleSet) NewEmptyStatus() genruntime.ConvertibleS // Owner returns the ResourceReference of the owner func (scaleSet *VirtualMachineScaleSet) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(scaleSet.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: scaleSet.Spec.Owner.Name, - } + return scaleSet.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/compute/v1beta20220301storage/virtual_machine_types_gen.go b/v2/api/compute/v1beta20220301storage/virtual_machine_types_gen.go index 49e7d21f126..f62a993bfd7 100644 --- a/v2/api/compute/v1beta20220301storage/virtual_machine_types_gen.go +++ b/v2/api/compute/v1beta20220301storage/virtual_machine_types_gen.go @@ -120,11 +120,7 @@ func (machine *VirtualMachine) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (machine *VirtualMachine) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(machine.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: machine.Spec.Owner.Name, - } + return machine.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/containerinstance/v1api20211001/container_group_types_gen.go b/v2/api/containerinstance/v1api20211001/container_group_types_gen.go index e305c0b3c17..bb0ecf1f602 100644 --- a/v2/api/containerinstance/v1api20211001/container_group_types_gen.go +++ b/v2/api/containerinstance/v1api20211001/container_group_types_gen.go @@ -142,11 +142,7 @@ func (group *ContainerGroup) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (group *ContainerGroup) Owner() *genruntime.ResourceReference { ownerGroup, ownerKind := genruntime.LookupOwnerGroupKind(group.Spec) - return &genruntime.ResourceReference{ - Group: ownerGroup, - Kind: ownerKind, - Name: group.Spec.Owner.Name, - } + return group.Spec.Owner.AsResourceReference(ownerGroup, ownerKind) } // SetStatus sets the status of this resource @@ -204,7 +200,7 @@ func (group *ContainerGroup) ValidateUpdate(old runtime.Object) (admission.Warni // createValidations validates the creation of the resource func (group *ContainerGroup) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){group.validateResourceReferences} + return []func() (admission.Warnings, error){group.validateResourceReferences, group.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -218,7 +214,16 @@ func (group *ContainerGroup) updateValidations() []func(old runtime.Object) (adm func(old runtime.Object) (admission.Warnings, error) { return group.validateResourceReferences() }, - group.validateWriteOnceProperties} + group.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return group.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (group *ContainerGroup) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(group) } // validateResourceReferences validates all resource references @@ -656,7 +661,10 @@ func (group *ContainerGroup_Spec) PopulateFromARM(owner genruntime.ArbitraryOwne } // Set property "Owner": - group.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + group.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "RestartPolicy": // copying flattened property: diff --git a/v2/api/containerinstance/v1api20211001storage/container_group_types_gen.go b/v2/api/containerinstance/v1api20211001storage/container_group_types_gen.go index ee331ce9d10..c4785ea412b 100644 --- a/v2/api/containerinstance/v1api20211001storage/container_group_types_gen.go +++ b/v2/api/containerinstance/v1api20211001storage/container_group_types_gen.go @@ -85,11 +85,7 @@ func (group *ContainerGroup) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (group *ContainerGroup) Owner() *genruntime.ResourceReference { ownerGroup, ownerKind := genruntime.LookupOwnerGroupKind(group.Spec) - return &genruntime.ResourceReference{ - Group: ownerGroup, - Kind: ownerKind, - Name: group.Spec.Owner.Name, - } + return group.Spec.Owner.AsResourceReference(ownerGroup, ownerKind) } // SetStatus sets the status of this resource diff --git a/v2/api/containerinstance/v1beta20211001/container_group_types_gen.go b/v2/api/containerinstance/v1beta20211001/container_group_types_gen.go index 776dae492f2..2c05eea59e0 100644 --- a/v2/api/containerinstance/v1beta20211001/container_group_types_gen.go +++ b/v2/api/containerinstance/v1beta20211001/container_group_types_gen.go @@ -143,11 +143,7 @@ func (group *ContainerGroup) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (group *ContainerGroup) Owner() *genruntime.ResourceReference { ownerGroup, ownerKind := genruntime.LookupOwnerGroupKind(group.Spec) - return &genruntime.ResourceReference{ - Group: ownerGroup, - Kind: ownerKind, - Name: group.Spec.Owner.Name, - } + return group.Spec.Owner.AsResourceReference(ownerGroup, ownerKind) } // SetStatus sets the status of this resource @@ -205,7 +201,7 @@ func (group *ContainerGroup) ValidateUpdate(old runtime.Object) (admission.Warni // createValidations validates the creation of the resource func (group *ContainerGroup) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){group.validateResourceReferences} + return []func() (admission.Warnings, error){group.validateResourceReferences, group.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -219,7 +215,16 @@ func (group *ContainerGroup) updateValidations() []func(old runtime.Object) (adm func(old runtime.Object) (admission.Warnings, error) { return group.validateResourceReferences() }, - group.validateWriteOnceProperties} + group.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return group.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (group *ContainerGroup) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(group) } // validateResourceReferences validates all resource references @@ -623,7 +628,10 @@ func (group *ContainerGroup_Spec) PopulateFromARM(owner genruntime.ArbitraryOwne } // Set property "Owner": - group.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + group.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "RestartPolicy": // copying flattened property: diff --git a/v2/api/containerinstance/v1beta20211001storage/container_group_types_gen.go b/v2/api/containerinstance/v1beta20211001storage/container_group_types_gen.go index c9964c2f6b3..cddb8db104a 100644 --- a/v2/api/containerinstance/v1beta20211001storage/container_group_types_gen.go +++ b/v2/api/containerinstance/v1beta20211001storage/container_group_types_gen.go @@ -104,11 +104,7 @@ func (group *ContainerGroup) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (group *ContainerGroup) Owner() *genruntime.ResourceReference { ownerGroup, ownerKind := genruntime.LookupOwnerGroupKind(group.Spec) - return &genruntime.ResourceReference{ - Group: ownerGroup, - Kind: ownerKind, - Name: group.Spec.Owner.Name, - } + return group.Spec.Owner.AsResourceReference(ownerGroup, ownerKind) } // SetStatus sets the status of this resource diff --git a/v2/api/containerregistry/v1api20210901/registry_types_gen.go b/v2/api/containerregistry/v1api20210901/registry_types_gen.go index 5b2d52f6413..3cf00cb96b1 100644 --- a/v2/api/containerregistry/v1api20210901/registry_types_gen.go +++ b/v2/api/containerregistry/v1api20210901/registry_types_gen.go @@ -141,11 +141,7 @@ func (registry *Registry) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (registry *Registry) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(registry.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: registry.Spec.Owner.Name, - } + return registry.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -203,7 +199,7 @@ func (registry *Registry) ValidateUpdate(old runtime.Object) (admission.Warnings // createValidations validates the creation of the resource func (registry *Registry) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){registry.validateResourceReferences} + return []func() (admission.Warnings, error){registry.validateResourceReferences, registry.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -217,7 +213,16 @@ func (registry *Registry) updateValidations() []func(old runtime.Object) (admiss func(old runtime.Object) (admission.Warnings, error) { return registry.validateResourceReferences() }, - registry.validateWriteOnceProperties} + registry.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return registry.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (registry *Registry) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(registry) } // validateResourceReferences validates all resource references @@ -560,7 +565,10 @@ func (registry *Registry_Spec) PopulateFromARM(owner genruntime.ArbitraryOwnerRe } // Set property "Owner": - registry.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + registry.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "Policies": // copying flattened property: diff --git a/v2/api/containerregistry/v1api20210901storage/registry_types_gen.go b/v2/api/containerregistry/v1api20210901storage/registry_types_gen.go index 039fc9fe17a..35d24a63c9a 100644 --- a/v2/api/containerregistry/v1api20210901storage/registry_types_gen.go +++ b/v2/api/containerregistry/v1api20210901storage/registry_types_gen.go @@ -84,11 +84,7 @@ func (registry *Registry) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (registry *Registry) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(registry.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: registry.Spec.Owner.Name, - } + return registry.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/containerregistry/v1beta20210901/registry_types_gen.go b/v2/api/containerregistry/v1beta20210901/registry_types_gen.go index f6e6e263aac..c5c1b18be1f 100644 --- a/v2/api/containerregistry/v1beta20210901/registry_types_gen.go +++ b/v2/api/containerregistry/v1beta20210901/registry_types_gen.go @@ -142,11 +142,7 @@ func (registry *Registry) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (registry *Registry) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(registry.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: registry.Spec.Owner.Name, - } + return registry.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -204,7 +200,7 @@ func (registry *Registry) ValidateUpdate(old runtime.Object) (admission.Warnings // createValidations validates the creation of the resource func (registry *Registry) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){registry.validateResourceReferences} + return []func() (admission.Warnings, error){registry.validateResourceReferences, registry.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -218,7 +214,16 @@ func (registry *Registry) updateValidations() []func(old runtime.Object) (admiss func(old runtime.Object) (admission.Warnings, error) { return registry.validateResourceReferences() }, - registry.validateWriteOnceProperties} + registry.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return registry.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (registry *Registry) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(registry) } // validateResourceReferences validates all resource references @@ -539,7 +544,10 @@ func (registry *Registry_Spec) PopulateFromARM(owner genruntime.ArbitraryOwnerRe } // Set property "Owner": - registry.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + registry.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "Policies": // copying flattened property: diff --git a/v2/api/containerregistry/v1beta20210901storage/registry_types_gen.go b/v2/api/containerregistry/v1beta20210901storage/registry_types_gen.go index 5743996e81b..6e7069dc7ce 100644 --- a/v2/api/containerregistry/v1beta20210901storage/registry_types_gen.go +++ b/v2/api/containerregistry/v1beta20210901storage/registry_types_gen.go @@ -103,11 +103,7 @@ func (registry *Registry) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (registry *Registry) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(registry.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: registry.Spec.Owner.Name, - } + return registry.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/containerservice/v1api20210501/managed_cluster_types_gen.go b/v2/api/containerservice/v1api20210501/managed_cluster_types_gen.go index dc180304ff4..45486a313b5 100644 --- a/v2/api/containerservice/v1api20210501/managed_cluster_types_gen.go +++ b/v2/api/containerservice/v1api20210501/managed_cluster_types_gen.go @@ -144,11 +144,7 @@ func (cluster *ManagedCluster) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (cluster *ManagedCluster) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(cluster.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: cluster.Spec.Owner.Name, - } + return cluster.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -206,7 +202,7 @@ func (cluster *ManagedCluster) ValidateUpdate(old runtime.Object) (admission.War // createValidations validates the creation of the resource func (cluster *ManagedCluster) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){cluster.validateResourceReferences, cluster.validateSecretDestinations} + return []func() (admission.Warnings, error){cluster.validateResourceReferences, cluster.validateOwnerReference, cluster.validateSecretDestinations} } // deleteValidations validates the deletion of the resource @@ -221,12 +217,20 @@ func (cluster *ManagedCluster) updateValidations() []func(old runtime.Object) (a return cluster.validateResourceReferences() }, cluster.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return cluster.validateOwnerReference() + }, func(old runtime.Object) (admission.Warnings, error) { return cluster.validateSecretDestinations() }, } } +// validateOwnerReference validates the owner field +func (cluster *ManagedCluster) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(cluster) +} + // validateResourceReferences validates all resource references func (cluster *ManagedCluster) validateResourceReferences() (admission.Warnings, error) { refs, err := reflecthelpers.FindResourceReferences(&cluster.Spec) @@ -935,7 +939,10 @@ func (cluster *ManagedCluster_Spec) PopulateFromARM(owner genruntime.ArbitraryOw // no assignment for property "OperatorSpec" // Set property "Owner": - cluster.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + cluster.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "PodIdentityProfile": // copying flattened property: diff --git a/v2/api/containerservice/v1api20210501/managed_clusters_agent_pool_types_gen.go b/v2/api/containerservice/v1api20210501/managed_clusters_agent_pool_types_gen.go index 8be80688f9d..80d893073ba 100644 --- a/v2/api/containerservice/v1api20210501/managed_clusters_agent_pool_types_gen.go +++ b/v2/api/containerservice/v1api20210501/managed_clusters_agent_pool_types_gen.go @@ -144,11 +144,7 @@ func (pool *ManagedClustersAgentPool) NewEmptyStatus() genruntime.ConvertibleSta // Owner returns the ResourceReference of the owner func (pool *ManagedClustersAgentPool) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(pool.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: pool.Spec.Owner.Name, - } + return pool.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -206,7 +202,7 @@ func (pool *ManagedClustersAgentPool) ValidateUpdate(old runtime.Object) (admiss // createValidations validates the creation of the resource func (pool *ManagedClustersAgentPool) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){pool.validateResourceReferences} + return []func() (admission.Warnings, error){pool.validateResourceReferences, pool.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -220,7 +216,16 @@ func (pool *ManagedClustersAgentPool) updateValidations() []func(old runtime.Obj func(old runtime.Object) (admission.Warnings, error) { return pool.validateResourceReferences() }, - pool.validateWriteOnceProperties} + pool.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return pool.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (pool *ManagedClustersAgentPool) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(pool) } // validateResourceReferences validates all resource references @@ -884,7 +889,10 @@ func (pool *ManagedClusters_AgentPool_Spec) PopulateFromARM(owner genruntime.Arb } // Set property "Owner": - pool.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + pool.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // no assignment for property "PodSubnetIDReference" diff --git a/v2/api/containerservice/v1api20210501storage/managed_cluster_types_gen.go b/v2/api/containerservice/v1api20210501storage/managed_cluster_types_gen.go index 1ef021c9d05..2b5bac72208 100644 --- a/v2/api/containerservice/v1api20210501storage/managed_cluster_types_gen.go +++ b/v2/api/containerservice/v1api20210501storage/managed_cluster_types_gen.go @@ -105,11 +105,7 @@ func (cluster *ManagedCluster) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (cluster *ManagedCluster) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(cluster.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: cluster.Spec.Owner.Name, - } + return cluster.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/containerservice/v1api20210501storage/managed_clusters_agent_pool_types_gen.go b/v2/api/containerservice/v1api20210501storage/managed_clusters_agent_pool_types_gen.go index 840e409beee..fa7626a7448 100644 --- a/v2/api/containerservice/v1api20210501storage/managed_clusters_agent_pool_types_gen.go +++ b/v2/api/containerservice/v1api20210501storage/managed_clusters_agent_pool_types_gen.go @@ -105,11 +105,7 @@ func (pool *ManagedClustersAgentPool) NewEmptyStatus() genruntime.ConvertibleSta // Owner returns the ResourceReference of the owner func (pool *ManagedClustersAgentPool) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(pool.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: pool.Spec.Owner.Name, - } + return pool.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/containerservice/v1api20230201/managed_cluster_types_gen.go b/v2/api/containerservice/v1api20230201/managed_cluster_types_gen.go index dae98a3853e..ef05c5525d9 100644 --- a/v2/api/containerservice/v1api20230201/managed_cluster_types_gen.go +++ b/v2/api/containerservice/v1api20230201/managed_cluster_types_gen.go @@ -165,11 +165,7 @@ func (cluster *ManagedCluster) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (cluster *ManagedCluster) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(cluster.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: cluster.Spec.Owner.Name, - } + return cluster.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -227,7 +223,7 @@ func (cluster *ManagedCluster) ValidateUpdate(old runtime.Object) (admission.War // createValidations validates the creation of the resource func (cluster *ManagedCluster) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){cluster.validateResourceReferences, cluster.validateSecretDestinations, cluster.validateConfigMapDestinations} + return []func() (admission.Warnings, error){cluster.validateResourceReferences, cluster.validateOwnerReference, cluster.validateSecretDestinations, cluster.validateConfigMapDestinations} } // deleteValidations validates the deletion of the resource @@ -242,6 +238,9 @@ func (cluster *ManagedCluster) updateValidations() []func(old runtime.Object) (a return cluster.validateResourceReferences() }, cluster.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return cluster.validateOwnerReference() + }, func(old runtime.Object) (admission.Warnings, error) { return cluster.validateSecretDestinations() }, @@ -265,6 +264,11 @@ func (cluster *ManagedCluster) validateConfigMapDestinations() (admission.Warnin return genruntime.ValidateConfigMapDestinations(toValidate) } +// validateOwnerReference validates the owner field +func (cluster *ManagedCluster) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(cluster) +} + // validateResourceReferences validates all resource references func (cluster *ManagedCluster) validateResourceReferences() (admission.Warnings, error) { refs, err := reflecthelpers.FindResourceReferences(&cluster.Spec) @@ -1073,7 +1077,10 @@ func (cluster *ManagedCluster_Spec) PopulateFromARM(owner genruntime.ArbitraryOw // no assignment for property "OperatorSpec" // Set property "Owner": - cluster.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + cluster.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "PodIdentityProfile": // copying flattened property: diff --git a/v2/api/containerservice/v1api20230201/managed_clusters_agent_pool_types_gen.go b/v2/api/containerservice/v1api20230201/managed_clusters_agent_pool_types_gen.go index 655866905e3..31abc52484e 100644 --- a/v2/api/containerservice/v1api20230201/managed_clusters_agent_pool_types_gen.go +++ b/v2/api/containerservice/v1api20230201/managed_clusters_agent_pool_types_gen.go @@ -141,11 +141,7 @@ func (pool *ManagedClustersAgentPool) NewEmptyStatus() genruntime.ConvertibleSta // Owner returns the ResourceReference of the owner func (pool *ManagedClustersAgentPool) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(pool.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: pool.Spec.Owner.Name, - } + return pool.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -203,7 +199,7 @@ func (pool *ManagedClustersAgentPool) ValidateUpdate(old runtime.Object) (admiss // createValidations validates the creation of the resource func (pool *ManagedClustersAgentPool) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){pool.validateResourceReferences} + return []func() (admission.Warnings, error){pool.validateResourceReferences, pool.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -217,7 +213,16 @@ func (pool *ManagedClustersAgentPool) updateValidations() []func(old runtime.Obj func(old runtime.Object) (admission.Warnings, error) { return pool.validateResourceReferences() }, - pool.validateWriteOnceProperties} + pool.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return pool.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (pool *ManagedClustersAgentPool) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(pool) } // validateResourceReferences validates all resource references @@ -962,7 +967,10 @@ func (pool *ManagedClusters_AgentPool_Spec) PopulateFromARM(owner genruntime.Arb } // Set property "Owner": - pool.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + pool.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // no assignment for property "PodSubnetReference" diff --git a/v2/api/containerservice/v1api20230201storage/managed_cluster_types_gen.go b/v2/api/containerservice/v1api20230201storage/managed_cluster_types_gen.go index 4ef3cfeea2e..38f6f0ba2cb 100644 --- a/v2/api/containerservice/v1api20230201storage/managed_cluster_types_gen.go +++ b/v2/api/containerservice/v1api20230201storage/managed_cluster_types_gen.go @@ -108,11 +108,7 @@ func (cluster *ManagedCluster) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (cluster *ManagedCluster) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(cluster.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: cluster.Spec.Owner.Name, - } + return cluster.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/containerservice/v1api20230201storage/managed_clusters_agent_pool_types_gen.go b/v2/api/containerservice/v1api20230201storage/managed_clusters_agent_pool_types_gen.go index 63380165096..ba6ab8ee46e 100644 --- a/v2/api/containerservice/v1api20230201storage/managed_clusters_agent_pool_types_gen.go +++ b/v2/api/containerservice/v1api20230201storage/managed_clusters_agent_pool_types_gen.go @@ -84,11 +84,7 @@ func (pool *ManagedClustersAgentPool) NewEmptyStatus() genruntime.ConvertibleSta // Owner returns the ResourceReference of the owner func (pool *ManagedClustersAgentPool) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(pool.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: pool.Spec.Owner.Name, - } + return pool.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/containerservice/v1api20230202preview/managed_cluster_types_gen.go b/v2/api/containerservice/v1api20230202preview/managed_cluster_types_gen.go index e7229c01e1f..3c61d5aaa4b 100644 --- a/v2/api/containerservice/v1api20230202preview/managed_cluster_types_gen.go +++ b/v2/api/containerservice/v1api20230202preview/managed_cluster_types_gen.go @@ -168,11 +168,7 @@ func (cluster *ManagedCluster) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (cluster *ManagedCluster) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(cluster.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: cluster.Spec.Owner.Name, - } + return cluster.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -230,7 +226,7 @@ func (cluster *ManagedCluster) ValidateUpdate(old runtime.Object) (admission.War // createValidations validates the creation of the resource func (cluster *ManagedCluster) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){cluster.validateResourceReferences, cluster.validateSecretDestinations, cluster.validateConfigMapDestinations} + return []func() (admission.Warnings, error){cluster.validateResourceReferences, cluster.validateOwnerReference, cluster.validateSecretDestinations, cluster.validateConfigMapDestinations} } // deleteValidations validates the deletion of the resource @@ -245,6 +241,9 @@ func (cluster *ManagedCluster) updateValidations() []func(old runtime.Object) (a return cluster.validateResourceReferences() }, cluster.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return cluster.validateOwnerReference() + }, func(old runtime.Object) (admission.Warnings, error) { return cluster.validateSecretDestinations() }, @@ -268,6 +267,11 @@ func (cluster *ManagedCluster) validateConfigMapDestinations() (admission.Warnin return genruntime.ValidateConfigMapDestinations(toValidate) } +// validateOwnerReference validates the owner field +func (cluster *ManagedCluster) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(cluster) +} + // validateResourceReferences validates all resource references func (cluster *ManagedCluster) validateResourceReferences() (admission.Warnings, error) { refs, err := reflecthelpers.FindResourceReferences(&cluster.Spec) @@ -1221,7 +1225,10 @@ func (cluster *ManagedCluster_Spec) PopulateFromARM(owner genruntime.ArbitraryOw // no assignment for property "OperatorSpec" // Set property "Owner": - cluster.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + cluster.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "PodIdentityProfile": // copying flattened property: diff --git a/v2/api/containerservice/v1api20230202preview/managed_clusters_agent_pool_types_gen.go b/v2/api/containerservice/v1api20230202preview/managed_clusters_agent_pool_types_gen.go index 4a9d56b896a..7775e54c983 100644 --- a/v2/api/containerservice/v1api20230202preview/managed_clusters_agent_pool_types_gen.go +++ b/v2/api/containerservice/v1api20230202preview/managed_clusters_agent_pool_types_gen.go @@ -144,11 +144,7 @@ func (pool *ManagedClustersAgentPool) NewEmptyStatus() genruntime.ConvertibleSta // Owner returns the ResourceReference of the owner func (pool *ManagedClustersAgentPool) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(pool.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: pool.Spec.Owner.Name, - } + return pool.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -206,7 +202,7 @@ func (pool *ManagedClustersAgentPool) ValidateUpdate(old runtime.Object) (admiss // createValidations validates the creation of the resource func (pool *ManagedClustersAgentPool) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){pool.validateResourceReferences} + return []func() (admission.Warnings, error){pool.validateResourceReferences, pool.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -220,7 +216,16 @@ func (pool *ManagedClustersAgentPool) updateValidations() []func(old runtime.Obj func(old runtime.Object) (admission.Warnings, error) { return pool.validateResourceReferences() }, - pool.validateWriteOnceProperties} + pool.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return pool.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (pool *ManagedClustersAgentPool) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(pool) } // validateResourceReferences validates all resource references @@ -1058,7 +1063,10 @@ func (pool *ManagedClusters_AgentPool_Spec) PopulateFromARM(owner genruntime.Arb } // Set property "Owner": - pool.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + pool.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // no assignment for property "PodSubnetReference" diff --git a/v2/api/containerservice/v1api20230202preview/trusted_access_role_binding_types_gen.go b/v2/api/containerservice/v1api20230202preview/trusted_access_role_binding_types_gen.go index 4295380b783..f4d981233b3 100644 --- a/v2/api/containerservice/v1api20230202preview/trusted_access_role_binding_types_gen.go +++ b/v2/api/containerservice/v1api20230202preview/trusted_access_role_binding_types_gen.go @@ -141,11 +141,7 @@ func (binding *TrustedAccessRoleBinding) NewEmptyStatus() genruntime.Convertible // Owner returns the ResourceReference of the owner func (binding *TrustedAccessRoleBinding) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(binding.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: binding.Spec.Owner.Name, - } + return binding.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -203,7 +199,7 @@ func (binding *TrustedAccessRoleBinding) ValidateUpdate(old runtime.Object) (adm // createValidations validates the creation of the resource func (binding *TrustedAccessRoleBinding) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){binding.validateResourceReferences} + return []func() (admission.Warnings, error){binding.validateResourceReferences, binding.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -217,7 +213,16 @@ func (binding *TrustedAccessRoleBinding) updateValidations() []func(old runtime. func(old runtime.Object) (admission.Warnings, error) { return binding.validateResourceReferences() }, - binding.validateWriteOnceProperties} + binding.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return binding.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (binding *TrustedAccessRoleBinding) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(binding) } // validateResourceReferences validates all resource references @@ -380,7 +385,10 @@ func (binding *ManagedClusters_TrustedAccessRoleBinding_Spec) PopulateFromARM(ow binding.SetAzureName(genruntime.ExtractKubernetesResourceNameFromARMName(typedInput.Name)) // Set property "Owner": - binding.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + binding.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "Roles": // copying flattened property: diff --git a/v2/api/containerservice/v1api20230202previewstorage/managed_cluster_types_gen.go b/v2/api/containerservice/v1api20230202previewstorage/managed_cluster_types_gen.go index 6eb0b4be102..9f910e1d9a8 100644 --- a/v2/api/containerservice/v1api20230202previewstorage/managed_cluster_types_gen.go +++ b/v2/api/containerservice/v1api20230202previewstorage/managed_cluster_types_gen.go @@ -129,11 +129,7 @@ func (cluster *ManagedCluster) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (cluster *ManagedCluster) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(cluster.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: cluster.Spec.Owner.Name, - } + return cluster.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/containerservice/v1api20230202previewstorage/managed_clusters_agent_pool_types_gen.go b/v2/api/containerservice/v1api20230202previewstorage/managed_clusters_agent_pool_types_gen.go index d67e801e0dc..fa730c48bef 100644 --- a/v2/api/containerservice/v1api20230202previewstorage/managed_clusters_agent_pool_types_gen.go +++ b/v2/api/containerservice/v1api20230202previewstorage/managed_clusters_agent_pool_types_gen.go @@ -105,11 +105,7 @@ func (pool *ManagedClustersAgentPool) NewEmptyStatus() genruntime.ConvertibleSta // Owner returns the ResourceReference of the owner func (pool *ManagedClustersAgentPool) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(pool.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: pool.Spec.Owner.Name, - } + return pool.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/containerservice/v1api20230202previewstorage/trusted_access_role_binding_types_gen.go b/v2/api/containerservice/v1api20230202previewstorage/trusted_access_role_binding_types_gen.go index e8e5be4b951..b8c16fe6555 100644 --- a/v2/api/containerservice/v1api20230202previewstorage/trusted_access_role_binding_types_gen.go +++ b/v2/api/containerservice/v1api20230202previewstorage/trusted_access_role_binding_types_gen.go @@ -84,11 +84,7 @@ func (binding *TrustedAccessRoleBinding) NewEmptyStatus() genruntime.Convertible // Owner returns the ResourceReference of the owner func (binding *TrustedAccessRoleBinding) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(binding.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: binding.Spec.Owner.Name, - } + return binding.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/containerservice/v1beta20210501/managed_cluster_types_gen.go b/v2/api/containerservice/v1beta20210501/managed_cluster_types_gen.go index 7bf51ede7f7..54be4bfa5c7 100644 --- a/v2/api/containerservice/v1beta20210501/managed_cluster_types_gen.go +++ b/v2/api/containerservice/v1beta20210501/managed_cluster_types_gen.go @@ -142,11 +142,7 @@ func (cluster *ManagedCluster) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (cluster *ManagedCluster) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(cluster.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: cluster.Spec.Owner.Name, - } + return cluster.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -204,7 +200,7 @@ func (cluster *ManagedCluster) ValidateUpdate(old runtime.Object) (admission.War // createValidations validates the creation of the resource func (cluster *ManagedCluster) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){cluster.validateResourceReferences, cluster.validateSecretDestinations} + return []func() (admission.Warnings, error){cluster.validateResourceReferences, cluster.validateOwnerReference, cluster.validateSecretDestinations} } // deleteValidations validates the deletion of the resource @@ -219,12 +215,20 @@ func (cluster *ManagedCluster) updateValidations() []func(old runtime.Object) (a return cluster.validateResourceReferences() }, cluster.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return cluster.validateOwnerReference() + }, func(old runtime.Object) (admission.Warnings, error) { return cluster.validateSecretDestinations() }, } } +// validateOwnerReference validates the owner field +func (cluster *ManagedCluster) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(cluster) +} + // validateResourceReferences validates all resource references func (cluster *ManagedCluster) validateResourceReferences() (admission.Warnings, error) { refs, err := reflecthelpers.FindResourceReferences(&cluster.Spec) @@ -871,7 +875,10 @@ func (cluster *ManagedCluster_Spec) PopulateFromARM(owner genruntime.ArbitraryOw // no assignment for property "OperatorSpec" // Set property "Owner": - cluster.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + cluster.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "PodIdentityProfile": // copying flattened property: diff --git a/v2/api/containerservice/v1beta20210501/managed_clusters_agent_pool_types_gen.go b/v2/api/containerservice/v1beta20210501/managed_clusters_agent_pool_types_gen.go index 1ec1d48ba32..191ead8496c 100644 --- a/v2/api/containerservice/v1beta20210501/managed_clusters_agent_pool_types_gen.go +++ b/v2/api/containerservice/v1beta20210501/managed_clusters_agent_pool_types_gen.go @@ -142,11 +142,7 @@ func (pool *ManagedClustersAgentPool) NewEmptyStatus() genruntime.ConvertibleSta // Owner returns the ResourceReference of the owner func (pool *ManagedClustersAgentPool) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(pool.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: pool.Spec.Owner.Name, - } + return pool.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -204,7 +200,7 @@ func (pool *ManagedClustersAgentPool) ValidateUpdate(old runtime.Object) (admiss // createValidations validates the creation of the resource func (pool *ManagedClustersAgentPool) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){pool.validateResourceReferences} + return []func() (admission.Warnings, error){pool.validateResourceReferences, pool.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -218,7 +214,16 @@ func (pool *ManagedClustersAgentPool) updateValidations() []func(old runtime.Obj func(old runtime.Object) (admission.Warnings, error) { return pool.validateResourceReferences() }, - pool.validateWriteOnceProperties} + pool.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return pool.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (pool *ManagedClustersAgentPool) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(pool) } // validateResourceReferences validates all resource references @@ -790,7 +795,10 @@ func (pool *ManagedClusters_AgentPool_Spec) PopulateFromARM(owner genruntime.Arb } // Set property "Owner": - pool.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + pool.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // no assignment for property "PodSubnetIDReference" diff --git a/v2/api/containerservice/v1beta20210501storage/managed_cluster_types_gen.go b/v2/api/containerservice/v1beta20210501storage/managed_cluster_types_gen.go index e5104f98cdf..2b59a38053b 100644 --- a/v2/api/containerservice/v1beta20210501storage/managed_cluster_types_gen.go +++ b/v2/api/containerservice/v1beta20210501storage/managed_cluster_types_gen.go @@ -116,11 +116,7 @@ func (cluster *ManagedCluster) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (cluster *ManagedCluster) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(cluster.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: cluster.Spec.Owner.Name, - } + return cluster.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/containerservice/v1beta20210501storage/managed_clusters_agent_pool_types_gen.go b/v2/api/containerservice/v1beta20210501storage/managed_clusters_agent_pool_types_gen.go index 166ce189981..8148ce3fe81 100644 --- a/v2/api/containerservice/v1beta20210501storage/managed_clusters_agent_pool_types_gen.go +++ b/v2/api/containerservice/v1beta20210501storage/managed_clusters_agent_pool_types_gen.go @@ -116,11 +116,7 @@ func (pool *ManagedClustersAgentPool) NewEmptyStatus() genruntime.ConvertibleSta // Owner returns the ResourceReference of the owner func (pool *ManagedClustersAgentPool) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(pool.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: pool.Spec.Owner.Name, - } + return pool.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/datafactory/v1api20180601/factory_types_gen.go b/v2/api/datafactory/v1api20180601/factory_types_gen.go index 3e4bb03359e..9a719d4a61e 100644 --- a/v2/api/datafactory/v1api20180601/factory_types_gen.go +++ b/v2/api/datafactory/v1api20180601/factory_types_gen.go @@ -142,11 +142,7 @@ func (factory *Factory) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (factory *Factory) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(factory.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: factory.Spec.Owner.Name, - } + return factory.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -204,7 +200,7 @@ func (factory *Factory) ValidateUpdate(old runtime.Object) (admission.Warnings, // createValidations validates the creation of the resource func (factory *Factory) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){factory.validateResourceReferences} + return []func() (admission.Warnings, error){factory.validateResourceReferences, factory.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -218,7 +214,16 @@ func (factory *Factory) updateValidations() []func(old runtime.Object) (admissio func(old runtime.Object) (admission.Warnings, error) { return factory.validateResourceReferences() }, - factory.validateWriteOnceProperties} + factory.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return factory.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (factory *Factory) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(factory) } // validateResourceReferences validates all resource references @@ -521,7 +526,10 @@ func (factory *Factory_Spec) PopulateFromARM(owner genruntime.ArbitraryOwnerRefe } // Set property "Owner": - factory.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + factory.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "PublicNetworkAccess": // copying flattened property: diff --git a/v2/api/datafactory/v1api20180601storage/factory_types_gen.go b/v2/api/datafactory/v1api20180601storage/factory_types_gen.go index fef7ed4d42b..66bb130f6fc 100644 --- a/v2/api/datafactory/v1api20180601storage/factory_types_gen.go +++ b/v2/api/datafactory/v1api20180601storage/factory_types_gen.go @@ -85,11 +85,7 @@ func (factory *Factory) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (factory *Factory) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(factory.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: factory.Spec.Owner.Name, - } + return factory.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/dataprotection/v1api20230101/backup_vault_types_gen.go b/v2/api/dataprotection/v1api20230101/backup_vault_types_gen.go index 3cdc0fb775a..481cdaaaa8a 100644 --- a/v2/api/dataprotection/v1api20230101/backup_vault_types_gen.go +++ b/v2/api/dataprotection/v1api20230101/backup_vault_types_gen.go @@ -141,11 +141,7 @@ func (vault *BackupVault) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (vault *BackupVault) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(vault.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: vault.Spec.Owner.Name, - } + return vault.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -203,7 +199,7 @@ func (vault *BackupVault) ValidateUpdate(old runtime.Object) (admission.Warnings // createValidations validates the creation of the resource func (vault *BackupVault) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){vault.validateResourceReferences} + return []func() (admission.Warnings, error){vault.validateResourceReferences, vault.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -217,7 +213,16 @@ func (vault *BackupVault) updateValidations() []func(old runtime.Object) (admiss func(old runtime.Object) (admission.Warnings, error) { return vault.validateResourceReferences() }, - vault.validateWriteOnceProperties} + vault.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return vault.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (vault *BackupVault) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(vault) } // validateResourceReferences validates all resource references @@ -421,7 +426,10 @@ func (vault *BackupVault_Spec) PopulateFromARM(owner genruntime.ArbitraryOwnerRe } // Set property "Owner": - vault.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + vault.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "Properties": if typedInput.Properties != nil { diff --git a/v2/api/dataprotection/v1api20230101/backup_vaults_backup_policy_types_gen.go b/v2/api/dataprotection/v1api20230101/backup_vaults_backup_policy_types_gen.go index 012328dce3a..2d5316230eb 100644 --- a/v2/api/dataprotection/v1api20230101/backup_vaults_backup_policy_types_gen.go +++ b/v2/api/dataprotection/v1api20230101/backup_vaults_backup_policy_types_gen.go @@ -141,11 +141,7 @@ func (policy *BackupVaultsBackupPolicy) NewEmptyStatus() genruntime.ConvertibleS // Owner returns the ResourceReference of the owner func (policy *BackupVaultsBackupPolicy) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(policy.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: policy.Spec.Owner.Name, - } + return policy.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -203,7 +199,7 @@ func (policy *BackupVaultsBackupPolicy) ValidateUpdate(old runtime.Object) (admi // createValidations validates the creation of the resource func (policy *BackupVaultsBackupPolicy) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){policy.validateResourceReferences} + return []func() (admission.Warnings, error){policy.validateResourceReferences, policy.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -217,7 +213,16 @@ func (policy *BackupVaultsBackupPolicy) updateValidations() []func(old runtime.O func(old runtime.Object) (admission.Warnings, error) { return policy.validateResourceReferences() }, - policy.validateWriteOnceProperties} + policy.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return policy.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (policy *BackupVaultsBackupPolicy) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(policy) } // validateResourceReferences validates all resource references @@ -365,7 +370,10 @@ func (policy *BackupVaults_BackupPolicy_Spec) PopulateFromARM(owner genruntime.A policy.SetAzureName(genruntime.ExtractKubernetesResourceNameFromARMName(typedInput.Name)) // Set property "Owner": - policy.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + policy.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "Properties": if typedInput.Properties != nil { diff --git a/v2/api/dataprotection/v1api20230101storage/backup_vault_types_gen.go b/v2/api/dataprotection/v1api20230101storage/backup_vault_types_gen.go index cfcea5670c9..80b523a0440 100644 --- a/v2/api/dataprotection/v1api20230101storage/backup_vault_types_gen.go +++ b/v2/api/dataprotection/v1api20230101storage/backup_vault_types_gen.go @@ -84,11 +84,7 @@ func (vault *BackupVault) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (vault *BackupVault) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(vault.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: vault.Spec.Owner.Name, - } + return vault.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/dataprotection/v1api20230101storage/backup_vaults_backup_policy_types_gen.go b/v2/api/dataprotection/v1api20230101storage/backup_vaults_backup_policy_types_gen.go index 51002f60a6e..d588fb62379 100644 --- a/v2/api/dataprotection/v1api20230101storage/backup_vaults_backup_policy_types_gen.go +++ b/v2/api/dataprotection/v1api20230101storage/backup_vaults_backup_policy_types_gen.go @@ -84,11 +84,7 @@ func (policy *BackupVaultsBackupPolicy) NewEmptyStatus() genruntime.ConvertibleS // Owner returns the ResourceReference of the owner func (policy *BackupVaultsBackupPolicy) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(policy.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: policy.Spec.Owner.Name, - } + return policy.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/dbformariadb/v1api20180601/configuration_types_gen.go b/v2/api/dbformariadb/v1api20180601/configuration_types_gen.go index b01caff955a..55ccec6465a 100644 --- a/v2/api/dbformariadb/v1api20180601/configuration_types_gen.go +++ b/v2/api/dbformariadb/v1api20180601/configuration_types_gen.go @@ -141,11 +141,7 @@ func (configuration *Configuration) NewEmptyStatus() genruntime.ConvertibleStatu // Owner returns the ResourceReference of the owner func (configuration *Configuration) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(configuration.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: configuration.Spec.Owner.Name, - } + return configuration.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -203,7 +199,7 @@ func (configuration *Configuration) ValidateUpdate(old runtime.Object) (admissio // createValidations validates the creation of the resource func (configuration *Configuration) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){configuration.validateResourceReferences} + return []func() (admission.Warnings, error){configuration.validateResourceReferences, configuration.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -217,7 +213,16 @@ func (configuration *Configuration) updateValidations() []func(old runtime.Objec func(old runtime.Object) (admission.Warnings, error) { return configuration.validateResourceReferences() }, - configuration.validateWriteOnceProperties} + configuration.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return configuration.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (configuration *Configuration) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(configuration) } // validateResourceReferences validates all resource references @@ -376,7 +381,10 @@ func (configuration *Servers_Configuration_Spec) PopulateFromARM(owner genruntim configuration.SetAzureName(genruntime.ExtractKubernetesResourceNameFromARMName(typedInput.Name)) // Set property "Owner": - configuration.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + configuration.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "Source": // copying flattened property: diff --git a/v2/api/dbformariadb/v1api20180601/database_types_gen.go b/v2/api/dbformariadb/v1api20180601/database_types_gen.go index 4e154f769c2..4baffdb5f5d 100644 --- a/v2/api/dbformariadb/v1api20180601/database_types_gen.go +++ b/v2/api/dbformariadb/v1api20180601/database_types_gen.go @@ -141,11 +141,7 @@ func (database *Database) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (database *Database) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(database.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: database.Spec.Owner.Name, - } + return database.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -203,7 +199,7 @@ func (database *Database) ValidateUpdate(old runtime.Object) (admission.Warnings // createValidations validates the creation of the resource func (database *Database) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){database.validateResourceReferences} + return []func() (admission.Warnings, error){database.validateResourceReferences, database.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -217,7 +213,16 @@ func (database *Database) updateValidations() []func(old runtime.Object) (admiss func(old runtime.Object) (admission.Warnings, error) { return database.validateResourceReferences() }, - database.validateWriteOnceProperties} + database.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return database.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (database *Database) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(database) } // validateResourceReferences validates all resource references @@ -389,7 +394,10 @@ func (database *Servers_Database_Spec) PopulateFromARM(owner genruntime.Arbitrar } // Set property "Owner": - database.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + database.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // No error return nil diff --git a/v2/api/dbformariadb/v1api20180601/server_types_gen.go b/v2/api/dbformariadb/v1api20180601/server_types_gen.go index bf0ae2464b1..aacab063bc8 100644 --- a/v2/api/dbformariadb/v1api20180601/server_types_gen.go +++ b/v2/api/dbformariadb/v1api20180601/server_types_gen.go @@ -141,11 +141,7 @@ func (server *Server) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (server *Server) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(server.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: server.Spec.Owner.Name, - } + return server.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -203,7 +199,7 @@ func (server *Server) ValidateUpdate(old runtime.Object) (admission.Warnings, er // createValidations validates the creation of the resource func (server *Server) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){server.validateResourceReferences, server.validateSecretDestinations} + return []func() (admission.Warnings, error){server.validateResourceReferences, server.validateOwnerReference, server.validateSecretDestinations} } // deleteValidations validates the deletion of the resource @@ -218,12 +214,20 @@ func (server *Server) updateValidations() []func(old runtime.Object) (admission. return server.validateResourceReferences() }, server.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return server.validateOwnerReference() + }, func(old runtime.Object) (admission.Warnings, error) { return server.validateSecretDestinations() }, } } +// validateOwnerReference validates the owner field +func (server *Server) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(server) +} + // validateResourceReferences validates all resource references func (server *Server) validateResourceReferences() (admission.Warnings, error) { refs, err := reflecthelpers.FindResourceReferences(&server.Spec) @@ -430,7 +434,10 @@ func (server *Server_Spec) PopulateFromARM(owner genruntime.ArbitraryOwnerRefere // no assignment for property "OperatorSpec" // Set property "Owner": - server.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + server.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "Properties": if typedInput.Properties != nil { diff --git a/v2/api/dbformariadb/v1api20180601storage/configuration_types_gen.go b/v2/api/dbformariadb/v1api20180601storage/configuration_types_gen.go index 104a96ad9f4..9df33d383ed 100644 --- a/v2/api/dbformariadb/v1api20180601storage/configuration_types_gen.go +++ b/v2/api/dbformariadb/v1api20180601storage/configuration_types_gen.go @@ -84,11 +84,7 @@ func (configuration *Configuration) NewEmptyStatus() genruntime.ConvertibleStatu // Owner returns the ResourceReference of the owner func (configuration *Configuration) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(configuration.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: configuration.Spec.Owner.Name, - } + return configuration.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/dbformariadb/v1api20180601storage/database_types_gen.go b/v2/api/dbformariadb/v1api20180601storage/database_types_gen.go index 25c3fe5e334..f715acae90f 100644 --- a/v2/api/dbformariadb/v1api20180601storage/database_types_gen.go +++ b/v2/api/dbformariadb/v1api20180601storage/database_types_gen.go @@ -84,11 +84,7 @@ func (database *Database) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (database *Database) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(database.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: database.Spec.Owner.Name, - } + return database.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/dbformariadb/v1api20180601storage/server_types_gen.go b/v2/api/dbformariadb/v1api20180601storage/server_types_gen.go index fdbe0208655..e8ec8cf9ccf 100644 --- a/v2/api/dbformariadb/v1api20180601storage/server_types_gen.go +++ b/v2/api/dbformariadb/v1api20180601storage/server_types_gen.go @@ -84,11 +84,7 @@ func (server *Server) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (server *Server) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(server.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: server.Spec.Owner.Name, - } + return server.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/dbformariadb/v1beta20180601/configuration_types_gen.go b/v2/api/dbformariadb/v1beta20180601/configuration_types_gen.go index 987aabcf049..7193ca5fe4a 100644 --- a/v2/api/dbformariadb/v1beta20180601/configuration_types_gen.go +++ b/v2/api/dbformariadb/v1beta20180601/configuration_types_gen.go @@ -142,11 +142,7 @@ func (configuration *Configuration) NewEmptyStatus() genruntime.ConvertibleStatu // Owner returns the ResourceReference of the owner func (configuration *Configuration) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(configuration.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: configuration.Spec.Owner.Name, - } + return configuration.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -204,7 +200,7 @@ func (configuration *Configuration) ValidateUpdate(old runtime.Object) (admissio // createValidations validates the creation of the resource func (configuration *Configuration) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){configuration.validateResourceReferences} + return []func() (admission.Warnings, error){configuration.validateResourceReferences, configuration.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -218,7 +214,16 @@ func (configuration *Configuration) updateValidations() []func(old runtime.Objec func(old runtime.Object) (admission.Warnings, error) { return configuration.validateResourceReferences() }, - configuration.validateWriteOnceProperties} + configuration.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return configuration.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (configuration *Configuration) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(configuration) } // validateResourceReferences validates all resource references @@ -372,7 +377,10 @@ func (configuration *Servers_Configuration_Spec) PopulateFromARM(owner genruntim configuration.SetAzureName(genruntime.ExtractKubernetesResourceNameFromARMName(typedInput.Name)) // Set property "Owner": - configuration.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + configuration.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "Source": // copying flattened property: diff --git a/v2/api/dbformariadb/v1beta20180601/database_types_gen.go b/v2/api/dbformariadb/v1beta20180601/database_types_gen.go index 63e7c2f66ce..468d609b9a3 100644 --- a/v2/api/dbformariadb/v1beta20180601/database_types_gen.go +++ b/v2/api/dbformariadb/v1beta20180601/database_types_gen.go @@ -142,11 +142,7 @@ func (database *Database) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (database *Database) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(database.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: database.Spec.Owner.Name, - } + return database.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -204,7 +200,7 @@ func (database *Database) ValidateUpdate(old runtime.Object) (admission.Warnings // createValidations validates the creation of the resource func (database *Database) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){database.validateResourceReferences} + return []func() (admission.Warnings, error){database.validateResourceReferences, database.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -218,7 +214,16 @@ func (database *Database) updateValidations() []func(old runtime.Object) (admiss func(old runtime.Object) (admission.Warnings, error) { return database.validateResourceReferences() }, - database.validateWriteOnceProperties} + database.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return database.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (database *Database) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(database) } // validateResourceReferences validates all resource references @@ -384,7 +389,10 @@ func (database *Servers_Database_Spec) PopulateFromARM(owner genruntime.Arbitrar } // Set property "Owner": - database.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + database.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // No error return nil diff --git a/v2/api/dbformariadb/v1beta20180601/server_types_gen.go b/v2/api/dbformariadb/v1beta20180601/server_types_gen.go index 09d03d6bb46..8048d430577 100644 --- a/v2/api/dbformariadb/v1beta20180601/server_types_gen.go +++ b/v2/api/dbformariadb/v1beta20180601/server_types_gen.go @@ -142,11 +142,7 @@ func (server *Server) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (server *Server) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(server.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: server.Spec.Owner.Name, - } + return server.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -204,7 +200,7 @@ func (server *Server) ValidateUpdate(old runtime.Object) (admission.Warnings, er // createValidations validates the creation of the resource func (server *Server) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){server.validateResourceReferences, server.validateSecretDestinations} + return []func() (admission.Warnings, error){server.validateResourceReferences, server.validateOwnerReference, server.validateSecretDestinations} } // deleteValidations validates the deletion of the resource @@ -219,12 +215,20 @@ func (server *Server) updateValidations() []func(old runtime.Object) (admission. return server.validateResourceReferences() }, server.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return server.validateOwnerReference() + }, func(old runtime.Object) (admission.Warnings, error) { return server.validateSecretDestinations() }, } } +// validateOwnerReference validates the owner field +func (server *Server) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(server) +} + // validateResourceReferences validates all resource references func (server *Server) validateResourceReferences() (admission.Warnings, error) { refs, err := reflecthelpers.FindResourceReferences(&server.Spec) @@ -423,7 +427,10 @@ func (server *Server_Spec) PopulateFromARM(owner genruntime.ArbitraryOwnerRefere // no assignment for property "OperatorSpec" // Set property "Owner": - server.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + server.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "Properties": if typedInput.Properties != nil { diff --git a/v2/api/dbformariadb/v1beta20180601storage/configuration_types_gen.go b/v2/api/dbformariadb/v1beta20180601storage/configuration_types_gen.go index ed187e079af..0037fb152b4 100644 --- a/v2/api/dbformariadb/v1beta20180601storage/configuration_types_gen.go +++ b/v2/api/dbformariadb/v1beta20180601storage/configuration_types_gen.go @@ -103,11 +103,7 @@ func (configuration *Configuration) NewEmptyStatus() genruntime.ConvertibleStatu // Owner returns the ResourceReference of the owner func (configuration *Configuration) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(configuration.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: configuration.Spec.Owner.Name, - } + return configuration.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/dbformariadb/v1beta20180601storage/database_types_gen.go b/v2/api/dbformariadb/v1beta20180601storage/database_types_gen.go index ede13972a50..4b76f5868cb 100644 --- a/v2/api/dbformariadb/v1beta20180601storage/database_types_gen.go +++ b/v2/api/dbformariadb/v1beta20180601storage/database_types_gen.go @@ -103,11 +103,7 @@ func (database *Database) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (database *Database) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(database.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: database.Spec.Owner.Name, - } + return database.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/dbformariadb/v1beta20180601storage/server_types_gen.go b/v2/api/dbformariadb/v1beta20180601storage/server_types_gen.go index 77faba0b163..43fde012baf 100644 --- a/v2/api/dbformariadb/v1beta20180601storage/server_types_gen.go +++ b/v2/api/dbformariadb/v1beta20180601storage/server_types_gen.go @@ -103,11 +103,7 @@ func (server *Server) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (server *Server) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(server.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: server.Spec.Owner.Name, - } + return server.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/dbformysql/v1/user_types.go b/v2/api/dbformysql/v1/user_types.go index 251e5c5df21..14af72473c0 100644 --- a/v2/api/dbformysql/v1/user_types.go +++ b/v2/api/dbformysql/v1/user_types.go @@ -78,11 +78,7 @@ func (user *User) AzureName() string { // Owner returns the ResourceReference of the owner, or nil if there is no owner func (user *User) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(user.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: user.Spec.Owner.Name, - } + return user.Spec.Owner.AsResourceReference(group, kind) } // +kubebuilder:webhook:path=/validate-dbformysql-azure-com-v1-user,mutating=false,sideEffects=None,matchPolicy=Exact,failurePolicy=fail,groups=dbformysql.azure.com,resources=users,verbs=create;update,versions=v1,name=validate.v1.users.dbformysql.azure.com,admissionReviewVersions=v1 @@ -271,7 +267,7 @@ type UserSpec struct { // Owner: The owner of the resource. The owner controls where the resource goes when it is deployed. The owner also // controls the resources lifecycle. When the owner is deleted the resource will also be deleted. Owner is expected to be a // reference to a dbformysql.azure.com/FlexibleServer resource - Owner *genruntime.KnownResourceReference `group:"dbformysql.azure.com" json:"owner,omitempty" kind:"FlexibleServer"` + Owner *genruntime.KubernetesOwnerReference `group:"dbformysql.azure.com" json:"owner,omitempty" kind:"FlexibleServer"` // Hostname is the host the user will connect from. If omitted, the default is to allow connection from any hostname. Hostname string `json:"hostname,omitempty"` diff --git a/v2/api/dbformysql/v1/zz_generated.deepcopy.go b/v2/api/dbformysql/v1/zz_generated.deepcopy.go index fbc4ec76a6d..5dbef4b74a0 100644 --- a/v2/api/dbformysql/v1/zz_generated.deepcopy.go +++ b/v2/api/dbformysql/v1/zz_generated.deepcopy.go @@ -119,7 +119,7 @@ func (in *UserSpec) DeepCopyInto(out *UserSpec) { *out = *in if in.Owner != nil { in, out := &in.Owner, &out.Owner - *out = new(genruntime.KnownResourceReference) + *out = new(genruntime.KubernetesOwnerReference) **out = **in } if in.Privileges != nil { diff --git a/v2/api/dbformysql/v1api20210501/flexible_server_types_gen.go b/v2/api/dbformysql/v1api20210501/flexible_server_types_gen.go index 0e6a57276f9..5f0518d718a 100644 --- a/v2/api/dbformysql/v1api20210501/flexible_server_types_gen.go +++ b/v2/api/dbformysql/v1api20210501/flexible_server_types_gen.go @@ -142,11 +142,7 @@ func (server *FlexibleServer) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (server *FlexibleServer) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(server.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: server.Spec.Owner.Name, - } + return server.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -204,7 +200,7 @@ func (server *FlexibleServer) ValidateUpdate(old runtime.Object) (admission.Warn // createValidations validates the creation of the resource func (server *FlexibleServer) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){server.validateResourceReferences, server.validateSecretDestinations} + return []func() (admission.Warnings, error){server.validateResourceReferences, server.validateOwnerReference, server.validateSecretDestinations} } // deleteValidations validates the deletion of the resource @@ -219,12 +215,20 @@ func (server *FlexibleServer) updateValidations() []func(old runtime.Object) (ad return server.validateResourceReferences() }, server.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return server.validateOwnerReference() + }, func(old runtime.Object) (admission.Warnings, error) { return server.validateSecretDestinations() }, } } +// validateOwnerReference validates the owner field +func (server *FlexibleServer) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(server) +} + // validateResourceReferences validates all resource references func (server *FlexibleServer) validateResourceReferences() (admission.Warnings, error) { refs, err := reflecthelpers.FindResourceReferences(&server.Spec) @@ -690,7 +694,10 @@ func (server *FlexibleServer_Spec) PopulateFromARM(owner genruntime.ArbitraryOwn // no assignment for property "OperatorSpec" // Set property "Owner": - server.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + server.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "ReplicationRole": // copying flattened property: diff --git a/v2/api/dbformysql/v1api20210501/flexible_servers_database_types_gen.go b/v2/api/dbformysql/v1api20210501/flexible_servers_database_types_gen.go index 1aa824a567f..40f078fac51 100644 --- a/v2/api/dbformysql/v1api20210501/flexible_servers_database_types_gen.go +++ b/v2/api/dbformysql/v1api20210501/flexible_servers_database_types_gen.go @@ -141,11 +141,7 @@ func (database *FlexibleServersDatabase) NewEmptyStatus() genruntime.Convertible // Owner returns the ResourceReference of the owner func (database *FlexibleServersDatabase) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(database.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: database.Spec.Owner.Name, - } + return database.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -203,7 +199,7 @@ func (database *FlexibleServersDatabase) ValidateUpdate(old runtime.Object) (adm // createValidations validates the creation of the resource func (database *FlexibleServersDatabase) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){database.validateResourceReferences} + return []func() (admission.Warnings, error){database.validateResourceReferences, database.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -217,7 +213,16 @@ func (database *FlexibleServersDatabase) updateValidations() []func(old runtime. func(old runtime.Object) (admission.Warnings, error) { return database.validateResourceReferences() }, - database.validateWriteOnceProperties} + database.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return database.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (database *FlexibleServersDatabase) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(database) } // validateResourceReferences validates all resource references @@ -389,7 +394,10 @@ func (database *FlexibleServers_Database_Spec) PopulateFromARM(owner genruntime. } // Set property "Owner": - database.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + database.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // No error return nil diff --git a/v2/api/dbformysql/v1api20210501/flexible_servers_firewall_rule_types_gen.go b/v2/api/dbformysql/v1api20210501/flexible_servers_firewall_rule_types_gen.go index e1b2bf419c1..bcca2025cd6 100644 --- a/v2/api/dbformysql/v1api20210501/flexible_servers_firewall_rule_types_gen.go +++ b/v2/api/dbformysql/v1api20210501/flexible_servers_firewall_rule_types_gen.go @@ -141,11 +141,7 @@ func (rule *FlexibleServersFirewallRule) NewEmptyStatus() genruntime.Convertible // Owner returns the ResourceReference of the owner func (rule *FlexibleServersFirewallRule) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(rule.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: rule.Spec.Owner.Name, - } + return rule.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -203,7 +199,7 @@ func (rule *FlexibleServersFirewallRule) ValidateUpdate(old runtime.Object) (adm // createValidations validates the creation of the resource func (rule *FlexibleServersFirewallRule) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){rule.validateResourceReferences} + return []func() (admission.Warnings, error){rule.validateResourceReferences, rule.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -217,7 +213,16 @@ func (rule *FlexibleServersFirewallRule) updateValidations() []func(old runtime. func(old runtime.Object) (admission.Warnings, error) { return rule.validateResourceReferences() }, - rule.validateWriteOnceProperties} + rule.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return rule.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (rule *FlexibleServersFirewallRule) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(rule) } // validateResourceReferences validates all resource references @@ -384,7 +389,10 @@ func (rule *FlexibleServers_FirewallRule_Spec) PopulateFromARM(owner genruntime. } // Set property "Owner": - rule.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + rule.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "StartIpAddress": // copying flattened property: diff --git a/v2/api/dbformysql/v1api20210501storage/flexible_server_types_gen.go b/v2/api/dbformysql/v1api20210501storage/flexible_server_types_gen.go index 7901c105091..5e64aa346eb 100644 --- a/v2/api/dbformysql/v1api20210501storage/flexible_server_types_gen.go +++ b/v2/api/dbformysql/v1api20210501storage/flexible_server_types_gen.go @@ -86,11 +86,7 @@ func (server *FlexibleServer) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (server *FlexibleServer) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(server.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: server.Spec.Owner.Name, - } + return server.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/dbformysql/v1api20210501storage/flexible_servers_database_types_gen.go b/v2/api/dbformysql/v1api20210501storage/flexible_servers_database_types_gen.go index 710c629f09a..73a2bf68a22 100644 --- a/v2/api/dbformysql/v1api20210501storage/flexible_servers_database_types_gen.go +++ b/v2/api/dbformysql/v1api20210501storage/flexible_servers_database_types_gen.go @@ -84,11 +84,7 @@ func (database *FlexibleServersDatabase) NewEmptyStatus() genruntime.Convertible // Owner returns the ResourceReference of the owner func (database *FlexibleServersDatabase) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(database.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: database.Spec.Owner.Name, - } + return database.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/dbformysql/v1api20210501storage/flexible_servers_firewall_rule_types_gen.go b/v2/api/dbformysql/v1api20210501storage/flexible_servers_firewall_rule_types_gen.go index b8a9d3c9580..a17b8deb168 100644 --- a/v2/api/dbformysql/v1api20210501storage/flexible_servers_firewall_rule_types_gen.go +++ b/v2/api/dbformysql/v1api20210501storage/flexible_servers_firewall_rule_types_gen.go @@ -84,11 +84,7 @@ func (rule *FlexibleServersFirewallRule) NewEmptyStatus() genruntime.Convertible // Owner returns the ResourceReference of the owner func (rule *FlexibleServersFirewallRule) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(rule.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: rule.Spec.Owner.Name, - } + return rule.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/dbformysql/v1api20220101/flexible_servers_administrator_types_gen.go b/v2/api/dbformysql/v1api20220101/flexible_servers_administrator_types_gen.go index 98fa6c9d544..4c09027899f 100644 --- a/v2/api/dbformysql/v1api20220101/flexible_servers_administrator_types_gen.go +++ b/v2/api/dbformysql/v1api20220101/flexible_servers_administrator_types_gen.go @@ -134,11 +134,7 @@ func (administrator *FlexibleServersAdministrator) NewEmptyStatus() genruntime.C // Owner returns the ResourceReference of the owner func (administrator *FlexibleServersAdministrator) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(administrator.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: administrator.Spec.Owner.Name, - } + return administrator.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -196,7 +192,7 @@ func (administrator *FlexibleServersAdministrator) ValidateUpdate(old runtime.Ob // createValidations validates the creation of the resource func (administrator *FlexibleServersAdministrator) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){administrator.validateResourceReferences, administrator.validateOptionalConfigMapReferences} + return []func() (admission.Warnings, error){administrator.validateResourceReferences, administrator.validateOwnerReference, administrator.validateOptionalConfigMapReferences} } // deleteValidations validates the deletion of the resource @@ -211,6 +207,9 @@ func (administrator *FlexibleServersAdministrator) updateValidations() []func(ol return administrator.validateResourceReferences() }, administrator.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return administrator.validateOwnerReference() + }, func(old runtime.Object) (admission.Warnings, error) { return administrator.validateOptionalConfigMapReferences() }, @@ -226,6 +225,11 @@ func (administrator *FlexibleServersAdministrator) validateOptionalConfigMapRefe return genruntime.ValidateOptionalConfigMapReferences(refs) } +// validateOwnerReference validates the owner field +func (administrator *FlexibleServersAdministrator) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(administrator) +} + // validateResourceReferences validates all resource references func (administrator *FlexibleServersAdministrator) validateResourceReferences() (admission.Warnings, error) { refs, err := reflecthelpers.FindResourceReferences(&administrator.Spec) @@ -448,7 +452,10 @@ func (administrator *FlexibleServers_Administrator_Spec) PopulateFromARM(owner g } // Set property "Owner": - administrator.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + administrator.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "Sid": // copying flattened property: diff --git a/v2/api/dbformysql/v1api20220101/flexible_servers_configuration_types_gen.go b/v2/api/dbformysql/v1api20220101/flexible_servers_configuration_types_gen.go index 9153d941118..4dc33d835c8 100644 --- a/v2/api/dbformysql/v1api20220101/flexible_servers_configuration_types_gen.go +++ b/v2/api/dbformysql/v1api20220101/flexible_servers_configuration_types_gen.go @@ -141,11 +141,7 @@ func (configuration *FlexibleServersConfiguration) NewEmptyStatus() genruntime.C // Owner returns the ResourceReference of the owner func (configuration *FlexibleServersConfiguration) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(configuration.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: configuration.Spec.Owner.Name, - } + return configuration.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -203,7 +199,7 @@ func (configuration *FlexibleServersConfiguration) ValidateUpdate(old runtime.Ob // createValidations validates the creation of the resource func (configuration *FlexibleServersConfiguration) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){configuration.validateResourceReferences} + return []func() (admission.Warnings, error){configuration.validateResourceReferences, configuration.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -217,7 +213,16 @@ func (configuration *FlexibleServersConfiguration) updateValidations() []func(ol func(old runtime.Object) (admission.Warnings, error) { return configuration.validateResourceReferences() }, - configuration.validateWriteOnceProperties} + configuration.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return configuration.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (configuration *FlexibleServersConfiguration) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(configuration) } // validateResourceReferences validates all resource references @@ -390,7 +395,10 @@ func (configuration *FlexibleServers_Configuration_Spec) PopulateFromARM(owner g } // Set property "Owner": - configuration.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + configuration.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "Source": // copying flattened property: diff --git a/v2/api/dbformysql/v1api20220101storage/flexible_servers_administrator_types_gen.go b/v2/api/dbformysql/v1api20220101storage/flexible_servers_administrator_types_gen.go index c9759603cbc..b0063354872 100644 --- a/v2/api/dbformysql/v1api20220101storage/flexible_servers_administrator_types_gen.go +++ b/v2/api/dbformysql/v1api20220101storage/flexible_servers_administrator_types_gen.go @@ -84,11 +84,7 @@ func (administrator *FlexibleServersAdministrator) NewEmptyStatus() genruntime.C // Owner returns the ResourceReference of the owner func (administrator *FlexibleServersAdministrator) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(administrator.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: administrator.Spec.Owner.Name, - } + return administrator.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/dbformysql/v1api20220101storage/flexible_servers_configuration_types_gen.go b/v2/api/dbformysql/v1api20220101storage/flexible_servers_configuration_types_gen.go index 07dbfb41c46..805f36b0329 100644 --- a/v2/api/dbformysql/v1api20220101storage/flexible_servers_configuration_types_gen.go +++ b/v2/api/dbformysql/v1api20220101storage/flexible_servers_configuration_types_gen.go @@ -84,11 +84,7 @@ func (configuration *FlexibleServersConfiguration) NewEmptyStatus() genruntime.C // Owner returns the ResourceReference of the owner func (configuration *FlexibleServersConfiguration) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(configuration.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: configuration.Spec.Owner.Name, - } + return configuration.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/dbformysql/v1beta1/user_types.go b/v2/api/dbformysql/v1beta1/user_types.go index 9f70b6e4958..e0e1c563b57 100644 --- a/v2/api/dbformysql/v1beta1/user_types.go +++ b/v2/api/dbformysql/v1beta1/user_types.go @@ -78,11 +78,7 @@ func (user *User) AzureName() string { // Owner returns the ResourceReference of the owner, or nil if there is no owner func (user *User) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(user.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: user.Spec.Owner.Name, - } + return user.Spec.Owner.AsResourceReference(group, kind) } // +kubebuilder:webhook:path=/validate-dbformysql-azure-com-v1beta1-user,mutating=false,sideEffects=None,matchPolicy=Exact,failurePolicy=fail,groups=dbformysql.azure.com,resources=users,verbs=create;update,versions=v1beta1,name=validate.v1beta1.users.dbformysql.azure.com,admissionReviewVersions=v1beta1 @@ -221,7 +217,7 @@ type UserSpec struct { //Owner: The owner of the resource. The owner controls where the resource goes when it is deployed. The owner also //controls the resources lifecycle. When the owner is deleted the resource will also be deleted. Owner is expected to be a //reference to a dbformysql.azure.com/FlexibleServer resource - Owner *genruntime.KnownResourceReference `group:"dbformysql.azure.com" json:"owner,omitempty" kind:"FlexibleServer"` + Owner *genruntime.KubernetesOwnerReference `group:"dbformysql.azure.com" json:"owner,omitempty" kind:"FlexibleServer"` // Hostname is the host the user will connect from. If omitted, the default is to allow connection from any hostname. Hostname string `json:"hostname,omitempty"` diff --git a/v2/api/dbformysql/v1beta1/zz_generated.deepcopy.go b/v2/api/dbformysql/v1beta1/zz_generated.deepcopy.go index 627f8481151..a4999b54c31 100644 --- a/v2/api/dbformysql/v1beta1/zz_generated.deepcopy.go +++ b/v2/api/dbformysql/v1beta1/zz_generated.deepcopy.go @@ -104,7 +104,7 @@ func (in *UserSpec) DeepCopyInto(out *UserSpec) { *out = *in if in.Owner != nil { in, out := &in.Owner, &out.Owner - *out = new(genruntime.KnownResourceReference) + *out = new(genruntime.KubernetesOwnerReference) **out = **in } if in.Privileges != nil { diff --git a/v2/api/dbformysql/v1beta20210501/flexible_server_types_gen.go b/v2/api/dbformysql/v1beta20210501/flexible_server_types_gen.go index 47a8b3a9e7e..e1c099b3921 100644 --- a/v2/api/dbformysql/v1beta20210501/flexible_server_types_gen.go +++ b/v2/api/dbformysql/v1beta20210501/flexible_server_types_gen.go @@ -143,11 +143,7 @@ func (server *FlexibleServer) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (server *FlexibleServer) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(server.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: server.Spec.Owner.Name, - } + return server.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -205,7 +201,7 @@ func (server *FlexibleServer) ValidateUpdate(old runtime.Object) (admission.Warn // createValidations validates the creation of the resource func (server *FlexibleServer) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){server.validateResourceReferences, server.validateSecretDestinations} + return []func() (admission.Warnings, error){server.validateResourceReferences, server.validateOwnerReference, server.validateSecretDestinations} } // deleteValidations validates the deletion of the resource @@ -220,12 +216,20 @@ func (server *FlexibleServer) updateValidations() []func(old runtime.Object) (ad return server.validateResourceReferences() }, server.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return server.validateOwnerReference() + }, func(old runtime.Object) (admission.Warnings, error) { return server.validateSecretDestinations() }, } } +// validateOwnerReference validates the owner field +func (server *FlexibleServer) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(server) +} + // validateResourceReferences validates all resource references func (server *FlexibleServer) validateResourceReferences() (admission.Warnings, error) { refs, err := reflecthelpers.FindResourceReferences(&server.Spec) @@ -655,7 +659,10 @@ func (server *FlexibleServer_Spec) PopulateFromARM(owner genruntime.ArbitraryOwn // no assignment for property "OperatorSpec" // Set property "Owner": - server.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + server.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "ReplicationRole": // copying flattened property: diff --git a/v2/api/dbformysql/v1beta20210501/flexible_servers_database_types_gen.go b/v2/api/dbformysql/v1beta20210501/flexible_servers_database_types_gen.go index e0adec45f93..3b5df68005e 100644 --- a/v2/api/dbformysql/v1beta20210501/flexible_servers_database_types_gen.go +++ b/v2/api/dbformysql/v1beta20210501/flexible_servers_database_types_gen.go @@ -142,11 +142,7 @@ func (database *FlexibleServersDatabase) NewEmptyStatus() genruntime.Convertible // Owner returns the ResourceReference of the owner func (database *FlexibleServersDatabase) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(database.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: database.Spec.Owner.Name, - } + return database.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -204,7 +200,7 @@ func (database *FlexibleServersDatabase) ValidateUpdate(old runtime.Object) (adm // createValidations validates the creation of the resource func (database *FlexibleServersDatabase) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){database.validateResourceReferences} + return []func() (admission.Warnings, error){database.validateResourceReferences, database.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -218,7 +214,16 @@ func (database *FlexibleServersDatabase) updateValidations() []func(old runtime. func(old runtime.Object) (admission.Warnings, error) { return database.validateResourceReferences() }, - database.validateWriteOnceProperties} + database.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return database.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (database *FlexibleServersDatabase) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(database) } // validateResourceReferences validates all resource references @@ -384,7 +389,10 @@ func (database *FlexibleServers_Database_Spec) PopulateFromARM(owner genruntime. } // Set property "Owner": - database.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + database.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // No error return nil diff --git a/v2/api/dbformysql/v1beta20210501/flexible_servers_firewall_rule_types_gen.go b/v2/api/dbformysql/v1beta20210501/flexible_servers_firewall_rule_types_gen.go index f59e2e7f221..6a8241868e9 100644 --- a/v2/api/dbformysql/v1beta20210501/flexible_servers_firewall_rule_types_gen.go +++ b/v2/api/dbformysql/v1beta20210501/flexible_servers_firewall_rule_types_gen.go @@ -142,11 +142,7 @@ func (rule *FlexibleServersFirewallRule) NewEmptyStatus() genruntime.Convertible // Owner returns the ResourceReference of the owner func (rule *FlexibleServersFirewallRule) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(rule.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: rule.Spec.Owner.Name, - } + return rule.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -204,7 +200,7 @@ func (rule *FlexibleServersFirewallRule) ValidateUpdate(old runtime.Object) (adm // createValidations validates the creation of the resource func (rule *FlexibleServersFirewallRule) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){rule.validateResourceReferences} + return []func() (admission.Warnings, error){rule.validateResourceReferences, rule.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -218,7 +214,16 @@ func (rule *FlexibleServersFirewallRule) updateValidations() []func(old runtime. func(old runtime.Object) (admission.Warnings, error) { return rule.validateResourceReferences() }, - rule.validateWriteOnceProperties} + rule.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return rule.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (rule *FlexibleServersFirewallRule) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(rule) } // validateResourceReferences validates all resource references @@ -381,7 +386,10 @@ func (rule *FlexibleServers_FirewallRule_Spec) PopulateFromARM(owner genruntime. } // Set property "Owner": - rule.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + rule.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "StartIpAddress": // copying flattened property: diff --git a/v2/api/dbformysql/v1beta20210501storage/flexible_server_types_gen.go b/v2/api/dbformysql/v1beta20210501storage/flexible_server_types_gen.go index e2e25c7dccb..5bc580fd697 100644 --- a/v2/api/dbformysql/v1beta20210501storage/flexible_server_types_gen.go +++ b/v2/api/dbformysql/v1beta20210501storage/flexible_server_types_gen.go @@ -104,11 +104,7 @@ func (server *FlexibleServer) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (server *FlexibleServer) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(server.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: server.Spec.Owner.Name, - } + return server.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/dbformysql/v1beta20210501storage/flexible_servers_database_types_gen.go b/v2/api/dbformysql/v1beta20210501storage/flexible_servers_database_types_gen.go index e1e4773a026..dfbb56dd848 100644 --- a/v2/api/dbformysql/v1beta20210501storage/flexible_servers_database_types_gen.go +++ b/v2/api/dbformysql/v1beta20210501storage/flexible_servers_database_types_gen.go @@ -103,11 +103,7 @@ func (database *FlexibleServersDatabase) NewEmptyStatus() genruntime.Convertible // Owner returns the ResourceReference of the owner func (database *FlexibleServersDatabase) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(database.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: database.Spec.Owner.Name, - } + return database.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/dbformysql/v1beta20210501storage/flexible_servers_firewall_rule_types_gen.go b/v2/api/dbformysql/v1beta20210501storage/flexible_servers_firewall_rule_types_gen.go index 373e95cc0dd..c1901c86d8d 100644 --- a/v2/api/dbformysql/v1beta20210501storage/flexible_servers_firewall_rule_types_gen.go +++ b/v2/api/dbformysql/v1beta20210501storage/flexible_servers_firewall_rule_types_gen.go @@ -103,11 +103,7 @@ func (rule *FlexibleServersFirewallRule) NewEmptyStatus() genruntime.Convertible // Owner returns the ResourceReference of the owner func (rule *FlexibleServersFirewallRule) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(rule.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: rule.Spec.Owner.Name, - } + return rule.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/dbforpostgresql/customizations/flexible_server_extensions.go b/v2/api/dbforpostgresql/customizations/flexible_server_extensions.go index 21a2236094e..de85232fe10 100644 --- a/v2/api/dbforpostgresql/customizations/flexible_server_extensions.go +++ b/v2/api/dbforpostgresql/customizations/flexible_server_extensions.go @@ -102,7 +102,7 @@ var nonBlockingFlexibleServerStates = set.Make( func (ext *FlexibleServerExtension) PreReconcileCheck( _ context.Context, obj genruntime.MetaObject, - owner genruntime.MetaObject, + _ genruntime.MetaObject, _ *resolver.Resolver, _ *genericarmclient.GenericClient, _ logr.Logger, diff --git a/v2/api/dbforpostgresql/customizations/flexible_servers_database_extensions.go b/v2/api/dbforpostgresql/customizations/flexible_servers_database_extensions.go index f9b2e7e087c..3203e3317a1 100644 --- a/v2/api/dbforpostgresql/customizations/flexible_servers_database_extensions.go +++ b/v2/api/dbforpostgresql/customizations/flexible_servers_database_extensions.go @@ -32,6 +32,10 @@ func (extension *FlexibleServersDatabaseExtension) PreReconcileCheck( _ extensions.PreReconcileCheckFunc, ) (extensions.PreReconcileCheckResult, error) { // Check to see if our owning server is ready for the database to be reconciled + if owner == nil { + // TODO: query from ARM instead? + return extensions.ProceedWithReconcile(), nil + } if server, ok := owner.(*hub.FlexibleServer); ok { serverState := server.Status.State if serverState != nil && flexibleServerStateBlocksReconciliation(*serverState) { diff --git a/v2/api/dbforpostgresql/customizations/flexible_servers_firewall_rule_extensions.go b/v2/api/dbforpostgresql/customizations/flexible_servers_firewall_rule_extensions.go index f12be14b585..a2a75fbcbd9 100644 --- a/v2/api/dbforpostgresql/customizations/flexible_servers_firewall_rule_extensions.go +++ b/v2/api/dbforpostgresql/customizations/flexible_servers_firewall_rule_extensions.go @@ -30,6 +30,11 @@ func (ext *FlexibleServersFirewallRuleExtension) PreReconcileCheck( _ logr.Logger, _ extensions.PreReconcileCheckFunc, ) (extensions.PreReconcileCheckResult, error) { + if owner == nil { + // TODO: Check from ARM instead? + return extensions.ProceedWithReconcile(), nil + } + // Check to see if our owning server is ready for the database to be reconciled if server, ok := owner.(*postgresql.FlexibleServer); ok { serverState := server.Status.State diff --git a/v2/api/dbforpostgresql/v1/user_types.go b/v2/api/dbforpostgresql/v1/user_types.go index 0c8365e6cfa..f8d06ba4c0b 100644 --- a/v2/api/dbforpostgresql/v1/user_types.go +++ b/v2/api/dbforpostgresql/v1/user_types.go @@ -75,11 +75,7 @@ func (user *User) AzureName() string { // Owner returns the ResourceReference of the owner, or nil if there is no owner func (user *User) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(user.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: user.Spec.Owner.Name, - } + return user.Spec.Owner.AsResourceReference(group, kind) } // +kubebuilder:webhook:path=/validate-dbforpostgresql-azure-com-v1-user,mutating=false,sideEffects=None,matchPolicy=Exact,failurePolicy=fail,groups=dbforpostgresql.azure.com,resources=users,verbs=create;update,versions=v1,name=validate.v1.users.dbforpostgresql.azure.com,admissionReviewVersions=v1 @@ -152,7 +148,7 @@ type UserSpec struct { //Owner: The owner of the resource. The owner controls where the resource goes when it is deployed. The owner also //controls the resources lifecycle. When the owner is deleted the resource will also be deleted. Owner is expected to be a //reference to a dbforpostgresql.azure.com/FlexibleServer resource - Owner *genruntime.KnownResourceReference `group:"dbforpostgresql.azure.com" json:"owner,omitempty" kind:"FlexibleServer"` + Owner *genruntime.KubernetesOwnerReference `group:"dbforpostgresql.azure.com" json:"owner,omitempty" kind:"FlexibleServer"` // The Azure Database for PostgreSQL server is created with the 3 default roles defined. // azure_pg_admin diff --git a/v2/api/dbforpostgresql/v1/zz_generated.deepcopy.go b/v2/api/dbforpostgresql/v1/zz_generated.deepcopy.go index 8c76b000d9d..7721607b9d5 100644 --- a/v2/api/dbforpostgresql/v1/zz_generated.deepcopy.go +++ b/v2/api/dbforpostgresql/v1/zz_generated.deepcopy.go @@ -119,7 +119,7 @@ func (in *UserSpec) DeepCopyInto(out *UserSpec) { *out = *in if in.Owner != nil { in, out := &in.Owner, &out.Owner - *out = new(genruntime.KnownResourceReference) + *out = new(genruntime.KubernetesOwnerReference) **out = **in } if in.Roles != nil { diff --git a/v2/api/dbforpostgresql/v1api20210601/flexible_server_types_gen.go b/v2/api/dbforpostgresql/v1api20210601/flexible_server_types_gen.go index 523a7badaa3..6f05b13fc31 100644 --- a/v2/api/dbforpostgresql/v1api20210601/flexible_server_types_gen.go +++ b/v2/api/dbforpostgresql/v1api20210601/flexible_server_types_gen.go @@ -141,11 +141,7 @@ func (server *FlexibleServer) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (server *FlexibleServer) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(server.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: server.Spec.Owner.Name, - } + return server.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -203,7 +199,7 @@ func (server *FlexibleServer) ValidateUpdate(old runtime.Object) (admission.Warn // createValidations validates the creation of the resource func (server *FlexibleServer) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){server.validateResourceReferences, server.validateSecretDestinations} + return []func() (admission.Warnings, error){server.validateResourceReferences, server.validateOwnerReference, server.validateSecretDestinations} } // deleteValidations validates the deletion of the resource @@ -218,12 +214,20 @@ func (server *FlexibleServer) updateValidations() []func(old runtime.Object) (ad return server.validateResourceReferences() }, server.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return server.validateOwnerReference() + }, func(old runtime.Object) (admission.Warnings, error) { return server.validateSecretDestinations() }, } } +// validateOwnerReference validates the owner field +func (server *FlexibleServer) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(server) +} + // validateResourceReferences validates all resource references func (server *FlexibleServer) validateResourceReferences() (admission.Warnings, error) { refs, err := reflecthelpers.FindResourceReferences(&server.Spec) @@ -637,7 +641,10 @@ func (server *FlexibleServer_Spec) PopulateFromARM(owner genruntime.ArbitraryOwn // no assignment for property "OperatorSpec" // Set property "Owner": - server.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + server.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "PointInTimeUTC": // copying flattened property: diff --git a/v2/api/dbforpostgresql/v1api20210601/flexible_servers_configuration_types_gen.go b/v2/api/dbforpostgresql/v1api20210601/flexible_servers_configuration_types_gen.go index 7aba696fb36..69a86919b66 100644 --- a/v2/api/dbforpostgresql/v1api20210601/flexible_servers_configuration_types_gen.go +++ b/v2/api/dbforpostgresql/v1api20210601/flexible_servers_configuration_types_gen.go @@ -141,11 +141,7 @@ func (configuration *FlexibleServersConfiguration) NewEmptyStatus() genruntime.C // Owner returns the ResourceReference of the owner func (configuration *FlexibleServersConfiguration) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(configuration.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: configuration.Spec.Owner.Name, - } + return configuration.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -203,7 +199,7 @@ func (configuration *FlexibleServersConfiguration) ValidateUpdate(old runtime.Ob // createValidations validates the creation of the resource func (configuration *FlexibleServersConfiguration) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){configuration.validateResourceReferences} + return []func() (admission.Warnings, error){configuration.validateResourceReferences, configuration.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -217,7 +213,16 @@ func (configuration *FlexibleServersConfiguration) updateValidations() []func(ol func(old runtime.Object) (admission.Warnings, error) { return configuration.validateResourceReferences() }, - configuration.validateWriteOnceProperties} + configuration.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return configuration.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (configuration *FlexibleServersConfiguration) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(configuration) } // validateResourceReferences validates all resource references @@ -371,7 +376,10 @@ func (configuration *FlexibleServers_Configuration_Spec) PopulateFromARM(owner g configuration.SetAzureName(genruntime.ExtractKubernetesResourceNameFromARMName(typedInput.Name)) // Set property "Owner": - configuration.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + configuration.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "Source": // copying flattened property: diff --git a/v2/api/dbforpostgresql/v1api20210601/flexible_servers_database_types_gen.go b/v2/api/dbforpostgresql/v1api20210601/flexible_servers_database_types_gen.go index 0b65a46f8a9..8379c6c1a57 100644 --- a/v2/api/dbforpostgresql/v1api20210601/flexible_servers_database_types_gen.go +++ b/v2/api/dbforpostgresql/v1api20210601/flexible_servers_database_types_gen.go @@ -141,11 +141,7 @@ func (database *FlexibleServersDatabase) NewEmptyStatus() genruntime.Convertible // Owner returns the ResourceReference of the owner func (database *FlexibleServersDatabase) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(database.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: database.Spec.Owner.Name, - } + return database.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -203,7 +199,7 @@ func (database *FlexibleServersDatabase) ValidateUpdate(old runtime.Object) (adm // createValidations validates the creation of the resource func (database *FlexibleServersDatabase) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){database.validateResourceReferences} + return []func() (admission.Warnings, error){database.validateResourceReferences, database.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -217,7 +213,16 @@ func (database *FlexibleServersDatabase) updateValidations() []func(old runtime. func(old runtime.Object) (admission.Warnings, error) { return database.validateResourceReferences() }, - database.validateWriteOnceProperties} + database.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return database.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (database *FlexibleServersDatabase) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(database) } // validateResourceReferences validates all resource references @@ -389,7 +394,10 @@ func (database *FlexibleServers_Database_Spec) PopulateFromARM(owner genruntime. } // Set property "Owner": - database.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + database.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // No error return nil diff --git a/v2/api/dbforpostgresql/v1api20210601/flexible_servers_firewall_rule_types_gen.go b/v2/api/dbforpostgresql/v1api20210601/flexible_servers_firewall_rule_types_gen.go index b3921fb4416..9b25ef070d4 100644 --- a/v2/api/dbforpostgresql/v1api20210601/flexible_servers_firewall_rule_types_gen.go +++ b/v2/api/dbforpostgresql/v1api20210601/flexible_servers_firewall_rule_types_gen.go @@ -141,11 +141,7 @@ func (rule *FlexibleServersFirewallRule) NewEmptyStatus() genruntime.Convertible // Owner returns the ResourceReference of the owner func (rule *FlexibleServersFirewallRule) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(rule.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: rule.Spec.Owner.Name, - } + return rule.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -203,7 +199,7 @@ func (rule *FlexibleServersFirewallRule) ValidateUpdate(old runtime.Object) (adm // createValidations validates the creation of the resource func (rule *FlexibleServersFirewallRule) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){rule.validateResourceReferences} + return []func() (admission.Warnings, error){rule.validateResourceReferences, rule.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -217,7 +213,16 @@ func (rule *FlexibleServersFirewallRule) updateValidations() []func(old runtime. func(old runtime.Object) (admission.Warnings, error) { return rule.validateResourceReferences() }, - rule.validateWriteOnceProperties} + rule.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return rule.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (rule *FlexibleServersFirewallRule) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(rule) } // validateResourceReferences validates all resource references @@ -384,7 +389,10 @@ func (rule *FlexibleServers_FirewallRule_Spec) PopulateFromARM(owner genruntime. } // Set property "Owner": - rule.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + rule.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "StartIpAddress": // copying flattened property: diff --git a/v2/api/dbforpostgresql/v1api20210601storage/flexible_server_types_gen.go b/v2/api/dbforpostgresql/v1api20210601storage/flexible_server_types_gen.go index 959e1d941bc..1240e1e3a70 100644 --- a/v2/api/dbforpostgresql/v1api20210601storage/flexible_server_types_gen.go +++ b/v2/api/dbforpostgresql/v1api20210601storage/flexible_server_types_gen.go @@ -84,11 +84,7 @@ func (server *FlexibleServer) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (server *FlexibleServer) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(server.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: server.Spec.Owner.Name, - } + return server.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/dbforpostgresql/v1api20210601storage/flexible_servers_configuration_types_gen.go b/v2/api/dbforpostgresql/v1api20210601storage/flexible_servers_configuration_types_gen.go index 7d07b1d4c65..d96723ea627 100644 --- a/v2/api/dbforpostgresql/v1api20210601storage/flexible_servers_configuration_types_gen.go +++ b/v2/api/dbforpostgresql/v1api20210601storage/flexible_servers_configuration_types_gen.go @@ -84,11 +84,7 @@ func (configuration *FlexibleServersConfiguration) NewEmptyStatus() genruntime.C // Owner returns the ResourceReference of the owner func (configuration *FlexibleServersConfiguration) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(configuration.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: configuration.Spec.Owner.Name, - } + return configuration.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/dbforpostgresql/v1api20210601storage/flexible_servers_database_types_gen.go b/v2/api/dbforpostgresql/v1api20210601storage/flexible_servers_database_types_gen.go index 293515b6a6c..8ff1c17d45f 100644 --- a/v2/api/dbforpostgresql/v1api20210601storage/flexible_servers_database_types_gen.go +++ b/v2/api/dbforpostgresql/v1api20210601storage/flexible_servers_database_types_gen.go @@ -84,11 +84,7 @@ func (database *FlexibleServersDatabase) NewEmptyStatus() genruntime.Convertible // Owner returns the ResourceReference of the owner func (database *FlexibleServersDatabase) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(database.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: database.Spec.Owner.Name, - } + return database.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/dbforpostgresql/v1api20210601storage/flexible_servers_firewall_rule_types_gen.go b/v2/api/dbforpostgresql/v1api20210601storage/flexible_servers_firewall_rule_types_gen.go index 2c43762cc96..90d01c3fded 100644 --- a/v2/api/dbforpostgresql/v1api20210601storage/flexible_servers_firewall_rule_types_gen.go +++ b/v2/api/dbforpostgresql/v1api20210601storage/flexible_servers_firewall_rule_types_gen.go @@ -84,11 +84,7 @@ func (rule *FlexibleServersFirewallRule) NewEmptyStatus() genruntime.Convertible // Owner returns the ResourceReference of the owner func (rule *FlexibleServersFirewallRule) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(rule.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: rule.Spec.Owner.Name, - } + return rule.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/dbforpostgresql/v1api20220120preview/flexible_server_types_gen.go b/v2/api/dbforpostgresql/v1api20220120preview/flexible_server_types_gen.go index 86c0125eed4..ac99844fb6b 100644 --- a/v2/api/dbforpostgresql/v1api20220120preview/flexible_server_types_gen.go +++ b/v2/api/dbforpostgresql/v1api20220120preview/flexible_server_types_gen.go @@ -166,11 +166,7 @@ func (server *FlexibleServer) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (server *FlexibleServer) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(server.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: server.Spec.Owner.Name, - } + return server.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -228,7 +224,7 @@ func (server *FlexibleServer) ValidateUpdate(old runtime.Object) (admission.Warn // createValidations validates the creation of the resource func (server *FlexibleServer) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){server.validateResourceReferences, server.validateConfigMapDestinations} + return []func() (admission.Warnings, error){server.validateResourceReferences, server.validateOwnerReference, server.validateConfigMapDestinations} } // deleteValidations validates the deletion of the resource @@ -243,6 +239,9 @@ func (server *FlexibleServer) updateValidations() []func(old runtime.Object) (ad return server.validateResourceReferences() }, server.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return server.validateOwnerReference() + }, func(old runtime.Object) (admission.Warnings, error) { return server.validateConfigMapDestinations() }, @@ -263,6 +262,11 @@ func (server *FlexibleServer) validateConfigMapDestinations() (admission.Warning return genruntime.ValidateConfigMapDestinations(toValidate) } +// validateOwnerReference validates the owner field +func (server *FlexibleServer) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(server) +} + // validateResourceReferences validates all resource references func (server *FlexibleServer) validateResourceReferences() (admission.Warnings, error) { refs, err := reflecthelpers.FindResourceReferences(&server.Spec) @@ -662,7 +666,10 @@ func (server *FlexibleServer_Spec) PopulateFromARM(owner genruntime.ArbitraryOwn // no assignment for property "OperatorSpec" // Set property "Owner": - server.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + server.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "PointInTimeUTC": // copying flattened property: diff --git a/v2/api/dbforpostgresql/v1api20220120preview/flexible_servers_configuration_types_gen.go b/v2/api/dbforpostgresql/v1api20220120preview/flexible_servers_configuration_types_gen.go index 784778ba17f..b738cc70f4b 100644 --- a/v2/api/dbforpostgresql/v1api20220120preview/flexible_servers_configuration_types_gen.go +++ b/v2/api/dbforpostgresql/v1api20220120preview/flexible_servers_configuration_types_gen.go @@ -144,11 +144,7 @@ func (configuration *FlexibleServersConfiguration) NewEmptyStatus() genruntime.C // Owner returns the ResourceReference of the owner func (configuration *FlexibleServersConfiguration) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(configuration.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: configuration.Spec.Owner.Name, - } + return configuration.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -206,7 +202,7 @@ func (configuration *FlexibleServersConfiguration) ValidateUpdate(old runtime.Ob // createValidations validates the creation of the resource func (configuration *FlexibleServersConfiguration) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){configuration.validateResourceReferences} + return []func() (admission.Warnings, error){configuration.validateResourceReferences, configuration.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -220,7 +216,16 @@ func (configuration *FlexibleServersConfiguration) updateValidations() []func(ol func(old runtime.Object) (admission.Warnings, error) { return configuration.validateResourceReferences() }, - configuration.validateWriteOnceProperties} + configuration.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return configuration.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (configuration *FlexibleServersConfiguration) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(configuration) } // validateResourceReferences validates all resource references @@ -374,7 +379,10 @@ func (configuration *FlexibleServers_Configuration_Spec) PopulateFromARM(owner g configuration.SetAzureName(genruntime.ExtractKubernetesResourceNameFromARMName(typedInput.Name)) // Set property "Owner": - configuration.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + configuration.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "Source": // copying flattened property: diff --git a/v2/api/dbforpostgresql/v1api20220120preview/flexible_servers_database_types_gen.go b/v2/api/dbforpostgresql/v1api20220120preview/flexible_servers_database_types_gen.go index 52c9128f246..c9f6d0c4021 100644 --- a/v2/api/dbforpostgresql/v1api20220120preview/flexible_servers_database_types_gen.go +++ b/v2/api/dbforpostgresql/v1api20220120preview/flexible_servers_database_types_gen.go @@ -144,11 +144,7 @@ func (database *FlexibleServersDatabase) NewEmptyStatus() genruntime.Convertible // Owner returns the ResourceReference of the owner func (database *FlexibleServersDatabase) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(database.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: database.Spec.Owner.Name, - } + return database.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -206,7 +202,7 @@ func (database *FlexibleServersDatabase) ValidateUpdate(old runtime.Object) (adm // createValidations validates the creation of the resource func (database *FlexibleServersDatabase) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){database.validateResourceReferences} + return []func() (admission.Warnings, error){database.validateResourceReferences, database.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -220,7 +216,16 @@ func (database *FlexibleServersDatabase) updateValidations() []func(old runtime. func(old runtime.Object) (admission.Warnings, error) { return database.validateResourceReferences() }, - database.validateWriteOnceProperties} + database.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return database.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (database *FlexibleServersDatabase) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(database) } // validateResourceReferences validates all resource references @@ -392,7 +397,10 @@ func (database *FlexibleServers_Database_Spec) PopulateFromARM(owner genruntime. } // Set property "Owner": - database.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + database.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // No error return nil diff --git a/v2/api/dbforpostgresql/v1api20220120preview/flexible_servers_firewall_rule_types_gen.go b/v2/api/dbforpostgresql/v1api20220120preview/flexible_servers_firewall_rule_types_gen.go index 5ba2d9516cf..650af8cc8ab 100644 --- a/v2/api/dbforpostgresql/v1api20220120preview/flexible_servers_firewall_rule_types_gen.go +++ b/v2/api/dbforpostgresql/v1api20220120preview/flexible_servers_firewall_rule_types_gen.go @@ -144,11 +144,7 @@ func (rule *FlexibleServersFirewallRule) NewEmptyStatus() genruntime.Convertible // Owner returns the ResourceReference of the owner func (rule *FlexibleServersFirewallRule) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(rule.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: rule.Spec.Owner.Name, - } + return rule.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -206,7 +202,7 @@ func (rule *FlexibleServersFirewallRule) ValidateUpdate(old runtime.Object) (adm // createValidations validates the creation of the resource func (rule *FlexibleServersFirewallRule) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){rule.validateResourceReferences} + return []func() (admission.Warnings, error){rule.validateResourceReferences, rule.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -220,7 +216,16 @@ func (rule *FlexibleServersFirewallRule) updateValidations() []func(old runtime. func(old runtime.Object) (admission.Warnings, error) { return rule.validateResourceReferences() }, - rule.validateWriteOnceProperties} + rule.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return rule.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (rule *FlexibleServersFirewallRule) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(rule) } // validateResourceReferences validates all resource references @@ -387,7 +392,10 @@ func (rule *FlexibleServers_FirewallRule_Spec) PopulateFromARM(owner genruntime. } // Set property "Owner": - rule.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + rule.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "StartIpAddress": // copying flattened property: diff --git a/v2/api/dbforpostgresql/v1api20220120previewstorage/flexible_server_types_gen.go b/v2/api/dbforpostgresql/v1api20220120previewstorage/flexible_server_types_gen.go index 9ee7f3fc2c9..8fd91700c6a 100644 --- a/v2/api/dbforpostgresql/v1api20220120previewstorage/flexible_server_types_gen.go +++ b/v2/api/dbforpostgresql/v1api20220120previewstorage/flexible_server_types_gen.go @@ -127,11 +127,7 @@ func (server *FlexibleServer) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (server *FlexibleServer) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(server.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: server.Spec.Owner.Name, - } + return server.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/dbforpostgresql/v1api20220120previewstorage/flexible_servers_configuration_types_gen.go b/v2/api/dbforpostgresql/v1api20220120previewstorage/flexible_servers_configuration_types_gen.go index 9d28388fa68..c1358f357f6 100644 --- a/v2/api/dbforpostgresql/v1api20220120previewstorage/flexible_servers_configuration_types_gen.go +++ b/v2/api/dbforpostgresql/v1api20220120previewstorage/flexible_servers_configuration_types_gen.go @@ -105,11 +105,7 @@ func (configuration *FlexibleServersConfiguration) NewEmptyStatus() genruntime.C // Owner returns the ResourceReference of the owner func (configuration *FlexibleServersConfiguration) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(configuration.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: configuration.Spec.Owner.Name, - } + return configuration.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/dbforpostgresql/v1api20220120previewstorage/flexible_servers_database_types_gen.go b/v2/api/dbforpostgresql/v1api20220120previewstorage/flexible_servers_database_types_gen.go index 6397944b588..73830bbc768 100644 --- a/v2/api/dbforpostgresql/v1api20220120previewstorage/flexible_servers_database_types_gen.go +++ b/v2/api/dbforpostgresql/v1api20220120previewstorage/flexible_servers_database_types_gen.go @@ -105,11 +105,7 @@ func (database *FlexibleServersDatabase) NewEmptyStatus() genruntime.Convertible // Owner returns the ResourceReference of the owner func (database *FlexibleServersDatabase) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(database.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: database.Spec.Owner.Name, - } + return database.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/dbforpostgresql/v1api20220120previewstorage/flexible_servers_firewall_rule_types_gen.go b/v2/api/dbforpostgresql/v1api20220120previewstorage/flexible_servers_firewall_rule_types_gen.go index 9f753f64a66..38daee109cc 100644 --- a/v2/api/dbforpostgresql/v1api20220120previewstorage/flexible_servers_firewall_rule_types_gen.go +++ b/v2/api/dbforpostgresql/v1api20220120previewstorage/flexible_servers_firewall_rule_types_gen.go @@ -105,11 +105,7 @@ func (rule *FlexibleServersFirewallRule) NewEmptyStatus() genruntime.Convertible // Owner returns the ResourceReference of the owner func (rule *FlexibleServersFirewallRule) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(rule.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: rule.Spec.Owner.Name, - } + return rule.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/dbforpostgresql/v1beta20210601/flexible_server_types_gen.go b/v2/api/dbforpostgresql/v1beta20210601/flexible_server_types_gen.go index a14bd178b9b..84b89e9e286 100644 --- a/v2/api/dbforpostgresql/v1beta20210601/flexible_server_types_gen.go +++ b/v2/api/dbforpostgresql/v1beta20210601/flexible_server_types_gen.go @@ -142,11 +142,7 @@ func (server *FlexibleServer) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (server *FlexibleServer) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(server.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: server.Spec.Owner.Name, - } + return server.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -204,7 +200,7 @@ func (server *FlexibleServer) ValidateUpdate(old runtime.Object) (admission.Warn // createValidations validates the creation of the resource func (server *FlexibleServer) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){server.validateResourceReferences, server.validateSecretDestinations} + return []func() (admission.Warnings, error){server.validateResourceReferences, server.validateOwnerReference, server.validateSecretDestinations} } // deleteValidations validates the deletion of the resource @@ -219,12 +215,20 @@ func (server *FlexibleServer) updateValidations() []func(old runtime.Object) (ad return server.validateResourceReferences() }, server.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return server.validateOwnerReference() + }, func(old runtime.Object) (admission.Warnings, error) { return server.validateSecretDestinations() }, } } +// validateOwnerReference validates the owner field +func (server *FlexibleServer) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(server) +} + // validateResourceReferences validates all resource references func (server *FlexibleServer) validateResourceReferences() (admission.Warnings, error) { refs, err := reflecthelpers.FindResourceReferences(&server.Spec) @@ -606,7 +610,10 @@ func (server *FlexibleServer_Spec) PopulateFromARM(owner genruntime.ArbitraryOwn // no assignment for property "OperatorSpec" // Set property "Owner": - server.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + server.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "PointInTimeUTC": // copying flattened property: diff --git a/v2/api/dbforpostgresql/v1beta20210601/flexible_servers_configuration_types_gen.go b/v2/api/dbforpostgresql/v1beta20210601/flexible_servers_configuration_types_gen.go index 35238cd80c6..32fc895201e 100644 --- a/v2/api/dbforpostgresql/v1beta20210601/flexible_servers_configuration_types_gen.go +++ b/v2/api/dbforpostgresql/v1beta20210601/flexible_servers_configuration_types_gen.go @@ -142,11 +142,7 @@ func (configuration *FlexibleServersConfiguration) NewEmptyStatus() genruntime.C // Owner returns the ResourceReference of the owner func (configuration *FlexibleServersConfiguration) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(configuration.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: configuration.Spec.Owner.Name, - } + return configuration.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -204,7 +200,7 @@ func (configuration *FlexibleServersConfiguration) ValidateUpdate(old runtime.Ob // createValidations validates the creation of the resource func (configuration *FlexibleServersConfiguration) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){configuration.validateResourceReferences} + return []func() (admission.Warnings, error){configuration.validateResourceReferences, configuration.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -218,7 +214,16 @@ func (configuration *FlexibleServersConfiguration) updateValidations() []func(ol func(old runtime.Object) (admission.Warnings, error) { return configuration.validateResourceReferences() }, - configuration.validateWriteOnceProperties} + configuration.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return configuration.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (configuration *FlexibleServersConfiguration) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(configuration) } // validateResourceReferences validates all resource references @@ -366,7 +371,10 @@ func (configuration *FlexibleServers_Configuration_Spec) PopulateFromARM(owner g configuration.SetAzureName(genruntime.ExtractKubernetesResourceNameFromARMName(typedInput.Name)) // Set property "Owner": - configuration.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + configuration.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "Source": // copying flattened property: diff --git a/v2/api/dbforpostgresql/v1beta20210601/flexible_servers_database_types_gen.go b/v2/api/dbforpostgresql/v1beta20210601/flexible_servers_database_types_gen.go index 4131b70b181..8ac90acf339 100644 --- a/v2/api/dbforpostgresql/v1beta20210601/flexible_servers_database_types_gen.go +++ b/v2/api/dbforpostgresql/v1beta20210601/flexible_servers_database_types_gen.go @@ -142,11 +142,7 @@ func (database *FlexibleServersDatabase) NewEmptyStatus() genruntime.Convertible // Owner returns the ResourceReference of the owner func (database *FlexibleServersDatabase) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(database.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: database.Spec.Owner.Name, - } + return database.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -204,7 +200,7 @@ func (database *FlexibleServersDatabase) ValidateUpdate(old runtime.Object) (adm // createValidations validates the creation of the resource func (database *FlexibleServersDatabase) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){database.validateResourceReferences} + return []func() (admission.Warnings, error){database.validateResourceReferences, database.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -218,7 +214,16 @@ func (database *FlexibleServersDatabase) updateValidations() []func(old runtime. func(old runtime.Object) (admission.Warnings, error) { return database.validateResourceReferences() }, - database.validateWriteOnceProperties} + database.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return database.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (database *FlexibleServersDatabase) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(database) } // validateResourceReferences validates all resource references @@ -384,7 +389,10 @@ func (database *FlexibleServers_Database_Spec) PopulateFromARM(owner genruntime. } // Set property "Owner": - database.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + database.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // No error return nil diff --git a/v2/api/dbforpostgresql/v1beta20210601/flexible_servers_firewall_rule_types_gen.go b/v2/api/dbforpostgresql/v1beta20210601/flexible_servers_firewall_rule_types_gen.go index a2cc6c5ce51..8976b44014e 100644 --- a/v2/api/dbforpostgresql/v1beta20210601/flexible_servers_firewall_rule_types_gen.go +++ b/v2/api/dbforpostgresql/v1beta20210601/flexible_servers_firewall_rule_types_gen.go @@ -142,11 +142,7 @@ func (rule *FlexibleServersFirewallRule) NewEmptyStatus() genruntime.Convertible // Owner returns the ResourceReference of the owner func (rule *FlexibleServersFirewallRule) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(rule.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: rule.Spec.Owner.Name, - } + return rule.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -204,7 +200,7 @@ func (rule *FlexibleServersFirewallRule) ValidateUpdate(old runtime.Object) (adm // createValidations validates the creation of the resource func (rule *FlexibleServersFirewallRule) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){rule.validateResourceReferences} + return []func() (admission.Warnings, error){rule.validateResourceReferences, rule.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -218,7 +214,16 @@ func (rule *FlexibleServersFirewallRule) updateValidations() []func(old runtime. func(old runtime.Object) (admission.Warnings, error) { return rule.validateResourceReferences() }, - rule.validateWriteOnceProperties} + rule.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return rule.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (rule *FlexibleServersFirewallRule) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(rule) } // validateResourceReferences validates all resource references @@ -381,7 +386,10 @@ func (rule *FlexibleServers_FirewallRule_Spec) PopulateFromARM(owner genruntime. } // Set property "Owner": - rule.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + rule.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "StartIpAddress": // copying flattened property: diff --git a/v2/api/dbforpostgresql/v1beta20210601storage/flexible_server_types_gen.go b/v2/api/dbforpostgresql/v1beta20210601storage/flexible_server_types_gen.go index a7cef7e586c..9d1306bdbef 100644 --- a/v2/api/dbforpostgresql/v1beta20210601storage/flexible_server_types_gen.go +++ b/v2/api/dbforpostgresql/v1beta20210601storage/flexible_server_types_gen.go @@ -117,11 +117,7 @@ func (server *FlexibleServer) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (server *FlexibleServer) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(server.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: server.Spec.Owner.Name, - } + return server.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/dbforpostgresql/v1beta20210601storage/flexible_servers_configuration_types_gen.go b/v2/api/dbforpostgresql/v1beta20210601storage/flexible_servers_configuration_types_gen.go index ec4386d9ef0..5cebe0990b3 100644 --- a/v2/api/dbforpostgresql/v1beta20210601storage/flexible_servers_configuration_types_gen.go +++ b/v2/api/dbforpostgresql/v1beta20210601storage/flexible_servers_configuration_types_gen.go @@ -116,11 +116,7 @@ func (configuration *FlexibleServersConfiguration) NewEmptyStatus() genruntime.C // Owner returns the ResourceReference of the owner func (configuration *FlexibleServersConfiguration) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(configuration.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: configuration.Spec.Owner.Name, - } + return configuration.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/dbforpostgresql/v1beta20210601storage/flexible_servers_database_types_gen.go b/v2/api/dbforpostgresql/v1beta20210601storage/flexible_servers_database_types_gen.go index a3ae957d32d..77b0a27bbeb 100644 --- a/v2/api/dbforpostgresql/v1beta20210601storage/flexible_servers_database_types_gen.go +++ b/v2/api/dbforpostgresql/v1beta20210601storage/flexible_servers_database_types_gen.go @@ -116,11 +116,7 @@ func (database *FlexibleServersDatabase) NewEmptyStatus() genruntime.Convertible // Owner returns the ResourceReference of the owner func (database *FlexibleServersDatabase) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(database.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: database.Spec.Owner.Name, - } + return database.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/dbforpostgresql/v1beta20210601storage/flexible_servers_firewall_rule_types_gen.go b/v2/api/dbforpostgresql/v1beta20210601storage/flexible_servers_firewall_rule_types_gen.go index e09613eafc3..fdd4446bd60 100644 --- a/v2/api/dbforpostgresql/v1beta20210601storage/flexible_servers_firewall_rule_types_gen.go +++ b/v2/api/dbforpostgresql/v1beta20210601storage/flexible_servers_firewall_rule_types_gen.go @@ -116,11 +116,7 @@ func (rule *FlexibleServersFirewallRule) NewEmptyStatus() genruntime.Convertible // Owner returns the ResourceReference of the owner func (rule *FlexibleServersFirewallRule) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(rule.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: rule.Spec.Owner.Name, - } + return rule.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/dbforpostgresql/v1beta20220120preview/flexible_server_types_gen.go b/v2/api/dbforpostgresql/v1beta20220120preview/flexible_server_types_gen.go index 09c877b5231..32d40a22d18 100644 --- a/v2/api/dbforpostgresql/v1beta20220120preview/flexible_server_types_gen.go +++ b/v2/api/dbforpostgresql/v1beta20220120preview/flexible_server_types_gen.go @@ -164,11 +164,7 @@ func (server *FlexibleServer) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (server *FlexibleServer) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(server.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: server.Spec.Owner.Name, - } + return server.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -226,7 +222,7 @@ func (server *FlexibleServer) ValidateUpdate(old runtime.Object) (admission.Warn // createValidations validates the creation of the resource func (server *FlexibleServer) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){server.validateResourceReferences, server.validateConfigMapDestinations} + return []func() (admission.Warnings, error){server.validateResourceReferences, server.validateOwnerReference, server.validateConfigMapDestinations} } // deleteValidations validates the deletion of the resource @@ -241,6 +237,9 @@ func (server *FlexibleServer) updateValidations() []func(old runtime.Object) (ad return server.validateResourceReferences() }, server.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return server.validateOwnerReference() + }, func(old runtime.Object) (admission.Warnings, error) { return server.validateConfigMapDestinations() }, @@ -261,6 +260,11 @@ func (server *FlexibleServer) validateConfigMapDestinations() (admission.Warning return genruntime.ValidateConfigMapDestinations(toValidate) } +// validateOwnerReference validates the owner field +func (server *FlexibleServer) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(server) +} + // validateResourceReferences validates all resource references func (server *FlexibleServer) validateResourceReferences() (admission.Warnings, error) { refs, err := reflecthelpers.FindResourceReferences(&server.Spec) @@ -628,7 +632,10 @@ func (server *FlexibleServer_Spec) PopulateFromARM(owner genruntime.ArbitraryOwn // no assignment for property "OperatorSpec" // Set property "Owner": - server.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + server.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "PointInTimeUTC": // copying flattened property: diff --git a/v2/api/dbforpostgresql/v1beta20220120preview/flexible_servers_configuration_types_gen.go b/v2/api/dbforpostgresql/v1beta20220120preview/flexible_servers_configuration_types_gen.go index 931826f3af9..265295d3f8f 100644 --- a/v2/api/dbforpostgresql/v1beta20220120preview/flexible_servers_configuration_types_gen.go +++ b/v2/api/dbforpostgresql/v1beta20220120preview/flexible_servers_configuration_types_gen.go @@ -142,11 +142,7 @@ func (configuration *FlexibleServersConfiguration) NewEmptyStatus() genruntime.C // Owner returns the ResourceReference of the owner func (configuration *FlexibleServersConfiguration) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(configuration.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: configuration.Spec.Owner.Name, - } + return configuration.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -204,7 +200,7 @@ func (configuration *FlexibleServersConfiguration) ValidateUpdate(old runtime.Ob // createValidations validates the creation of the resource func (configuration *FlexibleServersConfiguration) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){configuration.validateResourceReferences} + return []func() (admission.Warnings, error){configuration.validateResourceReferences, configuration.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -218,7 +214,16 @@ func (configuration *FlexibleServersConfiguration) updateValidations() []func(ol func(old runtime.Object) (admission.Warnings, error) { return configuration.validateResourceReferences() }, - configuration.validateWriteOnceProperties} + configuration.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return configuration.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (configuration *FlexibleServersConfiguration) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(configuration) } // validateResourceReferences validates all resource references @@ -366,7 +371,10 @@ func (configuration *FlexibleServers_Configuration_Spec) PopulateFromARM(owner g configuration.SetAzureName(genruntime.ExtractKubernetesResourceNameFromARMName(typedInput.Name)) // Set property "Owner": - configuration.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + configuration.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "Source": // copying flattened property: diff --git a/v2/api/dbforpostgresql/v1beta20220120preview/flexible_servers_database_types_gen.go b/v2/api/dbforpostgresql/v1beta20220120preview/flexible_servers_database_types_gen.go index 9308d5fb820..547beff7afa 100644 --- a/v2/api/dbforpostgresql/v1beta20220120preview/flexible_servers_database_types_gen.go +++ b/v2/api/dbforpostgresql/v1beta20220120preview/flexible_servers_database_types_gen.go @@ -142,11 +142,7 @@ func (database *FlexibleServersDatabase) NewEmptyStatus() genruntime.Convertible // Owner returns the ResourceReference of the owner func (database *FlexibleServersDatabase) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(database.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: database.Spec.Owner.Name, - } + return database.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -204,7 +200,7 @@ func (database *FlexibleServersDatabase) ValidateUpdate(old runtime.Object) (adm // createValidations validates the creation of the resource func (database *FlexibleServersDatabase) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){database.validateResourceReferences} + return []func() (admission.Warnings, error){database.validateResourceReferences, database.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -218,7 +214,16 @@ func (database *FlexibleServersDatabase) updateValidations() []func(old runtime. func(old runtime.Object) (admission.Warnings, error) { return database.validateResourceReferences() }, - database.validateWriteOnceProperties} + database.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return database.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (database *FlexibleServersDatabase) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(database) } // validateResourceReferences validates all resource references @@ -384,7 +389,10 @@ func (database *FlexibleServers_Database_Spec) PopulateFromARM(owner genruntime. } // Set property "Owner": - database.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + database.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // No error return nil diff --git a/v2/api/dbforpostgresql/v1beta20220120preview/flexible_servers_firewall_rule_types_gen.go b/v2/api/dbforpostgresql/v1beta20220120preview/flexible_servers_firewall_rule_types_gen.go index 2f1c46b4dcf..88be384f865 100644 --- a/v2/api/dbforpostgresql/v1beta20220120preview/flexible_servers_firewall_rule_types_gen.go +++ b/v2/api/dbforpostgresql/v1beta20220120preview/flexible_servers_firewall_rule_types_gen.go @@ -142,11 +142,7 @@ func (rule *FlexibleServersFirewallRule) NewEmptyStatus() genruntime.Convertible // Owner returns the ResourceReference of the owner func (rule *FlexibleServersFirewallRule) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(rule.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: rule.Spec.Owner.Name, - } + return rule.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -204,7 +200,7 @@ func (rule *FlexibleServersFirewallRule) ValidateUpdate(old runtime.Object) (adm // createValidations validates the creation of the resource func (rule *FlexibleServersFirewallRule) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){rule.validateResourceReferences} + return []func() (admission.Warnings, error){rule.validateResourceReferences, rule.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -218,7 +214,16 @@ func (rule *FlexibleServersFirewallRule) updateValidations() []func(old runtime. func(old runtime.Object) (admission.Warnings, error) { return rule.validateResourceReferences() }, - rule.validateWriteOnceProperties} + rule.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return rule.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (rule *FlexibleServersFirewallRule) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(rule) } // validateResourceReferences validates all resource references @@ -381,7 +386,10 @@ func (rule *FlexibleServers_FirewallRule_Spec) PopulateFromARM(owner genruntime. } // Set property "Owner": - rule.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + rule.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "StartIpAddress": // copying flattened property: diff --git a/v2/api/dbforpostgresql/v1beta20220120previewstorage/flexible_server_types_gen.go b/v2/api/dbforpostgresql/v1beta20220120previewstorage/flexible_server_types_gen.go index 2d1a952311a..4b2b7cb1567 100644 --- a/v2/api/dbforpostgresql/v1beta20220120previewstorage/flexible_server_types_gen.go +++ b/v2/api/dbforpostgresql/v1beta20220120previewstorage/flexible_server_types_gen.go @@ -126,11 +126,7 @@ func (server *FlexibleServer) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (server *FlexibleServer) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(server.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: server.Spec.Owner.Name, - } + return server.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/dbforpostgresql/v1beta20220120previewstorage/flexible_servers_configuration_types_gen.go b/v2/api/dbforpostgresql/v1beta20220120previewstorage/flexible_servers_configuration_types_gen.go index 2eff54e1df3..e359fbc218e 100644 --- a/v2/api/dbforpostgresql/v1beta20220120previewstorage/flexible_servers_configuration_types_gen.go +++ b/v2/api/dbforpostgresql/v1beta20220120previewstorage/flexible_servers_configuration_types_gen.go @@ -103,11 +103,7 @@ func (configuration *FlexibleServersConfiguration) NewEmptyStatus() genruntime.C // Owner returns the ResourceReference of the owner func (configuration *FlexibleServersConfiguration) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(configuration.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: configuration.Spec.Owner.Name, - } + return configuration.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/dbforpostgresql/v1beta20220120previewstorage/flexible_servers_database_types_gen.go b/v2/api/dbforpostgresql/v1beta20220120previewstorage/flexible_servers_database_types_gen.go index af51d8a1ff0..037e11d2f4e 100644 --- a/v2/api/dbforpostgresql/v1beta20220120previewstorage/flexible_servers_database_types_gen.go +++ b/v2/api/dbforpostgresql/v1beta20220120previewstorage/flexible_servers_database_types_gen.go @@ -103,11 +103,7 @@ func (database *FlexibleServersDatabase) NewEmptyStatus() genruntime.Convertible // Owner returns the ResourceReference of the owner func (database *FlexibleServersDatabase) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(database.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: database.Spec.Owner.Name, - } + return database.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/dbforpostgresql/v1beta20220120previewstorage/flexible_servers_firewall_rule_types_gen.go b/v2/api/dbforpostgresql/v1beta20220120previewstorage/flexible_servers_firewall_rule_types_gen.go index 2f6c7ee746f..d07f748b950 100644 --- a/v2/api/dbforpostgresql/v1beta20220120previewstorage/flexible_servers_firewall_rule_types_gen.go +++ b/v2/api/dbforpostgresql/v1beta20220120previewstorage/flexible_servers_firewall_rule_types_gen.go @@ -103,11 +103,7 @@ func (rule *FlexibleServersFirewallRule) NewEmptyStatus() genruntime.Convertible // Owner returns the ResourceReference of the owner func (rule *FlexibleServersFirewallRule) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(rule.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: rule.Spec.Owner.Name, - } + return rule.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/devices/v1api20210702/iot_hub_types_gen.go b/v2/api/devices/v1api20210702/iot_hub_types_gen.go index 16eb9703e4a..b1cadfcadc5 100644 --- a/v2/api/devices/v1api20210702/iot_hub_types_gen.go +++ b/v2/api/devices/v1api20210702/iot_hub_types_gen.go @@ -141,11 +141,7 @@ func (iotHub *IotHub) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (iotHub *IotHub) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(iotHub.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: iotHub.Spec.Owner.Name, - } + return iotHub.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -203,7 +199,7 @@ func (iotHub *IotHub) ValidateUpdate(old runtime.Object) (admission.Warnings, er // createValidations validates the creation of the resource func (iotHub *IotHub) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){iotHub.validateResourceReferences, iotHub.validateSecretDestinations} + return []func() (admission.Warnings, error){iotHub.validateResourceReferences, iotHub.validateOwnerReference, iotHub.validateSecretDestinations} } // deleteValidations validates the deletion of the resource @@ -218,12 +214,20 @@ func (iotHub *IotHub) updateValidations() []func(old runtime.Object) (admission. return iotHub.validateResourceReferences() }, iotHub.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return iotHub.validateOwnerReference() + }, func(old runtime.Object) (admission.Warnings, error) { return iotHub.validateSecretDestinations() }, } } +// validateOwnerReference validates the owner field +func (iotHub *IotHub) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(iotHub) +} + // validateResourceReferences validates all resource references func (iotHub *IotHub) validateResourceReferences() (admission.Warnings, error) { refs, err := reflecthelpers.FindResourceReferences(&iotHub.Spec) @@ -468,7 +472,10 @@ func (iotHub *IotHub_Spec) PopulateFromARM(owner genruntime.ArbitraryOwnerRefere // no assignment for property "OperatorSpec" // Set property "Owner": - iotHub.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + iotHub.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "Properties": if typedInput.Properties != nil { diff --git a/v2/api/devices/v1api20210702storage/iot_hub_types_gen.go b/v2/api/devices/v1api20210702storage/iot_hub_types_gen.go index 118a3300118..9034e4f96bd 100644 --- a/v2/api/devices/v1api20210702storage/iot_hub_types_gen.go +++ b/v2/api/devices/v1api20210702storage/iot_hub_types_gen.go @@ -84,11 +84,7 @@ func (iotHub *IotHub) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (iotHub *IotHub) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(iotHub.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: iotHub.Spec.Owner.Name, - } + return iotHub.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/documentdb/v1api20210515/database_account_types_gen.go b/v2/api/documentdb/v1api20210515/database_account_types_gen.go index 21e2a81ff78..be50df22871 100644 --- a/v2/api/documentdb/v1api20210515/database_account_types_gen.go +++ b/v2/api/documentdb/v1api20210515/database_account_types_gen.go @@ -141,11 +141,7 @@ func (account *DatabaseAccount) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (account *DatabaseAccount) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(account.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: account.Spec.Owner.Name, - } + return account.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -203,7 +199,7 @@ func (account *DatabaseAccount) ValidateUpdate(old runtime.Object) (admission.Wa // createValidations validates the creation of the resource func (account *DatabaseAccount) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){account.validateResourceReferences, account.validateSecretDestinations} + return []func() (admission.Warnings, error){account.validateResourceReferences, account.validateOwnerReference, account.validateSecretDestinations} } // deleteValidations validates the deletion of the resource @@ -218,12 +214,20 @@ func (account *DatabaseAccount) updateValidations() []func(old runtime.Object) ( return account.validateResourceReferences() }, account.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return account.validateOwnerReference() + }, func(old runtime.Object) (admission.Warnings, error) { return account.validateSecretDestinations() }, } } +// validateOwnerReference validates the owner field +func (account *DatabaseAccount) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(account) +} + // validateResourceReferences validates all resource references func (account *DatabaseAccount) validateResourceReferences() (admission.Warnings, error) { refs, err := reflecthelpers.FindResourceReferences(&account.Spec) @@ -899,7 +903,10 @@ func (account *DatabaseAccount_Spec) PopulateFromARM(owner genruntime.ArbitraryO // no assignment for property "OperatorSpec" // Set property "Owner": - account.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + account.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "PublicNetworkAccess": // copying flattened property: diff --git a/v2/api/documentdb/v1api20210515/mongodb_database_collection_throughput_setting_types_gen.go b/v2/api/documentdb/v1api20210515/mongodb_database_collection_throughput_setting_types_gen.go index 414365d888a..c57be9d07cc 100644 --- a/v2/api/documentdb/v1api20210515/mongodb_database_collection_throughput_setting_types_gen.go +++ b/v2/api/documentdb/v1api20210515/mongodb_database_collection_throughput_setting_types_gen.go @@ -134,11 +134,7 @@ func (setting *MongodbDatabaseCollectionThroughputSetting) NewEmptyStatus() genr // Owner returns the ResourceReference of the owner func (setting *MongodbDatabaseCollectionThroughputSetting) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(setting.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: setting.Spec.Owner.Name, - } + return setting.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -196,7 +192,7 @@ func (setting *MongodbDatabaseCollectionThroughputSetting) ValidateUpdate(old ru // createValidations validates the creation of the resource func (setting *MongodbDatabaseCollectionThroughputSetting) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){setting.validateResourceReferences} + return []func() (admission.Warnings, error){setting.validateResourceReferences, setting.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -210,7 +206,16 @@ func (setting *MongodbDatabaseCollectionThroughputSetting) updateValidations() [ func(old runtime.Object) (admission.Warnings, error) { return setting.validateResourceReferences() }, - setting.validateWriteOnceProperties} + setting.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return setting.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (setting *MongodbDatabaseCollectionThroughputSetting) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(setting) } // validateResourceReferences validates all resource references @@ -379,7 +384,10 @@ func (setting *DatabaseAccounts_MongodbDatabases_Collections_ThroughputSetting_S } // Set property "Owner": - setting.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + setting.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "Resource": // copying flattened property: diff --git a/v2/api/documentdb/v1api20210515/mongodb_database_collection_types_gen.go b/v2/api/documentdb/v1api20210515/mongodb_database_collection_types_gen.go index f9eeca83435..5c40e78c7d1 100644 --- a/v2/api/documentdb/v1api20210515/mongodb_database_collection_types_gen.go +++ b/v2/api/documentdb/v1api20210515/mongodb_database_collection_types_gen.go @@ -141,11 +141,7 @@ func (collection *MongodbDatabaseCollection) NewEmptyStatus() genruntime.Convert // Owner returns the ResourceReference of the owner func (collection *MongodbDatabaseCollection) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(collection.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: collection.Spec.Owner.Name, - } + return collection.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -203,7 +199,7 @@ func (collection *MongodbDatabaseCollection) ValidateUpdate(old runtime.Object) // createValidations validates the creation of the resource func (collection *MongodbDatabaseCollection) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){collection.validateResourceReferences} + return []func() (admission.Warnings, error){collection.validateResourceReferences, collection.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -217,7 +213,16 @@ func (collection *MongodbDatabaseCollection) updateValidations() []func(old runt func(old runtime.Object) (admission.Warnings, error) { return collection.validateResourceReferences() }, - collection.validateWriteOnceProperties} + collection.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return collection.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (collection *MongodbDatabaseCollection) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(collection) } // validateResourceReferences validates all resource references @@ -419,7 +424,10 @@ func (collection *DatabaseAccounts_MongodbDatabases_Collection_Spec) PopulateFro } // Set property "Owner": - collection.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + collection.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "Resource": // copying flattened property: diff --git a/v2/api/documentdb/v1api20210515/mongodb_database_throughput_setting_types_gen.go b/v2/api/documentdb/v1api20210515/mongodb_database_throughput_setting_types_gen.go index f4ac987240e..052068cea40 100644 --- a/v2/api/documentdb/v1api20210515/mongodb_database_throughput_setting_types_gen.go +++ b/v2/api/documentdb/v1api20210515/mongodb_database_throughput_setting_types_gen.go @@ -134,11 +134,7 @@ func (setting *MongodbDatabaseThroughputSetting) NewEmptyStatus() genruntime.Con // Owner returns the ResourceReference of the owner func (setting *MongodbDatabaseThroughputSetting) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(setting.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: setting.Spec.Owner.Name, - } + return setting.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -196,7 +192,7 @@ func (setting *MongodbDatabaseThroughputSetting) ValidateUpdate(old runtime.Obje // createValidations validates the creation of the resource func (setting *MongodbDatabaseThroughputSetting) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){setting.validateResourceReferences} + return []func() (admission.Warnings, error){setting.validateResourceReferences, setting.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -210,7 +206,16 @@ func (setting *MongodbDatabaseThroughputSetting) updateValidations() []func(old func(old runtime.Object) (admission.Warnings, error) { return setting.validateResourceReferences() }, - setting.validateWriteOnceProperties} + setting.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return setting.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (setting *MongodbDatabaseThroughputSetting) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(setting) } // validateResourceReferences validates all resource references @@ -379,7 +384,10 @@ func (setting *DatabaseAccounts_MongodbDatabases_ThroughputSetting_Spec) Populat } // Set property "Owner": - setting.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + setting.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "Resource": // copying flattened property: diff --git a/v2/api/documentdb/v1api20210515/mongodb_database_types_gen.go b/v2/api/documentdb/v1api20210515/mongodb_database_types_gen.go index 067d24bf638..bc652be25dd 100644 --- a/v2/api/documentdb/v1api20210515/mongodb_database_types_gen.go +++ b/v2/api/documentdb/v1api20210515/mongodb_database_types_gen.go @@ -141,11 +141,7 @@ func (database *MongodbDatabase) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (database *MongodbDatabase) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(database.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: database.Spec.Owner.Name, - } + return database.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -203,7 +199,7 @@ func (database *MongodbDatabase) ValidateUpdate(old runtime.Object) (admission.W // createValidations validates the creation of the resource func (database *MongodbDatabase) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){database.validateResourceReferences} + return []func() (admission.Warnings, error){database.validateResourceReferences, database.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -217,7 +213,16 @@ func (database *MongodbDatabase) updateValidations() []func(old runtime.Object) func(old runtime.Object) (admission.Warnings, error) { return database.validateResourceReferences() }, - database.validateWriteOnceProperties} + database.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return database.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (database *MongodbDatabase) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(database) } // validateResourceReferences validates all resource references @@ -419,7 +424,10 @@ func (database *DatabaseAccounts_MongodbDatabase_Spec) PopulateFromARM(owner gen } // Set property "Owner": - database.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + database.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "Resource": // copying flattened property: diff --git a/v2/api/documentdb/v1api20210515/sql_database_container_stored_procedure_types_gen.go b/v2/api/documentdb/v1api20210515/sql_database_container_stored_procedure_types_gen.go index 5281d18143e..ca2666bf4cd 100644 --- a/v2/api/documentdb/v1api20210515/sql_database_container_stored_procedure_types_gen.go +++ b/v2/api/documentdb/v1api20210515/sql_database_container_stored_procedure_types_gen.go @@ -141,11 +141,7 @@ func (procedure *SqlDatabaseContainerStoredProcedure) NewEmptyStatus() genruntim // Owner returns the ResourceReference of the owner func (procedure *SqlDatabaseContainerStoredProcedure) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(procedure.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: procedure.Spec.Owner.Name, - } + return procedure.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -203,7 +199,7 @@ func (procedure *SqlDatabaseContainerStoredProcedure) ValidateUpdate(old runtime // createValidations validates the creation of the resource func (procedure *SqlDatabaseContainerStoredProcedure) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){procedure.validateResourceReferences} + return []func() (admission.Warnings, error){procedure.validateResourceReferences, procedure.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -217,7 +213,16 @@ func (procedure *SqlDatabaseContainerStoredProcedure) updateValidations() []func func(old runtime.Object) (admission.Warnings, error) { return procedure.validateResourceReferences() }, - procedure.validateWriteOnceProperties} + procedure.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return procedure.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (procedure *SqlDatabaseContainerStoredProcedure) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(procedure) } // validateResourceReferences validates all resource references @@ -419,7 +424,10 @@ func (procedure *DatabaseAccounts_SqlDatabases_Containers_StoredProcedure_Spec) } // Set property "Owner": - procedure.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + procedure.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "Resource": // copying flattened property: diff --git a/v2/api/documentdb/v1api20210515/sql_database_container_throughput_setting_types_gen.go b/v2/api/documentdb/v1api20210515/sql_database_container_throughput_setting_types_gen.go index a44bac9ee56..e967dd4139b 100644 --- a/v2/api/documentdb/v1api20210515/sql_database_container_throughput_setting_types_gen.go +++ b/v2/api/documentdb/v1api20210515/sql_database_container_throughput_setting_types_gen.go @@ -134,11 +134,7 @@ func (setting *SqlDatabaseContainerThroughputSetting) NewEmptyStatus() genruntim // Owner returns the ResourceReference of the owner func (setting *SqlDatabaseContainerThroughputSetting) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(setting.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: setting.Spec.Owner.Name, - } + return setting.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -196,7 +192,7 @@ func (setting *SqlDatabaseContainerThroughputSetting) ValidateUpdate(old runtime // createValidations validates the creation of the resource func (setting *SqlDatabaseContainerThroughputSetting) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){setting.validateResourceReferences} + return []func() (admission.Warnings, error){setting.validateResourceReferences, setting.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -210,7 +206,16 @@ func (setting *SqlDatabaseContainerThroughputSetting) updateValidations() []func func(old runtime.Object) (admission.Warnings, error) { return setting.validateResourceReferences() }, - setting.validateWriteOnceProperties} + setting.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return setting.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (setting *SqlDatabaseContainerThroughputSetting) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(setting) } // validateResourceReferences validates all resource references @@ -379,7 +384,10 @@ func (setting *DatabaseAccounts_SqlDatabases_Containers_ThroughputSetting_Spec) } // Set property "Owner": - setting.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + setting.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "Resource": // copying flattened property: diff --git a/v2/api/documentdb/v1api20210515/sql_database_container_trigger_types_gen.go b/v2/api/documentdb/v1api20210515/sql_database_container_trigger_types_gen.go index 5ff97073ff5..353c37947c8 100644 --- a/v2/api/documentdb/v1api20210515/sql_database_container_trigger_types_gen.go +++ b/v2/api/documentdb/v1api20210515/sql_database_container_trigger_types_gen.go @@ -141,11 +141,7 @@ func (trigger *SqlDatabaseContainerTrigger) NewEmptyStatus() genruntime.Converti // Owner returns the ResourceReference of the owner func (trigger *SqlDatabaseContainerTrigger) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(trigger.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: trigger.Spec.Owner.Name, - } + return trigger.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -203,7 +199,7 @@ func (trigger *SqlDatabaseContainerTrigger) ValidateUpdate(old runtime.Object) ( // createValidations validates the creation of the resource func (trigger *SqlDatabaseContainerTrigger) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){trigger.validateResourceReferences} + return []func() (admission.Warnings, error){trigger.validateResourceReferences, trigger.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -217,7 +213,16 @@ func (trigger *SqlDatabaseContainerTrigger) updateValidations() []func(old runti func(old runtime.Object) (admission.Warnings, error) { return trigger.validateResourceReferences() }, - trigger.validateWriteOnceProperties} + trigger.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return trigger.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (trigger *SqlDatabaseContainerTrigger) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(trigger) } // validateResourceReferences validates all resource references @@ -419,7 +424,10 @@ func (trigger *DatabaseAccounts_SqlDatabases_Containers_Trigger_Spec) PopulateFr } // Set property "Owner": - trigger.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + trigger.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "Resource": // copying flattened property: diff --git a/v2/api/documentdb/v1api20210515/sql_database_container_types_gen.go b/v2/api/documentdb/v1api20210515/sql_database_container_types_gen.go index 596b4331baa..b31bbcdf2a2 100644 --- a/v2/api/documentdb/v1api20210515/sql_database_container_types_gen.go +++ b/v2/api/documentdb/v1api20210515/sql_database_container_types_gen.go @@ -141,11 +141,7 @@ func (container *SqlDatabaseContainer) NewEmptyStatus() genruntime.ConvertibleSt // Owner returns the ResourceReference of the owner func (container *SqlDatabaseContainer) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(container.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: container.Spec.Owner.Name, - } + return container.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -203,7 +199,7 @@ func (container *SqlDatabaseContainer) ValidateUpdate(old runtime.Object) (admis // createValidations validates the creation of the resource func (container *SqlDatabaseContainer) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){container.validateResourceReferences} + return []func() (admission.Warnings, error){container.validateResourceReferences, container.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -217,7 +213,16 @@ func (container *SqlDatabaseContainer) updateValidations() []func(old runtime.Ob func(old runtime.Object) (admission.Warnings, error) { return container.validateResourceReferences() }, - container.validateWriteOnceProperties} + container.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return container.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (container *SqlDatabaseContainer) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(container) } // validateResourceReferences validates all resource references @@ -419,7 +424,10 @@ func (container *DatabaseAccounts_SqlDatabases_Container_Spec) PopulateFromARM(o } // Set property "Owner": - container.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + container.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "Resource": // copying flattened property: diff --git a/v2/api/documentdb/v1api20210515/sql_database_container_user_defined_function_types_gen.go b/v2/api/documentdb/v1api20210515/sql_database_container_user_defined_function_types_gen.go index 97cf8145b49..777ef3ec859 100644 --- a/v2/api/documentdb/v1api20210515/sql_database_container_user_defined_function_types_gen.go +++ b/v2/api/documentdb/v1api20210515/sql_database_container_user_defined_function_types_gen.go @@ -141,11 +141,7 @@ func (function *SqlDatabaseContainerUserDefinedFunction) NewEmptyStatus() genrun // Owner returns the ResourceReference of the owner func (function *SqlDatabaseContainerUserDefinedFunction) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(function.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: function.Spec.Owner.Name, - } + return function.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -203,7 +199,7 @@ func (function *SqlDatabaseContainerUserDefinedFunction) ValidateUpdate(old runt // createValidations validates the creation of the resource func (function *SqlDatabaseContainerUserDefinedFunction) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){function.validateResourceReferences} + return []func() (admission.Warnings, error){function.validateResourceReferences, function.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -217,7 +213,16 @@ func (function *SqlDatabaseContainerUserDefinedFunction) updateValidations() []f func(old runtime.Object) (admission.Warnings, error) { return function.validateResourceReferences() }, - function.validateWriteOnceProperties} + function.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return function.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (function *SqlDatabaseContainerUserDefinedFunction) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(function) } // validateResourceReferences validates all resource references @@ -419,7 +424,10 @@ func (function *DatabaseAccounts_SqlDatabases_Containers_UserDefinedFunction_Spe } // Set property "Owner": - function.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + function.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "Resource": // copying flattened property: diff --git a/v2/api/documentdb/v1api20210515/sql_database_throughput_setting_types_gen.go b/v2/api/documentdb/v1api20210515/sql_database_throughput_setting_types_gen.go index 9aa17fcc11a..d5a54aa53ba 100644 --- a/v2/api/documentdb/v1api20210515/sql_database_throughput_setting_types_gen.go +++ b/v2/api/documentdb/v1api20210515/sql_database_throughput_setting_types_gen.go @@ -134,11 +134,7 @@ func (setting *SqlDatabaseThroughputSetting) NewEmptyStatus() genruntime.Convert // Owner returns the ResourceReference of the owner func (setting *SqlDatabaseThroughputSetting) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(setting.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: setting.Spec.Owner.Name, - } + return setting.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -196,7 +192,7 @@ func (setting *SqlDatabaseThroughputSetting) ValidateUpdate(old runtime.Object) // createValidations validates the creation of the resource func (setting *SqlDatabaseThroughputSetting) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){setting.validateResourceReferences} + return []func() (admission.Warnings, error){setting.validateResourceReferences, setting.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -210,7 +206,16 @@ func (setting *SqlDatabaseThroughputSetting) updateValidations() []func(old runt func(old runtime.Object) (admission.Warnings, error) { return setting.validateResourceReferences() }, - setting.validateWriteOnceProperties} + setting.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return setting.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (setting *SqlDatabaseThroughputSetting) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(setting) } // validateResourceReferences validates all resource references @@ -379,7 +384,10 @@ func (setting *DatabaseAccounts_SqlDatabases_ThroughputSetting_Spec) PopulateFro } // Set property "Owner": - setting.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + setting.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "Resource": // copying flattened property: diff --git a/v2/api/documentdb/v1api20210515/sql_database_types_gen.go b/v2/api/documentdb/v1api20210515/sql_database_types_gen.go index 27175b2b754..efa700f9c0c 100644 --- a/v2/api/documentdb/v1api20210515/sql_database_types_gen.go +++ b/v2/api/documentdb/v1api20210515/sql_database_types_gen.go @@ -141,11 +141,7 @@ func (database *SqlDatabase) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (database *SqlDatabase) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(database.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: database.Spec.Owner.Name, - } + return database.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -203,7 +199,7 @@ func (database *SqlDatabase) ValidateUpdate(old runtime.Object) (admission.Warni // createValidations validates the creation of the resource func (database *SqlDatabase) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){database.validateResourceReferences} + return []func() (admission.Warnings, error){database.validateResourceReferences, database.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -217,7 +213,16 @@ func (database *SqlDatabase) updateValidations() []func(old runtime.Object) (adm func(old runtime.Object) (admission.Warnings, error) { return database.validateResourceReferences() }, - database.validateWriteOnceProperties} + database.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return database.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (database *SqlDatabase) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(database) } // validateResourceReferences validates all resource references @@ -419,7 +424,10 @@ func (database *DatabaseAccounts_SqlDatabase_Spec) PopulateFromARM(owner genrunt } // Set property "Owner": - database.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + database.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "Resource": // copying flattened property: diff --git a/v2/api/documentdb/v1api20210515/sql_role_assignment_types_gen.go b/v2/api/documentdb/v1api20210515/sql_role_assignment_types_gen.go index 99a30de321d..e60289257a8 100644 --- a/v2/api/documentdb/v1api20210515/sql_role_assignment_types_gen.go +++ b/v2/api/documentdb/v1api20210515/sql_role_assignment_types_gen.go @@ -134,11 +134,7 @@ func (assignment *SqlRoleAssignment) NewEmptyStatus() genruntime.ConvertibleStat // Owner returns the ResourceReference of the owner func (assignment *SqlRoleAssignment) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(assignment.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: assignment.Spec.Owner.Name, - } + return assignment.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -196,7 +192,7 @@ func (assignment *SqlRoleAssignment) ValidateUpdate(old runtime.Object) (admissi // createValidations validates the creation of the resource func (assignment *SqlRoleAssignment) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){assignment.validateResourceReferences, assignment.validateOptionalConfigMapReferences} + return []func() (admission.Warnings, error){assignment.validateResourceReferences, assignment.validateOwnerReference, assignment.validateOptionalConfigMapReferences} } // deleteValidations validates the deletion of the resource @@ -211,6 +207,9 @@ func (assignment *SqlRoleAssignment) updateValidations() []func(old runtime.Obje return assignment.validateResourceReferences() }, assignment.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return assignment.validateOwnerReference() + }, func(old runtime.Object) (admission.Warnings, error) { return assignment.validateOptionalConfigMapReferences() }, @@ -226,6 +225,11 @@ func (assignment *SqlRoleAssignment) validateOptionalConfigMapReferences() (admi return genruntime.ValidateOptionalConfigMapReferences(refs) } +// validateOwnerReference validates the owner field +func (assignment *SqlRoleAssignment) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(assignment) +} + // validateResourceReferences validates all resource references func (assignment *SqlRoleAssignment) validateResourceReferences() (admission.Warnings, error) { refs, err := reflecthelpers.FindResourceReferences(&assignment.Spec) @@ -401,7 +405,10 @@ func (assignment *DatabaseAccounts_SqlRoleAssignment_Spec) PopulateFromARM(owner assignment.SetAzureName(genruntime.ExtractKubernetesResourceNameFromARMName(typedInput.Name)) // Set property "Owner": - assignment.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + assignment.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "PrincipalId": // copying flattened property: diff --git a/v2/api/documentdb/v1api20210515storage/database_account_types_gen.go b/v2/api/documentdb/v1api20210515storage/database_account_types_gen.go index 0f64246b8f0..6125b51361a 100644 --- a/v2/api/documentdb/v1api20210515storage/database_account_types_gen.go +++ b/v2/api/documentdb/v1api20210515storage/database_account_types_gen.go @@ -84,11 +84,7 @@ func (account *DatabaseAccount) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (account *DatabaseAccount) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(account.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: account.Spec.Owner.Name, - } + return account.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/documentdb/v1api20210515storage/mongodb_database_collection_throughput_setting_types_gen.go b/v2/api/documentdb/v1api20210515storage/mongodb_database_collection_throughput_setting_types_gen.go index f384e8cb7ce..03e58c9cc4c 100644 --- a/v2/api/documentdb/v1api20210515storage/mongodb_database_collection_throughput_setting_types_gen.go +++ b/v2/api/documentdb/v1api20210515storage/mongodb_database_collection_throughput_setting_types_gen.go @@ -84,11 +84,7 @@ func (setting *MongodbDatabaseCollectionThroughputSetting) NewEmptyStatus() genr // Owner returns the ResourceReference of the owner func (setting *MongodbDatabaseCollectionThroughputSetting) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(setting.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: setting.Spec.Owner.Name, - } + return setting.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/documentdb/v1api20210515storage/mongodb_database_collection_types_gen.go b/v2/api/documentdb/v1api20210515storage/mongodb_database_collection_types_gen.go index cc240de5b68..8c0576c47fa 100644 --- a/v2/api/documentdb/v1api20210515storage/mongodb_database_collection_types_gen.go +++ b/v2/api/documentdb/v1api20210515storage/mongodb_database_collection_types_gen.go @@ -84,11 +84,7 @@ func (collection *MongodbDatabaseCollection) NewEmptyStatus() genruntime.Convert // Owner returns the ResourceReference of the owner func (collection *MongodbDatabaseCollection) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(collection.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: collection.Spec.Owner.Name, - } + return collection.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/documentdb/v1api20210515storage/mongodb_database_throughput_setting_types_gen.go b/v2/api/documentdb/v1api20210515storage/mongodb_database_throughput_setting_types_gen.go index 361ecb138b5..8fe98b96cdd 100644 --- a/v2/api/documentdb/v1api20210515storage/mongodb_database_throughput_setting_types_gen.go +++ b/v2/api/documentdb/v1api20210515storage/mongodb_database_throughput_setting_types_gen.go @@ -84,11 +84,7 @@ func (setting *MongodbDatabaseThroughputSetting) NewEmptyStatus() genruntime.Con // Owner returns the ResourceReference of the owner func (setting *MongodbDatabaseThroughputSetting) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(setting.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: setting.Spec.Owner.Name, - } + return setting.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/documentdb/v1api20210515storage/mongodb_database_types_gen.go b/v2/api/documentdb/v1api20210515storage/mongodb_database_types_gen.go index b1f52d9a519..1800641703f 100644 --- a/v2/api/documentdb/v1api20210515storage/mongodb_database_types_gen.go +++ b/v2/api/documentdb/v1api20210515storage/mongodb_database_types_gen.go @@ -84,11 +84,7 @@ func (database *MongodbDatabase) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (database *MongodbDatabase) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(database.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: database.Spec.Owner.Name, - } + return database.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/documentdb/v1api20210515storage/sql_database_container_stored_procedure_types_gen.go b/v2/api/documentdb/v1api20210515storage/sql_database_container_stored_procedure_types_gen.go index 363918b84cb..6bb37e0c9d4 100644 --- a/v2/api/documentdb/v1api20210515storage/sql_database_container_stored_procedure_types_gen.go +++ b/v2/api/documentdb/v1api20210515storage/sql_database_container_stored_procedure_types_gen.go @@ -84,11 +84,7 @@ func (procedure *SqlDatabaseContainerStoredProcedure) NewEmptyStatus() genruntim // Owner returns the ResourceReference of the owner func (procedure *SqlDatabaseContainerStoredProcedure) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(procedure.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: procedure.Spec.Owner.Name, - } + return procedure.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/documentdb/v1api20210515storage/sql_database_container_throughput_setting_types_gen.go b/v2/api/documentdb/v1api20210515storage/sql_database_container_throughput_setting_types_gen.go index c0f36d2ec3f..bea2ca1ba46 100644 --- a/v2/api/documentdb/v1api20210515storage/sql_database_container_throughput_setting_types_gen.go +++ b/v2/api/documentdb/v1api20210515storage/sql_database_container_throughput_setting_types_gen.go @@ -84,11 +84,7 @@ func (setting *SqlDatabaseContainerThroughputSetting) NewEmptyStatus() genruntim // Owner returns the ResourceReference of the owner func (setting *SqlDatabaseContainerThroughputSetting) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(setting.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: setting.Spec.Owner.Name, - } + return setting.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/documentdb/v1api20210515storage/sql_database_container_trigger_types_gen.go b/v2/api/documentdb/v1api20210515storage/sql_database_container_trigger_types_gen.go index 50073a30cf4..86933a0532a 100644 --- a/v2/api/documentdb/v1api20210515storage/sql_database_container_trigger_types_gen.go +++ b/v2/api/documentdb/v1api20210515storage/sql_database_container_trigger_types_gen.go @@ -84,11 +84,7 @@ func (trigger *SqlDatabaseContainerTrigger) NewEmptyStatus() genruntime.Converti // Owner returns the ResourceReference of the owner func (trigger *SqlDatabaseContainerTrigger) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(trigger.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: trigger.Spec.Owner.Name, - } + return trigger.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/documentdb/v1api20210515storage/sql_database_container_types_gen.go b/v2/api/documentdb/v1api20210515storage/sql_database_container_types_gen.go index 9f63d02e7e6..8a450706269 100644 --- a/v2/api/documentdb/v1api20210515storage/sql_database_container_types_gen.go +++ b/v2/api/documentdb/v1api20210515storage/sql_database_container_types_gen.go @@ -84,11 +84,7 @@ func (container *SqlDatabaseContainer) NewEmptyStatus() genruntime.ConvertibleSt // Owner returns the ResourceReference of the owner func (container *SqlDatabaseContainer) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(container.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: container.Spec.Owner.Name, - } + return container.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/documentdb/v1api20210515storage/sql_database_container_user_defined_function_types_gen.go b/v2/api/documentdb/v1api20210515storage/sql_database_container_user_defined_function_types_gen.go index 4db911453ef..adcf7104b17 100644 --- a/v2/api/documentdb/v1api20210515storage/sql_database_container_user_defined_function_types_gen.go +++ b/v2/api/documentdb/v1api20210515storage/sql_database_container_user_defined_function_types_gen.go @@ -84,11 +84,7 @@ func (function *SqlDatabaseContainerUserDefinedFunction) NewEmptyStatus() genrun // Owner returns the ResourceReference of the owner func (function *SqlDatabaseContainerUserDefinedFunction) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(function.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: function.Spec.Owner.Name, - } + return function.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/documentdb/v1api20210515storage/sql_database_throughput_setting_types_gen.go b/v2/api/documentdb/v1api20210515storage/sql_database_throughput_setting_types_gen.go index ebbf0f5da2b..05d3286ff6f 100644 --- a/v2/api/documentdb/v1api20210515storage/sql_database_throughput_setting_types_gen.go +++ b/v2/api/documentdb/v1api20210515storage/sql_database_throughput_setting_types_gen.go @@ -84,11 +84,7 @@ func (setting *SqlDatabaseThroughputSetting) NewEmptyStatus() genruntime.Convert // Owner returns the ResourceReference of the owner func (setting *SqlDatabaseThroughputSetting) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(setting.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: setting.Spec.Owner.Name, - } + return setting.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/documentdb/v1api20210515storage/sql_database_types_gen.go b/v2/api/documentdb/v1api20210515storage/sql_database_types_gen.go index 939b32277f9..908f52b29be 100644 --- a/v2/api/documentdb/v1api20210515storage/sql_database_types_gen.go +++ b/v2/api/documentdb/v1api20210515storage/sql_database_types_gen.go @@ -84,11 +84,7 @@ func (database *SqlDatabase) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (database *SqlDatabase) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(database.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: database.Spec.Owner.Name, - } + return database.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/documentdb/v1api20210515storage/sql_role_assignment_types_gen.go b/v2/api/documentdb/v1api20210515storage/sql_role_assignment_types_gen.go index eb6edaa028a..66ede3c9cb3 100644 --- a/v2/api/documentdb/v1api20210515storage/sql_role_assignment_types_gen.go +++ b/v2/api/documentdb/v1api20210515storage/sql_role_assignment_types_gen.go @@ -84,11 +84,7 @@ func (assignment *SqlRoleAssignment) NewEmptyStatus() genruntime.ConvertibleStat // Owner returns the ResourceReference of the owner func (assignment *SqlRoleAssignment) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(assignment.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: assignment.Spec.Owner.Name, - } + return assignment.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/documentdb/v1beta20210515/database_account_types_gen.go b/v2/api/documentdb/v1beta20210515/database_account_types_gen.go index c0e00487478..71462846532 100644 --- a/v2/api/documentdb/v1beta20210515/database_account_types_gen.go +++ b/v2/api/documentdb/v1beta20210515/database_account_types_gen.go @@ -142,11 +142,7 @@ func (account *DatabaseAccount) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (account *DatabaseAccount) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(account.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: account.Spec.Owner.Name, - } + return account.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -204,7 +200,7 @@ func (account *DatabaseAccount) ValidateUpdate(old runtime.Object) (admission.Wa // createValidations validates the creation of the resource func (account *DatabaseAccount) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){account.validateResourceReferences, account.validateSecretDestinations} + return []func() (admission.Warnings, error){account.validateResourceReferences, account.validateOwnerReference, account.validateSecretDestinations} } // deleteValidations validates the deletion of the resource @@ -219,12 +215,20 @@ func (account *DatabaseAccount) updateValidations() []func(old runtime.Object) ( return account.validateResourceReferences() }, account.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return account.validateOwnerReference() + }, func(old runtime.Object) (admission.Warnings, error) { return account.validateSecretDestinations() }, } } +// validateOwnerReference validates the owner field +func (account *DatabaseAccount) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(account) +} + // validateResourceReferences validates all resource references func (account *DatabaseAccount) validateResourceReferences() (admission.Warnings, error) { refs, err := reflecthelpers.FindResourceReferences(&account.Spec) @@ -846,7 +850,10 @@ func (account *DatabaseAccount_Spec) PopulateFromARM(owner genruntime.ArbitraryO // no assignment for property "OperatorSpec" // Set property "Owner": - account.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + account.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "PublicNetworkAccess": // copying flattened property: diff --git a/v2/api/documentdb/v1beta20210515/mongodb_database_collection_throughput_setting_types_gen.go b/v2/api/documentdb/v1beta20210515/mongodb_database_collection_throughput_setting_types_gen.go index 8b71a1f844c..31ece3da1ae 100644 --- a/v2/api/documentdb/v1beta20210515/mongodb_database_collection_throughput_setting_types_gen.go +++ b/v2/api/documentdb/v1beta20210515/mongodb_database_collection_throughput_setting_types_gen.go @@ -135,11 +135,7 @@ func (setting *MongodbDatabaseCollectionThroughputSetting) NewEmptyStatus() genr // Owner returns the ResourceReference of the owner func (setting *MongodbDatabaseCollectionThroughputSetting) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(setting.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: setting.Spec.Owner.Name, - } + return setting.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -197,7 +193,7 @@ func (setting *MongodbDatabaseCollectionThroughputSetting) ValidateUpdate(old ru // createValidations validates the creation of the resource func (setting *MongodbDatabaseCollectionThroughputSetting) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){setting.validateResourceReferences} + return []func() (admission.Warnings, error){setting.validateResourceReferences, setting.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -211,7 +207,16 @@ func (setting *MongodbDatabaseCollectionThroughputSetting) updateValidations() [ func(old runtime.Object) (admission.Warnings, error) { return setting.validateResourceReferences() }, - setting.validateWriteOnceProperties} + setting.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return setting.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (setting *MongodbDatabaseCollectionThroughputSetting) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(setting) } // validateResourceReferences validates all resource references @@ -376,7 +381,10 @@ func (setting *DatabaseAccounts_MongodbDatabases_Collections_ThroughputSetting_S } // Set property "Owner": - setting.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + setting.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "Resource": // copying flattened property: diff --git a/v2/api/documentdb/v1beta20210515/mongodb_database_collection_types_gen.go b/v2/api/documentdb/v1beta20210515/mongodb_database_collection_types_gen.go index 7756c2ccea1..9947ae7f281 100644 --- a/v2/api/documentdb/v1beta20210515/mongodb_database_collection_types_gen.go +++ b/v2/api/documentdb/v1beta20210515/mongodb_database_collection_types_gen.go @@ -142,11 +142,7 @@ func (collection *MongodbDatabaseCollection) NewEmptyStatus() genruntime.Convert // Owner returns the ResourceReference of the owner func (collection *MongodbDatabaseCollection) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(collection.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: collection.Spec.Owner.Name, - } + return collection.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -204,7 +200,7 @@ func (collection *MongodbDatabaseCollection) ValidateUpdate(old runtime.Object) // createValidations validates the creation of the resource func (collection *MongodbDatabaseCollection) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){collection.validateResourceReferences} + return []func() (admission.Warnings, error){collection.validateResourceReferences, collection.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -218,7 +214,16 @@ func (collection *MongodbDatabaseCollection) updateValidations() []func(old runt func(old runtime.Object) (admission.Warnings, error) { return collection.validateResourceReferences() }, - collection.validateWriteOnceProperties} + collection.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return collection.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (collection *MongodbDatabaseCollection) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(collection) } // validateResourceReferences validates all resource references @@ -412,7 +417,10 @@ func (collection *DatabaseAccounts_MongodbDatabases_Collection_Spec) PopulateFro } // Set property "Owner": - collection.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + collection.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "Resource": // copying flattened property: diff --git a/v2/api/documentdb/v1beta20210515/mongodb_database_throughput_setting_types_gen.go b/v2/api/documentdb/v1beta20210515/mongodb_database_throughput_setting_types_gen.go index abc93eeca9b..fecd2a1eb62 100644 --- a/v2/api/documentdb/v1beta20210515/mongodb_database_throughput_setting_types_gen.go +++ b/v2/api/documentdb/v1beta20210515/mongodb_database_throughput_setting_types_gen.go @@ -135,11 +135,7 @@ func (setting *MongodbDatabaseThroughputSetting) NewEmptyStatus() genruntime.Con // Owner returns the ResourceReference of the owner func (setting *MongodbDatabaseThroughputSetting) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(setting.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: setting.Spec.Owner.Name, - } + return setting.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -197,7 +193,7 @@ func (setting *MongodbDatabaseThroughputSetting) ValidateUpdate(old runtime.Obje // createValidations validates the creation of the resource func (setting *MongodbDatabaseThroughputSetting) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){setting.validateResourceReferences} + return []func() (admission.Warnings, error){setting.validateResourceReferences, setting.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -211,7 +207,16 @@ func (setting *MongodbDatabaseThroughputSetting) updateValidations() []func(old func(old runtime.Object) (admission.Warnings, error) { return setting.validateResourceReferences() }, - setting.validateWriteOnceProperties} + setting.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return setting.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (setting *MongodbDatabaseThroughputSetting) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(setting) } // validateResourceReferences validates all resource references @@ -376,7 +381,10 @@ func (setting *DatabaseAccounts_MongodbDatabases_ThroughputSetting_Spec) Populat } // Set property "Owner": - setting.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + setting.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "Resource": // copying flattened property: diff --git a/v2/api/documentdb/v1beta20210515/mongodb_database_types_gen.go b/v2/api/documentdb/v1beta20210515/mongodb_database_types_gen.go index bf03e9c162c..4e046acbf23 100644 --- a/v2/api/documentdb/v1beta20210515/mongodb_database_types_gen.go +++ b/v2/api/documentdb/v1beta20210515/mongodb_database_types_gen.go @@ -142,11 +142,7 @@ func (database *MongodbDatabase) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (database *MongodbDatabase) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(database.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: database.Spec.Owner.Name, - } + return database.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -204,7 +200,7 @@ func (database *MongodbDatabase) ValidateUpdate(old runtime.Object) (admission.W // createValidations validates the creation of the resource func (database *MongodbDatabase) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){database.validateResourceReferences} + return []func() (admission.Warnings, error){database.validateResourceReferences, database.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -218,7 +214,16 @@ func (database *MongodbDatabase) updateValidations() []func(old runtime.Object) func(old runtime.Object) (admission.Warnings, error) { return database.validateResourceReferences() }, - database.validateWriteOnceProperties} + database.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return database.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (database *MongodbDatabase) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(database) } // validateResourceReferences validates all resource references @@ -412,7 +417,10 @@ func (database *DatabaseAccounts_MongodbDatabase_Spec) PopulateFromARM(owner gen } // Set property "Owner": - database.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + database.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "Resource": // copying flattened property: diff --git a/v2/api/documentdb/v1beta20210515/sql_database_container_stored_procedure_types_gen.go b/v2/api/documentdb/v1beta20210515/sql_database_container_stored_procedure_types_gen.go index 51defd23f93..903b3c3e9d1 100644 --- a/v2/api/documentdb/v1beta20210515/sql_database_container_stored_procedure_types_gen.go +++ b/v2/api/documentdb/v1beta20210515/sql_database_container_stored_procedure_types_gen.go @@ -142,11 +142,7 @@ func (procedure *SqlDatabaseContainerStoredProcedure) NewEmptyStatus() genruntim // Owner returns the ResourceReference of the owner func (procedure *SqlDatabaseContainerStoredProcedure) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(procedure.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: procedure.Spec.Owner.Name, - } + return procedure.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -204,7 +200,7 @@ func (procedure *SqlDatabaseContainerStoredProcedure) ValidateUpdate(old runtime // createValidations validates the creation of the resource func (procedure *SqlDatabaseContainerStoredProcedure) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){procedure.validateResourceReferences} + return []func() (admission.Warnings, error){procedure.validateResourceReferences, procedure.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -218,7 +214,16 @@ func (procedure *SqlDatabaseContainerStoredProcedure) updateValidations() []func func(old runtime.Object) (admission.Warnings, error) { return procedure.validateResourceReferences() }, - procedure.validateWriteOnceProperties} + procedure.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return procedure.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (procedure *SqlDatabaseContainerStoredProcedure) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(procedure) } // validateResourceReferences validates all resource references @@ -412,7 +417,10 @@ func (procedure *DatabaseAccounts_SqlDatabases_Containers_StoredProcedure_Spec) } // Set property "Owner": - procedure.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + procedure.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "Resource": // copying flattened property: diff --git a/v2/api/documentdb/v1beta20210515/sql_database_container_throughput_setting_types_gen.go b/v2/api/documentdb/v1beta20210515/sql_database_container_throughput_setting_types_gen.go index b87206683e8..7418ebd3695 100644 --- a/v2/api/documentdb/v1beta20210515/sql_database_container_throughput_setting_types_gen.go +++ b/v2/api/documentdb/v1beta20210515/sql_database_container_throughput_setting_types_gen.go @@ -135,11 +135,7 @@ func (setting *SqlDatabaseContainerThroughputSetting) NewEmptyStatus() genruntim // Owner returns the ResourceReference of the owner func (setting *SqlDatabaseContainerThroughputSetting) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(setting.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: setting.Spec.Owner.Name, - } + return setting.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -197,7 +193,7 @@ func (setting *SqlDatabaseContainerThroughputSetting) ValidateUpdate(old runtime // createValidations validates the creation of the resource func (setting *SqlDatabaseContainerThroughputSetting) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){setting.validateResourceReferences} + return []func() (admission.Warnings, error){setting.validateResourceReferences, setting.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -211,7 +207,16 @@ func (setting *SqlDatabaseContainerThroughputSetting) updateValidations() []func func(old runtime.Object) (admission.Warnings, error) { return setting.validateResourceReferences() }, - setting.validateWriteOnceProperties} + setting.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return setting.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (setting *SqlDatabaseContainerThroughputSetting) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(setting) } // validateResourceReferences validates all resource references @@ -376,7 +381,10 @@ func (setting *DatabaseAccounts_SqlDatabases_Containers_ThroughputSetting_Spec) } // Set property "Owner": - setting.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + setting.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "Resource": // copying flattened property: diff --git a/v2/api/documentdb/v1beta20210515/sql_database_container_trigger_types_gen.go b/v2/api/documentdb/v1beta20210515/sql_database_container_trigger_types_gen.go index b4c57185b86..3ba8c3b89f2 100644 --- a/v2/api/documentdb/v1beta20210515/sql_database_container_trigger_types_gen.go +++ b/v2/api/documentdb/v1beta20210515/sql_database_container_trigger_types_gen.go @@ -142,11 +142,7 @@ func (trigger *SqlDatabaseContainerTrigger) NewEmptyStatus() genruntime.Converti // Owner returns the ResourceReference of the owner func (trigger *SqlDatabaseContainerTrigger) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(trigger.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: trigger.Spec.Owner.Name, - } + return trigger.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -204,7 +200,7 @@ func (trigger *SqlDatabaseContainerTrigger) ValidateUpdate(old runtime.Object) ( // createValidations validates the creation of the resource func (trigger *SqlDatabaseContainerTrigger) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){trigger.validateResourceReferences} + return []func() (admission.Warnings, error){trigger.validateResourceReferences, trigger.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -218,7 +214,16 @@ func (trigger *SqlDatabaseContainerTrigger) updateValidations() []func(old runti func(old runtime.Object) (admission.Warnings, error) { return trigger.validateResourceReferences() }, - trigger.validateWriteOnceProperties} + trigger.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return trigger.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (trigger *SqlDatabaseContainerTrigger) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(trigger) } // validateResourceReferences validates all resource references @@ -412,7 +417,10 @@ func (trigger *DatabaseAccounts_SqlDatabases_Containers_Trigger_Spec) PopulateFr } // Set property "Owner": - trigger.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + trigger.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "Resource": // copying flattened property: diff --git a/v2/api/documentdb/v1beta20210515/sql_database_container_types_gen.go b/v2/api/documentdb/v1beta20210515/sql_database_container_types_gen.go index aee1be93a9c..132ffd4f939 100644 --- a/v2/api/documentdb/v1beta20210515/sql_database_container_types_gen.go +++ b/v2/api/documentdb/v1beta20210515/sql_database_container_types_gen.go @@ -142,11 +142,7 @@ func (container *SqlDatabaseContainer) NewEmptyStatus() genruntime.ConvertibleSt // Owner returns the ResourceReference of the owner func (container *SqlDatabaseContainer) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(container.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: container.Spec.Owner.Name, - } + return container.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -204,7 +200,7 @@ func (container *SqlDatabaseContainer) ValidateUpdate(old runtime.Object) (admis // createValidations validates the creation of the resource func (container *SqlDatabaseContainer) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){container.validateResourceReferences} + return []func() (admission.Warnings, error){container.validateResourceReferences, container.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -218,7 +214,16 @@ func (container *SqlDatabaseContainer) updateValidations() []func(old runtime.Ob func(old runtime.Object) (admission.Warnings, error) { return container.validateResourceReferences() }, - container.validateWriteOnceProperties} + container.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return container.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (container *SqlDatabaseContainer) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(container) } // validateResourceReferences validates all resource references @@ -412,7 +417,10 @@ func (container *DatabaseAccounts_SqlDatabases_Container_Spec) PopulateFromARM(o } // Set property "Owner": - container.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + container.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "Resource": // copying flattened property: diff --git a/v2/api/documentdb/v1beta20210515/sql_database_container_user_defined_function_types_gen.go b/v2/api/documentdb/v1beta20210515/sql_database_container_user_defined_function_types_gen.go index 57548c2eb6d..93ecb8fb843 100644 --- a/v2/api/documentdb/v1beta20210515/sql_database_container_user_defined_function_types_gen.go +++ b/v2/api/documentdb/v1beta20210515/sql_database_container_user_defined_function_types_gen.go @@ -142,11 +142,7 @@ func (function *SqlDatabaseContainerUserDefinedFunction) NewEmptyStatus() genrun // Owner returns the ResourceReference of the owner func (function *SqlDatabaseContainerUserDefinedFunction) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(function.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: function.Spec.Owner.Name, - } + return function.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -204,7 +200,7 @@ func (function *SqlDatabaseContainerUserDefinedFunction) ValidateUpdate(old runt // createValidations validates the creation of the resource func (function *SqlDatabaseContainerUserDefinedFunction) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){function.validateResourceReferences} + return []func() (admission.Warnings, error){function.validateResourceReferences, function.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -218,7 +214,16 @@ func (function *SqlDatabaseContainerUserDefinedFunction) updateValidations() []f func(old runtime.Object) (admission.Warnings, error) { return function.validateResourceReferences() }, - function.validateWriteOnceProperties} + function.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return function.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (function *SqlDatabaseContainerUserDefinedFunction) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(function) } // validateResourceReferences validates all resource references @@ -412,7 +417,10 @@ func (function *DatabaseAccounts_SqlDatabases_Containers_UserDefinedFunction_Spe } // Set property "Owner": - function.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + function.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "Resource": // copying flattened property: diff --git a/v2/api/documentdb/v1beta20210515/sql_database_throughput_setting_types_gen.go b/v2/api/documentdb/v1beta20210515/sql_database_throughput_setting_types_gen.go index 30dffcd0176..a387c4c5329 100644 --- a/v2/api/documentdb/v1beta20210515/sql_database_throughput_setting_types_gen.go +++ b/v2/api/documentdb/v1beta20210515/sql_database_throughput_setting_types_gen.go @@ -135,11 +135,7 @@ func (setting *SqlDatabaseThroughputSetting) NewEmptyStatus() genruntime.Convert // Owner returns the ResourceReference of the owner func (setting *SqlDatabaseThroughputSetting) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(setting.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: setting.Spec.Owner.Name, - } + return setting.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -197,7 +193,7 @@ func (setting *SqlDatabaseThroughputSetting) ValidateUpdate(old runtime.Object) // createValidations validates the creation of the resource func (setting *SqlDatabaseThroughputSetting) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){setting.validateResourceReferences} + return []func() (admission.Warnings, error){setting.validateResourceReferences, setting.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -211,7 +207,16 @@ func (setting *SqlDatabaseThroughputSetting) updateValidations() []func(old runt func(old runtime.Object) (admission.Warnings, error) { return setting.validateResourceReferences() }, - setting.validateWriteOnceProperties} + setting.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return setting.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (setting *SqlDatabaseThroughputSetting) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(setting) } // validateResourceReferences validates all resource references @@ -376,7 +381,10 @@ func (setting *DatabaseAccounts_SqlDatabases_ThroughputSetting_Spec) PopulateFro } // Set property "Owner": - setting.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + setting.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "Resource": // copying flattened property: diff --git a/v2/api/documentdb/v1beta20210515/sql_database_types_gen.go b/v2/api/documentdb/v1beta20210515/sql_database_types_gen.go index 9317aeabd13..573a74aa838 100644 --- a/v2/api/documentdb/v1beta20210515/sql_database_types_gen.go +++ b/v2/api/documentdb/v1beta20210515/sql_database_types_gen.go @@ -142,11 +142,7 @@ func (database *SqlDatabase) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (database *SqlDatabase) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(database.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: database.Spec.Owner.Name, - } + return database.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -204,7 +200,7 @@ func (database *SqlDatabase) ValidateUpdate(old runtime.Object) (admission.Warni // createValidations validates the creation of the resource func (database *SqlDatabase) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){database.validateResourceReferences} + return []func() (admission.Warnings, error){database.validateResourceReferences, database.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -218,7 +214,16 @@ func (database *SqlDatabase) updateValidations() []func(old runtime.Object) (adm func(old runtime.Object) (admission.Warnings, error) { return database.validateResourceReferences() }, - database.validateWriteOnceProperties} + database.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return database.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (database *SqlDatabase) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(database) } // validateResourceReferences validates all resource references @@ -412,7 +417,10 @@ func (database *DatabaseAccounts_SqlDatabase_Spec) PopulateFromARM(owner genrunt } // Set property "Owner": - database.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + database.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "Resource": // copying flattened property: diff --git a/v2/api/documentdb/v1beta20210515/sql_role_assignment_types_gen.go b/v2/api/documentdb/v1beta20210515/sql_role_assignment_types_gen.go index adbc075f6b6..a2e5b094848 100644 --- a/v2/api/documentdb/v1beta20210515/sql_role_assignment_types_gen.go +++ b/v2/api/documentdb/v1beta20210515/sql_role_assignment_types_gen.go @@ -135,11 +135,7 @@ func (assignment *SqlRoleAssignment) NewEmptyStatus() genruntime.ConvertibleStat // Owner returns the ResourceReference of the owner func (assignment *SqlRoleAssignment) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(assignment.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: assignment.Spec.Owner.Name, - } + return assignment.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -197,7 +193,7 @@ func (assignment *SqlRoleAssignment) ValidateUpdate(old runtime.Object) (admissi // createValidations validates the creation of the resource func (assignment *SqlRoleAssignment) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){assignment.validateResourceReferences, assignment.validateOptionalConfigMapReferences} + return []func() (admission.Warnings, error){assignment.validateResourceReferences, assignment.validateOwnerReference, assignment.validateOptionalConfigMapReferences} } // deleteValidations validates the deletion of the resource @@ -212,6 +208,9 @@ func (assignment *SqlRoleAssignment) updateValidations() []func(old runtime.Obje return assignment.validateResourceReferences() }, assignment.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return assignment.validateOwnerReference() + }, func(old runtime.Object) (admission.Warnings, error) { return assignment.validateOptionalConfigMapReferences() }, @@ -227,6 +226,11 @@ func (assignment *SqlRoleAssignment) validateOptionalConfigMapReferences() (admi return genruntime.ValidateOptionalConfigMapReferences(refs) } +// validateOwnerReference validates the owner field +func (assignment *SqlRoleAssignment) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(assignment) +} + // validateResourceReferences validates all resource references func (assignment *SqlRoleAssignment) validateResourceReferences() (admission.Warnings, error) { refs, err := reflecthelpers.FindResourceReferences(&assignment.Spec) @@ -389,7 +393,10 @@ func (assignment *DatabaseAccounts_SqlRoleAssignment_Spec) PopulateFromARM(owner assignment.SetAzureName(genruntime.ExtractKubernetesResourceNameFromARMName(typedInput.Name)) // Set property "Owner": - assignment.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + assignment.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "PrincipalId": // copying flattened property: diff --git a/v2/api/documentdb/v1beta20210515storage/database_account_types_gen.go b/v2/api/documentdb/v1beta20210515storage/database_account_types_gen.go index 87df5a2d517..6c936bfde0b 100644 --- a/v2/api/documentdb/v1beta20210515storage/database_account_types_gen.go +++ b/v2/api/documentdb/v1beta20210515storage/database_account_types_gen.go @@ -103,11 +103,7 @@ func (account *DatabaseAccount) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (account *DatabaseAccount) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(account.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: account.Spec.Owner.Name, - } + return account.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/documentdb/v1beta20210515storage/mongodb_database_collection_throughput_setting_types_gen.go b/v2/api/documentdb/v1beta20210515storage/mongodb_database_collection_throughput_setting_types_gen.go index aeab6a38162..e2f69e8d94c 100644 --- a/v2/api/documentdb/v1beta20210515storage/mongodb_database_collection_throughput_setting_types_gen.go +++ b/v2/api/documentdb/v1beta20210515storage/mongodb_database_collection_throughput_setting_types_gen.go @@ -103,11 +103,7 @@ func (setting *MongodbDatabaseCollectionThroughputSetting) NewEmptyStatus() genr // Owner returns the ResourceReference of the owner func (setting *MongodbDatabaseCollectionThroughputSetting) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(setting.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: setting.Spec.Owner.Name, - } + return setting.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/documentdb/v1beta20210515storage/mongodb_database_collection_types_gen.go b/v2/api/documentdb/v1beta20210515storage/mongodb_database_collection_types_gen.go index dd43e71fe1b..129c22ebff9 100644 --- a/v2/api/documentdb/v1beta20210515storage/mongodb_database_collection_types_gen.go +++ b/v2/api/documentdb/v1beta20210515storage/mongodb_database_collection_types_gen.go @@ -103,11 +103,7 @@ func (collection *MongodbDatabaseCollection) NewEmptyStatus() genruntime.Convert // Owner returns the ResourceReference of the owner func (collection *MongodbDatabaseCollection) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(collection.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: collection.Spec.Owner.Name, - } + return collection.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/documentdb/v1beta20210515storage/mongodb_database_throughput_setting_types_gen.go b/v2/api/documentdb/v1beta20210515storage/mongodb_database_throughput_setting_types_gen.go index da76990e891..ea67825b30d 100644 --- a/v2/api/documentdb/v1beta20210515storage/mongodb_database_throughput_setting_types_gen.go +++ b/v2/api/documentdb/v1beta20210515storage/mongodb_database_throughput_setting_types_gen.go @@ -103,11 +103,7 @@ func (setting *MongodbDatabaseThroughputSetting) NewEmptyStatus() genruntime.Con // Owner returns the ResourceReference of the owner func (setting *MongodbDatabaseThroughputSetting) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(setting.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: setting.Spec.Owner.Name, - } + return setting.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/documentdb/v1beta20210515storage/mongodb_database_types_gen.go b/v2/api/documentdb/v1beta20210515storage/mongodb_database_types_gen.go index 7d941bd6db3..14b5d40be91 100644 --- a/v2/api/documentdb/v1beta20210515storage/mongodb_database_types_gen.go +++ b/v2/api/documentdb/v1beta20210515storage/mongodb_database_types_gen.go @@ -103,11 +103,7 @@ func (database *MongodbDatabase) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (database *MongodbDatabase) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(database.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: database.Spec.Owner.Name, - } + return database.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/documentdb/v1beta20210515storage/sql_database_container_stored_procedure_types_gen.go b/v2/api/documentdb/v1beta20210515storage/sql_database_container_stored_procedure_types_gen.go index c2cb279bab8..98d6991b10a 100644 --- a/v2/api/documentdb/v1beta20210515storage/sql_database_container_stored_procedure_types_gen.go +++ b/v2/api/documentdb/v1beta20210515storage/sql_database_container_stored_procedure_types_gen.go @@ -103,11 +103,7 @@ func (procedure *SqlDatabaseContainerStoredProcedure) NewEmptyStatus() genruntim // Owner returns the ResourceReference of the owner func (procedure *SqlDatabaseContainerStoredProcedure) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(procedure.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: procedure.Spec.Owner.Name, - } + return procedure.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/documentdb/v1beta20210515storage/sql_database_container_throughput_setting_types_gen.go b/v2/api/documentdb/v1beta20210515storage/sql_database_container_throughput_setting_types_gen.go index 99b79ca0863..672712cf8ce 100644 --- a/v2/api/documentdb/v1beta20210515storage/sql_database_container_throughput_setting_types_gen.go +++ b/v2/api/documentdb/v1beta20210515storage/sql_database_container_throughput_setting_types_gen.go @@ -103,11 +103,7 @@ func (setting *SqlDatabaseContainerThroughputSetting) NewEmptyStatus() genruntim // Owner returns the ResourceReference of the owner func (setting *SqlDatabaseContainerThroughputSetting) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(setting.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: setting.Spec.Owner.Name, - } + return setting.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/documentdb/v1beta20210515storage/sql_database_container_trigger_types_gen.go b/v2/api/documentdb/v1beta20210515storage/sql_database_container_trigger_types_gen.go index e825fea694a..4018fb4bcc1 100644 --- a/v2/api/documentdb/v1beta20210515storage/sql_database_container_trigger_types_gen.go +++ b/v2/api/documentdb/v1beta20210515storage/sql_database_container_trigger_types_gen.go @@ -103,11 +103,7 @@ func (trigger *SqlDatabaseContainerTrigger) NewEmptyStatus() genruntime.Converti // Owner returns the ResourceReference of the owner func (trigger *SqlDatabaseContainerTrigger) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(trigger.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: trigger.Spec.Owner.Name, - } + return trigger.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/documentdb/v1beta20210515storage/sql_database_container_types_gen.go b/v2/api/documentdb/v1beta20210515storage/sql_database_container_types_gen.go index ca09c8eec33..e53e43258f3 100644 --- a/v2/api/documentdb/v1beta20210515storage/sql_database_container_types_gen.go +++ b/v2/api/documentdb/v1beta20210515storage/sql_database_container_types_gen.go @@ -103,11 +103,7 @@ func (container *SqlDatabaseContainer) NewEmptyStatus() genruntime.ConvertibleSt // Owner returns the ResourceReference of the owner func (container *SqlDatabaseContainer) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(container.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: container.Spec.Owner.Name, - } + return container.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/documentdb/v1beta20210515storage/sql_database_container_user_defined_function_types_gen.go b/v2/api/documentdb/v1beta20210515storage/sql_database_container_user_defined_function_types_gen.go index 9cfb47b2c1d..fc0f2c7b1ff 100644 --- a/v2/api/documentdb/v1beta20210515storage/sql_database_container_user_defined_function_types_gen.go +++ b/v2/api/documentdb/v1beta20210515storage/sql_database_container_user_defined_function_types_gen.go @@ -103,11 +103,7 @@ func (function *SqlDatabaseContainerUserDefinedFunction) NewEmptyStatus() genrun // Owner returns the ResourceReference of the owner func (function *SqlDatabaseContainerUserDefinedFunction) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(function.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: function.Spec.Owner.Name, - } + return function.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/documentdb/v1beta20210515storage/sql_database_throughput_setting_types_gen.go b/v2/api/documentdb/v1beta20210515storage/sql_database_throughput_setting_types_gen.go index 94a3c90b23b..e7bbcd0eeba 100644 --- a/v2/api/documentdb/v1beta20210515storage/sql_database_throughput_setting_types_gen.go +++ b/v2/api/documentdb/v1beta20210515storage/sql_database_throughput_setting_types_gen.go @@ -103,11 +103,7 @@ func (setting *SqlDatabaseThroughputSetting) NewEmptyStatus() genruntime.Convert // Owner returns the ResourceReference of the owner func (setting *SqlDatabaseThroughputSetting) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(setting.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: setting.Spec.Owner.Name, - } + return setting.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/documentdb/v1beta20210515storage/sql_database_types_gen.go b/v2/api/documentdb/v1beta20210515storage/sql_database_types_gen.go index 8b3a116cdb3..51c7d043c19 100644 --- a/v2/api/documentdb/v1beta20210515storage/sql_database_types_gen.go +++ b/v2/api/documentdb/v1beta20210515storage/sql_database_types_gen.go @@ -103,11 +103,7 @@ func (database *SqlDatabase) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (database *SqlDatabase) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(database.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: database.Spec.Owner.Name, - } + return database.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/documentdb/v1beta20210515storage/sql_role_assignment_types_gen.go b/v2/api/documentdb/v1beta20210515storage/sql_role_assignment_types_gen.go index c0d30e51dc3..e647c883aca 100644 --- a/v2/api/documentdb/v1beta20210515storage/sql_role_assignment_types_gen.go +++ b/v2/api/documentdb/v1beta20210515storage/sql_role_assignment_types_gen.go @@ -103,11 +103,7 @@ func (assignment *SqlRoleAssignment) NewEmptyStatus() genruntime.ConvertibleStat // Owner returns the ResourceReference of the owner func (assignment *SqlRoleAssignment) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(assignment.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: assignment.Spec.Owner.Name, - } + return assignment.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/eventgrid/v1api20200601/domain_types_gen.go b/v2/api/eventgrid/v1api20200601/domain_types_gen.go index ec9cfe086f0..cf8a0b583cf 100644 --- a/v2/api/eventgrid/v1api20200601/domain_types_gen.go +++ b/v2/api/eventgrid/v1api20200601/domain_types_gen.go @@ -141,11 +141,7 @@ func (domain *Domain) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (domain *Domain) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(domain.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: domain.Spec.Owner.Name, - } + return domain.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -203,7 +199,7 @@ func (domain *Domain) ValidateUpdate(old runtime.Object) (admission.Warnings, er // createValidations validates the creation of the resource func (domain *Domain) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){domain.validateResourceReferences} + return []func() (admission.Warnings, error){domain.validateResourceReferences, domain.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -217,7 +213,16 @@ func (domain *Domain) updateValidations() []func(old runtime.Object) (admission. func(old runtime.Object) (admission.Warnings, error) { return domain.validateResourceReferences() }, - domain.validateWriteOnceProperties} + domain.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return domain.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (domain *Domain) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(domain) } // validateResourceReferences validates all resource references @@ -466,7 +471,10 @@ func (domain *Domain_Spec) PopulateFromARM(owner genruntime.ArbitraryOwnerRefere } // Set property "Owner": - domain.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + domain.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "PublicNetworkAccess": // copying flattened property: diff --git a/v2/api/eventgrid/v1api20200601/domains_topic_types_gen.go b/v2/api/eventgrid/v1api20200601/domains_topic_types_gen.go index 83f06e7ac0f..831101a886c 100644 --- a/v2/api/eventgrid/v1api20200601/domains_topic_types_gen.go +++ b/v2/api/eventgrid/v1api20200601/domains_topic_types_gen.go @@ -141,11 +141,7 @@ func (topic *DomainsTopic) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (topic *DomainsTopic) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(topic.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: topic.Spec.Owner.Name, - } + return topic.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -203,7 +199,7 @@ func (topic *DomainsTopic) ValidateUpdate(old runtime.Object) (admission.Warning // createValidations validates the creation of the resource func (topic *DomainsTopic) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){topic.validateResourceReferences} + return []func() (admission.Warnings, error){topic.validateResourceReferences, topic.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -217,7 +213,16 @@ func (topic *DomainsTopic) updateValidations() []func(old runtime.Object) (admis func(old runtime.Object) (admission.Warnings, error) { return topic.validateResourceReferences() }, - topic.validateWriteOnceProperties} + topic.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return topic.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (topic *DomainsTopic) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(topic) } // validateResourceReferences validates all resource references @@ -352,7 +357,10 @@ func (topic *Domains_Topic_Spec) PopulateFromARM(owner genruntime.ArbitraryOwner topic.SetAzureName(genruntime.ExtractKubernetesResourceNameFromARMName(typedInput.Name)) // Set property "Owner": - topic.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + topic.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // No error return nil diff --git a/v2/api/eventgrid/v1api20200601/event_subscription_types_gen.go b/v2/api/eventgrid/v1api20200601/event_subscription_types_gen.go index 615e0bfc9c8..a0ae7f79136 100644 --- a/v2/api/eventgrid/v1api20200601/event_subscription_types_gen.go +++ b/v2/api/eventgrid/v1api20200601/event_subscription_types_gen.go @@ -140,11 +140,7 @@ func (subscription *EventSubscription) NewEmptyStatus() genruntime.ConvertibleSt // Owner returns the ResourceReference of the owner func (subscription *EventSubscription) Owner() *genruntime.ResourceReference { - return &genruntime.ResourceReference{ - Group: subscription.Spec.Owner.Group, - Kind: subscription.Spec.Owner.Kind, - Name: subscription.Spec.Owner.Name, - } + return subscription.Spec.Owner.AsResourceReference() } // SetStatus sets the status of this resource diff --git a/v2/api/eventgrid/v1api20200601/topic_types_gen.go b/v2/api/eventgrid/v1api20200601/topic_types_gen.go index ff32774a524..59799514ab1 100644 --- a/v2/api/eventgrid/v1api20200601/topic_types_gen.go +++ b/v2/api/eventgrid/v1api20200601/topic_types_gen.go @@ -141,11 +141,7 @@ func (topic *Topic) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (topic *Topic) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(topic.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: topic.Spec.Owner.Name, - } + return topic.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -203,7 +199,7 @@ func (topic *Topic) ValidateUpdate(old runtime.Object) (admission.Warnings, erro // createValidations validates the creation of the resource func (topic *Topic) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){topic.validateResourceReferences} + return []func() (admission.Warnings, error){topic.validateResourceReferences, topic.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -217,7 +213,16 @@ func (topic *Topic) updateValidations() []func(old runtime.Object) (admission.Wa func(old runtime.Object) (admission.Warnings, error) { return topic.validateResourceReferences() }, - topic.validateWriteOnceProperties} + topic.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return topic.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (topic *Topic) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(topic) } // validateResourceReferences validates all resource references @@ -462,7 +467,10 @@ func (topic *Topic_Spec) PopulateFromARM(owner genruntime.ArbitraryOwnerReferenc } // Set property "Owner": - topic.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + topic.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "PublicNetworkAccess": // copying flattened property: diff --git a/v2/api/eventgrid/v1api20200601storage/domain_types_gen.go b/v2/api/eventgrid/v1api20200601storage/domain_types_gen.go index 34f7250add3..a44f0f7889f 100644 --- a/v2/api/eventgrid/v1api20200601storage/domain_types_gen.go +++ b/v2/api/eventgrid/v1api20200601storage/domain_types_gen.go @@ -84,11 +84,7 @@ func (domain *Domain) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (domain *Domain) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(domain.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: domain.Spec.Owner.Name, - } + return domain.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/eventgrid/v1api20200601storage/domains_topic_types_gen.go b/v2/api/eventgrid/v1api20200601storage/domains_topic_types_gen.go index e2cc4a6aedf..0a405a61aa6 100644 --- a/v2/api/eventgrid/v1api20200601storage/domains_topic_types_gen.go +++ b/v2/api/eventgrid/v1api20200601storage/domains_topic_types_gen.go @@ -84,11 +84,7 @@ func (topic *DomainsTopic) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (topic *DomainsTopic) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(topic.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: topic.Spec.Owner.Name, - } + return topic.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/eventgrid/v1api20200601storage/event_subscription_types_gen.go b/v2/api/eventgrid/v1api20200601storage/event_subscription_types_gen.go index 3e10c08aa11..66178461ae3 100644 --- a/v2/api/eventgrid/v1api20200601storage/event_subscription_types_gen.go +++ b/v2/api/eventgrid/v1api20200601storage/event_subscription_types_gen.go @@ -83,11 +83,7 @@ func (subscription *EventSubscription) NewEmptyStatus() genruntime.ConvertibleSt // Owner returns the ResourceReference of the owner func (subscription *EventSubscription) Owner() *genruntime.ResourceReference { - return &genruntime.ResourceReference{ - Group: subscription.Spec.Owner.Group, - Kind: subscription.Spec.Owner.Kind, - Name: subscription.Spec.Owner.Name, - } + return subscription.Spec.Owner.AsResourceReference() } // SetStatus sets the status of this resource diff --git a/v2/api/eventgrid/v1api20200601storage/topic_types_gen.go b/v2/api/eventgrid/v1api20200601storage/topic_types_gen.go index 73963f87e87..61ad649ce5e 100644 --- a/v2/api/eventgrid/v1api20200601storage/topic_types_gen.go +++ b/v2/api/eventgrid/v1api20200601storage/topic_types_gen.go @@ -84,11 +84,7 @@ func (topic *Topic) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (topic *Topic) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(topic.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: topic.Spec.Owner.Name, - } + return topic.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/eventgrid/v1beta20200601/domain_types_gen.go b/v2/api/eventgrid/v1beta20200601/domain_types_gen.go index 912e47a86bb..29cf0ecb0bd 100644 --- a/v2/api/eventgrid/v1beta20200601/domain_types_gen.go +++ b/v2/api/eventgrid/v1beta20200601/domain_types_gen.go @@ -142,11 +142,7 @@ func (domain *Domain) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (domain *Domain) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(domain.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: domain.Spec.Owner.Name, - } + return domain.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -204,7 +200,7 @@ func (domain *Domain) ValidateUpdate(old runtime.Object) (admission.Warnings, er // createValidations validates the creation of the resource func (domain *Domain) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){domain.validateResourceReferences} + return []func() (admission.Warnings, error){domain.validateResourceReferences, domain.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -218,7 +214,16 @@ func (domain *Domain) updateValidations() []func(old runtime.Object) (admission. func(old runtime.Object) (admission.Warnings, error) { return domain.validateResourceReferences() }, - domain.validateWriteOnceProperties} + domain.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return domain.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (domain *Domain) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(domain) } // validateResourceReferences validates all resource references @@ -452,7 +457,10 @@ func (domain *Domain_Spec) PopulateFromARM(owner genruntime.ArbitraryOwnerRefere } // Set property "Owner": - domain.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + domain.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "PublicNetworkAccess": // copying flattened property: diff --git a/v2/api/eventgrid/v1beta20200601/domains_topic_types_gen.go b/v2/api/eventgrid/v1beta20200601/domains_topic_types_gen.go index 1933d5ec1ed..60a5b1ad4a0 100644 --- a/v2/api/eventgrid/v1beta20200601/domains_topic_types_gen.go +++ b/v2/api/eventgrid/v1beta20200601/domains_topic_types_gen.go @@ -142,11 +142,7 @@ func (topic *DomainsTopic) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (topic *DomainsTopic) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(topic.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: topic.Spec.Owner.Name, - } + return topic.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -204,7 +200,7 @@ func (topic *DomainsTopic) ValidateUpdate(old runtime.Object) (admission.Warning // createValidations validates the creation of the resource func (topic *DomainsTopic) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){topic.validateResourceReferences} + return []func() (admission.Warnings, error){topic.validateResourceReferences, topic.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -218,7 +214,16 @@ func (topic *DomainsTopic) updateValidations() []func(old runtime.Object) (admis func(old runtime.Object) (admission.Warnings, error) { return topic.validateResourceReferences() }, - topic.validateWriteOnceProperties} + topic.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return topic.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (topic *DomainsTopic) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(topic) } // validateResourceReferences validates all resource references @@ -351,7 +356,10 @@ func (topic *Domains_Topic_Spec) PopulateFromARM(owner genruntime.ArbitraryOwner topic.SetAzureName(genruntime.ExtractKubernetesResourceNameFromARMName(typedInput.Name)) // Set property "Owner": - topic.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + topic.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // No error return nil diff --git a/v2/api/eventgrid/v1beta20200601/event_subscription_types_gen.go b/v2/api/eventgrid/v1beta20200601/event_subscription_types_gen.go index 097bfe562e8..e7b7251380e 100644 --- a/v2/api/eventgrid/v1beta20200601/event_subscription_types_gen.go +++ b/v2/api/eventgrid/v1beta20200601/event_subscription_types_gen.go @@ -141,11 +141,7 @@ func (subscription *EventSubscription) NewEmptyStatus() genruntime.ConvertibleSt // Owner returns the ResourceReference of the owner func (subscription *EventSubscription) Owner() *genruntime.ResourceReference { - return &genruntime.ResourceReference{ - Group: subscription.Spec.Owner.Group, - Kind: subscription.Spec.Owner.Kind, - Name: subscription.Spec.Owner.Name, - } + return subscription.Spec.Owner.AsResourceReference() } // SetStatus sets the status of this resource diff --git a/v2/api/eventgrid/v1beta20200601/topic_types_gen.go b/v2/api/eventgrid/v1beta20200601/topic_types_gen.go index 34954e4255b..506dbe3e01b 100644 --- a/v2/api/eventgrid/v1beta20200601/topic_types_gen.go +++ b/v2/api/eventgrid/v1beta20200601/topic_types_gen.go @@ -142,11 +142,7 @@ func (topic *Topic) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (topic *Topic) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(topic.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: topic.Spec.Owner.Name, - } + return topic.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -204,7 +200,7 @@ func (topic *Topic) ValidateUpdate(old runtime.Object) (admission.Warnings, erro // createValidations validates the creation of the resource func (topic *Topic) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){topic.validateResourceReferences} + return []func() (admission.Warnings, error){topic.validateResourceReferences, topic.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -218,7 +214,16 @@ func (topic *Topic) updateValidations() []func(old runtime.Object) (admission.Wa func(old runtime.Object) (admission.Warnings, error) { return topic.validateResourceReferences() }, - topic.validateWriteOnceProperties} + topic.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return topic.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (topic *Topic) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(topic) } // validateResourceReferences validates all resource references @@ -446,7 +451,10 @@ func (topic *Topic_Spec) PopulateFromARM(owner genruntime.ArbitraryOwnerReferenc } // Set property "Owner": - topic.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + topic.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "PublicNetworkAccess": // copying flattened property: diff --git a/v2/api/eventgrid/v1beta20200601storage/domain_types_gen.go b/v2/api/eventgrid/v1beta20200601storage/domain_types_gen.go index 0f8f20a8ea6..e8138d0b6b3 100644 --- a/v2/api/eventgrid/v1beta20200601storage/domain_types_gen.go +++ b/v2/api/eventgrid/v1beta20200601storage/domain_types_gen.go @@ -103,11 +103,7 @@ func (domain *Domain) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (domain *Domain) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(domain.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: domain.Spec.Owner.Name, - } + return domain.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/eventgrid/v1beta20200601storage/domains_topic_types_gen.go b/v2/api/eventgrid/v1beta20200601storage/domains_topic_types_gen.go index 67ee6e528ff..2529393a989 100644 --- a/v2/api/eventgrid/v1beta20200601storage/domains_topic_types_gen.go +++ b/v2/api/eventgrid/v1beta20200601storage/domains_topic_types_gen.go @@ -103,11 +103,7 @@ func (topic *DomainsTopic) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (topic *DomainsTopic) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(topic.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: topic.Spec.Owner.Name, - } + return topic.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/eventgrid/v1beta20200601storage/event_subscription_types_gen.go b/v2/api/eventgrid/v1beta20200601storage/event_subscription_types_gen.go index 7d682f8da78..56543112dce 100644 --- a/v2/api/eventgrid/v1beta20200601storage/event_subscription_types_gen.go +++ b/v2/api/eventgrid/v1beta20200601storage/event_subscription_types_gen.go @@ -102,11 +102,7 @@ func (subscription *EventSubscription) NewEmptyStatus() genruntime.ConvertibleSt // Owner returns the ResourceReference of the owner func (subscription *EventSubscription) Owner() *genruntime.ResourceReference { - return &genruntime.ResourceReference{ - Group: subscription.Spec.Owner.Group, - Kind: subscription.Spec.Owner.Kind, - Name: subscription.Spec.Owner.Name, - } + return subscription.Spec.Owner.AsResourceReference() } // SetStatus sets the status of this resource diff --git a/v2/api/eventgrid/v1beta20200601storage/topic_types_gen.go b/v2/api/eventgrid/v1beta20200601storage/topic_types_gen.go index b8fdcdcab1d..aa9922a836e 100644 --- a/v2/api/eventgrid/v1beta20200601storage/topic_types_gen.go +++ b/v2/api/eventgrid/v1beta20200601storage/topic_types_gen.go @@ -103,11 +103,7 @@ func (topic *Topic) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (topic *Topic) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(topic.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: topic.Spec.Owner.Name, - } + return topic.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/eventhub/v1api20211101/namespace_types_gen.go b/v2/api/eventhub/v1api20211101/namespace_types_gen.go index 900603be316..085613cd078 100644 --- a/v2/api/eventhub/v1api20211101/namespace_types_gen.go +++ b/v2/api/eventhub/v1api20211101/namespace_types_gen.go @@ -141,11 +141,7 @@ func (namespace *Namespace) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (namespace *Namespace) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(namespace.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: namespace.Spec.Owner.Name, - } + return namespace.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -203,7 +199,7 @@ func (namespace *Namespace) ValidateUpdate(old runtime.Object) (admission.Warnin // createValidations validates the creation of the resource func (namespace *Namespace) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){namespace.validateResourceReferences} + return []func() (admission.Warnings, error){namespace.validateResourceReferences, namespace.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -217,7 +213,16 @@ func (namespace *Namespace) updateValidations() []func(old runtime.Object) (admi func(old runtime.Object) (admission.Warnings, error) { return namespace.validateResourceReferences() }, - namespace.validateWriteOnceProperties} + namespace.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return namespace.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (namespace *Namespace) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(namespace) } // validateResourceReferences validates all resource references @@ -561,7 +566,10 @@ func (namespace *Namespace_Spec) PopulateFromARM(owner genruntime.ArbitraryOwner } // Set property "Owner": - namespace.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + namespace.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "Sku": if typedInput.Sku != nil { diff --git a/v2/api/eventhub/v1api20211101/namespaces_authorization_rule_types_gen.go b/v2/api/eventhub/v1api20211101/namespaces_authorization_rule_types_gen.go index 4d396b780c2..7ad81e5274b 100644 --- a/v2/api/eventhub/v1api20211101/namespaces_authorization_rule_types_gen.go +++ b/v2/api/eventhub/v1api20211101/namespaces_authorization_rule_types_gen.go @@ -141,11 +141,7 @@ func (rule *NamespacesAuthorizationRule) NewEmptyStatus() genruntime.Convertible // Owner returns the ResourceReference of the owner func (rule *NamespacesAuthorizationRule) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(rule.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: rule.Spec.Owner.Name, - } + return rule.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -203,7 +199,7 @@ func (rule *NamespacesAuthorizationRule) ValidateUpdate(old runtime.Object) (adm // createValidations validates the creation of the resource func (rule *NamespacesAuthorizationRule) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){rule.validateResourceReferences} + return []func() (admission.Warnings, error){rule.validateResourceReferences, rule.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -217,7 +213,16 @@ func (rule *NamespacesAuthorizationRule) updateValidations() []func(old runtime. func(old runtime.Object) (admission.Warnings, error) { return rule.validateResourceReferences() }, - rule.validateWriteOnceProperties} + rule.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return rule.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (rule *NamespacesAuthorizationRule) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(rule) } // validateResourceReferences validates all resource references @@ -365,7 +370,10 @@ func (rule *Namespaces_AuthorizationRule_Spec) PopulateFromARM(owner genruntime. rule.SetAzureName(genruntime.ExtractKubernetesResourceNameFromARMName(typedInput.Name)) // Set property "Owner": - rule.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + rule.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "Rights": // copying flattened property: diff --git a/v2/api/eventhub/v1api20211101/namespaces_eventhub_types_gen.go b/v2/api/eventhub/v1api20211101/namespaces_eventhub_types_gen.go index d5219896393..d70357b4fdc 100644 --- a/v2/api/eventhub/v1api20211101/namespaces_eventhub_types_gen.go +++ b/v2/api/eventhub/v1api20211101/namespaces_eventhub_types_gen.go @@ -141,11 +141,7 @@ func (eventhub *NamespacesEventhub) NewEmptyStatus() genruntime.ConvertibleStatu // Owner returns the ResourceReference of the owner func (eventhub *NamespacesEventhub) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(eventhub.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: eventhub.Spec.Owner.Name, - } + return eventhub.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -203,7 +199,7 @@ func (eventhub *NamespacesEventhub) ValidateUpdate(old runtime.Object) (admissio // createValidations validates the creation of the resource func (eventhub *NamespacesEventhub) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){eventhub.validateResourceReferences} + return []func() (admission.Warnings, error){eventhub.validateResourceReferences, eventhub.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -217,7 +213,16 @@ func (eventhub *NamespacesEventhub) updateValidations() []func(old runtime.Objec func(old runtime.Object) (admission.Warnings, error) { return eventhub.validateResourceReferences() }, - eventhub.validateWriteOnceProperties} + eventhub.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return eventhub.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (eventhub *NamespacesEventhub) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(eventhub) } // validateResourceReferences validates all resource references @@ -411,7 +416,10 @@ func (eventhub *Namespaces_Eventhub_Spec) PopulateFromARM(owner genruntime.Arbit } // Set property "Owner": - eventhub.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + eventhub.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "PartitionCount": // copying flattened property: diff --git a/v2/api/eventhub/v1api20211101/namespaces_eventhubs_authorization_rule_types_gen.go b/v2/api/eventhub/v1api20211101/namespaces_eventhubs_authorization_rule_types_gen.go index 4d4e50a4b81..b161e331a3d 100644 --- a/v2/api/eventhub/v1api20211101/namespaces_eventhubs_authorization_rule_types_gen.go +++ b/v2/api/eventhub/v1api20211101/namespaces_eventhubs_authorization_rule_types_gen.go @@ -141,11 +141,7 @@ func (rule *NamespacesEventhubsAuthorizationRule) NewEmptyStatus() genruntime.Co // Owner returns the ResourceReference of the owner func (rule *NamespacesEventhubsAuthorizationRule) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(rule.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: rule.Spec.Owner.Name, - } + return rule.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -203,7 +199,7 @@ func (rule *NamespacesEventhubsAuthorizationRule) ValidateUpdate(old runtime.Obj // createValidations validates the creation of the resource func (rule *NamespacesEventhubsAuthorizationRule) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){rule.validateResourceReferences} + return []func() (admission.Warnings, error){rule.validateResourceReferences, rule.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -217,7 +213,16 @@ func (rule *NamespacesEventhubsAuthorizationRule) updateValidations() []func(old func(old runtime.Object) (admission.Warnings, error) { return rule.validateResourceReferences() }, - rule.validateWriteOnceProperties} + rule.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return rule.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (rule *NamespacesEventhubsAuthorizationRule) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(rule) } // validateResourceReferences validates all resource references @@ -365,7 +370,10 @@ func (rule *Namespaces_Eventhubs_AuthorizationRule_Spec) PopulateFromARM(owner g rule.SetAzureName(genruntime.ExtractKubernetesResourceNameFromARMName(typedInput.Name)) // Set property "Owner": - rule.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + rule.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "Rights": // copying flattened property: diff --git a/v2/api/eventhub/v1api20211101/namespaces_eventhubs_consumer_group_types_gen.go b/v2/api/eventhub/v1api20211101/namespaces_eventhubs_consumer_group_types_gen.go index 5d74c827be2..c60757f3796 100644 --- a/v2/api/eventhub/v1api20211101/namespaces_eventhubs_consumer_group_types_gen.go +++ b/v2/api/eventhub/v1api20211101/namespaces_eventhubs_consumer_group_types_gen.go @@ -141,11 +141,7 @@ func (group *NamespacesEventhubsConsumerGroup) NewEmptyStatus() genruntime.Conve // Owner returns the ResourceReference of the owner func (group *NamespacesEventhubsConsumerGroup) Owner() *genruntime.ResourceReference { ownerGroup, ownerKind := genruntime.LookupOwnerGroupKind(group.Spec) - return &genruntime.ResourceReference{ - Group: ownerGroup, - Kind: ownerKind, - Name: group.Spec.Owner.Name, - } + return group.Spec.Owner.AsResourceReference(ownerGroup, ownerKind) } // SetStatus sets the status of this resource @@ -203,7 +199,7 @@ func (group *NamespacesEventhubsConsumerGroup) ValidateUpdate(old runtime.Object // createValidations validates the creation of the resource func (group *NamespacesEventhubsConsumerGroup) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){group.validateResourceReferences} + return []func() (admission.Warnings, error){group.validateResourceReferences, group.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -217,7 +213,16 @@ func (group *NamespacesEventhubsConsumerGroup) updateValidations() []func(old ru func(old runtime.Object) (admission.Warnings, error) { return group.validateResourceReferences() }, - group.validateWriteOnceProperties} + group.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return group.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (group *NamespacesEventhubsConsumerGroup) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(group) } // validateResourceReferences validates all resource references @@ -368,7 +373,10 @@ func (consumergroup *Namespaces_Eventhubs_Consumergroup_Spec) PopulateFromARM(ow consumergroup.SetAzureName(genruntime.ExtractKubernetesResourceNameFromARMName(typedInput.Name)) // Set property "Owner": - consumergroup.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + consumergroup.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "UserMetadata": // copying flattened property: diff --git a/v2/api/eventhub/v1api20211101storage/namespace_types_gen.go b/v2/api/eventhub/v1api20211101storage/namespace_types_gen.go index f6e431f88df..1e9cf23a211 100644 --- a/v2/api/eventhub/v1api20211101storage/namespace_types_gen.go +++ b/v2/api/eventhub/v1api20211101storage/namespace_types_gen.go @@ -84,11 +84,7 @@ func (namespace *Namespace) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (namespace *Namespace) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(namespace.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: namespace.Spec.Owner.Name, - } + return namespace.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/eventhub/v1api20211101storage/namespaces_authorization_rule_types_gen.go b/v2/api/eventhub/v1api20211101storage/namespaces_authorization_rule_types_gen.go index 0731343a059..1e0ea1371d1 100644 --- a/v2/api/eventhub/v1api20211101storage/namespaces_authorization_rule_types_gen.go +++ b/v2/api/eventhub/v1api20211101storage/namespaces_authorization_rule_types_gen.go @@ -84,11 +84,7 @@ func (rule *NamespacesAuthorizationRule) NewEmptyStatus() genruntime.Convertible // Owner returns the ResourceReference of the owner func (rule *NamespacesAuthorizationRule) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(rule.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: rule.Spec.Owner.Name, - } + return rule.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/eventhub/v1api20211101storage/namespaces_eventhub_types_gen.go b/v2/api/eventhub/v1api20211101storage/namespaces_eventhub_types_gen.go index 2e68a2b6a57..f88cdd744f8 100644 --- a/v2/api/eventhub/v1api20211101storage/namespaces_eventhub_types_gen.go +++ b/v2/api/eventhub/v1api20211101storage/namespaces_eventhub_types_gen.go @@ -84,11 +84,7 @@ func (eventhub *NamespacesEventhub) NewEmptyStatus() genruntime.ConvertibleStatu // Owner returns the ResourceReference of the owner func (eventhub *NamespacesEventhub) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(eventhub.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: eventhub.Spec.Owner.Name, - } + return eventhub.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/eventhub/v1api20211101storage/namespaces_eventhubs_authorization_rule_types_gen.go b/v2/api/eventhub/v1api20211101storage/namespaces_eventhubs_authorization_rule_types_gen.go index e57786261aa..7c5129bc2f6 100644 --- a/v2/api/eventhub/v1api20211101storage/namespaces_eventhubs_authorization_rule_types_gen.go +++ b/v2/api/eventhub/v1api20211101storage/namespaces_eventhubs_authorization_rule_types_gen.go @@ -84,11 +84,7 @@ func (rule *NamespacesEventhubsAuthorizationRule) NewEmptyStatus() genruntime.Co // Owner returns the ResourceReference of the owner func (rule *NamespacesEventhubsAuthorizationRule) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(rule.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: rule.Spec.Owner.Name, - } + return rule.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/eventhub/v1api20211101storage/namespaces_eventhubs_consumer_group_types_gen.go b/v2/api/eventhub/v1api20211101storage/namespaces_eventhubs_consumer_group_types_gen.go index 37ac74da176..0b7407a01de 100644 --- a/v2/api/eventhub/v1api20211101storage/namespaces_eventhubs_consumer_group_types_gen.go +++ b/v2/api/eventhub/v1api20211101storage/namespaces_eventhubs_consumer_group_types_gen.go @@ -84,11 +84,7 @@ func (group *NamespacesEventhubsConsumerGroup) NewEmptyStatus() genruntime.Conve // Owner returns the ResourceReference of the owner func (group *NamespacesEventhubsConsumerGroup) Owner() *genruntime.ResourceReference { ownerGroup, ownerKind := genruntime.LookupOwnerGroupKind(group.Spec) - return &genruntime.ResourceReference{ - Group: ownerGroup, - Kind: ownerKind, - Name: group.Spec.Owner.Name, - } + return group.Spec.Owner.AsResourceReference(ownerGroup, ownerKind) } // SetStatus sets the status of this resource diff --git a/v2/api/eventhub/v1beta20211101/namespace_types_gen.go b/v2/api/eventhub/v1beta20211101/namespace_types_gen.go index f7f86561f60..e605bf549c4 100644 --- a/v2/api/eventhub/v1beta20211101/namespace_types_gen.go +++ b/v2/api/eventhub/v1beta20211101/namespace_types_gen.go @@ -142,11 +142,7 @@ func (namespace *Namespace) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (namespace *Namespace) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(namespace.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: namespace.Spec.Owner.Name, - } + return namespace.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -204,7 +200,7 @@ func (namespace *Namespace) ValidateUpdate(old runtime.Object) (admission.Warnin // createValidations validates the creation of the resource func (namespace *Namespace) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){namespace.validateResourceReferences} + return []func() (admission.Warnings, error){namespace.validateResourceReferences, namespace.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -218,7 +214,16 @@ func (namespace *Namespace) updateValidations() []func(old runtime.Object) (admi func(old runtime.Object) (admission.Warnings, error) { return namespace.validateResourceReferences() }, - namespace.validateWriteOnceProperties} + namespace.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return namespace.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (namespace *Namespace) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(namespace) } // validateResourceReferences validates all resource references @@ -537,7 +542,10 @@ func (namespace *Namespace_Spec) PopulateFromARM(owner genruntime.ArbitraryOwner } // Set property "Owner": - namespace.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + namespace.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "Sku": if typedInput.Sku != nil { diff --git a/v2/api/eventhub/v1beta20211101/namespaces_authorization_rule_types_gen.go b/v2/api/eventhub/v1beta20211101/namespaces_authorization_rule_types_gen.go index 5ece5083b57..dd778f1d43c 100644 --- a/v2/api/eventhub/v1beta20211101/namespaces_authorization_rule_types_gen.go +++ b/v2/api/eventhub/v1beta20211101/namespaces_authorization_rule_types_gen.go @@ -142,11 +142,7 @@ func (rule *NamespacesAuthorizationRule) NewEmptyStatus() genruntime.Convertible // Owner returns the ResourceReference of the owner func (rule *NamespacesAuthorizationRule) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(rule.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: rule.Spec.Owner.Name, - } + return rule.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -204,7 +200,7 @@ func (rule *NamespacesAuthorizationRule) ValidateUpdate(old runtime.Object) (adm // createValidations validates the creation of the resource func (rule *NamespacesAuthorizationRule) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){rule.validateResourceReferences} + return []func() (admission.Warnings, error){rule.validateResourceReferences, rule.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -218,7 +214,16 @@ func (rule *NamespacesAuthorizationRule) updateValidations() []func(old runtime. func(old runtime.Object) (admission.Warnings, error) { return rule.validateResourceReferences() }, - rule.validateWriteOnceProperties} + rule.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return rule.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (rule *NamespacesAuthorizationRule) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(rule) } // validateResourceReferences validates all resource references @@ -363,7 +368,10 @@ func (rule *Namespaces_AuthorizationRule_Spec) PopulateFromARM(owner genruntime. rule.SetAzureName(genruntime.ExtractKubernetesResourceNameFromARMName(typedInput.Name)) // Set property "Owner": - rule.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + rule.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "Rights": // copying flattened property: diff --git a/v2/api/eventhub/v1beta20211101/namespaces_eventhub_types_gen.go b/v2/api/eventhub/v1beta20211101/namespaces_eventhub_types_gen.go index 25c472d2895..56d6bda94bb 100644 --- a/v2/api/eventhub/v1beta20211101/namespaces_eventhub_types_gen.go +++ b/v2/api/eventhub/v1beta20211101/namespaces_eventhub_types_gen.go @@ -142,11 +142,7 @@ func (eventhub *NamespacesEventhub) NewEmptyStatus() genruntime.ConvertibleStatu // Owner returns the ResourceReference of the owner func (eventhub *NamespacesEventhub) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(eventhub.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: eventhub.Spec.Owner.Name, - } + return eventhub.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -204,7 +200,7 @@ func (eventhub *NamespacesEventhub) ValidateUpdate(old runtime.Object) (admissio // createValidations validates the creation of the resource func (eventhub *NamespacesEventhub) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){eventhub.validateResourceReferences} + return []func() (admission.Warnings, error){eventhub.validateResourceReferences, eventhub.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -218,7 +214,16 @@ func (eventhub *NamespacesEventhub) updateValidations() []func(old runtime.Objec func(old runtime.Object) (admission.Warnings, error) { return eventhub.validateResourceReferences() }, - eventhub.validateWriteOnceProperties} + eventhub.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return eventhub.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (eventhub *NamespacesEventhub) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(eventhub) } // validateResourceReferences validates all resource references @@ -406,7 +411,10 @@ func (eventhub *Namespaces_Eventhub_Spec) PopulateFromARM(owner genruntime.Arbit } // Set property "Owner": - eventhub.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + eventhub.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "PartitionCount": // copying flattened property: diff --git a/v2/api/eventhub/v1beta20211101/namespaces_eventhubs_authorization_rule_types_gen.go b/v2/api/eventhub/v1beta20211101/namespaces_eventhubs_authorization_rule_types_gen.go index 9ff2415e4d7..d26d1cbd847 100644 --- a/v2/api/eventhub/v1beta20211101/namespaces_eventhubs_authorization_rule_types_gen.go +++ b/v2/api/eventhub/v1beta20211101/namespaces_eventhubs_authorization_rule_types_gen.go @@ -142,11 +142,7 @@ func (rule *NamespacesEventhubsAuthorizationRule) NewEmptyStatus() genruntime.Co // Owner returns the ResourceReference of the owner func (rule *NamespacesEventhubsAuthorizationRule) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(rule.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: rule.Spec.Owner.Name, - } + return rule.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -204,7 +200,7 @@ func (rule *NamespacesEventhubsAuthorizationRule) ValidateUpdate(old runtime.Obj // createValidations validates the creation of the resource func (rule *NamespacesEventhubsAuthorizationRule) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){rule.validateResourceReferences} + return []func() (admission.Warnings, error){rule.validateResourceReferences, rule.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -218,7 +214,16 @@ func (rule *NamespacesEventhubsAuthorizationRule) updateValidations() []func(old func(old runtime.Object) (admission.Warnings, error) { return rule.validateResourceReferences() }, - rule.validateWriteOnceProperties} + rule.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return rule.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (rule *NamespacesEventhubsAuthorizationRule) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(rule) } // validateResourceReferences validates all resource references @@ -363,7 +368,10 @@ func (rule *Namespaces_Eventhubs_AuthorizationRule_Spec) PopulateFromARM(owner g rule.SetAzureName(genruntime.ExtractKubernetesResourceNameFromARMName(typedInput.Name)) // Set property "Owner": - rule.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + rule.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "Rights": // copying flattened property: diff --git a/v2/api/eventhub/v1beta20211101/namespaces_eventhubs_consumer_group_types_gen.go b/v2/api/eventhub/v1beta20211101/namespaces_eventhubs_consumer_group_types_gen.go index 8a0d2b0dbc8..071d6befd12 100644 --- a/v2/api/eventhub/v1beta20211101/namespaces_eventhubs_consumer_group_types_gen.go +++ b/v2/api/eventhub/v1beta20211101/namespaces_eventhubs_consumer_group_types_gen.go @@ -142,11 +142,7 @@ func (group *NamespacesEventhubsConsumerGroup) NewEmptyStatus() genruntime.Conve // Owner returns the ResourceReference of the owner func (group *NamespacesEventhubsConsumerGroup) Owner() *genruntime.ResourceReference { ownerGroup, ownerKind := genruntime.LookupOwnerGroupKind(group.Spec) - return &genruntime.ResourceReference{ - Group: ownerGroup, - Kind: ownerKind, - Name: group.Spec.Owner.Name, - } + return group.Spec.Owner.AsResourceReference(ownerGroup, ownerKind) } // SetStatus sets the status of this resource @@ -204,7 +200,7 @@ func (group *NamespacesEventhubsConsumerGroup) ValidateUpdate(old runtime.Object // createValidations validates the creation of the resource func (group *NamespacesEventhubsConsumerGroup) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){group.validateResourceReferences} + return []func() (admission.Warnings, error){group.validateResourceReferences, group.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -218,7 +214,16 @@ func (group *NamespacesEventhubsConsumerGroup) updateValidations() []func(old ru func(old runtime.Object) (admission.Warnings, error) { return group.validateResourceReferences() }, - group.validateWriteOnceProperties} + group.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return group.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (group *NamespacesEventhubsConsumerGroup) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(group) } // validateResourceReferences validates all resource references @@ -363,7 +368,10 @@ func (consumergroup *Namespaces_Eventhubs_Consumergroup_Spec) PopulateFromARM(ow consumergroup.SetAzureName(genruntime.ExtractKubernetesResourceNameFromARMName(typedInput.Name)) // Set property "Owner": - consumergroup.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + consumergroup.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "UserMetadata": // copying flattened property: diff --git a/v2/api/eventhub/v1beta20211101storage/namespace_types_gen.go b/v2/api/eventhub/v1beta20211101storage/namespace_types_gen.go index 66568bab258..4d6c92a1c39 100644 --- a/v2/api/eventhub/v1beta20211101storage/namespace_types_gen.go +++ b/v2/api/eventhub/v1beta20211101storage/namespace_types_gen.go @@ -103,11 +103,7 @@ func (namespace *Namespace) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (namespace *Namespace) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(namespace.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: namespace.Spec.Owner.Name, - } + return namespace.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/eventhub/v1beta20211101storage/namespaces_authorization_rule_types_gen.go b/v2/api/eventhub/v1beta20211101storage/namespaces_authorization_rule_types_gen.go index eb02b2a1e5e..2d7d3f1f9e8 100644 --- a/v2/api/eventhub/v1beta20211101storage/namespaces_authorization_rule_types_gen.go +++ b/v2/api/eventhub/v1beta20211101storage/namespaces_authorization_rule_types_gen.go @@ -103,11 +103,7 @@ func (rule *NamespacesAuthorizationRule) NewEmptyStatus() genruntime.Convertible // Owner returns the ResourceReference of the owner func (rule *NamespacesAuthorizationRule) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(rule.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: rule.Spec.Owner.Name, - } + return rule.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/eventhub/v1beta20211101storage/namespaces_eventhub_types_gen.go b/v2/api/eventhub/v1beta20211101storage/namespaces_eventhub_types_gen.go index cb57db7c940..a09de4fe75d 100644 --- a/v2/api/eventhub/v1beta20211101storage/namespaces_eventhub_types_gen.go +++ b/v2/api/eventhub/v1beta20211101storage/namespaces_eventhub_types_gen.go @@ -103,11 +103,7 @@ func (eventhub *NamespacesEventhub) NewEmptyStatus() genruntime.ConvertibleStatu // Owner returns the ResourceReference of the owner func (eventhub *NamespacesEventhub) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(eventhub.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: eventhub.Spec.Owner.Name, - } + return eventhub.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/eventhub/v1beta20211101storage/namespaces_eventhubs_authorization_rule_types_gen.go b/v2/api/eventhub/v1beta20211101storage/namespaces_eventhubs_authorization_rule_types_gen.go index 7988f0a1cd7..aece49dbe75 100644 --- a/v2/api/eventhub/v1beta20211101storage/namespaces_eventhubs_authorization_rule_types_gen.go +++ b/v2/api/eventhub/v1beta20211101storage/namespaces_eventhubs_authorization_rule_types_gen.go @@ -103,11 +103,7 @@ func (rule *NamespacesEventhubsAuthorizationRule) NewEmptyStatus() genruntime.Co // Owner returns the ResourceReference of the owner func (rule *NamespacesEventhubsAuthorizationRule) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(rule.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: rule.Spec.Owner.Name, - } + return rule.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/eventhub/v1beta20211101storage/namespaces_eventhubs_consumer_group_types_gen.go b/v2/api/eventhub/v1beta20211101storage/namespaces_eventhubs_consumer_group_types_gen.go index f381ebc2ebd..51011b8137e 100644 --- a/v2/api/eventhub/v1beta20211101storage/namespaces_eventhubs_consumer_group_types_gen.go +++ b/v2/api/eventhub/v1beta20211101storage/namespaces_eventhubs_consumer_group_types_gen.go @@ -103,11 +103,7 @@ func (group *NamespacesEventhubsConsumerGroup) NewEmptyStatus() genruntime.Conve // Owner returns the ResourceReference of the owner func (group *NamespacesEventhubsConsumerGroup) Owner() *genruntime.ResourceReference { ownerGroup, ownerKind := genruntime.LookupOwnerGroupKind(group.Spec) - return &genruntime.ResourceReference{ - Group: ownerGroup, - Kind: ownerKind, - Name: group.Spec.Owner.Name, - } + return group.Spec.Owner.AsResourceReference(ownerGroup, ownerKind) } // SetStatus sets the status of this resource diff --git a/v2/api/insights/v1api20180501preview/webtest_types_gen.go b/v2/api/insights/v1api20180501preview/webtest_types_gen.go index 685f3a9f251..cb06d6a7c27 100644 --- a/v2/api/insights/v1api20180501preview/webtest_types_gen.go +++ b/v2/api/insights/v1api20180501preview/webtest_types_gen.go @@ -141,11 +141,7 @@ func (webtest *Webtest) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (webtest *Webtest) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(webtest.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: webtest.Spec.Owner.Name, - } + return webtest.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -203,7 +199,7 @@ func (webtest *Webtest) ValidateUpdate(old runtime.Object) (admission.Warnings, // createValidations validates the creation of the resource func (webtest *Webtest) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){webtest.validateResourceReferences} + return []func() (admission.Warnings, error){webtest.validateResourceReferences, webtest.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -217,7 +213,16 @@ func (webtest *Webtest) updateValidations() []func(old runtime.Object) (admissio func(old runtime.Object) (admission.Warnings, error) { return webtest.validateResourceReferences() }, - webtest.validateWriteOnceProperties} + webtest.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return webtest.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (webtest *Webtest) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(webtest) } // validateResourceReferences validates all resource references @@ -576,7 +581,10 @@ func (webtest *Webtest_Spec) PopulateFromARM(owner genruntime.ArbitraryOwnerRefe } // Set property "Owner": - webtest.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + webtest.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "Request": // copying flattened property: diff --git a/v2/api/insights/v1api20180501previewstorage/webtest_types_gen.go b/v2/api/insights/v1api20180501previewstorage/webtest_types_gen.go index 1291f5a89fe..b127b2e9a5c 100644 --- a/v2/api/insights/v1api20180501previewstorage/webtest_types_gen.go +++ b/v2/api/insights/v1api20180501previewstorage/webtest_types_gen.go @@ -84,11 +84,7 @@ func (webtest *Webtest) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (webtest *Webtest) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(webtest.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: webtest.Spec.Owner.Name, - } + return webtest.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/insights/v1api20200202/component_types_gen.go b/v2/api/insights/v1api20200202/component_types_gen.go index 7d2d321fefd..798ee5b3be4 100644 --- a/v2/api/insights/v1api20200202/component_types_gen.go +++ b/v2/api/insights/v1api20200202/component_types_gen.go @@ -168,11 +168,7 @@ func (component *Component) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (component *Component) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(component.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: component.Spec.Owner.Name, - } + return component.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -230,7 +226,7 @@ func (component *Component) ValidateUpdate(old runtime.Object) (admission.Warnin // createValidations validates the creation of the resource func (component *Component) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){component.validateResourceReferences, component.validateConfigMapDestinations} + return []func() (admission.Warnings, error){component.validateResourceReferences, component.validateOwnerReference, component.validateConfigMapDestinations} } // deleteValidations validates the deletion of the resource @@ -245,6 +241,9 @@ func (component *Component) updateValidations() []func(old runtime.Object) (admi return component.validateResourceReferences() }, component.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return component.validateOwnerReference() + }, func(old runtime.Object) (admission.Warnings, error) { return component.validateConfigMapDestinations() }, @@ -266,6 +265,11 @@ func (component *Component) validateConfigMapDestinations() (admission.Warnings, return genruntime.ValidateConfigMapDestinations(toValidate) } +// validateOwnerReference validates the owner field +func (component *Component) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(component) +} + // validateResourceReferences validates all resource references func (component *Component) validateResourceReferences() (admission.Warnings, error) { refs, err := reflecthelpers.FindResourceReferences(&component.Spec) @@ -666,7 +670,10 @@ func (component *Component_Spec) PopulateFromARM(owner genruntime.ArbitraryOwner // no assignment for property "OperatorSpec" // Set property "Owner": - component.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + component.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "PublicNetworkAccessForIngestion": // copying flattened property: diff --git a/v2/api/insights/v1api20200202storage/component_types_gen.go b/v2/api/insights/v1api20200202storage/component_types_gen.go index 0ea277bfe18..5a871f629af 100644 --- a/v2/api/insights/v1api20200202storage/component_types_gen.go +++ b/v2/api/insights/v1api20200202storage/component_types_gen.go @@ -111,11 +111,7 @@ func (component *Component) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (component *Component) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(component.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: component.Spec.Owner.Name, - } + return component.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/insights/v1beta20180501preview/webtest_types_gen.go b/v2/api/insights/v1beta20180501preview/webtest_types_gen.go index 39833711f81..124ac699f5d 100644 --- a/v2/api/insights/v1beta20180501preview/webtest_types_gen.go +++ b/v2/api/insights/v1beta20180501preview/webtest_types_gen.go @@ -142,11 +142,7 @@ func (webtest *Webtest) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (webtest *Webtest) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(webtest.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: webtest.Spec.Owner.Name, - } + return webtest.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -204,7 +200,7 @@ func (webtest *Webtest) ValidateUpdate(old runtime.Object) (admission.Warnings, // createValidations validates the creation of the resource func (webtest *Webtest) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){webtest.validateResourceReferences} + return []func() (admission.Warnings, error){webtest.validateResourceReferences, webtest.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -218,7 +214,16 @@ func (webtest *Webtest) updateValidations() []func(old runtime.Object) (admissio func(old runtime.Object) (admission.Warnings, error) { return webtest.validateResourceReferences() }, - webtest.validateWriteOnceProperties} + webtest.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return webtest.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (webtest *Webtest) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(webtest) } // validateResourceReferences validates all resource references @@ -552,7 +557,10 @@ func (webtest *Webtest_Spec) PopulateFromARM(owner genruntime.ArbitraryOwnerRefe } // Set property "Owner": - webtest.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + webtest.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "Request": // copying flattened property: diff --git a/v2/api/insights/v1beta20180501previewstorage/webtest_types_gen.go b/v2/api/insights/v1beta20180501previewstorage/webtest_types_gen.go index fe0b84d92f9..89b57c4d143 100644 --- a/v2/api/insights/v1beta20180501previewstorage/webtest_types_gen.go +++ b/v2/api/insights/v1beta20180501previewstorage/webtest_types_gen.go @@ -103,11 +103,7 @@ func (webtest *Webtest) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (webtest *Webtest) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(webtest.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: webtest.Spec.Owner.Name, - } + return webtest.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/insights/v1beta20200202/component_types_gen.go b/v2/api/insights/v1beta20200202/component_types_gen.go index 47a5b303c0f..c8f8057e4d5 100644 --- a/v2/api/insights/v1beta20200202/component_types_gen.go +++ b/v2/api/insights/v1beta20200202/component_types_gen.go @@ -169,11 +169,7 @@ func (component *Component) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (component *Component) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(component.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: component.Spec.Owner.Name, - } + return component.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -231,7 +227,7 @@ func (component *Component) ValidateUpdate(old runtime.Object) (admission.Warnin // createValidations validates the creation of the resource func (component *Component) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){component.validateResourceReferences, component.validateConfigMapDestinations} + return []func() (admission.Warnings, error){component.validateResourceReferences, component.validateOwnerReference, component.validateConfigMapDestinations} } // deleteValidations validates the deletion of the resource @@ -246,6 +242,9 @@ func (component *Component) updateValidations() []func(old runtime.Object) (admi return component.validateResourceReferences() }, component.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return component.validateOwnerReference() + }, func(old runtime.Object) (admission.Warnings, error) { return component.validateConfigMapDestinations() }, @@ -267,6 +266,11 @@ func (component *Component) validateConfigMapDestinations() (admission.Warnings, return genruntime.ValidateConfigMapDestinations(toValidate) } +// validateOwnerReference validates the owner field +func (component *Component) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(component) +} + // validateResourceReferences validates all resource references func (component *Component) validateResourceReferences() (admission.Warnings, error) { refs, err := reflecthelpers.FindResourceReferences(&component.Spec) @@ -627,7 +631,10 @@ func (component *Component_Spec) PopulateFromARM(owner genruntime.ArbitraryOwner // no assignment for property "OperatorSpec" // Set property "Owner": - component.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + component.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "PublicNetworkAccessForIngestion": // copying flattened property: diff --git a/v2/api/insights/v1beta20200202storage/component_types_gen.go b/v2/api/insights/v1beta20200202storage/component_types_gen.go index 3522ba84e72..dd5e58bcd4d 100644 --- a/v2/api/insights/v1beta20200202storage/component_types_gen.go +++ b/v2/api/insights/v1beta20200202storage/component_types_gen.go @@ -130,11 +130,7 @@ func (component *Component) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (component *Component) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(component.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: component.Spec.Owner.Name, - } + return component.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/keyvault/v1api20210401preview/vault_types_gen.go b/v2/api/keyvault/v1api20210401preview/vault_types_gen.go index 9383b2f665b..bd58e8bcdf3 100644 --- a/v2/api/keyvault/v1api20210401preview/vault_types_gen.go +++ b/v2/api/keyvault/v1api20210401preview/vault_types_gen.go @@ -141,11 +141,7 @@ func (vault *Vault) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (vault *Vault) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(vault.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: vault.Spec.Owner.Name, - } + return vault.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -203,7 +199,7 @@ func (vault *Vault) ValidateUpdate(old runtime.Object) (admission.Warnings, erro // createValidations validates the creation of the resource func (vault *Vault) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){vault.validateResourceReferences, vault.validateOptionalConfigMapReferences} + return []func() (admission.Warnings, error){vault.validateResourceReferences, vault.validateOwnerReference, vault.validateOptionalConfigMapReferences} } // deleteValidations validates the deletion of the resource @@ -218,6 +214,9 @@ func (vault *Vault) updateValidations() []func(old runtime.Object) (admission.Wa return vault.validateResourceReferences() }, vault.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return vault.validateOwnerReference() + }, func(old runtime.Object) (admission.Warnings, error) { return vault.validateOptionalConfigMapReferences() }, @@ -233,6 +232,11 @@ func (vault *Vault) validateOptionalConfigMapReferences() (admission.Warnings, e return genruntime.ValidateOptionalConfigMapReferences(refs) } +// validateOwnerReference validates the owner field +func (vault *Vault) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(vault) +} + // validateResourceReferences validates all resource references func (vault *Vault) validateResourceReferences() (admission.Warnings, error) { refs, err := reflecthelpers.FindResourceReferences(&vault.Spec) @@ -412,7 +416,10 @@ func (vault *Vault_Spec) PopulateFromARM(owner genruntime.ArbitraryOwnerReferenc } // Set property "Owner": - vault.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + vault.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "Properties": if typedInput.Properties != nil { diff --git a/v2/api/keyvault/v1api20210401previewstorage/vault_types_gen.go b/v2/api/keyvault/v1api20210401previewstorage/vault_types_gen.go index 8329ee3aa7e..8545dc6963a 100644 --- a/v2/api/keyvault/v1api20210401previewstorage/vault_types_gen.go +++ b/v2/api/keyvault/v1api20210401previewstorage/vault_types_gen.go @@ -84,11 +84,7 @@ func (vault *Vault) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (vault *Vault) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(vault.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: vault.Spec.Owner.Name, - } + return vault.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/keyvault/v1beta20210401preview/vault_types_gen.go b/v2/api/keyvault/v1beta20210401preview/vault_types_gen.go index 620c4f10e17..78f8370f6f7 100644 --- a/v2/api/keyvault/v1beta20210401preview/vault_types_gen.go +++ b/v2/api/keyvault/v1beta20210401preview/vault_types_gen.go @@ -142,11 +142,7 @@ func (vault *Vault) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (vault *Vault) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(vault.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: vault.Spec.Owner.Name, - } + return vault.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -204,7 +200,7 @@ func (vault *Vault) ValidateUpdate(old runtime.Object) (admission.Warnings, erro // createValidations validates the creation of the resource func (vault *Vault) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){vault.validateResourceReferences, vault.validateOptionalConfigMapReferences} + return []func() (admission.Warnings, error){vault.validateResourceReferences, vault.validateOwnerReference, vault.validateOptionalConfigMapReferences} } // deleteValidations validates the deletion of the resource @@ -219,6 +215,9 @@ func (vault *Vault) updateValidations() []func(old runtime.Object) (admission.Wa return vault.validateResourceReferences() }, vault.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return vault.validateOwnerReference() + }, func(old runtime.Object) (admission.Warnings, error) { return vault.validateOptionalConfigMapReferences() }, @@ -234,6 +233,11 @@ func (vault *Vault) validateOptionalConfigMapReferences() (admission.Warnings, e return genruntime.ValidateOptionalConfigMapReferences(refs) } +// validateOwnerReference validates the owner field +func (vault *Vault) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(vault) +} + // validateResourceReferences validates all resource references func (vault *Vault) validateResourceReferences() (admission.Warnings, error) { refs, err := reflecthelpers.FindResourceReferences(&vault.Spec) @@ -408,7 +412,10 @@ func (vault *Vault_Spec) PopulateFromARM(owner genruntime.ArbitraryOwnerReferenc } // Set property "Owner": - vault.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + vault.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "Properties": if typedInput.Properties != nil { diff --git a/v2/api/keyvault/v1beta20210401previewstorage/vault_types_gen.go b/v2/api/keyvault/v1beta20210401previewstorage/vault_types_gen.go index a898ef59a30..9d72041d8ff 100644 --- a/v2/api/keyvault/v1beta20210401previewstorage/vault_types_gen.go +++ b/v2/api/keyvault/v1beta20210401previewstorage/vault_types_gen.go @@ -103,11 +103,7 @@ func (vault *Vault) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (vault *Vault) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(vault.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: vault.Spec.Owner.Name, - } + return vault.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/machinelearningservices/v1api20210701/workspace_types_gen.go b/v2/api/machinelearningservices/v1api20210701/workspace_types_gen.go index 3c540b39627..89458e7120a 100644 --- a/v2/api/machinelearningservices/v1api20210701/workspace_types_gen.go +++ b/v2/api/machinelearningservices/v1api20210701/workspace_types_gen.go @@ -141,11 +141,7 @@ func (workspace *Workspace) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (workspace *Workspace) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(workspace.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: workspace.Spec.Owner.Name, - } + return workspace.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -203,7 +199,7 @@ func (workspace *Workspace) ValidateUpdate(old runtime.Object) (admission.Warnin // createValidations validates the creation of the resource func (workspace *Workspace) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){workspace.validateResourceReferences, workspace.validateSecretDestinations} + return []func() (admission.Warnings, error){workspace.validateResourceReferences, workspace.validateOwnerReference, workspace.validateSecretDestinations} } // deleteValidations validates the deletion of the resource @@ -218,12 +214,20 @@ func (workspace *Workspace) updateValidations() []func(old runtime.Object) (admi return workspace.validateResourceReferences() }, workspace.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return workspace.validateOwnerReference() + }, func(old runtime.Object) (admission.Warnings, error) { return workspace.validateSecretDestinations() }, } } +// validateOwnerReference validates the owner field +func (workspace *Workspace) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(workspace) +} + // validateResourceReferences validates all resource references func (workspace *Workspace) validateResourceReferences() (admission.Warnings, error) { refs, err := reflecthelpers.FindResourceReferences(&workspace.Spec) @@ -696,7 +700,10 @@ func (workspace *Workspace_Spec) PopulateFromARM(owner genruntime.ArbitraryOwner // no assignment for property "OperatorSpec" // Set property "Owner": - workspace.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + workspace.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // no assignment for property "PrimaryUserAssignedIdentityReference" diff --git a/v2/api/machinelearningservices/v1api20210701/workspaces_compute_types_gen.go b/v2/api/machinelearningservices/v1api20210701/workspaces_compute_types_gen.go index 51922f40213..128b3253988 100644 --- a/v2/api/machinelearningservices/v1api20210701/workspaces_compute_types_gen.go +++ b/v2/api/machinelearningservices/v1api20210701/workspaces_compute_types_gen.go @@ -142,11 +142,7 @@ func (compute *WorkspacesCompute) NewEmptyStatus() genruntime.ConvertibleStatus // Owner returns the ResourceReference of the owner func (compute *WorkspacesCompute) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(compute.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: compute.Spec.Owner.Name, - } + return compute.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -204,7 +200,7 @@ func (compute *WorkspacesCompute) ValidateUpdate(old runtime.Object) (admission. // createValidations validates the creation of the resource func (compute *WorkspacesCompute) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){compute.validateResourceReferences} + return []func() (admission.Warnings, error){compute.validateResourceReferences, compute.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -218,7 +214,16 @@ func (compute *WorkspacesCompute) updateValidations() []func(old runtime.Object) func(old runtime.Object) (admission.Warnings, error) { return compute.validateResourceReferences() }, - compute.validateWriteOnceProperties} + compute.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return compute.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (compute *WorkspacesCompute) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(compute) } // validateResourceReferences validates all resource references @@ -442,7 +447,10 @@ func (compute *Workspaces_Compute_Spec) PopulateFromARM(owner genruntime.Arbitra } // Set property "Owner": - compute.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + compute.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "Properties": if typedInput.Properties != nil { diff --git a/v2/api/machinelearningservices/v1api20210701/workspaces_connection_types_gen.go b/v2/api/machinelearningservices/v1api20210701/workspaces_connection_types_gen.go index 53e8622f69c..97662e658ff 100644 --- a/v2/api/machinelearningservices/v1api20210701/workspaces_connection_types_gen.go +++ b/v2/api/machinelearningservices/v1api20210701/workspaces_connection_types_gen.go @@ -141,11 +141,7 @@ func (connection *WorkspacesConnection) NewEmptyStatus() genruntime.ConvertibleS // Owner returns the ResourceReference of the owner func (connection *WorkspacesConnection) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(connection.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: connection.Spec.Owner.Name, - } + return connection.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -203,7 +199,7 @@ func (connection *WorkspacesConnection) ValidateUpdate(old runtime.Object) (admi // createValidations validates the creation of the resource func (connection *WorkspacesConnection) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){connection.validateResourceReferences} + return []func() (admission.Warnings, error){connection.validateResourceReferences, connection.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -217,7 +213,16 @@ func (connection *WorkspacesConnection) updateValidations() []func(old runtime.O func(old runtime.Object) (admission.Warnings, error) { return connection.validateResourceReferences() }, - connection.validateWriteOnceProperties} + connection.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return connection.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (connection *WorkspacesConnection) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(connection) } // validateResourceReferences validates all resource references @@ -414,7 +419,10 @@ func (connection *Workspaces_Connection_Spec) PopulateFromARM(owner genruntime.A } // Set property "Owner": - connection.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + connection.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "Target": // copying flattened property: diff --git a/v2/api/machinelearningservices/v1api20210701storage/workspace_types_gen.go b/v2/api/machinelearningservices/v1api20210701storage/workspace_types_gen.go index d08c69f2d97..48d90f930d0 100644 --- a/v2/api/machinelearningservices/v1api20210701storage/workspace_types_gen.go +++ b/v2/api/machinelearningservices/v1api20210701storage/workspace_types_gen.go @@ -84,11 +84,7 @@ func (workspace *Workspace) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (workspace *Workspace) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(workspace.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: workspace.Spec.Owner.Name, - } + return workspace.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/machinelearningservices/v1api20210701storage/workspaces_compute_types_gen.go b/v2/api/machinelearningservices/v1api20210701storage/workspaces_compute_types_gen.go index 65474fa5433..3194b4eb017 100644 --- a/v2/api/machinelearningservices/v1api20210701storage/workspaces_compute_types_gen.go +++ b/v2/api/machinelearningservices/v1api20210701storage/workspaces_compute_types_gen.go @@ -85,11 +85,7 @@ func (compute *WorkspacesCompute) NewEmptyStatus() genruntime.ConvertibleStatus // Owner returns the ResourceReference of the owner func (compute *WorkspacesCompute) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(compute.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: compute.Spec.Owner.Name, - } + return compute.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/machinelearningservices/v1api20210701storage/workspaces_connection_types_gen.go b/v2/api/machinelearningservices/v1api20210701storage/workspaces_connection_types_gen.go index fa806328eb3..0103ced0360 100644 --- a/v2/api/machinelearningservices/v1api20210701storage/workspaces_connection_types_gen.go +++ b/v2/api/machinelearningservices/v1api20210701storage/workspaces_connection_types_gen.go @@ -84,11 +84,7 @@ func (connection *WorkspacesConnection) NewEmptyStatus() genruntime.ConvertibleS // Owner returns the ResourceReference of the owner func (connection *WorkspacesConnection) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(connection.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: connection.Spec.Owner.Name, - } + return connection.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/machinelearningservices/v1beta20210701/workspace_types_gen.go b/v2/api/machinelearningservices/v1beta20210701/workspace_types_gen.go index cbb9b3bb0e2..4543b3f475d 100644 --- a/v2/api/machinelearningservices/v1beta20210701/workspace_types_gen.go +++ b/v2/api/machinelearningservices/v1beta20210701/workspace_types_gen.go @@ -142,11 +142,7 @@ func (workspace *Workspace) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (workspace *Workspace) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(workspace.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: workspace.Spec.Owner.Name, - } + return workspace.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -204,7 +200,7 @@ func (workspace *Workspace) ValidateUpdate(old runtime.Object) (admission.Warnin // createValidations validates the creation of the resource func (workspace *Workspace) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){workspace.validateResourceReferences, workspace.validateSecretDestinations} + return []func() (admission.Warnings, error){workspace.validateResourceReferences, workspace.validateOwnerReference, workspace.validateSecretDestinations} } // deleteValidations validates the deletion of the resource @@ -219,12 +215,20 @@ func (workspace *Workspace) updateValidations() []func(old runtime.Object) (admi return workspace.validateResourceReferences() }, workspace.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return workspace.validateOwnerReference() + }, func(old runtime.Object) (admission.Warnings, error) { return workspace.validateSecretDestinations() }, } } +// validateOwnerReference validates the owner field +func (workspace *Workspace) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(workspace) +} + // validateResourceReferences validates all resource references func (workspace *Workspace) validateResourceReferences() (admission.Warnings, error) { refs, err := reflecthelpers.FindResourceReferences(&workspace.Spec) @@ -653,7 +657,10 @@ func (workspace *Workspace_Spec) PopulateFromARM(owner genruntime.ArbitraryOwner // no assignment for property "OperatorSpec" // Set property "Owner": - workspace.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + workspace.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // no assignment for property "PrimaryUserAssignedIdentityReference" diff --git a/v2/api/machinelearningservices/v1beta20210701/workspaces_compute_types_gen.go b/v2/api/machinelearningservices/v1beta20210701/workspaces_compute_types_gen.go index c30e00c0b57..1e5516975dc 100644 --- a/v2/api/machinelearningservices/v1beta20210701/workspaces_compute_types_gen.go +++ b/v2/api/machinelearningservices/v1beta20210701/workspaces_compute_types_gen.go @@ -143,11 +143,7 @@ func (compute *WorkspacesCompute) NewEmptyStatus() genruntime.ConvertibleStatus // Owner returns the ResourceReference of the owner func (compute *WorkspacesCompute) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(compute.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: compute.Spec.Owner.Name, - } + return compute.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -205,7 +201,7 @@ func (compute *WorkspacesCompute) ValidateUpdate(old runtime.Object) (admission. // createValidations validates the creation of the resource func (compute *WorkspacesCompute) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){compute.validateResourceReferences} + return []func() (admission.Warnings, error){compute.validateResourceReferences, compute.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -219,7 +215,16 @@ func (compute *WorkspacesCompute) updateValidations() []func(old runtime.Object) func(old runtime.Object) (admission.Warnings, error) { return compute.validateResourceReferences() }, - compute.validateWriteOnceProperties} + compute.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return compute.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (compute *WorkspacesCompute) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(compute) } // validateResourceReferences validates all resource references @@ -429,7 +434,10 @@ func (compute *Workspaces_Compute_Spec) PopulateFromARM(owner genruntime.Arbitra } // Set property "Owner": - compute.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + compute.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "Properties": if typedInput.Properties != nil { diff --git a/v2/api/machinelearningservices/v1beta20210701/workspaces_connection_types_gen.go b/v2/api/machinelearningservices/v1beta20210701/workspaces_connection_types_gen.go index cf8f1ce49d8..71cd07e2264 100644 --- a/v2/api/machinelearningservices/v1beta20210701/workspaces_connection_types_gen.go +++ b/v2/api/machinelearningservices/v1beta20210701/workspaces_connection_types_gen.go @@ -142,11 +142,7 @@ func (connection *WorkspacesConnection) NewEmptyStatus() genruntime.ConvertibleS // Owner returns the ResourceReference of the owner func (connection *WorkspacesConnection) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(connection.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: connection.Spec.Owner.Name, - } + return connection.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -204,7 +200,7 @@ func (connection *WorkspacesConnection) ValidateUpdate(old runtime.Object) (admi // createValidations validates the creation of the resource func (connection *WorkspacesConnection) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){connection.validateResourceReferences} + return []func() (admission.Warnings, error){connection.validateResourceReferences, connection.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -218,7 +214,16 @@ func (connection *WorkspacesConnection) updateValidations() []func(old runtime.O func(old runtime.Object) (admission.Warnings, error) { return connection.validateResourceReferences() }, - connection.validateWriteOnceProperties} + connection.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return connection.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (connection *WorkspacesConnection) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(connection) } // validateResourceReferences validates all resource references @@ -404,7 +409,10 @@ func (connection *Workspaces_Connection_Spec) PopulateFromARM(owner genruntime.A } // Set property "Owner": - connection.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + connection.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "Target": // copying flattened property: diff --git a/v2/api/machinelearningservices/v1beta20210701storage/workspace_types_gen.go b/v2/api/machinelearningservices/v1beta20210701storage/workspace_types_gen.go index 31b072cc737..60c1984ab04 100644 --- a/v2/api/machinelearningservices/v1beta20210701storage/workspace_types_gen.go +++ b/v2/api/machinelearningservices/v1beta20210701storage/workspace_types_gen.go @@ -103,11 +103,7 @@ func (workspace *Workspace) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (workspace *Workspace) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(workspace.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: workspace.Spec.Owner.Name, - } + return workspace.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/machinelearningservices/v1beta20210701storage/workspaces_compute_types_gen.go b/v2/api/machinelearningservices/v1beta20210701storage/workspaces_compute_types_gen.go index 4b5ecc1b20e..ed6d45c8c7b 100644 --- a/v2/api/machinelearningservices/v1beta20210701storage/workspaces_compute_types_gen.go +++ b/v2/api/machinelearningservices/v1beta20210701storage/workspaces_compute_types_gen.go @@ -104,11 +104,7 @@ func (compute *WorkspacesCompute) NewEmptyStatus() genruntime.ConvertibleStatus // Owner returns the ResourceReference of the owner func (compute *WorkspacesCompute) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(compute.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: compute.Spec.Owner.Name, - } + return compute.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/machinelearningservices/v1beta20210701storage/workspaces_connection_types_gen.go b/v2/api/machinelearningservices/v1beta20210701storage/workspaces_connection_types_gen.go index 30c9eebec70..8a9e72181ec 100644 --- a/v2/api/machinelearningservices/v1beta20210701storage/workspaces_connection_types_gen.go +++ b/v2/api/machinelearningservices/v1beta20210701storage/workspaces_connection_types_gen.go @@ -103,11 +103,7 @@ func (connection *WorkspacesConnection) NewEmptyStatus() genruntime.ConvertibleS // Owner returns the ResourceReference of the owner func (connection *WorkspacesConnection) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(connection.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: connection.Spec.Owner.Name, - } + return connection.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/managedidentity/v1api20181130/user_assigned_identity_types_gen.go b/v2/api/managedidentity/v1api20181130/user_assigned_identity_types_gen.go index 9e294113129..0c45894f364 100644 --- a/v2/api/managedidentity/v1api20181130/user_assigned_identity_types_gen.go +++ b/v2/api/managedidentity/v1api20181130/user_assigned_identity_types_gen.go @@ -173,11 +173,7 @@ func (identity *UserAssignedIdentity) NewEmptyStatus() genruntime.ConvertibleSta // Owner returns the ResourceReference of the owner func (identity *UserAssignedIdentity) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(identity.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: identity.Spec.Owner.Name, - } + return identity.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -235,7 +231,7 @@ func (identity *UserAssignedIdentity) ValidateUpdate(old runtime.Object) (admiss // createValidations validates the creation of the resource func (identity *UserAssignedIdentity) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){identity.validateResourceReferences, identity.validateConfigMapDestinations} + return []func() (admission.Warnings, error){identity.validateResourceReferences, identity.validateOwnerReference, identity.validateConfigMapDestinations} } // deleteValidations validates the deletion of the resource @@ -250,6 +246,9 @@ func (identity *UserAssignedIdentity) updateValidations() []func(old runtime.Obj return identity.validateResourceReferences() }, identity.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return identity.validateOwnerReference() + }, func(old runtime.Object) (admission.Warnings, error) { return identity.validateConfigMapDestinations() }, @@ -272,6 +271,11 @@ func (identity *UserAssignedIdentity) validateConfigMapDestinations() (admission return genruntime.ValidateConfigMapDestinations(toValidate) } +// validateOwnerReference validates the owner field +func (identity *UserAssignedIdentity) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(identity) +} + // validateResourceReferences validates all resource references func (identity *UserAssignedIdentity) validateResourceReferences() (admission.Warnings, error) { refs, err := reflecthelpers.FindResourceReferences(&identity.Spec) @@ -442,7 +446,10 @@ func (identity *UserAssignedIdentity_Spec) PopulateFromARM(owner genruntime.Arbi // no assignment for property "OperatorSpec" // Set property "Owner": - identity.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + identity.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "Tags": if typedInput.Tags != nil { diff --git a/v2/api/managedidentity/v1api20181130storage/user_assigned_identity_types_gen.go b/v2/api/managedidentity/v1api20181130storage/user_assigned_identity_types_gen.go index 065993e0955..65dc6d7d842 100644 --- a/v2/api/managedidentity/v1api20181130storage/user_assigned_identity_types_gen.go +++ b/v2/api/managedidentity/v1api20181130storage/user_assigned_identity_types_gen.go @@ -116,11 +116,7 @@ func (identity *UserAssignedIdentity) NewEmptyStatus() genruntime.ConvertibleSta // Owner returns the ResourceReference of the owner func (identity *UserAssignedIdentity) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(identity.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: identity.Spec.Owner.Name, - } + return identity.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/managedidentity/v1api20220131preview/federated_identity_credential_types_gen.go b/v2/api/managedidentity/v1api20220131preview/federated_identity_credential_types_gen.go index e0376d001d8..bc8bddf3634 100644 --- a/v2/api/managedidentity/v1api20220131preview/federated_identity_credential_types_gen.go +++ b/v2/api/managedidentity/v1api20220131preview/federated_identity_credential_types_gen.go @@ -141,11 +141,7 @@ func (credential *FederatedIdentityCredential) NewEmptyStatus() genruntime.Conve // Owner returns the ResourceReference of the owner func (credential *FederatedIdentityCredential) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(credential.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: credential.Spec.Owner.Name, - } + return credential.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -203,7 +199,7 @@ func (credential *FederatedIdentityCredential) ValidateUpdate(old runtime.Object // createValidations validates the creation of the resource func (credential *FederatedIdentityCredential) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){credential.validateResourceReferences, credential.validateOptionalConfigMapReferences} + return []func() (admission.Warnings, error){credential.validateResourceReferences, credential.validateOwnerReference, credential.validateOptionalConfigMapReferences} } // deleteValidations validates the deletion of the resource @@ -218,6 +214,9 @@ func (credential *FederatedIdentityCredential) updateValidations() []func(old ru return credential.validateResourceReferences() }, credential.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return credential.validateOwnerReference() + }, func(old runtime.Object) (admission.Warnings, error) { return credential.validateOptionalConfigMapReferences() }, @@ -233,6 +232,11 @@ func (credential *FederatedIdentityCredential) validateOptionalConfigMapReferenc return genruntime.ValidateOptionalConfigMapReferences(refs) } +// validateOwnerReference validates the owner field +func (credential *FederatedIdentityCredential) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(credential) +} + // validateResourceReferences validates all resource references func (credential *FederatedIdentityCredential) validateResourceReferences() (admission.Warnings, error) { refs, err := reflecthelpers.FindResourceReferences(&credential.Spec) @@ -441,7 +445,10 @@ func (credential *UserAssignedIdentities_FederatedIdentityCredential_Spec) Popul // no assignment for property "IssuerFromConfig" // Set property "Owner": - credential.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + credential.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "Subject": // copying flattened property: diff --git a/v2/api/managedidentity/v1api20220131previewstorage/federated_identity_credential_types_gen.go b/v2/api/managedidentity/v1api20220131previewstorage/federated_identity_credential_types_gen.go index 432d903ca1a..c459e00b7ad 100644 --- a/v2/api/managedidentity/v1api20220131previewstorage/federated_identity_credential_types_gen.go +++ b/v2/api/managedidentity/v1api20220131previewstorage/federated_identity_credential_types_gen.go @@ -84,11 +84,7 @@ func (credential *FederatedIdentityCredential) NewEmptyStatus() genruntime.Conve // Owner returns the ResourceReference of the owner func (credential *FederatedIdentityCredential) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(credential.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: credential.Spec.Owner.Name, - } + return credential.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/managedidentity/v1beta20181130/user_assigned_identity_types_gen.go b/v2/api/managedidentity/v1beta20181130/user_assigned_identity_types_gen.go index fa6ed1feb47..29bf392f637 100644 --- a/v2/api/managedidentity/v1beta20181130/user_assigned_identity_types_gen.go +++ b/v2/api/managedidentity/v1beta20181130/user_assigned_identity_types_gen.go @@ -174,11 +174,7 @@ func (identity *UserAssignedIdentity) NewEmptyStatus() genruntime.ConvertibleSta // Owner returns the ResourceReference of the owner func (identity *UserAssignedIdentity) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(identity.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: identity.Spec.Owner.Name, - } + return identity.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -236,7 +232,7 @@ func (identity *UserAssignedIdentity) ValidateUpdate(old runtime.Object) (admiss // createValidations validates the creation of the resource func (identity *UserAssignedIdentity) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){identity.validateResourceReferences, identity.validateConfigMapDestinations} + return []func() (admission.Warnings, error){identity.validateResourceReferences, identity.validateOwnerReference, identity.validateConfigMapDestinations} } // deleteValidations validates the deletion of the resource @@ -251,6 +247,9 @@ func (identity *UserAssignedIdentity) updateValidations() []func(old runtime.Obj return identity.validateResourceReferences() }, identity.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return identity.validateOwnerReference() + }, func(old runtime.Object) (admission.Warnings, error) { return identity.validateConfigMapDestinations() }, @@ -273,6 +272,11 @@ func (identity *UserAssignedIdentity) validateConfigMapDestinations() (admission return genruntime.ValidateConfigMapDestinations(toValidate) } +// validateOwnerReference validates the owner field +func (identity *UserAssignedIdentity) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(identity) +} + // validateResourceReferences validates all resource references func (identity *UserAssignedIdentity) validateResourceReferences() (admission.Warnings, error) { refs, err := reflecthelpers.FindResourceReferences(&identity.Spec) @@ -439,7 +443,10 @@ func (identity *UserAssignedIdentity_Spec) PopulateFromARM(owner genruntime.Arbi // no assignment for property "OperatorSpec" // Set property "Owner": - identity.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + identity.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "Tags": if typedInput.Tags != nil { diff --git a/v2/api/managedidentity/v1beta20181130storage/user_assigned_identity_types_gen.go b/v2/api/managedidentity/v1beta20181130storage/user_assigned_identity_types_gen.go index e2f16dfa587..67c19b7d141 100644 --- a/v2/api/managedidentity/v1beta20181130storage/user_assigned_identity_types_gen.go +++ b/v2/api/managedidentity/v1beta20181130storage/user_assigned_identity_types_gen.go @@ -135,11 +135,7 @@ func (identity *UserAssignedIdentity) NewEmptyStatus() genruntime.ConvertibleSta // Owner returns the ResourceReference of the owner func (identity *UserAssignedIdentity) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(identity.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: identity.Spec.Owner.Name, - } + return identity.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/managedidentity/v1beta20220131preview/federated_identity_credential_types_gen.go b/v2/api/managedidentity/v1beta20220131preview/federated_identity_credential_types_gen.go index 1e8f616a2fb..09765747c3b 100644 --- a/v2/api/managedidentity/v1beta20220131preview/federated_identity_credential_types_gen.go +++ b/v2/api/managedidentity/v1beta20220131preview/federated_identity_credential_types_gen.go @@ -142,11 +142,7 @@ func (credential *FederatedIdentityCredential) NewEmptyStatus() genruntime.Conve // Owner returns the ResourceReference of the owner func (credential *FederatedIdentityCredential) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(credential.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: credential.Spec.Owner.Name, - } + return credential.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -204,7 +200,7 @@ func (credential *FederatedIdentityCredential) ValidateUpdate(old runtime.Object // createValidations validates the creation of the resource func (credential *FederatedIdentityCredential) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){credential.validateResourceReferences, credential.validateOptionalConfigMapReferences} + return []func() (admission.Warnings, error){credential.validateResourceReferences, credential.validateOwnerReference, credential.validateOptionalConfigMapReferences} } // deleteValidations validates the deletion of the resource @@ -219,6 +215,9 @@ func (credential *FederatedIdentityCredential) updateValidations() []func(old ru return credential.validateResourceReferences() }, credential.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return credential.validateOwnerReference() + }, func(old runtime.Object) (admission.Warnings, error) { return credential.validateOptionalConfigMapReferences() }, @@ -234,6 +233,11 @@ func (credential *FederatedIdentityCredential) validateOptionalConfigMapReferenc return genruntime.ValidateOptionalConfigMapReferences(refs) } +// validateOwnerReference validates the owner field +func (credential *FederatedIdentityCredential) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(credential) +} + // validateResourceReferences validates all resource references func (credential *FederatedIdentityCredential) validateResourceReferences() (admission.Warnings, error) { refs, err := reflecthelpers.FindResourceReferences(&credential.Spec) @@ -432,7 +436,10 @@ func (credential *UserAssignedIdentities_FederatedIdentityCredential_Spec) Popul // no assignment for property "IssuerFromConfig" // Set property "Owner": - credential.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + credential.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "Subject": // copying flattened property: diff --git a/v2/api/managedidentity/v1beta20220131previewstorage/federated_identity_credential_types_gen.go b/v2/api/managedidentity/v1beta20220131previewstorage/federated_identity_credential_types_gen.go index cf01e03d81c..9bb9911e8d7 100644 --- a/v2/api/managedidentity/v1beta20220131previewstorage/federated_identity_credential_types_gen.go +++ b/v2/api/managedidentity/v1beta20220131previewstorage/federated_identity_credential_types_gen.go @@ -103,11 +103,7 @@ func (credential *FederatedIdentityCredential) NewEmptyStatus() genruntime.Conve // Owner returns the ResourceReference of the owner func (credential *FederatedIdentityCredential) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(credential.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: credential.Spec.Owner.Name, - } + return credential.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/network/v1api20180501/dns_zone_types_gen.go b/v2/api/network/v1api20180501/dns_zone_types_gen.go index 23a4c18de6a..9e93e188e0f 100644 --- a/v2/api/network/v1api20180501/dns_zone_types_gen.go +++ b/v2/api/network/v1api20180501/dns_zone_types_gen.go @@ -141,11 +141,7 @@ func (zone *DnsZone) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (zone *DnsZone) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(zone.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: zone.Spec.Owner.Name, - } + return zone.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -203,7 +199,7 @@ func (zone *DnsZone) ValidateUpdate(old runtime.Object) (admission.Warnings, err // createValidations validates the creation of the resource func (zone *DnsZone) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){zone.validateResourceReferences} + return []func() (admission.Warnings, error){zone.validateResourceReferences, zone.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -217,7 +213,16 @@ func (zone *DnsZone) updateValidations() []func(old runtime.Object) (admission.W func(old runtime.Object) (admission.Warnings, error) { return zone.validateResourceReferences() }, - zone.validateWriteOnceProperties} + zone.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return zone.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (zone *DnsZone) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(zone) } // validateResourceReferences validates all resource references @@ -420,7 +425,10 @@ func (zone *DnsZone_Spec) PopulateFromARM(owner genruntime.ArbitraryOwnerReferen } // Set property "Owner": - zone.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + zone.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "RegistrationVirtualNetworks": // copying flattened property: diff --git a/v2/api/network/v1api20180501/dns_zones_a_record_types_gen.go b/v2/api/network/v1api20180501/dns_zones_a_record_types_gen.go index c9f4ce94490..1dacd8c471c 100644 --- a/v2/api/network/v1api20180501/dns_zones_a_record_types_gen.go +++ b/v2/api/network/v1api20180501/dns_zones_a_record_types_gen.go @@ -141,11 +141,7 @@ func (record *DnsZonesARecord) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (record *DnsZonesARecord) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(record.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: record.Spec.Owner.Name, - } + return record.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -203,7 +199,7 @@ func (record *DnsZonesARecord) ValidateUpdate(old runtime.Object) (admission.War // createValidations validates the creation of the resource func (record *DnsZonesARecord) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){record.validateResourceReferences} + return []func() (admission.Warnings, error){record.validateResourceReferences, record.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -217,7 +213,16 @@ func (record *DnsZonesARecord) updateValidations() []func(old runtime.Object) (a func(old runtime.Object) (admission.Warnings, error) { return record.validateResourceReferences() }, - record.validateWriteOnceProperties} + record.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return record.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (record *DnsZonesARecord) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(record) } // validateResourceReferences validates all resource references @@ -603,7 +608,10 @@ func (zonesA *DnsZones_A_Spec) PopulateFromARM(owner genruntime.ArbitraryOwnerRe } // Set property "Owner": - zonesA.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + zonesA.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "PTRRecords": // copying flattened property: diff --git a/v2/api/network/v1api20180501/dns_zones_aaaa_record_types_gen.go b/v2/api/network/v1api20180501/dns_zones_aaaa_record_types_gen.go index 7cbb2490ecf..48779a11699 100644 --- a/v2/api/network/v1api20180501/dns_zones_aaaa_record_types_gen.go +++ b/v2/api/network/v1api20180501/dns_zones_aaaa_record_types_gen.go @@ -141,11 +141,7 @@ func (record *DnsZonesAAAARecord) NewEmptyStatus() genruntime.ConvertibleStatus // Owner returns the ResourceReference of the owner func (record *DnsZonesAAAARecord) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(record.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: record.Spec.Owner.Name, - } + return record.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -203,7 +199,7 @@ func (record *DnsZonesAAAARecord) ValidateUpdate(old runtime.Object) (admission. // createValidations validates the creation of the resource func (record *DnsZonesAAAARecord) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){record.validateResourceReferences} + return []func() (admission.Warnings, error){record.validateResourceReferences, record.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -217,7 +213,16 @@ func (record *DnsZonesAAAARecord) updateValidations() []func(old runtime.Object) func(old runtime.Object) (admission.Warnings, error) { return record.validateResourceReferences() }, - record.validateWriteOnceProperties} + record.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return record.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (record *DnsZonesAAAARecord) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(record) } // validateResourceReferences validates all resource references @@ -588,7 +593,10 @@ func (aaaa *DnsZones_AAAA_Spec) PopulateFromARM(owner genruntime.ArbitraryOwnerR } // Set property "Owner": - aaaa.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + aaaa.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "PTRRecords": // copying flattened property: diff --git a/v2/api/network/v1api20180501/dns_zones_caa_record_types_gen.go b/v2/api/network/v1api20180501/dns_zones_caa_record_types_gen.go index a8fffbdf6f9..c12a7e74ea2 100644 --- a/v2/api/network/v1api20180501/dns_zones_caa_record_types_gen.go +++ b/v2/api/network/v1api20180501/dns_zones_caa_record_types_gen.go @@ -141,11 +141,7 @@ func (record *DnsZonesCAARecord) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (record *DnsZonesCAARecord) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(record.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: record.Spec.Owner.Name, - } + return record.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -203,7 +199,7 @@ func (record *DnsZonesCAARecord) ValidateUpdate(old runtime.Object) (admission.W // createValidations validates the creation of the resource func (record *DnsZonesCAARecord) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){record.validateResourceReferences} + return []func() (admission.Warnings, error){record.validateResourceReferences, record.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -217,7 +213,16 @@ func (record *DnsZonesCAARecord) updateValidations() []func(old runtime.Object) func(old runtime.Object) (admission.Warnings, error) { return record.validateResourceReferences() }, - record.validateWriteOnceProperties} + record.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return record.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (record *DnsZonesCAARecord) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(record) } // validateResourceReferences validates all resource references @@ -588,7 +593,10 @@ func (zonesCAA *DnsZones_CAA_Spec) PopulateFromARM(owner genruntime.ArbitraryOwn } // Set property "Owner": - zonesCAA.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + zonesCAA.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "PTRRecords": // copying flattened property: diff --git a/v2/api/network/v1api20180501/dns_zones_cname_record_types_gen.go b/v2/api/network/v1api20180501/dns_zones_cname_record_types_gen.go index 82e41f0ba84..2b555385161 100644 --- a/v2/api/network/v1api20180501/dns_zones_cname_record_types_gen.go +++ b/v2/api/network/v1api20180501/dns_zones_cname_record_types_gen.go @@ -141,11 +141,7 @@ func (record *DnsZonesCNAMERecord) NewEmptyStatus() genruntime.ConvertibleStatus // Owner returns the ResourceReference of the owner func (record *DnsZonesCNAMERecord) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(record.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: record.Spec.Owner.Name, - } + return record.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -203,7 +199,7 @@ func (record *DnsZonesCNAMERecord) ValidateUpdate(old runtime.Object) (admission // createValidations validates the creation of the resource func (record *DnsZonesCNAMERecord) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){record.validateResourceReferences} + return []func() (admission.Warnings, error){record.validateResourceReferences, record.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -217,7 +213,16 @@ func (record *DnsZonesCNAMERecord) updateValidations() []func(old runtime.Object func(old runtime.Object) (admission.Warnings, error) { return record.validateResourceReferences() }, - record.validateWriteOnceProperties} + record.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return record.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (record *DnsZonesCNAMERecord) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(record) } // validateResourceReferences validates all resource references @@ -588,7 +593,10 @@ func (cname *DnsZones_CNAME_Spec) PopulateFromARM(owner genruntime.ArbitraryOwne } // Set property "Owner": - cname.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + cname.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "PTRRecords": // copying flattened property: diff --git a/v2/api/network/v1api20180501/dns_zones_mx_record_types_gen.go b/v2/api/network/v1api20180501/dns_zones_mx_record_types_gen.go index 9e137d78556..0b16f3f8519 100644 --- a/v2/api/network/v1api20180501/dns_zones_mx_record_types_gen.go +++ b/v2/api/network/v1api20180501/dns_zones_mx_record_types_gen.go @@ -141,11 +141,7 @@ func (record *DnsZonesMXRecord) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (record *DnsZonesMXRecord) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(record.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: record.Spec.Owner.Name, - } + return record.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -203,7 +199,7 @@ func (record *DnsZonesMXRecord) ValidateUpdate(old runtime.Object) (admission.Wa // createValidations validates the creation of the resource func (record *DnsZonesMXRecord) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){record.validateResourceReferences} + return []func() (admission.Warnings, error){record.validateResourceReferences, record.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -217,7 +213,16 @@ func (record *DnsZonesMXRecord) updateValidations() []func(old runtime.Object) ( func(old runtime.Object) (admission.Warnings, error) { return record.validateResourceReferences() }, - record.validateWriteOnceProperties} + record.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return record.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (record *DnsZonesMXRecord) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(record) } // validateResourceReferences validates all resource references @@ -588,7 +593,10 @@ func (zonesMX *DnsZones_MX_Spec) PopulateFromARM(owner genruntime.ArbitraryOwner } // Set property "Owner": - zonesMX.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + zonesMX.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "PTRRecords": // copying flattened property: diff --git a/v2/api/network/v1api20180501/dns_zones_ns_record_types_gen.go b/v2/api/network/v1api20180501/dns_zones_ns_record_types_gen.go index 88030a3451a..253383c41c9 100644 --- a/v2/api/network/v1api20180501/dns_zones_ns_record_types_gen.go +++ b/v2/api/network/v1api20180501/dns_zones_ns_record_types_gen.go @@ -141,11 +141,7 @@ func (record *DnsZonesNSRecord) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (record *DnsZonesNSRecord) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(record.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: record.Spec.Owner.Name, - } + return record.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -203,7 +199,7 @@ func (record *DnsZonesNSRecord) ValidateUpdate(old runtime.Object) (admission.Wa // createValidations validates the creation of the resource func (record *DnsZonesNSRecord) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){record.validateResourceReferences} + return []func() (admission.Warnings, error){record.validateResourceReferences, record.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -217,7 +213,16 @@ func (record *DnsZonesNSRecord) updateValidations() []func(old runtime.Object) ( func(old runtime.Object) (admission.Warnings, error) { return record.validateResourceReferences() }, - record.validateWriteOnceProperties} + record.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return record.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (record *DnsZonesNSRecord) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(record) } // validateResourceReferences validates all resource references @@ -588,7 +593,10 @@ func (zonesNS *DnsZones_NS_Spec) PopulateFromARM(owner genruntime.ArbitraryOwner } // Set property "Owner": - zonesNS.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + zonesNS.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "PTRRecords": // copying flattened property: diff --git a/v2/api/network/v1api20180501/dns_zones_ptr_record_types_gen.go b/v2/api/network/v1api20180501/dns_zones_ptr_record_types_gen.go index f7fcc723234..29a7c2ed397 100644 --- a/v2/api/network/v1api20180501/dns_zones_ptr_record_types_gen.go +++ b/v2/api/network/v1api20180501/dns_zones_ptr_record_types_gen.go @@ -141,11 +141,7 @@ func (record *DnsZonesPTRRecord) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (record *DnsZonesPTRRecord) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(record.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: record.Spec.Owner.Name, - } + return record.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -203,7 +199,7 @@ func (record *DnsZonesPTRRecord) ValidateUpdate(old runtime.Object) (admission.W // createValidations validates the creation of the resource func (record *DnsZonesPTRRecord) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){record.validateResourceReferences} + return []func() (admission.Warnings, error){record.validateResourceReferences, record.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -217,7 +213,16 @@ func (record *DnsZonesPTRRecord) updateValidations() []func(old runtime.Object) func(old runtime.Object) (admission.Warnings, error) { return record.validateResourceReferences() }, - record.validateWriteOnceProperties} + record.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return record.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (record *DnsZonesPTRRecord) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(record) } // validateResourceReferences validates all resource references @@ -588,7 +593,10 @@ func (zonesPTR *DnsZones_PTR_Spec) PopulateFromARM(owner genruntime.ArbitraryOwn } // Set property "Owner": - zonesPTR.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + zonesPTR.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "PTRRecords": // copying flattened property: diff --git a/v2/api/network/v1api20180501/dns_zones_srv_record_types_gen.go b/v2/api/network/v1api20180501/dns_zones_srv_record_types_gen.go index 6c74607c605..c68a5bbf8a6 100644 --- a/v2/api/network/v1api20180501/dns_zones_srv_record_types_gen.go +++ b/v2/api/network/v1api20180501/dns_zones_srv_record_types_gen.go @@ -141,11 +141,7 @@ func (record *DnsZonesSRVRecord) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (record *DnsZonesSRVRecord) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(record.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: record.Spec.Owner.Name, - } + return record.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -203,7 +199,7 @@ func (record *DnsZonesSRVRecord) ValidateUpdate(old runtime.Object) (admission.W // createValidations validates the creation of the resource func (record *DnsZonesSRVRecord) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){record.validateResourceReferences} + return []func() (admission.Warnings, error){record.validateResourceReferences, record.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -217,7 +213,16 @@ func (record *DnsZonesSRVRecord) updateValidations() []func(old runtime.Object) func(old runtime.Object) (admission.Warnings, error) { return record.validateResourceReferences() }, - record.validateWriteOnceProperties} + record.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return record.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (record *DnsZonesSRVRecord) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(record) } // validateResourceReferences validates all resource references @@ -588,7 +593,10 @@ func (zonesSRV *DnsZones_SRV_Spec) PopulateFromARM(owner genruntime.ArbitraryOwn } // Set property "Owner": - zonesSRV.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + zonesSRV.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "PTRRecords": // copying flattened property: diff --git a/v2/api/network/v1api20180501/dns_zones_txt_record_types_gen.go b/v2/api/network/v1api20180501/dns_zones_txt_record_types_gen.go index ee075187d83..33c3018fbc7 100644 --- a/v2/api/network/v1api20180501/dns_zones_txt_record_types_gen.go +++ b/v2/api/network/v1api20180501/dns_zones_txt_record_types_gen.go @@ -141,11 +141,7 @@ func (record *DnsZonesTXTRecord) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (record *DnsZonesTXTRecord) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(record.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: record.Spec.Owner.Name, - } + return record.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -203,7 +199,7 @@ func (record *DnsZonesTXTRecord) ValidateUpdate(old runtime.Object) (admission.W // createValidations validates the creation of the resource func (record *DnsZonesTXTRecord) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){record.validateResourceReferences} + return []func() (admission.Warnings, error){record.validateResourceReferences, record.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -217,7 +213,16 @@ func (record *DnsZonesTXTRecord) updateValidations() []func(old runtime.Object) func(old runtime.Object) (admission.Warnings, error) { return record.validateResourceReferences() }, - record.validateWriteOnceProperties} + record.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return record.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (record *DnsZonesTXTRecord) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(record) } // validateResourceReferences validates all resource references @@ -588,7 +593,10 @@ func (zonesTXT *DnsZones_TXT_Spec) PopulateFromARM(owner genruntime.ArbitraryOwn } // Set property "Owner": - zonesTXT.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + zonesTXT.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "PTRRecords": // copying flattened property: diff --git a/v2/api/network/v1api20180501storage/dns_zone_types_gen.go b/v2/api/network/v1api20180501storage/dns_zone_types_gen.go index c5406a244b4..5d86c28f318 100644 --- a/v2/api/network/v1api20180501storage/dns_zone_types_gen.go +++ b/v2/api/network/v1api20180501storage/dns_zone_types_gen.go @@ -85,11 +85,7 @@ func (zone *DnsZone) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (zone *DnsZone) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(zone.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: zone.Spec.Owner.Name, - } + return zone.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/network/v1api20180501storage/dns_zones_a_record_types_gen.go b/v2/api/network/v1api20180501storage/dns_zones_a_record_types_gen.go index 35f068f00fa..1a85cbcf7fe 100644 --- a/v2/api/network/v1api20180501storage/dns_zones_a_record_types_gen.go +++ b/v2/api/network/v1api20180501storage/dns_zones_a_record_types_gen.go @@ -84,11 +84,7 @@ func (record *DnsZonesARecord) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (record *DnsZonesARecord) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(record.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: record.Spec.Owner.Name, - } + return record.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/network/v1api20180501storage/dns_zones_aaaa_record_types_gen.go b/v2/api/network/v1api20180501storage/dns_zones_aaaa_record_types_gen.go index 10722b66a47..713a0f1c3fa 100644 --- a/v2/api/network/v1api20180501storage/dns_zones_aaaa_record_types_gen.go +++ b/v2/api/network/v1api20180501storage/dns_zones_aaaa_record_types_gen.go @@ -85,11 +85,7 @@ func (record *DnsZonesAAAARecord) NewEmptyStatus() genruntime.ConvertibleStatus // Owner returns the ResourceReference of the owner func (record *DnsZonesAAAARecord) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(record.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: record.Spec.Owner.Name, - } + return record.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/network/v1api20180501storage/dns_zones_caa_record_types_gen.go b/v2/api/network/v1api20180501storage/dns_zones_caa_record_types_gen.go index 3a04d327971..c35fbc594bf 100644 --- a/v2/api/network/v1api20180501storage/dns_zones_caa_record_types_gen.go +++ b/v2/api/network/v1api20180501storage/dns_zones_caa_record_types_gen.go @@ -84,11 +84,7 @@ func (record *DnsZonesCAARecord) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (record *DnsZonesCAARecord) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(record.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: record.Spec.Owner.Name, - } + return record.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/network/v1api20180501storage/dns_zones_cname_record_types_gen.go b/v2/api/network/v1api20180501storage/dns_zones_cname_record_types_gen.go index e97380aff06..5b15930e26b 100644 --- a/v2/api/network/v1api20180501storage/dns_zones_cname_record_types_gen.go +++ b/v2/api/network/v1api20180501storage/dns_zones_cname_record_types_gen.go @@ -84,11 +84,7 @@ func (record *DnsZonesCNAMERecord) NewEmptyStatus() genruntime.ConvertibleStatus // Owner returns the ResourceReference of the owner func (record *DnsZonesCNAMERecord) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(record.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: record.Spec.Owner.Name, - } + return record.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/network/v1api20180501storage/dns_zones_mx_record_types_gen.go b/v2/api/network/v1api20180501storage/dns_zones_mx_record_types_gen.go index bfa7cfdce6e..96726e9e5ae 100644 --- a/v2/api/network/v1api20180501storage/dns_zones_mx_record_types_gen.go +++ b/v2/api/network/v1api20180501storage/dns_zones_mx_record_types_gen.go @@ -84,11 +84,7 @@ func (record *DnsZonesMXRecord) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (record *DnsZonesMXRecord) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(record.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: record.Spec.Owner.Name, - } + return record.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/network/v1api20180501storage/dns_zones_ns_record_types_gen.go b/v2/api/network/v1api20180501storage/dns_zones_ns_record_types_gen.go index f96aa0298bf..ac743b50754 100644 --- a/v2/api/network/v1api20180501storage/dns_zones_ns_record_types_gen.go +++ b/v2/api/network/v1api20180501storage/dns_zones_ns_record_types_gen.go @@ -84,11 +84,7 @@ func (record *DnsZonesNSRecord) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (record *DnsZonesNSRecord) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(record.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: record.Spec.Owner.Name, - } + return record.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/network/v1api20180501storage/dns_zones_ptr_record_types_gen.go b/v2/api/network/v1api20180501storage/dns_zones_ptr_record_types_gen.go index 9dcd5ffa3c8..a722073aa2d 100644 --- a/v2/api/network/v1api20180501storage/dns_zones_ptr_record_types_gen.go +++ b/v2/api/network/v1api20180501storage/dns_zones_ptr_record_types_gen.go @@ -84,11 +84,7 @@ func (record *DnsZonesPTRRecord) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (record *DnsZonesPTRRecord) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(record.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: record.Spec.Owner.Name, - } + return record.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/network/v1api20180501storage/dns_zones_srv_record_types_gen.go b/v2/api/network/v1api20180501storage/dns_zones_srv_record_types_gen.go index 1f3260e61f0..424d2302715 100644 --- a/v2/api/network/v1api20180501storage/dns_zones_srv_record_types_gen.go +++ b/v2/api/network/v1api20180501storage/dns_zones_srv_record_types_gen.go @@ -84,11 +84,7 @@ func (record *DnsZonesSRVRecord) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (record *DnsZonesSRVRecord) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(record.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: record.Spec.Owner.Name, - } + return record.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/network/v1api20180501storage/dns_zones_txt_record_types_gen.go b/v2/api/network/v1api20180501storage/dns_zones_txt_record_types_gen.go index c12ab18161f..20c777238e1 100644 --- a/v2/api/network/v1api20180501storage/dns_zones_txt_record_types_gen.go +++ b/v2/api/network/v1api20180501storage/dns_zones_txt_record_types_gen.go @@ -84,11 +84,7 @@ func (record *DnsZonesTXTRecord) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (record *DnsZonesTXTRecord) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(record.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: record.Spec.Owner.Name, - } + return record.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/network/v1api20180901/private_dns_zone_types_gen.go b/v2/api/network/v1api20180901/private_dns_zone_types_gen.go index fc4b34bef14..4488820bbf3 100644 --- a/v2/api/network/v1api20180901/private_dns_zone_types_gen.go +++ b/v2/api/network/v1api20180901/private_dns_zone_types_gen.go @@ -141,11 +141,7 @@ func (zone *PrivateDnsZone) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (zone *PrivateDnsZone) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(zone.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: zone.Spec.Owner.Name, - } + return zone.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -203,7 +199,7 @@ func (zone *PrivateDnsZone) ValidateUpdate(old runtime.Object) (admission.Warnin // createValidations validates the creation of the resource func (zone *PrivateDnsZone) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){zone.validateResourceReferences} + return []func() (admission.Warnings, error){zone.validateResourceReferences, zone.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -217,7 +213,16 @@ func (zone *PrivateDnsZone) updateValidations() []func(old runtime.Object) (admi func(old runtime.Object) (admission.Warnings, error) { return zone.validateResourceReferences() }, - zone.validateWriteOnceProperties} + zone.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return zone.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (zone *PrivateDnsZone) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(zone) } // validateResourceReferences validates all resource references @@ -398,7 +403,10 @@ func (zone *PrivateDnsZone_Spec) PopulateFromARM(owner genruntime.ArbitraryOwner } // Set property "Owner": - zone.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + zone.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "Tags": if typedInput.Tags != nil { diff --git a/v2/api/network/v1api20180901storage/private_dns_zone_types_gen.go b/v2/api/network/v1api20180901storage/private_dns_zone_types_gen.go index 6c485fb7425..bd4d6c051b4 100644 --- a/v2/api/network/v1api20180901storage/private_dns_zone_types_gen.go +++ b/v2/api/network/v1api20180901storage/private_dns_zone_types_gen.go @@ -84,11 +84,7 @@ func (zone *PrivateDnsZone) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (zone *PrivateDnsZone) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(zone.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: zone.Spec.Owner.Name, - } + return zone.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/network/v1api20200601/private_dns_zones_a_record_types_gen.go b/v2/api/network/v1api20200601/private_dns_zones_a_record_types_gen.go index 4571287e7e0..f995196a27b 100644 --- a/v2/api/network/v1api20200601/private_dns_zones_a_record_types_gen.go +++ b/v2/api/network/v1api20200601/private_dns_zones_a_record_types_gen.go @@ -141,11 +141,7 @@ func (record *PrivateDnsZonesARecord) NewEmptyStatus() genruntime.ConvertibleSta // Owner returns the ResourceReference of the owner func (record *PrivateDnsZonesARecord) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(record.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: record.Spec.Owner.Name, - } + return record.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -203,7 +199,7 @@ func (record *PrivateDnsZonesARecord) ValidateUpdate(old runtime.Object) (admiss // createValidations validates the creation of the resource func (record *PrivateDnsZonesARecord) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){record.validateResourceReferences} + return []func() (admission.Warnings, error){record.validateResourceReferences, record.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -217,7 +213,16 @@ func (record *PrivateDnsZonesARecord) updateValidations() []func(old runtime.Obj func(old runtime.Object) (admission.Warnings, error) { return record.validateResourceReferences() }, - record.validateWriteOnceProperties} + record.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return record.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (record *PrivateDnsZonesARecord) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(record) } // validateResourceReferences validates all resource references @@ -543,7 +548,10 @@ func (zonesA *PrivateDnsZones_A_Spec) PopulateFromARM(owner genruntime.Arbitrary } // Set property "Owner": - zonesA.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + zonesA.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "PtrRecords": // copying flattened property: diff --git a/v2/api/network/v1api20200601/private_dns_zones_aaaa_record_types_gen.go b/v2/api/network/v1api20200601/private_dns_zones_aaaa_record_types_gen.go index 9e32596f7d1..2dbaa4fb40c 100644 --- a/v2/api/network/v1api20200601/private_dns_zones_aaaa_record_types_gen.go +++ b/v2/api/network/v1api20200601/private_dns_zones_aaaa_record_types_gen.go @@ -141,11 +141,7 @@ func (record *PrivateDnsZonesAAAARecord) NewEmptyStatus() genruntime.Convertible // Owner returns the ResourceReference of the owner func (record *PrivateDnsZonesAAAARecord) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(record.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: record.Spec.Owner.Name, - } + return record.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -203,7 +199,7 @@ func (record *PrivateDnsZonesAAAARecord) ValidateUpdate(old runtime.Object) (adm // createValidations validates the creation of the resource func (record *PrivateDnsZonesAAAARecord) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){record.validateResourceReferences} + return []func() (admission.Warnings, error){record.validateResourceReferences, record.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -217,7 +213,16 @@ func (record *PrivateDnsZonesAAAARecord) updateValidations() []func(old runtime. func(old runtime.Object) (admission.Warnings, error) { return record.validateResourceReferences() }, - record.validateWriteOnceProperties} + record.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return record.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (record *PrivateDnsZonesAAAARecord) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(record) } // validateResourceReferences validates all resource references @@ -548,7 +553,10 @@ func (aaaa *PrivateDnsZones_AAAA_Spec) PopulateFromARM(owner genruntime.Arbitrar } // Set property "Owner": - aaaa.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + aaaa.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "PtrRecords": // copying flattened property: diff --git a/v2/api/network/v1api20200601/private_dns_zones_cname_record_types_gen.go b/v2/api/network/v1api20200601/private_dns_zones_cname_record_types_gen.go index 2829b6a1b44..6db2993732c 100644 --- a/v2/api/network/v1api20200601/private_dns_zones_cname_record_types_gen.go +++ b/v2/api/network/v1api20200601/private_dns_zones_cname_record_types_gen.go @@ -141,11 +141,7 @@ func (record *PrivateDnsZonesCNAMERecord) NewEmptyStatus() genruntime.Convertibl // Owner returns the ResourceReference of the owner func (record *PrivateDnsZonesCNAMERecord) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(record.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: record.Spec.Owner.Name, - } + return record.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -203,7 +199,7 @@ func (record *PrivateDnsZonesCNAMERecord) ValidateUpdate(old runtime.Object) (ad // createValidations validates the creation of the resource func (record *PrivateDnsZonesCNAMERecord) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){record.validateResourceReferences} + return []func() (admission.Warnings, error){record.validateResourceReferences, record.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -217,7 +213,16 @@ func (record *PrivateDnsZonesCNAMERecord) updateValidations() []func(old runtime func(old runtime.Object) (admission.Warnings, error) { return record.validateResourceReferences() }, - record.validateWriteOnceProperties} + record.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return record.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (record *PrivateDnsZonesCNAMERecord) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(record) } // validateResourceReferences validates all resource references @@ -543,7 +548,10 @@ func (cname *PrivateDnsZones_CNAME_Spec) PopulateFromARM(owner genruntime.Arbitr } // Set property "Owner": - cname.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + cname.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "PtrRecords": // copying flattened property: diff --git a/v2/api/network/v1api20200601/private_dns_zones_mx_record_types_gen.go b/v2/api/network/v1api20200601/private_dns_zones_mx_record_types_gen.go index 3958fea8ab4..7ae18733050 100644 --- a/v2/api/network/v1api20200601/private_dns_zones_mx_record_types_gen.go +++ b/v2/api/network/v1api20200601/private_dns_zones_mx_record_types_gen.go @@ -141,11 +141,7 @@ func (record *PrivateDnsZonesMXRecord) NewEmptyStatus() genruntime.ConvertibleSt // Owner returns the ResourceReference of the owner func (record *PrivateDnsZonesMXRecord) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(record.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: record.Spec.Owner.Name, - } + return record.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -203,7 +199,7 @@ func (record *PrivateDnsZonesMXRecord) ValidateUpdate(old runtime.Object) (admis // createValidations validates the creation of the resource func (record *PrivateDnsZonesMXRecord) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){record.validateResourceReferences} + return []func() (admission.Warnings, error){record.validateResourceReferences, record.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -217,7 +213,16 @@ func (record *PrivateDnsZonesMXRecord) updateValidations() []func(old runtime.Ob func(old runtime.Object) (admission.Warnings, error) { return record.validateResourceReferences() }, - record.validateWriteOnceProperties} + record.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return record.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (record *PrivateDnsZonesMXRecord) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(record) } // validateResourceReferences validates all resource references @@ -543,7 +548,10 @@ func (zonesMX *PrivateDnsZones_MX_Spec) PopulateFromARM(owner genruntime.Arbitra } // Set property "Owner": - zonesMX.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + zonesMX.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "PtrRecords": // copying flattened property: diff --git a/v2/api/network/v1api20200601/private_dns_zones_ptr_record_types_gen.go b/v2/api/network/v1api20200601/private_dns_zones_ptr_record_types_gen.go index 3844f2213e5..3866248c6bb 100644 --- a/v2/api/network/v1api20200601/private_dns_zones_ptr_record_types_gen.go +++ b/v2/api/network/v1api20200601/private_dns_zones_ptr_record_types_gen.go @@ -141,11 +141,7 @@ func (record *PrivateDnsZonesPTRRecord) NewEmptyStatus() genruntime.ConvertibleS // Owner returns the ResourceReference of the owner func (record *PrivateDnsZonesPTRRecord) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(record.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: record.Spec.Owner.Name, - } + return record.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -203,7 +199,7 @@ func (record *PrivateDnsZonesPTRRecord) ValidateUpdate(old runtime.Object) (admi // createValidations validates the creation of the resource func (record *PrivateDnsZonesPTRRecord) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){record.validateResourceReferences} + return []func() (admission.Warnings, error){record.validateResourceReferences, record.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -217,7 +213,16 @@ func (record *PrivateDnsZonesPTRRecord) updateValidations() []func(old runtime.O func(old runtime.Object) (admission.Warnings, error) { return record.validateResourceReferences() }, - record.validateWriteOnceProperties} + record.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return record.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (record *PrivateDnsZonesPTRRecord) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(record) } // validateResourceReferences validates all resource references @@ -543,7 +548,10 @@ func (zonesPTR *PrivateDnsZones_PTR_Spec) PopulateFromARM(owner genruntime.Arbit } // Set property "Owner": - zonesPTR.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + zonesPTR.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "PtrRecords": // copying flattened property: diff --git a/v2/api/network/v1api20200601/private_dns_zones_srv_record_types_gen.go b/v2/api/network/v1api20200601/private_dns_zones_srv_record_types_gen.go index 52b54fdb704..51bce70cc37 100644 --- a/v2/api/network/v1api20200601/private_dns_zones_srv_record_types_gen.go +++ b/v2/api/network/v1api20200601/private_dns_zones_srv_record_types_gen.go @@ -141,11 +141,7 @@ func (record *PrivateDnsZonesSRVRecord) NewEmptyStatus() genruntime.ConvertibleS // Owner returns the ResourceReference of the owner func (record *PrivateDnsZonesSRVRecord) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(record.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: record.Spec.Owner.Name, - } + return record.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -203,7 +199,7 @@ func (record *PrivateDnsZonesSRVRecord) ValidateUpdate(old runtime.Object) (admi // createValidations validates the creation of the resource func (record *PrivateDnsZonesSRVRecord) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){record.validateResourceReferences} + return []func() (admission.Warnings, error){record.validateResourceReferences, record.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -217,7 +213,16 @@ func (record *PrivateDnsZonesSRVRecord) updateValidations() []func(old runtime.O func(old runtime.Object) (admission.Warnings, error) { return record.validateResourceReferences() }, - record.validateWriteOnceProperties} + record.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return record.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (record *PrivateDnsZonesSRVRecord) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(record) } // validateResourceReferences validates all resource references @@ -543,7 +548,10 @@ func (zonesSRV *PrivateDnsZones_SRV_Spec) PopulateFromARM(owner genruntime.Arbit } // Set property "Owner": - zonesSRV.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + zonesSRV.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "PtrRecords": // copying flattened property: diff --git a/v2/api/network/v1api20200601/private_dns_zones_txt_record_types_gen.go b/v2/api/network/v1api20200601/private_dns_zones_txt_record_types_gen.go index 839dc26cd75..4b935442261 100644 --- a/v2/api/network/v1api20200601/private_dns_zones_txt_record_types_gen.go +++ b/v2/api/network/v1api20200601/private_dns_zones_txt_record_types_gen.go @@ -141,11 +141,7 @@ func (record *PrivateDnsZonesTXTRecord) NewEmptyStatus() genruntime.ConvertibleS // Owner returns the ResourceReference of the owner func (record *PrivateDnsZonesTXTRecord) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(record.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: record.Spec.Owner.Name, - } + return record.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -203,7 +199,7 @@ func (record *PrivateDnsZonesTXTRecord) ValidateUpdate(old runtime.Object) (admi // createValidations validates the creation of the resource func (record *PrivateDnsZonesTXTRecord) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){record.validateResourceReferences} + return []func() (admission.Warnings, error){record.validateResourceReferences, record.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -217,7 +213,16 @@ func (record *PrivateDnsZonesTXTRecord) updateValidations() []func(old runtime.O func(old runtime.Object) (admission.Warnings, error) { return record.validateResourceReferences() }, - record.validateWriteOnceProperties} + record.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return record.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (record *PrivateDnsZonesTXTRecord) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(record) } // validateResourceReferences validates all resource references @@ -543,7 +548,10 @@ func (zonesTXT *PrivateDnsZones_TXT_Spec) PopulateFromARM(owner genruntime.Arbit } // Set property "Owner": - zonesTXT.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + zonesTXT.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "PtrRecords": // copying flattened property: diff --git a/v2/api/network/v1api20200601/private_dns_zones_virtual_network_link_types_gen.go b/v2/api/network/v1api20200601/private_dns_zones_virtual_network_link_types_gen.go index 2f694db011c..4f275d930a6 100644 --- a/v2/api/network/v1api20200601/private_dns_zones_virtual_network_link_types_gen.go +++ b/v2/api/network/v1api20200601/private_dns_zones_virtual_network_link_types_gen.go @@ -141,11 +141,7 @@ func (link *PrivateDnsZonesVirtualNetworkLink) NewEmptyStatus() genruntime.Conve // Owner returns the ResourceReference of the owner func (link *PrivateDnsZonesVirtualNetworkLink) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(link.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: link.Spec.Owner.Name, - } + return link.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -203,7 +199,7 @@ func (link *PrivateDnsZonesVirtualNetworkLink) ValidateUpdate(old runtime.Object // createValidations validates the creation of the resource func (link *PrivateDnsZonesVirtualNetworkLink) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){link.validateResourceReferences} + return []func() (admission.Warnings, error){link.validateResourceReferences, link.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -217,7 +213,16 @@ func (link *PrivateDnsZonesVirtualNetworkLink) updateValidations() []func(old ru func(old runtime.Object) (admission.Warnings, error) { return link.validateResourceReferences() }, - link.validateWriteOnceProperties} + link.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return link.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (link *PrivateDnsZonesVirtualNetworkLink) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(link) } // validateResourceReferences validates all resource references @@ -417,7 +422,10 @@ func (link *PrivateDnsZones_VirtualNetworkLink_Spec) PopulateFromARM(owner genru } // Set property "Owner": - link.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + link.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "RegistrationEnabled": // copying flattened property: diff --git a/v2/api/network/v1api20200601storage/private_dns_zones_a_record_types_gen.go b/v2/api/network/v1api20200601storage/private_dns_zones_a_record_types_gen.go index 3c0f5f8f2de..280a802e56b 100644 --- a/v2/api/network/v1api20200601storage/private_dns_zones_a_record_types_gen.go +++ b/v2/api/network/v1api20200601storage/private_dns_zones_a_record_types_gen.go @@ -84,11 +84,7 @@ func (record *PrivateDnsZonesARecord) NewEmptyStatus() genruntime.ConvertibleSta // Owner returns the ResourceReference of the owner func (record *PrivateDnsZonesARecord) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(record.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: record.Spec.Owner.Name, - } + return record.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/network/v1api20200601storage/private_dns_zones_aaaa_record_types_gen.go b/v2/api/network/v1api20200601storage/private_dns_zones_aaaa_record_types_gen.go index 5920c297788..b79e55116b6 100644 --- a/v2/api/network/v1api20200601storage/private_dns_zones_aaaa_record_types_gen.go +++ b/v2/api/network/v1api20200601storage/private_dns_zones_aaaa_record_types_gen.go @@ -84,11 +84,7 @@ func (record *PrivateDnsZonesAAAARecord) NewEmptyStatus() genruntime.Convertible // Owner returns the ResourceReference of the owner func (record *PrivateDnsZonesAAAARecord) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(record.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: record.Spec.Owner.Name, - } + return record.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/network/v1api20200601storage/private_dns_zones_cname_record_types_gen.go b/v2/api/network/v1api20200601storage/private_dns_zones_cname_record_types_gen.go index c9a3436f6b6..e422d19420b 100644 --- a/v2/api/network/v1api20200601storage/private_dns_zones_cname_record_types_gen.go +++ b/v2/api/network/v1api20200601storage/private_dns_zones_cname_record_types_gen.go @@ -84,11 +84,7 @@ func (record *PrivateDnsZonesCNAMERecord) NewEmptyStatus() genruntime.Convertibl // Owner returns the ResourceReference of the owner func (record *PrivateDnsZonesCNAMERecord) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(record.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: record.Spec.Owner.Name, - } + return record.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/network/v1api20200601storage/private_dns_zones_mx_record_types_gen.go b/v2/api/network/v1api20200601storage/private_dns_zones_mx_record_types_gen.go index edab0d30510..d8bd586c80d 100644 --- a/v2/api/network/v1api20200601storage/private_dns_zones_mx_record_types_gen.go +++ b/v2/api/network/v1api20200601storage/private_dns_zones_mx_record_types_gen.go @@ -84,11 +84,7 @@ func (record *PrivateDnsZonesMXRecord) NewEmptyStatus() genruntime.ConvertibleSt // Owner returns the ResourceReference of the owner func (record *PrivateDnsZonesMXRecord) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(record.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: record.Spec.Owner.Name, - } + return record.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/network/v1api20200601storage/private_dns_zones_ptr_record_types_gen.go b/v2/api/network/v1api20200601storage/private_dns_zones_ptr_record_types_gen.go index 33802e99679..a03135cd1d6 100644 --- a/v2/api/network/v1api20200601storage/private_dns_zones_ptr_record_types_gen.go +++ b/v2/api/network/v1api20200601storage/private_dns_zones_ptr_record_types_gen.go @@ -84,11 +84,7 @@ func (record *PrivateDnsZonesPTRRecord) NewEmptyStatus() genruntime.ConvertibleS // Owner returns the ResourceReference of the owner func (record *PrivateDnsZonesPTRRecord) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(record.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: record.Spec.Owner.Name, - } + return record.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/network/v1api20200601storage/private_dns_zones_srv_record_types_gen.go b/v2/api/network/v1api20200601storage/private_dns_zones_srv_record_types_gen.go index 9470c9d0d4e..ea8223ae2c1 100644 --- a/v2/api/network/v1api20200601storage/private_dns_zones_srv_record_types_gen.go +++ b/v2/api/network/v1api20200601storage/private_dns_zones_srv_record_types_gen.go @@ -84,11 +84,7 @@ func (record *PrivateDnsZonesSRVRecord) NewEmptyStatus() genruntime.ConvertibleS // Owner returns the ResourceReference of the owner func (record *PrivateDnsZonesSRVRecord) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(record.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: record.Spec.Owner.Name, - } + return record.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/network/v1api20200601storage/private_dns_zones_txt_record_types_gen.go b/v2/api/network/v1api20200601storage/private_dns_zones_txt_record_types_gen.go index a8f4d2bee81..4c1989b1e8f 100644 --- a/v2/api/network/v1api20200601storage/private_dns_zones_txt_record_types_gen.go +++ b/v2/api/network/v1api20200601storage/private_dns_zones_txt_record_types_gen.go @@ -84,11 +84,7 @@ func (record *PrivateDnsZonesTXTRecord) NewEmptyStatus() genruntime.ConvertibleS // Owner returns the ResourceReference of the owner func (record *PrivateDnsZonesTXTRecord) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(record.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: record.Spec.Owner.Name, - } + return record.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/network/v1api20200601storage/private_dns_zones_virtual_network_link_types_gen.go b/v2/api/network/v1api20200601storage/private_dns_zones_virtual_network_link_types_gen.go index da6a610c249..4055cf4bf93 100644 --- a/v2/api/network/v1api20200601storage/private_dns_zones_virtual_network_link_types_gen.go +++ b/v2/api/network/v1api20200601storage/private_dns_zones_virtual_network_link_types_gen.go @@ -85,11 +85,7 @@ func (link *PrivateDnsZonesVirtualNetworkLink) NewEmptyStatus() genruntime.Conve // Owner returns the ResourceReference of the owner func (link *PrivateDnsZonesVirtualNetworkLink) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(link.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: link.Spec.Owner.Name, - } + return link.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/network/v1api20201101/load_balancer_types_gen.go b/v2/api/network/v1api20201101/load_balancer_types_gen.go index df42845c6e2..7d1db3d97e7 100644 --- a/v2/api/network/v1api20201101/load_balancer_types_gen.go +++ b/v2/api/network/v1api20201101/load_balancer_types_gen.go @@ -141,11 +141,7 @@ func (balancer *LoadBalancer) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (balancer *LoadBalancer) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(balancer.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: balancer.Spec.Owner.Name, - } + return balancer.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -203,7 +199,7 @@ func (balancer *LoadBalancer) ValidateUpdate(old runtime.Object) (admission.Warn // createValidations validates the creation of the resource func (balancer *LoadBalancer) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){balancer.validateResourceReferences} + return []func() (admission.Warnings, error){balancer.validateResourceReferences, balancer.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -217,7 +213,16 @@ func (balancer *LoadBalancer) updateValidations() []func(old runtime.Object) (ad func(old runtime.Object) (admission.Warnings, error) { return balancer.validateResourceReferences() }, - balancer.validateWriteOnceProperties} + balancer.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return balancer.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (balancer *LoadBalancer) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(balancer) } // validateResourceReferences validates all resource references @@ -586,7 +591,10 @@ func (balancer *LoadBalancer_Spec) PopulateFromARM(owner genruntime.ArbitraryOwn } // Set property "Owner": - balancer.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + balancer.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "Probes": // copying flattened property: diff --git a/v2/api/network/v1api20201101/load_balancers_inbound_nat_rule_types_gen.go b/v2/api/network/v1api20201101/load_balancers_inbound_nat_rule_types_gen.go index 2945cc0f67b..5ee33641a16 100644 --- a/v2/api/network/v1api20201101/load_balancers_inbound_nat_rule_types_gen.go +++ b/v2/api/network/v1api20201101/load_balancers_inbound_nat_rule_types_gen.go @@ -141,11 +141,7 @@ func (rule *LoadBalancersInboundNatRule) NewEmptyStatus() genruntime.Convertible // Owner returns the ResourceReference of the owner func (rule *LoadBalancersInboundNatRule) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(rule.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: rule.Spec.Owner.Name, - } + return rule.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -203,7 +199,7 @@ func (rule *LoadBalancersInboundNatRule) ValidateUpdate(old runtime.Object) (adm // createValidations validates the creation of the resource func (rule *LoadBalancersInboundNatRule) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){rule.validateResourceReferences} + return []func() (admission.Warnings, error){rule.validateResourceReferences, rule.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -217,7 +213,16 @@ func (rule *LoadBalancersInboundNatRule) updateValidations() []func(old runtime. func(old runtime.Object) (admission.Warnings, error) { return rule.validateResourceReferences() }, - rule.validateWriteOnceProperties} + rule.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return rule.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (rule *LoadBalancersInboundNatRule) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(rule) } // validateResourceReferences validates all resource references @@ -480,7 +485,10 @@ func (rule *LoadBalancers_InboundNatRule_Spec) PopulateFromARM(owner genruntime. } // Set property "Owner": - rule.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + rule.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "Protocol": // copying flattened property: diff --git a/v2/api/network/v1api20201101/network_interface_types_gen.go b/v2/api/network/v1api20201101/network_interface_types_gen.go index 456bca10066..112635bea00 100644 --- a/v2/api/network/v1api20201101/network_interface_types_gen.go +++ b/v2/api/network/v1api20201101/network_interface_types_gen.go @@ -141,11 +141,7 @@ func (networkInterface *NetworkInterface) NewEmptyStatus() genruntime.Convertibl // Owner returns the ResourceReference of the owner func (networkInterface *NetworkInterface) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(networkInterface.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: networkInterface.Spec.Owner.Name, - } + return networkInterface.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -203,7 +199,7 @@ func (networkInterface *NetworkInterface) ValidateUpdate(old runtime.Object) (ad // createValidations validates the creation of the resource func (networkInterface *NetworkInterface) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){networkInterface.validateResourceReferences} + return []func() (admission.Warnings, error){networkInterface.validateResourceReferences, networkInterface.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -217,7 +213,16 @@ func (networkInterface *NetworkInterface) updateValidations() []func(old runtime func(old runtime.Object) (admission.Warnings, error) { return networkInterface.validateResourceReferences() }, - networkInterface.validateWriteOnceProperties} + networkInterface.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return networkInterface.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (networkInterface *NetworkInterface) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(networkInterface) } // validateResourceReferences validates all resource references @@ -545,7 +550,10 @@ func (networkInterface *NetworkInterface_Spec) PopulateFromARM(owner genruntime. } // Set property "Owner": - networkInterface.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + networkInterface.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "PrivateLinkService": // copying flattened property: diff --git a/v2/api/network/v1api20201101/network_security_group_types_gen.go b/v2/api/network/v1api20201101/network_security_group_types_gen.go index 13a4e66f5a2..6ed3bce97b0 100644 --- a/v2/api/network/v1api20201101/network_security_group_types_gen.go +++ b/v2/api/network/v1api20201101/network_security_group_types_gen.go @@ -141,11 +141,7 @@ func (group *NetworkSecurityGroup) NewEmptyStatus() genruntime.ConvertibleStatus // Owner returns the ResourceReference of the owner func (group *NetworkSecurityGroup) Owner() *genruntime.ResourceReference { ownerGroup, ownerKind := genruntime.LookupOwnerGroupKind(group.Spec) - return &genruntime.ResourceReference{ - Group: ownerGroup, - Kind: ownerKind, - Name: group.Spec.Owner.Name, - } + return group.Spec.Owner.AsResourceReference(ownerGroup, ownerKind) } // SetStatus sets the status of this resource @@ -203,7 +199,7 @@ func (group *NetworkSecurityGroup) ValidateUpdate(old runtime.Object) (admission // createValidations validates the creation of the resource func (group *NetworkSecurityGroup) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){group.validateResourceReferences} + return []func() (admission.Warnings, error){group.validateResourceReferences, group.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -217,7 +213,16 @@ func (group *NetworkSecurityGroup) updateValidations() []func(old runtime.Object func(old runtime.Object) (admission.Warnings, error) { return group.validateResourceReferences() }, - group.validateWriteOnceProperties} + group.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return group.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (group *NetworkSecurityGroup) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(group) } // validateResourceReferences validates all resource references @@ -380,7 +385,10 @@ func (group *NetworkSecurityGroup_Spec) PopulateFromARM(owner genruntime.Arbitra } // Set property "Owner": - group.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + group.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "Tags": if typedInput.Tags != nil { diff --git a/v2/api/network/v1api20201101/network_security_groups_security_rule_types_gen.go b/v2/api/network/v1api20201101/network_security_groups_security_rule_types_gen.go index 74f39524b41..42df83edede 100644 --- a/v2/api/network/v1api20201101/network_security_groups_security_rule_types_gen.go +++ b/v2/api/network/v1api20201101/network_security_groups_security_rule_types_gen.go @@ -141,11 +141,7 @@ func (rule *NetworkSecurityGroupsSecurityRule) NewEmptyStatus() genruntime.Conve // Owner returns the ResourceReference of the owner func (rule *NetworkSecurityGroupsSecurityRule) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(rule.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: rule.Spec.Owner.Name, - } + return rule.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -203,7 +199,7 @@ func (rule *NetworkSecurityGroupsSecurityRule) ValidateUpdate(old runtime.Object // createValidations validates the creation of the resource func (rule *NetworkSecurityGroupsSecurityRule) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){rule.validateResourceReferences} + return []func() (admission.Warnings, error){rule.validateResourceReferences, rule.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -217,7 +213,16 @@ func (rule *NetworkSecurityGroupsSecurityRule) updateValidations() []func(old ru func(old runtime.Object) (admission.Warnings, error) { return rule.validateResourceReferences() }, - rule.validateWriteOnceProperties} + rule.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return rule.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (rule *NetworkSecurityGroupsSecurityRule) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(rule) } // validateResourceReferences validates all resource references @@ -561,7 +566,10 @@ func (rule *NetworkSecurityGroups_SecurityRule_Spec) PopulateFromARM(owner genru } // Set property "Owner": - rule.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + rule.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "Priority": // copying flattened property: diff --git a/v2/api/network/v1api20201101/public_ip_address_types_gen.go b/v2/api/network/v1api20201101/public_ip_address_types_gen.go index b2b3f8b7e65..91913e69316 100644 --- a/v2/api/network/v1api20201101/public_ip_address_types_gen.go +++ b/v2/api/network/v1api20201101/public_ip_address_types_gen.go @@ -141,11 +141,7 @@ func (address *PublicIPAddress) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (address *PublicIPAddress) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(address.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: address.Spec.Owner.Name, - } + return address.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -203,7 +199,7 @@ func (address *PublicIPAddress) ValidateUpdate(old runtime.Object) (admission.Wa // createValidations validates the creation of the resource func (address *PublicIPAddress) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){address.validateResourceReferences} + return []func() (admission.Warnings, error){address.validateResourceReferences, address.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -217,7 +213,16 @@ func (address *PublicIPAddress) updateValidations() []func(old runtime.Object) ( func(old runtime.Object) (admission.Warnings, error) { return address.validateResourceReferences() }, - address.validateWriteOnceProperties} + address.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return address.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (address *PublicIPAddress) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(address) } // validateResourceReferences validates all resource references @@ -629,7 +634,10 @@ func (address *PublicIPAddress_Spec) PopulateFromARM(owner genruntime.ArbitraryO } // Set property "Owner": - address.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + address.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "PublicIPAddressVersion": // copying flattened property: diff --git a/v2/api/network/v1api20201101/route_table_types_gen.go b/v2/api/network/v1api20201101/route_table_types_gen.go index 0ef86cd405d..ae0afc646d1 100644 --- a/v2/api/network/v1api20201101/route_table_types_gen.go +++ b/v2/api/network/v1api20201101/route_table_types_gen.go @@ -141,11 +141,7 @@ func (table *RouteTable) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (table *RouteTable) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(table.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: table.Spec.Owner.Name, - } + return table.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -203,7 +199,7 @@ func (table *RouteTable) ValidateUpdate(old runtime.Object) (admission.Warnings, // createValidations validates the creation of the resource func (table *RouteTable) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){table.validateResourceReferences} + return []func() (admission.Warnings, error){table.validateResourceReferences, table.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -217,7 +213,16 @@ func (table *RouteTable) updateValidations() []func(old runtime.Object) (admissi func(old runtime.Object) (admission.Warnings, error) { return table.validateResourceReferences() }, - table.validateWriteOnceProperties} + table.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return table.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (table *RouteTable) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(table) } // validateResourceReferences validates all resource references @@ -399,7 +404,10 @@ func (table *RouteTable_Spec) PopulateFromARM(owner genruntime.ArbitraryOwnerRef } // Set property "Owner": - table.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + table.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "Tags": if typedInput.Tags != nil { diff --git a/v2/api/network/v1api20201101/route_tables_route_types_gen.go b/v2/api/network/v1api20201101/route_tables_route_types_gen.go index 8c3b842be08..1adbb77fc71 100644 --- a/v2/api/network/v1api20201101/route_tables_route_types_gen.go +++ b/v2/api/network/v1api20201101/route_tables_route_types_gen.go @@ -141,11 +141,7 @@ func (route *RouteTablesRoute) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (route *RouteTablesRoute) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(route.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: route.Spec.Owner.Name, - } + return route.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -203,7 +199,7 @@ func (route *RouteTablesRoute) ValidateUpdate(old runtime.Object) (admission.War // createValidations validates the creation of the resource func (route *RouteTablesRoute) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){route.validateResourceReferences} + return []func() (admission.Warnings, error){route.validateResourceReferences, route.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -217,7 +213,16 @@ func (route *RouteTablesRoute) updateValidations() []func(old runtime.Object) (a func(old runtime.Object) (admission.Warnings, error) { return route.validateResourceReferences() }, - route.validateWriteOnceProperties} + route.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return route.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (route *RouteTablesRoute) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(route) } // validateResourceReferences validates all resource references @@ -426,7 +431,10 @@ func (route *RouteTables_Route_Spec) PopulateFromARM(owner genruntime.ArbitraryO } // Set property "Owner": - route.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + route.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // No error return nil diff --git a/v2/api/network/v1api20201101/virtual_network_gateway_types_gen.go b/v2/api/network/v1api20201101/virtual_network_gateway_types_gen.go index a17547e79ae..12dc910779a 100644 --- a/v2/api/network/v1api20201101/virtual_network_gateway_types_gen.go +++ b/v2/api/network/v1api20201101/virtual_network_gateway_types_gen.go @@ -141,11 +141,7 @@ func (gateway *VirtualNetworkGateway) NewEmptyStatus() genruntime.ConvertibleSta // Owner returns the ResourceReference of the owner func (gateway *VirtualNetworkGateway) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(gateway.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: gateway.Spec.Owner.Name, - } + return gateway.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -203,7 +199,7 @@ func (gateway *VirtualNetworkGateway) ValidateUpdate(old runtime.Object) (admiss // createValidations validates the creation of the resource func (gateway *VirtualNetworkGateway) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){gateway.validateResourceReferences} + return []func() (admission.Warnings, error){gateway.validateResourceReferences, gateway.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -217,7 +213,16 @@ func (gateway *VirtualNetworkGateway) updateValidations() []func(old runtime.Obj func(old runtime.Object) (admission.Warnings, error) { return gateway.validateResourceReferences() }, - gateway.validateWriteOnceProperties} + gateway.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return gateway.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (gateway *VirtualNetworkGateway) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(gateway) } // validateResourceReferences validates all resource references @@ -650,7 +655,10 @@ func (gateway *VirtualNetworkGateway_Spec) PopulateFromARM(owner genruntime.Arbi } // Set property "Owner": - gateway.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + gateway.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "Sku": // copying flattened property: diff --git a/v2/api/network/v1api20201101/virtual_network_types_gen.go b/v2/api/network/v1api20201101/virtual_network_types_gen.go index 396434ffdf4..20fe0f027ff 100644 --- a/v2/api/network/v1api20201101/virtual_network_types_gen.go +++ b/v2/api/network/v1api20201101/virtual_network_types_gen.go @@ -141,11 +141,7 @@ func (network *VirtualNetwork) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (network *VirtualNetwork) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(network.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: network.Spec.Owner.Name, - } + return network.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -203,7 +199,7 @@ func (network *VirtualNetwork) ValidateUpdate(old runtime.Object) (admission.War // createValidations validates the creation of the resource func (network *VirtualNetwork) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){network.validateResourceReferences} + return []func() (admission.Warnings, error){network.validateResourceReferences, network.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -217,7 +213,16 @@ func (network *VirtualNetwork) updateValidations() []func(old runtime.Object) (a func(old runtime.Object) (admission.Warnings, error) { return network.validateResourceReferences() }, - network.validateWriteOnceProperties} + network.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return network.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (network *VirtualNetwork) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(network) } // validateResourceReferences validates all resource references @@ -569,7 +574,10 @@ func (network *VirtualNetwork_Spec) PopulateFromARM(owner genruntime.ArbitraryOw } // Set property "Owner": - network.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + network.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "Tags": if typedInput.Tags != nil { diff --git a/v2/api/network/v1api20201101/virtual_networks_subnet_types_gen.go b/v2/api/network/v1api20201101/virtual_networks_subnet_types_gen.go index b6f8c4d3532..1819ed41b11 100644 --- a/v2/api/network/v1api20201101/virtual_networks_subnet_types_gen.go +++ b/v2/api/network/v1api20201101/virtual_networks_subnet_types_gen.go @@ -141,11 +141,7 @@ func (subnet *VirtualNetworksSubnet) NewEmptyStatus() genruntime.ConvertibleStat // Owner returns the ResourceReference of the owner func (subnet *VirtualNetworksSubnet) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(subnet.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: subnet.Spec.Owner.Name, - } + return subnet.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -203,7 +199,7 @@ func (subnet *VirtualNetworksSubnet) ValidateUpdate(old runtime.Object) (admissi // createValidations validates the creation of the resource func (subnet *VirtualNetworksSubnet) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){subnet.validateResourceReferences} + return []func() (admission.Warnings, error){subnet.validateResourceReferences, subnet.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -217,7 +213,16 @@ func (subnet *VirtualNetworksSubnet) updateValidations() []func(old runtime.Obje func(old runtime.Object) (admission.Warnings, error) { return subnet.validateResourceReferences() }, - subnet.validateWriteOnceProperties} + subnet.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return subnet.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (subnet *VirtualNetworksSubnet) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(subnet) } // validateResourceReferences validates all resource references @@ -562,7 +567,10 @@ func (subnet *VirtualNetworks_Subnet_Spec) PopulateFromARM(owner genruntime.Arbi } // Set property "Owner": - subnet.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + subnet.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "PrivateEndpointNetworkPolicies": // copying flattened property: diff --git a/v2/api/network/v1api20201101/virtual_networks_virtual_network_peering_types_gen.go b/v2/api/network/v1api20201101/virtual_networks_virtual_network_peering_types_gen.go index ee1a483d802..6ac136003a0 100644 --- a/v2/api/network/v1api20201101/virtual_networks_virtual_network_peering_types_gen.go +++ b/v2/api/network/v1api20201101/virtual_networks_virtual_network_peering_types_gen.go @@ -141,11 +141,7 @@ func (peering *VirtualNetworksVirtualNetworkPeering) NewEmptyStatus() genruntime // Owner returns the ResourceReference of the owner func (peering *VirtualNetworksVirtualNetworkPeering) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(peering.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: peering.Spec.Owner.Name, - } + return peering.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -203,7 +199,7 @@ func (peering *VirtualNetworksVirtualNetworkPeering) ValidateUpdate(old runtime. // createValidations validates the creation of the resource func (peering *VirtualNetworksVirtualNetworkPeering) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){peering.validateResourceReferences} + return []func() (admission.Warnings, error){peering.validateResourceReferences, peering.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -217,7 +213,16 @@ func (peering *VirtualNetworksVirtualNetworkPeering) updateValidations() []func( func(old runtime.Object) (admission.Warnings, error) { return peering.validateResourceReferences() }, - peering.validateWriteOnceProperties} + peering.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return peering.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (peering *VirtualNetworksVirtualNetworkPeering) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(peering) } // validateResourceReferences validates all resource references @@ -483,7 +488,10 @@ func (peering *VirtualNetworks_VirtualNetworkPeering_Spec) PopulateFromARM(owner } // Set property "Owner": - peering.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + peering.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "PeeringState": // copying flattened property: diff --git a/v2/api/network/v1api20201101storage/load_balancer_types_gen.go b/v2/api/network/v1api20201101storage/load_balancer_types_gen.go index 0d88369e828..72ebde72b5e 100644 --- a/v2/api/network/v1api20201101storage/load_balancer_types_gen.go +++ b/v2/api/network/v1api20201101storage/load_balancer_types_gen.go @@ -85,11 +85,7 @@ func (balancer *LoadBalancer) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (balancer *LoadBalancer) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(balancer.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: balancer.Spec.Owner.Name, - } + return balancer.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/network/v1api20201101storage/load_balancers_inbound_nat_rule_types_gen.go b/v2/api/network/v1api20201101storage/load_balancers_inbound_nat_rule_types_gen.go index 237955c3035..1400b7b0d0c 100644 --- a/v2/api/network/v1api20201101storage/load_balancers_inbound_nat_rule_types_gen.go +++ b/v2/api/network/v1api20201101storage/load_balancers_inbound_nat_rule_types_gen.go @@ -84,11 +84,7 @@ func (rule *LoadBalancersInboundNatRule) NewEmptyStatus() genruntime.Convertible // Owner returns the ResourceReference of the owner func (rule *LoadBalancersInboundNatRule) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(rule.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: rule.Spec.Owner.Name, - } + return rule.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/network/v1api20201101storage/network_interface_types_gen.go b/v2/api/network/v1api20201101storage/network_interface_types_gen.go index a81e45f6540..ae4fbc07fb5 100644 --- a/v2/api/network/v1api20201101storage/network_interface_types_gen.go +++ b/v2/api/network/v1api20201101storage/network_interface_types_gen.go @@ -84,11 +84,7 @@ func (networkInterface *NetworkInterface) NewEmptyStatus() genruntime.Convertibl // Owner returns the ResourceReference of the owner func (networkInterface *NetworkInterface) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(networkInterface.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: networkInterface.Spec.Owner.Name, - } + return networkInterface.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/network/v1api20201101storage/network_security_group_types_gen.go b/v2/api/network/v1api20201101storage/network_security_group_types_gen.go index e33d607a88b..d7d0b317396 100644 --- a/v2/api/network/v1api20201101storage/network_security_group_types_gen.go +++ b/v2/api/network/v1api20201101storage/network_security_group_types_gen.go @@ -84,11 +84,7 @@ func (group *NetworkSecurityGroup) NewEmptyStatus() genruntime.ConvertibleStatus // Owner returns the ResourceReference of the owner func (group *NetworkSecurityGroup) Owner() *genruntime.ResourceReference { ownerGroup, ownerKind := genruntime.LookupOwnerGroupKind(group.Spec) - return &genruntime.ResourceReference{ - Group: ownerGroup, - Kind: ownerKind, - Name: group.Spec.Owner.Name, - } + return group.Spec.Owner.AsResourceReference(ownerGroup, ownerKind) } // SetStatus sets the status of this resource diff --git a/v2/api/network/v1api20201101storage/network_security_groups_security_rule_types_gen.go b/v2/api/network/v1api20201101storage/network_security_groups_security_rule_types_gen.go index e679af7d21e..9e771edea7d 100644 --- a/v2/api/network/v1api20201101storage/network_security_groups_security_rule_types_gen.go +++ b/v2/api/network/v1api20201101storage/network_security_groups_security_rule_types_gen.go @@ -84,11 +84,7 @@ func (rule *NetworkSecurityGroupsSecurityRule) NewEmptyStatus() genruntime.Conve // Owner returns the ResourceReference of the owner func (rule *NetworkSecurityGroupsSecurityRule) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(rule.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: rule.Spec.Owner.Name, - } + return rule.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/network/v1api20201101storage/public_ip_address_types_gen.go b/v2/api/network/v1api20201101storage/public_ip_address_types_gen.go index 6d500828f22..08a52575f8c 100644 --- a/v2/api/network/v1api20201101storage/public_ip_address_types_gen.go +++ b/v2/api/network/v1api20201101storage/public_ip_address_types_gen.go @@ -85,11 +85,7 @@ func (address *PublicIPAddress) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (address *PublicIPAddress) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(address.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: address.Spec.Owner.Name, - } + return address.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/network/v1api20201101storage/route_table_types_gen.go b/v2/api/network/v1api20201101storage/route_table_types_gen.go index 0696fd2cad8..0a0485c5411 100644 --- a/v2/api/network/v1api20201101storage/route_table_types_gen.go +++ b/v2/api/network/v1api20201101storage/route_table_types_gen.go @@ -84,11 +84,7 @@ func (table *RouteTable) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (table *RouteTable) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(table.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: table.Spec.Owner.Name, - } + return table.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/network/v1api20201101storage/route_tables_route_types_gen.go b/v2/api/network/v1api20201101storage/route_tables_route_types_gen.go index f0301f6cace..a4454cca2c6 100644 --- a/v2/api/network/v1api20201101storage/route_tables_route_types_gen.go +++ b/v2/api/network/v1api20201101storage/route_tables_route_types_gen.go @@ -84,11 +84,7 @@ func (route *RouteTablesRoute) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (route *RouteTablesRoute) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(route.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: route.Spec.Owner.Name, - } + return route.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/network/v1api20201101storage/virtual_network_gateway_types_gen.go b/v2/api/network/v1api20201101storage/virtual_network_gateway_types_gen.go index e6f0090bcae..cd9ac6ba8d5 100644 --- a/v2/api/network/v1api20201101storage/virtual_network_gateway_types_gen.go +++ b/v2/api/network/v1api20201101storage/virtual_network_gateway_types_gen.go @@ -84,11 +84,7 @@ func (gateway *VirtualNetworkGateway) NewEmptyStatus() genruntime.ConvertibleSta // Owner returns the ResourceReference of the owner func (gateway *VirtualNetworkGateway) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(gateway.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: gateway.Spec.Owner.Name, - } + return gateway.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/network/v1api20201101storage/virtual_network_types_gen.go b/v2/api/network/v1api20201101storage/virtual_network_types_gen.go index 3be5349a4ea..f273b9a9397 100644 --- a/v2/api/network/v1api20201101storage/virtual_network_types_gen.go +++ b/v2/api/network/v1api20201101storage/virtual_network_types_gen.go @@ -84,11 +84,7 @@ func (network *VirtualNetwork) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (network *VirtualNetwork) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(network.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: network.Spec.Owner.Name, - } + return network.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/network/v1api20201101storage/virtual_networks_subnet_types_gen.go b/v2/api/network/v1api20201101storage/virtual_networks_subnet_types_gen.go index b2758227395..33c4754b2a6 100644 --- a/v2/api/network/v1api20201101storage/virtual_networks_subnet_types_gen.go +++ b/v2/api/network/v1api20201101storage/virtual_networks_subnet_types_gen.go @@ -84,11 +84,7 @@ func (subnet *VirtualNetworksSubnet) NewEmptyStatus() genruntime.ConvertibleStat // Owner returns the ResourceReference of the owner func (subnet *VirtualNetworksSubnet) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(subnet.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: subnet.Spec.Owner.Name, - } + return subnet.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/network/v1api20201101storage/virtual_networks_virtual_network_peering_types_gen.go b/v2/api/network/v1api20201101storage/virtual_networks_virtual_network_peering_types_gen.go index 38b10b1a8e1..ad5f5ca14a7 100644 --- a/v2/api/network/v1api20201101storage/virtual_networks_virtual_network_peering_types_gen.go +++ b/v2/api/network/v1api20201101storage/virtual_networks_virtual_network_peering_types_gen.go @@ -84,11 +84,7 @@ func (peering *VirtualNetworksVirtualNetworkPeering) NewEmptyStatus() genruntime // Owner returns the ResourceReference of the owner func (peering *VirtualNetworksVirtualNetworkPeering) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(peering.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: peering.Spec.Owner.Name, - } + return peering.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/network/v1api20220701/bastion_host_types_gen.go b/v2/api/network/v1api20220701/bastion_host_types_gen.go index f851f807ea5..9bf9e118ae8 100644 --- a/v2/api/network/v1api20220701/bastion_host_types_gen.go +++ b/v2/api/network/v1api20220701/bastion_host_types_gen.go @@ -141,11 +141,7 @@ func (host *BastionHost) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (host *BastionHost) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(host.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: host.Spec.Owner.Name, - } + return host.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -203,7 +199,7 @@ func (host *BastionHost) ValidateUpdate(old runtime.Object) (admission.Warnings, // createValidations validates the creation of the resource func (host *BastionHost) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){host.validateResourceReferences} + return []func() (admission.Warnings, error){host.validateResourceReferences, host.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -217,7 +213,16 @@ func (host *BastionHost) updateValidations() []func(old runtime.Object) (admissi func(old runtime.Object) (admission.Warnings, error) { return host.validateResourceReferences() }, - host.validateWriteOnceProperties} + host.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return host.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (host *BastionHost) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(host) } // validateResourceReferences validates all resource references @@ -536,7 +541,10 @@ func (host *BastionHost_Spec) PopulateFromARM(owner genruntime.ArbitraryOwnerRef } // Set property "Owner": - host.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + host.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "ScaleUnits": // copying flattened property: diff --git a/v2/api/network/v1api20220701/dns_forwarding_rule_sets_forwarding_rule_types_gen.go b/v2/api/network/v1api20220701/dns_forwarding_rule_sets_forwarding_rule_types_gen.go index 1adb2de7dde..11164fa349d 100644 --- a/v2/api/network/v1api20220701/dns_forwarding_rule_sets_forwarding_rule_types_gen.go +++ b/v2/api/network/v1api20220701/dns_forwarding_rule_sets_forwarding_rule_types_gen.go @@ -141,11 +141,7 @@ func (rule *DnsForwardingRuleSetsForwardingRule) NewEmptyStatus() genruntime.Con // Owner returns the ResourceReference of the owner func (rule *DnsForwardingRuleSetsForwardingRule) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(rule.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: rule.Spec.Owner.Name, - } + return rule.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -203,7 +199,7 @@ func (rule *DnsForwardingRuleSetsForwardingRule) ValidateUpdate(old runtime.Obje // createValidations validates the creation of the resource func (rule *DnsForwardingRuleSetsForwardingRule) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){rule.validateResourceReferences, rule.validateOptionalConfigMapReferences} + return []func() (admission.Warnings, error){rule.validateResourceReferences, rule.validateOwnerReference, rule.validateOptionalConfigMapReferences} } // deleteValidations validates the deletion of the resource @@ -218,6 +214,9 @@ func (rule *DnsForwardingRuleSetsForwardingRule) updateValidations() []func(old return rule.validateResourceReferences() }, rule.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return rule.validateOwnerReference() + }, func(old runtime.Object) (admission.Warnings, error) { return rule.validateOptionalConfigMapReferences() }, @@ -233,6 +232,11 @@ func (rule *DnsForwardingRuleSetsForwardingRule) validateOptionalConfigMapRefere return genruntime.ValidateOptionalConfigMapReferences(refs) } +// validateOwnerReference validates the owner field +func (rule *DnsForwardingRuleSetsForwardingRule) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(rule) +} + // validateResourceReferences validates all resource references func (rule *DnsForwardingRuleSetsForwardingRule) validateResourceReferences() (admission.Warnings, error) { refs, err := reflecthelpers.FindResourceReferences(&rule.Spec) @@ -437,7 +441,10 @@ func (rule *DnsForwardingRulesets_ForwardingRule_Spec) PopulateFromARM(owner gen } // Set property "Owner": - rule.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + rule.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "TargetDnsServers": // copying flattened property: diff --git a/v2/api/network/v1api20220701/dns_forwarding_ruleset_types_gen.go b/v2/api/network/v1api20220701/dns_forwarding_ruleset_types_gen.go index 307b33c8c08..e8b1fa4724d 100644 --- a/v2/api/network/v1api20220701/dns_forwarding_ruleset_types_gen.go +++ b/v2/api/network/v1api20220701/dns_forwarding_ruleset_types_gen.go @@ -141,11 +141,7 @@ func (ruleset *DnsForwardingRuleset) NewEmptyStatus() genruntime.ConvertibleStat // Owner returns the ResourceReference of the owner func (ruleset *DnsForwardingRuleset) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(ruleset.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: ruleset.Spec.Owner.Name, - } + return ruleset.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -203,7 +199,7 @@ func (ruleset *DnsForwardingRuleset) ValidateUpdate(old runtime.Object) (admissi // createValidations validates the creation of the resource func (ruleset *DnsForwardingRuleset) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){ruleset.validateResourceReferences} + return []func() (admission.Warnings, error){ruleset.validateResourceReferences, ruleset.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -217,7 +213,16 @@ func (ruleset *DnsForwardingRuleset) updateValidations() []func(old runtime.Obje func(old runtime.Object) (admission.Warnings, error) { return ruleset.validateResourceReferences() }, - ruleset.validateWriteOnceProperties} + ruleset.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return ruleset.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (ruleset *DnsForwardingRuleset) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(ruleset) } // validateResourceReferences validates all resource references @@ -409,7 +414,10 @@ func (ruleset *DnsForwardingRuleset_Spec) PopulateFromARM(owner genruntime.Arbit } // Set property "Owner": - ruleset.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + ruleset.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "Tags": if typedInput.Tags != nil { diff --git a/v2/api/network/v1api20220701/dns_resolver_types_gen.go b/v2/api/network/v1api20220701/dns_resolver_types_gen.go index 1a19865ea9b..3b89e552e0d 100644 --- a/v2/api/network/v1api20220701/dns_resolver_types_gen.go +++ b/v2/api/network/v1api20220701/dns_resolver_types_gen.go @@ -141,11 +141,7 @@ func (resolver *DnsResolver) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (resolver *DnsResolver) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(resolver.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: resolver.Spec.Owner.Name, - } + return resolver.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -203,7 +199,7 @@ func (resolver *DnsResolver) ValidateUpdate(old runtime.Object) (admission.Warni // createValidations validates the creation of the resource func (resolver *DnsResolver) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){resolver.validateResourceReferences} + return []func() (admission.Warnings, error){resolver.validateResourceReferences, resolver.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -217,7 +213,16 @@ func (resolver *DnsResolver) updateValidations() []func(old runtime.Object) (adm func(old runtime.Object) (admission.Warnings, error) { return resolver.validateResourceReferences() }, - resolver.validateWriteOnceProperties} + resolver.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return resolver.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (resolver *DnsResolver) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(resolver) } // validateResourceReferences validates all resource references @@ -396,7 +401,10 @@ func (resolver *DnsResolver_Spec) PopulateFromARM(owner genruntime.ArbitraryOwne } // Set property "Owner": - resolver.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + resolver.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "Tags": if typedInput.Tags != nil { diff --git a/v2/api/network/v1api20220701/dns_resolvers_inbound_endpoint_types_gen.go b/v2/api/network/v1api20220701/dns_resolvers_inbound_endpoint_types_gen.go index dbe773e9bcc..4453c55ddcb 100644 --- a/v2/api/network/v1api20220701/dns_resolvers_inbound_endpoint_types_gen.go +++ b/v2/api/network/v1api20220701/dns_resolvers_inbound_endpoint_types_gen.go @@ -141,11 +141,7 @@ func (endpoint *DnsResolversInboundEndpoint) NewEmptyStatus() genruntime.Convert // Owner returns the ResourceReference of the owner func (endpoint *DnsResolversInboundEndpoint) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(endpoint.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: endpoint.Spec.Owner.Name, - } + return endpoint.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -203,7 +199,7 @@ func (endpoint *DnsResolversInboundEndpoint) ValidateUpdate(old runtime.Object) // createValidations validates the creation of the resource func (endpoint *DnsResolversInboundEndpoint) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){endpoint.validateResourceReferences} + return []func() (admission.Warnings, error){endpoint.validateResourceReferences, endpoint.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -217,7 +213,16 @@ func (endpoint *DnsResolversInboundEndpoint) updateValidations() []func(old runt func(old runtime.Object) (admission.Warnings, error) { return endpoint.validateResourceReferences() }, - endpoint.validateWriteOnceProperties} + endpoint.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return endpoint.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (endpoint *DnsResolversInboundEndpoint) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(endpoint) } // validateResourceReferences validates all resource references @@ -408,7 +413,10 @@ func (endpoint *DnsResolvers_InboundEndpoint_Spec) PopulateFromARM(owner genrunt } // Set property "Owner": - endpoint.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + endpoint.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "Tags": if typedInput.Tags != nil { diff --git a/v2/api/network/v1api20220701/dns_resolvers_outbound_endpoint_types_gen.go b/v2/api/network/v1api20220701/dns_resolvers_outbound_endpoint_types_gen.go index d8f816c47c7..877e6bcaaf7 100644 --- a/v2/api/network/v1api20220701/dns_resolvers_outbound_endpoint_types_gen.go +++ b/v2/api/network/v1api20220701/dns_resolvers_outbound_endpoint_types_gen.go @@ -141,11 +141,7 @@ func (endpoint *DnsResolversOutboundEndpoint) NewEmptyStatus() genruntime.Conver // Owner returns the ResourceReference of the owner func (endpoint *DnsResolversOutboundEndpoint) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(endpoint.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: endpoint.Spec.Owner.Name, - } + return endpoint.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -203,7 +199,7 @@ func (endpoint *DnsResolversOutboundEndpoint) ValidateUpdate(old runtime.Object) // createValidations validates the creation of the resource func (endpoint *DnsResolversOutboundEndpoint) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){endpoint.validateResourceReferences} + return []func() (admission.Warnings, error){endpoint.validateResourceReferences, endpoint.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -217,7 +213,16 @@ func (endpoint *DnsResolversOutboundEndpoint) updateValidations() []func(old run func(old runtime.Object) (admission.Warnings, error) { return endpoint.validateResourceReferences() }, - endpoint.validateWriteOnceProperties} + endpoint.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return endpoint.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (endpoint *DnsResolversOutboundEndpoint) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(endpoint) } // validateResourceReferences validates all resource references @@ -396,7 +401,10 @@ func (endpoint *DnsResolvers_OutboundEndpoint_Spec) PopulateFromARM(owner genrun } // Set property "Owner": - endpoint.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + endpoint.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "Subnet": // copying flattened property: diff --git a/v2/api/network/v1api20220701/nat_gateway_types_gen.go b/v2/api/network/v1api20220701/nat_gateway_types_gen.go index 924e2e0b6f5..0261f0649b8 100644 --- a/v2/api/network/v1api20220701/nat_gateway_types_gen.go +++ b/v2/api/network/v1api20220701/nat_gateway_types_gen.go @@ -141,11 +141,7 @@ func (gateway *NatGateway) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (gateway *NatGateway) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(gateway.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: gateway.Spec.Owner.Name, - } + return gateway.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -203,7 +199,7 @@ func (gateway *NatGateway) ValidateUpdate(old runtime.Object) (admission.Warning // createValidations validates the creation of the resource func (gateway *NatGateway) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){gateway.validateResourceReferences} + return []func() (admission.Warnings, error){gateway.validateResourceReferences, gateway.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -217,7 +213,16 @@ func (gateway *NatGateway) updateValidations() []func(old runtime.Object) (admis func(old runtime.Object) (admission.Warnings, error) { return gateway.validateResourceReferences() }, - gateway.validateWriteOnceProperties} + gateway.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return gateway.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (gateway *NatGateway) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(gateway) } // validateResourceReferences validates all resource references @@ -442,7 +447,10 @@ func (gateway *NatGateway_Spec) PopulateFromARM(owner genruntime.ArbitraryOwnerR } // Set property "Owner": - gateway.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + gateway.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "PublicIpAddresses": // copying flattened property: diff --git a/v2/api/network/v1api20220701/private_endpoint_types_gen.go b/v2/api/network/v1api20220701/private_endpoint_types_gen.go index 1ecc2a317b8..629d0595a46 100644 --- a/v2/api/network/v1api20220701/private_endpoint_types_gen.go +++ b/v2/api/network/v1api20220701/private_endpoint_types_gen.go @@ -141,11 +141,7 @@ func (endpoint *PrivateEndpoint) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (endpoint *PrivateEndpoint) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(endpoint.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: endpoint.Spec.Owner.Name, - } + return endpoint.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -203,7 +199,7 @@ func (endpoint *PrivateEndpoint) ValidateUpdate(old runtime.Object) (admission.W // createValidations validates the creation of the resource func (endpoint *PrivateEndpoint) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){endpoint.validateResourceReferences} + return []func() (admission.Warnings, error){endpoint.validateResourceReferences, endpoint.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -217,7 +213,16 @@ func (endpoint *PrivateEndpoint) updateValidations() []func(old runtime.Object) func(old runtime.Object) (admission.Warnings, error) { return endpoint.validateResourceReferences() }, - endpoint.validateWriteOnceProperties} + endpoint.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return endpoint.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (endpoint *PrivateEndpoint) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(endpoint) } // validateResourceReferences validates all resource references @@ -520,7 +525,10 @@ func (endpoint *PrivateEndpoint_Spec) PopulateFromARM(owner genruntime.Arbitrary } // Set property "Owner": - endpoint.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + endpoint.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "PrivateLinkServiceConnections": // copying flattened property: diff --git a/v2/api/network/v1api20220701/private_endpoints_private_dns_zone_group_types_gen.go b/v2/api/network/v1api20220701/private_endpoints_private_dns_zone_group_types_gen.go index 9266864a3dc..aa094389a51 100644 --- a/v2/api/network/v1api20220701/private_endpoints_private_dns_zone_group_types_gen.go +++ b/v2/api/network/v1api20220701/private_endpoints_private_dns_zone_group_types_gen.go @@ -141,11 +141,7 @@ func (group *PrivateEndpointsPrivateDnsZoneGroup) NewEmptyStatus() genruntime.Co // Owner returns the ResourceReference of the owner func (group *PrivateEndpointsPrivateDnsZoneGroup) Owner() *genruntime.ResourceReference { ownerGroup, ownerKind := genruntime.LookupOwnerGroupKind(group.Spec) - return &genruntime.ResourceReference{ - Group: ownerGroup, - Kind: ownerKind, - Name: group.Spec.Owner.Name, - } + return group.Spec.Owner.AsResourceReference(ownerGroup, ownerKind) } // SetStatus sets the status of this resource @@ -203,7 +199,7 @@ func (group *PrivateEndpointsPrivateDnsZoneGroup) ValidateUpdate(old runtime.Obj // createValidations validates the creation of the resource func (group *PrivateEndpointsPrivateDnsZoneGroup) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){group.validateResourceReferences} + return []func() (admission.Warnings, error){group.validateResourceReferences, group.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -217,7 +213,16 @@ func (group *PrivateEndpointsPrivateDnsZoneGroup) updateValidations() []func(old func(old runtime.Object) (admission.Warnings, error) { return group.validateResourceReferences() }, - group.validateWriteOnceProperties} + group.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return group.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (group *PrivateEndpointsPrivateDnsZoneGroup) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(group) } // validateResourceReferences validates all resource references @@ -367,7 +372,10 @@ func (group *PrivateEndpoints_PrivateDnsZoneGroup_Spec) PopulateFromARM(owner ge group.SetAzureName(genruntime.ExtractKubernetesResourceNameFromARMName(typedInput.Name)) // Set property "Owner": - group.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + group.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "PrivateDnsZoneConfigs": // copying flattened property: diff --git a/v2/api/network/v1api20220701/private_link_service_types_gen.go b/v2/api/network/v1api20220701/private_link_service_types_gen.go index 222caee0b30..b1ca4e804ec 100644 --- a/v2/api/network/v1api20220701/private_link_service_types_gen.go +++ b/v2/api/network/v1api20220701/private_link_service_types_gen.go @@ -163,11 +163,7 @@ func (service *PrivateLinkService) NewEmptyStatus() genruntime.ConvertibleStatus // Owner returns the ResourceReference of the owner func (service *PrivateLinkService) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(service.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: service.Spec.Owner.Name, - } + return service.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -225,7 +221,7 @@ func (service *PrivateLinkService) ValidateUpdate(old runtime.Object) (admission // createValidations validates the creation of the resource func (service *PrivateLinkService) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){service.validateResourceReferences, service.validateConfigMapDestinations} + return []func() (admission.Warnings, error){service.validateResourceReferences, service.validateOwnerReference, service.validateConfigMapDestinations} } // deleteValidations validates the deletion of the resource @@ -240,6 +236,9 @@ func (service *PrivateLinkService) updateValidations() []func(old runtime.Object return service.validateResourceReferences() }, service.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return service.validateOwnerReference() + }, func(old runtime.Object) (admission.Warnings, error) { return service.validateConfigMapDestinations() }, @@ -260,6 +259,11 @@ func (service *PrivateLinkService) validateConfigMapDestinations() (admission.Wa return genruntime.ValidateConfigMapDestinations(toValidate) } +// validateOwnerReference validates the owner field +func (service *PrivateLinkService) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(service) +} + // validateResourceReferences validates all resource references func (service *PrivateLinkService) validateResourceReferences() (admission.Warnings, error) { refs, err := reflecthelpers.FindResourceReferences(&service.Spec) @@ -570,7 +574,10 @@ func (service *PrivateLinkService_Spec) PopulateFromARM(owner genruntime.Arbitra // no assignment for property "OperatorSpec" // Set property "Owner": - service.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + service.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "Tags": if typedInput.Tags != nil { diff --git a/v2/api/network/v1api20220701/public_ip_prefix_types_gen.go b/v2/api/network/v1api20220701/public_ip_prefix_types_gen.go index d143177f9df..4478fb830ad 100644 --- a/v2/api/network/v1api20220701/public_ip_prefix_types_gen.go +++ b/v2/api/network/v1api20220701/public_ip_prefix_types_gen.go @@ -141,11 +141,7 @@ func (prefix *PublicIPPrefix) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (prefix *PublicIPPrefix) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(prefix.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: prefix.Spec.Owner.Name, - } + return prefix.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -203,7 +199,7 @@ func (prefix *PublicIPPrefix) ValidateUpdate(old runtime.Object) (admission.Warn // createValidations validates the creation of the resource func (prefix *PublicIPPrefix) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){prefix.validateResourceReferences} + return []func() (admission.Warnings, error){prefix.validateResourceReferences, prefix.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -217,7 +213,16 @@ func (prefix *PublicIPPrefix) updateValidations() []func(old runtime.Object) (ad func(old runtime.Object) (admission.Warnings, error) { return prefix.validateResourceReferences() }, - prefix.validateWriteOnceProperties} + prefix.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return prefix.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (prefix *PublicIPPrefix) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(prefix) } // validateResourceReferences validates all resource references @@ -519,7 +524,10 @@ func (prefix *PublicIPPrefix_Spec) PopulateFromARM(owner genruntime.ArbitraryOwn } // Set property "Owner": - prefix.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + prefix.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "PrefixLength": // copying flattened property: diff --git a/v2/api/network/v1api20220701storage/bastion_host_types_gen.go b/v2/api/network/v1api20220701storage/bastion_host_types_gen.go index 66a4c82c0eb..a55b5874d09 100644 --- a/v2/api/network/v1api20220701storage/bastion_host_types_gen.go +++ b/v2/api/network/v1api20220701storage/bastion_host_types_gen.go @@ -84,11 +84,7 @@ func (host *BastionHost) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (host *BastionHost) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(host.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: host.Spec.Owner.Name, - } + return host.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/network/v1api20220701storage/dns_forwarding_rule_sets_forwarding_rule_types_gen.go b/v2/api/network/v1api20220701storage/dns_forwarding_rule_sets_forwarding_rule_types_gen.go index da37dba32de..2f1d4bc5e88 100644 --- a/v2/api/network/v1api20220701storage/dns_forwarding_rule_sets_forwarding_rule_types_gen.go +++ b/v2/api/network/v1api20220701storage/dns_forwarding_rule_sets_forwarding_rule_types_gen.go @@ -84,11 +84,7 @@ func (rule *DnsForwardingRuleSetsForwardingRule) NewEmptyStatus() genruntime.Con // Owner returns the ResourceReference of the owner func (rule *DnsForwardingRuleSetsForwardingRule) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(rule.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: rule.Spec.Owner.Name, - } + return rule.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/network/v1api20220701storage/dns_forwarding_ruleset_types_gen.go b/v2/api/network/v1api20220701storage/dns_forwarding_ruleset_types_gen.go index d442d36919f..e426abfe0cc 100644 --- a/v2/api/network/v1api20220701storage/dns_forwarding_ruleset_types_gen.go +++ b/v2/api/network/v1api20220701storage/dns_forwarding_ruleset_types_gen.go @@ -84,11 +84,7 @@ func (ruleset *DnsForwardingRuleset) NewEmptyStatus() genruntime.ConvertibleStat // Owner returns the ResourceReference of the owner func (ruleset *DnsForwardingRuleset) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(ruleset.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: ruleset.Spec.Owner.Name, - } + return ruleset.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/network/v1api20220701storage/dns_resolver_types_gen.go b/v2/api/network/v1api20220701storage/dns_resolver_types_gen.go index 70184c2d277..6588890012c 100644 --- a/v2/api/network/v1api20220701storage/dns_resolver_types_gen.go +++ b/v2/api/network/v1api20220701storage/dns_resolver_types_gen.go @@ -84,11 +84,7 @@ func (resolver *DnsResolver) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (resolver *DnsResolver) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(resolver.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: resolver.Spec.Owner.Name, - } + return resolver.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/network/v1api20220701storage/dns_resolvers_inbound_endpoint_types_gen.go b/v2/api/network/v1api20220701storage/dns_resolvers_inbound_endpoint_types_gen.go index 61098c82fc7..373b2059f02 100644 --- a/v2/api/network/v1api20220701storage/dns_resolvers_inbound_endpoint_types_gen.go +++ b/v2/api/network/v1api20220701storage/dns_resolvers_inbound_endpoint_types_gen.go @@ -84,11 +84,7 @@ func (endpoint *DnsResolversInboundEndpoint) NewEmptyStatus() genruntime.Convert // Owner returns the ResourceReference of the owner func (endpoint *DnsResolversInboundEndpoint) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(endpoint.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: endpoint.Spec.Owner.Name, - } + return endpoint.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/network/v1api20220701storage/dns_resolvers_outbound_endpoint_types_gen.go b/v2/api/network/v1api20220701storage/dns_resolvers_outbound_endpoint_types_gen.go index 91be81f4697..c7a0307bb20 100644 --- a/v2/api/network/v1api20220701storage/dns_resolvers_outbound_endpoint_types_gen.go +++ b/v2/api/network/v1api20220701storage/dns_resolvers_outbound_endpoint_types_gen.go @@ -84,11 +84,7 @@ func (endpoint *DnsResolversOutboundEndpoint) NewEmptyStatus() genruntime.Conver // Owner returns the ResourceReference of the owner func (endpoint *DnsResolversOutboundEndpoint) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(endpoint.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: endpoint.Spec.Owner.Name, - } + return endpoint.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/network/v1api20220701storage/nat_gateway_types_gen.go b/v2/api/network/v1api20220701storage/nat_gateway_types_gen.go index c67d2e32fb0..a3550fd920f 100644 --- a/v2/api/network/v1api20220701storage/nat_gateway_types_gen.go +++ b/v2/api/network/v1api20220701storage/nat_gateway_types_gen.go @@ -84,11 +84,7 @@ func (gateway *NatGateway) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (gateway *NatGateway) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(gateway.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: gateway.Spec.Owner.Name, - } + return gateway.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/network/v1api20220701storage/private_endpoint_types_gen.go b/v2/api/network/v1api20220701storage/private_endpoint_types_gen.go index 9651f8f4ba5..df1a7ae9004 100644 --- a/v2/api/network/v1api20220701storage/private_endpoint_types_gen.go +++ b/v2/api/network/v1api20220701storage/private_endpoint_types_gen.go @@ -84,11 +84,7 @@ func (endpoint *PrivateEndpoint) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (endpoint *PrivateEndpoint) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(endpoint.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: endpoint.Spec.Owner.Name, - } + return endpoint.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/network/v1api20220701storage/private_endpoints_private_dns_zone_group_types_gen.go b/v2/api/network/v1api20220701storage/private_endpoints_private_dns_zone_group_types_gen.go index bf3bf4fc0b2..6d12771398f 100644 --- a/v2/api/network/v1api20220701storage/private_endpoints_private_dns_zone_group_types_gen.go +++ b/v2/api/network/v1api20220701storage/private_endpoints_private_dns_zone_group_types_gen.go @@ -84,11 +84,7 @@ func (group *PrivateEndpointsPrivateDnsZoneGroup) NewEmptyStatus() genruntime.Co // Owner returns the ResourceReference of the owner func (group *PrivateEndpointsPrivateDnsZoneGroup) Owner() *genruntime.ResourceReference { ownerGroup, ownerKind := genruntime.LookupOwnerGroupKind(group.Spec) - return &genruntime.ResourceReference{ - Group: ownerGroup, - Kind: ownerKind, - Name: group.Spec.Owner.Name, - } + return group.Spec.Owner.AsResourceReference(ownerGroup, ownerKind) } // SetStatus sets the status of this resource diff --git a/v2/api/network/v1api20220701storage/private_link_service_types_gen.go b/v2/api/network/v1api20220701storage/private_link_service_types_gen.go index b62abfc2a63..9440f207f12 100644 --- a/v2/api/network/v1api20220701storage/private_link_service_types_gen.go +++ b/v2/api/network/v1api20220701storage/private_link_service_types_gen.go @@ -106,11 +106,7 @@ func (service *PrivateLinkService) NewEmptyStatus() genruntime.ConvertibleStatus // Owner returns the ResourceReference of the owner func (service *PrivateLinkService) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(service.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: service.Spec.Owner.Name, - } + return service.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/network/v1api20220701storage/public_ip_prefix_types_gen.go b/v2/api/network/v1api20220701storage/public_ip_prefix_types_gen.go index 829ef7e2c84..f7cecb9d503 100644 --- a/v2/api/network/v1api20220701storage/public_ip_prefix_types_gen.go +++ b/v2/api/network/v1api20220701storage/public_ip_prefix_types_gen.go @@ -84,11 +84,7 @@ func (prefix *PublicIPPrefix) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (prefix *PublicIPPrefix) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(prefix.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: prefix.Spec.Owner.Name, - } + return prefix.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/network/v1beta20180901/private_dns_zone_types_gen.go b/v2/api/network/v1beta20180901/private_dns_zone_types_gen.go index ae85c58f8a7..a75f9fdf69b 100644 --- a/v2/api/network/v1beta20180901/private_dns_zone_types_gen.go +++ b/v2/api/network/v1beta20180901/private_dns_zone_types_gen.go @@ -142,11 +142,7 @@ func (zone *PrivateDnsZone) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (zone *PrivateDnsZone) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(zone.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: zone.Spec.Owner.Name, - } + return zone.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -204,7 +200,7 @@ func (zone *PrivateDnsZone) ValidateUpdate(old runtime.Object) (admission.Warnin // createValidations validates the creation of the resource func (zone *PrivateDnsZone) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){zone.validateResourceReferences} + return []func() (admission.Warnings, error){zone.validateResourceReferences, zone.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -218,7 +214,16 @@ func (zone *PrivateDnsZone) updateValidations() []func(old runtime.Object) (admi func(old runtime.Object) (admission.Warnings, error) { return zone.validateResourceReferences() }, - zone.validateWriteOnceProperties} + zone.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return zone.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (zone *PrivateDnsZone) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(zone) } // validateResourceReferences validates all resource references @@ -392,7 +397,10 @@ func (zone *PrivateDnsZone_Spec) PopulateFromARM(owner genruntime.ArbitraryOwner } // Set property "Owner": - zone.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + zone.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "Tags": if typedInput.Tags != nil { diff --git a/v2/api/network/v1beta20180901storage/private_dns_zone_types_gen.go b/v2/api/network/v1beta20180901storage/private_dns_zone_types_gen.go index 205437d9c48..d9036d1464c 100644 --- a/v2/api/network/v1beta20180901storage/private_dns_zone_types_gen.go +++ b/v2/api/network/v1beta20180901storage/private_dns_zone_types_gen.go @@ -103,11 +103,7 @@ func (zone *PrivateDnsZone) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (zone *PrivateDnsZone) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(zone.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: zone.Spec.Owner.Name, - } + return zone.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/network/v1beta20201101/load_balancer_types_gen.go b/v2/api/network/v1beta20201101/load_balancer_types_gen.go index 5eff1d59292..86603c94ecd 100644 --- a/v2/api/network/v1beta20201101/load_balancer_types_gen.go +++ b/v2/api/network/v1beta20201101/load_balancer_types_gen.go @@ -142,11 +142,7 @@ func (balancer *LoadBalancer) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (balancer *LoadBalancer) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(balancer.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: balancer.Spec.Owner.Name, - } + return balancer.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -204,7 +200,7 @@ func (balancer *LoadBalancer) ValidateUpdate(old runtime.Object) (admission.Warn // createValidations validates the creation of the resource func (balancer *LoadBalancer) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){balancer.validateResourceReferences} + return []func() (admission.Warnings, error){balancer.validateResourceReferences, balancer.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -218,7 +214,16 @@ func (balancer *LoadBalancer) updateValidations() []func(old runtime.Object) (ad func(old runtime.Object) (admission.Warnings, error) { return balancer.validateResourceReferences() }, - balancer.validateWriteOnceProperties} + balancer.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return balancer.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (balancer *LoadBalancer) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(balancer) } // validateResourceReferences validates all resource references @@ -557,7 +562,10 @@ func (balancer *LoadBalancer_Spec) PopulateFromARM(owner genruntime.ArbitraryOwn } // Set property "Owner": - balancer.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + balancer.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "Probes": // copying flattened property: diff --git a/v2/api/network/v1beta20201101/network_interface_types_gen.go b/v2/api/network/v1beta20201101/network_interface_types_gen.go index 77ed46f7bcb..28aadfedc6f 100644 --- a/v2/api/network/v1beta20201101/network_interface_types_gen.go +++ b/v2/api/network/v1beta20201101/network_interface_types_gen.go @@ -142,11 +142,7 @@ func (networkInterface *NetworkInterface) NewEmptyStatus() genruntime.Convertibl // Owner returns the ResourceReference of the owner func (networkInterface *NetworkInterface) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(networkInterface.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: networkInterface.Spec.Owner.Name, - } + return networkInterface.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -204,7 +200,7 @@ func (networkInterface *NetworkInterface) ValidateUpdate(old runtime.Object) (ad // createValidations validates the creation of the resource func (networkInterface *NetworkInterface) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){networkInterface.validateResourceReferences} + return []func() (admission.Warnings, error){networkInterface.validateResourceReferences, networkInterface.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -218,7 +214,16 @@ func (networkInterface *NetworkInterface) updateValidations() []func(old runtime func(old runtime.Object) (admission.Warnings, error) { return networkInterface.validateResourceReferences() }, - networkInterface.validateWriteOnceProperties} + networkInterface.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return networkInterface.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (networkInterface *NetworkInterface) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(networkInterface) } // validateResourceReferences validates all resource references @@ -524,7 +529,10 @@ func (networkInterface *NetworkInterface_Spec) PopulateFromARM(owner genruntime. } // Set property "Owner": - networkInterface.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + networkInterface.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "PrivateLinkService": // copying flattened property: diff --git a/v2/api/network/v1beta20201101/network_security_group_types_gen.go b/v2/api/network/v1beta20201101/network_security_group_types_gen.go index 12162363873..f348451ce8f 100644 --- a/v2/api/network/v1beta20201101/network_security_group_types_gen.go +++ b/v2/api/network/v1beta20201101/network_security_group_types_gen.go @@ -142,11 +142,7 @@ func (group *NetworkSecurityGroup) NewEmptyStatus() genruntime.ConvertibleStatus // Owner returns the ResourceReference of the owner func (group *NetworkSecurityGroup) Owner() *genruntime.ResourceReference { ownerGroup, ownerKind := genruntime.LookupOwnerGroupKind(group.Spec) - return &genruntime.ResourceReference{ - Group: ownerGroup, - Kind: ownerKind, - Name: group.Spec.Owner.Name, - } + return group.Spec.Owner.AsResourceReference(ownerGroup, ownerKind) } // SetStatus sets the status of this resource @@ -204,7 +200,7 @@ func (group *NetworkSecurityGroup) ValidateUpdate(old runtime.Object) (admission // createValidations validates the creation of the resource func (group *NetworkSecurityGroup) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){group.validateResourceReferences} + return []func() (admission.Warnings, error){group.validateResourceReferences, group.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -218,7 +214,16 @@ func (group *NetworkSecurityGroup) updateValidations() []func(old runtime.Object func(old runtime.Object) (admission.Warnings, error) { return group.validateResourceReferences() }, - group.validateWriteOnceProperties} + group.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return group.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (group *NetworkSecurityGroup) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(group) } // validateResourceReferences validates all resource references @@ -375,7 +380,10 @@ func (group *NetworkSecurityGroup_Spec) PopulateFromARM(owner genruntime.Arbitra } // Set property "Owner": - group.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + group.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "Tags": if typedInput.Tags != nil { diff --git a/v2/api/network/v1beta20201101/network_security_groups_security_rule_types_gen.go b/v2/api/network/v1beta20201101/network_security_groups_security_rule_types_gen.go index a95a5cbda8a..4d696ad10b0 100644 --- a/v2/api/network/v1beta20201101/network_security_groups_security_rule_types_gen.go +++ b/v2/api/network/v1beta20201101/network_security_groups_security_rule_types_gen.go @@ -142,11 +142,7 @@ func (rule *NetworkSecurityGroupsSecurityRule) NewEmptyStatus() genruntime.Conve // Owner returns the ResourceReference of the owner func (rule *NetworkSecurityGroupsSecurityRule) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(rule.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: rule.Spec.Owner.Name, - } + return rule.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -204,7 +200,7 @@ func (rule *NetworkSecurityGroupsSecurityRule) ValidateUpdate(old runtime.Object // createValidations validates the creation of the resource func (rule *NetworkSecurityGroupsSecurityRule) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){rule.validateResourceReferences} + return []func() (admission.Warnings, error){rule.validateResourceReferences, rule.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -218,7 +214,16 @@ func (rule *NetworkSecurityGroupsSecurityRule) updateValidations() []func(old ru func(old runtime.Object) (admission.Warnings, error) { return rule.validateResourceReferences() }, - rule.validateWriteOnceProperties} + rule.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return rule.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (rule *NetworkSecurityGroupsSecurityRule) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(rule) } // validateResourceReferences validates all resource references @@ -527,7 +532,10 @@ func (rule *NetworkSecurityGroups_SecurityRule_Spec) PopulateFromARM(owner genru } // Set property "Owner": - rule.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + rule.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "Priority": // copying flattened property: diff --git a/v2/api/network/v1beta20201101/public_ip_address_types_gen.go b/v2/api/network/v1beta20201101/public_ip_address_types_gen.go index 3b5ce3357fe..35895025832 100644 --- a/v2/api/network/v1beta20201101/public_ip_address_types_gen.go +++ b/v2/api/network/v1beta20201101/public_ip_address_types_gen.go @@ -142,11 +142,7 @@ func (address *PublicIPAddress) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (address *PublicIPAddress) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(address.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: address.Spec.Owner.Name, - } + return address.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -204,7 +200,7 @@ func (address *PublicIPAddress) ValidateUpdate(old runtime.Object) (admission.Wa // createValidations validates the creation of the resource func (address *PublicIPAddress) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){address.validateResourceReferences} + return []func() (admission.Warnings, error){address.validateResourceReferences, address.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -218,7 +214,16 @@ func (address *PublicIPAddress) updateValidations() []func(old runtime.Object) ( func(old runtime.Object) (admission.Warnings, error) { return address.validateResourceReferences() }, - address.validateWriteOnceProperties} + address.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return address.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (address *PublicIPAddress) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(address) } // validateResourceReferences validates all resource references @@ -596,7 +601,10 @@ func (address *PublicIPAddress_Spec) PopulateFromARM(owner genruntime.ArbitraryO } // Set property "Owner": - address.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + address.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "PublicIPAddressVersion": // copying flattened property: diff --git a/v2/api/network/v1beta20201101/route_table_types_gen.go b/v2/api/network/v1beta20201101/route_table_types_gen.go index af802e9dd54..ff3a3065400 100644 --- a/v2/api/network/v1beta20201101/route_table_types_gen.go +++ b/v2/api/network/v1beta20201101/route_table_types_gen.go @@ -142,11 +142,7 @@ func (table *RouteTable) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (table *RouteTable) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(table.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: table.Spec.Owner.Name, - } + return table.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -204,7 +200,7 @@ func (table *RouteTable) ValidateUpdate(old runtime.Object) (admission.Warnings, // createValidations validates the creation of the resource func (table *RouteTable) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){table.validateResourceReferences} + return []func() (admission.Warnings, error){table.validateResourceReferences, table.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -218,7 +214,16 @@ func (table *RouteTable) updateValidations() []func(old runtime.Object) (admissi func(old runtime.Object) (admission.Warnings, error) { return table.validateResourceReferences() }, - table.validateWriteOnceProperties} + table.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return table.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (table *RouteTable) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(table) } // validateResourceReferences validates all resource references @@ -392,7 +397,10 @@ func (table *RouteTable_Spec) PopulateFromARM(owner genruntime.ArbitraryOwnerRef } // Set property "Owner": - table.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + table.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "Tags": if typedInput.Tags != nil { diff --git a/v2/api/network/v1beta20201101/route_tables_route_types_gen.go b/v2/api/network/v1beta20201101/route_tables_route_types_gen.go index 568840cfcf8..f635faace69 100644 --- a/v2/api/network/v1beta20201101/route_tables_route_types_gen.go +++ b/v2/api/network/v1beta20201101/route_tables_route_types_gen.go @@ -142,11 +142,7 @@ func (route *RouteTablesRoute) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (route *RouteTablesRoute) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(route.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: route.Spec.Owner.Name, - } + return route.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -204,7 +200,7 @@ func (route *RouteTablesRoute) ValidateUpdate(old runtime.Object) (admission.War // createValidations validates the creation of the resource func (route *RouteTablesRoute) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){route.validateResourceReferences} + return []func() (admission.Warnings, error){route.validateResourceReferences, route.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -218,7 +214,16 @@ func (route *RouteTablesRoute) updateValidations() []func(old runtime.Object) (a func(old runtime.Object) (admission.Warnings, error) { return route.validateResourceReferences() }, - route.validateWriteOnceProperties} + route.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return route.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (route *RouteTablesRoute) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(route) } // validateResourceReferences validates all resource references @@ -418,7 +423,10 @@ func (route *RouteTables_Route_Spec) PopulateFromARM(owner genruntime.ArbitraryO } // Set property "Owner": - route.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + route.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // No error return nil diff --git a/v2/api/network/v1beta20201101/virtual_network_gateway_types_gen.go b/v2/api/network/v1beta20201101/virtual_network_gateway_types_gen.go index f7cd2bfa6e2..328929c7017 100644 --- a/v2/api/network/v1beta20201101/virtual_network_gateway_types_gen.go +++ b/v2/api/network/v1beta20201101/virtual_network_gateway_types_gen.go @@ -142,11 +142,7 @@ func (gateway *VirtualNetworkGateway) NewEmptyStatus() genruntime.ConvertibleSta // Owner returns the ResourceReference of the owner func (gateway *VirtualNetworkGateway) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(gateway.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: gateway.Spec.Owner.Name, - } + return gateway.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -204,7 +200,7 @@ func (gateway *VirtualNetworkGateway) ValidateUpdate(old runtime.Object) (admiss // createValidations validates the creation of the resource func (gateway *VirtualNetworkGateway) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){gateway.validateResourceReferences} + return []func() (admission.Warnings, error){gateway.validateResourceReferences, gateway.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -218,7 +214,16 @@ func (gateway *VirtualNetworkGateway) updateValidations() []func(old runtime.Obj func(old runtime.Object) (admission.Warnings, error) { return gateway.validateResourceReferences() }, - gateway.validateWriteOnceProperties} + gateway.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return gateway.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (gateway *VirtualNetworkGateway) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(gateway) } // validateResourceReferences validates all resource references @@ -611,7 +616,10 @@ func (gateway *VirtualNetworkGateway_Spec) PopulateFromARM(owner genruntime.Arbi } // Set property "Owner": - gateway.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + gateway.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "Sku": // copying flattened property: diff --git a/v2/api/network/v1beta20201101/virtual_network_types_gen.go b/v2/api/network/v1beta20201101/virtual_network_types_gen.go index 5d4b31b389b..54c32a0f301 100644 --- a/v2/api/network/v1beta20201101/virtual_network_types_gen.go +++ b/v2/api/network/v1beta20201101/virtual_network_types_gen.go @@ -142,11 +142,7 @@ func (network *VirtualNetwork) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (network *VirtualNetwork) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(network.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: network.Spec.Owner.Name, - } + return network.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -204,7 +200,7 @@ func (network *VirtualNetwork) ValidateUpdate(old runtime.Object) (admission.War // createValidations validates the creation of the resource func (network *VirtualNetwork) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){network.validateResourceReferences} + return []func() (admission.Warnings, error){network.validateResourceReferences, network.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -218,7 +214,16 @@ func (network *VirtualNetwork) updateValidations() []func(old runtime.Object) (a func(old runtime.Object) (admission.Warnings, error) { return network.validateResourceReferences() }, - network.validateWriteOnceProperties} + network.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return network.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (network *VirtualNetwork) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(network) } // validateResourceReferences validates all resource references @@ -548,7 +553,10 @@ func (network *VirtualNetwork_Spec) PopulateFromARM(owner genruntime.ArbitraryOw } // Set property "Owner": - network.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + network.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "Tags": if typedInput.Tags != nil { diff --git a/v2/api/network/v1beta20201101/virtual_networks_subnet_types_gen.go b/v2/api/network/v1beta20201101/virtual_networks_subnet_types_gen.go index 5d6d04bbe0c..49763767efc 100644 --- a/v2/api/network/v1beta20201101/virtual_networks_subnet_types_gen.go +++ b/v2/api/network/v1beta20201101/virtual_networks_subnet_types_gen.go @@ -142,11 +142,7 @@ func (subnet *VirtualNetworksSubnet) NewEmptyStatus() genruntime.ConvertibleStat // Owner returns the ResourceReference of the owner func (subnet *VirtualNetworksSubnet) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(subnet.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: subnet.Spec.Owner.Name, - } + return subnet.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -204,7 +200,7 @@ func (subnet *VirtualNetworksSubnet) ValidateUpdate(old runtime.Object) (admissi // createValidations validates the creation of the resource func (subnet *VirtualNetworksSubnet) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){subnet.validateResourceReferences} + return []func() (admission.Warnings, error){subnet.validateResourceReferences, subnet.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -218,7 +214,16 @@ func (subnet *VirtualNetworksSubnet) updateValidations() []func(old runtime.Obje func(old runtime.Object) (admission.Warnings, error) { return subnet.validateResourceReferences() }, - subnet.validateWriteOnceProperties} + subnet.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return subnet.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (subnet *VirtualNetworksSubnet) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(subnet) } // validateResourceReferences validates all resource references @@ -538,7 +543,10 @@ func (subnet *VirtualNetworks_Subnet_Spec) PopulateFromARM(owner genruntime.Arbi } // Set property "Owner": - subnet.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + subnet.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "PrivateEndpointNetworkPolicies": // copying flattened property: diff --git a/v2/api/network/v1beta20201101/virtual_networks_virtual_network_peering_types_gen.go b/v2/api/network/v1beta20201101/virtual_networks_virtual_network_peering_types_gen.go index f1d9b518165..188187a82de 100644 --- a/v2/api/network/v1beta20201101/virtual_networks_virtual_network_peering_types_gen.go +++ b/v2/api/network/v1beta20201101/virtual_networks_virtual_network_peering_types_gen.go @@ -142,11 +142,7 @@ func (peering *VirtualNetworksVirtualNetworkPeering) NewEmptyStatus() genruntime // Owner returns the ResourceReference of the owner func (peering *VirtualNetworksVirtualNetworkPeering) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(peering.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: peering.Spec.Owner.Name, - } + return peering.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -204,7 +200,7 @@ func (peering *VirtualNetworksVirtualNetworkPeering) ValidateUpdate(old runtime. // createValidations validates the creation of the resource func (peering *VirtualNetworksVirtualNetworkPeering) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){peering.validateResourceReferences} + return []func() (admission.Warnings, error){peering.validateResourceReferences, peering.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -218,7 +214,16 @@ func (peering *VirtualNetworksVirtualNetworkPeering) updateValidations() []func( func(old runtime.Object) (admission.Warnings, error) { return peering.validateResourceReferences() }, - peering.validateWriteOnceProperties} + peering.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return peering.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (peering *VirtualNetworksVirtualNetworkPeering) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(peering) } // validateResourceReferences validates all resource references @@ -458,7 +463,10 @@ func (peering *VirtualNetworks_VirtualNetworkPeering_Spec) PopulateFromARM(owner } // Set property "Owner": - peering.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + peering.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "PeeringState": // copying flattened property: diff --git a/v2/api/network/v1beta20201101storage/load_balancer_types_gen.go b/v2/api/network/v1beta20201101storage/load_balancer_types_gen.go index ee923bc23c8..dff5847bbb9 100644 --- a/v2/api/network/v1beta20201101storage/load_balancer_types_gen.go +++ b/v2/api/network/v1beta20201101storage/load_balancer_types_gen.go @@ -105,11 +105,7 @@ func (balancer *LoadBalancer) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (balancer *LoadBalancer) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(balancer.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: balancer.Spec.Owner.Name, - } + return balancer.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/network/v1beta20201101storage/network_interface_types_gen.go b/v2/api/network/v1beta20201101storage/network_interface_types_gen.go index 8a922b833fc..72bb46b72cb 100644 --- a/v2/api/network/v1beta20201101storage/network_interface_types_gen.go +++ b/v2/api/network/v1beta20201101storage/network_interface_types_gen.go @@ -105,11 +105,7 @@ func (networkInterface *NetworkInterface) NewEmptyStatus() genruntime.Convertibl // Owner returns the ResourceReference of the owner func (networkInterface *NetworkInterface) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(networkInterface.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: networkInterface.Spec.Owner.Name, - } + return networkInterface.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/network/v1beta20201101storage/network_security_group_types_gen.go b/v2/api/network/v1beta20201101storage/network_security_group_types_gen.go index 81332373b5f..94adb6bde5f 100644 --- a/v2/api/network/v1beta20201101storage/network_security_group_types_gen.go +++ b/v2/api/network/v1beta20201101storage/network_security_group_types_gen.go @@ -103,11 +103,7 @@ func (group *NetworkSecurityGroup) NewEmptyStatus() genruntime.ConvertibleStatus // Owner returns the ResourceReference of the owner func (group *NetworkSecurityGroup) Owner() *genruntime.ResourceReference { ownerGroup, ownerKind := genruntime.LookupOwnerGroupKind(group.Spec) - return &genruntime.ResourceReference{ - Group: ownerGroup, - Kind: ownerKind, - Name: group.Spec.Owner.Name, - } + return group.Spec.Owner.AsResourceReference(ownerGroup, ownerKind) } // SetStatus sets the status of this resource diff --git a/v2/api/network/v1beta20201101storage/network_security_groups_security_rule_types_gen.go b/v2/api/network/v1beta20201101storage/network_security_groups_security_rule_types_gen.go index b9c8adb7a0b..f75f3acece7 100644 --- a/v2/api/network/v1beta20201101storage/network_security_groups_security_rule_types_gen.go +++ b/v2/api/network/v1beta20201101storage/network_security_groups_security_rule_types_gen.go @@ -103,11 +103,7 @@ func (rule *NetworkSecurityGroupsSecurityRule) NewEmptyStatus() genruntime.Conve // Owner returns the ResourceReference of the owner func (rule *NetworkSecurityGroupsSecurityRule) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(rule.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: rule.Spec.Owner.Name, - } + return rule.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/network/v1beta20201101storage/public_ip_address_types_gen.go b/v2/api/network/v1beta20201101storage/public_ip_address_types_gen.go index d2f6ae60a24..5a81e88ac10 100644 --- a/v2/api/network/v1beta20201101storage/public_ip_address_types_gen.go +++ b/v2/api/network/v1beta20201101storage/public_ip_address_types_gen.go @@ -105,11 +105,7 @@ func (address *PublicIPAddress) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (address *PublicIPAddress) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(address.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: address.Spec.Owner.Name, - } + return address.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/network/v1beta20201101storage/route_table_types_gen.go b/v2/api/network/v1beta20201101storage/route_table_types_gen.go index e491043e0ac..65d7b3fbb35 100644 --- a/v2/api/network/v1beta20201101storage/route_table_types_gen.go +++ b/v2/api/network/v1beta20201101storage/route_table_types_gen.go @@ -103,11 +103,7 @@ func (table *RouteTable) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (table *RouteTable) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(table.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: table.Spec.Owner.Name, - } + return table.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/network/v1beta20201101storage/route_tables_route_types_gen.go b/v2/api/network/v1beta20201101storage/route_tables_route_types_gen.go index 85a60f39c7a..8e2ef361b4b 100644 --- a/v2/api/network/v1beta20201101storage/route_tables_route_types_gen.go +++ b/v2/api/network/v1beta20201101storage/route_tables_route_types_gen.go @@ -103,11 +103,7 @@ func (route *RouteTablesRoute) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (route *RouteTablesRoute) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(route.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: route.Spec.Owner.Name, - } + return route.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/network/v1beta20201101storage/virtual_network_gateway_types_gen.go b/v2/api/network/v1beta20201101storage/virtual_network_gateway_types_gen.go index 4df58173bb2..3e40681cb92 100644 --- a/v2/api/network/v1beta20201101storage/virtual_network_gateway_types_gen.go +++ b/v2/api/network/v1beta20201101storage/virtual_network_gateway_types_gen.go @@ -105,11 +105,7 @@ func (gateway *VirtualNetworkGateway) NewEmptyStatus() genruntime.ConvertibleSta // Owner returns the ResourceReference of the owner func (gateway *VirtualNetworkGateway) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(gateway.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: gateway.Spec.Owner.Name, - } + return gateway.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/network/v1beta20201101storage/virtual_network_types_gen.go b/v2/api/network/v1beta20201101storage/virtual_network_types_gen.go index d3cb1a479f9..46fb4f57a05 100644 --- a/v2/api/network/v1beta20201101storage/virtual_network_types_gen.go +++ b/v2/api/network/v1beta20201101storage/virtual_network_types_gen.go @@ -105,11 +105,7 @@ func (network *VirtualNetwork) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (network *VirtualNetwork) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(network.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: network.Spec.Owner.Name, - } + return network.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/network/v1beta20201101storage/virtual_networks_subnet_types_gen.go b/v2/api/network/v1beta20201101storage/virtual_networks_subnet_types_gen.go index 6e83d288f5b..ff2c6664f20 100644 --- a/v2/api/network/v1beta20201101storage/virtual_networks_subnet_types_gen.go +++ b/v2/api/network/v1beta20201101storage/virtual_networks_subnet_types_gen.go @@ -105,11 +105,7 @@ func (subnet *VirtualNetworksSubnet) NewEmptyStatus() genruntime.ConvertibleStat // Owner returns the ResourceReference of the owner func (subnet *VirtualNetworksSubnet) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(subnet.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: subnet.Spec.Owner.Name, - } + return subnet.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/network/v1beta20201101storage/virtual_networks_virtual_network_peering_types_gen.go b/v2/api/network/v1beta20201101storage/virtual_networks_virtual_network_peering_types_gen.go index 8bfd9fa4b25..5fe8bd1d926 100644 --- a/v2/api/network/v1beta20201101storage/virtual_networks_virtual_network_peering_types_gen.go +++ b/v2/api/network/v1beta20201101storage/virtual_networks_virtual_network_peering_types_gen.go @@ -105,11 +105,7 @@ func (peering *VirtualNetworksVirtualNetworkPeering) NewEmptyStatus() genruntime // Owner returns the ResourceReference of the owner func (peering *VirtualNetworksVirtualNetworkPeering) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(peering.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: peering.Spec.Owner.Name, - } + return peering.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/operationalinsights/v1api20210601/workspace_types_gen.go b/v2/api/operationalinsights/v1api20210601/workspace_types_gen.go index 5f8b277739e..feb8b6d31f7 100644 --- a/v2/api/operationalinsights/v1api20210601/workspace_types_gen.go +++ b/v2/api/operationalinsights/v1api20210601/workspace_types_gen.go @@ -141,11 +141,7 @@ func (workspace *Workspace) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (workspace *Workspace) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(workspace.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: workspace.Spec.Owner.Name, - } + return workspace.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -203,7 +199,7 @@ func (workspace *Workspace) ValidateUpdate(old runtime.Object) (admission.Warnin // createValidations validates the creation of the resource func (workspace *Workspace) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){workspace.validateResourceReferences} + return []func() (admission.Warnings, error){workspace.validateResourceReferences, workspace.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -217,7 +213,16 @@ func (workspace *Workspace) updateValidations() []func(old runtime.Object) (admi func(old runtime.Object) (admission.Warnings, error) { return workspace.validateResourceReferences() }, - workspace.validateWriteOnceProperties} + workspace.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return workspace.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (workspace *Workspace) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(workspace) } // validateResourceReferences validates all resource references @@ -506,7 +511,10 @@ func (workspace *Workspace_Spec) PopulateFromARM(owner genruntime.ArbitraryOwner } // Set property "Owner": - workspace.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + workspace.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "ProvisioningState": // copying flattened property: diff --git a/v2/api/operationalinsights/v1api20210601storage/workspace_types_gen.go b/v2/api/operationalinsights/v1api20210601storage/workspace_types_gen.go index 92c53a19680..2d4eb794667 100644 --- a/v2/api/operationalinsights/v1api20210601storage/workspace_types_gen.go +++ b/v2/api/operationalinsights/v1api20210601storage/workspace_types_gen.go @@ -84,11 +84,7 @@ func (workspace *Workspace) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (workspace *Workspace) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(workspace.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: workspace.Spec.Owner.Name, - } + return workspace.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/operationalinsights/v1beta20210601/workspace_types_gen.go b/v2/api/operationalinsights/v1beta20210601/workspace_types_gen.go index 0e4e5c95e16..a9d431748ce 100644 --- a/v2/api/operationalinsights/v1beta20210601/workspace_types_gen.go +++ b/v2/api/operationalinsights/v1beta20210601/workspace_types_gen.go @@ -142,11 +142,7 @@ func (workspace *Workspace) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (workspace *Workspace) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(workspace.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: workspace.Spec.Owner.Name, - } + return workspace.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -204,7 +200,7 @@ func (workspace *Workspace) ValidateUpdate(old runtime.Object) (admission.Warnin // createValidations validates the creation of the resource func (workspace *Workspace) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){workspace.validateResourceReferences} + return []func() (admission.Warnings, error){workspace.validateResourceReferences, workspace.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -218,7 +214,16 @@ func (workspace *Workspace) updateValidations() []func(old runtime.Object) (admi func(old runtime.Object) (admission.Warnings, error) { return workspace.validateResourceReferences() }, - workspace.validateWriteOnceProperties} + workspace.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return workspace.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (workspace *Workspace) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(workspace) } // validateResourceReferences validates all resource references @@ -484,7 +489,10 @@ func (workspace *Workspace_Spec) PopulateFromARM(owner genruntime.ArbitraryOwner } // Set property "Owner": - workspace.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + workspace.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "ProvisioningState": // copying flattened property: diff --git a/v2/api/operationalinsights/v1beta20210601storage/workspace_types_gen.go b/v2/api/operationalinsights/v1beta20210601storage/workspace_types_gen.go index 467213aa9a2..47c81b79189 100644 --- a/v2/api/operationalinsights/v1beta20210601storage/workspace_types_gen.go +++ b/v2/api/operationalinsights/v1beta20210601storage/workspace_types_gen.go @@ -103,11 +103,7 @@ func (workspace *Workspace) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (workspace *Workspace) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(workspace.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: workspace.Spec.Owner.Name, - } + return workspace.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/search/v1api20220901/search_service_types_gen.go b/v2/api/search/v1api20220901/search_service_types_gen.go index e424a17e0cd..b9ac5c9755e 100644 --- a/v2/api/search/v1api20220901/search_service_types_gen.go +++ b/v2/api/search/v1api20220901/search_service_types_gen.go @@ -142,11 +142,7 @@ func (service *SearchService) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (service *SearchService) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(service.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: service.Spec.Owner.Name, - } + return service.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -204,7 +200,7 @@ func (service *SearchService) ValidateUpdate(old runtime.Object) (admission.Warn // createValidations validates the creation of the resource func (service *SearchService) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){service.validateResourceReferences, service.validateSecretDestinations} + return []func() (admission.Warnings, error){service.validateResourceReferences, service.validateOwnerReference, service.validateSecretDestinations} } // deleteValidations validates the deletion of the resource @@ -219,12 +215,20 @@ func (service *SearchService) updateValidations() []func(old runtime.Object) (ad return service.validateResourceReferences() }, service.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return service.validateOwnerReference() + }, func(old runtime.Object) (admission.Warnings, error) { return service.validateSecretDestinations() }, } } +// validateOwnerReference validates the owner field +func (service *SearchService) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(service) +} + // validateResourceReferences validates all resource references func (service *SearchService) validateResourceReferences() (admission.Warnings, error) { refs, err := reflecthelpers.FindResourceReferences(&service.Spec) @@ -603,7 +607,10 @@ func (service *SearchService_Spec) PopulateFromARM(owner genruntime.ArbitraryOwn // no assignment for property "OperatorSpec" // Set property "Owner": - service.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + service.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "PartitionCount": // copying flattened property: diff --git a/v2/api/search/v1api20220901storage/search_service_types_gen.go b/v2/api/search/v1api20220901storage/search_service_types_gen.go index 90bfd9bffb4..620ac98c16d 100644 --- a/v2/api/search/v1api20220901storage/search_service_types_gen.go +++ b/v2/api/search/v1api20220901storage/search_service_types_gen.go @@ -85,11 +85,7 @@ func (service *SearchService) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (service *SearchService) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(service.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: service.Spec.Owner.Name, - } + return service.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/servicebus/v1api20210101preview/namespace_types_gen.go b/v2/api/servicebus/v1api20210101preview/namespace_types_gen.go index 9cf9ab713da..46c534aad5d 100644 --- a/v2/api/servicebus/v1api20210101preview/namespace_types_gen.go +++ b/v2/api/servicebus/v1api20210101preview/namespace_types_gen.go @@ -141,11 +141,7 @@ func (namespace *Namespace) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (namespace *Namespace) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(namespace.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: namespace.Spec.Owner.Name, - } + return namespace.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -203,7 +199,7 @@ func (namespace *Namespace) ValidateUpdate(old runtime.Object) (admission.Warnin // createValidations validates the creation of the resource func (namespace *Namespace) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){namespace.validateResourceReferences, namespace.validateSecretDestinations} + return []func() (admission.Warnings, error){namespace.validateResourceReferences, namespace.validateOwnerReference, namespace.validateSecretDestinations} } // deleteValidations validates the deletion of the resource @@ -218,12 +214,20 @@ func (namespace *Namespace) updateValidations() []func(old runtime.Object) (admi return namespace.validateResourceReferences() }, namespace.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return namespace.validateOwnerReference() + }, func(old runtime.Object) (admission.Warnings, error) { return namespace.validateSecretDestinations() }, } } +// validateOwnerReference validates the owner field +func (namespace *Namespace) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(namespace) +} + // validateResourceReferences validates all resource references func (namespace *Namespace) validateResourceReferences() (admission.Warnings, error) { refs, err := reflecthelpers.FindResourceReferences(&namespace.Spec) @@ -486,7 +490,10 @@ func (namespace *Namespace_Spec) PopulateFromARM(owner genruntime.ArbitraryOwner // no assignment for property "OperatorSpec" // Set property "Owner": - namespace.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + namespace.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "Sku": if typedInput.Sku != nil { diff --git a/v2/api/servicebus/v1api20210101preview/namespaces_authorization_rule_types_gen.go b/v2/api/servicebus/v1api20210101preview/namespaces_authorization_rule_types_gen.go index 63d5c23e448..5284f5da88f 100644 --- a/v2/api/servicebus/v1api20210101preview/namespaces_authorization_rule_types_gen.go +++ b/v2/api/servicebus/v1api20210101preview/namespaces_authorization_rule_types_gen.go @@ -141,11 +141,7 @@ func (rule *NamespacesAuthorizationRule) NewEmptyStatus() genruntime.Convertible // Owner returns the ResourceReference of the owner func (rule *NamespacesAuthorizationRule) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(rule.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: rule.Spec.Owner.Name, - } + return rule.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -203,7 +199,7 @@ func (rule *NamespacesAuthorizationRule) ValidateUpdate(old runtime.Object) (adm // createValidations validates the creation of the resource func (rule *NamespacesAuthorizationRule) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){rule.validateResourceReferences, rule.validateSecretDestinations} + return []func() (admission.Warnings, error){rule.validateResourceReferences, rule.validateOwnerReference, rule.validateSecretDestinations} } // deleteValidations validates the deletion of the resource @@ -218,12 +214,20 @@ func (rule *NamespacesAuthorizationRule) updateValidations() []func(old runtime. return rule.validateResourceReferences() }, rule.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return rule.validateOwnerReference() + }, func(old runtime.Object) (admission.Warnings, error) { return rule.validateSecretDestinations() }, } } +// validateOwnerReference validates the owner field +func (rule *NamespacesAuthorizationRule) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(rule) +} + // validateResourceReferences validates all resource references func (rule *NamespacesAuthorizationRule) validateResourceReferences() (admission.Warnings, error) { refs, err := reflecthelpers.FindResourceReferences(&rule.Spec) @@ -393,7 +397,10 @@ func (rule *Namespaces_AuthorizationRule_Spec) PopulateFromARM(owner genruntime. // no assignment for property "OperatorSpec" // Set property "Owner": - rule.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + rule.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "Rights": // copying flattened property: diff --git a/v2/api/servicebus/v1api20210101preview/namespaces_queue_types_gen.go b/v2/api/servicebus/v1api20210101preview/namespaces_queue_types_gen.go index 920ebd69662..20901569bb5 100644 --- a/v2/api/servicebus/v1api20210101preview/namespaces_queue_types_gen.go +++ b/v2/api/servicebus/v1api20210101preview/namespaces_queue_types_gen.go @@ -141,11 +141,7 @@ func (queue *NamespacesQueue) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (queue *NamespacesQueue) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(queue.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: queue.Spec.Owner.Name, - } + return queue.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -203,7 +199,7 @@ func (queue *NamespacesQueue) ValidateUpdate(old runtime.Object) (admission.Warn // createValidations validates the creation of the resource func (queue *NamespacesQueue) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){queue.validateResourceReferences} + return []func() (admission.Warnings, error){queue.validateResourceReferences, queue.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -217,7 +213,16 @@ func (queue *NamespacesQueue) updateValidations() []func(old runtime.Object) (ad func(old runtime.Object) (admission.Warnings, error) { return queue.validateResourceReferences() }, - queue.validateWriteOnceProperties} + queue.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return queue.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (queue *NamespacesQueue) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(queue) } // validateResourceReferences validates all resource references @@ -586,7 +591,10 @@ func (queue *Namespaces_Queue_Spec) PopulateFromARM(owner genruntime.ArbitraryOw } // Set property "Owner": - queue.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + queue.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "RequiresDuplicateDetection": // copying flattened property: diff --git a/v2/api/servicebus/v1api20210101preview/namespaces_topic_types_gen.go b/v2/api/servicebus/v1api20210101preview/namespaces_topic_types_gen.go index f3600b477f8..bbfac1dd7bd 100644 --- a/v2/api/servicebus/v1api20210101preview/namespaces_topic_types_gen.go +++ b/v2/api/servicebus/v1api20210101preview/namespaces_topic_types_gen.go @@ -141,11 +141,7 @@ func (topic *NamespacesTopic) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (topic *NamespacesTopic) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(topic.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: topic.Spec.Owner.Name, - } + return topic.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -203,7 +199,7 @@ func (topic *NamespacesTopic) ValidateUpdate(old runtime.Object) (admission.Warn // createValidations validates the creation of the resource func (topic *NamespacesTopic) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){topic.validateResourceReferences} + return []func() (admission.Warnings, error){topic.validateResourceReferences, topic.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -217,7 +213,16 @@ func (topic *NamespacesTopic) updateValidations() []func(old runtime.Object) (ad func(old runtime.Object) (admission.Warnings, error) { return topic.validateResourceReferences() }, - topic.validateWriteOnceProperties} + topic.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return topic.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (topic *NamespacesTopic) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(topic) } // validateResourceReferences validates all resource references @@ -498,7 +503,10 @@ func (topic *Namespaces_Topic_Spec) PopulateFromARM(owner genruntime.ArbitraryOw } // Set property "Owner": - topic.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + topic.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "RequiresDuplicateDetection": // copying flattened property: diff --git a/v2/api/servicebus/v1api20210101preview/namespaces_topics_subscription_types_gen.go b/v2/api/servicebus/v1api20210101preview/namespaces_topics_subscription_types_gen.go index 69dd9b9b6b6..e10312f870c 100644 --- a/v2/api/servicebus/v1api20210101preview/namespaces_topics_subscription_types_gen.go +++ b/v2/api/servicebus/v1api20210101preview/namespaces_topics_subscription_types_gen.go @@ -141,11 +141,7 @@ func (subscription *NamespacesTopicsSubscription) NewEmptyStatus() genruntime.Co // Owner returns the ResourceReference of the owner func (subscription *NamespacesTopicsSubscription) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(subscription.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: subscription.Spec.Owner.Name, - } + return subscription.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -203,7 +199,7 @@ func (subscription *NamespacesTopicsSubscription) ValidateUpdate(old runtime.Obj // createValidations validates the creation of the resource func (subscription *NamespacesTopicsSubscription) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){subscription.validateResourceReferences} + return []func() (admission.Warnings, error){subscription.validateResourceReferences, subscription.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -217,7 +213,16 @@ func (subscription *NamespacesTopicsSubscription) updateValidations() []func(old func(old runtime.Object) (admission.Warnings, error) { return subscription.validateResourceReferences() }, - subscription.validateWriteOnceProperties} + subscription.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return subscription.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (subscription *NamespacesTopicsSubscription) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(subscription) } // validateResourceReferences validates all resource references @@ -542,7 +547,10 @@ func (subscription *Namespaces_Topics_Subscription_Spec) PopulateFromARM(owner g } // Set property "Owner": - subscription.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + subscription.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "RequiresSession": // copying flattened property: diff --git a/v2/api/servicebus/v1api20210101preview/namespaces_topics_subscriptions_rule_types_gen.go b/v2/api/servicebus/v1api20210101preview/namespaces_topics_subscriptions_rule_types_gen.go index 6c34935b0d5..a05534ea52e 100644 --- a/v2/api/servicebus/v1api20210101preview/namespaces_topics_subscriptions_rule_types_gen.go +++ b/v2/api/servicebus/v1api20210101preview/namespaces_topics_subscriptions_rule_types_gen.go @@ -141,11 +141,7 @@ func (rule *NamespacesTopicsSubscriptionsRule) NewEmptyStatus() genruntime.Conve // Owner returns the ResourceReference of the owner func (rule *NamespacesTopicsSubscriptionsRule) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(rule.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: rule.Spec.Owner.Name, - } + return rule.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -203,7 +199,7 @@ func (rule *NamespacesTopicsSubscriptionsRule) ValidateUpdate(old runtime.Object // createValidations validates the creation of the resource func (rule *NamespacesTopicsSubscriptionsRule) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){rule.validateResourceReferences} + return []func() (admission.Warnings, error){rule.validateResourceReferences, rule.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -217,7 +213,16 @@ func (rule *NamespacesTopicsSubscriptionsRule) updateValidations() []func(old ru func(old runtime.Object) (admission.Warnings, error) { return rule.validateResourceReferences() }, - rule.validateWriteOnceProperties} + rule.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return rule.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (rule *NamespacesTopicsSubscriptionsRule) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(rule) } // validateResourceReferences validates all resource references @@ -440,7 +445,10 @@ func (rule *Namespaces_Topics_Subscriptions_Rule_Spec) PopulateFromARM(owner gen } // Set property "Owner": - rule.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + rule.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "SqlFilter": // copying flattened property: diff --git a/v2/api/servicebus/v1api20210101previewstorage/namespace_types_gen.go b/v2/api/servicebus/v1api20210101previewstorage/namespace_types_gen.go index 6c333a8ae9b..435df95bf62 100644 --- a/v2/api/servicebus/v1api20210101previewstorage/namespace_types_gen.go +++ b/v2/api/servicebus/v1api20210101previewstorage/namespace_types_gen.go @@ -84,11 +84,7 @@ func (namespace *Namespace) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (namespace *Namespace) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(namespace.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: namespace.Spec.Owner.Name, - } + return namespace.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/servicebus/v1api20210101previewstorage/namespaces_authorization_rule_types_gen.go b/v2/api/servicebus/v1api20210101previewstorage/namespaces_authorization_rule_types_gen.go index 37c184e5ae1..0965cedd018 100644 --- a/v2/api/servicebus/v1api20210101previewstorage/namespaces_authorization_rule_types_gen.go +++ b/v2/api/servicebus/v1api20210101previewstorage/namespaces_authorization_rule_types_gen.go @@ -84,11 +84,7 @@ func (rule *NamespacesAuthorizationRule) NewEmptyStatus() genruntime.Convertible // Owner returns the ResourceReference of the owner func (rule *NamespacesAuthorizationRule) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(rule.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: rule.Spec.Owner.Name, - } + return rule.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/servicebus/v1api20210101previewstorage/namespaces_queue_types_gen.go b/v2/api/servicebus/v1api20210101previewstorage/namespaces_queue_types_gen.go index 06d40a27be4..2918df40266 100644 --- a/v2/api/servicebus/v1api20210101previewstorage/namespaces_queue_types_gen.go +++ b/v2/api/servicebus/v1api20210101previewstorage/namespaces_queue_types_gen.go @@ -84,11 +84,7 @@ func (queue *NamespacesQueue) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (queue *NamespacesQueue) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(queue.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: queue.Spec.Owner.Name, - } + return queue.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/servicebus/v1api20210101previewstorage/namespaces_topic_types_gen.go b/v2/api/servicebus/v1api20210101previewstorage/namespaces_topic_types_gen.go index a0882808d16..09b5083e57a 100644 --- a/v2/api/servicebus/v1api20210101previewstorage/namespaces_topic_types_gen.go +++ b/v2/api/servicebus/v1api20210101previewstorage/namespaces_topic_types_gen.go @@ -84,11 +84,7 @@ func (topic *NamespacesTopic) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (topic *NamespacesTopic) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(topic.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: topic.Spec.Owner.Name, - } + return topic.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/servicebus/v1api20210101previewstorage/namespaces_topics_subscription_types_gen.go b/v2/api/servicebus/v1api20210101previewstorage/namespaces_topics_subscription_types_gen.go index 6348ea008a8..7004b0a808d 100644 --- a/v2/api/servicebus/v1api20210101previewstorage/namespaces_topics_subscription_types_gen.go +++ b/v2/api/servicebus/v1api20210101previewstorage/namespaces_topics_subscription_types_gen.go @@ -84,11 +84,7 @@ func (subscription *NamespacesTopicsSubscription) NewEmptyStatus() genruntime.Co // Owner returns the ResourceReference of the owner func (subscription *NamespacesTopicsSubscription) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(subscription.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: subscription.Spec.Owner.Name, - } + return subscription.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/servicebus/v1api20210101previewstorage/namespaces_topics_subscriptions_rule_types_gen.go b/v2/api/servicebus/v1api20210101previewstorage/namespaces_topics_subscriptions_rule_types_gen.go index 27ee9f472ee..02fb22a99b9 100644 --- a/v2/api/servicebus/v1api20210101previewstorage/namespaces_topics_subscriptions_rule_types_gen.go +++ b/v2/api/servicebus/v1api20210101previewstorage/namespaces_topics_subscriptions_rule_types_gen.go @@ -84,11 +84,7 @@ func (rule *NamespacesTopicsSubscriptionsRule) NewEmptyStatus() genruntime.Conve // Owner returns the ResourceReference of the owner func (rule *NamespacesTopicsSubscriptionsRule) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(rule.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: rule.Spec.Owner.Name, - } + return rule.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/servicebus/v1beta20210101preview/namespace_types_gen.go b/v2/api/servicebus/v1beta20210101preview/namespace_types_gen.go index 3cafb88019c..f0a06470247 100644 --- a/v2/api/servicebus/v1beta20210101preview/namespace_types_gen.go +++ b/v2/api/servicebus/v1beta20210101preview/namespace_types_gen.go @@ -142,11 +142,7 @@ func (namespace *Namespace) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (namespace *Namespace) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(namespace.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: namespace.Spec.Owner.Name, - } + return namespace.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -204,7 +200,7 @@ func (namespace *Namespace) ValidateUpdate(old runtime.Object) (admission.Warnin // createValidations validates the creation of the resource func (namespace *Namespace) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){namespace.validateResourceReferences, namespace.validateSecretDestinations} + return []func() (admission.Warnings, error){namespace.validateResourceReferences, namespace.validateOwnerReference, namespace.validateSecretDestinations} } // deleteValidations validates the deletion of the resource @@ -219,12 +215,20 @@ func (namespace *Namespace) updateValidations() []func(old runtime.Object) (admi return namespace.validateResourceReferences() }, namespace.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return namespace.validateOwnerReference() + }, func(old runtime.Object) (admission.Warnings, error) { return namespace.validateSecretDestinations() }, } } +// validateOwnerReference validates the owner field +func (namespace *Namespace) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(namespace) +} + // validateResourceReferences validates all resource references func (namespace *Namespace) validateResourceReferences() (admission.Warnings, error) { refs, err := reflecthelpers.FindResourceReferences(&namespace.Spec) @@ -475,7 +479,10 @@ func (namespace *Namespace_Spec) PopulateFromARM(owner genruntime.ArbitraryOwner // no assignment for property "OperatorSpec" // Set property "Owner": - namespace.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + namespace.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "Sku": if typedInput.Sku != nil { diff --git a/v2/api/servicebus/v1beta20210101preview/namespaces_queue_types_gen.go b/v2/api/servicebus/v1beta20210101preview/namespaces_queue_types_gen.go index d59054eaeff..a9656811533 100644 --- a/v2/api/servicebus/v1beta20210101preview/namespaces_queue_types_gen.go +++ b/v2/api/servicebus/v1beta20210101preview/namespaces_queue_types_gen.go @@ -142,11 +142,7 @@ func (queue *NamespacesQueue) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (queue *NamespacesQueue) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(queue.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: queue.Spec.Owner.Name, - } + return queue.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -204,7 +200,7 @@ func (queue *NamespacesQueue) ValidateUpdate(old runtime.Object) (admission.Warn // createValidations validates the creation of the resource func (queue *NamespacesQueue) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){queue.validateResourceReferences} + return []func() (admission.Warnings, error){queue.validateResourceReferences, queue.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -218,7 +214,16 @@ func (queue *NamespacesQueue) updateValidations() []func(old runtime.Object) (ad func(old runtime.Object) (admission.Warnings, error) { return queue.validateResourceReferences() }, - queue.validateWriteOnceProperties} + queue.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return queue.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (queue *NamespacesQueue) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(queue) } // validateResourceReferences validates all resource references @@ -549,7 +554,10 @@ func (queue *Namespaces_Queue_Spec) PopulateFromARM(owner genruntime.ArbitraryOw } // Set property "Owner": - queue.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + queue.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "RequiresDuplicateDetection": // copying flattened property: diff --git a/v2/api/servicebus/v1beta20210101preview/namespaces_topic_types_gen.go b/v2/api/servicebus/v1beta20210101preview/namespaces_topic_types_gen.go index f61f79ac0b6..b8f14eb78da 100644 --- a/v2/api/servicebus/v1beta20210101preview/namespaces_topic_types_gen.go +++ b/v2/api/servicebus/v1beta20210101preview/namespaces_topic_types_gen.go @@ -142,11 +142,7 @@ func (topic *NamespacesTopic) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (topic *NamespacesTopic) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(topic.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: topic.Spec.Owner.Name, - } + return topic.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -204,7 +200,7 @@ func (topic *NamespacesTopic) ValidateUpdate(old runtime.Object) (admission.Warn // createValidations validates the creation of the resource func (topic *NamespacesTopic) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){topic.validateResourceReferences} + return []func() (admission.Warnings, error){topic.validateResourceReferences, topic.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -218,7 +214,16 @@ func (topic *NamespacesTopic) updateValidations() []func(old runtime.Object) (ad func(old runtime.Object) (admission.Warnings, error) { return topic.validateResourceReferences() }, - topic.validateWriteOnceProperties} + topic.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return topic.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (topic *NamespacesTopic) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(topic) } // validateResourceReferences validates all resource references @@ -474,7 +479,10 @@ func (topic *Namespaces_Topic_Spec) PopulateFromARM(owner genruntime.ArbitraryOw } // Set property "Owner": - topic.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + topic.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "RequiresDuplicateDetection": // copying flattened property: diff --git a/v2/api/servicebus/v1beta20210101preview/namespaces_topics_subscription_types_gen.go b/v2/api/servicebus/v1beta20210101preview/namespaces_topics_subscription_types_gen.go index b318744ab75..cb5e31360dc 100644 --- a/v2/api/servicebus/v1beta20210101preview/namespaces_topics_subscription_types_gen.go +++ b/v2/api/servicebus/v1beta20210101preview/namespaces_topics_subscription_types_gen.go @@ -142,11 +142,7 @@ func (subscription *NamespacesTopicsSubscription) NewEmptyStatus() genruntime.Co // Owner returns the ResourceReference of the owner func (subscription *NamespacesTopicsSubscription) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(subscription.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: subscription.Spec.Owner.Name, - } + return subscription.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -204,7 +200,7 @@ func (subscription *NamespacesTopicsSubscription) ValidateUpdate(old runtime.Obj // createValidations validates the creation of the resource func (subscription *NamespacesTopicsSubscription) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){subscription.validateResourceReferences} + return []func() (admission.Warnings, error){subscription.validateResourceReferences, subscription.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -218,7 +214,16 @@ func (subscription *NamespacesTopicsSubscription) updateValidations() []func(old func(old runtime.Object) (admission.Warnings, error) { return subscription.validateResourceReferences() }, - subscription.validateWriteOnceProperties} + subscription.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return subscription.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (subscription *NamespacesTopicsSubscription) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(subscription) } // validateResourceReferences validates all resource references @@ -514,7 +519,10 @@ func (subscription *Namespaces_Topics_Subscription_Spec) PopulateFromARM(owner g } // Set property "Owner": - subscription.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + subscription.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "RequiresSession": // copying flattened property: diff --git a/v2/api/servicebus/v1beta20210101preview/namespaces_topics_subscriptions_rule_types_gen.go b/v2/api/servicebus/v1beta20210101preview/namespaces_topics_subscriptions_rule_types_gen.go index 2c2cf5dba2d..eb739c9c97d 100644 --- a/v2/api/servicebus/v1beta20210101preview/namespaces_topics_subscriptions_rule_types_gen.go +++ b/v2/api/servicebus/v1beta20210101preview/namespaces_topics_subscriptions_rule_types_gen.go @@ -142,11 +142,7 @@ func (rule *NamespacesTopicsSubscriptionsRule) NewEmptyStatus() genruntime.Conve // Owner returns the ResourceReference of the owner func (rule *NamespacesTopicsSubscriptionsRule) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(rule.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: rule.Spec.Owner.Name, - } + return rule.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -204,7 +200,7 @@ func (rule *NamespacesTopicsSubscriptionsRule) ValidateUpdate(old runtime.Object // createValidations validates the creation of the resource func (rule *NamespacesTopicsSubscriptionsRule) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){rule.validateResourceReferences} + return []func() (admission.Warnings, error){rule.validateResourceReferences, rule.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -218,7 +214,16 @@ func (rule *NamespacesTopicsSubscriptionsRule) updateValidations() []func(old ru func(old runtime.Object) (admission.Warnings, error) { return rule.validateResourceReferences() }, - rule.validateWriteOnceProperties} + rule.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return rule.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (rule *NamespacesTopicsSubscriptionsRule) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(rule) } // validateResourceReferences validates all resource references @@ -431,7 +436,10 @@ func (rule *Namespaces_Topics_Subscriptions_Rule_Spec) PopulateFromARM(owner gen } // Set property "Owner": - rule.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + rule.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "SqlFilter": // copying flattened property: diff --git a/v2/api/servicebus/v1beta20210101previewstorage/namespace_types_gen.go b/v2/api/servicebus/v1beta20210101previewstorage/namespace_types_gen.go index 37c947b7461..da2eca84f4c 100644 --- a/v2/api/servicebus/v1beta20210101previewstorage/namespace_types_gen.go +++ b/v2/api/servicebus/v1beta20210101previewstorage/namespace_types_gen.go @@ -103,11 +103,7 @@ func (namespace *Namespace) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (namespace *Namespace) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(namespace.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: namespace.Spec.Owner.Name, - } + return namespace.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/servicebus/v1beta20210101previewstorage/namespaces_queue_types_gen.go b/v2/api/servicebus/v1beta20210101previewstorage/namespaces_queue_types_gen.go index 6814e301001..df59123d6dc 100644 --- a/v2/api/servicebus/v1beta20210101previewstorage/namespaces_queue_types_gen.go +++ b/v2/api/servicebus/v1beta20210101previewstorage/namespaces_queue_types_gen.go @@ -103,11 +103,7 @@ func (queue *NamespacesQueue) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (queue *NamespacesQueue) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(queue.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: queue.Spec.Owner.Name, - } + return queue.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/servicebus/v1beta20210101previewstorage/namespaces_topic_types_gen.go b/v2/api/servicebus/v1beta20210101previewstorage/namespaces_topic_types_gen.go index 7dcb42f8e73..e9c4bc2ca92 100644 --- a/v2/api/servicebus/v1beta20210101previewstorage/namespaces_topic_types_gen.go +++ b/v2/api/servicebus/v1beta20210101previewstorage/namespaces_topic_types_gen.go @@ -103,11 +103,7 @@ func (topic *NamespacesTopic) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (topic *NamespacesTopic) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(topic.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: topic.Spec.Owner.Name, - } + return topic.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/servicebus/v1beta20210101previewstorage/namespaces_topics_subscription_types_gen.go b/v2/api/servicebus/v1beta20210101previewstorage/namespaces_topics_subscription_types_gen.go index 2ab46dc522b..2e006007bba 100644 --- a/v2/api/servicebus/v1beta20210101previewstorage/namespaces_topics_subscription_types_gen.go +++ b/v2/api/servicebus/v1beta20210101previewstorage/namespaces_topics_subscription_types_gen.go @@ -103,11 +103,7 @@ func (subscription *NamespacesTopicsSubscription) NewEmptyStatus() genruntime.Co // Owner returns the ResourceReference of the owner func (subscription *NamespacesTopicsSubscription) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(subscription.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: subscription.Spec.Owner.Name, - } + return subscription.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/servicebus/v1beta20210101previewstorage/namespaces_topics_subscriptions_rule_types_gen.go b/v2/api/servicebus/v1beta20210101previewstorage/namespaces_topics_subscriptions_rule_types_gen.go index 23a39ee00a1..c07a356bfda 100644 --- a/v2/api/servicebus/v1beta20210101previewstorage/namespaces_topics_subscriptions_rule_types_gen.go +++ b/v2/api/servicebus/v1beta20210101previewstorage/namespaces_topics_subscriptions_rule_types_gen.go @@ -103,11 +103,7 @@ func (rule *NamespacesTopicsSubscriptionsRule) NewEmptyStatus() genruntime.Conve // Owner returns the ResourceReference of the owner func (rule *NamespacesTopicsSubscriptionsRule) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(rule.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: rule.Spec.Owner.Name, - } + return rule.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/signalrservice/v1api20211001/signal_r_types_gen.go b/v2/api/signalrservice/v1api20211001/signal_r_types_gen.go index 5708063f2e9..407cbcbe0d5 100644 --- a/v2/api/signalrservice/v1api20211001/signal_r_types_gen.go +++ b/v2/api/signalrservice/v1api20211001/signal_r_types_gen.go @@ -141,11 +141,7 @@ func (signalR *SignalR) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (signalR *SignalR) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(signalR.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: signalR.Spec.Owner.Name, - } + return signalR.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -203,7 +199,7 @@ func (signalR *SignalR) ValidateUpdate(old runtime.Object) (admission.Warnings, // createValidations validates the creation of the resource func (signalR *SignalR) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){signalR.validateResourceReferences} + return []func() (admission.Warnings, error){signalR.validateResourceReferences, signalR.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -217,7 +213,16 @@ func (signalR *SignalR) updateValidations() []func(old runtime.Object) (admissio func(old runtime.Object) (admission.Warnings, error) { return signalR.validateResourceReferences() }, - signalR.validateWriteOnceProperties} + signalR.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return signalR.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (signalR *SignalR) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(signalR) } // validateResourceReferences validates all resource references @@ -603,7 +608,10 @@ func (signalR *SignalR_Spec) PopulateFromARM(owner genruntime.ArbitraryOwnerRefe } // Set property "Owner": - signalR.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + signalR.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "PublicNetworkAccess": // copying flattened property: diff --git a/v2/api/signalrservice/v1api20211001storage/signal_r_types_gen.go b/v2/api/signalrservice/v1api20211001storage/signal_r_types_gen.go index 3cd3c3ee3c4..bb7102ba62d 100644 --- a/v2/api/signalrservice/v1api20211001storage/signal_r_types_gen.go +++ b/v2/api/signalrservice/v1api20211001storage/signal_r_types_gen.go @@ -84,11 +84,7 @@ func (signalR *SignalR) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (signalR *SignalR) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(signalR.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: signalR.Spec.Owner.Name, - } + return signalR.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/signalrservice/v1beta20211001/signal_r_types_gen.go b/v2/api/signalrservice/v1beta20211001/signal_r_types_gen.go index 66cb288002f..2c2fed3b822 100644 --- a/v2/api/signalrservice/v1beta20211001/signal_r_types_gen.go +++ b/v2/api/signalrservice/v1beta20211001/signal_r_types_gen.go @@ -142,11 +142,7 @@ func (signalR *SignalR) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (signalR *SignalR) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(signalR.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: signalR.Spec.Owner.Name, - } + return signalR.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -204,7 +200,7 @@ func (signalR *SignalR) ValidateUpdate(old runtime.Object) (admission.Warnings, // createValidations validates the creation of the resource func (signalR *SignalR) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){signalR.validateResourceReferences} + return []func() (admission.Warnings, error){signalR.validateResourceReferences, signalR.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -218,7 +214,16 @@ func (signalR *SignalR) updateValidations() []func(old runtime.Object) (admissio func(old runtime.Object) (admission.Warnings, error) { return signalR.validateResourceReferences() }, - signalR.validateWriteOnceProperties} + signalR.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return signalR.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (signalR *SignalR) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(signalR) } // validateResourceReferences validates all resource references @@ -565,7 +570,10 @@ func (signalR *SignalR_Spec) PopulateFromARM(owner genruntime.ArbitraryOwnerRefe } // Set property "Owner": - signalR.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + signalR.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "PublicNetworkAccess": // copying flattened property: diff --git a/v2/api/signalrservice/v1beta20211001storage/signal_r_types_gen.go b/v2/api/signalrservice/v1beta20211001storage/signal_r_types_gen.go index 776ee52e45a..04d0edef502 100644 --- a/v2/api/signalrservice/v1beta20211001storage/signal_r_types_gen.go +++ b/v2/api/signalrservice/v1beta20211001storage/signal_r_types_gen.go @@ -103,11 +103,7 @@ func (signalR *SignalR) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (signalR *SignalR) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(signalR.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: signalR.Spec.Owner.Name, - } + return signalR.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/sql/v1api20211101/server_types_gen.go b/v2/api/sql/v1api20211101/server_types_gen.go index 36e4e70998e..09213964a84 100644 --- a/v2/api/sql/v1api20211101/server_types_gen.go +++ b/v2/api/sql/v1api20211101/server_types_gen.go @@ -163,11 +163,7 @@ func (server *Server) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (server *Server) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(server.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: server.Spec.Owner.Name, - } + return server.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -225,7 +221,7 @@ func (server *Server) ValidateUpdate(old runtime.Object) (admission.Warnings, er // createValidations validates the creation of the resource func (server *Server) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){server.validateResourceReferences, server.validateConfigMapDestinations} + return []func() (admission.Warnings, error){server.validateResourceReferences, server.validateOwnerReference, server.validateConfigMapDestinations} } // deleteValidations validates the deletion of the resource @@ -240,6 +236,9 @@ func (server *Server) updateValidations() []func(old runtime.Object) (admission. return server.validateResourceReferences() }, server.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return server.validateOwnerReference() + }, func(old runtime.Object) (admission.Warnings, error) { return server.validateConfigMapDestinations() }, @@ -260,6 +259,11 @@ func (server *Server) validateConfigMapDestinations() (admission.Warnings, error return genruntime.ValidateConfigMapDestinations(toValidate) } +// validateOwnerReference validates the owner field +func (server *Server) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(server) +} + // validateResourceReferences validates all resource references func (server *Server) validateResourceReferences() (admission.Warnings, error) { refs, err := reflecthelpers.FindResourceReferences(&server.Spec) @@ -605,7 +609,10 @@ func (server *Server_Spec) PopulateFromARM(owner genruntime.ArbitraryOwnerRefere // no assignment for property "OperatorSpec" // Set property "Owner": - server.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + server.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // no assignment for property "PrimaryUserAssignedIdentityReference" diff --git a/v2/api/sql/v1api20211101/servers_administrator_types_gen.go b/v2/api/sql/v1api20211101/servers_administrator_types_gen.go index d7a3caadc3c..5b34c992f76 100644 --- a/v2/api/sql/v1api20211101/servers_administrator_types_gen.go +++ b/v2/api/sql/v1api20211101/servers_administrator_types_gen.go @@ -134,11 +134,7 @@ func (administrator *ServersAdministrator) NewEmptyStatus() genruntime.Convertib // Owner returns the ResourceReference of the owner func (administrator *ServersAdministrator) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(administrator.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: administrator.Spec.Owner.Name, - } + return administrator.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -196,7 +192,7 @@ func (administrator *ServersAdministrator) ValidateUpdate(old runtime.Object) (a // createValidations validates the creation of the resource func (administrator *ServersAdministrator) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){administrator.validateResourceReferences, administrator.validateOptionalConfigMapReferences} + return []func() (admission.Warnings, error){administrator.validateResourceReferences, administrator.validateOwnerReference, administrator.validateOptionalConfigMapReferences} } // deleteValidations validates the deletion of the resource @@ -211,6 +207,9 @@ func (administrator *ServersAdministrator) updateValidations() []func(old runtim return administrator.validateResourceReferences() }, administrator.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return administrator.validateOwnerReference() + }, func(old runtime.Object) (admission.Warnings, error) { return administrator.validateOptionalConfigMapReferences() }, @@ -226,6 +225,11 @@ func (administrator *ServersAdministrator) validateOptionalConfigMapReferences() return genruntime.ValidateOptionalConfigMapReferences(refs) } +// validateOwnerReference validates the owner field +func (administrator *ServersAdministrator) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(administrator) +} + // validateResourceReferences validates all resource references func (administrator *ServersAdministrator) validateResourceReferences() (admission.Warnings, error) { refs, err := reflecthelpers.FindResourceReferences(&administrator.Spec) @@ -433,7 +437,10 @@ func (administrator *Servers_Administrator_Spec) PopulateFromARM(owner genruntim } // Set property "Owner": - administrator.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + administrator.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "Sid": // copying flattened property: diff --git a/v2/api/sql/v1api20211101/servers_advanced_threat_protection_setting_types_gen.go b/v2/api/sql/v1api20211101/servers_advanced_threat_protection_setting_types_gen.go index c1dec2f7b23..ec5de5235b4 100644 --- a/v2/api/sql/v1api20211101/servers_advanced_threat_protection_setting_types_gen.go +++ b/v2/api/sql/v1api20211101/servers_advanced_threat_protection_setting_types_gen.go @@ -134,11 +134,7 @@ func (setting *ServersAdvancedThreatProtectionSetting) NewEmptyStatus() genrunti // Owner returns the ResourceReference of the owner func (setting *ServersAdvancedThreatProtectionSetting) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(setting.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: setting.Spec.Owner.Name, - } + return setting.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -196,7 +192,7 @@ func (setting *ServersAdvancedThreatProtectionSetting) ValidateUpdate(old runtim // createValidations validates the creation of the resource func (setting *ServersAdvancedThreatProtectionSetting) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){setting.validateResourceReferences} + return []func() (admission.Warnings, error){setting.validateResourceReferences, setting.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -210,7 +206,16 @@ func (setting *ServersAdvancedThreatProtectionSetting) updateValidations() []fun func(old runtime.Object) (admission.Warnings, error) { return setting.validateResourceReferences() }, - setting.validateWriteOnceProperties} + setting.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return setting.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (setting *ServersAdvancedThreatProtectionSetting) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(setting) } // validateResourceReferences validates all resource references @@ -352,7 +357,10 @@ func (setting *Servers_AdvancedThreatProtectionSetting_Spec) PopulateFromARM(own } // Set property "Owner": - setting.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + setting.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "State": // copying flattened property: diff --git a/v2/api/sql/v1api20211101/servers_auditing_setting_types_gen.go b/v2/api/sql/v1api20211101/servers_auditing_setting_types_gen.go index c6608ef5110..1ebc84f9960 100644 --- a/v2/api/sql/v1api20211101/servers_auditing_setting_types_gen.go +++ b/v2/api/sql/v1api20211101/servers_auditing_setting_types_gen.go @@ -134,11 +134,7 @@ func (setting *ServersAuditingSetting) NewEmptyStatus() genruntime.ConvertibleSt // Owner returns the ResourceReference of the owner func (setting *ServersAuditingSetting) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(setting.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: setting.Spec.Owner.Name, - } + return setting.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -196,7 +192,7 @@ func (setting *ServersAuditingSetting) ValidateUpdate(old runtime.Object) (admis // createValidations validates the creation of the resource func (setting *ServersAuditingSetting) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){setting.validateResourceReferences} + return []func() (admission.Warnings, error){setting.validateResourceReferences, setting.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -210,7 +206,16 @@ func (setting *ServersAuditingSetting) updateValidations() []func(old runtime.Ob func(old runtime.Object) (admission.Warnings, error) { return setting.validateResourceReferences() }, - setting.validateWriteOnceProperties} + setting.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return setting.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (setting *ServersAuditingSetting) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(setting) } // validateResourceReferences validates all resource references @@ -565,7 +570,10 @@ func (setting *Servers_AuditingSetting_Spec) PopulateFromARM(owner genruntime.Ar } // Set property "Owner": - setting.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + setting.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "QueueDelayMs": // copying flattened property: diff --git a/v2/api/sql/v1api20211101/servers_azure_ad_only_authentication_types_gen.go b/v2/api/sql/v1api20211101/servers_azure_ad_only_authentication_types_gen.go index d913e19c0b5..2f2c2c0e65f 100644 --- a/v2/api/sql/v1api20211101/servers_azure_ad_only_authentication_types_gen.go +++ b/v2/api/sql/v1api20211101/servers_azure_ad_only_authentication_types_gen.go @@ -134,11 +134,7 @@ func (authentication *ServersAzureADOnlyAuthentication) NewEmptyStatus() genrunt // Owner returns the ResourceReference of the owner func (authentication *ServersAzureADOnlyAuthentication) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(authentication.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: authentication.Spec.Owner.Name, - } + return authentication.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -196,7 +192,7 @@ func (authentication *ServersAzureADOnlyAuthentication) ValidateUpdate(old runti // createValidations validates the creation of the resource func (authentication *ServersAzureADOnlyAuthentication) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){authentication.validateResourceReferences} + return []func() (admission.Warnings, error){authentication.validateResourceReferences, authentication.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -210,7 +206,16 @@ func (authentication *ServersAzureADOnlyAuthentication) updateValidations() []fu func(old runtime.Object) (admission.Warnings, error) { return authentication.validateResourceReferences() }, - authentication.validateWriteOnceProperties} + authentication.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return authentication.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (authentication *ServersAzureADOnlyAuthentication) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(authentication) } // validateResourceReferences validates all resource references @@ -360,7 +365,10 @@ func (authentication *Servers_AzureADOnlyAuthentication_Spec) PopulateFromARM(ow } // Set property "Owner": - authentication.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + authentication.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // No error return nil diff --git a/v2/api/sql/v1api20211101/servers_connection_policy_types_gen.go b/v2/api/sql/v1api20211101/servers_connection_policy_types_gen.go index 8e264c43405..f4a96d849a6 100644 --- a/v2/api/sql/v1api20211101/servers_connection_policy_types_gen.go +++ b/v2/api/sql/v1api20211101/servers_connection_policy_types_gen.go @@ -134,11 +134,7 @@ func (policy *ServersConnectionPolicy) NewEmptyStatus() genruntime.ConvertibleSt // Owner returns the ResourceReference of the owner func (policy *ServersConnectionPolicy) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(policy.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: policy.Spec.Owner.Name, - } + return policy.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -196,7 +192,7 @@ func (policy *ServersConnectionPolicy) ValidateUpdate(old runtime.Object) (admis // createValidations validates the creation of the resource func (policy *ServersConnectionPolicy) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){policy.validateResourceReferences} + return []func() (admission.Warnings, error){policy.validateResourceReferences, policy.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -210,7 +206,16 @@ func (policy *ServersConnectionPolicy) updateValidations() []func(old runtime.Ob func(old runtime.Object) (admission.Warnings, error) { return policy.validateResourceReferences() }, - policy.validateWriteOnceProperties} + policy.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return policy.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (policy *ServersConnectionPolicy) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(policy) } // validateResourceReferences validates all resource references @@ -360,7 +365,10 @@ func (policy *Servers_ConnectionPolicy_Spec) PopulateFromARM(owner genruntime.Ar } // Set property "Owner": - policy.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + policy.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // No error return nil diff --git a/v2/api/sql/v1api20211101/servers_database_types_gen.go b/v2/api/sql/v1api20211101/servers_database_types_gen.go index c8a6d21c5fb..ef08cc199f2 100644 --- a/v2/api/sql/v1api20211101/servers_database_types_gen.go +++ b/v2/api/sql/v1api20211101/servers_database_types_gen.go @@ -141,11 +141,7 @@ func (database *ServersDatabase) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (database *ServersDatabase) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(database.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: database.Spec.Owner.Name, - } + return database.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -203,7 +199,7 @@ func (database *ServersDatabase) ValidateUpdate(old runtime.Object) (admission.W // createValidations validates the creation of the resource func (database *ServersDatabase) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){database.validateResourceReferences} + return []func() (admission.Warnings, error){database.validateResourceReferences, database.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -217,7 +213,16 @@ func (database *ServersDatabase) updateValidations() []func(old runtime.Object) func(old runtime.Object) (admission.Warnings, error) { return database.validateResourceReferences() }, - database.validateWriteOnceProperties} + database.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return database.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (database *ServersDatabase) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(database) } // validateResourceReferences validates all resource references @@ -803,7 +808,10 @@ func (database *Servers_Database_Spec) PopulateFromARM(owner genruntime.Arbitrar } // Set property "Owner": - database.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + database.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "ReadScale": // copying flattened property: diff --git a/v2/api/sql/v1api20211101/servers_databases_advanced_threat_protection_setting_types_gen.go b/v2/api/sql/v1api20211101/servers_databases_advanced_threat_protection_setting_types_gen.go index bed9575a843..d1beeb853ae 100644 --- a/v2/api/sql/v1api20211101/servers_databases_advanced_threat_protection_setting_types_gen.go +++ b/v2/api/sql/v1api20211101/servers_databases_advanced_threat_protection_setting_types_gen.go @@ -134,11 +134,7 @@ func (setting *ServersDatabasesAdvancedThreatProtectionSetting) NewEmptyStatus() // Owner returns the ResourceReference of the owner func (setting *ServersDatabasesAdvancedThreatProtectionSetting) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(setting.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: setting.Spec.Owner.Name, - } + return setting.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -196,7 +192,7 @@ func (setting *ServersDatabasesAdvancedThreatProtectionSetting) ValidateUpdate(o // createValidations validates the creation of the resource func (setting *ServersDatabasesAdvancedThreatProtectionSetting) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){setting.validateResourceReferences} + return []func() (admission.Warnings, error){setting.validateResourceReferences, setting.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -210,7 +206,16 @@ func (setting *ServersDatabasesAdvancedThreatProtectionSetting) updateValidation func(old runtime.Object) (admission.Warnings, error) { return setting.validateResourceReferences() }, - setting.validateWriteOnceProperties} + setting.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return setting.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (setting *ServersDatabasesAdvancedThreatProtectionSetting) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(setting) } // validateResourceReferences validates all resource references @@ -352,7 +357,10 @@ func (setting *Servers_Databases_AdvancedThreatProtectionSetting_Spec) PopulateF } // Set property "Owner": - setting.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + setting.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "State": // copying flattened property: diff --git a/v2/api/sql/v1api20211101/servers_databases_auditing_setting_types_gen.go b/v2/api/sql/v1api20211101/servers_databases_auditing_setting_types_gen.go index df47ac7667d..ced87709f79 100644 --- a/v2/api/sql/v1api20211101/servers_databases_auditing_setting_types_gen.go +++ b/v2/api/sql/v1api20211101/servers_databases_auditing_setting_types_gen.go @@ -134,11 +134,7 @@ func (setting *ServersDatabasesAuditingSetting) NewEmptyStatus() genruntime.Conv // Owner returns the ResourceReference of the owner func (setting *ServersDatabasesAuditingSetting) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(setting.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: setting.Spec.Owner.Name, - } + return setting.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -196,7 +192,7 @@ func (setting *ServersDatabasesAuditingSetting) ValidateUpdate(old runtime.Objec // createValidations validates the creation of the resource func (setting *ServersDatabasesAuditingSetting) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){setting.validateResourceReferences} + return []func() (admission.Warnings, error){setting.validateResourceReferences, setting.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -210,7 +206,16 @@ func (setting *ServersDatabasesAuditingSetting) updateValidations() []func(old r func(old runtime.Object) (admission.Warnings, error) { return setting.validateResourceReferences() }, - setting.validateWriteOnceProperties} + setting.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return setting.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (setting *ServersDatabasesAuditingSetting) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(setting) } // validateResourceReferences validates all resource references @@ -538,7 +543,10 @@ func (setting *Servers_Databases_AuditingSetting_Spec) PopulateFromARM(owner gen } // Set property "Owner": - setting.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + setting.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "QueueDelayMs": // copying flattened property: diff --git a/v2/api/sql/v1api20211101/servers_databases_backup_long_term_retention_policy_types_gen.go b/v2/api/sql/v1api20211101/servers_databases_backup_long_term_retention_policy_types_gen.go index b5e9da198a7..679668ed5d9 100644 --- a/v2/api/sql/v1api20211101/servers_databases_backup_long_term_retention_policy_types_gen.go +++ b/v2/api/sql/v1api20211101/servers_databases_backup_long_term_retention_policy_types_gen.go @@ -134,11 +134,7 @@ func (policy *ServersDatabasesBackupLongTermRetentionPolicy) NewEmptyStatus() ge // Owner returns the ResourceReference of the owner func (policy *ServersDatabasesBackupLongTermRetentionPolicy) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(policy.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: policy.Spec.Owner.Name, - } + return policy.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -196,7 +192,7 @@ func (policy *ServersDatabasesBackupLongTermRetentionPolicy) ValidateUpdate(old // createValidations validates the creation of the resource func (policy *ServersDatabasesBackupLongTermRetentionPolicy) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){policy.validateResourceReferences} + return []func() (admission.Warnings, error){policy.validateResourceReferences, policy.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -210,7 +206,16 @@ func (policy *ServersDatabasesBackupLongTermRetentionPolicy) updateValidations() func(old runtime.Object) (admission.Warnings, error) { return policy.validateResourceReferences() }, - policy.validateWriteOnceProperties} + policy.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return policy.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (policy *ServersDatabasesBackupLongTermRetentionPolicy) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(policy) } // validateResourceReferences validates all resource references @@ -383,7 +388,10 @@ func (policy *Servers_Databases_BackupLongTermRetentionPolicy_Spec) PopulateFrom } // Set property "Owner": - policy.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + policy.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "WeekOfYear": // copying flattened property: diff --git a/v2/api/sql/v1api20211101/servers_databases_backup_short_term_retention_policy_types_gen.go b/v2/api/sql/v1api20211101/servers_databases_backup_short_term_retention_policy_types_gen.go index 8226876858a..5b0fabf2cf4 100644 --- a/v2/api/sql/v1api20211101/servers_databases_backup_short_term_retention_policy_types_gen.go +++ b/v2/api/sql/v1api20211101/servers_databases_backup_short_term_retention_policy_types_gen.go @@ -134,11 +134,7 @@ func (policy *ServersDatabasesBackupShortTermRetentionPolicy) NewEmptyStatus() g // Owner returns the ResourceReference of the owner func (policy *ServersDatabasesBackupShortTermRetentionPolicy) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(policy.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: policy.Spec.Owner.Name, - } + return policy.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -196,7 +192,7 @@ func (policy *ServersDatabasesBackupShortTermRetentionPolicy) ValidateUpdate(old // createValidations validates the creation of the resource func (policy *ServersDatabasesBackupShortTermRetentionPolicy) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){policy.validateResourceReferences} + return []func() (admission.Warnings, error){policy.validateResourceReferences, policy.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -210,7 +206,16 @@ func (policy *ServersDatabasesBackupShortTermRetentionPolicy) updateValidations( func(old runtime.Object) (admission.Warnings, error) { return policy.validateResourceReferences() }, - policy.validateWriteOnceProperties} + policy.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return policy.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (policy *ServersDatabasesBackupShortTermRetentionPolicy) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(policy) } // validateResourceReferences validates all resource references @@ -367,7 +372,10 @@ func (policy *Servers_Databases_BackupShortTermRetentionPolicy_Spec) PopulateFro } // Set property "Owner": - policy.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + policy.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "RetentionDays": // copying flattened property: diff --git a/v2/api/sql/v1api20211101/servers_databases_security_alert_policy_types_gen.go b/v2/api/sql/v1api20211101/servers_databases_security_alert_policy_types_gen.go index 75b49be1bc5..9ff48e4ef06 100644 --- a/v2/api/sql/v1api20211101/servers_databases_security_alert_policy_types_gen.go +++ b/v2/api/sql/v1api20211101/servers_databases_security_alert_policy_types_gen.go @@ -134,11 +134,7 @@ func (policy *ServersDatabasesSecurityAlertPolicy) NewEmptyStatus() genruntime.C // Owner returns the ResourceReference of the owner func (policy *ServersDatabasesSecurityAlertPolicy) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(policy.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: policy.Spec.Owner.Name, - } + return policy.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -196,7 +192,7 @@ func (policy *ServersDatabasesSecurityAlertPolicy) ValidateUpdate(old runtime.Ob // createValidations validates the creation of the resource func (policy *ServersDatabasesSecurityAlertPolicy) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){policy.validateResourceReferences} + return []func() (admission.Warnings, error){policy.validateResourceReferences, policy.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -210,7 +206,16 @@ func (policy *ServersDatabasesSecurityAlertPolicy) updateValidations() []func(ol func(old runtime.Object) (admission.Warnings, error) { return policy.validateResourceReferences() }, - policy.validateWriteOnceProperties} + policy.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return policy.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (policy *ServersDatabasesSecurityAlertPolicy) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(policy) } // validateResourceReferences validates all resource references @@ -429,7 +434,10 @@ func (policy *Servers_Databases_SecurityAlertPolicy_Spec) PopulateFromARM(owner } // Set property "Owner": - policy.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + policy.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "RetentionDays": // copying flattened property: diff --git a/v2/api/sql/v1api20211101/servers_databases_transparent_data_encryption_types_gen.go b/v2/api/sql/v1api20211101/servers_databases_transparent_data_encryption_types_gen.go index 6140a9bbe35..772175e582e 100644 --- a/v2/api/sql/v1api20211101/servers_databases_transparent_data_encryption_types_gen.go +++ b/v2/api/sql/v1api20211101/servers_databases_transparent_data_encryption_types_gen.go @@ -134,11 +134,7 @@ func (encryption *ServersDatabasesTransparentDataEncryption) NewEmptyStatus() ge // Owner returns the ResourceReference of the owner func (encryption *ServersDatabasesTransparentDataEncryption) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(encryption.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: encryption.Spec.Owner.Name, - } + return encryption.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -196,7 +192,7 @@ func (encryption *ServersDatabasesTransparentDataEncryption) ValidateUpdate(old // createValidations validates the creation of the resource func (encryption *ServersDatabasesTransparentDataEncryption) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){encryption.validateResourceReferences} + return []func() (admission.Warnings, error){encryption.validateResourceReferences, encryption.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -210,7 +206,16 @@ func (encryption *ServersDatabasesTransparentDataEncryption) updateValidations() func(old runtime.Object) (admission.Warnings, error) { return encryption.validateResourceReferences() }, - encryption.validateWriteOnceProperties} + encryption.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return encryption.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (encryption *ServersDatabasesTransparentDataEncryption) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(encryption) } // validateResourceReferences validates all resource references @@ -351,7 +356,10 @@ func (encryption *Servers_Databases_TransparentDataEncryption_Spec) PopulateFrom } // Set property "Owner": - encryption.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + encryption.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "State": // copying flattened property: diff --git a/v2/api/sql/v1api20211101/servers_databases_vulnerability_assessment_types_gen.go b/v2/api/sql/v1api20211101/servers_databases_vulnerability_assessment_types_gen.go index 7b04d37a1f4..2ac2023f5f5 100644 --- a/v2/api/sql/v1api20211101/servers_databases_vulnerability_assessment_types_gen.go +++ b/v2/api/sql/v1api20211101/servers_databases_vulnerability_assessment_types_gen.go @@ -134,11 +134,7 @@ func (assessment *ServersDatabasesVulnerabilityAssessment) NewEmptyStatus() genr // Owner returns the ResourceReference of the owner func (assessment *ServersDatabasesVulnerabilityAssessment) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(assessment.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: assessment.Spec.Owner.Name, - } + return assessment.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -196,7 +192,7 @@ func (assessment *ServersDatabasesVulnerabilityAssessment) ValidateUpdate(old ru // createValidations validates the creation of the resource func (assessment *ServersDatabasesVulnerabilityAssessment) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){assessment.validateResourceReferences, assessment.validateOptionalConfigMapReferences} + return []func() (admission.Warnings, error){assessment.validateResourceReferences, assessment.validateOwnerReference, assessment.validateOptionalConfigMapReferences} } // deleteValidations validates the deletion of the resource @@ -211,6 +207,9 @@ func (assessment *ServersDatabasesVulnerabilityAssessment) updateValidations() [ return assessment.validateResourceReferences() }, assessment.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return assessment.validateOwnerReference() + }, func(old runtime.Object) (admission.Warnings, error) { return assessment.validateOptionalConfigMapReferences() }, @@ -226,6 +225,11 @@ func (assessment *ServersDatabasesVulnerabilityAssessment) validateOptionalConfi return genruntime.ValidateOptionalConfigMapReferences(refs) } +// validateOwnerReference validates the owner field +func (assessment *ServersDatabasesVulnerabilityAssessment) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(assessment) +} + // validateResourceReferences validates all resource references func (assessment *ServersDatabasesVulnerabilityAssessment) validateResourceReferences() (admission.Warnings, error) { refs, err := reflecthelpers.FindResourceReferences(&assessment.Spec) @@ -419,7 +423,10 @@ func (assessment *Servers_Databases_VulnerabilityAssessment_Spec) PopulateFromAR } // Set property "Owner": - assessment.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + assessment.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "RecurringScans": // copying flattened property: diff --git a/v2/api/sql/v1api20211101/servers_elastic_pool_types_gen.go b/v2/api/sql/v1api20211101/servers_elastic_pool_types_gen.go index 43ed9b382ee..a3926bb0bb8 100644 --- a/v2/api/sql/v1api20211101/servers_elastic_pool_types_gen.go +++ b/v2/api/sql/v1api20211101/servers_elastic_pool_types_gen.go @@ -141,11 +141,7 @@ func (pool *ServersElasticPool) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (pool *ServersElasticPool) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(pool.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: pool.Spec.Owner.Name, - } + return pool.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -203,7 +199,7 @@ func (pool *ServersElasticPool) ValidateUpdate(old runtime.Object) (admission.Wa // createValidations validates the creation of the resource func (pool *ServersElasticPool) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){pool.validateResourceReferences} + return []func() (admission.Warnings, error){pool.validateResourceReferences, pool.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -217,7 +213,16 @@ func (pool *ServersElasticPool) updateValidations() []func(old runtime.Object) ( func(old runtime.Object) (admission.Warnings, error) { return pool.validateResourceReferences() }, - pool.validateWriteOnceProperties} + pool.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return pool.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (pool *ServersElasticPool) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(pool) } // validateResourceReferences validates all resource references @@ -510,7 +515,10 @@ func (pool *Servers_ElasticPool_Spec) PopulateFromARM(owner genruntime.Arbitrary } // Set property "Owner": - pool.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + pool.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "PerDatabaseSettings": // copying flattened property: diff --git a/v2/api/sql/v1api20211101/servers_failover_group_types_gen.go b/v2/api/sql/v1api20211101/servers_failover_group_types_gen.go index 22f41c44f87..6d364bb47cb 100644 --- a/v2/api/sql/v1api20211101/servers_failover_group_types_gen.go +++ b/v2/api/sql/v1api20211101/servers_failover_group_types_gen.go @@ -141,11 +141,7 @@ func (group *ServersFailoverGroup) NewEmptyStatus() genruntime.ConvertibleStatus // Owner returns the ResourceReference of the owner func (group *ServersFailoverGroup) Owner() *genruntime.ResourceReference { ownerGroup, ownerKind := genruntime.LookupOwnerGroupKind(group.Spec) - return &genruntime.ResourceReference{ - Group: ownerGroup, - Kind: ownerKind, - Name: group.Spec.Owner.Name, - } + return group.Spec.Owner.AsResourceReference(ownerGroup, ownerKind) } // SetStatus sets the status of this resource @@ -203,7 +199,7 @@ func (group *ServersFailoverGroup) ValidateUpdate(old runtime.Object) (admission // createValidations validates the creation of the resource func (group *ServersFailoverGroup) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){group.validateResourceReferences} + return []func() (admission.Warnings, error){group.validateResourceReferences, group.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -217,7 +213,16 @@ func (group *ServersFailoverGroup) updateValidations() []func(old runtime.Object func(old runtime.Object) (admission.Warnings, error) { return group.validateResourceReferences() }, - group.validateWriteOnceProperties} + group.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return group.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (group *ServersFailoverGroup) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(group) } // validateResourceReferences validates all resource references @@ -417,7 +422,10 @@ func (group *Servers_FailoverGroup_Spec) PopulateFromARM(owner genruntime.Arbitr // no assignment for property "DatabasesReferences" // Set property "Owner": - group.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + group.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "PartnerServers": // copying flattened property: diff --git a/v2/api/sql/v1api20211101/servers_firewall_rule_types_gen.go b/v2/api/sql/v1api20211101/servers_firewall_rule_types_gen.go index 792be9a9ba5..e1ed8828088 100644 --- a/v2/api/sql/v1api20211101/servers_firewall_rule_types_gen.go +++ b/v2/api/sql/v1api20211101/servers_firewall_rule_types_gen.go @@ -141,11 +141,7 @@ func (rule *ServersFirewallRule) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (rule *ServersFirewallRule) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(rule.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: rule.Spec.Owner.Name, - } + return rule.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -203,7 +199,7 @@ func (rule *ServersFirewallRule) ValidateUpdate(old runtime.Object) (admission.W // createValidations validates the creation of the resource func (rule *ServersFirewallRule) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){rule.validateResourceReferences} + return []func() (admission.Warnings, error){rule.validateResourceReferences, rule.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -217,7 +213,16 @@ func (rule *ServersFirewallRule) updateValidations() []func(old runtime.Object) func(old runtime.Object) (admission.Warnings, error) { return rule.validateResourceReferences() }, - rule.validateWriteOnceProperties} + rule.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return rule.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (rule *ServersFirewallRule) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(rule) } // validateResourceReferences validates all resource references @@ -382,7 +387,10 @@ func (rule *Servers_FirewallRule_Spec) PopulateFromARM(owner genruntime.Arbitrar } // Set property "Owner": - rule.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + rule.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "StartIpAddress": // copying flattened property: diff --git a/v2/api/sql/v1api20211101/servers_ipv_6_firewall_rule_types_gen.go b/v2/api/sql/v1api20211101/servers_ipv_6_firewall_rule_types_gen.go index a195013c60f..7037925838e 100644 --- a/v2/api/sql/v1api20211101/servers_ipv_6_firewall_rule_types_gen.go +++ b/v2/api/sql/v1api20211101/servers_ipv_6_firewall_rule_types_gen.go @@ -141,11 +141,7 @@ func (rule *ServersIPV6FirewallRule) NewEmptyStatus() genruntime.ConvertibleStat // Owner returns the ResourceReference of the owner func (rule *ServersIPV6FirewallRule) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(rule.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: rule.Spec.Owner.Name, - } + return rule.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -203,7 +199,7 @@ func (rule *ServersIPV6FirewallRule) ValidateUpdate(old runtime.Object) (admissi // createValidations validates the creation of the resource func (rule *ServersIPV6FirewallRule) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){rule.validateResourceReferences} + return []func() (admission.Warnings, error){rule.validateResourceReferences, rule.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -217,7 +213,16 @@ func (rule *ServersIPV6FirewallRule) updateValidations() []func(old runtime.Obje func(old runtime.Object) (admission.Warnings, error) { return rule.validateResourceReferences() }, - rule.validateWriteOnceProperties} + rule.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return rule.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (rule *ServersIPV6FirewallRule) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(rule) } // validateResourceReferences validates all resource references @@ -381,7 +386,10 @@ func (rule *Servers_Ipv6FirewallRule_Spec) PopulateFromARM(owner genruntime.Arbi } // Set property "Owner": - rule.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + rule.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "StartIPv6Address": // copying flattened property: diff --git a/v2/api/sql/v1api20211101/servers_outbound_firewall_rule_types_gen.go b/v2/api/sql/v1api20211101/servers_outbound_firewall_rule_types_gen.go index 4777554b31c..9d882402405 100644 --- a/v2/api/sql/v1api20211101/servers_outbound_firewall_rule_types_gen.go +++ b/v2/api/sql/v1api20211101/servers_outbound_firewall_rule_types_gen.go @@ -141,11 +141,7 @@ func (rule *ServersOutboundFirewallRule) NewEmptyStatus() genruntime.Convertible // Owner returns the ResourceReference of the owner func (rule *ServersOutboundFirewallRule) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(rule.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: rule.Spec.Owner.Name, - } + return rule.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -203,7 +199,7 @@ func (rule *ServersOutboundFirewallRule) ValidateUpdate(old runtime.Object) (adm // createValidations validates the creation of the resource func (rule *ServersOutboundFirewallRule) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){rule.validateResourceReferences} + return []func() (admission.Warnings, error){rule.validateResourceReferences, rule.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -217,7 +213,16 @@ func (rule *ServersOutboundFirewallRule) updateValidations() []func(old runtime. func(old runtime.Object) (admission.Warnings, error) { return rule.validateResourceReferences() }, - rule.validateWriteOnceProperties} + rule.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return rule.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (rule *ServersOutboundFirewallRule) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(rule) } // validateResourceReferences validates all resource references @@ -352,7 +357,10 @@ func (rule *Servers_OutboundFirewallRule_Spec) PopulateFromARM(owner genruntime. rule.SetAzureName(genruntime.ExtractKubernetesResourceNameFromARMName(typedInput.Name)) // Set property "Owner": - rule.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + rule.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // No error return nil diff --git a/v2/api/sql/v1api20211101/servers_security_alert_policy_types_gen.go b/v2/api/sql/v1api20211101/servers_security_alert_policy_types_gen.go index 88dfd4ac49a..edb1095a593 100644 --- a/v2/api/sql/v1api20211101/servers_security_alert_policy_types_gen.go +++ b/v2/api/sql/v1api20211101/servers_security_alert_policy_types_gen.go @@ -134,11 +134,7 @@ func (policy *ServersSecurityAlertPolicy) NewEmptyStatus() genruntime.Convertibl // Owner returns the ResourceReference of the owner func (policy *ServersSecurityAlertPolicy) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(policy.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: policy.Spec.Owner.Name, - } + return policy.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -196,7 +192,7 @@ func (policy *ServersSecurityAlertPolicy) ValidateUpdate(old runtime.Object) (ad // createValidations validates the creation of the resource func (policy *ServersSecurityAlertPolicy) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){policy.validateResourceReferences} + return []func() (admission.Warnings, error){policy.validateResourceReferences, policy.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -210,7 +206,16 @@ func (policy *ServersSecurityAlertPolicy) updateValidations() []func(old runtime func(old runtime.Object) (admission.Warnings, error) { return policy.validateResourceReferences() }, - policy.validateWriteOnceProperties} + policy.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return policy.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (policy *ServersSecurityAlertPolicy) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(policy) } // validateResourceReferences validates all resource references @@ -429,7 +434,10 @@ func (policy *Servers_SecurityAlertPolicy_Spec) PopulateFromARM(owner genruntime } // Set property "Owner": - policy.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + policy.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "RetentionDays": // copying flattened property: diff --git a/v2/api/sql/v1api20211101/servers_virtual_network_rule_types_gen.go b/v2/api/sql/v1api20211101/servers_virtual_network_rule_types_gen.go index 22a38821062..585466d7fa1 100644 --- a/v2/api/sql/v1api20211101/servers_virtual_network_rule_types_gen.go +++ b/v2/api/sql/v1api20211101/servers_virtual_network_rule_types_gen.go @@ -141,11 +141,7 @@ func (rule *ServersVirtualNetworkRule) NewEmptyStatus() genruntime.ConvertibleSt // Owner returns the ResourceReference of the owner func (rule *ServersVirtualNetworkRule) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(rule.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: rule.Spec.Owner.Name, - } + return rule.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -203,7 +199,7 @@ func (rule *ServersVirtualNetworkRule) ValidateUpdate(old runtime.Object) (admis // createValidations validates the creation of the resource func (rule *ServersVirtualNetworkRule) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){rule.validateResourceReferences} + return []func() (admission.Warnings, error){rule.validateResourceReferences, rule.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -217,7 +213,16 @@ func (rule *ServersVirtualNetworkRule) updateValidations() []func(old runtime.Ob func(old runtime.Object) (admission.Warnings, error) { return rule.validateResourceReferences() }, - rule.validateWriteOnceProperties} + rule.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return rule.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (rule *ServersVirtualNetworkRule) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(rule) } // validateResourceReferences validates all resource references @@ -385,7 +390,10 @@ func (rule *Servers_VirtualNetworkRule_Spec) PopulateFromARM(owner genruntime.Ar } // Set property "Owner": - rule.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + rule.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // no assignment for property "VirtualNetworkSubnetReference" diff --git a/v2/api/sql/v1api20211101/servers_vulnerability_assessment_types_gen.go b/v2/api/sql/v1api20211101/servers_vulnerability_assessment_types_gen.go index 61c05952699..57fb84c2141 100644 --- a/v2/api/sql/v1api20211101/servers_vulnerability_assessment_types_gen.go +++ b/v2/api/sql/v1api20211101/servers_vulnerability_assessment_types_gen.go @@ -134,11 +134,7 @@ func (assessment *ServersVulnerabilityAssessment) NewEmptyStatus() genruntime.Co // Owner returns the ResourceReference of the owner func (assessment *ServersVulnerabilityAssessment) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(assessment.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: assessment.Spec.Owner.Name, - } + return assessment.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -196,7 +192,7 @@ func (assessment *ServersVulnerabilityAssessment) ValidateUpdate(old runtime.Obj // createValidations validates the creation of the resource func (assessment *ServersVulnerabilityAssessment) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){assessment.validateResourceReferences, assessment.validateOptionalConfigMapReferences} + return []func() (admission.Warnings, error){assessment.validateResourceReferences, assessment.validateOwnerReference, assessment.validateOptionalConfigMapReferences} } // deleteValidations validates the deletion of the resource @@ -211,6 +207,9 @@ func (assessment *ServersVulnerabilityAssessment) updateValidations() []func(old return assessment.validateResourceReferences() }, assessment.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return assessment.validateOwnerReference() + }, func(old runtime.Object) (admission.Warnings, error) { return assessment.validateOptionalConfigMapReferences() }, @@ -226,6 +225,11 @@ func (assessment *ServersVulnerabilityAssessment) validateOptionalConfigMapRefer return genruntime.ValidateOptionalConfigMapReferences(refs) } +// validateOwnerReference validates the owner field +func (assessment *ServersVulnerabilityAssessment) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(assessment) +} + // validateResourceReferences validates all resource references func (assessment *ServersVulnerabilityAssessment) validateResourceReferences() (admission.Warnings, error) { refs, err := reflecthelpers.FindResourceReferences(&assessment.Spec) @@ -417,7 +421,10 @@ func (assessment *Servers_VulnerabilityAssessment_Spec) PopulateFromARM(owner ge } // Set property "Owner": - assessment.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + assessment.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "RecurringScans": // copying flattened property: diff --git a/v2/api/sql/v1api20211101storage/server_types_gen.go b/v2/api/sql/v1api20211101storage/server_types_gen.go index b65a2aa64ff..46d0d351b77 100644 --- a/v2/api/sql/v1api20211101storage/server_types_gen.go +++ b/v2/api/sql/v1api20211101storage/server_types_gen.go @@ -106,11 +106,7 @@ func (server *Server) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (server *Server) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(server.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: server.Spec.Owner.Name, - } + return server.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/sql/v1api20211101storage/servers_administrator_types_gen.go b/v2/api/sql/v1api20211101storage/servers_administrator_types_gen.go index adcb9bc048e..9b3ac14fe6b 100644 --- a/v2/api/sql/v1api20211101storage/servers_administrator_types_gen.go +++ b/v2/api/sql/v1api20211101storage/servers_administrator_types_gen.go @@ -84,11 +84,7 @@ func (administrator *ServersAdministrator) NewEmptyStatus() genruntime.Convertib // Owner returns the ResourceReference of the owner func (administrator *ServersAdministrator) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(administrator.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: administrator.Spec.Owner.Name, - } + return administrator.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/sql/v1api20211101storage/servers_advanced_threat_protection_setting_types_gen.go b/v2/api/sql/v1api20211101storage/servers_advanced_threat_protection_setting_types_gen.go index 55e61d07368..aa654983141 100644 --- a/v2/api/sql/v1api20211101storage/servers_advanced_threat_protection_setting_types_gen.go +++ b/v2/api/sql/v1api20211101storage/servers_advanced_threat_protection_setting_types_gen.go @@ -84,11 +84,7 @@ func (setting *ServersAdvancedThreatProtectionSetting) NewEmptyStatus() genrunti // Owner returns the ResourceReference of the owner func (setting *ServersAdvancedThreatProtectionSetting) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(setting.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: setting.Spec.Owner.Name, - } + return setting.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/sql/v1api20211101storage/servers_auditing_setting_types_gen.go b/v2/api/sql/v1api20211101storage/servers_auditing_setting_types_gen.go index 89586468321..21ae5118429 100644 --- a/v2/api/sql/v1api20211101storage/servers_auditing_setting_types_gen.go +++ b/v2/api/sql/v1api20211101storage/servers_auditing_setting_types_gen.go @@ -84,11 +84,7 @@ func (setting *ServersAuditingSetting) NewEmptyStatus() genruntime.ConvertibleSt // Owner returns the ResourceReference of the owner func (setting *ServersAuditingSetting) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(setting.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: setting.Spec.Owner.Name, - } + return setting.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/sql/v1api20211101storage/servers_azure_ad_only_authentication_types_gen.go b/v2/api/sql/v1api20211101storage/servers_azure_ad_only_authentication_types_gen.go index b8722a2ef0b..6a81f9a87be 100644 --- a/v2/api/sql/v1api20211101storage/servers_azure_ad_only_authentication_types_gen.go +++ b/v2/api/sql/v1api20211101storage/servers_azure_ad_only_authentication_types_gen.go @@ -84,11 +84,7 @@ func (authentication *ServersAzureADOnlyAuthentication) NewEmptyStatus() genrunt // Owner returns the ResourceReference of the owner func (authentication *ServersAzureADOnlyAuthentication) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(authentication.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: authentication.Spec.Owner.Name, - } + return authentication.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/sql/v1api20211101storage/servers_connection_policy_types_gen.go b/v2/api/sql/v1api20211101storage/servers_connection_policy_types_gen.go index e28299ffed1..f899caabcad 100644 --- a/v2/api/sql/v1api20211101storage/servers_connection_policy_types_gen.go +++ b/v2/api/sql/v1api20211101storage/servers_connection_policy_types_gen.go @@ -84,11 +84,7 @@ func (policy *ServersConnectionPolicy) NewEmptyStatus() genruntime.ConvertibleSt // Owner returns the ResourceReference of the owner func (policy *ServersConnectionPolicy) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(policy.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: policy.Spec.Owner.Name, - } + return policy.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/sql/v1api20211101storage/servers_database_types_gen.go b/v2/api/sql/v1api20211101storage/servers_database_types_gen.go index 22750d0092e..2220a20767d 100644 --- a/v2/api/sql/v1api20211101storage/servers_database_types_gen.go +++ b/v2/api/sql/v1api20211101storage/servers_database_types_gen.go @@ -84,11 +84,7 @@ func (database *ServersDatabase) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (database *ServersDatabase) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(database.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: database.Spec.Owner.Name, - } + return database.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/sql/v1api20211101storage/servers_databases_advanced_threat_protection_setting_types_gen.go b/v2/api/sql/v1api20211101storage/servers_databases_advanced_threat_protection_setting_types_gen.go index 56d8d8c0f87..331596f4303 100644 --- a/v2/api/sql/v1api20211101storage/servers_databases_advanced_threat_protection_setting_types_gen.go +++ b/v2/api/sql/v1api20211101storage/servers_databases_advanced_threat_protection_setting_types_gen.go @@ -84,11 +84,7 @@ func (setting *ServersDatabasesAdvancedThreatProtectionSetting) NewEmptyStatus() // Owner returns the ResourceReference of the owner func (setting *ServersDatabasesAdvancedThreatProtectionSetting) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(setting.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: setting.Spec.Owner.Name, - } + return setting.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/sql/v1api20211101storage/servers_databases_auditing_setting_types_gen.go b/v2/api/sql/v1api20211101storage/servers_databases_auditing_setting_types_gen.go index e60877dc6b6..7db74ecfe6d 100644 --- a/v2/api/sql/v1api20211101storage/servers_databases_auditing_setting_types_gen.go +++ b/v2/api/sql/v1api20211101storage/servers_databases_auditing_setting_types_gen.go @@ -84,11 +84,7 @@ func (setting *ServersDatabasesAuditingSetting) NewEmptyStatus() genruntime.Conv // Owner returns the ResourceReference of the owner func (setting *ServersDatabasesAuditingSetting) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(setting.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: setting.Spec.Owner.Name, - } + return setting.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/sql/v1api20211101storage/servers_databases_backup_long_term_retention_policy_types_gen.go b/v2/api/sql/v1api20211101storage/servers_databases_backup_long_term_retention_policy_types_gen.go index ce037a801ee..11c394ab332 100644 --- a/v2/api/sql/v1api20211101storage/servers_databases_backup_long_term_retention_policy_types_gen.go +++ b/v2/api/sql/v1api20211101storage/servers_databases_backup_long_term_retention_policy_types_gen.go @@ -84,11 +84,7 @@ func (policy *ServersDatabasesBackupLongTermRetentionPolicy) NewEmptyStatus() ge // Owner returns the ResourceReference of the owner func (policy *ServersDatabasesBackupLongTermRetentionPolicy) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(policy.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: policy.Spec.Owner.Name, - } + return policy.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/sql/v1api20211101storage/servers_databases_backup_short_term_retention_policy_types_gen.go b/v2/api/sql/v1api20211101storage/servers_databases_backup_short_term_retention_policy_types_gen.go index 631390b3730..101b57a67f7 100644 --- a/v2/api/sql/v1api20211101storage/servers_databases_backup_short_term_retention_policy_types_gen.go +++ b/v2/api/sql/v1api20211101storage/servers_databases_backup_short_term_retention_policy_types_gen.go @@ -84,11 +84,7 @@ func (policy *ServersDatabasesBackupShortTermRetentionPolicy) NewEmptyStatus() g // Owner returns the ResourceReference of the owner func (policy *ServersDatabasesBackupShortTermRetentionPolicy) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(policy.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: policy.Spec.Owner.Name, - } + return policy.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/sql/v1api20211101storage/servers_databases_security_alert_policy_types_gen.go b/v2/api/sql/v1api20211101storage/servers_databases_security_alert_policy_types_gen.go index eb900a0195f..f29ada4b89d 100644 --- a/v2/api/sql/v1api20211101storage/servers_databases_security_alert_policy_types_gen.go +++ b/v2/api/sql/v1api20211101storage/servers_databases_security_alert_policy_types_gen.go @@ -84,11 +84,7 @@ func (policy *ServersDatabasesSecurityAlertPolicy) NewEmptyStatus() genruntime.C // Owner returns the ResourceReference of the owner func (policy *ServersDatabasesSecurityAlertPolicy) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(policy.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: policy.Spec.Owner.Name, - } + return policy.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/sql/v1api20211101storage/servers_databases_transparent_data_encryption_types_gen.go b/v2/api/sql/v1api20211101storage/servers_databases_transparent_data_encryption_types_gen.go index 196663b6d7a..83cc1b21460 100644 --- a/v2/api/sql/v1api20211101storage/servers_databases_transparent_data_encryption_types_gen.go +++ b/v2/api/sql/v1api20211101storage/servers_databases_transparent_data_encryption_types_gen.go @@ -84,11 +84,7 @@ func (encryption *ServersDatabasesTransparentDataEncryption) NewEmptyStatus() ge // Owner returns the ResourceReference of the owner func (encryption *ServersDatabasesTransparentDataEncryption) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(encryption.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: encryption.Spec.Owner.Name, - } + return encryption.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/sql/v1api20211101storage/servers_databases_vulnerability_assessment_types_gen.go b/v2/api/sql/v1api20211101storage/servers_databases_vulnerability_assessment_types_gen.go index 810e561a7b4..7dba165a20d 100644 --- a/v2/api/sql/v1api20211101storage/servers_databases_vulnerability_assessment_types_gen.go +++ b/v2/api/sql/v1api20211101storage/servers_databases_vulnerability_assessment_types_gen.go @@ -84,11 +84,7 @@ func (assessment *ServersDatabasesVulnerabilityAssessment) NewEmptyStatus() genr // Owner returns the ResourceReference of the owner func (assessment *ServersDatabasesVulnerabilityAssessment) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(assessment.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: assessment.Spec.Owner.Name, - } + return assessment.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/sql/v1api20211101storage/servers_elastic_pool_types_gen.go b/v2/api/sql/v1api20211101storage/servers_elastic_pool_types_gen.go index 7caf1cceccf..2a58bf6ec8a 100644 --- a/v2/api/sql/v1api20211101storage/servers_elastic_pool_types_gen.go +++ b/v2/api/sql/v1api20211101storage/servers_elastic_pool_types_gen.go @@ -84,11 +84,7 @@ func (pool *ServersElasticPool) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (pool *ServersElasticPool) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(pool.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: pool.Spec.Owner.Name, - } + return pool.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/sql/v1api20211101storage/servers_failover_group_types_gen.go b/v2/api/sql/v1api20211101storage/servers_failover_group_types_gen.go index 5900e117daf..f51539150a2 100644 --- a/v2/api/sql/v1api20211101storage/servers_failover_group_types_gen.go +++ b/v2/api/sql/v1api20211101storage/servers_failover_group_types_gen.go @@ -84,11 +84,7 @@ func (group *ServersFailoverGroup) NewEmptyStatus() genruntime.ConvertibleStatus // Owner returns the ResourceReference of the owner func (group *ServersFailoverGroup) Owner() *genruntime.ResourceReference { ownerGroup, ownerKind := genruntime.LookupOwnerGroupKind(group.Spec) - return &genruntime.ResourceReference{ - Group: ownerGroup, - Kind: ownerKind, - Name: group.Spec.Owner.Name, - } + return group.Spec.Owner.AsResourceReference(ownerGroup, ownerKind) } // SetStatus sets the status of this resource diff --git a/v2/api/sql/v1api20211101storage/servers_firewall_rule_types_gen.go b/v2/api/sql/v1api20211101storage/servers_firewall_rule_types_gen.go index 10aafa59798..aa004e72b0d 100644 --- a/v2/api/sql/v1api20211101storage/servers_firewall_rule_types_gen.go +++ b/v2/api/sql/v1api20211101storage/servers_firewall_rule_types_gen.go @@ -84,11 +84,7 @@ func (rule *ServersFirewallRule) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (rule *ServersFirewallRule) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(rule.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: rule.Spec.Owner.Name, - } + return rule.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/sql/v1api20211101storage/servers_ipv_6_firewall_rule_types_gen.go b/v2/api/sql/v1api20211101storage/servers_ipv_6_firewall_rule_types_gen.go index d5c4974804a..37f15d5a807 100644 --- a/v2/api/sql/v1api20211101storage/servers_ipv_6_firewall_rule_types_gen.go +++ b/v2/api/sql/v1api20211101storage/servers_ipv_6_firewall_rule_types_gen.go @@ -84,11 +84,7 @@ func (rule *ServersIPV6FirewallRule) NewEmptyStatus() genruntime.ConvertibleStat // Owner returns the ResourceReference of the owner func (rule *ServersIPV6FirewallRule) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(rule.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: rule.Spec.Owner.Name, - } + return rule.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/sql/v1api20211101storage/servers_outbound_firewall_rule_types_gen.go b/v2/api/sql/v1api20211101storage/servers_outbound_firewall_rule_types_gen.go index 74c9d45dca9..2ea25b0b253 100644 --- a/v2/api/sql/v1api20211101storage/servers_outbound_firewall_rule_types_gen.go +++ b/v2/api/sql/v1api20211101storage/servers_outbound_firewall_rule_types_gen.go @@ -84,11 +84,7 @@ func (rule *ServersOutboundFirewallRule) NewEmptyStatus() genruntime.Convertible // Owner returns the ResourceReference of the owner func (rule *ServersOutboundFirewallRule) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(rule.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: rule.Spec.Owner.Name, - } + return rule.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/sql/v1api20211101storage/servers_security_alert_policy_types_gen.go b/v2/api/sql/v1api20211101storage/servers_security_alert_policy_types_gen.go index 140785d5ad1..1e54a866d58 100644 --- a/v2/api/sql/v1api20211101storage/servers_security_alert_policy_types_gen.go +++ b/v2/api/sql/v1api20211101storage/servers_security_alert_policy_types_gen.go @@ -84,11 +84,7 @@ func (policy *ServersSecurityAlertPolicy) NewEmptyStatus() genruntime.Convertibl // Owner returns the ResourceReference of the owner func (policy *ServersSecurityAlertPolicy) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(policy.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: policy.Spec.Owner.Name, - } + return policy.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/sql/v1api20211101storage/servers_virtual_network_rule_types_gen.go b/v2/api/sql/v1api20211101storage/servers_virtual_network_rule_types_gen.go index b32cec6341a..984b1777f50 100644 --- a/v2/api/sql/v1api20211101storage/servers_virtual_network_rule_types_gen.go +++ b/v2/api/sql/v1api20211101storage/servers_virtual_network_rule_types_gen.go @@ -84,11 +84,7 @@ func (rule *ServersVirtualNetworkRule) NewEmptyStatus() genruntime.ConvertibleSt // Owner returns the ResourceReference of the owner func (rule *ServersVirtualNetworkRule) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(rule.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: rule.Spec.Owner.Name, - } + return rule.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/sql/v1api20211101storage/servers_vulnerability_assessment_types_gen.go b/v2/api/sql/v1api20211101storage/servers_vulnerability_assessment_types_gen.go index 50c70d22485..0ee2055cd3e 100644 --- a/v2/api/sql/v1api20211101storage/servers_vulnerability_assessment_types_gen.go +++ b/v2/api/sql/v1api20211101storage/servers_vulnerability_assessment_types_gen.go @@ -84,11 +84,7 @@ func (assessment *ServersVulnerabilityAssessment) NewEmptyStatus() genruntime.Co // Owner returns the ResourceReference of the owner func (assessment *ServersVulnerabilityAssessment) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(assessment.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: assessment.Spec.Owner.Name, - } + return assessment.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/storage/v1api20210401/storage_account_types_gen.go b/v2/api/storage/v1api20210401/storage_account_types_gen.go index 55a2b2a8bb7..33b68dc2135 100644 --- a/v2/api/storage/v1api20210401/storage_account_types_gen.go +++ b/v2/api/storage/v1api20210401/storage_account_types_gen.go @@ -203,11 +203,7 @@ func (account *StorageAccount) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (account *StorageAccount) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(account.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: account.Spec.Owner.Name, - } + return account.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -265,7 +261,7 @@ func (account *StorageAccount) ValidateUpdate(old runtime.Object) (admission.War // createValidations validates the creation of the resource func (account *StorageAccount) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){account.validateResourceReferences, account.validateSecretDestinations, account.validateConfigMapDestinations} + return []func() (admission.Warnings, error){account.validateResourceReferences, account.validateOwnerReference, account.validateSecretDestinations, account.validateConfigMapDestinations} } // deleteValidations validates the deletion of the resource @@ -280,6 +276,9 @@ func (account *StorageAccount) updateValidations() []func(old runtime.Object) (a return account.validateResourceReferences() }, account.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return account.validateOwnerReference() + }, func(old runtime.Object) (admission.Warnings, error) { return account.validateSecretDestinations() }, @@ -308,6 +307,11 @@ func (account *StorageAccount) validateConfigMapDestinations() (admission.Warnin return genruntime.ValidateConfigMapDestinations(toValidate) } +// validateOwnerReference validates the owner field +func (account *StorageAccount) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(account) +} + // validateResourceReferences validates all resource references func (account *StorageAccount) validateResourceReferences() (admission.Warnings, error) { refs, err := reflecthelpers.FindResourceReferences(&account.Spec) @@ -894,7 +898,10 @@ func (account *StorageAccount_Spec) PopulateFromARM(owner genruntime.ArbitraryOw // no assignment for property "OperatorSpec" // Set property "Owner": - account.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + account.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "RoutingPreference": // copying flattened property: diff --git a/v2/api/storage/v1api20210401/storage_accounts_blob_service_types_gen.go b/v2/api/storage/v1api20210401/storage_accounts_blob_service_types_gen.go index cec0368229f..7f04cb3197e 100644 --- a/v2/api/storage/v1api20210401/storage_accounts_blob_service_types_gen.go +++ b/v2/api/storage/v1api20210401/storage_accounts_blob_service_types_gen.go @@ -137,11 +137,7 @@ func (service *StorageAccountsBlobService) NewEmptyStatus() genruntime.Convertib // Owner returns the ResourceReference of the owner func (service *StorageAccountsBlobService) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(service.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: service.Spec.Owner.Name, - } + return service.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -199,7 +195,7 @@ func (service *StorageAccountsBlobService) ValidateUpdate(old runtime.Object) (a // createValidations validates the creation of the resource func (service *StorageAccountsBlobService) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){service.validateResourceReferences} + return []func() (admission.Warnings, error){service.validateResourceReferences, service.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -213,7 +209,16 @@ func (service *StorageAccountsBlobService) updateValidations() []func(old runtim func(old runtime.Object) (admission.Warnings, error) { return service.validateResourceReferences() }, - service.validateWriteOnceProperties} + service.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return service.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (service *StorageAccountsBlobService) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(service) } // validateResourceReferences validates all resource references @@ -541,7 +546,10 @@ func (service *StorageAccounts_BlobService_Spec) PopulateFromARM(owner genruntim } // Set property "Owner": - service.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + service.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "RestorePolicy": // copying flattened property: diff --git a/v2/api/storage/v1api20210401/storage_accounts_blob_services_container_types_gen.go b/v2/api/storage/v1api20210401/storage_accounts_blob_services_container_types_gen.go index 070361c011a..fc3afc8b805 100644 --- a/v2/api/storage/v1api20210401/storage_accounts_blob_services_container_types_gen.go +++ b/v2/api/storage/v1api20210401/storage_accounts_blob_services_container_types_gen.go @@ -144,11 +144,7 @@ func (container *StorageAccountsBlobServicesContainer) NewEmptyStatus() genrunti // Owner returns the ResourceReference of the owner func (container *StorageAccountsBlobServicesContainer) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(container.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: container.Spec.Owner.Name, - } + return container.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -206,7 +202,7 @@ func (container *StorageAccountsBlobServicesContainer) ValidateUpdate(old runtim // createValidations validates the creation of the resource func (container *StorageAccountsBlobServicesContainer) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){container.validateResourceReferences} + return []func() (admission.Warnings, error){container.validateResourceReferences, container.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -220,7 +216,16 @@ func (container *StorageAccountsBlobServicesContainer) updateValidations() []fun func(old runtime.Object) (admission.Warnings, error) { return container.validateResourceReferences() }, - container.validateWriteOnceProperties} + container.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return container.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (container *StorageAccountsBlobServicesContainer) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(container) } // validateResourceReferences validates all resource references @@ -451,7 +456,10 @@ func (container *StorageAccounts_BlobServices_Container_Spec) PopulateFromARM(ow } // Set property "Owner": - container.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + container.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "PublicAccess": // copying flattened property: diff --git a/v2/api/storage/v1api20210401/storage_accounts_management_policy_types_gen.go b/v2/api/storage/v1api20210401/storage_accounts_management_policy_types_gen.go index 5414195b1d4..722cec1bd73 100644 --- a/v2/api/storage/v1api20210401/storage_accounts_management_policy_types_gen.go +++ b/v2/api/storage/v1api20210401/storage_accounts_management_policy_types_gen.go @@ -137,11 +137,7 @@ func (policy *StorageAccountsManagementPolicy) NewEmptyStatus() genruntime.Conve // Owner returns the ResourceReference of the owner func (policy *StorageAccountsManagementPolicy) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(policy.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: policy.Spec.Owner.Name, - } + return policy.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -199,7 +195,7 @@ func (policy *StorageAccountsManagementPolicy) ValidateUpdate(old runtime.Object // createValidations validates the creation of the resource func (policy *StorageAccountsManagementPolicy) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){policy.validateResourceReferences} + return []func() (admission.Warnings, error){policy.validateResourceReferences, policy.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -213,7 +209,16 @@ func (policy *StorageAccountsManagementPolicy) updateValidations() []func(old ru func(old runtime.Object) (admission.Warnings, error) { return policy.validateResourceReferences() }, - policy.validateWriteOnceProperties} + policy.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return policy.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (policy *StorageAccountsManagementPolicy) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(policy) } // validateResourceReferences validates all resource references @@ -359,7 +364,10 @@ func (policy *StorageAccounts_ManagementPolicy_Spec) PopulateFromARM(owner genru } // Set property "Owner": - policy.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + policy.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "Policy": // copying flattened property: diff --git a/v2/api/storage/v1api20210401/storage_accounts_queue_service_types_gen.go b/v2/api/storage/v1api20210401/storage_accounts_queue_service_types_gen.go index 42385faf1ce..04d7e5808bd 100644 --- a/v2/api/storage/v1api20210401/storage_accounts_queue_service_types_gen.go +++ b/v2/api/storage/v1api20210401/storage_accounts_queue_service_types_gen.go @@ -137,11 +137,7 @@ func (service *StorageAccountsQueueService) NewEmptyStatus() genruntime.Converti // Owner returns the ResourceReference of the owner func (service *StorageAccountsQueueService) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(service.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: service.Spec.Owner.Name, - } + return service.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -199,7 +195,7 @@ func (service *StorageAccountsQueueService) ValidateUpdate(old runtime.Object) ( // createValidations validates the creation of the resource func (service *StorageAccountsQueueService) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){service.validateResourceReferences} + return []func() (admission.Warnings, error){service.validateResourceReferences, service.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -213,7 +209,16 @@ func (service *StorageAccountsQueueService) updateValidations() []func(old runti func(old runtime.Object) (admission.Warnings, error) { return service.validateResourceReferences() }, - service.validateWriteOnceProperties} + service.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return service.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (service *StorageAccountsQueueService) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(service) } // validateResourceReferences validates all resource references @@ -373,7 +378,10 @@ func (service *StorageAccounts_QueueService_Spec) PopulateFromARM(owner genrunti } // Set property "Owner": - service.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + service.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // No error return nil diff --git a/v2/api/storage/v1api20210401/storage_accounts_queue_services_queue_types_gen.go b/v2/api/storage/v1api20210401/storage_accounts_queue_services_queue_types_gen.go index 1944923c6d0..474c16135d9 100644 --- a/v2/api/storage/v1api20210401/storage_accounts_queue_services_queue_types_gen.go +++ b/v2/api/storage/v1api20210401/storage_accounts_queue_services_queue_types_gen.go @@ -144,11 +144,7 @@ func (queue *StorageAccountsQueueServicesQueue) NewEmptyStatus() genruntime.Conv // Owner returns the ResourceReference of the owner func (queue *StorageAccountsQueueServicesQueue) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(queue.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: queue.Spec.Owner.Name, - } + return queue.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -206,7 +202,7 @@ func (queue *StorageAccountsQueueServicesQueue) ValidateUpdate(old runtime.Objec // createValidations validates the creation of the resource func (queue *StorageAccountsQueueServicesQueue) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){queue.validateResourceReferences} + return []func() (admission.Warnings, error){queue.validateResourceReferences, queue.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -220,7 +216,16 @@ func (queue *StorageAccountsQueueServicesQueue) updateValidations() []func(old r func(old runtime.Object) (admission.Warnings, error) { return queue.validateResourceReferences() }, - queue.validateWriteOnceProperties} + queue.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return queue.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (queue *StorageAccountsQueueServicesQueue) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(queue) } // validateResourceReferences validates all resource references @@ -382,7 +387,10 @@ func (queue *StorageAccounts_QueueServices_Queue_Spec) PopulateFromARM(owner gen } // Set property "Owner": - queue.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + queue.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // No error return nil diff --git a/v2/api/storage/v1api20210401storage/storage_account_types_gen.go b/v2/api/storage/v1api20210401storage/storage_account_types_gen.go index 779b0225fd9..af86e4523d3 100644 --- a/v2/api/storage/v1api20210401storage/storage_account_types_gen.go +++ b/v2/api/storage/v1api20210401storage/storage_account_types_gen.go @@ -164,11 +164,7 @@ func (account *StorageAccount) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (account *StorageAccount) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(account.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: account.Spec.Owner.Name, - } + return account.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/storage/v1api20210401storage/storage_accounts_blob_service_types_gen.go b/v2/api/storage/v1api20210401storage/storage_accounts_blob_service_types_gen.go index 70324877fa1..1f48f610a6d 100644 --- a/v2/api/storage/v1api20210401storage/storage_accounts_blob_service_types_gen.go +++ b/v2/api/storage/v1api20210401storage/storage_accounts_blob_service_types_gen.go @@ -105,11 +105,7 @@ func (service *StorageAccountsBlobService) NewEmptyStatus() genruntime.Convertib // Owner returns the ResourceReference of the owner func (service *StorageAccountsBlobService) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(service.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: service.Spec.Owner.Name, - } + return service.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/storage/v1api20210401storage/storage_accounts_blob_services_container_types_gen.go b/v2/api/storage/v1api20210401storage/storage_accounts_blob_services_container_types_gen.go index 81916eb22b3..999077d2937 100644 --- a/v2/api/storage/v1api20210401storage/storage_accounts_blob_services_container_types_gen.go +++ b/v2/api/storage/v1api20210401storage/storage_accounts_blob_services_container_types_gen.go @@ -105,11 +105,7 @@ func (container *StorageAccountsBlobServicesContainer) NewEmptyStatus() genrunti // Owner returns the ResourceReference of the owner func (container *StorageAccountsBlobServicesContainer) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(container.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: container.Spec.Owner.Name, - } + return container.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/storage/v1api20210401storage/storage_accounts_management_policy_types_gen.go b/v2/api/storage/v1api20210401storage/storage_accounts_management_policy_types_gen.go index 83db020b2c5..73ecf233fbc 100644 --- a/v2/api/storage/v1api20210401storage/storage_accounts_management_policy_types_gen.go +++ b/v2/api/storage/v1api20210401storage/storage_accounts_management_policy_types_gen.go @@ -105,11 +105,7 @@ func (policy *StorageAccountsManagementPolicy) NewEmptyStatus() genruntime.Conve // Owner returns the ResourceReference of the owner func (policy *StorageAccountsManagementPolicy) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(policy.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: policy.Spec.Owner.Name, - } + return policy.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/storage/v1api20210401storage/storage_accounts_queue_service_types_gen.go b/v2/api/storage/v1api20210401storage/storage_accounts_queue_service_types_gen.go index 363eae29ea6..829731700bf 100644 --- a/v2/api/storage/v1api20210401storage/storage_accounts_queue_service_types_gen.go +++ b/v2/api/storage/v1api20210401storage/storage_accounts_queue_service_types_gen.go @@ -105,11 +105,7 @@ func (service *StorageAccountsQueueService) NewEmptyStatus() genruntime.Converti // Owner returns the ResourceReference of the owner func (service *StorageAccountsQueueService) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(service.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: service.Spec.Owner.Name, - } + return service.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/storage/v1api20210401storage/storage_accounts_queue_services_queue_types_gen.go b/v2/api/storage/v1api20210401storage/storage_accounts_queue_services_queue_types_gen.go index 0979d900cd1..d5823bc5aab 100644 --- a/v2/api/storage/v1api20210401storage/storage_accounts_queue_services_queue_types_gen.go +++ b/v2/api/storage/v1api20210401storage/storage_accounts_queue_services_queue_types_gen.go @@ -105,11 +105,7 @@ func (queue *StorageAccountsQueueServicesQueue) NewEmptyStatus() genruntime.Conv // Owner returns the ResourceReference of the owner func (queue *StorageAccountsQueueServicesQueue) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(queue.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: queue.Spec.Owner.Name, - } + return queue.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/storage/v1api20220901/storage_account_types_gen.go b/v2/api/storage/v1api20220901/storage_account_types_gen.go index 4a494921bd7..ecb69151568 100644 --- a/v2/api/storage/v1api20220901/storage_account_types_gen.go +++ b/v2/api/storage/v1api20220901/storage_account_types_gen.go @@ -200,11 +200,7 @@ func (account *StorageAccount) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (account *StorageAccount) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(account.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: account.Spec.Owner.Name, - } + return account.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -262,7 +258,7 @@ func (account *StorageAccount) ValidateUpdate(old runtime.Object) (admission.War // createValidations validates the creation of the resource func (account *StorageAccount) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){account.validateResourceReferences, account.validateSecretDestinations, account.validateConfigMapDestinations} + return []func() (admission.Warnings, error){account.validateResourceReferences, account.validateOwnerReference, account.validateSecretDestinations, account.validateConfigMapDestinations} } // deleteValidations validates the deletion of the resource @@ -277,6 +273,9 @@ func (account *StorageAccount) updateValidations() []func(old runtime.Object) (a return account.validateResourceReferences() }, account.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return account.validateOwnerReference() + }, func(old runtime.Object) (admission.Warnings, error) { return account.validateSecretDestinations() }, @@ -305,6 +304,11 @@ func (account *StorageAccount) validateConfigMapDestinations() (admission.Warnin return genruntime.ValidateConfigMapDestinations(toValidate) } +// validateOwnerReference validates the owner field +func (account *StorageAccount) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(account) +} + // validateResourceReferences validates all resource references func (account *StorageAccount) validateResourceReferences() (admission.Warnings, error) { refs, err := reflecthelpers.FindResourceReferences(&account.Spec) @@ -1017,7 +1021,10 @@ func (account *StorageAccount_Spec) PopulateFromARM(owner genruntime.ArbitraryOw // no assignment for property "OperatorSpec" // Set property "Owner": - account.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + account.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "PublicNetworkAccess": // copying flattened property: diff --git a/v2/api/storage/v1api20220901/storage_accounts_blob_service_types_gen.go b/v2/api/storage/v1api20220901/storage_accounts_blob_service_types_gen.go index 56b553610a9..8616e9f6140 100644 --- a/v2/api/storage/v1api20220901/storage_accounts_blob_service_types_gen.go +++ b/v2/api/storage/v1api20220901/storage_accounts_blob_service_types_gen.go @@ -134,11 +134,7 @@ func (service *StorageAccountsBlobService) NewEmptyStatus() genruntime.Convertib // Owner returns the ResourceReference of the owner func (service *StorageAccountsBlobService) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(service.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: service.Spec.Owner.Name, - } + return service.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -196,7 +192,7 @@ func (service *StorageAccountsBlobService) ValidateUpdate(old runtime.Object) (a // createValidations validates the creation of the resource func (service *StorageAccountsBlobService) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){service.validateResourceReferences} + return []func() (admission.Warnings, error){service.validateResourceReferences, service.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -210,7 +206,16 @@ func (service *StorageAccountsBlobService) updateValidations() []func(old runtim func(old runtime.Object) (admission.Warnings, error) { return service.validateResourceReferences() }, - service.validateWriteOnceProperties} + service.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return service.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (service *StorageAccountsBlobService) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(service) } // validateResourceReferences validates all resource references @@ -538,7 +543,10 @@ func (service *StorageAccounts_BlobService_Spec) PopulateFromARM(owner genruntim } // Set property "Owner": - service.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + service.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "RestorePolicy": // copying flattened property: diff --git a/v2/api/storage/v1api20220901/storage_accounts_blob_services_container_types_gen.go b/v2/api/storage/v1api20220901/storage_accounts_blob_services_container_types_gen.go index 10914b0d1f2..3b226ee0779 100644 --- a/v2/api/storage/v1api20220901/storage_accounts_blob_services_container_types_gen.go +++ b/v2/api/storage/v1api20220901/storage_accounts_blob_services_container_types_gen.go @@ -141,11 +141,7 @@ func (container *StorageAccountsBlobServicesContainer) NewEmptyStatus() genrunti // Owner returns the ResourceReference of the owner func (container *StorageAccountsBlobServicesContainer) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(container.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: container.Spec.Owner.Name, - } + return container.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -203,7 +199,7 @@ func (container *StorageAccountsBlobServicesContainer) ValidateUpdate(old runtim // createValidations validates the creation of the resource func (container *StorageAccountsBlobServicesContainer) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){container.validateResourceReferences} + return []func() (admission.Warnings, error){container.validateResourceReferences, container.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -217,7 +213,16 @@ func (container *StorageAccountsBlobServicesContainer) updateValidations() []fun func(old runtime.Object) (admission.Warnings, error) { return container.validateResourceReferences() }, - container.validateWriteOnceProperties} + container.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return container.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (container *StorageAccountsBlobServicesContainer) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(container) } // validateResourceReferences validates all resource references @@ -482,7 +487,10 @@ func (container *StorageAccounts_BlobServices_Container_Spec) PopulateFromARM(ow } // Set property "Owner": - container.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + container.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "PublicAccess": // copying flattened property: diff --git a/v2/api/storage/v1api20220901/storage_accounts_file_service_types_gen.go b/v2/api/storage/v1api20220901/storage_accounts_file_service_types_gen.go index 3f62fdd0e56..25ea1f58666 100644 --- a/v2/api/storage/v1api20220901/storage_accounts_file_service_types_gen.go +++ b/v2/api/storage/v1api20220901/storage_accounts_file_service_types_gen.go @@ -134,11 +134,7 @@ func (service *StorageAccountsFileService) NewEmptyStatus() genruntime.Convertib // Owner returns the ResourceReference of the owner func (service *StorageAccountsFileService) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(service.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: service.Spec.Owner.Name, - } + return service.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -196,7 +192,7 @@ func (service *StorageAccountsFileService) ValidateUpdate(old runtime.Object) (a // createValidations validates the creation of the resource func (service *StorageAccountsFileService) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){service.validateResourceReferences} + return []func() (admission.Warnings, error){service.validateResourceReferences, service.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -210,7 +206,16 @@ func (service *StorageAccountsFileService) updateValidations() []func(old runtim func(old runtime.Object) (admission.Warnings, error) { return service.validateResourceReferences() }, - service.validateWriteOnceProperties} + service.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return service.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (service *StorageAccountsFileService) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(service) } // validateResourceReferences validates all resource references @@ -394,7 +399,10 @@ func (service *StorageAccounts_FileService_Spec) PopulateFromARM(owner genruntim } // Set property "Owner": - service.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + service.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "ProtocolSettings": // copying flattened property: diff --git a/v2/api/storage/v1api20220901/storage_accounts_file_services_share_types_gen.go b/v2/api/storage/v1api20220901/storage_accounts_file_services_share_types_gen.go index ce739591242..0865f147f24 100644 --- a/v2/api/storage/v1api20220901/storage_accounts_file_services_share_types_gen.go +++ b/v2/api/storage/v1api20220901/storage_accounts_file_services_share_types_gen.go @@ -141,11 +141,7 @@ func (share *StorageAccountsFileServicesShare) NewEmptyStatus() genruntime.Conve // Owner returns the ResourceReference of the owner func (share *StorageAccountsFileServicesShare) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(share.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: share.Spec.Owner.Name, - } + return share.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -203,7 +199,7 @@ func (share *StorageAccountsFileServicesShare) ValidateUpdate(old runtime.Object // createValidations validates the creation of the resource func (share *StorageAccountsFileServicesShare) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){share.validateResourceReferences} + return []func() (admission.Warnings, error){share.validateResourceReferences, share.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -217,7 +213,16 @@ func (share *StorageAccountsFileServicesShare) updateValidations() []func(old ru func(old runtime.Object) (admission.Warnings, error) { return share.validateResourceReferences() }, - share.validateWriteOnceProperties} + share.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return share.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (share *StorageAccountsFileServicesShare) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(share) } // validateResourceReferences validates all resource references @@ -445,7 +450,10 @@ func (share *StorageAccounts_FileServices_Share_Spec) PopulateFromARM(owner genr } // Set property "Owner": - share.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + share.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "RootSquash": // copying flattened property: diff --git a/v2/api/storage/v1api20220901/storage_accounts_management_policy_types_gen.go b/v2/api/storage/v1api20220901/storage_accounts_management_policy_types_gen.go index 9c783ac0186..0257550256b 100644 --- a/v2/api/storage/v1api20220901/storage_accounts_management_policy_types_gen.go +++ b/v2/api/storage/v1api20220901/storage_accounts_management_policy_types_gen.go @@ -134,11 +134,7 @@ func (policy *StorageAccountsManagementPolicy) NewEmptyStatus() genruntime.Conve // Owner returns the ResourceReference of the owner func (policy *StorageAccountsManagementPolicy) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(policy.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: policy.Spec.Owner.Name, - } + return policy.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -196,7 +192,7 @@ func (policy *StorageAccountsManagementPolicy) ValidateUpdate(old runtime.Object // createValidations validates the creation of the resource func (policy *StorageAccountsManagementPolicy) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){policy.validateResourceReferences} + return []func() (admission.Warnings, error){policy.validateResourceReferences, policy.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -210,7 +206,16 @@ func (policy *StorageAccountsManagementPolicy) updateValidations() []func(old ru func(old runtime.Object) (admission.Warnings, error) { return policy.validateResourceReferences() }, - policy.validateWriteOnceProperties} + policy.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return policy.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (policy *StorageAccountsManagementPolicy) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(policy) } // validateResourceReferences validates all resource references @@ -356,7 +361,10 @@ func (policy *StorageAccounts_ManagementPolicy_Spec) PopulateFromARM(owner genru } // Set property "Owner": - policy.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + policy.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "Policy": // copying flattened property: diff --git a/v2/api/storage/v1api20220901/storage_accounts_queue_service_types_gen.go b/v2/api/storage/v1api20220901/storage_accounts_queue_service_types_gen.go index 006159ed8ef..cf87d7e7f4b 100644 --- a/v2/api/storage/v1api20220901/storage_accounts_queue_service_types_gen.go +++ b/v2/api/storage/v1api20220901/storage_accounts_queue_service_types_gen.go @@ -134,11 +134,7 @@ func (service *StorageAccountsQueueService) NewEmptyStatus() genruntime.Converti // Owner returns the ResourceReference of the owner func (service *StorageAccountsQueueService) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(service.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: service.Spec.Owner.Name, - } + return service.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -196,7 +192,7 @@ func (service *StorageAccountsQueueService) ValidateUpdate(old runtime.Object) ( // createValidations validates the creation of the resource func (service *StorageAccountsQueueService) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){service.validateResourceReferences} + return []func() (admission.Warnings, error){service.validateResourceReferences, service.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -210,7 +206,16 @@ func (service *StorageAccountsQueueService) updateValidations() []func(old runti func(old runtime.Object) (admission.Warnings, error) { return service.validateResourceReferences() }, - service.validateWriteOnceProperties} + service.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return service.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (service *StorageAccountsQueueService) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(service) } // validateResourceReferences validates all resource references @@ -370,7 +375,10 @@ func (service *StorageAccounts_QueueService_Spec) PopulateFromARM(owner genrunti } // Set property "Owner": - service.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + service.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // No error return nil diff --git a/v2/api/storage/v1api20220901/storage_accounts_queue_services_queue_types_gen.go b/v2/api/storage/v1api20220901/storage_accounts_queue_services_queue_types_gen.go index 2c5f545fd2a..6e06ce8ffe6 100644 --- a/v2/api/storage/v1api20220901/storage_accounts_queue_services_queue_types_gen.go +++ b/v2/api/storage/v1api20220901/storage_accounts_queue_services_queue_types_gen.go @@ -141,11 +141,7 @@ func (queue *StorageAccountsQueueServicesQueue) NewEmptyStatus() genruntime.Conv // Owner returns the ResourceReference of the owner func (queue *StorageAccountsQueueServicesQueue) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(queue.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: queue.Spec.Owner.Name, - } + return queue.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -203,7 +199,7 @@ func (queue *StorageAccountsQueueServicesQueue) ValidateUpdate(old runtime.Objec // createValidations validates the creation of the resource func (queue *StorageAccountsQueueServicesQueue) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){queue.validateResourceReferences} + return []func() (admission.Warnings, error){queue.validateResourceReferences, queue.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -217,7 +213,16 @@ func (queue *StorageAccountsQueueServicesQueue) updateValidations() []func(old r func(old runtime.Object) (admission.Warnings, error) { return queue.validateResourceReferences() }, - queue.validateWriteOnceProperties} + queue.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return queue.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (queue *StorageAccountsQueueServicesQueue) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(queue) } // validateResourceReferences validates all resource references @@ -379,7 +384,10 @@ func (queue *StorageAccounts_QueueServices_Queue_Spec) PopulateFromARM(owner gen } // Set property "Owner": - queue.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + queue.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // No error return nil diff --git a/v2/api/storage/v1api20220901/storage_accounts_table_service_types_gen.go b/v2/api/storage/v1api20220901/storage_accounts_table_service_types_gen.go index ae24fd87371..be588daddfb 100644 --- a/v2/api/storage/v1api20220901/storage_accounts_table_service_types_gen.go +++ b/v2/api/storage/v1api20220901/storage_accounts_table_service_types_gen.go @@ -134,11 +134,7 @@ func (service *StorageAccountsTableService) NewEmptyStatus() genruntime.Converti // Owner returns the ResourceReference of the owner func (service *StorageAccountsTableService) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(service.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: service.Spec.Owner.Name, - } + return service.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -196,7 +192,7 @@ func (service *StorageAccountsTableService) ValidateUpdate(old runtime.Object) ( // createValidations validates the creation of the resource func (service *StorageAccountsTableService) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){service.validateResourceReferences} + return []func() (admission.Warnings, error){service.validateResourceReferences, service.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -210,7 +206,16 @@ func (service *StorageAccountsTableService) updateValidations() []func(old runti func(old runtime.Object) (admission.Warnings, error) { return service.validateResourceReferences() }, - service.validateWriteOnceProperties} + service.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return service.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (service *StorageAccountsTableService) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(service) } // validateResourceReferences validates all resource references @@ -370,7 +375,10 @@ func (service *StorageAccounts_TableService_Spec) PopulateFromARM(owner genrunti } // Set property "Owner": - service.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + service.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // No error return nil diff --git a/v2/api/storage/v1api20220901/storage_accounts_table_services_table_types_gen.go b/v2/api/storage/v1api20220901/storage_accounts_table_services_table_types_gen.go index ec4d803b7ab..fdf63f7a452 100644 --- a/v2/api/storage/v1api20220901/storage_accounts_table_services_table_types_gen.go +++ b/v2/api/storage/v1api20220901/storage_accounts_table_services_table_types_gen.go @@ -141,11 +141,7 @@ func (table *StorageAccountsTableServicesTable) NewEmptyStatus() genruntime.Conv // Owner returns the ResourceReference of the owner func (table *StorageAccountsTableServicesTable) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(table.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: table.Spec.Owner.Name, - } + return table.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -203,7 +199,7 @@ func (table *StorageAccountsTableServicesTable) ValidateUpdate(old runtime.Objec // createValidations validates the creation of the resource func (table *StorageAccountsTableServicesTable) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){table.validateResourceReferences} + return []func() (admission.Warnings, error){table.validateResourceReferences, table.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -217,7 +213,16 @@ func (table *StorageAccountsTableServicesTable) updateValidations() []func(old r func(old runtime.Object) (admission.Warnings, error) { return table.validateResourceReferences() }, - table.validateWriteOnceProperties} + table.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return table.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (table *StorageAccountsTableServicesTable) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(table) } // validateResourceReferences validates all resource references @@ -370,7 +375,10 @@ func (table *StorageAccounts_TableServices_Table_Spec) PopulateFromARM(owner gen table.SetAzureName(genruntime.ExtractKubernetesResourceNameFromARMName(typedInput.Name)) // Set property "Owner": - table.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + table.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "SignedIdentifiers": // copying flattened property: diff --git a/v2/api/storage/v1api20220901storage/storage_account_types_gen.go b/v2/api/storage/v1api20220901storage/storage_account_types_gen.go index d80259f77d3..459d07d8a2b 100644 --- a/v2/api/storage/v1api20220901storage/storage_account_types_gen.go +++ b/v2/api/storage/v1api20220901storage/storage_account_types_gen.go @@ -143,11 +143,7 @@ func (account *StorageAccount) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (account *StorageAccount) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(account.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: account.Spec.Owner.Name, - } + return account.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/storage/v1api20220901storage/storage_accounts_blob_service_types_gen.go b/v2/api/storage/v1api20220901storage/storage_accounts_blob_service_types_gen.go index 4105ee08b5e..382ec408f98 100644 --- a/v2/api/storage/v1api20220901storage/storage_accounts_blob_service_types_gen.go +++ b/v2/api/storage/v1api20220901storage/storage_accounts_blob_service_types_gen.go @@ -84,11 +84,7 @@ func (service *StorageAccountsBlobService) NewEmptyStatus() genruntime.Convertib // Owner returns the ResourceReference of the owner func (service *StorageAccountsBlobService) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(service.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: service.Spec.Owner.Name, - } + return service.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/storage/v1api20220901storage/storage_accounts_blob_services_container_types_gen.go b/v2/api/storage/v1api20220901storage/storage_accounts_blob_services_container_types_gen.go index 673fd5894f6..b63ae1570df 100644 --- a/v2/api/storage/v1api20220901storage/storage_accounts_blob_services_container_types_gen.go +++ b/v2/api/storage/v1api20220901storage/storage_accounts_blob_services_container_types_gen.go @@ -84,11 +84,7 @@ func (container *StorageAccountsBlobServicesContainer) NewEmptyStatus() genrunti // Owner returns the ResourceReference of the owner func (container *StorageAccountsBlobServicesContainer) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(container.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: container.Spec.Owner.Name, - } + return container.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/storage/v1api20220901storage/storage_accounts_file_service_types_gen.go b/v2/api/storage/v1api20220901storage/storage_accounts_file_service_types_gen.go index 315812625c0..6ceef58d57b 100644 --- a/v2/api/storage/v1api20220901storage/storage_accounts_file_service_types_gen.go +++ b/v2/api/storage/v1api20220901storage/storage_accounts_file_service_types_gen.go @@ -84,11 +84,7 @@ func (service *StorageAccountsFileService) NewEmptyStatus() genruntime.Convertib // Owner returns the ResourceReference of the owner func (service *StorageAccountsFileService) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(service.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: service.Spec.Owner.Name, - } + return service.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/storage/v1api20220901storage/storage_accounts_file_services_share_types_gen.go b/v2/api/storage/v1api20220901storage/storage_accounts_file_services_share_types_gen.go index 60e13c4a392..f280ac0e20f 100644 --- a/v2/api/storage/v1api20220901storage/storage_accounts_file_services_share_types_gen.go +++ b/v2/api/storage/v1api20220901storage/storage_accounts_file_services_share_types_gen.go @@ -84,11 +84,7 @@ func (share *StorageAccountsFileServicesShare) NewEmptyStatus() genruntime.Conve // Owner returns the ResourceReference of the owner func (share *StorageAccountsFileServicesShare) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(share.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: share.Spec.Owner.Name, - } + return share.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/storage/v1api20220901storage/storage_accounts_management_policy_types_gen.go b/v2/api/storage/v1api20220901storage/storage_accounts_management_policy_types_gen.go index ae57fe8794c..274a6995ced 100644 --- a/v2/api/storage/v1api20220901storage/storage_accounts_management_policy_types_gen.go +++ b/v2/api/storage/v1api20220901storage/storage_accounts_management_policy_types_gen.go @@ -84,11 +84,7 @@ func (policy *StorageAccountsManagementPolicy) NewEmptyStatus() genruntime.Conve // Owner returns the ResourceReference of the owner func (policy *StorageAccountsManagementPolicy) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(policy.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: policy.Spec.Owner.Name, - } + return policy.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/storage/v1api20220901storage/storage_accounts_queue_service_types_gen.go b/v2/api/storage/v1api20220901storage/storage_accounts_queue_service_types_gen.go index 6441b96afb6..b56ec413ce3 100644 --- a/v2/api/storage/v1api20220901storage/storage_accounts_queue_service_types_gen.go +++ b/v2/api/storage/v1api20220901storage/storage_accounts_queue_service_types_gen.go @@ -84,11 +84,7 @@ func (service *StorageAccountsQueueService) NewEmptyStatus() genruntime.Converti // Owner returns the ResourceReference of the owner func (service *StorageAccountsQueueService) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(service.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: service.Spec.Owner.Name, - } + return service.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/storage/v1api20220901storage/storage_accounts_queue_services_queue_types_gen.go b/v2/api/storage/v1api20220901storage/storage_accounts_queue_services_queue_types_gen.go index aadba814aca..4ff90ad9394 100644 --- a/v2/api/storage/v1api20220901storage/storage_accounts_queue_services_queue_types_gen.go +++ b/v2/api/storage/v1api20220901storage/storage_accounts_queue_services_queue_types_gen.go @@ -84,11 +84,7 @@ func (queue *StorageAccountsQueueServicesQueue) NewEmptyStatus() genruntime.Conv // Owner returns the ResourceReference of the owner func (queue *StorageAccountsQueueServicesQueue) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(queue.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: queue.Spec.Owner.Name, - } + return queue.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/storage/v1api20220901storage/storage_accounts_table_service_types_gen.go b/v2/api/storage/v1api20220901storage/storage_accounts_table_service_types_gen.go index 673c4543f28..d1a4a0fde02 100644 --- a/v2/api/storage/v1api20220901storage/storage_accounts_table_service_types_gen.go +++ b/v2/api/storage/v1api20220901storage/storage_accounts_table_service_types_gen.go @@ -84,11 +84,7 @@ func (service *StorageAccountsTableService) NewEmptyStatus() genruntime.Converti // Owner returns the ResourceReference of the owner func (service *StorageAccountsTableService) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(service.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: service.Spec.Owner.Name, - } + return service.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/storage/v1api20220901storage/storage_accounts_table_services_table_types_gen.go b/v2/api/storage/v1api20220901storage/storage_accounts_table_services_table_types_gen.go index 1fcdf64b621..377ae4c2bd6 100644 --- a/v2/api/storage/v1api20220901storage/storage_accounts_table_services_table_types_gen.go +++ b/v2/api/storage/v1api20220901storage/storage_accounts_table_services_table_types_gen.go @@ -84,11 +84,7 @@ func (table *StorageAccountsTableServicesTable) NewEmptyStatus() genruntime.Conv // Owner returns the ResourceReference of the owner func (table *StorageAccountsTableServicesTable) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(table.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: table.Spec.Owner.Name, - } + return table.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/storage/v1beta20210401/storage_account_types_gen.go b/v2/api/storage/v1beta20210401/storage_account_types_gen.go index a4df2509b0c..0e91ae22c9b 100644 --- a/v2/api/storage/v1beta20210401/storage_account_types_gen.go +++ b/v2/api/storage/v1beta20210401/storage_account_types_gen.go @@ -201,11 +201,7 @@ func (account *StorageAccount) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (account *StorageAccount) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(account.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: account.Spec.Owner.Name, - } + return account.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -263,7 +259,7 @@ func (account *StorageAccount) ValidateUpdate(old runtime.Object) (admission.War // createValidations validates the creation of the resource func (account *StorageAccount) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){account.validateResourceReferences, account.validateSecretDestinations, account.validateConfigMapDestinations} + return []func() (admission.Warnings, error){account.validateResourceReferences, account.validateOwnerReference, account.validateSecretDestinations, account.validateConfigMapDestinations} } // deleteValidations validates the deletion of the resource @@ -278,6 +274,9 @@ func (account *StorageAccount) updateValidations() []func(old runtime.Object) (a return account.validateResourceReferences() }, account.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return account.validateOwnerReference() + }, func(old runtime.Object) (admission.Warnings, error) { return account.validateSecretDestinations() }, @@ -306,6 +305,11 @@ func (account *StorageAccount) validateConfigMapDestinations() (admission.Warnin return genruntime.ValidateConfigMapDestinations(toValidate) } +// validateOwnerReference validates the owner field +func (account *StorageAccount) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(account) +} + // validateResourceReferences validates all resource references func (account *StorageAccount) validateResourceReferences() (admission.Warnings, error) { refs, err := reflecthelpers.FindResourceReferences(&account.Spec) @@ -838,7 +842,10 @@ func (account *StorageAccount_Spec) PopulateFromARM(owner genruntime.ArbitraryOw // no assignment for property "OperatorSpec" // Set property "Owner": - account.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + account.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "RoutingPreference": // copying flattened property: diff --git a/v2/api/storage/v1beta20210401/storage_accounts_blob_service_types_gen.go b/v2/api/storage/v1beta20210401/storage_accounts_blob_service_types_gen.go index dfb703ac7f7..bfff896872b 100644 --- a/v2/api/storage/v1beta20210401/storage_accounts_blob_service_types_gen.go +++ b/v2/api/storage/v1beta20210401/storage_accounts_blob_service_types_gen.go @@ -135,11 +135,7 @@ func (service *StorageAccountsBlobService) NewEmptyStatus() genruntime.Convertib // Owner returns the ResourceReference of the owner func (service *StorageAccountsBlobService) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(service.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: service.Spec.Owner.Name, - } + return service.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -197,7 +193,7 @@ func (service *StorageAccountsBlobService) ValidateUpdate(old runtime.Object) (a // createValidations validates the creation of the resource func (service *StorageAccountsBlobService) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){service.validateResourceReferences} + return []func() (admission.Warnings, error){service.validateResourceReferences, service.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -211,7 +207,16 @@ func (service *StorageAccountsBlobService) updateValidations() []func(old runtim func(old runtime.Object) (admission.Warnings, error) { return service.validateResourceReferences() }, - service.validateWriteOnceProperties} + service.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return service.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (service *StorageAccountsBlobService) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(service) } // validateResourceReferences validates all resource references @@ -517,7 +522,10 @@ func (service *StorageAccounts_BlobService_Spec) PopulateFromARM(owner genruntim } // Set property "Owner": - service.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + service.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "RestorePolicy": // copying flattened property: diff --git a/v2/api/storage/v1beta20210401/storage_accounts_blob_services_container_types_gen.go b/v2/api/storage/v1beta20210401/storage_accounts_blob_services_container_types_gen.go index 372622a352a..979c2b75bae 100644 --- a/v2/api/storage/v1beta20210401/storage_accounts_blob_services_container_types_gen.go +++ b/v2/api/storage/v1beta20210401/storage_accounts_blob_services_container_types_gen.go @@ -142,11 +142,7 @@ func (container *StorageAccountsBlobServicesContainer) NewEmptyStatus() genrunti // Owner returns the ResourceReference of the owner func (container *StorageAccountsBlobServicesContainer) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(container.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: container.Spec.Owner.Name, - } + return container.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -204,7 +200,7 @@ func (container *StorageAccountsBlobServicesContainer) ValidateUpdate(old runtim // createValidations validates the creation of the resource func (container *StorageAccountsBlobServicesContainer) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){container.validateResourceReferences} + return []func() (admission.Warnings, error){container.validateResourceReferences, container.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -218,7 +214,16 @@ func (container *StorageAccountsBlobServicesContainer) updateValidations() []fun func(old runtime.Object) (admission.Warnings, error) { return container.validateResourceReferences() }, - container.validateWriteOnceProperties} + container.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return container.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (container *StorageAccountsBlobServicesContainer) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(container) } // validateResourceReferences validates all resource references @@ -436,7 +441,10 @@ func (container *StorageAccounts_BlobServices_Container_Spec) PopulateFromARM(ow } // Set property "Owner": - container.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + container.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "PublicAccess": // copying flattened property: diff --git a/v2/api/storage/v1beta20210401/storage_accounts_management_policy_types_gen.go b/v2/api/storage/v1beta20210401/storage_accounts_management_policy_types_gen.go index 1857931650e..1b93a3fcf43 100644 --- a/v2/api/storage/v1beta20210401/storage_accounts_management_policy_types_gen.go +++ b/v2/api/storage/v1beta20210401/storage_accounts_management_policy_types_gen.go @@ -135,11 +135,7 @@ func (policy *StorageAccountsManagementPolicy) NewEmptyStatus() genruntime.Conve // Owner returns the ResourceReference of the owner func (policy *StorageAccountsManagementPolicy) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(policy.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: policy.Spec.Owner.Name, - } + return policy.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -197,7 +193,7 @@ func (policy *StorageAccountsManagementPolicy) ValidateUpdate(old runtime.Object // createValidations validates the creation of the resource func (policy *StorageAccountsManagementPolicy) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){policy.validateResourceReferences} + return []func() (admission.Warnings, error){policy.validateResourceReferences, policy.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -211,7 +207,16 @@ func (policy *StorageAccountsManagementPolicy) updateValidations() []func(old ru func(old runtime.Object) (admission.Warnings, error) { return policy.validateResourceReferences() }, - policy.validateWriteOnceProperties} + policy.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return policy.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (policy *StorageAccountsManagementPolicy) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(policy) } // validateResourceReferences validates all resource references @@ -353,7 +358,10 @@ func (policy *StorageAccounts_ManagementPolicy_Spec) PopulateFromARM(owner genru } // Set property "Owner": - policy.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + policy.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "Policy": // copying flattened property: diff --git a/v2/api/storage/v1beta20210401/storage_accounts_queue_service_types_gen.go b/v2/api/storage/v1beta20210401/storage_accounts_queue_service_types_gen.go index 3458b30bb73..75bfaf1e817 100644 --- a/v2/api/storage/v1beta20210401/storage_accounts_queue_service_types_gen.go +++ b/v2/api/storage/v1beta20210401/storage_accounts_queue_service_types_gen.go @@ -135,11 +135,7 @@ func (service *StorageAccountsQueueService) NewEmptyStatus() genruntime.Converti // Owner returns the ResourceReference of the owner func (service *StorageAccountsQueueService) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(service.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: service.Spec.Owner.Name, - } + return service.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -197,7 +193,7 @@ func (service *StorageAccountsQueueService) ValidateUpdate(old runtime.Object) ( // createValidations validates the creation of the resource func (service *StorageAccountsQueueService) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){service.validateResourceReferences} + return []func() (admission.Warnings, error){service.validateResourceReferences, service.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -211,7 +207,16 @@ func (service *StorageAccountsQueueService) updateValidations() []func(old runti func(old runtime.Object) (admission.Warnings, error) { return service.validateResourceReferences() }, - service.validateWriteOnceProperties} + service.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return service.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (service *StorageAccountsQueueService) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(service) } // validateResourceReferences validates all resource references @@ -366,7 +371,10 @@ func (service *StorageAccounts_QueueService_Spec) PopulateFromARM(owner genrunti } // Set property "Owner": - service.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + service.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // No error return nil diff --git a/v2/api/storage/v1beta20210401/storage_accounts_queue_services_queue_types_gen.go b/v2/api/storage/v1beta20210401/storage_accounts_queue_services_queue_types_gen.go index 93d24ed3aae..d2f5b25416c 100644 --- a/v2/api/storage/v1beta20210401/storage_accounts_queue_services_queue_types_gen.go +++ b/v2/api/storage/v1beta20210401/storage_accounts_queue_services_queue_types_gen.go @@ -142,11 +142,7 @@ func (queue *StorageAccountsQueueServicesQueue) NewEmptyStatus() genruntime.Conv // Owner returns the ResourceReference of the owner func (queue *StorageAccountsQueueServicesQueue) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(queue.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: queue.Spec.Owner.Name, - } + return queue.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -204,7 +200,7 @@ func (queue *StorageAccountsQueueServicesQueue) ValidateUpdate(old runtime.Objec // createValidations validates the creation of the resource func (queue *StorageAccountsQueueServicesQueue) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){queue.validateResourceReferences} + return []func() (admission.Warnings, error){queue.validateResourceReferences, queue.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -218,7 +214,16 @@ func (queue *StorageAccountsQueueServicesQueue) updateValidations() []func(old r func(old runtime.Object) (admission.Warnings, error) { return queue.validateResourceReferences() }, - queue.validateWriteOnceProperties} + queue.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return queue.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (queue *StorageAccountsQueueServicesQueue) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(queue) } // validateResourceReferences validates all resource references @@ -376,7 +381,10 @@ func (queue *StorageAccounts_QueueServices_Queue_Spec) PopulateFromARM(owner gen } // Set property "Owner": - queue.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + queue.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // No error return nil diff --git a/v2/api/storage/v1beta20210401storage/storage_account_types_gen.go b/v2/api/storage/v1beta20210401storage/storage_account_types_gen.go index 1463ef8afdf..327e5da8756 100644 --- a/v2/api/storage/v1beta20210401storage/storage_account_types_gen.go +++ b/v2/api/storage/v1beta20210401storage/storage_account_types_gen.go @@ -175,11 +175,7 @@ func (account *StorageAccount) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (account *StorageAccount) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(account.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: account.Spec.Owner.Name, - } + return account.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/storage/v1beta20210401storage/storage_accounts_blob_service_types_gen.go b/v2/api/storage/v1beta20210401storage/storage_accounts_blob_service_types_gen.go index a0fe7271664..0e880e30abf 100644 --- a/v2/api/storage/v1beta20210401storage/storage_accounts_blob_service_types_gen.go +++ b/v2/api/storage/v1beta20210401storage/storage_accounts_blob_service_types_gen.go @@ -116,11 +116,7 @@ func (service *StorageAccountsBlobService) NewEmptyStatus() genruntime.Convertib // Owner returns the ResourceReference of the owner func (service *StorageAccountsBlobService) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(service.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: service.Spec.Owner.Name, - } + return service.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/storage/v1beta20210401storage/storage_accounts_blob_services_container_types_gen.go b/v2/api/storage/v1beta20210401storage/storage_accounts_blob_services_container_types_gen.go index 731073df2a9..cefab7e9564 100644 --- a/v2/api/storage/v1beta20210401storage/storage_accounts_blob_services_container_types_gen.go +++ b/v2/api/storage/v1beta20210401storage/storage_accounts_blob_services_container_types_gen.go @@ -116,11 +116,7 @@ func (container *StorageAccountsBlobServicesContainer) NewEmptyStatus() genrunti // Owner returns the ResourceReference of the owner func (container *StorageAccountsBlobServicesContainer) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(container.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: container.Spec.Owner.Name, - } + return container.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/storage/v1beta20210401storage/storage_accounts_management_policy_types_gen.go b/v2/api/storage/v1beta20210401storage/storage_accounts_management_policy_types_gen.go index 719b6678483..eb0e226feda 100644 --- a/v2/api/storage/v1beta20210401storage/storage_accounts_management_policy_types_gen.go +++ b/v2/api/storage/v1beta20210401storage/storage_accounts_management_policy_types_gen.go @@ -116,11 +116,7 @@ func (policy *StorageAccountsManagementPolicy) NewEmptyStatus() genruntime.Conve // Owner returns the ResourceReference of the owner func (policy *StorageAccountsManagementPolicy) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(policy.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: policy.Spec.Owner.Name, - } + return policy.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/storage/v1beta20210401storage/storage_accounts_queue_service_types_gen.go b/v2/api/storage/v1beta20210401storage/storage_accounts_queue_service_types_gen.go index 8defcd6f5cd..be676c01ec2 100644 --- a/v2/api/storage/v1beta20210401storage/storage_accounts_queue_service_types_gen.go +++ b/v2/api/storage/v1beta20210401storage/storage_accounts_queue_service_types_gen.go @@ -116,11 +116,7 @@ func (service *StorageAccountsQueueService) NewEmptyStatus() genruntime.Converti // Owner returns the ResourceReference of the owner func (service *StorageAccountsQueueService) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(service.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: service.Spec.Owner.Name, - } + return service.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/storage/v1beta20210401storage/storage_accounts_queue_services_queue_types_gen.go b/v2/api/storage/v1beta20210401storage/storage_accounts_queue_services_queue_types_gen.go index a5541443a0f..e759d91eb2c 100644 --- a/v2/api/storage/v1beta20210401storage/storage_accounts_queue_services_queue_types_gen.go +++ b/v2/api/storage/v1beta20210401storage/storage_accounts_queue_services_queue_types_gen.go @@ -116,11 +116,7 @@ func (queue *StorageAccountsQueueServicesQueue) NewEmptyStatus() genruntime.Conv // Owner returns the ResourceReference of the owner func (queue *StorageAccountsQueueServicesQueue) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(queue.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: queue.Spec.Owner.Name, - } + return queue.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/synapse/v1api20210601/workspace_types_gen.go b/v2/api/synapse/v1api20210601/workspace_types_gen.go index 58a6574ca33..ed65a064b5f 100644 --- a/v2/api/synapse/v1api20210601/workspace_types_gen.go +++ b/v2/api/synapse/v1api20210601/workspace_types_gen.go @@ -142,11 +142,7 @@ func (workspace *Workspace) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (workspace *Workspace) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(workspace.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: workspace.Spec.Owner.Name, - } + return workspace.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -204,7 +200,7 @@ func (workspace *Workspace) ValidateUpdate(old runtime.Object) (admission.Warnin // createValidations validates the creation of the resource func (workspace *Workspace) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){workspace.validateResourceReferences, workspace.validateOptionalConfigMapReferences} + return []func() (admission.Warnings, error){workspace.validateResourceReferences, workspace.validateOwnerReference, workspace.validateOptionalConfigMapReferences} } // deleteValidations validates the deletion of the resource @@ -219,6 +215,9 @@ func (workspace *Workspace) updateValidations() []func(old runtime.Object) (admi return workspace.validateResourceReferences() }, workspace.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return workspace.validateOwnerReference() + }, func(old runtime.Object) (admission.Warnings, error) { return workspace.validateOptionalConfigMapReferences() }, @@ -234,6 +233,11 @@ func (workspace *Workspace) validateOptionalConfigMapReferences() (admission.War return genruntime.ValidateOptionalConfigMapReferences(refs) } +// validateOwnerReference validates the owner field +func (workspace *Workspace) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(workspace) +} + // validateResourceReferences validates all resource references func (workspace *Workspace) validateResourceReferences() (admission.Warnings, error) { refs, err := reflecthelpers.FindResourceReferences(&workspace.Spec) @@ -656,7 +660,10 @@ func (workspace *Workspace_Spec) PopulateFromARM(owner genruntime.ArbitraryOwner } // Set property "Owner": - workspace.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + workspace.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "PublicNetworkAccess": // copying flattened property: diff --git a/v2/api/synapse/v1api20210601/workspaces_big_data_pool_types_gen.go b/v2/api/synapse/v1api20210601/workspaces_big_data_pool_types_gen.go index 15f5b9cd99b..2828a0d00d2 100644 --- a/v2/api/synapse/v1api20210601/workspaces_big_data_pool_types_gen.go +++ b/v2/api/synapse/v1api20210601/workspaces_big_data_pool_types_gen.go @@ -141,11 +141,7 @@ func (pool *WorkspacesBigDataPool) NewEmptyStatus() genruntime.ConvertibleStatus // Owner returns the ResourceReference of the owner func (pool *WorkspacesBigDataPool) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(pool.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: pool.Spec.Owner.Name, - } + return pool.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -203,7 +199,7 @@ func (pool *WorkspacesBigDataPool) ValidateUpdate(old runtime.Object) (admission // createValidations validates the creation of the resource func (pool *WorkspacesBigDataPool) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){pool.validateResourceReferences} + return []func() (admission.Warnings, error){pool.validateResourceReferences, pool.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -217,7 +213,16 @@ func (pool *WorkspacesBigDataPool) updateValidations() []func(old runtime.Object func(old runtime.Object) (admission.Warnings, error) { return pool.validateResourceReferences() }, - pool.validateWriteOnceProperties} + pool.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return pool.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (pool *WorkspacesBigDataPool) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(pool) } // validateResourceReferences validates all resource references @@ -657,7 +662,10 @@ func (pool *Workspaces_BigDataPool_Spec) PopulateFromARM(owner genruntime.Arbitr } // Set property "Owner": - pool.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + pool.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "ProvisioningState": // copying flattened property: diff --git a/v2/api/synapse/v1api20210601storage/workspace_types_gen.go b/v2/api/synapse/v1api20210601storage/workspace_types_gen.go index 72aad2ac194..96aa3413ac8 100644 --- a/v2/api/synapse/v1api20210601storage/workspace_types_gen.go +++ b/v2/api/synapse/v1api20210601storage/workspace_types_gen.go @@ -85,11 +85,7 @@ func (workspace *Workspace) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (workspace *Workspace) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(workspace.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: workspace.Spec.Owner.Name, - } + return workspace.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/synapse/v1api20210601storage/workspaces_big_data_pool_types_gen.go b/v2/api/synapse/v1api20210601storage/workspaces_big_data_pool_types_gen.go index daacb933441..4ecf22d70c1 100644 --- a/v2/api/synapse/v1api20210601storage/workspaces_big_data_pool_types_gen.go +++ b/v2/api/synapse/v1api20210601storage/workspaces_big_data_pool_types_gen.go @@ -84,11 +84,7 @@ func (pool *WorkspacesBigDataPool) NewEmptyStatus() genruntime.ConvertibleStatus // Owner returns the ResourceReference of the owner func (pool *WorkspacesBigDataPool) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(pool.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: pool.Spec.Owner.Name, - } + return pool.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/web/v1api20220301/server_farm_types_gen.go b/v2/api/web/v1api20220301/server_farm_types_gen.go index 274a075ab83..f3bbd5ff37c 100644 --- a/v2/api/web/v1api20220301/server_farm_types_gen.go +++ b/v2/api/web/v1api20220301/server_farm_types_gen.go @@ -141,11 +141,7 @@ func (farm *ServerFarm) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (farm *ServerFarm) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(farm.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: farm.Spec.Owner.Name, - } + return farm.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -203,7 +199,7 @@ func (farm *ServerFarm) ValidateUpdate(old runtime.Object) (admission.Warnings, // createValidations validates the creation of the resource func (farm *ServerFarm) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){farm.validateResourceReferences} + return []func() (admission.Warnings, error){farm.validateResourceReferences, farm.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -217,7 +213,16 @@ func (farm *ServerFarm) updateValidations() []func(old runtime.Object) (admissio func(old runtime.Object) (admission.Warnings, error) { return farm.validateResourceReferences() }, - farm.validateWriteOnceProperties} + farm.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return farm.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (farm *ServerFarm) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(farm) } // validateResourceReferences validates all resource references @@ -653,7 +658,10 @@ func (serverfarm *Serverfarm_Spec) PopulateFromARM(owner genruntime.ArbitraryOwn } // Set property "Owner": - serverfarm.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + serverfarm.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "PerSiteScaling": // copying flattened property: diff --git a/v2/api/web/v1api20220301/site_types_gen.go b/v2/api/web/v1api20220301/site_types_gen.go index 4aa103b73ab..9ca2e79706d 100644 --- a/v2/api/web/v1api20220301/site_types_gen.go +++ b/v2/api/web/v1api20220301/site_types_gen.go @@ -141,11 +141,7 @@ func (site *Site) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (site *Site) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(site.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: site.Spec.Owner.Name, - } + return site.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -203,7 +199,7 @@ func (site *Site) ValidateUpdate(old runtime.Object) (admission.Warnings, error) // createValidations validates the creation of the resource func (site *Site) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){site.validateResourceReferences} + return []func() (admission.Warnings, error){site.validateResourceReferences, site.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -217,7 +213,16 @@ func (site *Site) updateValidations() []func(old runtime.Object) (admission.Warn func(old runtime.Object) (admission.Warnings, error) { return site.validateResourceReferences() }, - site.validateWriteOnceProperties} + site.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return site.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (site *Site) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(site) } // validateResourceReferences validates all resource references @@ -859,7 +864,10 @@ func (site *Site_Spec) PopulateFromARM(owner genruntime.ArbitraryOwnerReference, } // Set property "Owner": - site.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + site.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "PublicNetworkAccess": // copying flattened property: diff --git a/v2/api/web/v1api20220301storage/server_farm_types_gen.go b/v2/api/web/v1api20220301storage/server_farm_types_gen.go index 8e2b90b031e..c3f5a5ef0c8 100644 --- a/v2/api/web/v1api20220301storage/server_farm_types_gen.go +++ b/v2/api/web/v1api20220301storage/server_farm_types_gen.go @@ -84,11 +84,7 @@ func (farm *ServerFarm) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (farm *ServerFarm) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(farm.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: farm.Spec.Owner.Name, - } + return farm.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/web/v1api20220301storage/site_types_gen.go b/v2/api/web/v1api20220301storage/site_types_gen.go index 60650d5a1cf..fc4ef530373 100644 --- a/v2/api/web/v1api20220301storage/site_types_gen.go +++ b/v2/api/web/v1api20220301storage/site_types_gen.go @@ -84,11 +84,7 @@ func (site *Site) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (site *Site) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(site.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: site.Spec.Owner.Name, - } + return site.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/web/v1beta20220301/server_farm_types_gen.go b/v2/api/web/v1beta20220301/server_farm_types_gen.go index c9dbb33e9f4..764c2d7a36c 100644 --- a/v2/api/web/v1beta20220301/server_farm_types_gen.go +++ b/v2/api/web/v1beta20220301/server_farm_types_gen.go @@ -142,11 +142,7 @@ func (farm *ServerFarm) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (farm *ServerFarm) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(farm.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: farm.Spec.Owner.Name, - } + return farm.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -204,7 +200,7 @@ func (farm *ServerFarm) ValidateUpdate(old runtime.Object) (admission.Warnings, // createValidations validates the creation of the resource func (farm *ServerFarm) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){farm.validateResourceReferences} + return []func() (admission.Warnings, error){farm.validateResourceReferences, farm.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -218,7 +214,16 @@ func (farm *ServerFarm) updateValidations() []func(old runtime.Object) (admissio func(old runtime.Object) (admission.Warnings, error) { return farm.validateResourceReferences() }, - farm.validateWriteOnceProperties} + farm.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return farm.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (farm *ServerFarm) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(farm) } // validateResourceReferences validates all resource references @@ -611,7 +616,10 @@ func (serverfarm *Serverfarm_Spec) PopulateFromARM(owner genruntime.ArbitraryOwn } // Set property "Owner": - serverfarm.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + serverfarm.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "PerSiteScaling": // copying flattened property: diff --git a/v2/api/web/v1beta20220301/site_types_gen.go b/v2/api/web/v1beta20220301/site_types_gen.go index 14dc649bb9e..0a6a3218d2a 100644 --- a/v2/api/web/v1beta20220301/site_types_gen.go +++ b/v2/api/web/v1beta20220301/site_types_gen.go @@ -142,11 +142,7 @@ func (site *Site) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (site *Site) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(site.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: site.Spec.Owner.Name, - } + return site.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource @@ -204,7 +200,7 @@ func (site *Site) ValidateUpdate(old runtime.Object) (admission.Warnings, error) // createValidations validates the creation of the resource func (site *Site) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){site.validateResourceReferences} + return []func() (admission.Warnings, error){site.validateResourceReferences, site.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -218,7 +214,16 @@ func (site *Site) updateValidations() []func(old runtime.Object) (admission.Warn func(old runtime.Object) (admission.Warnings, error) { return site.validateResourceReferences() }, - site.validateWriteOnceProperties} + site.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return site.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (site *Site) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(site) } // validateResourceReferences validates all resource references @@ -779,7 +784,10 @@ func (site *Site_Spec) PopulateFromARM(owner genruntime.ArbitraryOwnerReference, } // Set property "Owner": - site.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + site.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "PublicNetworkAccess": // copying flattened property: diff --git a/v2/api/web/v1beta20220301storage/server_farm_types_gen.go b/v2/api/web/v1beta20220301storage/server_farm_types_gen.go index 96fce980b15..ec93f575a26 100644 --- a/v2/api/web/v1beta20220301storage/server_farm_types_gen.go +++ b/v2/api/web/v1beta20220301storage/server_farm_types_gen.go @@ -103,11 +103,7 @@ func (farm *ServerFarm) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (farm *ServerFarm) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(farm.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: farm.Spec.Owner.Name, - } + return farm.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/api/web/v1beta20220301storage/site_types_gen.go b/v2/api/web/v1beta20220301storage/site_types_gen.go index 0b255d76923..420739ca768 100644 --- a/v2/api/web/v1beta20220301storage/site_types_gen.go +++ b/v2/api/web/v1beta20220301storage/site_types_gen.go @@ -103,11 +103,7 @@ func (site *Site) NewEmptyStatus() genruntime.ConvertibleStatus { // Owner returns the ResourceReference of the owner func (site *Site) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(site.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: site.Spec.Owner.Name, - } + return site.Spec.Owner.AsResourceReference(group, kind) } // SetStatus sets the status of this resource diff --git a/v2/internal/controllers/crd_storage_storageaccount_20220901_test.go b/v2/internal/controllers/crd_storage_storageaccount_20220901_test.go index 39562e8e0c1..f3aa4928287 100644 --- a/v2/internal/controllers/crd_storage_storageaccount_20220901_test.go +++ b/v2/internal/controllers/crd_storage_storageaccount_20220901_test.go @@ -375,20 +375,17 @@ func StorageAccount_ManagementPolicy_CRUD(tc *testcommon.KubePerTestContext, blo func newStorageAccount20220901(tc *testcommon.KubePerTestContext, rg *resources.ResourceGroup) *storage.StorageAccount { // Create a storage account - accessTier := storage.StorageAccountPropertiesCreateParameters_AccessTier_Hot - kind := storage.StorageAccount_Kind_Spec_StorageV2 - sku := storage.SkuName_Standard_LRS acct := &storage.StorageAccount{ ObjectMeta: tc.MakeObjectMetaWithName(tc.NoSpaceNamer.GenerateName("stor")), Spec: storage.StorageAccount_Spec{ Location: tc.AzureRegion, Owner: testcommon.AsOwner(rg), - Kind: &kind, + Kind: to.Ptr(storage.StorageAccount_Kind_Spec_StorageV2), Sku: &storage.Sku{ - Name: &sku, + Name: to.Ptr(storage.SkuName_Standard_LRS), }, // TODO: They mark this property as optional but actually it is required - AccessTier: &accessTier, + AccessTier: to.Ptr(storage.StorageAccountPropertiesCreateParameters_AccessTier_Hot), }, } return acct diff --git a/v2/internal/controllers/owner_arm_id_negative_test.go b/v2/internal/controllers/owner_arm_id_negative_test.go new file mode 100644 index 00000000000..b4e6a07034d --- /dev/null +++ b/v2/internal/controllers/owner_arm_id_negative_test.go @@ -0,0 +1,89 @@ +/* +Copyright (c) Microsoft Corporation. +Licensed under the MIT license. +*/ + +package controllers_test + +import ( + "fmt" + "testing" + + . "github.com/onsi/gomega" + + "github.com/Azure/azure-service-operator/v2/internal/testcommon" + "github.com/Azure/azure-service-operator/v2/pkg/common/annotations" +) + +func Test_OwnerIsARMIDSetWithName_Rejected(t *testing.T) { + t.Parallel() + tc := globalTestContext.ForTest(t) + + // Create a resource group + rg := tc.CreateTestResourceGroupAndWait() + + // Get the rg's ARM ID + tc.Expect(rg.Status.Id).ToNot(BeNil()) + armID := *rg.Status.Id + + // Now create a storage account + acct := newStorageAccount20220901(tc, rg) + acct.Spec.Owner.ARMID = armID + + // Create the storage account from ARM ID + err := tc.CreateResourceExpectRequestFailure(acct) + tc.Expect(err).To(MatchError(ContainSubstring("the 'ARMID' field is mutually exclusive with 'Group', 'Kind', 'Namespace', and 'Name'"))) +} + +func Test_OwnerIsARMIDOfWrongType_Rejected(t *testing.T) { + t.Parallel() + tc := globalTestContext.ForTest(t) + + // Create a resource group + rg := tc.CreateTestResourceGroupAndWait() + badARMID := fmt.Sprintf("/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Compute/virtualMachines/myvm", tc.AzureSubscription, "nonexistrg") + + // Now create a storage account + acct := newStorageAccount20220901(tc, rg) + acct.Spec.Owner = testcommon.AsARMIDOwner(badARMID) + + // Create the storage account from ARM ID + err := tc.CreateResourceExpectRequestFailure(acct) + tc.Expect(err).To(MatchError(ContainSubstring("expected owner ARM ID to be for a resource group, but was \"Microsoft.Compute/virtualMachines\""))) +} + +func Test_OwnerIsARMIDFromDifferentSubscription_ResourceFails(t *testing.T) { + t.Parallel() + tc := globalTestContext.ForTest(t) + + cfg, err := testcommon.ReadFromEnvironmentForTest() + tc.Expect(err).ToNot(HaveOccurred()) + + // Create a resource group + rg := tc.CreateTestResourceGroupAndWait() + + // Get the rg's ARM ID + tc.Expect(rg.Status.Id).ToNot(BeNil()) + armID := *rg.Status.Id + + scopedCredentialName := "other-subscription-secret" + + // Now create a storage account + acct := newStorageAccount20220901(tc, rg) + acct.Spec.Owner = testcommon.AsARMIDOwner(armID) + acct.Annotations = map[string]string{annotations.PerResourceSecret: scopedCredentialName} + + uuid, err := tc.Namer.GenerateUUID() + tc.Expect(err).ToNot(HaveOccurred()) + + scopedCredentialSecret := testcommon.NewScopedServicePrincipalSecret( + uuid.String(), + tc.AzureTenant, + cfg.ClientID, + "1234", // We're not expecting to make it all the way to provision the resource, so it's OK to use a fake client secret here + scopedCredentialName, + tc.Namespace) + tc.CreateResource(scopedCredentialSecret) + + tc.CreateResourceAndWaitForFailure(acct) +} diff --git a/v2/internal/controllers/owner_arm_id_test.go b/v2/internal/controllers/owner_arm_id_test.go new file mode 100644 index 00000000000..40ffec1524d --- /dev/null +++ b/v2/internal/controllers/owner_arm_id_test.go @@ -0,0 +1,171 @@ +/* +Copyright (c) Microsoft Corporation. +Licensed under the MIT license. +*/ + +package controllers_test + +import ( + "fmt" + "testing" + + . "github.com/onsi/gomega" + + authorization "github.com/Azure/azure-service-operator/v2/api/authorization/v1api20200801preview" + managedidentity "github.com/Azure/azure-service-operator/v2/api/managedidentity/v1api20181130" + storage "github.com/Azure/azure-service-operator/v2/api/storage/v1api20220901" + "github.com/Azure/azure-service-operator/v2/internal/testcommon" + "github.com/Azure/azure-service-operator/v2/pkg/genruntime" +) + +func Test_OwnerIsARMIDOfResourceGroup_ResourceSuccessfullyReconciled(t *testing.T) { + t.Parallel() + tc := globalTestContext.ForTest(t) + + // Create a resource group + rg := tc.CreateTestResourceGroupAndWait() + + // Get the rg's ARM ID + tc.Expect(rg.Status.Id).ToNot(BeNil()) + armID := *rg.Status.Id + + // Now create a storage account + acct := newStorageAccount20220901(tc, rg) + acct.Spec.Owner = testcommon.AsARMIDOwner(armID) + + // Create the storage account from ARM ID + tc.CreateResourceAndWait(acct) + tc.Expect(acct.Status.Id).ToNot(BeNil()) + acctARMID := *acct.Status.Id + + // Update the storage account + old := acct.DeepCopy() + acct.Spec.Tags = map[string]string{"tag1": "value1"} + tc.PatchResourceAndWait(old, acct) + tc.Expect(acct.Status.Tags).To(HaveKey("tag1")) + + tc.DeleteResourceAndWait(acct) + + // Ensure that the account was really deleted in Azure + exists, _, err := tc.AzureClient.HeadByID( + tc.Ctx, + acctARMID, + string(storage.APIVersion_Value)) + tc.Expect(err).ToNot(HaveOccurred()) + tc.Expect(exists).To(BeFalse()) +} + +func Test_OwnerIsARMIDOfParent_ChildResourceSuccessfullyReconciled(t *testing.T) { + t.Parallel() + tc := globalTestContext.ForTest(t) + + // Create a resource group + rg := tc.CreateTestResourceGroupAndWait() + + // Now create a storage account + acct := newStorageAccount20220901(tc, rg) + tc.CreateResourceAndWait(acct) + + // and a blob service + blobService := &storage.StorageAccountsBlobService{ + ObjectMeta: tc.MakeObjectMeta("blobservice"), + Spec: storage.StorageAccounts_BlobService_Spec{ + Owner: testcommon.AsOwner(acct), + }, + } + tc.CreateResourceAndWait(blobService) + + tc.Expect(blobService.Status.Id).ToNot(BeNil()) + armID := *blobService.Status.Id + + blobContainer := &storage.StorageAccountsBlobServicesContainer{ + ObjectMeta: tc.MakeObjectMeta("container"), + Spec: storage.StorageAccounts_BlobServices_Container_Spec{ + Owner: testcommon.AsARMIDOwner(armID), + }, + } + tc.CreateResourceAndWait(blobContainer) + tc.Expect(blobContainer.Status.Id).ToNot(BeNil()) + containerARMID := *blobContainer.Status.Id + + // Update the container + old := blobContainer.DeepCopy() + blobContainer.Spec.Metadata = map[string]string{"tag1": "value1"} + tc.PatchResourceAndWait(old, blobContainer) + tc.Expect(blobContainer.Status.Metadata).To(HaveKey("tag1")) + + tc.DeleteResourceAndWait(blobContainer) + + // Ensure that the container was really deleted in Azure + exists, _, err := tc.AzureClient.HeadByID( + tc.Ctx, + containerARMID, + string(storage.APIVersion_Value)) + tc.Expect(err).ToNot(HaveOccurred()) + tc.Expect(exists).To(BeFalse()) +} + +func Test_OwnerIsARMID_ExtensionResourceSuccessfullyReconciled(t *testing.T) { + t.Parallel() + tc := globalTestContext.ForTest(t) + + // Create a resource group + rg := tc.CreateTestResourceGroupAndWait() + + configMapName := "my-configmap" + principalIdKey := "principalId" + + // Create a dummy managed identity which we will assign to a role + mi := &managedidentity.UserAssignedIdentity{ + ObjectMeta: tc.MakeObjectMeta("mi"), + Spec: managedidentity.UserAssignedIdentity_Spec{ + Location: tc.AzureRegion, + Owner: testcommon.AsOwner(rg), + OperatorSpec: &managedidentity.UserAssignedIdentityOperatorSpec{ + ConfigMaps: &managedidentity.UserAssignedIdentityOperatorConfigMaps{ + PrincipalId: &genruntime.ConfigMapDestination{ + Name: configMapName, + Key: principalIdKey, + }, + }, + }, + }, + } + + tc.CreateResourceAndWait(mi) + tc.Expect(mi.Status.TenantId).ToNot(BeNil()) + tc.Expect(mi.Status.PrincipalId).ToNot(BeNil()) + tc.Expect(mi.Status.Id).ToNot(BeNil()) + armID := *mi.Status.Id + + // Now assign a new role to that managed identity + roleAssignment := &authorization.RoleAssignment{ + ObjectMeta: tc.MakeObjectMeta("roleassignment"), + Spec: authorization.RoleAssignment_Spec{ + Owner: &genruntime.ArbitraryOwnerReference{ + ARMID: armID, + }, + PrincipalIdFromConfig: &genruntime.ConfigMapReference{ + Name: configMapName, + Key: principalIdKey, + }, + RoleDefinitionReference: &genruntime.ResourceReference{ + ARMID: fmt.Sprintf("/subscriptions/%s/providers/Microsoft.Authorization/roleDefinitions/b24988ac-6180-42a0-ab88-20f7382dd24c", tc.AzureSubscription), // This is contributor + }, + }, + } + tc.CreateResourceAndWait(roleAssignment) + + tc.Expect(roleAssignment.Status.Id).ToNot(BeNil()) + armId := *roleAssignment.Status.Id + + tc.DeleteResourceAndWait(roleAssignment) + + // Ensure that the role assignment was really deleted in Azure + exists, _, err := tc.AzureClient.HeadByID( + tc.Ctx, + armId, + string(authorization.APIVersion_Value)) + tc.Expect(err).ToNot(HaveOccurred()) + tc.Expect(exists).To(BeFalse()) +} diff --git a/v2/internal/controllers/recordings/Test_OwnerIsARMIDFromDifferentSubscription_ResourceFails.yaml b/v2/internal/controllers/recordings/Test_OwnerIsARMIDFromDifferentSubscription_ResourceFails.yaml new file mode 100644 index 00000000000..7fd5b2439ce --- /dev/null +++ b/v2/internal/controllers/recordings/Test_OwnerIsARMIDFromDifferentSubscription_ResourceFails.yaml @@ -0,0 +1,141 @@ +--- +version: 1 +interactions: +- request: + body: '{"location":"westus2","name":"asotest-rg-fnsbef","tags":{"CreatedAt":"2001-02-03T04:05:06Z"}}' + form: {} + headers: + Accept: + - application/json + Content-Length: + - "93" + Content-Type: + - application/json + Test-Request-Attempt: + - "0" + url: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/asotest-rg-fnsbef?api-version=2020-06-01 + method: PUT + response: + body: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/asotest-rg-fnsbef","name":"asotest-rg-fnsbef","type":"Microsoft.Resources/resourceGroups","location":"westus2","tags":{"CreatedAt":"2001-02-03T04:05:06Z"},"properties":{"provisioningState":"Succeeded"}}' + headers: + Cache-Control: + - no-cache + Content-Length: + - "276" + Content-Type: + - application/json; charset=utf-8 + Expires: + - "-1" + Pragma: + - no-cache + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + X-Cache: + - CONFIG_NOCACHE + X-Content-Type-Options: + - nosniff + X-Msedge-Ref: + - 'Ref A: 3E3991FF49934EC3B0B51744865B85D6 Ref B: CO6AA3150219031 Ref C: 2023-09-01T21:27:05Z' + status: 200 OK + code: 200 + duration: "" +- request: + body: "" + form: {} + headers: + Accept: + - application/json + Test-Request-Attempt: + - "0" + url: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/asotest-rg-fnsbef?api-version=2020-06-01 + method: GET + response: + body: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/asotest-rg-fnsbef","name":"asotest-rg-fnsbef","type":"Microsoft.Resources/resourceGroups","location":"westus2","tags":{"CreatedAt":"2001-02-03T04:05:06Z"},"properties":{"provisioningState":"Succeeded"}}' + headers: + Cache-Control: + - no-cache + Content-Length: + - "276" + Content-Type: + - application/json; charset=utf-8 + Expires: + - "-1" + Pragma: + - no-cache + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + X-Cache: + - CONFIG_NOCACHE + X-Content-Type-Options: + - nosniff + X-Msedge-Ref: + - 'Ref A: 532FE37ABA27462CB4DCFBA2E1779092 Ref B: CO6AA3150219031 Ref C: 2023-09-01T21:27:05Z' + status: 200 OK + code: 200 + duration: "" +- request: + body: "" + form: {} + headers: + Accept: + - application/json + Test-Request-Attempt: + - "0" + url: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/asotest-rg-fnsbef?api-version=2020-06-01 + method: DELETE + response: + body: "" + headers: + Cache-Control: + - no-cache + Content-Length: + - "0" + Expires: + - "-1" + Location: + - https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/operationresults/eyJqb2JJZCI6IlJFU09VUkNFR1JPVVBERUxFVElPTkpPQi1BU09URVNUOjJEUkc6MkRGTlNCRUYtV0VTVFVTMiIsImpvYkxvY2F0aW9uIjoid2VzdHVzMiJ9?api-version=2020-06-01 + Pragma: + - no-cache + Retry-After: + - "15" + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + X-Cache: + - CONFIG_NOCACHE + X-Content-Type-Options: + - nosniff + X-Msedge-Ref: + - 'Ref A: 2D781CB9473E496EAD57438A30A8DF2F Ref B: CO6AA3150219031 Ref C: 2023-09-01T21:27:13Z' + status: 202 Accepted + code: 202 + duration: "" +- request: + body: "" + form: {} + headers: + Test-Request-Attempt: + - "0" + url: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/operationresults/eyJqb2JJZCI6IlJFU09VUkNFR1JPVVBERUxFVElPTkpPQi1BU09URVNUOjJEUkc6MkRGTlNCRUYtV0VTVFVTMiIsImpvYkxvY2F0aW9uIjoid2VzdHVzMiJ9?api-version=2020-06-01 + method: GET + response: + body: "" + headers: + Cache-Control: + - no-cache + Content-Length: + - "0" + Expires: + - "-1" + Pragma: + - no-cache + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + X-Cache: + - CONFIG_NOCACHE + X-Content-Type-Options: + - nosniff + X-Msedge-Ref: + - 'Ref A: 5546685F0DC248008F59CCD7F31C4456 Ref B: CO6AA3150219031 Ref C: 2023-09-01T21:27:28Z' + status: 200 OK + code: 200 + duration: "" diff --git a/v2/internal/controllers/recordings/Test_OwnerIsARMIDOfParent_ChildResourceSuccessfullyReconciled.yaml b/v2/internal/controllers/recordings/Test_OwnerIsARMIDOfParent_ChildResourceSuccessfullyReconciled.yaml new file mode 100644 index 00000000000..b51e595bb6f --- /dev/null +++ b/v2/internal/controllers/recordings/Test_OwnerIsARMIDOfParent_ChildResourceSuccessfullyReconciled.yaml @@ -0,0 +1,824 @@ +--- +version: 1 +interactions: +- request: + body: '{"location":"westus2","name":"asotest-rg-hoowdu","tags":{"CreatedAt":"2001-02-03T04:05:06Z"}}' + form: {} + headers: + Accept: + - application/json + Content-Length: + - "93" + Content-Type: + - application/json + Test-Request-Attempt: + - "0" + url: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/asotest-rg-hoowdu?api-version=2020-06-01 + method: PUT + response: + body: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/asotest-rg-hoowdu","name":"asotest-rg-hoowdu","type":"Microsoft.Resources/resourceGroups","location":"westus2","tags":{"CreatedAt":"2001-02-03T04:05:06Z"},"properties":{"provisioningState":"Succeeded"}}' + headers: + Cache-Control: + - no-cache + Content-Length: + - "276" + Content-Type: + - application/json; charset=utf-8 + Expires: + - "-1" + Pragma: + - no-cache + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + X-Cache: + - CONFIG_NOCACHE + X-Content-Type-Options: + - nosniff + X-Msedge-Ref: + - 'Ref A: F23472F05C414FBD84D33D61A0A722BD Ref B: CO6AA3150220051 Ref C: 2023-09-01T18:27:35Z' + status: 201 Created + code: 201 + duration: "" +- request: + body: "" + form: {} + headers: + Accept: + - application/json + Test-Request-Attempt: + - "0" + url: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/asotest-rg-hoowdu?api-version=2020-06-01 + method: GET + response: + body: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/asotest-rg-hoowdu","name":"asotest-rg-hoowdu","type":"Microsoft.Resources/resourceGroups","location":"westus2","tags":{"CreatedAt":"2001-02-03T04:05:06Z"},"properties":{"provisioningState":"Succeeded"}}' + headers: + Cache-Control: + - no-cache + Content-Length: + - "276" + Content-Type: + - application/json; charset=utf-8 + Expires: + - "-1" + Pragma: + - no-cache + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + X-Cache: + - CONFIG_NOCACHE + X-Content-Type-Options: + - nosniff + X-Msedge-Ref: + - 'Ref A: 3D51AF8C410749459D03CC102DECC6A0 Ref B: CO6AA3150220051 Ref C: 2023-09-01T18:27:35Z' + status: 200 OK + code: 200 + duration: "" +- request: + body: '{"kind":"StorageV2","location":"westus2","name":"asoteststorzgzeqy","properties":{"accessTier":"Hot"},"sku":{"name":"Standard_LRS"},"tags":null}' + form: {} + headers: + Accept: + - application/json + Content-Length: + - "144" + Content-Type: + - application/json + Test-Request-Attempt: + - "0" + url: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/asotest-rg-hoowdu/providers/Microsoft.Storage/storageAccounts/asoteststorzgzeqy?api-version=2022-09-01 + method: PUT + response: + body: "" + headers: + Cache-Control: + - no-cache + Content-Length: + - "0" + Content-Type: + - text/plain; charset=utf-8 + Expires: + - "-1" + Location: + - https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Storage/locations/westus2/asyncoperations/08086687-5aeb-4fee-b163-a0b3e99fafe2?monitor=true&api-version=2022-09-01 + Pragma: + - no-cache + Retry-After: + - "17" + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + X-Cache: + - CONFIG_NOCACHE + X-Content-Type-Options: + - nosniff + X-Msedge-Ref: + - 'Ref A: 0DA97A05636748B8800F5779CA7F7C10 Ref B: CO6AA3150220051 Ref C: 2023-09-01T18:27:37Z' + status: 202 Accepted + code: 202 + duration: "" +- request: + body: "" + form: {} + headers: + Test-Request-Attempt: + - "0" + url: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Storage/locations/westus2/asyncoperations/08086687-5aeb-4fee-b163-a0b3e99fafe2?monitor=true&api-version=2022-09-01 + method: GET + response: + body: "" + headers: + Cache-Control: + - no-cache + Content-Length: + - "0" + Content-Type: + - text/plain; charset=utf-8 + Expires: + - "-1" + Location: + - https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Storage/locations/westus2/asyncoperations/08086687-5aeb-4fee-b163-a0b3e99fafe2?monitor=true&api-version=2022-09-01 + Pragma: + - no-cache + Retry-After: + - "17" + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + X-Cache: + - CONFIG_NOCACHE + X-Content-Type-Options: + - nosniff + X-Msedge-Ref: + - 'Ref A: 37F995CED2A540DB88F8C755DE7A8942 Ref B: CO6AA3150220051 Ref C: 2023-09-01T18:27:41Z' + status: 202 Accepted + code: 202 + duration: "" +- request: + body: "" + form: {} + headers: + Test-Request-Attempt: + - "1" + url: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Storage/locations/westus2/asyncoperations/08086687-5aeb-4fee-b163-a0b3e99fafe2?monitor=true&api-version=2022-09-01 + method: GET + response: + body: '{"sku":{"name":"Standard_LRS","tier":"Standard"},"kind":"StorageV2","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/asotest-rg-hoowdu/providers/Microsoft.Storage/storageAccounts/asoteststorzgzeqy","name":"asoteststorzgzeqy","type":"Microsoft.Storage/storageAccounts","location":"westus2","tags":{},"properties":{"keyCreationTime":{"key1":"2001-02-03T04:05:06Z","key2":"2001-02-03T04:05:06Z"},"privateEndpointConnections":[],"minimumTlsVersion":"TLS1_0","allowBlobPublicAccess":true,"networkAcls":{"bypass":"AzureServices","virtualNetworkRules":[],"ipRules":[],"defaultAction":"Allow"},"supportsHttpsTrafficOnly":true,"encryption":{"services":{"file":{"keyType":"Account","enabled":true,"lastEnabledTime":"2001-02-03T04:05:06Z"},"blob":{"keyType":"Account","enabled":true,"lastEnabledTime":"2001-02-03T04:05:06Z"}},"keySource":"Microsoft.Storage"},"accessTier":"Hot","provisioningState":"Succeeded","creationTime":"2001-02-03T04:05:06Z","primaryEndpoints":{"dfs":"https://asoteststorzgzeqy.dfs.core.windows.net/","web":"https://asoteststorzgzeqy.z5.web.core.windows.net/","blob":"https://asoteststorzgzeqy.blob.core.windows.net/","queue":"https://asoteststorzgzeqy.queue.core.windows.net/","table":"https://asoteststorzgzeqy.table.core.windows.net/","file":"https://asoteststorzgzeqy.file.core.windows.net/"},"primaryLocation":"westus2","statusOfPrimary":"available"}}' + headers: + Cache-Control: + - no-cache + Content-Length: + - "1432" + Content-Type: + - application/json + Expires: + - "-1" + Pragma: + - no-cache + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + X-Cache: + - CONFIG_NOCACHE + X-Content-Type-Options: + - nosniff + X-Msedge-Ref: + - 'Ref A: F74746E4334E4113833191A2A635959C Ref B: CO6AA3150220051 Ref C: 2023-09-01T18:27:58Z' + status: 200 OK + code: 200 + duration: "" +- request: + body: "" + form: {} + headers: + Accept: + - application/json + Test-Request-Attempt: + - "0" + url: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/asotest-rg-hoowdu/providers/Microsoft.Storage/storageAccounts/asoteststorzgzeqy?api-version=2022-09-01 + method: GET + response: + body: '{"sku":{"name":"Standard_LRS","tier":"Standard"},"kind":"StorageV2","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/asotest-rg-hoowdu/providers/Microsoft.Storage/storageAccounts/asoteststorzgzeqy","name":"asoteststorzgzeqy","type":"Microsoft.Storage/storageAccounts","location":"westus2","tags":{},"properties":{"keyCreationTime":{"key1":"2001-02-03T04:05:06Z","key2":"2001-02-03T04:05:06Z"},"privateEndpointConnections":[],"minimumTlsVersion":"TLS1_0","allowBlobPublicAccess":true,"networkAcls":{"bypass":"AzureServices","virtualNetworkRules":[],"ipRules":[],"defaultAction":"Allow"},"supportsHttpsTrafficOnly":true,"encryption":{"services":{"file":{"keyType":"Account","enabled":true,"lastEnabledTime":"2001-02-03T04:05:06Z"},"blob":{"keyType":"Account","enabled":true,"lastEnabledTime":"2001-02-03T04:05:06Z"}},"keySource":"Microsoft.Storage"},"accessTier":"Hot","provisioningState":"Succeeded","creationTime":"2001-02-03T04:05:06Z","primaryEndpoints":{"dfs":"https://asoteststorzgzeqy.dfs.core.windows.net/","web":"https://asoteststorzgzeqy.z5.web.core.windows.net/","blob":"https://asoteststorzgzeqy.blob.core.windows.net/","queue":"https://asoteststorzgzeqy.queue.core.windows.net/","table":"https://asoteststorzgzeqy.table.core.windows.net/","file":"https://asoteststorzgzeqy.file.core.windows.net/"},"primaryLocation":"westus2","statusOfPrimary":"available"}}' + headers: + Cache-Control: + - no-cache + Content-Length: + - "1432" + Content-Type: + - application/json + Expires: + - "-1" + Pragma: + - no-cache + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + X-Cache: + - CONFIG_NOCACHE + X-Content-Type-Options: + - nosniff + X-Msedge-Ref: + - 'Ref A: E4DCB89D8AA14739A80F6F3B83C02C92 Ref B: CO6AA3150220051 Ref C: 2023-09-01T18:27:58Z' + status: 200 OK + code: 200 + duration: "" +- request: + body: '{"name":"default"}' + form: {} + headers: + Accept: + - application/json + Content-Length: + - "18" + Content-Type: + - application/json + Test-Request-Attempt: + - "0" + url: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/asotest-rg-hoowdu/providers/Microsoft.Storage/storageAccounts/asoteststorzgzeqy/blobServices/default?api-version=2022-09-01 + method: PUT + response: + body: '{"name":"default"}' + headers: + Cache-Control: + - no-cache + Content-Length: + - "18" + Content-Type: + - application/json + Expires: + - "-1" + Pragma: + - no-cache + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + X-Cache: + - CONFIG_NOCACHE + X-Content-Type-Options: + - nosniff + X-Msedge-Ref: + - 'Ref A: 4C3CE7E407AD46C7A551B66F46BBC6D4 Ref B: CO6AA3150220051 Ref C: 2023-09-01T18:28:02Z' + status: 200 OK + code: 200 + duration: "" +- request: + body: "" + form: {} + headers: + Accept: + - application/json + Test-Request-Attempt: + - "0" + url: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/asotest-rg-hoowdu/providers/Microsoft.Storage/storageAccounts/asoteststorzgzeqy/blobServices/default?api-version=2022-09-01 + method: GET + response: + body: '{"sku":{"name":"Standard_LRS","tier":"Standard"},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/asotest-rg-hoowdu/providers/Microsoft.Storage/storageAccounts/asoteststorzgzeqy/blobServices/default","name":"default","type":"Microsoft.Storage/storageAccounts/blobServices","properties":{"cors":{"corsRules":[]},"deleteRetentionPolicy":{"allowPermanentDelete":false,"enabled":false}}}' + headers: + Cache-Control: + - no-cache + Content-Length: + - "407" + Content-Type: + - application/json + Expires: + - "-1" + Pragma: + - no-cache + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + X-Cache: + - CONFIG_NOCACHE + X-Content-Type-Options: + - nosniff + X-Msedge-Ref: + - 'Ref A: AE01AC655D4243A5AB9B95EEB9D4FE8A Ref B: CO6AA3150220051 Ref C: 2023-09-01T18:28:03Z' + status: 200 OK + code: 200 + duration: "" +- request: + body: '{"name":"asotest-container-lxzhpo"}' + form: {} + headers: + Accept: + - application/json + Content-Length: + - "35" + Content-Type: + - application/json + Test-Request-Attempt: + - "0" + url: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/asotest-rg-hoowdu/providers/Microsoft.Storage/storageAccounts/asoteststorzgzeqy/blobServices/default/containers/asotest-container-lxzhpo?api-version=2022-09-01 + method: PUT + response: + body: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/asotest-rg-hoowdu/providers/Microsoft.Storage/storageAccounts/asoteststorzgzeqy/blobServices/default/containers/asotest-container-lxzhpo","name":"asotest-container-lxzhpo","type":"Microsoft.Storage/storageAccounts/blobServices/containers"}' + headers: + Cache-Control: + - no-cache + Content-Length: + - "313" + Content-Type: + - application/json + Etag: + - '"0x8DBAB1930A2C5A0"' + Expires: + - "-1" + Pragma: + - no-cache + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + X-Cache: + - CONFIG_NOCACHE + X-Content-Type-Options: + - nosniff + X-Msedge-Ref: + - 'Ref A: FA4EA127E13D4631A0E2DA0A676CB703 Ref B: CO6AA3150220051 Ref C: 2023-09-01T18:28:07Z' + status: 201 Created + code: 201 + duration: "" +- request: + body: "" + form: {} + headers: + Test-Request-Attempt: + - "0" + url: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/asotest-rg-hoowdu/providers/Microsoft.Storage/storageAccounts/asoteststorzgzeqy/blobServices/default/containers/asotest-container-lxzhpo?api-version=2022-09-01 + method: GET + response: + body: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/asotest-rg-hoowdu/providers/Microsoft.Storage/storageAccounts/asoteststorzgzeqy/blobServices/default/containers/asotest-container-lxzhpo","name":"asotest-container-lxzhpo","type":"Microsoft.Storage/storageAccounts/blobServices/containers","etag":"\"0x8DBAB1930A2C5A0\"","properties":{"deleted":false,"remainingRetentionDays":0,"defaultEncryptionScope":"$account-encryption-key","denyEncryptionScopeOverride":false,"publicAccess":"None","leaseStatus":"Unlocked","leaseState":"Available","lastModifiedTime":"2001-02-03T04:05:06Z","legalHold":{"hasLegalHold":false,"tags":[]},"hasImmutabilityPolicy":false,"hasLegalHold":false}}' + headers: + Cache-Control: + - no-cache + Content-Length: + - "707" + Content-Type: + - application/json + Etag: + - '"0x8DBAB1930A2C5A0"' + Expires: + - "-1" + Pragma: + - no-cache + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + X-Cache: + - CONFIG_NOCACHE + X-Content-Type-Options: + - nosniff + X-Msedge-Ref: + - 'Ref A: 690A6E4AB26D44DAA90A19E61DCB78AB Ref B: CO6AA3150220051 Ref C: 2023-09-01T18:28:09Z' + status: 200 OK + code: 200 + duration: "" +- request: + body: "" + form: {} + headers: + Accept: + - application/json + Test-Request-Attempt: + - "1" + url: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/asotest-rg-hoowdu/providers/Microsoft.Storage/storageAccounts/asoteststorzgzeqy/blobServices/default/containers/asotest-container-lxzhpo?api-version=2022-09-01 + method: GET + response: + body: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/asotest-rg-hoowdu/providers/Microsoft.Storage/storageAccounts/asoteststorzgzeqy/blobServices/default/containers/asotest-container-lxzhpo","name":"asotest-container-lxzhpo","type":"Microsoft.Storage/storageAccounts/blobServices/containers","etag":"\"0x8DBAB1930A2C5A0\"","properties":{"deleted":false,"remainingRetentionDays":0,"defaultEncryptionScope":"$account-encryption-key","denyEncryptionScopeOverride":false,"publicAccess":"None","leaseStatus":"Unlocked","leaseState":"Available","lastModifiedTime":"2001-02-03T04:05:06Z","legalHold":{"hasLegalHold":false,"tags":[]},"hasImmutabilityPolicy":false,"hasLegalHold":false}}' + headers: + Cache-Control: + - no-cache + Content-Length: + - "707" + Content-Type: + - application/json + Etag: + - '"0x8DBAB1930A2C5A0"' + Expires: + - "-1" + Pragma: + - no-cache + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + X-Cache: + - CONFIG_NOCACHE + X-Content-Type-Options: + - nosniff + X-Msedge-Ref: + - 'Ref A: C236C99E64F34B9DB36269794AC5C0CD Ref B: CO6AA3150220051 Ref C: 2023-09-01T18:28:09Z' + status: 200 OK + code: 200 + duration: "" +- request: + body: '{"name":"asotest-container-lxzhpo","properties":{"metadata":{"tag1":"value1"}}}' + form: {} + headers: + Accept: + - application/json + Content-Length: + - "79" + Content-Type: + - application/json + Test-Request-Attempt: + - "1" + url: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/asotest-rg-hoowdu/providers/Microsoft.Storage/storageAccounts/asoteststorzgzeqy/blobServices/default/containers/asotest-container-lxzhpo?api-version=2022-09-01 + method: PUT + response: + body: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/asotest-rg-hoowdu/providers/Microsoft.Storage/storageAccounts/asoteststorzgzeqy/blobServices/default/containers/asotest-container-lxzhpo","name":"asotest-container-lxzhpo","type":"Microsoft.Storage/storageAccounts/blobServices/containers","properties":{"deleted":false,"remainingRetentionDays":0,"metadata":{"tag1":"value1"},"hasImmutabilityPolicy":false,"hasLegalHold":false}}' + headers: + Cache-Control: + - no-cache + Content-Length: + - "451" + Content-Type: + - application/json + Etag: + - '"0x8DBAB1933994F47"' + Expires: + - "-1" + Pragma: + - no-cache + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + X-Cache: + - CONFIG_NOCACHE + X-Content-Type-Options: + - nosniff + X-Msedge-Ref: + - 'Ref A: F97079808A9B4CAE8B7EFD71BF1EE666 Ref B: CO6AA3150220051 Ref C: 2023-09-01T18:28:12Z' + status: 200 OK + code: 200 + duration: "" +- request: + body: "" + form: {} + headers: + Accept: + - application/json + Test-Request-Attempt: + - "2" + url: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/asotest-rg-hoowdu/providers/Microsoft.Storage/storageAccounts/asoteststorzgzeqy/blobServices/default/containers/asotest-container-lxzhpo?api-version=2022-09-01 + method: GET + response: + body: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/asotest-rg-hoowdu/providers/Microsoft.Storage/storageAccounts/asoteststorzgzeqy/blobServices/default/containers/asotest-container-lxzhpo","name":"asotest-container-lxzhpo","type":"Microsoft.Storage/storageAccounts/blobServices/containers","etag":"\"0x8DBAB1933994F47\"","properties":{"deleted":false,"remainingRetentionDays":0,"defaultEncryptionScope":"$account-encryption-key","denyEncryptionScopeOverride":false,"metadata":{"tag1":"value1"},"publicAccess":"None","leaseStatus":"Unlocked","leaseState":"Available","lastModifiedTime":"2001-02-03T04:05:06Z","legalHold":{"hasLegalHold":false,"tags":[]},"hasImmutabilityPolicy":false,"hasLegalHold":false}}' + headers: + Cache-Control: + - no-cache + Content-Length: + - "736" + Content-Type: + - application/json + Etag: + - '"0x8DBAB1933994F47"' + Expires: + - "-1" + Pragma: + - no-cache + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + X-Cache: + - CONFIG_NOCACHE + X-Content-Type-Options: + - nosniff + X-Msedge-Ref: + - 'Ref A: 44D6F9FC2FAD4DBC8A2CF8748BCB6299 Ref B: CO6AA3150220051 Ref C: 2023-09-01T18:28:13Z' + status: 200 OK + code: 200 + duration: "" +- request: + body: "" + form: {} + headers: + Accept: + - application/json + Test-Request-Attempt: + - "0" + url: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/asotest-rg-hoowdu/providers/Microsoft.Storage/storageAccounts/asoteststorzgzeqy/blobServices/default/containers/asotest-container-lxzhpo?api-version=2022-09-01 + method: DELETE + response: + body: "" + headers: + Cache-Control: + - no-cache + Content-Length: + - "0" + Content-Type: + - text/plain; charset=utf-8 + Expires: + - "-1" + Pragma: + - no-cache + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + X-Cache: + - CONFIG_NOCACHE + X-Content-Type-Options: + - nosniff + X-Msedge-Ref: + - 'Ref A: 16CF6B8020B241D8BA301E4D5595D0CE Ref B: CO6AA3150220051 Ref C: 2023-09-01T18:28:17Z' + status: 200 OK + code: 200 + duration: "" +- request: + body: "" + form: {} + headers: + Accept: + - application/json + Test-Request-Attempt: + - "3" + url: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/asotest-rg-hoowdu/providers/Microsoft.Storage/storageAccounts/asoteststorzgzeqy/blobServices/default/containers/asotest-container-lxzhpo?api-version=2022-09-01 + method: GET + response: + body: '{"error":{"code":"ContainerNotFound","message":"The specified container + does not exist.\nRequestId:706dcb60-f01e-000e-1202-ddaca6000000\nTime:2001-02-03T04:05:06Z"}}' + headers: + Cache-Control: + - no-cache + Content-Length: + - "173" + Content-Type: + - application/json + Expires: + - "-1" + Pragma: + - no-cache + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + X-Cache: + - CONFIG_NOCACHE + X-Content-Type-Options: + - nosniff + X-Msedge-Ref: + - 'Ref A: CE47D8EE43F04AEFBEA98971962801E4 Ref B: CO6AA3150220051 Ref C: 2023-09-01T18:28:22Z' + status: 404 Not Found + code: 404 + duration: "" +- request: + body: "" + form: {} + headers: + Accept: + - application/json + Test-Request-Attempt: + - "0" + url: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/asotest-rg-hoowdu?api-version=2020-06-01 + method: DELETE + response: + body: "" + headers: + Cache-Control: + - no-cache + Content-Length: + - "0" + Expires: + - "-1" + Location: + - https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/operationresults/eyJqb2JJZCI6IlJFU09VUkNFR1JPVVBERUxFVElPTkpPQi1BU09URVNUOjJEUkc6MkRIT09XRFUtV0VTVFVTMiIsImpvYkxvY2F0aW9uIjoid2VzdHVzMiJ9?api-version=2020-06-01 + Pragma: + - no-cache + Retry-After: + - "15" + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + X-Cache: + - CONFIG_NOCACHE + X-Content-Type-Options: + - nosniff + X-Msedge-Ref: + - 'Ref A: 53802B1F759945ABBA4AA32261A05540 Ref B: CO6AA3150220051 Ref C: 2023-09-01T18:28:23Z' + status: 202 Accepted + code: 202 + duration: "" +- request: + body: "" + form: {} + headers: + Test-Request-Attempt: + - "0" + url: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/operationresults/eyJqb2JJZCI6IlJFU09VUkNFR1JPVVBERUxFVElPTkpPQi1BU09URVNUOjJEUkc6MkRIT09XRFUtV0VTVFVTMiIsImpvYkxvY2F0aW9uIjoid2VzdHVzMiJ9?api-version=2020-06-01 + method: GET + response: + body: "" + headers: + Cache-Control: + - no-cache + Content-Length: + - "0" + Expires: + - "-1" + Location: + - https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/operationresults/eyJqb2JJZCI6IlJFU09VUkNFR1JPVVBERUxFVElPTkpPQi1BU09URVNUOjJEUkc6MkRIT09XRFUtV0VTVFVTMiIsImpvYkxvY2F0aW9uIjoid2VzdHVzMiJ9?api-version=2020-06-01 + Pragma: + - no-cache + Retry-After: + - "15" + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + X-Cache: + - CONFIG_NOCACHE + X-Content-Type-Options: + - nosniff + X-Msedge-Ref: + - 'Ref A: 795E4771EE764CF49EBB88AE16153B08 Ref B: CO6AA3150220051 Ref C: 2023-09-01T18:28:38Z' + status: 202 Accepted + code: 202 + duration: "" +- request: + body: "" + form: {} + headers: + Test-Request-Attempt: + - "1" + url: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/operationresults/eyJqb2JJZCI6IlJFU09VUkNFR1JPVVBERUxFVElPTkpPQi1BU09URVNUOjJEUkc6MkRIT09XRFUtV0VTVFVTMiIsImpvYkxvY2F0aW9uIjoid2VzdHVzMiJ9?api-version=2020-06-01 + method: GET + response: + body: "" + headers: + Cache-Control: + - no-cache + Content-Length: + - "0" + Expires: + - "-1" + Location: + - https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/operationresults/eyJqb2JJZCI6IlJFU09VUkNFR1JPVVBERUxFVElPTkpPQi1BU09URVNUOjJEUkc6MkRIT09XRFUtV0VTVFVTMiIsImpvYkxvY2F0aW9uIjoid2VzdHVzMiJ9?api-version=2020-06-01 + Pragma: + - no-cache + Retry-After: + - "15" + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + X-Cache: + - CONFIG_NOCACHE + X-Content-Type-Options: + - nosniff + X-Msedge-Ref: + - 'Ref A: FD60C6FC213E41BBB2D8A46CE92412BB Ref B: CO6AA3150220051 Ref C: 2023-09-01T18:28:54Z' + status: 202 Accepted + code: 202 + duration: "" +- request: + body: "" + form: {} + headers: + Test-Request-Attempt: + - "2" + url: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/operationresults/eyJqb2JJZCI6IlJFU09VUkNFR1JPVVBERUxFVElPTkpPQi1BU09URVNUOjJEUkc6MkRIT09XRFUtV0VTVFVTMiIsImpvYkxvY2F0aW9uIjoid2VzdHVzMiJ9?api-version=2020-06-01 + method: GET + response: + body: "" + headers: + Cache-Control: + - no-cache + Content-Length: + - "0" + Expires: + - "-1" + Location: + - https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/operationresults/eyJqb2JJZCI6IlJFU09VUkNFR1JPVVBERUxFVElPTkpPQi1BU09URVNUOjJEUkc6MkRIT09XRFUtV0VTVFVTMiIsImpvYkxvY2F0aW9uIjoid2VzdHVzMiJ9?api-version=2020-06-01 + Pragma: + - no-cache + Retry-After: + - "15" + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + X-Cache: + - CONFIG_NOCACHE + X-Content-Type-Options: + - nosniff + X-Msedge-Ref: + - 'Ref A: 505A69CB859B4767AD588A8717311992 Ref B: CO6AA3150220051 Ref C: 2023-09-01T18:29:09Z' + status: 202 Accepted + code: 202 + duration: "" +- request: + body: "" + form: {} + headers: + Test-Request-Attempt: + - "3" + url: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/operationresults/eyJqb2JJZCI6IlJFU09VUkNFR1JPVVBERUxFVElPTkpPQi1BU09URVNUOjJEUkc6MkRIT09XRFUtV0VTVFVTMiIsImpvYkxvY2F0aW9uIjoid2VzdHVzMiJ9?api-version=2020-06-01 + method: GET + response: + body: "" + headers: + Cache-Control: + - no-cache + Content-Length: + - "0" + Expires: + - "-1" + Location: + - https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/operationresults/eyJqb2JJZCI6IlJFU09VUkNFR1JPVVBERUxFVElPTkpPQi1BU09URVNUOjJEUkc6MkRIT09XRFUtV0VTVFVTMiIsImpvYkxvY2F0aW9uIjoid2VzdHVzMiJ9?api-version=2020-06-01 + Pragma: + - no-cache + Retry-After: + - "15" + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + X-Cache: + - CONFIG_NOCACHE + X-Content-Type-Options: + - nosniff + X-Msedge-Ref: + - 'Ref A: E3EA213EEB1449F1831D50BD1CA9E7DD Ref B: CO6AA3150220051 Ref C: 2023-09-01T18:29:24Z' + status: 202 Accepted + code: 202 + duration: "" +- request: + body: "" + form: {} + headers: + Test-Request-Attempt: + - "4" + url: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/operationresults/eyJqb2JJZCI6IlJFU09VUkNFR1JPVVBERUxFVElPTkpPQi1BU09URVNUOjJEUkc6MkRIT09XRFUtV0VTVFVTMiIsImpvYkxvY2F0aW9uIjoid2VzdHVzMiJ9?api-version=2020-06-01 + method: GET + response: + body: "" + headers: + Cache-Control: + - no-cache + Content-Length: + - "0" + Expires: + - "-1" + Pragma: + - no-cache + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + X-Cache: + - CONFIG_NOCACHE + X-Content-Type-Options: + - nosniff + X-Msedge-Ref: + - 'Ref A: EF084A53DF0C45EC8268B438D27F8BA3 Ref B: CO6AA3150220051 Ref C: 2023-09-01T18:29:39Z' + status: 200 OK + code: 200 + duration: "" +- request: + body: "" + form: {} + headers: + Accept: + - application/json + Test-Request-Attempt: + - "0" + url: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/asotest-rg-hoowdu/providers/Microsoft.Storage/storageAccounts/asoteststorzgzeqy?api-version=2022-09-01 + method: DELETE + response: + body: '{"error":{"code":"ResourceGroupNotFound","message":"Resource group ''asotest-rg-hoowdu'' + could not be found."}}' + headers: + Cache-Control: + - no-cache + Content-Length: + - "109" + Content-Type: + - application/json; charset=utf-8 + Expires: + - "-1" + Pragma: + - no-cache + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + X-Cache: + - CONFIG_NOCACHE + X-Content-Type-Options: + - nosniff + X-Ms-Failure-Cause: + - gateway + X-Msedge-Ref: + - 'Ref A: BA18336334894CE3840B00ED7E20376F Ref B: CO6AA3150220051 Ref C: 2023-09-01T18:29:43Z' + status: 404 Not Found + code: 404 + duration: "" +- request: + body: "" + form: {} + headers: + Accept: + - application/json + Test-Request-Attempt: + - "0" + url: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/asotest-rg-hoowdu/providers/Microsoft.Storage/storageAccounts/asoteststorzgzeqy/blobServices/default?api-version=2022-09-01 + method: DELETE + response: + body: '{"error":{"code":"ParentResourceNotFound","message":"Failed to perform + ''delete'' on resource(s) of type ''storageAccounts/blobServices'', because + the parent resource ''/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/asotest-rg-hoowdu/providers/Microsoft.Storage/storageAccounts/asoteststorzgzeqy'' + could not be found."}}' + headers: + Cache-Control: + - no-cache + Content-Length: + - "334" + Content-Type: + - application/json; charset=utf-8 + Expires: + - "-1" + Pragma: + - no-cache + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + X-Cache: + - CONFIG_NOCACHE + X-Content-Type-Options: + - nosniff + X-Ms-Failure-Cause: + - gateway + X-Msedge-Ref: + - 'Ref A: CAB4A41D3DBE46AE96D0CC595BEFCE0D Ref B: CO6AA3150220051 Ref C: 2023-09-01T18:29:48Z' + status: 404 Not Found + code: 404 + duration: "" diff --git a/v2/internal/controllers/recordings/Test_OwnerIsARMIDOfResourceGroup_ResourceSuccessfullyReconciled.yaml b/v2/internal/controllers/recordings/Test_OwnerIsARMIDOfResourceGroup_ResourceSuccessfullyReconciled.yaml new file mode 100644 index 00000000000..37b29a6efd1 --- /dev/null +++ b/v2/internal/controllers/recordings/Test_OwnerIsARMIDOfResourceGroup_ResourceSuccessfullyReconciled.yaml @@ -0,0 +1,429 @@ +--- +version: 1 +interactions: +- request: + body: '{"location":"westus2","name":"asotest-rg-drfmps","tags":{"CreatedAt":"2001-02-03T04:05:06Z"}}' + form: {} + headers: + Accept: + - application/json + Content-Length: + - "93" + Content-Type: + - application/json + Test-Request-Attempt: + - "0" + url: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/asotest-rg-drfmps?api-version=2020-06-01 + method: PUT + response: + body: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/asotest-rg-drfmps","name":"asotest-rg-drfmps","type":"Microsoft.Resources/resourceGroups","location":"westus2","tags":{"CreatedAt":"2001-02-03T04:05:06Z"},"properties":{"provisioningState":"Succeeded"}}' + headers: + Cache-Control: + - no-cache + Content-Length: + - "276" + Content-Type: + - application/json; charset=utf-8 + Expires: + - "-1" + Pragma: + - no-cache + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + X-Cache: + - CONFIG_NOCACHE + X-Content-Type-Options: + - nosniff + X-Msedge-Ref: + - 'Ref A: 8F26C2F0C48E4BEEB1930E95B167DE72 Ref B: CO6AA3150218017 Ref C: 2023-09-01T18:04:49Z' + status: 201 Created + code: 201 + duration: "" +- request: + body: "" + form: {} + headers: + Accept: + - application/json + Test-Request-Attempt: + - "0" + url: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/asotest-rg-drfmps?api-version=2020-06-01 + method: GET + response: + body: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/asotest-rg-drfmps","name":"asotest-rg-drfmps","type":"Microsoft.Resources/resourceGroups","location":"westus2","tags":{"CreatedAt":"2001-02-03T04:05:06Z"},"properties":{"provisioningState":"Succeeded"}}' + headers: + Cache-Control: + - no-cache + Content-Length: + - "276" + Content-Type: + - application/json; charset=utf-8 + Expires: + - "-1" + Pragma: + - no-cache + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + X-Cache: + - CONFIG_NOCACHE + X-Content-Type-Options: + - nosniff + X-Msedge-Ref: + - 'Ref A: 778BCFE3351F4FE1B6BA92BFE24A82C6 Ref B: CO6AA3150218017 Ref C: 2023-09-01T18:04:50Z' + status: 200 OK + code: 200 + duration: "" +- request: + body: '{"kind":"StorageV2","location":"westus2","name":"asoteststorbpzrrz","properties":{"accessTier":"Hot"},"sku":{"name":"Standard_LRS"},"tags":null}' + form: {} + headers: + Accept: + - application/json + Content-Length: + - "144" + Content-Type: + - application/json + Test-Request-Attempt: + - "0" + url: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/asotest-rg-drfmps/providers/Microsoft.Storage/storageAccounts/asoteststorbpzrrz?api-version=2022-09-01 + method: PUT + response: + body: "" + headers: + Cache-Control: + - no-cache + Content-Length: + - "0" + Content-Type: + - text/plain; charset=utf-8 + Expires: + - "-1" + Location: + - https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Storage/locations/westus2/asyncoperations/cabb8259-18a4-4fc4-ab0f-d200945ffeb1?monitor=true&api-version=2022-09-01 + Pragma: + - no-cache + Retry-After: + - "17" + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + X-Cache: + - CONFIG_NOCACHE + X-Content-Type-Options: + - nosniff + X-Msedge-Ref: + - 'Ref A: B552CCECBFC5470996BEE7254CB4D901 Ref B: CO6AA3150218017 Ref C: 2023-09-01T18:04:51Z' + status: 202 Accepted + code: 202 + duration: "" +- request: + body: "" + form: {} + headers: + Test-Request-Attempt: + - "0" + url: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Storage/locations/westus2/asyncoperations/cabb8259-18a4-4fc4-ab0f-d200945ffeb1?monitor=true&api-version=2022-09-01 + method: GET + response: + body: "" + headers: + Cache-Control: + - no-cache + Content-Length: + - "0" + Content-Type: + - text/plain; charset=utf-8 + Expires: + - "-1" + Location: + - https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Storage/locations/westus2/asyncoperations/cabb8259-18a4-4fc4-ab0f-d200945ffeb1?monitor=true&api-version=2022-09-01 + Pragma: + - no-cache + Retry-After: + - "17" + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + X-Cache: + - CONFIG_NOCACHE + X-Content-Type-Options: + - nosniff + X-Msedge-Ref: + - 'Ref A: 3A6C8789100549CA87DEA79DAF774F5F Ref B: CO6AA3150218017 Ref C: 2023-09-01T18:04:55Z' + status: 202 Accepted + code: 202 + duration: "" +- request: + body: "" + form: {} + headers: + Test-Request-Attempt: + - "1" + url: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Storage/locations/westus2/asyncoperations/cabb8259-18a4-4fc4-ab0f-d200945ffeb1?monitor=true&api-version=2022-09-01 + method: GET + response: + body: '{"sku":{"name":"Standard_LRS","tier":"Standard"},"kind":"StorageV2","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/asotest-rg-drfmps/providers/Microsoft.Storage/storageAccounts/asoteststorbpzrrz","name":"asoteststorbpzrrz","type":"Microsoft.Storage/storageAccounts","location":"westus2","tags":{},"properties":{"keyCreationTime":{"key1":"2001-02-03T04:05:06Z","key2":"2001-02-03T04:05:06Z"},"privateEndpointConnections":[],"minimumTlsVersion":"TLS1_0","allowBlobPublicAccess":true,"networkAcls":{"bypass":"AzureServices","virtualNetworkRules":[],"ipRules":[],"defaultAction":"Allow"},"supportsHttpsTrafficOnly":true,"encryption":{"services":{"file":{"keyType":"Account","enabled":true,"lastEnabledTime":"2001-02-03T04:05:06Z"},"blob":{"keyType":"Account","enabled":true,"lastEnabledTime":"2001-02-03T04:05:06Z"}},"keySource":"Microsoft.Storage"},"accessTier":"Hot","provisioningState":"Succeeded","creationTime":"2001-02-03T04:05:06Z","primaryEndpoints":{"dfs":"https://asoteststorbpzrrz.dfs.core.windows.net/","web":"https://asoteststorbpzrrz.z5.web.core.windows.net/","blob":"https://asoteststorbpzrrz.blob.core.windows.net/","queue":"https://asoteststorbpzrrz.queue.core.windows.net/","table":"https://asoteststorbpzrrz.table.core.windows.net/","file":"https://asoteststorbpzrrz.file.core.windows.net/"},"primaryLocation":"westus2","statusOfPrimary":"available"}}' + headers: + Cache-Control: + - no-cache + Content-Length: + - "1432" + Content-Type: + - application/json + Expires: + - "-1" + Pragma: + - no-cache + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + X-Cache: + - CONFIG_NOCACHE + X-Content-Type-Options: + - nosniff + X-Msedge-Ref: + - 'Ref A: 2ABA2147C3AB4D63820CF5E6302A2C06 Ref B: CO6AA3150218017 Ref C: 2023-09-01T18:05:12Z' + status: 200 OK + code: 200 + duration: "" +- request: + body: "" + form: {} + headers: + Accept: + - application/json + Test-Request-Attempt: + - "0" + url: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/asotest-rg-drfmps/providers/Microsoft.Storage/storageAccounts/asoteststorbpzrrz?api-version=2022-09-01 + method: GET + response: + body: '{"sku":{"name":"Standard_LRS","tier":"Standard"},"kind":"StorageV2","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/asotest-rg-drfmps/providers/Microsoft.Storage/storageAccounts/asoteststorbpzrrz","name":"asoteststorbpzrrz","type":"Microsoft.Storage/storageAccounts","location":"westus2","tags":{},"properties":{"keyCreationTime":{"key1":"2001-02-03T04:05:06Z","key2":"2001-02-03T04:05:06Z"},"privateEndpointConnections":[],"minimumTlsVersion":"TLS1_0","allowBlobPublicAccess":true,"networkAcls":{"bypass":"AzureServices","virtualNetworkRules":[],"ipRules":[],"defaultAction":"Allow"},"supportsHttpsTrafficOnly":true,"encryption":{"services":{"file":{"keyType":"Account","enabled":true,"lastEnabledTime":"2001-02-03T04:05:06Z"},"blob":{"keyType":"Account","enabled":true,"lastEnabledTime":"2001-02-03T04:05:06Z"}},"keySource":"Microsoft.Storage"},"accessTier":"Hot","provisioningState":"Succeeded","creationTime":"2001-02-03T04:05:06Z","primaryEndpoints":{"dfs":"https://asoteststorbpzrrz.dfs.core.windows.net/","web":"https://asoteststorbpzrrz.z5.web.core.windows.net/","blob":"https://asoteststorbpzrrz.blob.core.windows.net/","queue":"https://asoteststorbpzrrz.queue.core.windows.net/","table":"https://asoteststorbpzrrz.table.core.windows.net/","file":"https://asoteststorbpzrrz.file.core.windows.net/"},"primaryLocation":"westus2","statusOfPrimary":"available"}}' + headers: + Cache-Control: + - no-cache + Content-Length: + - "1432" + Content-Type: + - application/json + Expires: + - "-1" + Pragma: + - no-cache + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + X-Cache: + - CONFIG_NOCACHE + X-Content-Type-Options: + - nosniff + X-Msedge-Ref: + - 'Ref A: 87B6E7DA4A3F4E6D9DF396ADE543FE85 Ref B: CO6AA3150218017 Ref C: 2023-09-01T18:05:13Z' + status: 200 OK + code: 200 + duration: "" +- request: + body: '{"kind":"StorageV2","location":"westus2","name":"asoteststorbpzrrz","properties":{"accessTier":"Hot"},"sku":{"name":"Standard_LRS"},"tags":{"tag1":"value1"}}' + form: {} + headers: + Accept: + - application/json + Content-Length: + - "157" + Content-Type: + - application/json + Test-Request-Attempt: + - "1" + url: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/asotest-rg-drfmps/providers/Microsoft.Storage/storageAccounts/asoteststorbpzrrz?api-version=2022-09-01 + method: PUT + response: + body: '{"sku":{"name":"Standard_LRS","tier":"Standard"},"kind":"StorageV2","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/asotest-rg-drfmps/providers/Microsoft.Storage/storageAccounts/asoteststorbpzrrz","name":"asoteststorbpzrrz","type":"Microsoft.Storage/storageAccounts","location":"westus2","tags":{"tag1":"value1"},"properties":{"keyCreationTime":{"key1":"2001-02-03T04:05:06Z","key2":"2001-02-03T04:05:06Z"},"privateEndpointConnections":[],"minimumTlsVersion":"TLS1_0","allowBlobPublicAccess":true,"networkAcls":{"bypass":"AzureServices","virtualNetworkRules":[],"ipRules":[],"defaultAction":"Allow"},"supportsHttpsTrafficOnly":true,"encryption":{"services":{"file":{"keyType":"Account","enabled":true,"lastEnabledTime":"2001-02-03T04:05:06Z"},"blob":{"keyType":"Account","enabled":true,"lastEnabledTime":"2001-02-03T04:05:06Z"}},"keySource":"Microsoft.Storage"},"accessTier":"Hot","provisioningState":"Succeeded","creationTime":"2001-02-03T04:05:06Z","primaryEndpoints":{"dfs":"https://asoteststorbpzrrz.dfs.core.windows.net/","web":"https://asoteststorbpzrrz.z5.web.core.windows.net/","blob":"https://asoteststorbpzrrz.blob.core.windows.net/","queue":"https://asoteststorbpzrrz.queue.core.windows.net/","table":"https://asoteststorbpzrrz.table.core.windows.net/","file":"https://asoteststorbpzrrz.file.core.windows.net/"},"primaryLocation":"westus2","statusOfPrimary":"available"}}' + headers: + Cache-Control: + - no-cache + Content-Length: + - "1447" + Content-Type: + - application/json + Expires: + - "-1" + Pragma: + - no-cache + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + X-Cache: + - CONFIG_NOCACHE + X-Content-Type-Options: + - nosniff + X-Msedge-Ref: + - 'Ref A: 585B5A812E4F401E92339B022D1CF0DF Ref B: CO6AA3150218017 Ref C: 2023-09-01T18:05:16Z' + status: 200 OK + code: 200 + duration: "" +- request: + body: "" + form: {} + headers: + Accept: + - application/json + Test-Request-Attempt: + - "1" + url: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/asotest-rg-drfmps/providers/Microsoft.Storage/storageAccounts/asoteststorbpzrrz?api-version=2022-09-01 + method: GET + response: + body: '{"sku":{"name":"Standard_LRS","tier":"Standard"},"kind":"StorageV2","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/asotest-rg-drfmps/providers/Microsoft.Storage/storageAccounts/asoteststorbpzrrz","name":"asoteststorbpzrrz","type":"Microsoft.Storage/storageAccounts","location":"westus2","tags":{"tag1":"value1"},"properties":{"keyCreationTime":{"key1":"2001-02-03T04:05:06Z","key2":"2001-02-03T04:05:06Z"},"privateEndpointConnections":[],"minimumTlsVersion":"TLS1_0","allowBlobPublicAccess":true,"networkAcls":{"bypass":"AzureServices","virtualNetworkRules":[],"ipRules":[],"defaultAction":"Allow"},"supportsHttpsTrafficOnly":true,"encryption":{"services":{"file":{"keyType":"Account","enabled":true,"lastEnabledTime":"2001-02-03T04:05:06Z"},"blob":{"keyType":"Account","enabled":true,"lastEnabledTime":"2001-02-03T04:05:06Z"}},"keySource":"Microsoft.Storage"},"accessTier":"Hot","provisioningState":"Succeeded","creationTime":"2001-02-03T04:05:06Z","primaryEndpoints":{"dfs":"https://asoteststorbpzrrz.dfs.core.windows.net/","web":"https://asoteststorbpzrrz.z5.web.core.windows.net/","blob":"https://asoteststorbpzrrz.blob.core.windows.net/","queue":"https://asoteststorbpzrrz.queue.core.windows.net/","table":"https://asoteststorbpzrrz.table.core.windows.net/","file":"https://asoteststorbpzrrz.file.core.windows.net/"},"primaryLocation":"westus2","statusOfPrimary":"available"}}' + headers: + Cache-Control: + - no-cache + Content-Length: + - "1447" + Content-Type: + - application/json + Expires: + - "-1" + Pragma: + - no-cache + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + X-Cache: + - CONFIG_NOCACHE + X-Content-Type-Options: + - nosniff + X-Msedge-Ref: + - 'Ref A: E687733EB33743DE89B0C774BF0D103A Ref B: CO6AA3150218017 Ref C: 2023-09-01T18:05:18Z' + status: 200 OK + code: 200 + duration: "" +- request: + body: "" + form: {} + headers: + Accept: + - application/json + Test-Request-Attempt: + - "0" + url: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/asotest-rg-drfmps/providers/Microsoft.Storage/storageAccounts/asoteststorbpzrrz?api-version=2022-09-01 + method: DELETE + response: + body: "" + headers: + Cache-Control: + - no-cache + Content-Length: + - "0" + Content-Type: + - text/plain; charset=utf-8 + Expires: + - "-1" + Pragma: + - no-cache + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + X-Cache: + - CONFIG_NOCACHE + X-Content-Type-Options: + - nosniff + X-Msedge-Ref: + - 'Ref A: 2FCC813057FF4154B50ED11B599A05E8 Ref B: CO6AA3150218017 Ref C: 2023-09-01T18:05:21Z' + status: 200 OK + code: 200 + duration: "" +- request: + body: "" + form: {} + headers: + Accept: + - application/json + Test-Request-Attempt: + - "2" + url: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/asotest-rg-drfmps/providers/Microsoft.Storage/storageAccounts/asoteststorbpzrrz?api-version=2022-09-01 + method: GET + response: + body: '{"error":{"code":"ResourceNotFound","message":"The Resource ''Microsoft.Storage/storageAccounts/asoteststorbpzrrz'' + under resource group ''asotest-rg-drfmps'' was not found. For more details please + go to https://aka.ms/ARMResourceNotFoundFix"}}' + headers: + Cache-Control: + - no-cache + Content-Length: + - "240" + Content-Type: + - application/json; charset=utf-8 + Expires: + - "-1" + Pragma: + - no-cache + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + X-Cache: + - CONFIG_NOCACHE + X-Content-Type-Options: + - nosniff + X-Ms-Failure-Cause: + - gateway + X-Msedge-Ref: + - 'Ref A: EF516024158343EAB662D36E30FAAE07 Ref B: CO6AA3150218017 Ref C: 2023-09-01T18:05:26Z' + status: 404 Not Found + code: 404 + duration: "" +- request: + body: "" + form: {} + headers: + Accept: + - application/json + Test-Request-Attempt: + - "0" + url: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/asotest-rg-drfmps?api-version=2020-06-01 + method: DELETE + response: + body: "" + headers: + Cache-Control: + - no-cache + Content-Length: + - "0" + Expires: + - "-1" + Location: + - https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/operationresults/eyJqb2JJZCI6IlJFU09VUkNFR1JPVVBERUxFVElPTkpPQi1BU09URVNUOjJEUkc6MkREUkZNUFMtV0VTVFVTMiIsImpvYkxvY2F0aW9uIjoid2VzdHVzMiJ9?api-version=2020-06-01 + Pragma: + - no-cache + Retry-After: + - "15" + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + X-Cache: + - CONFIG_NOCACHE + X-Content-Type-Options: + - nosniff + X-Msedge-Ref: + - 'Ref A: 6CF978626FCC4F2FB181E43211199636 Ref B: CO6AA3150218017 Ref C: 2023-09-01T18:05:26Z' + status: 202 Accepted + code: 202 + duration: "" +- request: + body: "" + form: {} + headers: + Test-Request-Attempt: + - "0" + url: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/operationresults/eyJqb2JJZCI6IlJFU09VUkNFR1JPVVBERUxFVElPTkpPQi1BU09URVNUOjJEUkc6MkREUkZNUFMtV0VTVFVTMiIsImpvYkxvY2F0aW9uIjoid2VzdHVzMiJ9?api-version=2020-06-01 + method: GET + response: + body: "" + headers: + Cache-Control: + - no-cache + Content-Length: + - "0" + Expires: + - "-1" + Pragma: + - no-cache + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + X-Cache: + - CONFIG_NOCACHE + X-Content-Type-Options: + - nosniff + X-Msedge-Ref: + - 'Ref A: BAEDFF9AE9CC4EE79D5B6537A100BA74 Ref B: CO6AA3150218017 Ref C: 2023-09-01T18:05:43Z' + status: 200 OK + code: 200 + duration: "" diff --git a/v2/internal/controllers/recordings/Test_OwnerIsARMIDOfWrongType_Rejected.yaml b/v2/internal/controllers/recordings/Test_OwnerIsARMIDOfWrongType_Rejected.yaml new file mode 100644 index 00000000000..9f30f4f2d20 --- /dev/null +++ b/v2/internal/controllers/recordings/Test_OwnerIsARMIDOfWrongType_Rejected.yaml @@ -0,0 +1,141 @@ +--- +version: 1 +interactions: +- request: + body: '{"location":"westus2","name":"asotest-rg-tqvpug","tags":{"CreatedAt":"2001-02-03T04:05:06Z"}}' + form: {} + headers: + Accept: + - application/json + Content-Length: + - "93" + Content-Type: + - application/json + Test-Request-Attempt: + - "0" + url: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/asotest-rg-tqvpug?api-version=2020-06-01 + method: PUT + response: + body: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/asotest-rg-tqvpug","name":"asotest-rg-tqvpug","type":"Microsoft.Resources/resourceGroups","location":"westus2","tags":{"CreatedAt":"2001-02-03T04:05:06Z"},"properties":{"provisioningState":"Succeeded"}}' + headers: + Cache-Control: + - no-cache + Content-Length: + - "276" + Content-Type: + - application/json; charset=utf-8 + Expires: + - "-1" + Pragma: + - no-cache + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + X-Cache: + - CONFIG_NOCACHE + X-Content-Type-Options: + - nosniff + X-Msedge-Ref: + - 'Ref A: 940A86212F9644ADA83518CDBB1271D8 Ref B: CO6AA3150219027 Ref C: 2023-09-01T22:11:32Z' + status: 201 Created + code: 201 + duration: "" +- request: + body: "" + form: {} + headers: + Accept: + - application/json + Test-Request-Attempt: + - "0" + url: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/asotest-rg-tqvpug?api-version=2020-06-01 + method: GET + response: + body: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/asotest-rg-tqvpug","name":"asotest-rg-tqvpug","type":"Microsoft.Resources/resourceGroups","location":"westus2","tags":{"CreatedAt":"2001-02-03T04:05:06Z"},"properties":{"provisioningState":"Succeeded"}}' + headers: + Cache-Control: + - no-cache + Content-Length: + - "276" + Content-Type: + - application/json; charset=utf-8 + Expires: + - "-1" + Pragma: + - no-cache + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + X-Cache: + - CONFIG_NOCACHE + X-Content-Type-Options: + - nosniff + X-Msedge-Ref: + - 'Ref A: F2E8DB66D4EE452E847CBFE3B4A7A170 Ref B: CO6AA3150219027 Ref C: 2023-09-01T22:11:33Z' + status: 200 OK + code: 200 + duration: "" +- request: + body: "" + form: {} + headers: + Accept: + - application/json + Test-Request-Attempt: + - "0" + url: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/asotest-rg-tqvpug?api-version=2020-06-01 + method: DELETE + response: + body: "" + headers: + Cache-Control: + - no-cache + Content-Length: + - "0" + Expires: + - "-1" + Location: + - https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/operationresults/eyJqb2JJZCI6IlJFU09VUkNFR1JPVVBERUxFVElPTkpPQi1BU09URVNUOjJEUkc6MkRUUVZQVUctV0VTVFVTMiIsImpvYkxvY2F0aW9uIjoid2VzdHVzMiJ9?api-version=2020-06-01 + Pragma: + - no-cache + Retry-After: + - "15" + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + X-Cache: + - CONFIG_NOCACHE + X-Content-Type-Options: + - nosniff + X-Msedge-Ref: + - 'Ref A: 3D04055E0A8D45C6B327E555291DE329 Ref B: CO6AA3150219027 Ref C: 2023-09-01T22:11:34Z' + status: 202 Accepted + code: 202 + duration: "" +- request: + body: "" + form: {} + headers: + Test-Request-Attempt: + - "0" + url: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/operationresults/eyJqb2JJZCI6IlJFU09VUkNFR1JPVVBERUxFVElPTkpPQi1BU09URVNUOjJEUkc6MkRUUVZQVUctV0VTVFVTMiIsImpvYkxvY2F0aW9uIjoid2VzdHVzMiJ9?api-version=2020-06-01 + method: GET + response: + body: "" + headers: + Cache-Control: + - no-cache + Content-Length: + - "0" + Expires: + - "-1" + Pragma: + - no-cache + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + X-Cache: + - CONFIG_NOCACHE + X-Content-Type-Options: + - nosniff + X-Msedge-Ref: + - 'Ref A: BF495087336E4E34BA9230050ED908C7 Ref B: CO6AA3150219027 Ref C: 2023-09-01T22:11:50Z' + status: 200 OK + code: 200 + duration: "" diff --git a/v2/internal/controllers/recordings/Test_OwnerIsARMIDSetWithName_Rejected.yaml b/v2/internal/controllers/recordings/Test_OwnerIsARMIDSetWithName_Rejected.yaml new file mode 100644 index 00000000000..b684eca253a --- /dev/null +++ b/v2/internal/controllers/recordings/Test_OwnerIsARMIDSetWithName_Rejected.yaml @@ -0,0 +1,141 @@ +--- +version: 1 +interactions: +- request: + body: '{"location":"westus2","name":"asotest-rg-xpedlj","tags":{"CreatedAt":"2001-02-03T04:05:06Z"}}' + form: {} + headers: + Accept: + - application/json + Content-Length: + - "93" + Content-Type: + - application/json + Test-Request-Attempt: + - "0" + url: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/asotest-rg-xpedlj?api-version=2020-06-01 + method: PUT + response: + body: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/asotest-rg-xpedlj","name":"asotest-rg-xpedlj","type":"Microsoft.Resources/resourceGroups","location":"westus2","tags":{"CreatedAt":"2001-02-03T04:05:06Z"},"properties":{"provisioningState":"Succeeded"}}' + headers: + Cache-Control: + - no-cache + Content-Length: + - "276" + Content-Type: + - application/json; charset=utf-8 + Expires: + - "-1" + Pragma: + - no-cache + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + X-Cache: + - CONFIG_NOCACHE + X-Content-Type-Options: + - nosniff + X-Msedge-Ref: + - 'Ref A: 349DC951900C4FD8B95A59030FFC383D Ref B: CO6AA3150218037 Ref C: 2023-09-01T19:35:46Z' + status: 201 Created + code: 201 + duration: "" +- request: + body: "" + form: {} + headers: + Accept: + - application/json + Test-Request-Attempt: + - "0" + url: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/asotest-rg-xpedlj?api-version=2020-06-01 + method: GET + response: + body: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/asotest-rg-xpedlj","name":"asotest-rg-xpedlj","type":"Microsoft.Resources/resourceGroups","location":"westus2","tags":{"CreatedAt":"2001-02-03T04:05:06Z"},"properties":{"provisioningState":"Succeeded"}}' + headers: + Cache-Control: + - no-cache + Content-Length: + - "276" + Content-Type: + - application/json; charset=utf-8 + Expires: + - "-1" + Pragma: + - no-cache + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + X-Cache: + - CONFIG_NOCACHE + X-Content-Type-Options: + - nosniff + X-Msedge-Ref: + - 'Ref A: B811D771571C4CE696D63BE031A405E0 Ref B: CO6AA3150218037 Ref C: 2023-09-01T19:35:46Z' + status: 200 OK + code: 200 + duration: "" +- request: + body: "" + form: {} + headers: + Accept: + - application/json + Test-Request-Attempt: + - "0" + url: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/asotest-rg-xpedlj?api-version=2020-06-01 + method: DELETE + response: + body: "" + headers: + Cache-Control: + - no-cache + Content-Length: + - "0" + Expires: + - "-1" + Location: + - https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/operationresults/eyJqb2JJZCI6IlJFU09VUkNFR1JPVVBERUxFVElPTkpPQi1BU09URVNUOjJEUkc6MkRYUEVETEotV0VTVFVTMiIsImpvYkxvY2F0aW9uIjoid2VzdHVzMiJ9?api-version=2020-06-01 + Pragma: + - no-cache + Retry-After: + - "15" + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + X-Cache: + - CONFIG_NOCACHE + X-Content-Type-Options: + - nosniff + X-Msedge-Ref: + - 'Ref A: 39C886FD46D144EDBF4942D2B885B7A4 Ref B: CO6AA3150218037 Ref C: 2023-09-01T19:35:48Z' + status: 202 Accepted + code: 202 + duration: "" +- request: + body: "" + form: {} + headers: + Test-Request-Attempt: + - "0" + url: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/operationresults/eyJqb2JJZCI6IlJFU09VUkNFR1JPVVBERUxFVElPTkpPQi1BU09URVNUOjJEUkc6MkRYUEVETEotV0VTVFVTMiIsImpvYkxvY2F0aW9uIjoid2VzdHVzMiJ9?api-version=2020-06-01 + method: GET + response: + body: "" + headers: + Cache-Control: + - no-cache + Content-Length: + - "0" + Expires: + - "-1" + Pragma: + - no-cache + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + X-Cache: + - CONFIG_NOCACHE + X-Content-Type-Options: + - nosniff + X-Msedge-Ref: + - 'Ref A: 22981FB784E24DE28D969BDBA446A2F7 Ref B: CO6AA3150218037 Ref C: 2023-09-01T19:36:03Z' + status: 200 OK + code: 200 + duration: "" diff --git a/v2/internal/controllers/recordings/Test_OwnerIsARMID_ExtensionResourceSuccessfullyReconciled.yaml b/v2/internal/controllers/recordings/Test_OwnerIsARMID_ExtensionResourceSuccessfullyReconciled.yaml new file mode 100644 index 00000000000..ceb4bd0d855 --- /dev/null +++ b/v2/internal/controllers/recordings/Test_OwnerIsARMID_ExtensionResourceSuccessfullyReconciled.yaml @@ -0,0 +1,789 @@ +--- +version: 1 +interactions: +- request: + body: '{"location":"westus2","name":"asotest-rg-ivnajy","tags":{"CreatedAt":"2001-02-03T04:05:06Z"}}' + form: {} + headers: + Accept: + - application/json + Content-Length: + - "93" + Content-Type: + - application/json + Test-Request-Attempt: + - "0" + url: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/asotest-rg-ivnajy?api-version=2020-06-01 + method: PUT + response: + body: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/asotest-rg-ivnajy","name":"asotest-rg-ivnajy","type":"Microsoft.Resources/resourceGroups","location":"westus2","tags":{"CreatedAt":"2001-02-03T04:05:06Z"},"properties":{"provisioningState":"Succeeded"}}' + headers: + Cache-Control: + - no-cache + Content-Length: + - "276" + Content-Type: + - application/json; charset=utf-8 + Expires: + - "-1" + Pragma: + - no-cache + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + X-Cache: + - CONFIG_NOCACHE + X-Content-Type-Options: + - nosniff + X-Msedge-Ref: + - 'Ref A: EC8DACA3E08544CF9867DF59A6879591 Ref B: CO6AA3150218017 Ref C: 2023-09-01T18:33:13Z' + status: 201 Created + code: 201 + duration: "" +- request: + body: "" + form: {} + headers: + Accept: + - application/json + Test-Request-Attempt: + - "0" + url: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/asotest-rg-ivnajy?api-version=2020-06-01 + method: GET + response: + body: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/asotest-rg-ivnajy","name":"asotest-rg-ivnajy","type":"Microsoft.Resources/resourceGroups","location":"westus2","tags":{"CreatedAt":"2001-02-03T04:05:06Z"},"properties":{"provisioningState":"Succeeded"}}' + headers: + Cache-Control: + - no-cache + Content-Length: + - "276" + Content-Type: + - application/json; charset=utf-8 + Expires: + - "-1" + Pragma: + - no-cache + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + X-Cache: + - CONFIG_NOCACHE + X-Content-Type-Options: + - nosniff + X-Msedge-Ref: + - 'Ref A: D23718F89BE04CA282C91BCA699937DE Ref B: CO6AA3150218017 Ref C: 2023-09-01T18:33:14Z' + status: 200 OK + code: 200 + duration: "" +- request: + body: '{"location":"westus2","name":"asotest-mi-dmkpnx"}' + form: {} + headers: + Accept: + - application/json + Content-Length: + - "49" + Content-Type: + - application/json + Test-Request-Attempt: + - "0" + url: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/asotest-rg-ivnajy/providers/Microsoft.ManagedIdentity/userAssignedIdentities/asotest-mi-dmkpnx?api-version=2018-11-30 + method: PUT + response: + body: '{"location":"westus2","tags":{},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/asotest-rg-ivnajy/providers/Microsoft.ManagedIdentity/userAssignedIdentities/asotest-mi-dmkpnx","name":"asotest-mi-dmkpnx","type":"Microsoft.ManagedIdentity/userAssignedIdentities","properties":{"tenantId":"00000000-0000-0000-0000-000000000000","principalId":"07ef5046-5a76-4bd1-810f-d23d72476aac","clientId":"4c10f681-294e-4fa5-89b6-02ef0f4e40bc"}}' + headers: + Cache-Control: + - no-cache + Content-Length: + - "454" + Content-Type: + - application/json; charset=utf-8 + Expires: + - "-1" + Location: + - /subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/asotest-rg-ivnajy/providers/Microsoft.ManagedIdentity/userAssignedIdentities/asotest-mi-dmkpnx + Pragma: + - no-cache + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + X-Cache: + - CONFIG_NOCACHE + X-Content-Type-Options: + - nosniff + X-Msedge-Ref: + - 'Ref A: 25E73CDA24594D878ED814BA3F880376 Ref B: CO6AA3150218017 Ref C: 2023-09-01T18:33:16Z' + status: 201 Created + code: 201 + duration: "" +- request: + body: '{"location":"westus2","name":"asotest-mi-dmkpnx"}' + form: {} + headers: + Accept: + - application/json + Content-Length: + - "49" + Content-Type: + - application/json + Test-Request-Attempt: + - "1" + url: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/asotest-rg-ivnajy/providers/Microsoft.ManagedIdentity/userAssignedIdentities/asotest-mi-dmkpnx?api-version=2018-11-30 + method: PUT + response: + body: '{"location":"westus2","tags":{},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/asotest-rg-ivnajy/providers/Microsoft.ManagedIdentity/userAssignedIdentities/asotest-mi-dmkpnx","name":"asotest-mi-dmkpnx","type":"Microsoft.ManagedIdentity/userAssignedIdentities","properties":{"tenantId":"00000000-0000-0000-0000-000000000000","principalId":"07ef5046-5a76-4bd1-810f-d23d72476aac","clientId":"4c10f681-294e-4fa5-89b6-02ef0f4e40bc"}}' + headers: + Cache-Control: + - no-cache + Content-Length: + - "454" + Content-Type: + - application/json; charset=utf-8 + Expires: + - "-1" + Pragma: + - no-cache + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + X-Cache: + - CONFIG_NOCACHE + X-Content-Type-Options: + - nosniff + X-Msedge-Ref: + - 'Ref A: A919A3D8D23A4705A2DCD22B0CF059CD Ref B: CO6AA3150218017 Ref C: 2023-09-01T18:33:18Z' + status: 200 OK + code: 200 + duration: "" +- request: + body: "" + form: {} + headers: + Accept: + - application/json + Test-Request-Attempt: + - "0" + url: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/asotest-rg-ivnajy/providers/Microsoft.ManagedIdentity/userAssignedIdentities/asotest-mi-dmkpnx?api-version=2018-11-30 + method: GET + response: + body: '{"location":"westus2","tags":{},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/asotest-rg-ivnajy/providers/Microsoft.ManagedIdentity/userAssignedIdentities/asotest-mi-dmkpnx","name":"asotest-mi-dmkpnx","type":"Microsoft.ManagedIdentity/userAssignedIdentities","properties":{"tenantId":"00000000-0000-0000-0000-000000000000","principalId":"07ef5046-5a76-4bd1-810f-d23d72476aac","clientId":"4c10f681-294e-4fa5-89b6-02ef0f4e40bc"}}' + headers: + Cache-Control: + - no-cache + Content-Length: + - "454" + Content-Type: + - application/json; charset=utf-8 + Expires: + - "-1" + Pragma: + - no-cache + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + X-Cache: + - CONFIG_NOCACHE + X-Content-Type-Options: + - nosniff + X-Msedge-Ref: + - 'Ref A: AF916FAFD51C4FB7B5E14AD3192C53DF Ref B: CO6AA3150218017 Ref C: 2023-09-01T18:33:18Z' + status: 200 OK + code: 200 + duration: "" +- request: + body: '{"name":"a3514350-162b-50a6-87f0-60df62359c59","properties":{"principalId":"07ef5046-5a76-4bd1-810f-d23d72476aac","roleDefinitionId":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Authorization/roleDefinitions/b24988ac-6180-42a0-ab88-20f7382dd24c"}}' + form: {} + headers: + Accept: + - application/json + Content-Length: + - "275" + Content-Type: + - application/json + Test-Request-Attempt: + - "0" + url: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/asotest-rg-ivnajy/providers/Microsoft.ManagedIdentity/userAssignedIdentities/asotest-mi-dmkpnx/providers/Microsoft.Authorization/roleAssignments/a3514350-162b-50a6-87f0-60df62359c59?api-version=2020-08-01-preview + method: PUT + response: + body: '{"error":{"code":"PrincipalNotFound","message":"Principal 07ef50465a764bd1810fd23d72476aac + does not exist in the directory 00000000-0000-0000-0000-000000000000. Check + that you have the correct principal ID. If you are creating this principal and + then immediately assigning a role, this error might be related to a replication + delay. In this case, set the role assignment principalType property to a value, + such as ServicePrincipal, User, or Group. See https://aka.ms/docs-principaltype"}}' + headers: + Cache-Control: + - no-cache + Content-Length: + - "489" + Content-Type: + - application/json; charset=utf-8 + Expires: + - "-1" + Pragma: + - no-cache + Set-Cookie: + - x-ms-gateway-slice=Production; path=/; secure; samesite=none; httponly + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + X-Cache: + - CONFIG_NOCACHE + X-Content-Type-Options: + - nosniff + X-Msedge-Ref: + - 'Ref A: 590ED296CE224544BD977F59279AB2E0 Ref B: CO6AA3150218017 Ref C: 2023-09-01T18:33:21Z' + status: 400 Bad Request + code: 400 + duration: "" +- request: + body: '{"name":"a3514350-162b-50a6-87f0-60df62359c59","properties":{"principalId":"07ef5046-5a76-4bd1-810f-d23d72476aac","roleDefinitionId":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Authorization/roleDefinitions/b24988ac-6180-42a0-ab88-20f7382dd24c"}}' + form: {} + headers: + Accept: + - application/json + Content-Length: + - "275" + Content-Type: + - application/json + Test-Request-Attempt: + - "1" + url: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/asotest-rg-ivnajy/providers/Microsoft.ManagedIdentity/userAssignedIdentities/asotest-mi-dmkpnx/providers/Microsoft.Authorization/roleAssignments/a3514350-162b-50a6-87f0-60df62359c59?api-version=2020-08-01-preview + method: PUT + response: + body: '{"error":{"code":"PrincipalNotFound","message":"Principal 07ef50465a764bd1810fd23d72476aac + does not exist in the directory 00000000-0000-0000-0000-000000000000. Check + that you have the correct principal ID. If you are creating this principal and + then immediately assigning a role, this error might be related to a replication + delay. In this case, set the role assignment principalType property to a value, + such as ServicePrincipal, User, or Group. See https://aka.ms/docs-principaltype"}}' + headers: + Cache-Control: + - no-cache + Content-Length: + - "489" + Content-Type: + - application/json; charset=utf-8 + Expires: + - "-1" + Pragma: + - no-cache + Set-Cookie: + - x-ms-gateway-slice=Production; path=/; secure; samesite=none; httponly + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + X-Cache: + - CONFIG_NOCACHE + X-Content-Type-Options: + - nosniff + X-Msedge-Ref: + - 'Ref A: 3AE5B6B4C09544D0815EBF3D9223691A Ref B: CO6AA3150218017 Ref C: 2023-09-01T18:33:22Z' + status: 400 Bad Request + code: 400 + duration: "" +- request: + body: '{"name":"a3514350-162b-50a6-87f0-60df62359c59","properties":{"principalId":"07ef5046-5a76-4bd1-810f-d23d72476aac","roleDefinitionId":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Authorization/roleDefinitions/b24988ac-6180-42a0-ab88-20f7382dd24c"}}' + form: {} + headers: + Accept: + - application/json + Content-Length: + - "275" + Content-Type: + - application/json + Test-Request-Attempt: + - "2" + url: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/asotest-rg-ivnajy/providers/Microsoft.ManagedIdentity/userAssignedIdentities/asotest-mi-dmkpnx/providers/Microsoft.Authorization/roleAssignments/a3514350-162b-50a6-87f0-60df62359c59?api-version=2020-08-01-preview + method: PUT + response: + body: '{"error":{"code":"PrincipalNotFound","message":"Principal 07ef50465a764bd1810fd23d72476aac + does not exist in the directory 00000000-0000-0000-0000-000000000000. Check + that you have the correct principal ID. If you are creating this principal and + then immediately assigning a role, this error might be related to a replication + delay. In this case, set the role assignment principalType property to a value, + such as ServicePrincipal, User, or Group. See https://aka.ms/docs-principaltype"}}' + headers: + Cache-Control: + - no-cache + Content-Length: + - "489" + Content-Type: + - application/json; charset=utf-8 + Expires: + - "-1" + Pragma: + - no-cache + Set-Cookie: + - x-ms-gateway-slice=Production; path=/; secure; samesite=none; httponly + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + X-Cache: + - CONFIG_NOCACHE + X-Content-Type-Options: + - nosniff + X-Msedge-Ref: + - 'Ref A: 9375B39ED10A433BBCF7FCC69457FBFE Ref B: CO6AA3150218017 Ref C: 2023-09-01T18:33:26Z' + status: 400 Bad Request + code: 400 + duration: "" +- request: + body: '{"name":"a3514350-162b-50a6-87f0-60df62359c59","properties":{"principalId":"07ef5046-5a76-4bd1-810f-d23d72476aac","roleDefinitionId":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Authorization/roleDefinitions/b24988ac-6180-42a0-ab88-20f7382dd24c"}}' + form: {} + headers: + Accept: + - application/json + Content-Length: + - "275" + Content-Type: + - application/json + Test-Request-Attempt: + - "3" + url: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/asotest-rg-ivnajy/providers/Microsoft.ManagedIdentity/userAssignedIdentities/asotest-mi-dmkpnx/providers/Microsoft.Authorization/roleAssignments/a3514350-162b-50a6-87f0-60df62359c59?api-version=2020-08-01-preview + method: PUT + response: + body: '{"error":{"code":"PrincipalNotFound","message":"Principal 07ef50465a764bd1810fd23d72476aac + does not exist in the directory 00000000-0000-0000-0000-000000000000. Check + that you have the correct principal ID. If you are creating this principal and + then immediately assigning a role, this error might be related to a replication + delay. In this case, set the role assignment principalType property to a value, + such as ServicePrincipal, User, or Group. See https://aka.ms/docs-principaltype"}}' + headers: + Cache-Control: + - no-cache + Content-Length: + - "489" + Content-Type: + - application/json; charset=utf-8 + Expires: + - "-1" + Pragma: + - no-cache + Set-Cookie: + - x-ms-gateway-slice=Production; path=/; secure; samesite=none; httponly + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + X-Cache: + - CONFIG_NOCACHE + X-Content-Type-Options: + - nosniff + X-Msedge-Ref: + - 'Ref A: FFEFF989751841928D3823AC3C004D48 Ref B: CO6AA3150218017 Ref C: 2023-09-01T18:33:30Z' + status: 400 Bad Request + code: 400 + duration: "" +- request: + body: '{"name":"a3514350-162b-50a6-87f0-60df62359c59","properties":{"principalId":"07ef5046-5a76-4bd1-810f-d23d72476aac","roleDefinitionId":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Authorization/roleDefinitions/b24988ac-6180-42a0-ab88-20f7382dd24c"}}' + form: {} + headers: + Accept: + - application/json + Content-Length: + - "275" + Content-Type: + - application/json + Test-Request-Attempt: + - "4" + url: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/asotest-rg-ivnajy/providers/Microsoft.ManagedIdentity/userAssignedIdentities/asotest-mi-dmkpnx/providers/Microsoft.Authorization/roleAssignments/a3514350-162b-50a6-87f0-60df62359c59?api-version=2020-08-01-preview + method: PUT + response: + body: '{"properties":{"roleDefinitionId":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Authorization/roleDefinitions/b24988ac-6180-42a0-ab88-20f7382dd24c","principalId":"07ef5046-5a76-4bd1-810f-d23d72476aac","principalType":"ServicePrincipal","scope":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/asotest-rg-ivnajy/providers/Microsoft.ManagedIdentity/userAssignedIdentities/asotest-mi-dmkpnx","condition":null,"conditionVersion":null,"createdOn":"2001-02-03T04:05:06Z","updatedOn":"2001-02-03T04:05:06Z","createdBy":null,"updatedBy":"84f47115-7605-44df-accf-7e01c55e425f","delegatedManagedIdentityResourceId":null,"description":null},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/asotest-rg-ivnajy/providers/Microsoft.ManagedIdentity/userAssignedIdentities/asotest-mi-dmkpnx/providers/Microsoft.Authorization/roleAssignments/a3514350-162b-50a6-87f0-60df62359c59","type":"Microsoft.Authorization/roleAssignments","name":"a3514350-162b-50a6-87f0-60df62359c59"}' + headers: + Cache-Control: + - no-cache + Content-Length: + - "1043" + Content-Type: + - application/json; charset=utf-8 + Expires: + - "-1" + Pragma: + - no-cache + Set-Cookie: + - x-ms-gateway-slice=Production; path=/; secure; samesite=none; httponly + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + X-Cache: + - CONFIG_NOCACHE + X-Content-Type-Options: + - nosniff + X-Msedge-Ref: + - 'Ref A: D5D8CB88044C463FAA44B04A8732DC46 Ref B: CO6AA3150218017 Ref C: 2023-09-01T18:33:39Z' + status: 201 Created + code: 201 + duration: "" +- request: + body: "" + form: {} + headers: + Test-Request-Attempt: + - "0" + url: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/asotest-rg-ivnajy/providers/Microsoft.ManagedIdentity/userAssignedIdentities/asotest-mi-dmkpnx/providers/Microsoft.Authorization/roleAssignments/a3514350-162b-50a6-87f0-60df62359c59?api-version=2020-08-01-preview + method: GET + response: + body: '{"properties":{"roleDefinitionId":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Authorization/roleDefinitions/b24988ac-6180-42a0-ab88-20f7382dd24c","principalId":"07ef5046-5a76-4bd1-810f-d23d72476aac","principalType":"ServicePrincipal","scope":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/asotest-rg-ivnajy/providers/Microsoft.ManagedIdentity/userAssignedIdentities/asotest-mi-dmkpnx","condition":null,"conditionVersion":null,"createdOn":"2001-02-03T04:05:06Z","updatedOn":"2001-02-03T04:05:06Z","createdBy":"84f47115-7605-44df-accf-7e01c55e425f","updatedBy":"84f47115-7605-44df-accf-7e01c55e425f","delegatedManagedIdentityResourceId":null,"description":null},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/asotest-rg-ivnajy/providers/Microsoft.ManagedIdentity/userAssignedIdentities/asotest-mi-dmkpnx/providers/Microsoft.Authorization/roleAssignments/a3514350-162b-50a6-87f0-60df62359c59","type":"Microsoft.Authorization/roleAssignments","name":"a3514350-162b-50a6-87f0-60df62359c59"}' + headers: + Cache-Control: + - no-cache + Content-Length: + - "1077" + Content-Type: + - application/json; charset=utf-8 + Expires: + - "-1" + Pragma: + - no-cache + Set-Cookie: + - x-ms-gateway-slice=Production; path=/; secure; samesite=none; httponly + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + X-Cache: + - CONFIG_NOCACHE + X-Content-Type-Options: + - nosniff + X-Msedge-Ref: + - 'Ref A: ADEB8F11FCFE4CE788856C06E7B01E2F Ref B: CO6AA3150218017 Ref C: 2023-09-01T18:33:41Z' + status: 200 OK + code: 200 + duration: "" +- request: + body: "" + form: {} + headers: + Accept: + - application/json + Test-Request-Attempt: + - "1" + url: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/asotest-rg-ivnajy/providers/Microsoft.ManagedIdentity/userAssignedIdentities/asotest-mi-dmkpnx/providers/Microsoft.Authorization/roleAssignments/a3514350-162b-50a6-87f0-60df62359c59?api-version=2020-08-01-preview + method: GET + response: + body: '{"properties":{"roleDefinitionId":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Authorization/roleDefinitions/b24988ac-6180-42a0-ab88-20f7382dd24c","principalId":"07ef5046-5a76-4bd1-810f-d23d72476aac","principalType":"ServicePrincipal","scope":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/asotest-rg-ivnajy/providers/Microsoft.ManagedIdentity/userAssignedIdentities/asotest-mi-dmkpnx","condition":null,"conditionVersion":null,"createdOn":"2001-02-03T04:05:06Z","updatedOn":"2001-02-03T04:05:06Z","createdBy":"84f47115-7605-44df-accf-7e01c55e425f","updatedBy":"84f47115-7605-44df-accf-7e01c55e425f","delegatedManagedIdentityResourceId":null,"description":null},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/asotest-rg-ivnajy/providers/Microsoft.ManagedIdentity/userAssignedIdentities/asotest-mi-dmkpnx/providers/Microsoft.Authorization/roleAssignments/a3514350-162b-50a6-87f0-60df62359c59","type":"Microsoft.Authorization/roleAssignments","name":"a3514350-162b-50a6-87f0-60df62359c59"}' + headers: + Cache-Control: + - no-cache + Content-Length: + - "1077" + Content-Type: + - application/json; charset=utf-8 + Expires: + - "-1" + Pragma: + - no-cache + Set-Cookie: + - x-ms-gateway-slice=Production; path=/; secure; samesite=none; httponly + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + X-Cache: + - CONFIG_NOCACHE + X-Content-Type-Options: + - nosniff + X-Msedge-Ref: + - 'Ref A: CBE82EEC7335452FAE11E3D58389C3B8 Ref B: CO6AA3150218017 Ref C: 2023-09-01T18:33:41Z' + status: 200 OK + code: 200 + duration: "" +- request: + body: "" + form: {} + headers: + Accept: + - application/json + Test-Request-Attempt: + - "0" + url: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/asotest-rg-ivnajy/providers/Microsoft.ManagedIdentity/userAssignedIdentities/asotest-mi-dmkpnx/providers/Microsoft.Authorization/roleAssignments/a3514350-162b-50a6-87f0-60df62359c59?api-version=2020-08-01-preview + method: DELETE + response: + body: '{"properties":{"roleDefinitionId":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Authorization/roleDefinitions/b24988ac-6180-42a0-ab88-20f7382dd24c","principalId":"07ef5046-5a76-4bd1-810f-d23d72476aac","principalType":"ServicePrincipal","scope":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/asotest-rg-ivnajy/providers/Microsoft.ManagedIdentity/userAssignedIdentities/asotest-mi-dmkpnx","condition":null,"conditionVersion":null,"createdOn":"2001-02-03T04:05:06Z","updatedOn":"2001-02-03T04:05:06Z","createdBy":"84f47115-7605-44df-accf-7e01c55e425f","updatedBy":"84f47115-7605-44df-accf-7e01c55e425f","delegatedManagedIdentityResourceId":null,"description":null},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/asotest-rg-ivnajy/providers/Microsoft.ManagedIdentity/userAssignedIdentities/asotest-mi-dmkpnx/providers/Microsoft.Authorization/roleAssignments/a3514350-162b-50a6-87f0-60df62359c59","type":"Microsoft.Authorization/roleAssignments","name":"a3514350-162b-50a6-87f0-60df62359c59"}' + headers: + Cache-Control: + - no-cache + Content-Length: + - "1077" + Content-Type: + - application/json; charset=utf-8 + Expires: + - "-1" + Pragma: + - no-cache + Set-Cookie: + - x-ms-gateway-slice=Production; path=/; secure; samesite=none; httponly + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + X-Cache: + - CONFIG_NOCACHE + X-Content-Type-Options: + - nosniff + X-Msedge-Ref: + - 'Ref A: E2EFC443E7F7426083F09E988E541E09 Ref B: CO6AA3150218017 Ref C: 2023-09-01T18:33:46Z' + status: 200 OK + code: 200 + duration: "" +- request: + body: "" + form: {} + headers: + Accept: + - application/json + Test-Request-Attempt: + - "2" + url: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/asotest-rg-ivnajy/providers/Microsoft.ManagedIdentity/userAssignedIdentities/asotest-mi-dmkpnx/providers/Microsoft.Authorization/roleAssignments/a3514350-162b-50a6-87f0-60df62359c59?api-version=2020-08-01-preview + method: GET + response: + body: '{"error":{"code":"RoleAssignmentNotFound","message":"The role assignment + ''a3514350-162b-50a6-87f0-60df62359c59'' is not found."}}' + headers: + Cache-Control: + - no-cache + Content-Length: + - "128" + Content-Type: + - application/json; charset=utf-8 + Expires: + - "-1" + Pragma: + - no-cache + Set-Cookie: + - x-ms-gateway-slice=Production; path=/; secure; samesite=none; httponly + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + X-Cache: + - CONFIG_NOCACHE + X-Content-Type-Options: + - nosniff + X-Msedge-Ref: + - 'Ref A: 322D24FBB26F416C8B173F608F03E5BB Ref B: CO6AA3150218017 Ref C: 2023-09-01T18:33:51Z' + status: 404 Not Found + code: 404 + duration: "" +- request: + body: "" + form: {} + headers: + Accept: + - application/json + Test-Request-Attempt: + - "0" + url: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/asotest-rg-ivnajy?api-version=2020-06-01 + method: DELETE + response: + body: "" + headers: + Cache-Control: + - no-cache + Content-Length: + - "0" + Expires: + - "-1" + Location: + - https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/operationresults/eyJqb2JJZCI6IlJFU09VUkNFR1JPVVBERUxFVElPTkpPQi1BU09URVNUOjJEUkc6MkRJVk5BSlktV0VTVFVTMiIsImpvYkxvY2F0aW9uIjoid2VzdHVzMiJ9?api-version=2020-06-01 + Pragma: + - no-cache + Retry-After: + - "15" + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + X-Cache: + - CONFIG_NOCACHE + X-Content-Type-Options: + - nosniff + X-Msedge-Ref: + - 'Ref A: 85EE3EA54F154A3EA9E8A83949253908 Ref B: CO6AA3150218017 Ref C: 2023-09-01T18:33:51Z' + status: 202 Accepted + code: 202 + duration: "" +- request: + body: "" + form: {} + headers: + Test-Request-Attempt: + - "0" + url: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/operationresults/eyJqb2JJZCI6IlJFU09VUkNFR1JPVVBERUxFVElPTkpPQi1BU09URVNUOjJEUkc6MkRJVk5BSlktV0VTVFVTMiIsImpvYkxvY2F0aW9uIjoid2VzdHVzMiJ9?api-version=2020-06-01 + method: GET + response: + body: "" + headers: + Cache-Control: + - no-cache + Content-Length: + - "0" + Expires: + - "-1" + Location: + - https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/operationresults/eyJqb2JJZCI6IlJFU09VUkNFR1JPVVBERUxFVElPTkpPQi1BU09URVNUOjJEUkc6MkRJVk5BSlktV0VTVFVTMiIsImpvYkxvY2F0aW9uIjoid2VzdHVzMiJ9?api-version=2020-06-01 + Pragma: + - no-cache + Retry-After: + - "15" + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + X-Cache: + - CONFIG_NOCACHE + X-Content-Type-Options: + - nosniff + X-Msedge-Ref: + - 'Ref A: C483C7CACC8F4095AF914D2FC37D0260 Ref B: CO6AA3150218017 Ref C: 2023-09-01T18:34:07Z' + status: 202 Accepted + code: 202 + duration: "" +- request: + body: "" + form: {} + headers: + Test-Request-Attempt: + - "1" + url: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/operationresults/eyJqb2JJZCI6IlJFU09VUkNFR1JPVVBERUxFVElPTkpPQi1BU09URVNUOjJEUkc6MkRJVk5BSlktV0VTVFVTMiIsImpvYkxvY2F0aW9uIjoid2VzdHVzMiJ9?api-version=2020-06-01 + method: GET + response: + body: "" + headers: + Cache-Control: + - no-cache + Content-Length: + - "0" + Expires: + - "-1" + Location: + - https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/operationresults/eyJqb2JJZCI6IlJFU09VUkNFR1JPVVBERUxFVElPTkpPQi1BU09URVNUOjJEUkc6MkRJVk5BSlktV0VTVFVTMiIsImpvYkxvY2F0aW9uIjoid2VzdHVzMiJ9?api-version=2020-06-01 + Pragma: + - no-cache + Retry-After: + - "15" + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + X-Cache: + - CONFIG_NOCACHE + X-Content-Type-Options: + - nosniff + X-Msedge-Ref: + - 'Ref A: 33B81DFF61E24B5F979EE44C0E4D933C Ref B: CO6AA3150218017 Ref C: 2023-09-01T18:34:22Z' + status: 202 Accepted + code: 202 + duration: "" +- request: + body: "" + form: {} + headers: + Test-Request-Attempt: + - "2" + url: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/operationresults/eyJqb2JJZCI6IlJFU09VUkNFR1JPVVBERUxFVElPTkpPQi1BU09URVNUOjJEUkc6MkRJVk5BSlktV0VTVFVTMiIsImpvYkxvY2F0aW9uIjoid2VzdHVzMiJ9?api-version=2020-06-01 + method: GET + response: + body: "" + headers: + Cache-Control: + - no-cache + Content-Length: + - "0" + Expires: + - "-1" + Location: + - https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/operationresults/eyJqb2JJZCI6IlJFU09VUkNFR1JPVVBERUxFVElPTkpPQi1BU09URVNUOjJEUkc6MkRJVk5BSlktV0VTVFVTMiIsImpvYkxvY2F0aW9uIjoid2VzdHVzMiJ9?api-version=2020-06-01 + Pragma: + - no-cache + Retry-After: + - "15" + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + X-Cache: + - CONFIG_NOCACHE + X-Content-Type-Options: + - nosniff + X-Msedge-Ref: + - 'Ref A: E738D59EC5F440C69C1CCC25ECC3575D Ref B: CO6AA3150218017 Ref C: 2023-09-01T18:34:37Z' + status: 202 Accepted + code: 202 + duration: "" +- request: + body: "" + form: {} + headers: + Test-Request-Attempt: + - "3" + url: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/operationresults/eyJqb2JJZCI6IlJFU09VUkNFR1JPVVBERUxFVElPTkpPQi1BU09URVNUOjJEUkc6MkRJVk5BSlktV0VTVFVTMiIsImpvYkxvY2F0aW9uIjoid2VzdHVzMiJ9?api-version=2020-06-01 + method: GET + response: + body: "" + headers: + Cache-Control: + - no-cache + Content-Length: + - "0" + Expires: + - "-1" + Location: + - https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/operationresults/eyJqb2JJZCI6IlJFU09VUkNFR1JPVVBERUxFVElPTkpPQi1BU09URVNUOjJEUkc6MkRJVk5BSlktV0VTVFVTMiIsImpvYkxvY2F0aW9uIjoid2VzdHVzMiJ9?api-version=2020-06-01 + Pragma: + - no-cache + Retry-After: + - "15" + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + X-Cache: + - CONFIG_NOCACHE + X-Content-Type-Options: + - nosniff + X-Msedge-Ref: + - 'Ref A: 88A1BFF35A9B4863B44C274942842E9E Ref B: CO6AA3150218017 Ref C: 2023-09-01T18:34:52Z' + status: 202 Accepted + code: 202 + duration: "" +- request: + body: "" + form: {} + headers: + Test-Request-Attempt: + - "4" + url: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/operationresults/eyJqb2JJZCI6IlJFU09VUkNFR1JPVVBERUxFVElPTkpPQi1BU09URVNUOjJEUkc6MkRJVk5BSlktV0VTVFVTMiIsImpvYkxvY2F0aW9uIjoid2VzdHVzMiJ9?api-version=2020-06-01 + method: GET + response: + body: "" + headers: + Cache-Control: + - no-cache + Content-Length: + - "0" + Expires: + - "-1" + Pragma: + - no-cache + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + X-Cache: + - CONFIG_NOCACHE + X-Content-Type-Options: + - nosniff + X-Msedge-Ref: + - 'Ref A: 0C30E530B4D84C1DBCD9FFA5A6CAF900 Ref B: CO6AA3150218017 Ref C: 2023-09-01T18:35:07Z' + status: 200 OK + code: 200 + duration: "" +- request: + body: "" + form: {} + headers: + Accept: + - application/json + Test-Request-Attempt: + - "0" + url: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/asotest-rg-ivnajy/providers/Microsoft.ManagedIdentity/userAssignedIdentities/asotest-mi-dmkpnx?api-version=2018-11-30 + method: DELETE + response: + body: '{"error":{"code":"ResourceGroupNotFound","message":"Resource group ''asotest-rg-ivnajy'' + could not be found."}}' + headers: + Cache-Control: + - no-cache + Content-Length: + - "109" + Content-Type: + - application/json; charset=utf-8 + Expires: + - "-1" + Pragma: + - no-cache + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + X-Cache: + - CONFIG_NOCACHE + X-Content-Type-Options: + - nosniff + X-Ms-Failure-Cause: + - gateway + X-Msedge-Ref: + - 'Ref A: AC1760DBC713406880D3D9386D96FB35 Ref B: CO6AA3150218017 Ref C: 2023-09-01T18:35:11Z' + status: 404 Not Found + code: 404 + duration: "" diff --git a/v2/internal/reconcilers/arm/azure_generic_arm_reconciler_instance.go b/v2/internal/reconcilers/arm/azure_generic_arm_reconciler_instance.go index 89b57736ab2..d8781a91c67 100644 --- a/v2/internal/reconcilers/arm/azure_generic_arm_reconciler_instance.go +++ b/v2/internal/reconcilers/arm/azure_generic_arm_reconciler_instance.go @@ -350,14 +350,14 @@ func (r *azureDeploymentReconcilerInstance) preReconciliationCheck(ctx context.C } // We also need to have our owner, it too with an up-to-date status - owner, ownerErr := r.ResourceResolver.ResolveOwner(ctx, r.Obj) + ownerDetails, ownerErr := r.ResourceResolver.ResolveOwner(ctx, r.Obj) if ownerErr != nil { // We can't obtain the owner, so we can't run the extension return extensions.PreReconcileCheckResult{}, ownerErr } // Run our pre-reconciliation checker - check, checkErr := checker(ctx, r.Obj, owner, r.ResourceResolver, r.ARMConnection.Client(), r.Log) + check, checkErr := checker(ctx, r.Obj, ownerDetails.Owner, r.ResourceResolver, r.ARMConnection.Client(), r.Log) if checkErr != nil { // Something went wrong running the check. return extensions.PreReconcileCheckResult{}, checkErr @@ -480,14 +480,14 @@ func (r *azureDeploymentReconcilerInstance) postReconciliationCheck(ctx context. } // We also need to have our owner, it too with an up-to-date status - owner, ownerErr := r.ResourceResolver.ResolveOwner(ctx, r.Obj) + ownerDetails, ownerErr := r.ResourceResolver.ResolveOwner(ctx, r.Obj) if ownerErr != nil { // We can't obtain the owner, so we can't run the extension return extensions.PostReconcileCheckResult{}, ownerErr } // Run our post-reconciliation checker - check, checkErr := checker(ctx, r.Obj, owner, r.ResourceResolver, r.ARMConnection.Client(), r.Log) + check, checkErr := checker(ctx, r.Obj, ownerDetails.Owner, r.ResourceResolver, r.ARMConnection.Client(), r.Log) if checkErr != nil { // Something went wrong running the check. return extensions.PostReconcileCheckResult{}, checkErr @@ -759,7 +759,7 @@ func ConvertToARMResourceImpl( armID, err := resourceHierarchy.FullyQualifiedARMID(subscriptionID) if err != nil { - return nil, err + return nil, reconcilers.ClassifyResolverError(err) } result := genruntime.NewARMResource(typedArmSpec, nil, armID) diff --git a/v2/internal/reconcilers/common.go b/v2/internal/reconcilers/common.go index d57c007788b..5f9a09cda11 100644 --- a/v2/internal/reconcilers/common.go +++ b/v2/internal/reconcilers/common.go @@ -66,7 +66,7 @@ type ARMOwnedResourceReconcilerCommon struct { // NeedsToWaitForOwner returns false if the owner doesn't need to be waited for, and true if it does. func (r *ARMOwnedResourceReconcilerCommon) NeedsToWaitForOwner(ctx context.Context, log logr.Logger, obj genruntime.ARMOwnedMetaObject) (bool, error) { - owner, err := r.ResourceResolver.ResolveOwner(ctx, obj) + ownerDetails, err := r.ResourceResolver.ResolveOwner(ctx, obj) if err != nil { var typedErr *core.ReferenceNotFound if errors.As(err, &typedErr) { @@ -78,12 +78,12 @@ func (r *ARMOwnedResourceReconcilerCommon) NeedsToWaitForOwner(ctx context.Conte } // No need to wait for resources that don't have an owner - if owner == nil { + if !ownerDetails.FoundKuberentesOwner() { return false, nil } // If the owner isn't ready, wait - ready := genruntime.GetReadyCondition(owner) + ready := genruntime.GetReadyCondition(ownerDetails.Owner) isOwnerReady := ready != nil && ready.Status == metav1.ConditionTrue if !isOwnerReady { var readyStr string @@ -100,22 +100,23 @@ func (r *ARMOwnedResourceReconcilerCommon) NeedsToWaitForOwner(ctx context.Conte } func (r *ARMOwnedResourceReconcilerCommon) ApplyOwnership(ctx context.Context, log logr.Logger, obj genruntime.ARMOwnedMetaObject) error { - owner, err := r.ResourceResolver.ResolveOwner(ctx, obj) + ownerDetails, err := r.ResourceResolver.ResolveOwner(ctx, obj) if err != nil { return errors.Wrap(err, "failed to get owner") } - if owner == nil { + if !ownerDetails.FoundKuberentesOwner() { + // If no owner is expected or the owner is only in ARM, no need to assign ownership in Kubernetes return nil } - ownerRef := ownerutil.MakeOwnerReference(owner) + ownerRef := ownerutil.MakeOwnerReference(ownerDetails.Owner) obj.SetOwnerReferences(ownerutil.EnsureOwnerRef(obj.GetOwnerReferences(), ownerRef)) log.V(Info).Info( "Set owner reference", - "ownerGvk", owner.GetObjectKind().GroupVersionKind(), - "ownerName", owner.GetName()) + "ownerGvk", ownerDetails.Owner.GetObjectKind().GroupVersionKind(), + "ownerName", ownerDetails.Owner.GetName()) return nil } @@ -165,6 +166,12 @@ func ClassifyResolverError(err error) error { return conditions.NewReadyConditionImpactingError(err, conditions.ConditionSeverityWarning, conditions.ReasonConfigMapNotFound) } + // If it's subscription mismatch, classify that + var subscriptionMismatchErr *core.SubscriptionMismatch + if errors.As(err, &subscriptionMismatchErr) { + return conditions.NewReadyConditionImpactingError(err, conditions.ConditionSeverityError, conditions.ReasonFailed) + } + // Everything else is ReferenceNotFound. This is maybe a bit of a lie but secrets are also references and we want to make sure // everything is classified as something, so for now it's good enough. return conditions.NewReadyConditionImpactingError(err, conditions.ConditionSeverityWarning, conditions.ReasonReferenceNotFound) diff --git a/v2/internal/reconcilers/mysql/connector.go b/v2/internal/reconcilers/mysql/connector.go index 7990da9c03b..581a4250c9d 100644 --- a/v2/internal/reconcilers/mysql/connector.go +++ b/v2/internal/reconcilers/mysql/connector.go @@ -25,14 +25,20 @@ type Connector interface { func getServerFQDN(ctx context.Context, resourceResolver *resolver.Resolver, user *asomysql.User) (string, error) { // Get the owner - at this point it must exist - owner, err := resourceResolver.ResolveOwner(ctx, user) + ownerDetails, err := resourceResolver.ResolveOwner(ctx, user) if err != nil { return "", err } - flexibleServer, ok := owner.(*dbformysql.FlexibleServer) + // Note that this is not actually possible for this type because we don't allow ARMID references for these owners, + // but protecting against it here anyway. + if !ownerDetails.FoundKuberentesOwner() { + return "", errors.Errorf("user owner must exist in Kubernetes for user %s", user.Name) + } + + flexibleServer, ok := ownerDetails.Owner.(*dbformysql.FlexibleServer) if !ok { - return "", errors.Errorf("owner was not type FlexibleServer, instead: %T", owner) + return "", errors.Errorf("owner was not type FlexibleServer, instead: %T", ownerDetails) } // Magical assertion to ensure that this is still the storage type diff --git a/v2/internal/reconcilers/postgresql/postgresql_user_reconciler.go b/v2/internal/reconcilers/postgresql/postgresql_user_reconciler.go index 1a5bd178e89..af73edafee4 100644 --- a/v2/internal/reconcilers/postgresql/postgresql_user_reconciler.go +++ b/v2/internal/reconcilers/postgresql/postgresql_user_reconciler.go @@ -8,7 +8,7 @@ package postgresql import ( "context" "database/sql" - dbforpostgressql "github.com/Azure/azure-service-operator/v2/api/dbforpostgresql/v1api20210601storage" + "github.com/go-logr/logr" "github.com/pkg/errors" "k8s.io/client-go/tools/record" @@ -16,6 +16,7 @@ import ( ctrlconversion "sigs.k8s.io/controller-runtime/pkg/conversion" asopostgresql "github.com/Azure/azure-service-operator/v2/api/dbforpostgresql/v1" + dbforpostgressql "github.com/Azure/azure-service-operator/v2/api/dbforpostgresql/v1api20210601storage" "github.com/Azure/azure-service-operator/v2/internal/config" . "github.com/Azure/azure-service-operator/v2/internal/logging" "github.com/Azure/azure-service-operator/v2/internal/reconcilers" @@ -223,14 +224,20 @@ func (r *PostgreSQLUserReconciler) UpdateStatus(ctx context.Context, log logr.Lo func (r *PostgreSQLUserReconciler) connectToDB(ctx context.Context, _ logr.Logger, user *asopostgresql.User, secrets genruntime.Resolved[genruntime.SecretReference]) (*sql.DB, error) { // Get the owner - at this point it must exist - owner, err := r.ResourceResolver.ResolveOwner(ctx, user) + ownerDetails, err := r.ResourceResolver.ResolveOwner(ctx, user) if err != nil { return nil, errors.Wrapf(err, "resolving owner for user %s", user.Name) } - flexibleServer, ok := owner.(*dbforpostgressql.FlexibleServer) + // Note that this is not actually possible for this type because we don't allow ARMID references for these owners, + // but protecting against it here anyway. + if !ownerDetails.FoundKuberentesOwner() { + return nil, errors.Errorf("user owner must exist in Kubernetes for user %s", user.Name) + } + + flexibleServer, ok := ownerDetails.Owner.(*dbforpostgressql.FlexibleServer) if !ok { - return nil, errors.Errorf("owner was not type FlexibleServer, instead: %T", owner) + return nil, errors.Errorf("owner was not type FlexibleServer, instead: %T", ownerDetails) } // Magical assertion to ensure that this is still the storage type var _ ctrlconversion.Hub = &dbforpostgressql.FlexibleServer{} diff --git a/v2/internal/reflecthelpers/reflect_helpers_test.go b/v2/internal/reflecthelpers/reflect_helpers_test.go index f26aeab5533..373c6258a47 100644 --- a/v2/internal/reflecthelpers/reflect_helpers_test.go +++ b/v2/internal/reflecthelpers/reflect_helpers_test.go @@ -243,7 +243,7 @@ func Test_FindPropertiesWithTag(t *testing.T) { g.Expect(err).ToNot(HaveOccurred()) // This is the number of properties and child properties on this object. It's fragile to structural changes // in the object so may need to be changed in the future - g.Expect(results).To(HaveLen(23)) + g.Expect(results).To(HaveLen(24)) } func Test_FindOptionalConfigMapReferences(t *testing.T) { diff --git a/v2/internal/resolver/resolver.go b/v2/internal/resolver/resolver.go index 2ea0f79ac7f..5584cefccc9 100644 --- a/v2/internal/resolver/resolver.go +++ b/v2/internal/resolver/resolver.go @@ -127,21 +127,27 @@ func (r *Resolver) ResolveResourceReferences(ctx context.Context, metaObject gen } // ResolveResourceHierarchy gets the resource hierarchy for a given resource. The result is a slice of -// resources, with the uppermost parent at position 0 and the resource itself at position len(slice)-1 +// resources, with the uppermost parent at position 0 and the resource itself at position len(slice)-1. +// Note that there is NO GUARANTEE that this hierarchy is "complete". It may root up to a resource which uses +// the ARMID field of owner. func (r *Resolver) ResolveResourceHierarchy(ctx context.Context, obj genruntime.ARMMetaObject) (ResourceHierarchy, error) { owner := obj.Owner() if owner == nil { return ResourceHierarchy{obj}, nil } - ownerMeta, err := r.ResolveOwner(ctx, obj) + ownerDetails, err := r.ResolveOwner(ctx, obj) if err != nil { return nil, err } - owners, err := r.ResolveResourceHierarchy(ctx, ownerMeta) + if ownerDetails.Result == OwnerFoundARM { + return ResourceHierarchy{obj}, nil + } + + owners, err := r.ResolveResourceHierarchy(ctx, ownerDetails.Owner) if err != nil { - return nil, errors.Wrapf(err, "getting owners for %s", ownerMeta.GetName()) + return nil, errors.Wrapf(err, "getting owners for %s", ownerDetails.Owner.GetName()) } return append(owners, obj), nil @@ -177,14 +183,64 @@ func (r *Resolver) ResolveReference(ctx context.Context, ref genruntime.Namespac return metaObj, nil } +type ResolveOwnerResult string + +const ( + // OwnerFoundKubernetes indicates the owner was found in Kubernetes. + OwnerFoundKubernetes = ResolveOwnerResult("OwnerFoundKubernetes") + // OwnerFoundARM indicates the owner is an ARM ID. The resource the ARM ID points to may or may not exist in Azure currently. + OwnerFoundARM = ResolveOwnerResult("OwnerFoundARM") + // OwnerNotExpected indicates that this resource is not expected to have any owner. (Example: ResourceGroup) + OwnerNotExpected = ResolveOwnerResult("OwnerNotExpected") +) + +type OwnerDetails struct { + Result ResolveOwnerResult + Owner genruntime.ARMMetaObject + ARMID string +} + +func (det OwnerDetails) FoundKuberentesOwner() bool { + if det.Result == OwnerNotExpected || det.Result == OwnerFoundARM { + // If no owner is expected or the owner is only in ARM, no need to assign ownership in Kubernetes + return false + } + + return true +} + +func OwnerDetailsFromKubernetes(owner genruntime.ARMMetaObject) OwnerDetails { + return OwnerDetails{ + Result: OwnerFoundKubernetes, + Owner: owner, + } +} + +func OwnerDetailsFromARM(armID string) OwnerDetails { + return OwnerDetails{ + Result: OwnerFoundARM, + ARMID: armID, + } +} + +func OwnerDetailsNotExpected() OwnerDetails { + return OwnerDetails{ + Result: OwnerNotExpected, + } +} + // ResolveOwner returns the MetaObject for the given resource's owner. If the resource is supposed to have // an owner but doesn't, this returns an ReferenceNotFound error. If the resource is not supposed -// to have an owner (for example, ResourceGroup), returns nil. -func (r *Resolver) ResolveOwner(ctx context.Context, obj genruntime.ARMOwnedMetaObject) (genruntime.ARMMetaObject, error) { +// to have an owner (for example, ResourceGroup) or the owner points to a raw ARM ID, returns nil. +func (r *Resolver) ResolveOwner(ctx context.Context, obj genruntime.ARMOwnedMetaObject) (OwnerDetails, error) { owner := obj.Owner() if owner == nil { - return nil, nil + return OwnerDetailsNotExpected(), nil + } + + if owner.IsDirectARMReference() { + return OwnerDetailsFromARM(owner.ARMID), nil } namespacedRef := genruntime.NamespacedResourceReference{ @@ -193,10 +249,10 @@ func (r *Resolver) ResolveOwner(ctx context.Context, obj genruntime.ARMOwnedMeta } ownerMeta, err := r.ResolveReference(ctx, namespacedRef) if err != nil { - return nil, err + return OwnerDetails{}, err } - return ownerMeta, nil + return OwnerDetailsFromKubernetes(ownerMeta), nil } // Scheme returns the current scheme from our client diff --git a/v2/internal/resolver/resolver_test.go b/v2/internal/resolver/resolver_test.go index 9788e52638d..f448ce34bcb 100644 --- a/v2/internal/resolver/resolver_test.go +++ b/v2/internal/resolver/resolver_test.go @@ -136,6 +136,25 @@ func createResourceGroupRootedResource(rgName string, name string) (genruntime.A return a, b } +func createResourceGroupARMIDRootedResource(armID string, name string) genruntime.ARMMetaObject { + return &batch.BatchAccount{ + TypeMeta: metav1.TypeMeta{ + Kind: "BatchAccount", + APIVersion: batch.GroupVersion.String(), + }, + ObjectMeta: metav1.ObjectMeta{ + Name: name, + Namespace: testNamespace, + }, + Spec: batch.BatchAccount_Spec{ + Owner: &genruntime.KnownResourceReference{ + ARMID: armID, + }, + AzureName: name, // defaulter webhook will copy Name to AzureName + }, + } +} + func createDeeplyNestedResource(rgName string, parentName string, name string) resolver.ResourceHierarchy { a := createResourceGroup(rgName) @@ -175,6 +194,24 @@ func createDeeplyNestedResource(rgName string, parentName string, name string) r return resolver.ResourceHierarchy{a, b, c} } +func createChildResourceOwnedByARMID(armID string, name string) genruntime.ARMMetaObject { + return &storage.StorageAccountsBlobService{ + TypeMeta: metav1.TypeMeta{ + Kind: "StorageAccountsBlobService", + APIVersion: storage.GroupVersion.String(), + }, + ObjectMeta: metav1.ObjectMeta{ + Name: name, + Namespace: testNamespace, + }, + Spec: storage.StorageAccounts_BlobService_Spec{ + Owner: &genruntime.KnownResourceReference{ + ARMID: armID, + }, + }, + } +} + func createSimpleExtensionResource(name string, ownerName string, ownerGVK schema.GroupVersionKind) genruntime.ARMMetaObject { return &testcommon.SimpleExtensionResource{ TypeMeta: metav1.TypeMeta{ @@ -186,7 +223,7 @@ func createSimpleExtensionResource(name string, ownerName string, ownerGVK schem Namespace: testNamespace, }, Spec: testcommon.SimpleExtensionResourceSpec{ - Owner: genruntime.ResourceReference{ + Owner: genruntime.ArbitraryOwnerReference{ Group: ownerGVK.Group, Kind: ownerGVK.Kind, Name: ownerName, @@ -196,6 +233,25 @@ func createSimpleExtensionResource(name string, ownerName string, ownerGVK schem } } +func createSimpleExtensionResourceOwnedByARMID(name string, armID string) genruntime.ARMMetaObject { + return &testcommon.SimpleExtensionResource{ + TypeMeta: metav1.TypeMeta{ + Kind: "SimpleExtensionResource", + APIVersion: testcommon.SimpleExtensionResourceGroupVersion.String(), + }, + ObjectMeta: metav1.ObjectMeta{ + Name: name, + Namespace: testNamespace, + }, + Spec: testcommon.SimpleExtensionResourceSpec{ + Owner: genruntime.ArbitraryOwnerReference{ + ARMID: armID, + }, + AzureName: name, // defaulter webhook will copy Name to AzureName + }, + } +} + func createExtensionResourceOnResourceGroup(rgName string, name string) (genruntime.ARMMetaObject, genruntime.ARMMetaObject) { a := createResourceGroup(rgName) gvk := a.GetObjectKind().GroupVersionKind() @@ -224,7 +280,6 @@ func createExtensionResourceOnDeepHierarchyInResourceGroup(rgName string, parent } func createExtensionResourceOnTenantScopeResource(subscriptionName string, name string) resolver.ResourceHierarchy { - sub := createSubscription(subscriptionName) gvk := sub.GetObjectKind().GroupVersionKind() ext := createSimpleExtensionResource(name, sub.GetName(), gvk) @@ -232,6 +287,14 @@ func createExtensionResourceOnTenantScopeResource(subscriptionName string, name return resolver.ResourceHierarchy{sub, ext} } +func createExtensionResourceOnDeepHierarchyOwnedByARMID(armID string, resourceName string, name string) resolver.ResourceHierarchy { + extensionParent := createChildResourceOwnedByARMID(armID, resourceName) + gvk := extensionParent.GetObjectKind().GroupVersionKind() + + extension := createSimpleExtensionResource(name, extensionParent.GetName(), gvk) + return resolver.ResourceHierarchy{extensionParent, extension} +} + func Test_ResolveResourceHierarchy_ResourceGroupOnly(t *testing.T) { t.Parallel() g := NewGomegaWithT(t) diff --git a/v2/internal/resolver/resource_hierarchy.go b/v2/internal/resolver/resource_hierarchy.go index deab4dbe35c..8476b386f6a 100644 --- a/v2/internal/resolver/resource_hierarchy.go +++ b/v2/internal/resolver/resource_hierarchy.go @@ -9,10 +9,12 @@ import ( "fmt" "strings" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" "github.com/pkg/errors" "github.com/Azure/azure-service-operator/v2/internal/genericarmclient" "github.com/Azure/azure-service-operator/v2/pkg/genruntime" + "github.com/Azure/azure-service-operator/v2/pkg/genruntime/core" ) type ResourceHierarchyRoot string @@ -21,6 +23,7 @@ const ( ResourceHierarchyRootResourceGroup = ResourceHierarchyRoot("ResourceGroup") ResourceHierarchyRootSubscription = ResourceHierarchyRoot("Subscription") ResourceHierarchyRootTenant = ResourceHierarchyRoot("Tenant") + ResourceHierarchyRootARMID = ResourceHierarchyRoot("ARMID") ResourceHierarchyRootOverride = ResourceHierarchyRoot("Override") ) @@ -34,6 +37,20 @@ type ResourceHierarchy []genruntime.ARMMetaObject // in a resource group. func (h ResourceHierarchy) ResourceGroup() (string, error) { rootKind := h.rootKind(h) + if rootKind == ResourceHierarchyRootARMID { + armIDStr := h[0].Owner().ARMID + armID, err := arm.ParseResourceID(armIDStr) + if err != nil { + return "", err + } + + if armID.ResourceGroupName == "" { + return "", errors.Errorf("not rooted by a resource group: %s", armIDStr) + } + + return armID.ResourceGroupName, nil + } + if rootKind != ResourceHierarchyRootResourceGroup { return "", errors.Errorf("not rooted by a resource group: %s", rootKind) } @@ -46,6 +63,8 @@ func (h ResourceHierarchy) ResourceGroup() (string, error) { // if the root is not a subscription. func (h ResourceHierarchy) Location() (string, error) { rootKind := h.rootKind(h) + // We don't support ARM ID rooted for this method because it doesn't really make sense. + // If there's a need for it in the future we can add it if rootKind != ResourceHierarchyRootSubscription { return "", errors.Errorf("not rooted in a subscription: %s", rootKind) } @@ -81,13 +100,19 @@ func (h ResourceHierarchy) fullyQualifiedARMIDImpl(subscriptionID string, origin lastResourceScope := lastResource.GetResourceScope() if lastResourceScope == genruntime.ResourceScopeExtension { - hierarchy := h[:len(h)-1] - parentARMID, err := hierarchy.fullyQualifiedARMIDImpl(subscriptionID, h) - if err != nil { - return "", err + var parentARMID string + if lastResource.Owner().IsDirectARMReference() { + parentARMID = lastResource.Owner().ARMID + } else { + hierarchy := h[:len(h)-1] + var err error + parentARMID, err = hierarchy.fullyQualifiedARMIDImpl(subscriptionID, h) + if err != nil { + return "", err + } } - provider, types, err := getResourceTypeAndProvider(lastResource) + provider, types, err := genruntime.GetResourceTypeAndProvider(lastResource) if err != nil { return "", err } @@ -112,7 +137,7 @@ func (h ResourceHierarchy) fullyQualifiedARMIDImpl(subscriptionID string, origin // The only resource we actually care about for figuring out resource types is the // most derived resource res := h[len(h)-1] - provider, resourceTypes, err := getResourceTypeAndProvider(res) + provider, resourceTypes, err := genruntime.GetResourceTypeAndProvider(res) if err != nil { return "", err } @@ -134,7 +159,7 @@ func (h ResourceHierarchy) fullyQualifiedARMIDImpl(subscriptionID string, origin // The only resource we actually care about for figuring out resource types is the // most derived resource res := h[len(h)-1] - provider, resourceTypes, err := getResourceTypeAndProvider(res) + provider, resourceTypes, err := genruntime.GetResourceTypeAndProvider(res) if err != nil { return "", err } @@ -151,14 +176,82 @@ func (h ResourceHierarchy) fullyQualifiedARMIDImpl(subscriptionID string, origin // Join them together interleaved := genruntime.InterleaveStrSlice(resourceTypes, azureNames) return genericarmclient.MakeTenantScopeARMID(provider, interleaved...) + case ResourceHierarchyRootARMID: + // TODO: Possibly refactor this huge method into sub-functions? + // The only resource we actually care about for figuring out resource types is the + // most derived resource + res := h[len(h)-1] + provider, resourceTypes, err := genruntime.GetResourceTypeAndProvider(res) + if err != nil { + return "", err + } + + // We also need the ARMID from the root resource + root := h[0] + armIDStr := root.Owner().ARMID // Safe to do this without nil-guards because we already checked elsewhere + + // Trim the trailing slash of the ARM ID if it's there (we'll add it back later) + armIDStr = strings.TrimRight(armIDStr, "/") + + err = genruntime.VerifyResourceOwnerARMID(root) + if err != nil { + return "", err + } + + armID, err := arm.ParseResourceID(armIDStr) + if err != nil { + return "", err + } + // armIDSub may be empty if there is no subscription in the user specified ARM ID (for example because the resource roots + // at the tenant level) + if armID.SubscriptionID != "" { + // Confirm that the subscription ID the user specified matches the subscription ID we're using from our credential + if !strings.EqualFold(armID.SubscriptionID, subscriptionID) { + return "", core.NewSubscriptionMismatchError( + errors.Errorf( + "resource subscription %q does not match parent ARM ID subscription %q from ARM ID %q", + subscriptionID, + armID.SubscriptionID, + armIDStr)) + } + } + + // Rooting to an ARM ID means that some of the resourceTypes may not actually be included explicitly in our + // hierarchy (because they're instead in the ARM ID itself). We filter these out of resourceTypes by + // removing types that aren't included in the hierarchy. + _, rootResourceTypes, err := genruntime.GetResourceTypeAndProvider(root) + if err != nil { + return "", err + } + resourceTypesIncludedInARMID := rootResourceTypes[:len(rootResourceTypes)-1] + resourceTypes = resourceTypes[len(resourceTypesIncludedInARMID):] + + // Ensure that we have the same number of names and types + if len(azureNames) != len(resourceTypes) { + return "", errors.Errorf("could not create fully qualified ARM ID, had %d azureNames and %d resourceTypes. azureNames: %+q resourceTypes: %+q", + len(azureNames), + len(resourceTypes), + azureNames, + resourceTypes) + } + + interleaved := genruntime.InterleaveStrSlice(resourceTypes, azureNames) + suffix := strings.Join(interleaved, "/") + // If the root ARM ID already contains the provider ID, we can just append the pairs. + // If it doesn't, we need to build a full ARM ID by appending the provider as well. + if strings.Contains(strings.ToLower(armIDStr), strings.ToLower(provider)) { + return fmt.Sprintf("%s/%s", armIDStr, suffix), nil + } else { + return fmt.Sprintf("%s/providers/%s/%s", armIDStr, provider, suffix), nil + } case ResourceHierarchyRootOverride: // Find the resource that has the override and start building the ID from there: idFragment, idx := h.getChildResourceIDOverride() if idx == -1 { - return "", errors.Errorf("Resource had root kind %q, but had no child resource ID override", rootKind) + return "", errors.Errorf("resource had root kind %q, but had no child resource ID override", rootKind) } if idx != 0 { - return "", errors.Errorf("Resource had root kind %q, but child resource override was not at index 0. Instead at index %d", rootKind, idx) + return "", errors.Errorf("resource had root kind %q, but child resource override was not at index 0. Instead at index %d", rootKind, idx) } return idFragment, nil // TODO: if we actually need to support this for hierarchies, we could do something like the below @@ -174,12 +267,13 @@ func (h ResourceHierarchy) fullyQualifiedARMIDImpl(subscriptionID string, origin } // rootKind returns the ResourceHierarchyRoot type of the hierarchy. -// There are 5 cases here: +// There are 6 cases here: // 1. The hierarchy is comprised solely of a resource group. This is subscription rooted. // 2. The hierarchy has multiple entries and roots up to a resource group. This is Resource Group rooted. // 3. The hierarchy has multiple entries and doesn't root up to a resource group. This is subscription rooted. // 4. The hierarchy roots up to a tenant scope resource. This is tenant rooted. -// 5. The hierarchy contains a resource that sets genruntime.ChildResourceIDOverrideAnnotation. This is +// 5. The hierarchy roots up to a resource whose Owner() is an ARMID. This is ARMID rooted. +// 6. The hierarchy contains a resource that sets genruntime.ChildResourceIDOverrideAnnotation. This is // "Override" rooted. func (h ResourceHierarchy) rootKind(originalHierarchy ResourceHierarchy) ResourceHierarchyRoot { if len(h) == 0 { @@ -193,7 +287,15 @@ func (h ResourceHierarchy) rootKind(originalHierarchy ResourceHierarchy) Resourc return ResourceHierarchyRootOverride } - scope := h[0].GetResourceScope() + root := h[0] + + // Check if the root resource is owned by an ARM ID + rootOwner := root.Owner() + if rootOwner != nil && rootOwner.IsDirectARMReference() { + return ResourceHierarchyRootARMID + } + + scope := root.GetResourceScope() if scope == genruntime.ResourceScopeTenant { return ResourceHierarchyRootTenant } @@ -218,18 +320,6 @@ func (h ResourceHierarchy) getAzureNames() []string { return azureNames } -func getResourceTypeAndProvider(res genruntime.ARMMetaObject) (string, []string, error) { - rawType := res.GetType() - - split := strings.Split(rawType, "/") - if len(split) <= 1 { - return "", nil, errors.Errorf("unexpected resource type format: %q", rawType) - } - - // The first item is always the provider - return split[0], split[1:], nil -} - // getChildResourceIDOverride returns the child resource ID override and the index at which the override was specified, or // -1 if there was no childResourceIDOverride func (h ResourceHierarchy) getChildResourceIDOverride() (string, int) { diff --git a/v2/internal/resolver/resource_hierarchy_test.go b/v2/internal/resolver/resource_hierarchy_test.go index 4a03a669052..633789ba86e 100644 --- a/v2/internal/resolver/resource_hierarchy_test.go +++ b/v2/internal/resolver/resource_hierarchy_test.go @@ -190,6 +190,159 @@ func Test_ResourceHierarchy_ExtensionOnDeepHierarchy(t *testing.T) { g.Expect(hierarchy.AzureName()).To(Equal(extensionName)) } +func Test_ResourceHierarchy_OwnerARMIDResourceGroup(t *testing.T) { + t.Parallel() + g := NewGomegaWithT(t) + + resourceGroupName := "myrg" + resourceName := "myresource" + + rootARMID := fmt.Sprintf("/subscriptions/1234/resourceGroups/%s", resourceGroupName) + resource := createResourceGroupARMIDRootedResource(rootARMID, resourceName) + hierarchy := resolver.ResourceHierarchy{resource} + + expectedARMID := fmt.Sprintf( + "/subscriptions/1234/resourceGroups/%s/providers/Microsoft.Batch/batchAccounts/%s", + resourceGroupName, + resourceName) + + g.Expect(hierarchy.ResourceGroup()).To(Equal(resourceGroupName)) + g.Expect(hierarchy.FullyQualifiedARMID("1234")).To(Equal(expectedARMID)) + g.Expect(hierarchy.AzureName()).To(Equal(resourceName)) +} + +func Test_ResourceHierarchy_OwnerARMIDParent(t *testing.T) { + t.Parallel() + g := NewGomegaWithT(t) + + resourceGroupName := "myrg" + parentName := "parent" + resourceName := "myresource" + + rootARMID := fmt.Sprintf("/subscriptions/1234/resourceGroups/%s/providers/Microsoft.Storage/storageAccounts/%s", resourceGroupName, parentName) + resource := createChildResourceOwnedByARMID(rootARMID, resourceName) + hierarchy := resolver.ResourceHierarchy{resource} + + expectedARMID := fmt.Sprintf( + "/subscriptions/1234/resourceGroups/%s/providers/Microsoft.Storage/storageAccounts/%s/blobServices/default", + resourceGroupName, + parentName) + + g.Expect(hierarchy.ResourceGroup()).To(Equal(resourceGroupName)) + g.Expect(hierarchy.FullyQualifiedARMID("1234")).To(Equal(expectedARMID)) + g.Expect(hierarchy.AzureName()).To(Equal("default")) +} + +func Test_ResourceHierarchy_OwnerARMIDWrongProvider_ReturnsError(t *testing.T) { + t.Parallel() + g := NewGomegaWithT(t) + + resourceGroupName := "myrg" + parentName := "parent" + resourceName := "myresource" + + rootARMID := fmt.Sprintf("/subscriptions/1234/resourceGroups/%s/providers/Microsoft.Qux/storageAccounts/%s", resourceGroupName, parentName) + resource := createChildResourceOwnedByARMID(rootARMID, resourceName) + hierarchy := resolver.ResourceHierarchy{resource} + + _, err := hierarchy.FullyQualifiedARMID("1234") + g.Expect(err).To(MatchError("expected owner ARM ID to be from provider \"Microsoft.Storage\", but was \"Microsoft.Qux\"")) +} + +func Test_ResourceHierarchy_OwnerARMIDWrongType_ReturnsError(t *testing.T) { + t.Parallel() + g := NewGomegaWithT(t) + + resourceGroupName := "myrg" + parentName := "parent" + resourceName := "myresource" + + rootARMID := fmt.Sprintf("/subscriptions/1234/resourceGroups/%s/providers/Microsoft.Storage/cats/%s", resourceGroupName, parentName) + resource := createChildResourceOwnedByARMID(rootARMID, resourceName) + hierarchy := resolver.ResourceHierarchy{resource} + + _, err := hierarchy.FullyQualifiedARMID("1234") + g.Expect(err).To(MatchError("expected owner ARM ID to be of type \"Microsoft.Storage/storageAccounts\", but was \"Microsoft.Storage/cats\"")) +} + +func Test_ResourceHierarchy_OwnerARMIDAnotherWrongType_ReturnsError(t *testing.T) { + t.Parallel() + g := NewGomegaWithT(t) + + resourceGroupName := "myrg" + parentName := "parent" + resourceName := "myresource" + + rootARMID := fmt.Sprintf("/subscriptions/1234/resourceGroups/%s/providers/Microsoft.Storage/cats/%s", resourceGroupName, parentName) + resource := createResourceGroupARMIDRootedResource(rootARMID, resourceName) + hierarchy := resolver.ResourceHierarchy{resource} + + _, err := hierarchy.FullyQualifiedARMID("1234") + g.Expect(err).To(MatchError("expected owner ARM ID to be for a resource group, but was \"Microsoft.Storage/cats\"")) +} + +func Test_ResourceHierarchy_OwnerARMIDWrongSubscription_ReturnsError(t *testing.T) { + t.Parallel() + g := NewGomegaWithT(t) + + resourceGroupName := "myrg" + resourceName := "myresource" + + rootARMID := fmt.Sprintf("/subscriptions/4567/resourceGroups/%s", resourceGroupName) + resource := createResourceGroupARMIDRootedResource(rootARMID, resourceName) + hierarchy := resolver.ResourceHierarchy{resource} + + _, err := hierarchy.FullyQualifiedARMID("1234") + g.Expect(err).To(MatchError("resource subscription \"1234\" does not match parent ARM ID subscription \"4567\" from ARM ID \"/subscriptions/4567/resourceGroups/myrg\"")) +} + +func Test_ResourceHierarchy_OwnerARMIDWithExtension(t *testing.T) { + t.Parallel() + g := NewGomegaWithT(t) + + resourceGroupName := "myrg" + resourceName := "myresource" + extensionName := "myextension" + + rootARMID := fmt.Sprintf("/subscriptions/1234/resourceGroups/%s/providers/Microsoft.Storage/storageAccounts/%s", resourceGroupName, resourceName) + resource := createSimpleExtensionResourceOwnedByARMID(extensionName, rootARMID) + hierarchy := resolver.ResourceHierarchy{resource} + + expectedARMID := fmt.Sprintf( + "/subscriptions/1234/resourceGroups/%s/providers/Microsoft.Storage/storageAccounts/%s/providers/Microsoft.SimpleExtension/simpleExtensions/%s", + resourceGroupName, + resourceName, + extensionName) + + g.Expect(hierarchy.ResourceGroup()).To(Equal(resourceGroupName)) + g.Expect(hierarchy.FullyQualifiedARMID("1234")).To(Equal(expectedARMID)) + g.Expect(hierarchy.AzureName()).To(Equal(extensionName)) +} + +func Test_ResourceHierarchy_OwnerARMIDWithExtensionOnDeepHierarchy(t *testing.T) { + t.Parallel() + g := NewGomegaWithT(t) + + resourceGroupName := "myrg" + resourceName := "myresource" + childResourceName := "mychildresource" + extensionName := "myextension" + + rootARMID := fmt.Sprintf("/subscriptions/1234/resourceGroups/%s/providers/Microsoft.Storage/storageAccounts/%s", resourceGroupName, resourceName) + hierarchy := createExtensionResourceOnDeepHierarchyOwnedByARMID(rootARMID, childResourceName, extensionName) + + expectedARMID := fmt.Sprintf( + "/subscriptions/1234/resourceGroups/%s/providers/Microsoft.Storage/storageAccounts/%s/blobServices/%s/providers/Microsoft.SimpleExtension/simpleExtensions/%s", + resourceGroupName, + resourceName, + hierarchy[0].AzureName(), + extensionName) + + g.Expect(hierarchy.ResourceGroup()).To(Equal(resourceGroupName)) + g.Expect(hierarchy.FullyQualifiedARMID("1234")).To(Equal(expectedARMID)) + g.Expect(hierarchy.AzureName()).To(Equal(extensionName)) +} + func Test_ResourceHierarchy_ChildResourceIDOverride_DoesNotImpactResourceItself(t *testing.T) { t.Parallel() g := NewGomegaWithT(t) diff --git a/v2/internal/testcommon/creds.go b/v2/internal/testcommon/creds.go index 958df658f53..988e0a1208a 100644 --- a/v2/internal/testcommon/creds.go +++ b/v2/internal/testcommon/creds.go @@ -11,6 +11,8 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/pkg/errors" + v1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "github.com/Azure/azure-service-operator/v2/pkg/common/config" ) @@ -63,3 +65,44 @@ func getCreds() (azcore.TokenCredential, AzureIDs, error) { cachedIds = ids return creds, ids, nil } + +func newScopedCredentialSecret(subscriptionID, tenantID, name, namespace string) *v1.Secret { + secretData := make(map[string][]byte) + + secretData[config.AzureTenantID] = []byte(tenantID) + secretData[config.AzureSubscriptionID] = []byte(subscriptionID) + + return &v1.Secret{ + ObjectMeta: metav1.ObjectMeta{ + Name: name, + Namespace: namespace, + }, + Data: secretData, + } +} + +func NewScopedServicePrincipalSecret(subscriptionID, tenantID, clientID, clientSecret, name, namespace string) *v1.Secret { + secret := newScopedCredentialSecret(subscriptionID, tenantID, name, namespace) + + secret.Data[config.AzureClientID] = []byte(clientID) + secret.Data[config.AzureClientSecret] = []byte(clientSecret) + + return secret +} + +func NewScopedManagedIdentitySecret(subscriptionID, tenantID, clientID, name, namespace string) *v1.Secret { + secret := newScopedCredentialSecret(subscriptionID, tenantID, name, namespace) + + secret.Data[config.AzureClientID] = []byte(clientID) + + return secret +} + +func NewScopedServicePrincipalCertificateSecret(subscriptionID, tenantID, clientID, clientCert, name, namespace string) *v1.Secret { + secret := newScopedCredentialSecret(subscriptionID, tenantID, name, namespace) + + secret.Data[config.AzureClientID] = []byte(clientID) + secret.Data[config.AzureClientCertificate] = []byte(clientCert) + + return secret +} diff --git a/v2/internal/testcommon/kube_matcher.go b/v2/internal/testcommon/kube_matcher.go index cbf9af85414..9a57ce59b18 100644 --- a/v2/internal/testcommon/kube_matcher.go +++ b/v2/internal/testcommon/kube_matcher.go @@ -54,11 +54,12 @@ func (m *KubeMatcher) BeDeleted() types.GomegaMatcher { } } -func (m *KubeMatcher) BeInState(status metav1.ConditionStatus, severity conditions.ConditionSeverity) types.GomegaMatcher { +func (m *KubeMatcher) BeInState(status metav1.ConditionStatus, severity conditions.ConditionSeverity, originalGeneration int64) types.GomegaMatcher { return &DesiredStateMatcher{ - verify: m.verify, - ctx: m.ctx, - readyGoalStatus: status, - readyGoalSeverity: severity, + verify: m.verify, + ctx: m.ctx, + readyGoalStatus: status, + readyGoalSeverity: severity, + originalGeneration: originalGeneration, } } diff --git a/v2/internal/testcommon/kube_per_test_context.go b/v2/internal/testcommon/kube_per_test_context.go index 48f8332b806..604e73d3956 100644 --- a/v2/internal/testcommon/kube_per_test_context.go +++ b/v2/internal/testcommon/kube_per_test_context.go @@ -427,7 +427,7 @@ func (tc *KubePerTestContext) CreateResourceAndWaitForState( tc.T.Helper() tc.CreateResource(obj) - tc.Eventually(obj).Should(tc.Match.BeInState(status, severity)) + tc.Eventually(obj).Should(tc.Match.BeInState(status, severity, 0)) } // CheckIfResourceExists tries to get the current state of the resource from K8s (not from Azure), @@ -453,6 +453,20 @@ func (tc *KubePerTestContext) PatchResourceAndWait(old client.Object, new client tc.Eventually(new).Should(tc.Match.BeProvisioned(gen)) } +// PatchResourceAndWaitForState patches the resource in K8s and waits for the Ready condition to change into the specified +// state +func (tc *KubePerTestContext) PatchResourceAndWaitForState( + old client.Object, + new client.Object, + status metav1.ConditionStatus, + severity conditions.ConditionSeverity) { + gen := old.GetGeneration() + + tc.T.Helper() + tc.Patch(old, new) + tc.Eventually(new).Should(tc.Match.BeInState(status, severity, gen)) +} + // GetResource retrieves the current state of the resource from K8s (not from Azure). func (tc *KubePerTestContext) GetResource(key types.NamespacedName, obj client.Object) { tc.T.Helper() diff --git a/v2/internal/testcommon/kube_test_context.go b/v2/internal/testcommon/kube_test_context.go index 4c6345d1f12..c559840b8f8 100644 --- a/v2/internal/testcommon/kube_test_context.go +++ b/v2/internal/testcommon/kube_test_context.go @@ -70,3 +70,15 @@ func AsOwner(obj client.Object) *genruntime.KnownResourceReference { Name: obj.GetName(), } } + +func AsKubernetesOwner(obj client.Object) *genruntime.KubernetesOwnerReference { + return &genruntime.KubernetesOwnerReference{ + Name: obj.GetName(), + } +} + +func AsARMIDOwner(id string) *genruntime.KnownResourceReference { + return &genruntime.KnownResourceReference{ + ARMID: id, + } +} diff --git a/v2/internal/testcommon/sample_resource.go b/v2/internal/testcommon/sample_resource.go index c8ef94feda4..86fe038a529 100644 --- a/v2/internal/testcommon/sample_resource.go +++ b/v2/internal/testcommon/sample_resource.go @@ -75,7 +75,7 @@ func (r *SimpleExtensionResource) AzureName() string { // Owner returns the ResourceReference of the owner, or nil if there is no owner func (r *SimpleExtensionResource) Owner() *genruntime.ResourceReference { - return nil + return r.Spec.Owner.AsResourceReference() } func (r *SimpleExtensionResource) GetType() string { @@ -90,7 +90,7 @@ func (r *SimpleExtensionResource) GetResourceScope() genruntime.ResourceScope { type SimpleExtensionResourceSpec struct { AzureName string `json:"azureName,omitempty"` - Owner genruntime.ResourceReference `json:"owner"` + Owner genruntime.ArbitraryOwnerReference `json:"owner"` } var _ genruntime.ConvertibleSpec = &SimpleExtensionResourceSpec{} diff --git a/v2/pkg/genruntime/core/errors.go b/v2/pkg/genruntime/core/errors.go index 98fb4f1caff..abf19f26859 100644 --- a/v2/pkg/genruntime/core/errors.go +++ b/v2/pkg/genruntime/core/errors.go @@ -187,6 +187,40 @@ func (e *ConfigMapNotFound) Format(s fmt.State, verb rune) { format(e, s, verb) } +// SubscriptionMismatch error is used when a child resource and parent resource subscription don't match +type SubscriptionMismatch struct { + cause error +} + +func NewSubscriptionMismatchError(cause error) *SubscriptionMismatch { + return &SubscriptionMismatch{ + cause: cause, + } +} + +var _ error = &SubscriptionMismatch{} +var _ causer = &SubscriptionMismatch{} + +func (e *SubscriptionMismatch) Error() string { + return e.cause.Error() +} + +func (e *SubscriptionMismatch) Is(err error) bool { + var typedErr *SubscriptionMismatch + if errors.As(err, &typedErr) { + return true + } + return false +} + +func (e *SubscriptionMismatch) Cause() error { + return e.cause +} + +func (e *SubscriptionMismatch) Format(s fmt.State, verb rune) { + format(e, s, verb) +} + // This was adapted from the function in errors func format(e causer, s fmt.State, verb rune) { switch verb { diff --git a/v2/pkg/genruntime/kubernetes_resource.go b/v2/pkg/genruntime/kubernetes_resource.go index cb47e522a40..5b8134932e2 100644 --- a/v2/pkg/genruntime/kubernetes_resource.go +++ b/v2/pkg/genruntime/kubernetes_resource.go @@ -6,6 +6,8 @@ package genruntime import ( + "strings" + "github.com/pkg/errors" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime/schema" @@ -91,3 +93,17 @@ func GetAPIVersion(metaObject ARMMetaObject, scheme *runtime.Scheme) (string, er return rsrc.GetAPIVersion(), nil } + +// GetResourceTypeAndProvider returns the provider and the array of resource types which represent the resource. +// For example: Microsoft.Compute/virtualMachineScaleSets would return ("Microsoft.Compute", []string{"virtualMachineScaleSets"}, nil) +func GetResourceTypeAndProvider(res ARMMetaObject) (string, []string, error) { + rawType := res.GetType() + + split := strings.Split(rawType, "/") + if len(split) <= 1 { + return "", nil, errors.Errorf("unexpected resource type format: %q", rawType) + } + + // The first item is always the provider + return split[0], split[1:], nil +} diff --git a/v2/pkg/genruntime/resource_reference.go b/v2/pkg/genruntime/resource_reference.go index 94d96374c96..c9f68777fe7 100644 --- a/v2/pkg/genruntime/resource_reference.go +++ b/v2/pkg/genruntime/resource_reference.go @@ -9,7 +9,9 @@ package genruntime import ( "fmt" "reflect" + "strings" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" "github.com/pkg/errors" "k8s.io/apimachinery/pkg/runtime/schema" kerrors "k8s.io/apimachinery/pkg/util/errors" @@ -21,33 +23,80 @@ import ( // KnownResourceReference is a resource reference to a known type. // +kubebuilder:object:generate=true type KnownResourceReference struct { + // TODO: In practice this type is used only for Owner fields and so might more appropriately have been called OwnerReference + // TODO: but changing to that would be a breaking change so avoiding it. + // This is the name of the Kubernetes resource to reference. - // +kubebuilder:validation:Required Name string `json:"name,omitempty"` // References across namespaces are not supported. - // Note that ownership across namespaces in Kubernetes is not allowed, but technically resource // references are. There are RBAC considerations here though so probably easier to just start by // disallowing cross-namespace references for now + + // +kubebuilder:validation:Pattern="(?i)(^(/subscriptions/([^/]+)(/resourcegroups/([^/]+))?)?/providers/([^/]+)/([^/]+/[^/]+)(/([^/]+/[^/]+))*$|^/subscriptions/([^/]+)(/resourcegroups/([^/]+))?$)" + ARMID string `json:"armId,omitempty"` +} + +// AsResourceReference transforms this KnownResourceReference into a ResourceReference +func (ref KnownResourceReference) AsResourceReference(group string, kind string) *ResourceReference { + if ref.Name == "" { + group = "" + kind = "" + } + + return &ResourceReference{ + Group: group, + Kind: kind, + Name: ref.Name, + ARMID: ref.ARMID, + } +} + +// KubernetesOwnerReference is a resource reference to a known type in Kuberentes. Most types support +// ARM references as well but some (such as SQL users) do not. +// +kubebuilder:object:generate=true +type KubernetesOwnerReference struct { + // +kubebuilder:validation:Required + // This is the name of the Kubernetes resource to reference. + Name string `json:"name,omitempty"` } +// AsResourceReference transforms this KnownResourceReference into a ResourceReference +func (ref KubernetesOwnerReference) AsResourceReference(group string, kind string) *ResourceReference { + return &ResourceReference{ + Group: group, + Kind: kind, + Name: ref.Name, + } +} + +// TODO: This type and ResourceReference are almost exactly the same now... // ArbitraryOwnerReference is an owner reference to an unknown type. // +kubebuilder:object:generate=true type ArbitraryOwnerReference struct { // This is the name of the Kubernetes resource to reference. - // +kubebuilder:validation:Required Name string `json:"name,omitempty"` - // +kubebuilder:validation:Required // Group is the Kubernetes group of the resource. Group string `json:"group,omitempty"` - // +kubebuilder:validation:Required // Kind is the Kubernetes kind of the resource. Kind string `json:"kind,omitempty"` // Ownership across namespaces is not supported. + // +kubebuilder:validation:Pattern="(?i)(^(/subscriptions/([^/]+)(/resourcegroups/([^/]+))?)?/providers/([^/]+)/([^/]+/[^/]+)(/([^/]+/[^/]+))*$|^/subscriptions/([^/]+)(/resourcegroups/([^/]+))?$)" + ARMID string `json:"armId,omitempty"` +} + +// AsResourceReference transforms this ArbitraryOwnerReference into a ResourceReference +func (ref ArbitraryOwnerReference) AsResourceReference() *ResourceReference { + return &ResourceReference{ + Group: ref.Group, + Kind: ref.Kind, + Name: ref.Name, + ARMID: ref.ARMID, + } } var _ fmt.Stringer = ResourceReference{} @@ -179,6 +228,11 @@ func (ref ResourceReference) Copy() ResourceReference { return ref } +// Copy makes an independent copy of the KubernetesOwnerReference +func (ref KubernetesOwnerReference) Copy() KubernetesOwnerReference { + return ref +} + // ValidateResourceReferences calls Validate on each ResourceReference func ValidateResourceReferences(refs set.Set[ResourceReference]) (admission.Warnings, error) { errs := make([]error, 0, len(refs)) @@ -196,6 +250,76 @@ func ValidateResourceReferences(refs set.Set[ResourceReference]) (admission.Warn return nil, kerrors.NewAggregate(errs) } +func VerifyResourceOwnerARMID(resource ARMMetaObject) error { + owner := resource.Owner() + if owner == nil { + return nil + } + if !owner.IsDirectARMReference() { + return nil + } + + armID, err := arm.ParseResourceID(owner.ARMID) + if err != nil { + return err + } + + provider, rootResourceTypes, err := GetResourceTypeAndProvider(resource) + if err != nil { + return err + } + expectedResourceTypesIncludedInARMID := rootResourceTypes[:len(rootResourceTypes)-1] + + // Ensure that the ARM ID actually has a suffix containing the resource types we expect + if len(expectedResourceTypesIncludedInARMID) > 0 { + if strings.ToLower(armID.ResourceType.Namespace) != strings.ToLower(provider) { + return errors.Errorf( + "expected owner ARM ID to be from provider %q, but was %q", + provider, + armID.ResourceType.Namespace) + } + expectedARMIDType := strings.Join(expectedResourceTypesIncludedInARMID, "/") + if !strings.EqualFold(armID.ResourceType.Type, expectedARMIDType) { + return errors.Errorf( + "expected owner ARM ID to be of type %q, but was %q", + fmt.Sprintf("%s/%s", provider, expectedARMIDType), + armID.ResourceType.String()) + } + } else if len(expectedResourceTypesIncludedInARMID) == 0 { + scope := resource.GetResourceScope() + if scope == ResourceScopeResourceGroup && armID.ResourceType.String() != "Microsoft.Resources/resourceGroups" { + return errors.Errorf( + "expected owner ARM ID to be for a resource group, but was %q", + armID.ResourceType.String()) + } + } + + return nil +} + +// ValidateOwner calls Validate on the resource Owner +func ValidateOwner(obj ARMMetaObject) (admission.Warnings, error) { + owner := obj.Owner() + if owner == nil { + return nil, nil + } + + var warningsResult admission.Warnings + + warnings, err := owner.Validate() + warningsResult = append(warningsResult, warnings...) + if err != nil { + return warningsResult, err + } + + err = VerifyResourceOwnerARMID(obj) + if err != nil { + return warningsResult, err + } + + return warningsResult, nil +} + // NamespacedResourceReference is a resource reference with namespace information included type NamespacedResourceReference struct { ResourceReference diff --git a/v2/pkg/genruntime/zz_generated.deepcopy.go b/v2/pkg/genruntime/zz_generated.deepcopy.go index 069c5704109..c4995111cc2 100644 --- a/v2/pkg/genruntime/zz_generated.deepcopy.go +++ b/v2/pkg/genruntime/zz_generated.deepcopy.go @@ -54,6 +54,21 @@ func (in *KnownResourceReference) DeepCopy() *KnownResourceReference { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *KubernetesOwnerReference) DeepCopyInto(out *KubernetesOwnerReference) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KubernetesOwnerReference. +func (in *KubernetesOwnerReference) DeepCopy() *KubernetesOwnerReference { + if in == nil { + return nil + } + out := new(KubernetesOwnerReference) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ResourceReference) DeepCopyInto(out *ResourceReference) { *out = *in diff --git a/v2/test/mysql_aad_test.go b/v2/test/mysql_aad_test.go index ac67295b4c1..4126b0f4a88 100644 --- a/v2/test/mysql_aad_test.go +++ b/v2/test/mysql_aad_test.go @@ -164,7 +164,7 @@ func MySQL_AADUser_CRUD( user := &mysqlv1.User{ ObjectMeta: tc.MakeObjectMetaWithName(mi.Name), Spec: mysqlv1.UserSpec{ - Owner: testcommon.AsOwner(server), + Owner: testcommon.AsKubernetesOwner(server), Privileges: []string{ "CREATE USER", "PROCESS", @@ -210,7 +210,7 @@ func MySQL_AADUser_CRUD( tc.Expect(serverPrivs).To(Equal(set.Make[string](user.Spec.Privileges...))) // Update the user once again, this time to remove privs and also use a resource scoped identity - secret := newManagedIdentityCredential(tc.AzureSubscription, tc.AzureTenant, to.Value(admin.Spec.Sid), "credential", tc.Namespace) + secret := testcommon.NewScopedManagedIdentitySecret(tc.AzureSubscription, tc.AzureTenant, to.Value(admin.Spec.Sid), "credential", tc.Namespace) tc.CreateResource(secret) old = user.DeepCopy() @@ -271,7 +271,7 @@ func MySQL_LocalUser_AADAdmin_CRUD( user := &mysqlv1.User{ ObjectMeta: tc.MakeObjectMetaWithName(tc.NoSpaceNamer.GenerateName("local")), Spec: mysqlv1.UserSpec{ - Owner: testcommon.AsOwner(server), + Owner: testcommon.AsKubernetesOwner(server), Privileges: []string{ "CREATE USER", "PROCESS", @@ -344,7 +344,7 @@ func MySQL_AADUserAndGroup_CRUD( user := &mysqlv1.User{ ObjectMeta: tc.MakeObjectMetaWithName("aaduser"), Spec: mysqlv1.UserSpec{ - Owner: testcommon.AsOwner(server), + Owner: testcommon.AsKubernetesOwner(server), AzureName: aadUserName, Privileges: []string{ "CREATE USER", @@ -379,7 +379,7 @@ func MySQL_AADUserAndGroup_CRUD( user2 := &mysqlv1.User{ ObjectMeta: tc.MakeObjectMetaWithName("groupuser"), Spec: mysqlv1.UserSpec{ - Owner: testcommon.AsOwner(server), + Owner: testcommon.AsKubernetesOwner(server), AzureName: aadGroupName, Privileges: []string{ "CREATE USER", diff --git a/v2/test/mysql_test.go b/v2/test/mysql_test.go index 5341038a0ba..68daf433409 100644 --- a/v2/test/mysql_test.go +++ b/v2/test/mysql_test.go @@ -184,7 +184,7 @@ func MySQL_User_CRUD(tc *testcommon.KubePerTestContext, server *mysql.FlexibleSe user := &mysqlv1.User{ ObjectMeta: tc.MakeObjectMetaWithName(username), Spec: mysqlv1.UserSpec{ - Owner: testcommon.AsOwner(server), + Owner: testcommon.AsKubernetesOwner(server), Privileges: []string{ "CREATE USER", "PROCESS", @@ -422,7 +422,7 @@ func Test_MySQL_User(t *testing.T) { user := &mysqlv1.User{ ObjectMeta: tc.MakeObjectMetaWithName(tc.NoSpaceNamer.GenerateName("user")), Spec: mysqlv1.UserSpec{ - Owner: testcommon.AsOwner(flexibleServer), + Owner: testcommon.AsKubernetesOwner(flexibleServer), Privileges: []string{ "CREATE USER", "PROCESS", diff --git a/v2/test/owner_arm_id_test.go b/v2/test/owner_arm_id_test.go new file mode 100644 index 00000000000..d7b6b9a9e26 --- /dev/null +++ b/v2/test/owner_arm_id_test.go @@ -0,0 +1,92 @@ +/* +Copyright (c) Microsoft Corporation. +Licensed under the MIT license. +*/ + +package test + +import ( + "fmt" + "testing" + + . "github.com/onsi/gomega" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + + storage "github.com/Azure/azure-service-operator/v2/api/storage/v1api20220901" + "github.com/Azure/azure-service-operator/v2/internal/testcommon" + "github.com/Azure/azure-service-operator/v2/internal/util/to" + "github.com/Azure/azure-service-operator/v2/pkg/genruntime/conditions" +) + +// This test cannot be run in record/replay mode because the state it looks for at the beginning (Ready = false with warning) +// is not "stable" (the reconciler keeps retrying). Since it keeps retrying there isn't a deterministic number of +// retry attempts it makes which means a recording test may run out of recorded retries. +func Test_OwnerIsARMIDThatDoesntExist_ResourceFailsWithWarning(t *testing.T) { + t.Parallel() + tc := globalTestContext.ForTest(t) + + dummyResourceGroupID := fmt.Sprintf("/subscriptions/%s/resourceGroups/%s", tc.AzureSubscription, "nonexistrg") + + // Now create a storage account + acct := &storage.StorageAccount{ + ObjectMeta: tc.MakeObjectMetaWithName(tc.NoSpaceNamer.GenerateName("stor")), + Spec: storage.StorageAccount_Spec{ + Location: tc.AzureRegion, + Owner: testcommon.AsARMIDOwner(dummyResourceGroupID), + Kind: to.Ptr(storage.StorageAccount_Kind_Spec_StorageV2), + Sku: &storage.Sku{ + Name: to.Ptr(storage.SkuName_Standard_LRS), + }, + AccessTier: to.Ptr(storage.StorageAccountPropertiesCreateParameters_AccessTier_Hot), + }, + } + + // This isn't a fatal state because fatal errors won't reconcile periodically and if the resource is created in Azure + // we want to proceed + tc.CreateResourceAndWaitForState(acct, metav1.ConditionFalse, conditions.ConditionSeverityWarning) + tc.Expect(acct.Status.Conditions[0].Message).To(ContainSubstring("Resource group 'nonexistrg' could not be found.")) + + // Ensure that delete of the acct goes through properly + tc.DeleteResourceAndWait(acct) +} + +func Test_OwnerIsARMID_OwnerDeleted_ResourceFailsWithWarning(t *testing.T) { + t.Parallel() + tc := globalTestContext.ForTest(t) + + // Create a resource group + rg := tc.CreateTestResourceGroupAndWait() + + // Get the rg's ARM ID + tc.Expect(rg.Status.Id).ToNot(BeNil()) + armID := *rg.Status.Id + + // Now create a storage account + acct := &storage.StorageAccount{ + ObjectMeta: tc.MakeObjectMetaWithName(tc.NoSpaceNamer.GenerateName("stor")), + Spec: storage.StorageAccount_Spec{ + Location: tc.AzureRegion, + Owner: testcommon.AsARMIDOwner(armID), + Kind: to.Ptr(storage.StorageAccount_Kind_Spec_StorageV2), + Sku: &storage.Sku{ + Name: to.Ptr(storage.SkuName_Standard_LRS), + }, + AccessTier: to.Ptr(storage.StorageAccountPropertiesCreateParameters_AccessTier_Hot), + }, + } + + // Create the storage account from ARM ID + tc.CreateResourceAndWait(acct) + + // Delete the resource group + tc.DeleteResourceAndWait(rg) + + // Now try to update the storage acct + old := acct.DeepCopy() + acct.Spec.Tags = map[string]string{"tag1": "value1"} + tc.PatchResourceAndWaitForState(old, acct, metav1.ConditionFalse, conditions.ConditionSeverityWarning) + tc.Expect(acct.Status.Conditions[0].Message).To(ContainSubstring(fmt.Sprintf("Resource group '%s' could not be found.", rg.Name))) + + // Ensure that delete of the acct goes through properly + tc.DeleteResourceAndWait(acct) +} diff --git a/v2/test/postgresql_test.go b/v2/test/postgresql_test.go index cc4954ac05c..a2d8c08a653 100644 --- a/v2/test/postgresql_test.go +++ b/v2/test/postgresql_test.go @@ -200,7 +200,7 @@ func PostgreSQL_User_CRUD(tc *testcommon.KubePerTestContext, server *postgresql. user := &postgresqlv1.User{ ObjectMeta: tc.MakeObjectMetaWithName(username), Spec: postgresqlv1.UserSpec{ - Owner: testcommon.AsOwner(server), + Owner: testcommon.AsKubernetesOwner(server), Roles: []string{ "azure_pg_admin", }, @@ -318,7 +318,7 @@ func Test_PostgreSQL_User(t *testing.T) { user := &postgresqlv1.User{ ObjectMeta: tc.MakeObjectMetaWithName(tc.NoSpaceNamer.GenerateName("user")), Spec: postgresqlv1.UserSpec{ - Owner: testcommon.AsOwner(flexibleServer), + Owner: testcommon.AsKubernetesOwner(flexibleServer), Roles: []string{ "azure_pg_admin", }, diff --git a/v2/test/single_operator_multitenant_test.go b/v2/test/single_operator_multitenant_test.go index 6e4ef2d2b1c..3e66e89788c 100644 --- a/v2/test/single_operator_multitenant_test.go +++ b/v2/test/single_operator_multitenant_test.go @@ -21,7 +21,6 @@ import ( "github.com/Azure/azure-service-operator/v2/internal/identity" "github.com/Azure/azure-service-operator/v2/internal/testcommon" "github.com/Azure/azure-service-operator/v2/pkg/common/annotations" - "github.com/Azure/azure-service-operator/v2/pkg/common/config" "github.com/Azure/azure-service-operator/v2/pkg/genruntime" "github.com/Azure/azure-service-operator/v2/pkg/genruntime/conditions" ) @@ -135,8 +134,6 @@ func Test_Multitenant_SingleOperator_PerResourceCredential(t *testing.T) { } func newClientSecretCredential(subscriptionID, tenantID, name, namespace string) (*v1.Secret, error) { - secret := newCredentialSecret(subscriptionID, tenantID, name, namespace) - clientSecret := os.Getenv(AzureClientSecretMultitenantVar) if clientSecret == "" { return nil, errors.Errorf("required environment variable %q was not supplied", AzureClientSecretMultitenantVar) @@ -147,15 +144,10 @@ func newClientSecretCredential(subscriptionID, tenantID, name, namespace string) return nil, errors.Errorf("required environment variable %q was not supplied", AzureClientIDMultitenantVar) } - secret.Data[config.AzureClientID] = []byte(clientID) - secret.Data[config.AzureClientSecret] = []byte(clientSecret) - - return secret, nil + return testcommon.NewScopedServicePrincipalSecret(subscriptionID, tenantID, clientID, clientSecret, name, namespace), nil } func newClientCertificateCredential(subscriptionID, tenantID, name, namespace string) (*v1.Secret, error) { - secret := newCredentialSecret(subscriptionID, tenantID, name, namespace) - clientCert := os.Getenv(AzureClientCertificateMultitenantVar) if clientCert == "" { return nil, errors.Errorf("required environment variable %q was not supplied", AzureClientCertificateMultitenantVar) @@ -166,33 +158,7 @@ func newClientCertificateCredential(subscriptionID, tenantID, name, namespace st return nil, errors.Errorf("required environment variable %q was not supplied", AzureClientIDMultitenantCertAuthVar) } - secret.Data[config.AzureClientID] = []byte(clientID) - secret.Data[config.AzureClientCertificate] = []byte(clientCert) - - return secret, nil -} - -func newManagedIdentityCredential(subscriptionID, tenantID, clientID, name, namespace string) *v1.Secret { - secret := newCredentialSecret(subscriptionID, tenantID, name, namespace) - - secret.Data[config.AzureClientID] = []byte(clientID) - - return secret -} - -func newCredentialSecret(subscriptionID, tenantID, name, namespace string) *v1.Secret { - secretData := make(map[string][]byte) - - secretData[config.AzureTenantID] = []byte(tenantID) - secretData[config.AzureSubscriptionID] = []byte(subscriptionID) - - return &v1.Secret{ - ObjectMeta: metav1.ObjectMeta{ - Name: name, - Namespace: namespace, - }, - Data: secretData, - } + return testcommon.NewScopedServicePrincipalCertificateSecret(subscriptionID, tenantID, clientID, clientCert, name, namespace), nil } func newStorageAccount(tc *testcommon.KubePerTestContext, rg *resources.ResourceGroup) *storage.StorageAccount { diff --git a/v2/tools/generator/internal/armconversion/convert_from_arm_function_builder.go b/v2/tools/generator/internal/armconversion/convert_from_arm_function_builder.go index a2770a65162..781a079c168 100644 --- a/v2/tools/generator/internal/armconversion/convert_from_arm_function_builder.go +++ b/v2/tools/generator/internal/armconversion/convert_from_arm_function_builder.go @@ -278,6 +278,7 @@ func (builder *convertFromARMBuilder) ownerPropertyHandler( if ownerNameType == astmodel.KnownResourceReferenceType { compositeLit := astbuilder.NewCompositeLiteralBuilder(astmodel.KnownResourceReferenceType.AsType(builder.codeGenerationContext)) compositeLit.AddField("Name", astbuilder.Selector(dst.NewIdent(ownerParameter), "Name")) + compositeLit.AddField("ARMID", astbuilder.Selector(dst.NewIdent(ownerParameter), "ARMID")) convertedOwner = astbuilder.AddrOf(compositeLit.Build()) } else if ownerNameType == astmodel.ArbitraryOwnerReference { convertedOwner = astbuilder.AddrOf(dst.NewIdent(ownerParameter)) diff --git a/v2/tools/generator/internal/codegen/pipeline/apply_defaulter_and_validator_interfaces.go b/v2/tools/generator/internal/codegen/pipeline/apply_defaulter_and_validator_interfaces.go index 11fa0aacb34..9c174660f96 100644 --- a/v2/tools/generator/internal/codegen/pipeline/apply_defaulter_and_validator_interfaces.go +++ b/v2/tools/generator/internal/codegen/pipeline/apply_defaulter_and_validator_interfaces.go @@ -116,6 +116,15 @@ func getValidations( }, } + if resource.Owner() != nil { + validations[functions.ValidationKindCreate] = append( + validations[functions.ValidationKindCreate], + functions.NewValidateOwnerReferenceFunction(resource, idFactory)) + validations[functions.ValidationKindUpdate] = append( + validations[functions.ValidationKindUpdate], + functions.NewValidateOwnerReferenceFunction(resource, idFactory)) + } + secrets, err := getOperatorSpecSubType(defs, resource, astmodel.OperatorSpecSecretsProperty) if err != nil { return nil, err diff --git a/v2/tools/generator/internal/codegen/testdata/ArmResource/Arm_oneof_resource_conversion_on_arm_type_only_azure.golden b/v2/tools/generator/internal/codegen/testdata/ArmResource/Arm_oneof_resource_conversion_on_arm_type_only_azure.golden index 254cb355f49..9d6194ba879 100644 --- a/v2/tools/generator/internal/codegen/testdata/ArmResource/Arm_oneof_resource_conversion_on_arm_type_only_azure.golden +++ b/v2/tools/generator/internal/codegen/testdata/ArmResource/Arm_oneof_resource_conversion_on_arm_type_only_azure.golden @@ -116,11 +116,7 @@ func (resource *FakeResource) GetType() string { // Owner returns the ResourceReference of the owner func (resource *FakeResource) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(resource.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: resource.Spec.Owner.Name, - } + return resource.Spec.Owner.AsResourceReference(group, kind) } // +kubebuilder:webhook:path=/validate-test-azure-com-v1api20200101-fakeresource,mutating=false,sideEffects=None,matchPolicy=Exact,failurePolicy=fail,groups=test.azure.com,resources=fakeresources,verbs=create;update,versions=v1api20200101,name=validate.v1api20200101.fakeresources.test.azure.com,admissionReviewVersions=v1 @@ -159,7 +155,7 @@ func (resource *FakeResource) ValidateUpdate(old runtime.Object) (admission.Warn // createValidations validates the creation of the resource func (resource *FakeResource) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){resource.validateResourceReferences} + return []func() (admission.Warnings, error){resource.validateResourceReferences, resource.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -173,7 +169,16 @@ func (resource *FakeResource) updateValidations() []func(old runtime.Object) (ad func(old runtime.Object) (admission.Warnings, error) { return resource.validateResourceReferences() }, - resource.validateWriteOnceProperties} + resource.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return resource.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (resource *FakeResource) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(resource) } // validateResourceReferences validates all resource references @@ -338,7 +343,10 @@ func (resource *FakeResource_Spec) PopulateFromARM(owner genruntime.ArbitraryOwn resource.SetAzureName(genruntime.ExtractKubernetesResourceNameFromARMName(typedInput.Name)) // Set property "Owner": - resource.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + resource.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "Type": resource.Type = typedInput.Type diff --git a/v2/tools/generator/internal/codegen/testdata/ArmResource/Arm_test_dependent_resource_and_ownership_azure.golden b/v2/tools/generator/internal/codegen/testdata/ArmResource/Arm_test_dependent_resource_and_ownership_azure.golden index b25e3e9a51e..284a38b659d 100644 --- a/v2/tools/generator/internal/codegen/testdata/ArmResource/Arm_test_dependent_resource_and_ownership_azure.golden +++ b/v2/tools/generator/internal/codegen/testdata/ArmResource/Arm_test_dependent_resource_and_ownership_azure.golden @@ -114,11 +114,7 @@ func (a *A) GetType() string { // Owner returns the ResourceReference of the owner func (a *A) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(a.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: a.Spec.Owner.Name, - } + return a.Spec.Owner.AsResourceReference(group, kind) } // +kubebuilder:webhook:path=/validate-test-azure-com-v1api20200101-a,mutating=false,sideEffects=None,matchPolicy=Exact,failurePolicy=fail,groups=test.azure.com,resources=as,verbs=create;update,versions=v1api20200101,name=validate.v1api20200101.as.test.azure.com,admissionReviewVersions=v1 @@ -157,7 +153,7 @@ func (a *A) ValidateUpdate(old runtime.Object) (admission.Warnings, error) { // createValidations validates the creation of the resource func (a *A) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){a.validateResourceReferences} + return []func() (admission.Warnings, error){a.validateResourceReferences, a.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -171,7 +167,16 @@ func (a *A) updateValidations() []func(old runtime.Object) (admission.Warnings, func(old runtime.Object) (admission.Warnings, error) { return a.validateResourceReferences() }, - a.validateWriteOnceProperties} + a.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return a.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (a *A) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(a) } // validateResourceReferences validates all resource references @@ -366,11 +371,7 @@ func (b *B) GetType() string { // Owner returns the ResourceReference of the owner func (b *B) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(b.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: b.Spec.Owner.Name, - } + return b.Spec.Owner.AsResourceReference(group, kind) } // +kubebuilder:webhook:path=/validate-test-azure-com-v1api20200101-b,mutating=false,sideEffects=None,matchPolicy=Exact,failurePolicy=fail,groups=test.azure.com,resources=bs,verbs=create;update,versions=v1api20200101,name=validate.v1api20200101.bs.test.azure.com,admissionReviewVersions=v1 @@ -409,7 +410,7 @@ func (b *B) ValidateUpdate(old runtime.Object) (admission.Warnings, error) { // createValidations validates the creation of the resource func (b *B) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){b.validateResourceReferences} + return []func() (admission.Warnings, error){b.validateResourceReferences, b.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -423,7 +424,16 @@ func (b *B) updateValidations() []func(old runtime.Object) (admission.Warnings, func(old runtime.Object) (admission.Warnings, error) { return b.validateResourceReferences() }, - b.validateWriteOnceProperties} + b.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return b.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (b *B) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(b) } // validateResourceReferences validates all resource references @@ -618,11 +628,7 @@ func (c *C) GetType() string { // Owner returns the ResourceReference of the owner func (c *C) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(c.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: c.Spec.Owner.Name, - } + return c.Spec.Owner.AsResourceReference(group, kind) } // +kubebuilder:webhook:path=/validate-test-azure-com-v1api20200101-c,mutating=false,sideEffects=None,matchPolicy=Exact,failurePolicy=fail,groups=test.azure.com,resources=cs,verbs=create;update,versions=v1api20200101,name=validate.v1api20200101.cs.test.azure.com,admissionReviewVersions=v1 @@ -661,7 +667,7 @@ func (c *C) ValidateUpdate(old runtime.Object) (admission.Warnings, error) { // createValidations validates the creation of the resource func (c *C) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){c.validateResourceReferences} + return []func() (admission.Warnings, error){c.validateResourceReferences, c.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -675,7 +681,16 @@ func (c *C) updateValidations() []func(old runtime.Object) (admission.Warnings, func(old runtime.Object) (admission.Warnings, error) { return c.validateResourceReferences() }, - c.validateWriteOnceProperties} + c.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return c.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (c *C) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(c) } // validateResourceReferences validates all resource references @@ -870,11 +885,7 @@ func (d *D) GetType() string { // Owner returns the ResourceReference of the owner func (d *D) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(d.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: d.Spec.Owner.Name, - } + return d.Spec.Owner.AsResourceReference(group, kind) } // +kubebuilder:webhook:path=/validate-test-azure-com-v1api20200101-d,mutating=false,sideEffects=None,matchPolicy=Exact,failurePolicy=fail,groups=test.azure.com,resources=ds,verbs=create;update,versions=v1api20200101,name=validate.v1api20200101.ds.test.azure.com,admissionReviewVersions=v1 @@ -913,7 +924,7 @@ func (d *D) ValidateUpdate(old runtime.Object) (admission.Warnings, error) { // createValidations validates the creation of the resource func (d *D) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){d.validateResourceReferences} + return []func() (admission.Warnings, error){d.validateResourceReferences, d.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -927,7 +938,16 @@ func (d *D) updateValidations() []func(old runtime.Object) (admission.Warnings, func(old runtime.Object) (admission.Warnings, error) { return d.validateResourceReferences() }, - d.validateWriteOnceProperties} + d.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return d.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (d *D) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(d) } // validateResourceReferences validates all resource references @@ -1087,7 +1107,10 @@ func (a *A_Spec) PopulateFromARM(owner genruntime.ArbitraryOwnerReference, armIn a.SetAzureName(genruntime.ExtractKubernetesResourceNameFromARMName(typedInput.Name)) // Set property "Owner": - a.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + a.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "Type": a.Type = typedInput.Type @@ -1296,7 +1319,10 @@ func (b *B_Spec) PopulateFromARM(owner genruntime.ArbitraryOwnerReference, armIn b.SetAzureName(genruntime.ExtractKubernetesResourceNameFromARMName(typedInput.Name)) // Set property "Owner": - b.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + b.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "Type": b.Type = typedInput.Type @@ -1500,7 +1526,10 @@ func (c *C_Spec) PopulateFromARM(owner genruntime.ArbitraryOwnerReference, armIn c.SetAzureName(genruntime.ExtractKubernetesResourceNameFromARMName(typedInput.Name)) // Set property "Owner": - c.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + c.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "Type": c.Type = typedInput.Type @@ -1704,7 +1733,10 @@ func (d *D_Spec) PopulateFromARM(owner genruntime.ArbitraryOwnerReference, armIn d.SetAzureName(genruntime.ExtractKubernetesResourceNameFromARMName(typedInput.Name)) // Set property "Owner": - d.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + d.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "Type": d.Type = typedInput.Type diff --git a/v2/tools/generator/internal/codegen/testdata/ArmResource/Arm_test_id_resource_reference_azure.golden b/v2/tools/generator/internal/codegen/testdata/ArmResource/Arm_test_id_resource_reference_azure.golden index 63cddbf6d97..4df76c9de69 100644 --- a/v2/tools/generator/internal/codegen/testdata/ArmResource/Arm_test_id_resource_reference_azure.golden +++ b/v2/tools/generator/internal/codegen/testdata/ArmResource/Arm_test_id_resource_reference_azure.golden @@ -116,11 +116,7 @@ func (resource *FakeResource) GetType() string { // Owner returns the ResourceReference of the owner func (resource *FakeResource) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(resource.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: resource.Spec.Owner.Name, - } + return resource.Spec.Owner.AsResourceReference(group, kind) } // +kubebuilder:webhook:path=/validate-test-azure-com-v1api20200101-fakeresource,mutating=false,sideEffects=None,matchPolicy=Exact,failurePolicy=fail,groups=test.azure.com,resources=fakeresources,verbs=create;update,versions=v1api20200101,name=validate.v1api20200101.fakeresources.test.azure.com,admissionReviewVersions=v1 @@ -159,7 +155,7 @@ func (resource *FakeResource) ValidateUpdate(old runtime.Object) (admission.Warn // createValidations validates the creation of the resource func (resource *FakeResource) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){resource.validateResourceReferences} + return []func() (admission.Warnings, error){resource.validateResourceReferences, resource.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -173,7 +169,16 @@ func (resource *FakeResource) updateValidations() []func(old runtime.Object) (ad func(old runtime.Object) (admission.Warnings, error) { return resource.validateResourceReferences() }, - resource.validateWriteOnceProperties} + resource.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return resource.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (resource *FakeResource) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(resource) } // validateResourceReferences validates all resource references @@ -354,7 +359,10 @@ func (resource *FakeResource_Spec) PopulateFromARM(owner genruntime.ArbitraryOwn resource.SetAzureName(genruntime.ExtractKubernetesResourceNameFromARMName(typedInput.Name)) // Set property "Owner": - resource.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + resource.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "Properties": if typedInput.Properties != nil { diff --git a/v2/tools/generator/internal/codegen/testdata/ArmResource/Arm_test_required_and_optional_resource_references_azure.golden b/v2/tools/generator/internal/codegen/testdata/ArmResource/Arm_test_required_and_optional_resource_references_azure.golden index a84eee1c6a2..dfa6cc706c3 100644 --- a/v2/tools/generator/internal/codegen/testdata/ArmResource/Arm_test_required_and_optional_resource_references_azure.golden +++ b/v2/tools/generator/internal/codegen/testdata/ArmResource/Arm_test_required_and_optional_resource_references_azure.golden @@ -116,11 +116,7 @@ func (resource *FakeResource) GetType() string { // Owner returns the ResourceReference of the owner func (resource *FakeResource) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(resource.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: resource.Spec.Owner.Name, - } + return resource.Spec.Owner.AsResourceReference(group, kind) } // +kubebuilder:webhook:path=/validate-test-azure-com-v1api20200101-fakeresource,mutating=false,sideEffects=None,matchPolicy=Exact,failurePolicy=fail,groups=test.azure.com,resources=fakeresources,verbs=create;update,versions=v1api20200101,name=validate.v1api20200101.fakeresources.test.azure.com,admissionReviewVersions=v1 @@ -159,7 +155,7 @@ func (resource *FakeResource) ValidateUpdate(old runtime.Object) (admission.Warn // createValidations validates the creation of the resource func (resource *FakeResource) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){resource.validateResourceReferences} + return []func() (admission.Warnings, error){resource.validateResourceReferences, resource.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -173,7 +169,16 @@ func (resource *FakeResource) updateValidations() []func(old runtime.Object) (ad func(old runtime.Object) (admission.Warnings, error) { return resource.validateResourceReferences() }, - resource.validateWriteOnceProperties} + resource.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return resource.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (resource *FakeResource) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(resource) } // validateResourceReferences validates all resource references @@ -354,7 +359,10 @@ func (resource *FakeResource_Spec) PopulateFromARM(owner genruntime.ArbitraryOwn resource.SetAzureName(genruntime.ExtractKubernetesResourceNameFromARMName(typedInput.Name)) // Set property "Owner": - resource.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + resource.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "Properties": if typedInput.Properties != nil { diff --git a/v2/tools/generator/internal/codegen/testdata/ArmResource/Arm_test_simple_resource_array_properties_azure.golden b/v2/tools/generator/internal/codegen/testdata/ArmResource/Arm_test_simple_resource_array_properties_azure.golden index 77cd1b417cf..e7e60322d20 100644 --- a/v2/tools/generator/internal/codegen/testdata/ArmResource/Arm_test_simple_resource_array_properties_azure.golden +++ b/v2/tools/generator/internal/codegen/testdata/ArmResource/Arm_test_simple_resource_array_properties_azure.golden @@ -116,11 +116,7 @@ func (resource *FakeResource) GetType() string { // Owner returns the ResourceReference of the owner func (resource *FakeResource) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(resource.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: resource.Spec.Owner.Name, - } + return resource.Spec.Owner.AsResourceReference(group, kind) } // +kubebuilder:webhook:path=/validate-test-azure-com-v1api20200101-fakeresource,mutating=false,sideEffects=None,matchPolicy=Exact,failurePolicy=fail,groups=test.azure.com,resources=fakeresources,verbs=create;update,versions=v1api20200101,name=validate.v1api20200101.fakeresources.test.azure.com,admissionReviewVersions=v1 @@ -159,7 +155,7 @@ func (resource *FakeResource) ValidateUpdate(old runtime.Object) (admission.Warn // createValidations validates the creation of the resource func (resource *FakeResource) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){resource.validateResourceReferences} + return []func() (admission.Warnings, error){resource.validateResourceReferences, resource.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -173,7 +169,16 @@ func (resource *FakeResource) updateValidations() []func(old runtime.Object) (ad func(old runtime.Object) (admission.Warnings, error) { return resource.validateResourceReferences() }, - resource.validateWriteOnceProperties} + resource.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return resource.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (resource *FakeResource) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(resource) } // validateResourceReferences validates all resource references @@ -482,7 +487,10 @@ func (resource *FakeResource_Spec) PopulateFromARM(owner genruntime.ArbitraryOwn resource.SetAzureName(genruntime.ExtractKubernetesResourceNameFromARMName(typedInput.Name)) // Set property "Owner": - resource.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + resource.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "Type": resource.Type = typedInput.Type diff --git a/v2/tools/generator/internal/codegen/testdata/ArmResource/Arm_test_simple_resource_complex_properties_azure.golden b/v2/tools/generator/internal/codegen/testdata/ArmResource/Arm_test_simple_resource_complex_properties_azure.golden index 40711c5480b..ff5334a6aa7 100644 --- a/v2/tools/generator/internal/codegen/testdata/ArmResource/Arm_test_simple_resource_complex_properties_azure.golden +++ b/v2/tools/generator/internal/codegen/testdata/ArmResource/Arm_test_simple_resource_complex_properties_azure.golden @@ -116,11 +116,7 @@ func (resource *FakeResource) GetType() string { // Owner returns the ResourceReference of the owner func (resource *FakeResource) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(resource.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: resource.Spec.Owner.Name, - } + return resource.Spec.Owner.AsResourceReference(group, kind) } // +kubebuilder:webhook:path=/validate-test-azure-com-v1api20200101-fakeresource,mutating=false,sideEffects=None,matchPolicy=Exact,failurePolicy=fail,groups=test.azure.com,resources=fakeresources,verbs=create;update,versions=v1api20200101,name=validate.v1api20200101.fakeresources.test.azure.com,admissionReviewVersions=v1 @@ -159,7 +155,7 @@ func (resource *FakeResource) ValidateUpdate(old runtime.Object) (admission.Warn // createValidations validates the creation of the resource func (resource *FakeResource) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){resource.validateResourceReferences} + return []func() (admission.Warnings, error){resource.validateResourceReferences, resource.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -173,7 +169,16 @@ func (resource *FakeResource) updateValidations() []func(old runtime.Object) (ad func(old runtime.Object) (admission.Warnings, error) { return resource.validateResourceReferences() }, - resource.validateWriteOnceProperties} + resource.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return resource.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (resource *FakeResource) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(resource) } // validateResourceReferences validates all resource references @@ -416,7 +421,10 @@ func (resource *FakeResource_Spec) PopulateFromARM(owner genruntime.ArbitraryOwn } // Set property "Owner": - resource.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + resource.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "Type": resource.Type = typedInput.Type diff --git a/v2/tools/generator/internal/codegen/testdata/ArmResource/Arm_test_simple_resource_json_fields_azure.golden b/v2/tools/generator/internal/codegen/testdata/ArmResource/Arm_test_simple_resource_json_fields_azure.golden index 0819863ec93..db8ca58f235 100644 --- a/v2/tools/generator/internal/codegen/testdata/ArmResource/Arm_test_simple_resource_json_fields_azure.golden +++ b/v2/tools/generator/internal/codegen/testdata/ArmResource/Arm_test_simple_resource_json_fields_azure.golden @@ -117,11 +117,7 @@ func (resource *FakeResource) GetType() string { // Owner returns the ResourceReference of the owner func (resource *FakeResource) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(resource.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: resource.Spec.Owner.Name, - } + return resource.Spec.Owner.AsResourceReference(group, kind) } // +kubebuilder:webhook:path=/validate-test-azure-com-v1api20200101-fakeresource,mutating=false,sideEffects=None,matchPolicy=Exact,failurePolicy=fail,groups=test.azure.com,resources=fakeresources,verbs=create;update,versions=v1api20200101,name=validate.v1api20200101.fakeresources.test.azure.com,admissionReviewVersions=v1 @@ -160,7 +156,7 @@ func (resource *FakeResource) ValidateUpdate(old runtime.Object) (admission.Warn // createValidations validates the creation of the resource func (resource *FakeResource) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){resource.validateResourceReferences} + return []func() (admission.Warnings, error){resource.validateResourceReferences, resource.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -174,7 +170,16 @@ func (resource *FakeResource) updateValidations() []func(old runtime.Object) (ad func(old runtime.Object) (admission.Warnings, error) { return resource.validateResourceReferences() }, - resource.validateWriteOnceProperties} + resource.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return resource.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (resource *FakeResource) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(resource) } // validateResourceReferences validates all resource references @@ -389,7 +394,10 @@ func (resource *FakeResource_Spec) PopulateFromARM(owner genruntime.ArbitraryOwn } // Set property "Owner": - resource.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + resource.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "Type": resource.Type = typedInput.Type diff --git a/v2/tools/generator/internal/codegen/testdata/ArmResource/Arm_test_simple_resource_map_properties_azure.golden b/v2/tools/generator/internal/codegen/testdata/ArmResource/Arm_test_simple_resource_map_properties_azure.golden index 6de1e70ec79..9154c3a2de6 100644 --- a/v2/tools/generator/internal/codegen/testdata/ArmResource/Arm_test_simple_resource_map_properties_azure.golden +++ b/v2/tools/generator/internal/codegen/testdata/ArmResource/Arm_test_simple_resource_map_properties_azure.golden @@ -116,11 +116,7 @@ func (resource *FakeResource) GetType() string { // Owner returns the ResourceReference of the owner func (resource *FakeResource) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(resource.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: resource.Spec.Owner.Name, - } + return resource.Spec.Owner.AsResourceReference(group, kind) } // +kubebuilder:webhook:path=/validate-test-azure-com-v1api20200101-fakeresource,mutating=false,sideEffects=None,matchPolicy=Exact,failurePolicy=fail,groups=test.azure.com,resources=fakeresources,verbs=create;update,versions=v1api20200101,name=validate.v1api20200101.fakeresources.test.azure.com,admissionReviewVersions=v1 @@ -159,7 +155,7 @@ func (resource *FakeResource) ValidateUpdate(old runtime.Object) (admission.Warn // createValidations validates the creation of the resource func (resource *FakeResource) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){resource.validateResourceReferences} + return []func() (admission.Warnings, error){resource.validateResourceReferences, resource.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -173,7 +169,16 @@ func (resource *FakeResource) updateValidations() []func(old runtime.Object) (ad func(old runtime.Object) (admission.Warnings, error) { return resource.validateResourceReferences() }, - resource.validateWriteOnceProperties} + resource.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return resource.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (resource *FakeResource) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(resource) } // validateResourceReferences validates all resource references @@ -580,7 +585,10 @@ func (resource *FakeResource_Spec) PopulateFromARM(owner genruntime.ArbitraryOwn } // Set property "Owner": - resource.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + resource.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "Type": resource.Type = typedInput.Type diff --git a/v2/tools/generator/internal/codegen/testdata/ArmResource/Arm_test_simple_resource_renders_spec_azure.golden b/v2/tools/generator/internal/codegen/testdata/ArmResource/Arm_test_simple_resource_renders_spec_azure.golden index 254cb355f49..9d6194ba879 100644 --- a/v2/tools/generator/internal/codegen/testdata/ArmResource/Arm_test_simple_resource_renders_spec_azure.golden +++ b/v2/tools/generator/internal/codegen/testdata/ArmResource/Arm_test_simple_resource_renders_spec_azure.golden @@ -116,11 +116,7 @@ func (resource *FakeResource) GetType() string { // Owner returns the ResourceReference of the owner func (resource *FakeResource) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(resource.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: resource.Spec.Owner.Name, - } + return resource.Spec.Owner.AsResourceReference(group, kind) } // +kubebuilder:webhook:path=/validate-test-azure-com-v1api20200101-fakeresource,mutating=false,sideEffects=None,matchPolicy=Exact,failurePolicy=fail,groups=test.azure.com,resources=fakeresources,verbs=create;update,versions=v1api20200101,name=validate.v1api20200101.fakeresources.test.azure.com,admissionReviewVersions=v1 @@ -159,7 +155,7 @@ func (resource *FakeResource) ValidateUpdate(old runtime.Object) (admission.Warn // createValidations validates the creation of the resource func (resource *FakeResource) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){resource.validateResourceReferences} + return []func() (admission.Warnings, error){resource.validateResourceReferences, resource.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -173,7 +169,16 @@ func (resource *FakeResource) updateValidations() []func(old runtime.Object) (ad func(old runtime.Object) (admission.Warnings, error) { return resource.validateResourceReferences() }, - resource.validateWriteOnceProperties} + resource.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return resource.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (resource *FakeResource) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(resource) } // validateResourceReferences validates all resource references @@ -338,7 +343,10 @@ func (resource *FakeResource_Spec) PopulateFromARM(owner genruntime.ArbitraryOwn resource.SetAzureName(genruntime.ExtractKubernetesResourceNameFromARMName(typedInput.Name)) // Set property "Owner": - resource.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + resource.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "Type": resource.Type = typedInput.Type diff --git a/v2/tools/generator/internal/codegen/testdata/EmbeddedTypes/Embedded_type_simple_resource.golden b/v2/tools/generator/internal/codegen/testdata/EmbeddedTypes/Embedded_type_simple_resource.golden index c965a248046..1bef4f597ba 100644 --- a/v2/tools/generator/internal/codegen/testdata/EmbeddedTypes/Embedded_type_simple_resource.golden +++ b/v2/tools/generator/internal/codegen/testdata/EmbeddedTypes/Embedded_type_simple_resource.golden @@ -116,11 +116,7 @@ func (resource *FakeResource) GetType() string { // Owner returns the ResourceReference of the owner func (resource *FakeResource) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(resource.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: resource.Spec.Owner.Name, - } + return resource.Spec.Owner.AsResourceReference(group, kind) } // +kubebuilder:webhook:path=/validate-test-azure-com-v1api20200101-fakeresource,mutating=false,sideEffects=None,matchPolicy=Exact,failurePolicy=fail,groups=test.azure.com,resources=fakeresources,verbs=create;update,versions=v1api20200101,name=validate.v1api20200101.fakeresources.test.azure.com,admissionReviewVersions=v1 @@ -159,7 +155,7 @@ func (resource *FakeResource) ValidateUpdate(old runtime.Object) (admission.Warn // createValidations validates the creation of the resource func (resource *FakeResource) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){resource.validateResourceReferences} + return []func() (admission.Warnings, error){resource.validateResourceReferences, resource.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -173,7 +169,16 @@ func (resource *FakeResource) updateValidations() []func(old runtime.Object) (ad func(old runtime.Object) (admission.Warnings, error) { return resource.validateResourceReferences() }, - resource.validateWriteOnceProperties} + resource.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return resource.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (resource *FakeResource) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(resource) } // validateResourceReferences validates all resource references @@ -423,7 +428,10 @@ func (resource *FakeResource_Spec) PopulateFromARM(owner genruntime.ArbitraryOwn } // Set property "Owner": - resource.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + resource.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "Type": resource.Type = typedInput.Type diff --git a/v2/tools/generator/internal/codegen/testdata/EnumNames/Multi_valued_enum_name.golden b/v2/tools/generator/internal/codegen/testdata/EnumNames/Multi_valued_enum_name.golden index 4211cd57645..d438db8474a 100644 --- a/v2/tools/generator/internal/codegen/testdata/EnumNames/Multi_valued_enum_name.golden +++ b/v2/tools/generator/internal/codegen/testdata/EnumNames/Multi_valued_enum_name.golden @@ -116,11 +116,7 @@ func (resource *AResource) GetType() string { // Owner returns the ResourceReference of the owner func (resource *AResource) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(resource.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: resource.Spec.Owner.Name, - } + return resource.Spec.Owner.AsResourceReference(group, kind) } // +kubebuilder:webhook:path=/validate-test-azure-com-v1api20200101-aresource,mutating=false,sideEffects=None,matchPolicy=Exact,failurePolicy=fail,groups=test.azure.com,resources=aresources,verbs=create;update,versions=v1api20200101,name=validate.v1api20200101.aresources.test.azure.com,admissionReviewVersions=v1 @@ -159,7 +155,7 @@ func (resource *AResource) ValidateUpdate(old runtime.Object) (admission.Warning // createValidations validates the creation of the resource func (resource *AResource) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){resource.validateResourceReferences} + return []func() (admission.Warnings, error){resource.validateResourceReferences, resource.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -173,7 +169,16 @@ func (resource *AResource) updateValidations() []func(old runtime.Object) (admis func(old runtime.Object) (admission.Warnings, error) { return resource.validateResourceReferences() }, - resource.validateWriteOnceProperties} + resource.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return resource.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (resource *AResource) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(resource) } // validateResourceReferences validates all resource references @@ -338,7 +343,10 @@ func (resource *AResource_Spec) PopulateFromARM(owner genruntime.ArbitraryOwnerR resource.SetAzureName(genruntime.ExtractKubernetesResourceNameFromARMName(typedInput.Name)) // Set property "Owner": - resource.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + resource.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "Type": resource.Type = typedInput.Type diff --git a/v2/tools/generator/internal/codegen/testdata/EnumNames/Single_valued_enum_name.golden b/v2/tools/generator/internal/codegen/testdata/EnumNames/Single_valued_enum_name.golden index abcacc04180..756c2910180 100644 --- a/v2/tools/generator/internal/codegen/testdata/EnumNames/Single_valued_enum_name.golden +++ b/v2/tools/generator/internal/codegen/testdata/EnumNames/Single_valued_enum_name.golden @@ -109,11 +109,7 @@ func (resource *AResource) GetType() string { // Owner returns the ResourceReference of the owner func (resource *AResource) Owner() *genruntime.ResourceReference { group, kind := genruntime.LookupOwnerGroupKind(resource.Spec) - return &genruntime.ResourceReference{ - Group: group, - Kind: kind, - Name: resource.Spec.Owner.Name, - } + return resource.Spec.Owner.AsResourceReference(group, kind) } // +kubebuilder:webhook:path=/validate-test-azure-com-v1api20200101-aresource,mutating=false,sideEffects=None,matchPolicy=Exact,failurePolicy=fail,groups=test.azure.com,resources=aresources,verbs=create;update,versions=v1api20200101,name=validate.v1api20200101.aresources.test.azure.com,admissionReviewVersions=v1 @@ -152,7 +148,7 @@ func (resource *AResource) ValidateUpdate(old runtime.Object) (admission.Warning // createValidations validates the creation of the resource func (resource *AResource) createValidations() []func() (admission.Warnings, error) { - return []func() (admission.Warnings, error){resource.validateResourceReferences} + return []func() (admission.Warnings, error){resource.validateResourceReferences, resource.validateOwnerReference} } // deleteValidations validates the deletion of the resource @@ -166,7 +162,16 @@ func (resource *AResource) updateValidations() []func(old runtime.Object) (admis func(old runtime.Object) (admission.Warnings, error) { return resource.validateResourceReferences() }, - resource.validateWriteOnceProperties} + resource.validateWriteOnceProperties, + func(old runtime.Object) (admission.Warnings, error) { + return resource.validateOwnerReference() + }, + } +} + +// validateOwnerReference validates the owner field +func (resource *AResource) validateOwnerReference() (admission.Warnings, error) { + return genruntime.ValidateOwner(resource) } // validateResourceReferences validates all resource references @@ -324,7 +329,10 @@ func (resource *AResource_Spec) PopulateFromARM(owner genruntime.ArbitraryOwnerR resource.APIVersion = typedInput.APIVersion // Set property "Owner": - resource.Owner = &genruntime.KnownResourceReference{Name: owner.Name} + resource.Owner = &genruntime.KnownResourceReference{ + Name: owner.Name, + ARMID: owner.ARMID, + } // Set property "Type": resource.Type = typedInput.Type diff --git a/v2/tools/generator/internal/functions/kubernetes_admissions_validations.go b/v2/tools/generator/internal/functions/kubernetes_admissions_validations.go index 4c2c1b6393e..9df90fb92c8 100644 --- a/v2/tools/generator/internal/functions/kubernetes_admissions_validations.go +++ b/v2/tools/generator/internal/functions/kubernetes_admissions_validations.go @@ -23,6 +23,15 @@ func NewValidateResourceReferencesFunction(resource *astmodel.ResourceType, idFa astmodel.NewPackageReferenceSet(astmodel.GenRuntimeReference, astmodel.ReflectHelpersReference)) } +func NewValidateOwnerReferenceFunction(resource *astmodel.ResourceType, idFactory astmodel.IdentifierFactory) *ResourceFunction { + return NewResourceFunction( + "validateOwnerReference", + resource, + idFactory, + validateOwnerReferences, + astmodel.NewPackageReferenceSet(astmodel.GenRuntimeReference)) +} + func NewValidateWriteOncePropertiesFunction(resource *astmodel.ResourceType, idFactory astmodel.IdentifierFactory) *ResourceFunction { return NewResourceFunction( "validateWriteOnceProperties", @@ -92,6 +101,42 @@ func validateResourceReferencesBody(codeGenerationContext *astmodel.CodeGenerati return body } +func validateOwnerReferences(k *ResourceFunction, codeGenerationContext *astmodel.CodeGenerationContext, receiver astmodel.TypeName, methodName string) *dst.FuncDecl { + receiverIdent := k.IdFactory().CreateReceiver(receiver.Name()) + receiverType := receiver.AsType(codeGenerationContext) + + fn := &astbuilder.FuncDetails{ + Name: methodName, + ReceiverIdent: receiverIdent, + ReceiverType: astbuilder.PointerTo(receiverType), + Body: validateOwnerReferencesBody(codeGenerationContext, receiverIdent), + } + + fn.AddReturn(astbuilder.QualifiedTypeName(codeGenerationContext.MustGetImportedPackageName(astmodel.ControllerRuntimeAdmission), "Warnings")) + fn.AddReturn(dst.NewIdent("error")) + fn.AddComments("validates the owner field") + return fn.DefineFunc() +} + +// validateOwnerReferencesBody helps generate the body of the validateOwnerReferences function: +// +// return genruntime.ValidateOwner() +func validateOwnerReferencesBody(codeGenerationContext *astmodel.CodeGenerationContext, receiverIdent string) []dst.Stmt { + genRuntime := codeGenerationContext.MustGetImportedPackageName(astmodel.GenRuntimeReference) + + var body []dst.Stmt + + body = append( + body, + astbuilder.Returns( + astbuilder.CallQualifiedFunc( + genRuntime, + "ValidateOwner", + dst.NewIdent(receiverIdent)))) + + return body +} + func validateWriteOncePropertiesFunction(resourceFn *ResourceFunction, codeGenerationContext *astmodel.CodeGenerationContext, receiver astmodel.TypeName, methodName string) *dst.FuncDecl { receiverIdent := resourceFn.IdFactory().CreateReceiver(receiver.Name()) diff --git a/v2/tools/generator/internal/interfaces/kubernetes_resource_interface.go b/v2/tools/generator/internal/interfaces/kubernetes_resource_interface.go index fb7c170e1f1..d3219fa2049 100644 --- a/v2/tools/generator/internal/interfaces/kubernetes_resource_interface.go +++ b/v2/tools/generator/internal/interfaces/kubernetes_resource_interface.go @@ -286,13 +286,13 @@ func fixedValueGetAzureNameFunction(fixedValue string) functions.ObjectFunctionH // // func ( *) Owner() *genruntime.ResourceReference { // group, kind := genruntime.LookupOwnerGroupKind(.Spec) -// return &genruntime.ResourceReference{Group: group, Kind: kind, Namespace: .Namespace, Name: .Spec.Owner.Name} +// return .Spec.Owner.AsKnownResourceReference(group, kind) // } // // For extension resources: // // func ( *) Owner() *genruntime.ResourceReference { -// return &genruntime.ResourceReference{Group: .Spec.Owner.Group, Kind: .Spec.Owner.Kind, name: .Spec.Owner.Name} +// return .Spec.Owner.AsKnownResourceReference() // } func newOwnerFunction(r *astmodel.ResourceType) func(k *functions.ObjectFunction, codeGenerationContext *astmodel.CodeGenerationContext, receiver astmodel.TypeName, methodName string) *dst.FuncDecl { return func(k *functions.ObjectFunction, codeGenerationContext *astmodel.CodeGenerationContext, receiver astmodel.TypeName, methodName string) *dst.FuncDecl { @@ -305,7 +305,6 @@ func newOwnerFunction(r *astmodel.ResourceType) func(k *functions.ObjectFunction ReceiverType: astbuilder.PointerTo(receiver.AsType(codeGenerationContext)), Params: nil, } - fn.AddReturn(astbuilder.Dereference(astmodel.ResourceReferenceType.AsType(codeGenerationContext))) groupLocal := "group" @@ -315,20 +314,19 @@ func newOwnerFunction(r *astmodel.ResourceType) func(k *functions.ObjectFunction kindLocal = "ownerKind" } + owner := astbuilder.Selector(specSelector, astmodel.OwnerProperty) + switch r.Scope() { case astmodel.ResourceScopeResourceGroup: fn.AddComments("returns the ResourceReference of the owner") fn.AddStatements( lookupGroupAndKindStmt(groupLocal, kindLocal, specSelector), - astbuilder.Returns(createResourceReference(dst.NewIdent(groupLocal), dst.NewIdent(kindLocal), receiverIdent))) + astbuilder.Returns(createResourceReferenceWithGroupKind(dst.NewIdent(groupLocal), dst.NewIdent(kindLocal), owner))) case astmodel.ResourceScopeExtension: fn.AddComments("returns the ResourceReference of the owner") - owner := astbuilder.Selector(specSelector, astmodel.OwnerProperty) - group := astbuilder.Selector(owner, "Group") - kind := astbuilder.Selector(owner, "Kind") fn.AddStatements( - astbuilder.Returns(createResourceReference(group, kind, receiverIdent))) + astbuilder.Returns(createResourceReference(owner))) case astmodel.ResourceScopeTenant: // Tenant resources never have an owner, just return nil fn.AddComments("returns nil as Tenant scoped resources never have an owner") @@ -406,22 +404,18 @@ func lookupGroupAndKindStmt( } } -func createResourceReference( +func createResourceReferenceWithGroupKind( group dst.Expr, kind dst.Expr, - receiverIdent string, + ownerSelector dst.Expr, ) dst.Expr { - specSelector := astbuilder.Selector(dst.NewIdent(receiverIdent), "Spec") - - compositeLitDetails := astbuilder.NewCompositeLiteralBuilder( - astbuilder.Selector( - dst.NewIdent(astmodel.GenRuntimeReference.PackageName()), - "ResourceReference")) - compositeLitDetails.AddField("Group", group) - compositeLitDetails.AddField("Kind", kind) - compositeLitDetails.AddField("Name", astbuilder.Selector(astbuilder.Selector(specSelector, astmodel.OwnerProperty), "Name")) + return astbuilder.CallExpr(ownerSelector, "AsResourceReference", group, kind) +} - return astbuilder.AddrOf(compositeLitDetails.Build()) +func createResourceReference( + ownerSelector dst.Expr, +) dst.Expr { + return astbuilder.CallExpr(ownerSelector, "AsResourceReference") } // setStringAzureNameFunction returns a function that sets the Name property of