diff --git a/v2/api/eventgrid/v1api20200601/storage/structure.txt b/v2/api/eventgrid/v1api20200601/storage/structure.txt index 2a1d1e0ac7f..6a5135e7f1b 100644 --- a/v2/api/eventgrid/v1api20200601/storage/structure.txt +++ b/v2/api/eventgrid/v1api20200601/storage/structure.txt @@ -415,7 +415,10 @@ github.com/Azure/azure-service-operator/v2/api/eventgrid/v1api20200601/storage │ │ │ └── SourceField: *string │ │ └── PropertyBag: genruntime.PropertyBag │ ├── Location: *string - │ ├── OperatorSpec: *Object (2 properties) + │ ├── OperatorSpec: *Object (3 properties) + │ │ ├── ConfigMaps: *Object (2 properties) + │ │ │ ├── Endpoint: *genruntime.ConfigMapDestination + │ │ │ └── PropertyBag: genruntime.PropertyBag │ │ ├── PropertyBag: genruntime.PropertyBag │ │ └── Secrets: *Object (3 properties) │ │ ├── Key1: *genruntime.SecretDestination diff --git a/v2/api/eventgrid/v1api20200601/storage/topic_types_gen.go b/v2/api/eventgrid/v1api20200601/storage/topic_types_gen.go index 438a79bccb9..657210cab60 100644 --- a/v2/api/eventgrid/v1api20200601/storage/topic_types_gen.go +++ b/v2/api/eventgrid/v1api20200601/storage/topic_types_gen.go @@ -4,11 +4,16 @@ package storage import ( + "context" + "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/conditions" + "github.com/Azure/azure-service-operator/v2/pkg/genruntime/configmaps" + "github.com/go-logr/logr" "github.com/pkg/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime/schema" + "sigs.k8s.io/controller-runtime/pkg/client" ) // +kubebuilder:rbac:groups=eventgrid.azure.com,resources=topics,verbs=get;list;watch;create;update;patch;delete @@ -44,6 +49,23 @@ func (topic *Topic) SetConditions(conditions conditions.Conditions) { topic.Status.Conditions = conditions } +var _ genruntime.KubernetesExporter = &Topic{} + +// ExportKubernetesResources defines a resource which can create other resources in Kubernetes. +func (topic *Topic) ExportKubernetesResources(_ context.Context, _ genruntime.MetaObject, _ *genericarmclient.GenericClient, _ logr.Logger) ([]client.Object, error) { + collector := configmaps.NewCollector(topic.Namespace) + if topic.Spec.OperatorSpec != nil && topic.Spec.OperatorSpec.ConfigMaps != nil { + if topic.Status.Endpoint != nil { + collector.AddValue(topic.Spec.OperatorSpec.ConfigMaps.Endpoint, *topic.Status.Endpoint) + } + } + result, err := collector.Values() + if err != nil { + return nil, err + } + return configmaps.SliceToClientObjectSlice(result), nil +} + var _ genruntime.KubernetesResource = &Topic{} // AzureName returns the Azure name of the resource @@ -230,8 +252,15 @@ type PrivateEndpointConnection_STATUS_Topic_SubResourceEmbedded struct { // Storage version of v1api20200601.TopicOperatorSpec // Details for configuring operator behavior. Fields in this struct are interpreted by the operator directly rather than being passed to Azure type TopicOperatorSpec struct { - PropertyBag genruntime.PropertyBag `json:"$propertyBag,omitempty"` - Secrets *TopicOperatorSecrets `json:"secrets,omitempty"` + ConfigMaps *TopicOperatorConfigMaps `json:"configMaps,omitempty"` + PropertyBag genruntime.PropertyBag `json:"$propertyBag,omitempty"` + Secrets *TopicOperatorSecrets `json:"secrets,omitempty"` +} + +// Storage version of v1api20200601.TopicOperatorConfigMaps +type TopicOperatorConfigMaps struct { + Endpoint *genruntime.ConfigMapDestination `json:"endpoint,omitempty"` + PropertyBag genruntime.PropertyBag `json:"$propertyBag,omitempty"` } // Storage version of v1api20200601.TopicOperatorSecrets diff --git a/v2/api/eventgrid/v1api20200601/storage/topic_types_gen_test.go b/v2/api/eventgrid/v1api20200601/storage/topic_types_gen_test.go index 05731a64057..e0c2b71c18a 100644 --- a/v2/api/eventgrid/v1api20200601/storage/topic_types_gen_test.go +++ b/v2/api/eventgrid/v1api20200601/storage/topic_types_gen_test.go @@ -363,9 +363,65 @@ func TopicOperatorSpecGenerator() gopter.Gen { // AddRelatedPropertyGeneratorsForTopicOperatorSpec is a factory method for creating gopter generators func AddRelatedPropertyGeneratorsForTopicOperatorSpec(gens map[string]gopter.Gen) { + gens["ConfigMaps"] = gen.PtrOf(TopicOperatorConfigMapsGenerator()) gens["Secrets"] = gen.PtrOf(TopicOperatorSecretsGenerator()) } +func Test_TopicOperatorConfigMaps_WhenSerializedToJson_DeserializesAsEqual(t *testing.T) { + t.Parallel() + parameters := gopter.DefaultTestParameters() + parameters.MinSuccessfulTests = 100 + parameters.MaxSize = 3 + properties := gopter.NewProperties(parameters) + properties.Property( + "Round trip of TopicOperatorConfigMaps via JSON returns original", + prop.ForAll(RunJSONSerializationTestForTopicOperatorConfigMaps, TopicOperatorConfigMapsGenerator())) + properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout)) +} + +// RunJSONSerializationTestForTopicOperatorConfigMaps runs a test to see if a specific instance of TopicOperatorConfigMaps round trips to JSON and back losslessly +func RunJSONSerializationTestForTopicOperatorConfigMaps(subject TopicOperatorConfigMaps) string { + // Serialize to JSON + bin, err := json.Marshal(subject) + if err != nil { + return err.Error() + } + + // Deserialize back into memory + var actual TopicOperatorConfigMaps + err = json.Unmarshal(bin, &actual) + if err != nil { + return err.Error() + } + + // Check for outcome + match := cmp.Equal(subject, actual, cmpopts.EquateEmpty()) + if !match { + actualFmt := pretty.Sprint(actual) + subjectFmt := pretty.Sprint(subject) + result := diff.Diff(subjectFmt, actualFmt) + return result + } + + return "" +} + +// Generator of TopicOperatorConfigMaps instances for property testing - lazily instantiated by +// TopicOperatorConfigMapsGenerator() +var topicOperatorConfigMapsGenerator gopter.Gen + +// TopicOperatorConfigMapsGenerator returns a generator of TopicOperatorConfigMaps instances for property testing. +func TopicOperatorConfigMapsGenerator() gopter.Gen { + if topicOperatorConfigMapsGenerator != nil { + return topicOperatorConfigMapsGenerator + } + + generators := make(map[string]gopter.Gen) + topicOperatorConfigMapsGenerator = gen.Struct(reflect.TypeOf(TopicOperatorConfigMaps{}), generators) + + return topicOperatorConfigMapsGenerator +} + func Test_TopicOperatorSecrets_WhenSerializedToJson_DeserializesAsEqual(t *testing.T) { t.Parallel() parameters := gopter.DefaultTestParameters() diff --git a/v2/api/eventgrid/v1api20200601/storage/zz_generated.deepcopy.go b/v2/api/eventgrid/v1api20200601/storage/zz_generated.deepcopy.go index 4a8264fe7ea..945de29eaf9 100644 --- a/v2/api/eventgrid/v1api20200601/storage/zz_generated.deepcopy.go +++ b/v2/api/eventgrid/v1api20200601/storage/zz_generated.deepcopy.go @@ -2980,6 +2980,33 @@ func (in *TopicList) DeepCopyObject() runtime.Object { return nil } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *TopicOperatorConfigMaps) DeepCopyInto(out *TopicOperatorConfigMaps) { + *out = *in + if in.Endpoint != nil { + in, out := &in.Endpoint, &out.Endpoint + *out = new(genruntime.ConfigMapDestination) + **out = **in + } + if in.PropertyBag != nil { + in, out := &in.PropertyBag, &out.PropertyBag + *out = make(genruntime.PropertyBag, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TopicOperatorConfigMaps. +func (in *TopicOperatorConfigMaps) DeepCopy() *TopicOperatorConfigMaps { + if in == nil { + return nil + } + out := new(TopicOperatorConfigMaps) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *TopicOperatorSecrets) DeepCopyInto(out *TopicOperatorSecrets) { *out = *in @@ -3015,6 +3042,11 @@ func (in *TopicOperatorSecrets) DeepCopy() *TopicOperatorSecrets { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *TopicOperatorSpec) DeepCopyInto(out *TopicOperatorSpec) { *out = *in + if in.ConfigMaps != nil { + in, out := &in.ConfigMaps, &out.ConfigMaps + *out = new(TopicOperatorConfigMaps) + (*in).DeepCopyInto(*out) + } if in.PropertyBag != nil { in, out := &in.PropertyBag, &out.PropertyBag *out = make(genruntime.PropertyBag, len(*in)) diff --git a/v2/api/eventgrid/v1api20200601/structure.txt b/v2/api/eventgrid/v1api20200601/structure.txt index 85c06211418..4094a1690dc 100644 --- a/v2/api/eventgrid/v1api20200601/structure.txt +++ b/v2/api/eventgrid/v1api20200601/structure.txt @@ -844,7 +844,9 @@ github.com/Azure/azure-service-operator/v2/api/eventgrid/v1api20200601 │ │ │ └── Topic: *Object (1 property) │ │ │ └── SourceField: *string │ │ ├── Location: *string -│ │ ├── OperatorSpec: *Object (1 property) +│ │ ├── OperatorSpec: *Object (2 properties) +│ │ │ ├── ConfigMaps: *Object (1 property) +│ │ │ │ └── Endpoint: *genruntime.ConfigMapDestination │ │ │ └── Secrets: *Object (2 properties) │ │ │ ├── Key1: *genruntime.SecretDestination │ │ │ └── Key2: *genruntime.SecretDestination diff --git a/v2/api/eventgrid/v1api20200601/topic_types_gen.go b/v2/api/eventgrid/v1api20200601/topic_types_gen.go index b45299df344..1b30554d143 100644 --- a/v2/api/eventgrid/v1api20200601/topic_types_gen.go +++ b/v2/api/eventgrid/v1api20200601/topic_types_gen.go @@ -4,15 +4,20 @@ package v1api20200601 import ( + "context" "fmt" v20200601s "github.com/Azure/azure-service-operator/v2/api/eventgrid/v1api20200601/storage" + "github.com/Azure/azure-service-operator/v2/internal/genericarmclient" "github.com/Azure/azure-service-operator/v2/internal/reflecthelpers" "github.com/Azure/azure-service-operator/v2/pkg/genruntime" "github.com/Azure/azure-service-operator/v2/pkg/genruntime/conditions" + "github.com/Azure/azure-service-operator/v2/pkg/genruntime/configmaps" + "github.com/go-logr/logr" "github.com/pkg/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime/schema" + "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/conversion" "sigs.k8s.io/controller-runtime/pkg/webhook/admission" ) @@ -101,6 +106,23 @@ func (topic *Topic) InitializeSpec(status genruntime.ConvertibleStatus) error { return fmt.Errorf("expected Status of type Topic_STATUS but received %T instead", status) } +var _ genruntime.KubernetesExporter = &Topic{} + +// ExportKubernetesResources defines a resource which can create other resources in Kubernetes. +func (topic *Topic) ExportKubernetesResources(_ context.Context, _ genruntime.MetaObject, _ *genericarmclient.GenericClient, _ logr.Logger) ([]client.Object, error) { + collector := configmaps.NewCollector(topic.Namespace) + if topic.Spec.OperatorSpec != nil && topic.Spec.OperatorSpec.ConfigMaps != nil { + if topic.Status.Endpoint != nil { + collector.AddValue(topic.Spec.OperatorSpec.ConfigMaps.Endpoint, *topic.Status.Endpoint) + } + } + result, err := collector.Values() + if err != nil { + return nil, err + } + return configmaps.SliceToClientObjectSlice(result), nil +} + var _ genruntime.KubernetesResource = &Topic{} // AzureName returns the Azure name of the resource @@ -208,7 +230,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, topic.validateOwnerReference, topic.validateSecretDestinations} + return []func() (admission.Warnings, error){topic.validateResourceReferences, topic.validateOwnerReference, topic.validateSecretDestinations, topic.validateConfigMapDestinations} } // deleteValidations validates the deletion of the resource @@ -229,9 +251,26 @@ func (topic *Topic) updateValidations() []func(old runtime.Object) (admission.Wa func(old runtime.Object) (admission.Warnings, error) { return topic.validateSecretDestinations() }, + func(old runtime.Object) (admission.Warnings, error) { + return topic.validateConfigMapDestinations() + }, } } +// validateConfigMapDestinations validates there are no colliding genruntime.ConfigMapDestinations +func (topic *Topic) validateConfigMapDestinations() (admission.Warnings, error) { + if topic.Spec.OperatorSpec == nil { + return nil, nil + } + if topic.Spec.OperatorSpec.ConfigMaps == nil { + return nil, nil + } + toValidate := []*genruntime.ConfigMapDestination{ + topic.Spec.OperatorSpec.ConfigMaps.Endpoint, + } + return genruntime.ValidateConfigMapDestinations(toValidate) +} + // validateOwnerReference validates the owner field func (topic *Topic) validateOwnerReference() (admission.Warnings, error) { return genruntime.ValidateOwner(topic) @@ -1366,6 +1405,9 @@ func (embedded *PrivateEndpointConnection_STATUS_Topic_SubResourceEmbedded) Assi // Details for configuring operator behavior. Fields in this struct are interpreted by the operator directly rather than being passed to Azure type TopicOperatorSpec struct { + // ConfigMaps: configures where to place operator written ConfigMaps. + ConfigMaps *TopicOperatorConfigMaps `json:"configMaps,omitempty"` + // Secrets: configures where to place Azure generated secrets. Secrets *TopicOperatorSecrets `json:"secrets,omitempty"` } @@ -1373,6 +1415,18 @@ type TopicOperatorSpec struct { // AssignProperties_From_TopicOperatorSpec populates our TopicOperatorSpec from the provided source TopicOperatorSpec func (operator *TopicOperatorSpec) AssignProperties_From_TopicOperatorSpec(source *v20200601s.TopicOperatorSpec) error { + // ConfigMaps + if source.ConfigMaps != nil { + var configMap TopicOperatorConfigMaps + err := configMap.AssignProperties_From_TopicOperatorConfigMaps(source.ConfigMaps) + if err != nil { + return errors.Wrap(err, "calling AssignProperties_From_TopicOperatorConfigMaps() to populate field ConfigMaps") + } + operator.ConfigMaps = &configMap + } else { + operator.ConfigMaps = nil + } + // Secrets if source.Secrets != nil { var secret TopicOperatorSecrets @@ -1394,6 +1448,18 @@ func (operator *TopicOperatorSpec) AssignProperties_To_TopicOperatorSpec(destina // Create a new property bag propertyBag := genruntime.NewPropertyBag() + // ConfigMaps + if operator.ConfigMaps != nil { + var configMap v20200601s.TopicOperatorConfigMaps + err := operator.ConfigMaps.AssignProperties_To_TopicOperatorConfigMaps(&configMap) + if err != nil { + return errors.Wrap(err, "calling AssignProperties_To_TopicOperatorConfigMaps() to populate field ConfigMaps") + } + destination.ConfigMaps = &configMap + } else { + destination.ConfigMaps = nil + } + // Secrets if operator.Secrets != nil { var secret v20200601s.TopicOperatorSecrets @@ -1460,6 +1526,50 @@ const ( TopicProperties_PublicNetworkAccess_STATUS_Enabled = TopicProperties_PublicNetworkAccess_STATUS("Enabled") ) +type TopicOperatorConfigMaps struct { + // Endpoint: indicates where the Endpoint config map should be placed. If omitted, no config map will be created. + Endpoint *genruntime.ConfigMapDestination `json:"endpoint,omitempty"` +} + +// AssignProperties_From_TopicOperatorConfigMaps populates our TopicOperatorConfigMaps from the provided source TopicOperatorConfigMaps +func (maps *TopicOperatorConfigMaps) AssignProperties_From_TopicOperatorConfigMaps(source *v20200601s.TopicOperatorConfigMaps) error { + + // Endpoint + if source.Endpoint != nil { + endpoint := source.Endpoint.Copy() + maps.Endpoint = &endpoint + } else { + maps.Endpoint = nil + } + + // No error + return nil +} + +// AssignProperties_To_TopicOperatorConfigMaps populates the provided destination TopicOperatorConfigMaps from our TopicOperatorConfigMaps +func (maps *TopicOperatorConfigMaps) AssignProperties_To_TopicOperatorConfigMaps(destination *v20200601s.TopicOperatorConfigMaps) error { + // Create a new property bag + propertyBag := genruntime.NewPropertyBag() + + // Endpoint + if maps.Endpoint != nil { + endpoint := maps.Endpoint.Copy() + destination.Endpoint = &endpoint + } else { + destination.Endpoint = nil + } + + // Update the property bag + if len(propertyBag) > 0 { + destination.PropertyBag = propertyBag + } else { + destination.PropertyBag = nil + } + + // No error + return nil +} + type TopicOperatorSecrets struct { // Key1: indicates where the Key1 secret should be placed. If omitted, the secret will not be retrieved from Azure. Key1 *genruntime.SecretDestination `json:"key1,omitempty"` diff --git a/v2/api/eventgrid/v1api20200601/topic_types_gen_test.go b/v2/api/eventgrid/v1api20200601/topic_types_gen_test.go index 0fe100033f8..8a76fc4692e 100644 --- a/v2/api/eventgrid/v1api20200601/topic_types_gen_test.go +++ b/v2/api/eventgrid/v1api20200601/topic_types_gen_test.go @@ -622,9 +622,107 @@ func TopicOperatorSpecGenerator() gopter.Gen { // AddRelatedPropertyGeneratorsForTopicOperatorSpec is a factory method for creating gopter generators func AddRelatedPropertyGeneratorsForTopicOperatorSpec(gens map[string]gopter.Gen) { + gens["ConfigMaps"] = gen.PtrOf(TopicOperatorConfigMapsGenerator()) gens["Secrets"] = gen.PtrOf(TopicOperatorSecretsGenerator()) } +func Test_TopicOperatorConfigMaps_WhenPropertiesConverted_RoundTripsWithoutLoss(t *testing.T) { + t.Parallel() + parameters := gopter.DefaultTestParameters() + parameters.MaxSize = 10 + properties := gopter.NewProperties(parameters) + properties.Property( + "Round trip from TopicOperatorConfigMaps to TopicOperatorConfigMaps via AssignProperties_To_TopicOperatorConfigMaps & AssignProperties_From_TopicOperatorConfigMaps returns original", + prop.ForAll(RunPropertyAssignmentTestForTopicOperatorConfigMaps, TopicOperatorConfigMapsGenerator())) + properties.TestingRun(t, gopter.NewFormatedReporter(false, 240, os.Stdout)) +} + +// RunPropertyAssignmentTestForTopicOperatorConfigMaps tests if a specific instance of TopicOperatorConfigMaps can be assigned to storage and back losslessly +func RunPropertyAssignmentTestForTopicOperatorConfigMaps(subject TopicOperatorConfigMaps) string { + // Copy subject to make sure assignment doesn't modify it + copied := subject.DeepCopy() + + // Use AssignPropertiesTo() for the first stage of conversion + var other v20200601s.TopicOperatorConfigMaps + err := copied.AssignProperties_To_TopicOperatorConfigMaps(&other) + if err != nil { + return err.Error() + } + + // Use AssignPropertiesFrom() to convert back to our original type + var actual TopicOperatorConfigMaps + err = actual.AssignProperties_From_TopicOperatorConfigMaps(&other) + if err != nil { + return err.Error() + } + + // Check for a match + match := cmp.Equal(subject, actual, cmpopts.EquateEmpty()) + if !match { + actualFmt := pretty.Sprint(actual) + subjectFmt := pretty.Sprint(subject) + result := diff.Diff(subjectFmt, actualFmt) + return result + } + + return "" +} + +func Test_TopicOperatorConfigMaps_WhenSerializedToJson_DeserializesAsEqual(t *testing.T) { + t.Parallel() + parameters := gopter.DefaultTestParameters() + parameters.MinSuccessfulTests = 100 + parameters.MaxSize = 3 + properties := gopter.NewProperties(parameters) + properties.Property( + "Round trip of TopicOperatorConfigMaps via JSON returns original", + prop.ForAll(RunJSONSerializationTestForTopicOperatorConfigMaps, TopicOperatorConfigMapsGenerator())) + properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout)) +} + +// RunJSONSerializationTestForTopicOperatorConfigMaps runs a test to see if a specific instance of TopicOperatorConfigMaps round trips to JSON and back losslessly +func RunJSONSerializationTestForTopicOperatorConfigMaps(subject TopicOperatorConfigMaps) string { + // Serialize to JSON + bin, err := json.Marshal(subject) + if err != nil { + return err.Error() + } + + // Deserialize back into memory + var actual TopicOperatorConfigMaps + err = json.Unmarshal(bin, &actual) + if err != nil { + return err.Error() + } + + // Check for outcome + match := cmp.Equal(subject, actual, cmpopts.EquateEmpty()) + if !match { + actualFmt := pretty.Sprint(actual) + subjectFmt := pretty.Sprint(subject) + result := diff.Diff(subjectFmt, actualFmt) + return result + } + + return "" +} + +// Generator of TopicOperatorConfigMaps instances for property testing - lazily instantiated by +// TopicOperatorConfigMapsGenerator() +var topicOperatorConfigMapsGenerator gopter.Gen + +// TopicOperatorConfigMapsGenerator returns a generator of TopicOperatorConfigMaps instances for property testing. +func TopicOperatorConfigMapsGenerator() gopter.Gen { + if topicOperatorConfigMapsGenerator != nil { + return topicOperatorConfigMapsGenerator + } + + generators := make(map[string]gopter.Gen) + topicOperatorConfigMapsGenerator = gen.Struct(reflect.TypeOf(TopicOperatorConfigMaps{}), generators) + + return topicOperatorConfigMapsGenerator +} + func Test_TopicOperatorSecrets_WhenPropertiesConverted_RoundTripsWithoutLoss(t *testing.T) { t.Parallel() parameters := gopter.DefaultTestParameters() diff --git a/v2/api/eventgrid/v1api20200601/zz_generated.deepcopy.go b/v2/api/eventgrid/v1api20200601/zz_generated.deepcopy.go index 92aee832cb8..00bd848528a 100644 --- a/v2/api/eventgrid/v1api20200601/zz_generated.deepcopy.go +++ b/v2/api/eventgrid/v1api20200601/zz_generated.deepcopy.go @@ -4955,6 +4955,26 @@ func (in *TopicList) DeepCopyObject() runtime.Object { return nil } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *TopicOperatorConfigMaps) DeepCopyInto(out *TopicOperatorConfigMaps) { + *out = *in + if in.Endpoint != nil { + in, out := &in.Endpoint, &out.Endpoint + *out = new(genruntime.ConfigMapDestination) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TopicOperatorConfigMaps. +func (in *TopicOperatorConfigMaps) DeepCopy() *TopicOperatorConfigMaps { + if in == nil { + return nil + } + out := new(TopicOperatorConfigMaps) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *TopicOperatorSecrets) DeepCopyInto(out *TopicOperatorSecrets) { *out = *in @@ -4983,6 +5003,11 @@ func (in *TopicOperatorSecrets) DeepCopy() *TopicOperatorSecrets { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *TopicOperatorSpec) DeepCopyInto(out *TopicOperatorSpec) { *out = *in + if in.ConfigMaps != nil { + in, out := &in.ConfigMaps, &out.ConfigMaps + *out = new(TopicOperatorConfigMaps) + (*in).DeepCopyInto(*out) + } if in.Secrets != nil { in, out := &in.Secrets, &out.Secrets *out = new(TopicOperatorSecrets) diff --git a/v2/azure-arm.yaml b/v2/azure-arm.yaml index a383d2d7e7c..534373dd326 100644 --- a/v2/azure-arm.yaml +++ b/v2/azure-arm.yaml @@ -1751,6 +1751,8 @@ objectModelConfiguration: $azureGeneratedSecrets: - Key1 - Key2 + $generatedConfigs: + Endpoint: $.Status.Endpoint eventhub: 2021-11-01: Destination_Properties: diff --git a/v2/internal/controllers/crd_eventgrid_topic_test.go b/v2/internal/controllers/crd_eventgrid_topic_test.go index d1c30851157..df46aab2511 100644 --- a/v2/internal/controllers/crd_eventgrid_topic_test.go +++ b/v2/internal/controllers/crd_eventgrid_topic_test.go @@ -74,15 +74,23 @@ func Test_EventGrid_Topic(t *testing.T) { func Topic_SecretsWrittenToSameKubeSecret(tc *testcommon.KubePerTestContext, topic *eventgrid.Topic) { old := topic.DeepCopy() topicSecret := "topickeys" + topicConfigMap := "topicconfigmap" topic.Spec.OperatorSpec = &eventgrid.TopicOperatorSpec{ Secrets: &eventgrid.TopicOperatorSecrets{ Key1: &genruntime.SecretDestination{Name: topicSecret, Key: "key1"}, Key2: &genruntime.SecretDestination{Name: topicSecret, Key: "key2"}, }, + ConfigMaps: &eventgrid.TopicOperatorConfigMaps{ + Endpoint: &genruntime.ConfigMapDestination{ + Name: topicConfigMap, + Key: "endpoint", + }, + }, } tc.PatchResourceAndWait(old, topic) tc.ExpectSecretHasKeys(topicSecret, "key1", "key2") + tc.ExpectConfigMapHasKeys(topicConfigMap, "endpoint") } func Topic_Subscription_CRUD(tc *testcommon.KubePerTestContext, rg *resources.ResourceGroup, topic *eventgrid.Topic) {