From f64dc47dbc45ee11ad49b855f932920700448044 Mon Sep 17 00:00:00 2001 From: I545514 Date: Fri, 15 Nov 2024 16:28:07 +0100 Subject: [PATCH 1/5] feature: add parameters to subscription --- apis/account/v1alpha1/subscription_types.go | 3 + .../account/v1alpha1/zz_generated.deepcopy.go | 8 +- .../v1alpha1/zz_generated.resolvers.go | 1 + .../account/v1beta1/zz_generated.resolvers.go | 1 + .../v1alpha1/zz_generated.resolvers.go | 1 + .../v1alpha1/zz_generated.resolvers.go | 1 + internal/clients/subscription/subscription.go | 16 +- .../subaccountservicebinding/zz_controller.go | 83 +++ .../zz_controller.go | 83 +++ internal/controller/zz_setup.go | 4 + ...ossplane.io_subaccountservicebindings.yaml | 457 +++++++++++++++++ ...ssplane.io_subaccountserviceinstances.yaml | 474 ++++++++++++++++++ ...t.btp.sap.crossplane.io_subscriptions.yaml | 3 +- 13 files changed, 1132 insertions(+), 3 deletions(-) create mode 100755 internal/controller/account/subaccountservicebinding/zz_controller.go create mode 100755 internal/controller/account/subaccountserviceinstance/zz_controller.go create mode 100644 package/crds/account.btp.sap.crossplane.io_subaccountservicebindings.yaml create mode 100644 package/crds/account.btp.sap.crossplane.io_subaccountserviceinstances.yaml diff --git a/apis/account/v1alpha1/subscription_types.go b/apis/account/v1alpha1/subscription_types.go index 60e788f..a8fae01 100644 --- a/apis/account/v1alpha1/subscription_types.go +++ b/apis/account/v1alpha1/subscription_types.go @@ -1,6 +1,7 @@ package v1alpha1 import ( + "encoding/json" "reflect" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -27,6 +28,8 @@ type SubscriptionParameters struct { // PlanName to subscribe to // +kubebuilder:validation:XValidation:rule="self == oldSelf",message="planName can't be updated once set" PlanName string `json:"planName"` + // Subscription parameters allows you to add additional parameters + SubscriptionParameters json.RawMessage `json:",subscriptionParameters"` } // SubscriptionObservation are the observable fields of a Subscription. diff --git a/apis/account/v1alpha1/zz_generated.deepcopy.go b/apis/account/v1alpha1/zz_generated.deepcopy.go index ff68d32..e66ffb2 100644 --- a/apis/account/v1alpha1/zz_generated.deepcopy.go +++ b/apis/account/v1alpha1/zz_generated.deepcopy.go @@ -21,6 +21,7 @@ limitations under the License. package v1alpha1 import ( + "encoding/json" "github.com/crossplane/crossplane-runtime/apis/common/v1" runtime "k8s.io/apimachinery/pkg/runtime" ) @@ -2379,6 +2380,11 @@ func (in *SubscriptionObservation) DeepCopy() *SubscriptionObservation { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *SubscriptionParameters) DeepCopyInto(out *SubscriptionParameters) { *out = *in + if in.SubscriptionParameters != nil { + in, out := &in.SubscriptionParameters, &out.SubscriptionParameters + *out = make(json.RawMessage, len(*in)) + copy(*out, *in) + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SubscriptionParameters. @@ -2395,7 +2401,7 @@ func (in *SubscriptionParameters) DeepCopy() *SubscriptionParameters { func (in *SubscriptionSpec) DeepCopyInto(out *SubscriptionSpec) { *out = *in in.ResourceSpec.DeepCopyInto(&out.ResourceSpec) - out.ForProvider = in.ForProvider + in.ForProvider.DeepCopyInto(&out.ForProvider) if in.CloudManagementSelector != nil { in, out := &in.CloudManagementSelector, &out.CloudManagementSelector *out = new(v1.Selector) diff --git a/apis/account/v1alpha1/zz_generated.resolvers.go b/apis/account/v1alpha1/zz_generated.resolvers.go index a7ea779..6f500d5 100644 --- a/apis/account/v1alpha1/zz_generated.resolvers.go +++ b/apis/account/v1alpha1/zz_generated.resolvers.go @@ -20,6 +20,7 @@ package v1alpha1 import ( "context" + reference "github.com/crossplane/crossplane-runtime/pkg/reference" errors "github.com/pkg/errors" client "sigs.k8s.io/controller-runtime/pkg/client" diff --git a/apis/account/v1beta1/zz_generated.resolvers.go b/apis/account/v1beta1/zz_generated.resolvers.go index 66a39de..2d601c4 100644 --- a/apis/account/v1beta1/zz_generated.resolvers.go +++ b/apis/account/v1beta1/zz_generated.resolvers.go @@ -20,6 +20,7 @@ package v1beta1 import ( "context" + reference "github.com/crossplane/crossplane-runtime/pkg/reference" errors "github.com/pkg/errors" v1alpha1 "github.com/sap/crossplane-provider-btp/apis/account/v1alpha1" diff --git a/apis/environment/v1alpha1/zz_generated.resolvers.go b/apis/environment/v1alpha1/zz_generated.resolvers.go index f459d4a..f61c42f 100644 --- a/apis/environment/v1alpha1/zz_generated.resolvers.go +++ b/apis/environment/v1alpha1/zz_generated.resolvers.go @@ -20,6 +20,7 @@ package v1alpha1 import ( "context" + reference "github.com/crossplane/crossplane-runtime/pkg/reference" errors "github.com/pkg/errors" v1alpha1 "github.com/sap/crossplane-provider-btp/apis/account/v1alpha1" diff --git a/apis/security/v1alpha1/zz_generated.resolvers.go b/apis/security/v1alpha1/zz_generated.resolvers.go index 0cd5c78..4390788 100644 --- a/apis/security/v1alpha1/zz_generated.resolvers.go +++ b/apis/security/v1alpha1/zz_generated.resolvers.go @@ -20,6 +20,7 @@ package v1alpha1 import ( "context" + reference "github.com/crossplane/crossplane-runtime/pkg/reference" errors "github.com/pkg/errors" v1alpha1 "github.com/sap/crossplane-provider-btp/apis/account/v1alpha1" diff --git a/internal/clients/subscription/subscription.go b/internal/clients/subscription/subscription.go index 8dc2a75..59930e3 100644 --- a/internal/clients/subscription/subscription.go +++ b/internal/clients/subscription/subscription.go @@ -2,6 +2,7 @@ package subscription import ( "context" + "encoding/json" "fmt" "strings" @@ -156,11 +157,24 @@ func (s *SubscriptionTypeMapper) ConvertToCreatePayload(cr *v1alpha1.Subscriptio return SubscriptionPost{ appName: cr.Spec.ForProvider.AppName, CreateSubscriptionRequestPayload: saas_client.CreateSubscriptionRequestPayload{ - PlanName: &cr.Spec.ForProvider.PlanName, + PlanName: &cr.Spec.ForProvider.PlanName, + SubscriptionParams: s.ConvertToClientParams(cr), }, } } +func (s *SubscriptionTypeMapper) ConvertToClientParams(cr *v1alpha1.Subscription) map[string]map[string]interface{} { + type subparams map[string]map[string]interface{} + var sp subparams + + err := json.Unmarshal(cr.Spec.ForProvider.SubscriptionParameters, &sp) + if err != nil { + return nil + } + + return sp +} + func (s *SubscriptionTypeMapper) ConvertToUpdatePayload(cr *v1alpha1.Subscription) SubscriptionPut { panic("currently not supported") } diff --git a/internal/controller/account/subaccountservicebinding/zz_controller.go b/internal/controller/account/subaccountservicebinding/zz_controller.go new file mode 100755 index 0000000..5139963 --- /dev/null +++ b/internal/controller/account/subaccountservicebinding/zz_controller.go @@ -0,0 +1,83 @@ +/* +Copyright 2022 The Crossplane Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by upjet. DO NOT EDIT. + +package subaccountservicebinding + +import ( + "time" + + "github.com/crossplane/crossplane-runtime/pkg/connection" + "github.com/crossplane/crossplane-runtime/pkg/event" + "github.com/crossplane/crossplane-runtime/pkg/ratelimiter" + "github.com/crossplane/crossplane-runtime/pkg/reconciler/managed" + xpresource "github.com/crossplane/crossplane-runtime/pkg/resource" + tjcontroller "github.com/crossplane/upjet/pkg/controller" + "github.com/crossplane/upjet/pkg/controller/handler" + "github.com/crossplane/upjet/pkg/terraform" + "github.com/pkg/errors" + ctrl "sigs.k8s.io/controller-runtime" + + v1alpha1 "github.com/sap/crossplane-provider-btp/apis/account/v1alpha1" + features "github.com/sap/crossplane-provider-btp/internal/features" +) + +// Setup adds a controller that reconciles SubaccountServiceBinding managed resources. +func Setup(mgr ctrl.Manager, o tjcontroller.Options) error { + name := managed.ControllerName(v1alpha1.SubaccountServiceBinding_GroupVersionKind.String()) + var initializers managed.InitializerChain + cps := []managed.ConnectionPublisher{managed.NewAPISecretPublisher(mgr.GetClient(), mgr.GetScheme())} + if o.SecretStoreConfigGVK != nil { + cps = append(cps, connection.NewDetailsManager(mgr.GetClient(), *o.SecretStoreConfigGVK, connection.WithTLSConfig(o.ESSOptions.TLSConfig))) + } + eventHandler := handler.NewEventHandler(handler.WithLogger(o.Logger.WithValues("gvk", v1alpha1.SubaccountServiceBinding_GroupVersionKind))) + opts := []managed.ReconcilerOption{ + managed.WithExternalConnecter(tjcontroller.NewConnector(mgr.GetClient(), o.WorkspaceStore, o.SetupFn, o.Provider.Resources["btp_subaccount_service_binding"], tjcontroller.WithLogger(o.Logger), tjcontroller.WithConnectorEventHandler(eventHandler))), + managed.WithLogger(o.Logger.WithValues("controller", name)), + managed.WithRecorder(event.NewAPIRecorder(mgr.GetEventRecorderFor(name))), + managed.WithFinalizer(terraform.NewWorkspaceFinalizer(o.WorkspaceStore, xpresource.NewAPIFinalizer(mgr.GetClient(), managed.FinalizerName))), + managed.WithTimeout(3 * time.Minute), + managed.WithInitializers(initializers), + managed.WithConnectionPublishers(cps...), + managed.WithPollInterval(o.PollInterval), + } + if o.PollJitter != 0 { + opts = append(opts, managed.WithPollJitterHook(o.PollJitter)) + } + if o.Features.Enabled(features.EnableBetaManagementPolicies) { + opts = append(opts, managed.WithManagementPolicies()) + } + + // register webhooks for the kind v1alpha1.SubaccountServiceBinding + // if they're enabled. + if o.StartWebhooks { + if err := ctrl.NewWebhookManagedBy(mgr). + For(&v1alpha1.SubaccountServiceBinding{}). + Complete(); err != nil { + return errors.Wrap(err, "cannot register webhook for the kind v1alpha1.SubaccountServiceBinding") + } + } + + r := managed.NewReconciler(mgr, xpresource.ManagedKind(v1alpha1.SubaccountServiceBinding_GroupVersionKind), opts...) + + return ctrl.NewControllerManagedBy(mgr). + Named(name). + WithOptions(o.ForControllerRuntime()). + WithEventFilter(xpresource.DesiredStateChanged()). + Watches(&v1alpha1.SubaccountServiceBinding{}, eventHandler). + Complete(ratelimiter.NewReconciler(name, r, o.GlobalRateLimiter)) +} diff --git a/internal/controller/account/subaccountserviceinstance/zz_controller.go b/internal/controller/account/subaccountserviceinstance/zz_controller.go new file mode 100755 index 0000000..8fe15ef --- /dev/null +++ b/internal/controller/account/subaccountserviceinstance/zz_controller.go @@ -0,0 +1,83 @@ +/* +Copyright 2022 The Crossplane Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by upjet. DO NOT EDIT. + +package subaccountserviceinstance + +import ( + "time" + + "github.com/crossplane/crossplane-runtime/pkg/connection" + "github.com/crossplane/crossplane-runtime/pkg/event" + "github.com/crossplane/crossplane-runtime/pkg/ratelimiter" + "github.com/crossplane/crossplane-runtime/pkg/reconciler/managed" + xpresource "github.com/crossplane/crossplane-runtime/pkg/resource" + tjcontroller "github.com/crossplane/upjet/pkg/controller" + "github.com/crossplane/upjet/pkg/controller/handler" + "github.com/crossplane/upjet/pkg/terraform" + "github.com/pkg/errors" + ctrl "sigs.k8s.io/controller-runtime" + + v1alpha1 "github.com/sap/crossplane-provider-btp/apis/account/v1alpha1" + features "github.com/sap/crossplane-provider-btp/internal/features" +) + +// Setup adds a controller that reconciles SubaccountServiceInstance managed resources. +func Setup(mgr ctrl.Manager, o tjcontroller.Options) error { + name := managed.ControllerName(v1alpha1.SubaccountServiceInstance_GroupVersionKind.String()) + var initializers managed.InitializerChain + cps := []managed.ConnectionPublisher{managed.NewAPISecretPublisher(mgr.GetClient(), mgr.GetScheme())} + if o.SecretStoreConfigGVK != nil { + cps = append(cps, connection.NewDetailsManager(mgr.GetClient(), *o.SecretStoreConfigGVK, connection.WithTLSConfig(o.ESSOptions.TLSConfig))) + } + eventHandler := handler.NewEventHandler(handler.WithLogger(o.Logger.WithValues("gvk", v1alpha1.SubaccountServiceInstance_GroupVersionKind))) + opts := []managed.ReconcilerOption{ + managed.WithExternalConnecter(tjcontroller.NewConnector(mgr.GetClient(), o.WorkspaceStore, o.SetupFn, o.Provider.Resources["btp_subaccount_service_instance"], tjcontroller.WithLogger(o.Logger), tjcontroller.WithConnectorEventHandler(eventHandler))), + managed.WithLogger(o.Logger.WithValues("controller", name)), + managed.WithRecorder(event.NewAPIRecorder(mgr.GetEventRecorderFor(name))), + managed.WithFinalizer(terraform.NewWorkspaceFinalizer(o.WorkspaceStore, xpresource.NewAPIFinalizer(mgr.GetClient(), managed.FinalizerName))), + managed.WithTimeout(3 * time.Minute), + managed.WithInitializers(initializers), + managed.WithConnectionPublishers(cps...), + managed.WithPollInterval(o.PollInterval), + } + if o.PollJitter != 0 { + opts = append(opts, managed.WithPollJitterHook(o.PollJitter)) + } + if o.Features.Enabled(features.EnableBetaManagementPolicies) { + opts = append(opts, managed.WithManagementPolicies()) + } + + // register webhooks for the kind v1alpha1.SubaccountServiceInstance + // if they're enabled. + if o.StartWebhooks { + if err := ctrl.NewWebhookManagedBy(mgr). + For(&v1alpha1.SubaccountServiceInstance{}). + Complete(); err != nil { + return errors.Wrap(err, "cannot register webhook for the kind v1alpha1.SubaccountServiceInstance") + } + } + + r := managed.NewReconciler(mgr, xpresource.ManagedKind(v1alpha1.SubaccountServiceInstance_GroupVersionKind), opts...) + + return ctrl.NewControllerManagedBy(mgr). + Named(name). + WithOptions(o.ForControllerRuntime()). + WithEventFilter(xpresource.DesiredStateChanged()). + Watches(&v1alpha1.SubaccountServiceInstance{}, eventHandler). + Complete(ratelimiter.NewReconciler(name, r, o.GlobalRateLimiter)) +} diff --git a/internal/controller/zz_setup.go b/internal/controller/zz_setup.go index 05ddd3c..17eb718 100644 --- a/internal/controller/zz_setup.go +++ b/internal/controller/zz_setup.go @@ -22,6 +22,8 @@ import ( "github.com/crossplane/upjet/pkg/controller" directoryentitlement "github.com/sap/crossplane-provider-btp/internal/controller/account/directoryentitlement" + subaccountservicebinding "github.com/sap/crossplane-provider-btp/internal/controller/account/subaccountservicebinding" + subaccountserviceinstance "github.com/sap/crossplane-provider-btp/internal/controller/account/subaccountserviceinstance" providerconfig "github.com/sap/crossplane-provider-btp/internal/controller/providerconfig" globalaccounttrustconfiguration "github.com/sap/crossplane-provider-btp/internal/controller/security/globalaccounttrustconfiguration" subaccounttrustconfiguration "github.com/sap/crossplane-provider-btp/internal/controller/security/subaccounttrustconfiguration" @@ -32,6 +34,8 @@ import ( func Setup(mgr ctrl.Manager, o controller.Options) error { for _, setup := range []func(ctrl.Manager, controller.Options) error{ directoryentitlement.Setup, + subaccountservicebinding.Setup, + subaccountserviceinstance.Setup, providerconfig.Setup, globalaccounttrustconfiguration.Setup, subaccounttrustconfiguration.Setup, diff --git a/package/crds/account.btp.sap.crossplane.io_subaccountservicebindings.yaml b/package/crds/account.btp.sap.crossplane.io_subaccountservicebindings.yaml new file mode 100644 index 0000000..8c46d4c --- /dev/null +++ b/package/crds/account.btp.sap.crossplane.io_subaccountservicebindings.yaml @@ -0,0 +1,457 @@ +--- +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + annotations: + controller-gen.kubebuilder.io/version: v0.14.0 + name: subaccountservicebindings.account.btp.sap.crossplane.io +spec: + group: account.btp.sap.crossplane.io + names: + categories: + - crossplane + - managed + - account + kind: SubaccountServiceBinding + listKind: SubaccountServiceBindingList + plural: subaccountservicebindings + singular: subaccountservicebinding + scope: Cluster + versions: + - additionalPrinterColumns: + - jsonPath: .status.conditions[?(@.type=='Ready')].status + name: READY + type: string + - jsonPath: .status.conditions[?(@.type=='Synced')].status + name: SYNCED + type: string + - jsonPath: .metadata.annotations.crossplane\.io/external-name + name: EXTERNAL-NAME + type: string + - jsonPath: .metadata.creationTimestamp + name: AGE + type: date + name: v1alpha1 + schema: + openAPIV3Schema: + description: 'SubaccountServiceBinding is the Schema for the SubaccountServiceBindings + API. Creates a service binding, i.e. generates access details to consume + a service. Tip: You must be assigned to the admin or the service administrator + role of the subaccount.' + properties: + apiVersion: + description: |- + APIVersion defines the versioned schema of this representation of an object. + Servers should convert recognized schemas to the latest internal value, and + may reject unrecognized values. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources + type: string + kind: + description: |- + Kind is a string value representing the REST resource this object represents. + Servers may infer this from the endpoint the client submits requests to. + Cannot be updated. + In CamelCase. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds + type: string + metadata: + type: object + spec: + description: SubaccountServiceBindingSpec defines the desired state of + SubaccountServiceBinding + properties: + deletionPolicy: + default: Delete + description: |- + DeletionPolicy specifies what will happen to the underlying external + when this managed resource is deleted - either "Delete" or "Orphan" the + external resource. + This field is planned to be deprecated in favor of the ManagementPolicies + field in a future release. Currently, both could be set independently and + non-default values would be honored if the feature flag is enabled. + See the design doc for more information: https://github.com/crossplane/crossplane/blob/499895a25d1a1a0ba1604944ef98ac7a1a71f197/design/design-doc-observe-only-resources.md?plain=1#L223 + enum: + - Orphan + - Delete + type: string + forProvider: + properties: + labels: + additionalProperties: + items: + type: string + type: array + description: |- + (Map of Set of String) The set of words or phrases assigned to the service binding. + The set of words or phrases assigned to the service binding. + type: object + name: + description: |- + (String) The name of the service binding. + The name of the service binding. + type: string + parameters: + description: |- + (String) The parameters of the service binding as a valid JSON object. + The parameters of the service binding as a valid JSON object. + type: string + serviceInstanceId: + description: |- + (String) The ID of the service instance associated with the binding. + The ID of the service instance associated with the binding. + type: string + subaccountId: + description: |- + (String) The ID of the subaccount. + The ID of the subaccount. + type: string + type: object + initProvider: + description: |- + THIS IS A BETA FIELD. It will be honored + unless the Management Policies feature flag is disabled. + InitProvider holds the same fields as ForProvider, with the exception + of Identifier and other resource reference fields. The fields that are + in InitProvider are merged into ForProvider when the resource is created. + The same fields are also added to the terraform ignore_changes hook, to + avoid updating them after creation. This is useful for fields that are + required on creation, but we do not desire to update them after creation, + for example because of an external controller is managing them, like an + autoscaler. + properties: + labels: + additionalProperties: + items: + type: string + type: array + description: |- + (Map of Set of String) The set of words or phrases assigned to the service binding. + The set of words or phrases assigned to the service binding. + type: object + name: + description: |- + (String) The name of the service binding. + The name of the service binding. + type: string + parameters: + description: |- + (String) The parameters of the service binding as a valid JSON object. + The parameters of the service binding as a valid JSON object. + type: string + serviceInstanceId: + description: |- + (String) The ID of the service instance associated with the binding. + The ID of the service instance associated with the binding. + type: string + subaccountId: + description: |- + (String) The ID of the subaccount. + The ID of the subaccount. + type: string + type: object + managementPolicies: + default: + - '*' + description: |- + THIS IS A BETA FIELD. It is on by default but can be opted out + through a Crossplane feature flag. + ManagementPolicies specify the array of actions Crossplane is allowed to + take on the managed and external resources. + This field is planned to replace the DeletionPolicy field in a future + release. Currently, both could be set independently and non-default + values would be honored if the feature flag is enabled. If both are + custom, the DeletionPolicy field will be ignored. + See the design doc for more information: https://github.com/crossplane/crossplane/blob/499895a25d1a1a0ba1604944ef98ac7a1a71f197/design/design-doc-observe-only-resources.md?plain=1#L223 + and this one: https://github.com/crossplane/crossplane/blob/444267e84783136daa93568b364a5f01228cacbe/design/one-pager-ignore-changes.md + items: + description: |- + A ManagementAction represents an action that the Crossplane controllers + can take on an external resource. + enum: + - Observe + - Create + - Update + - Delete + - LateInitialize + - '*' + type: string + type: array + providerConfigRef: + default: + name: default + description: |- + ProviderConfigReference specifies how the provider that will be used to + create, observe, update, and delete this managed resource should be + configured. + properties: + name: + description: Name of the referenced object. + type: string + policy: + description: Policies for referencing. + properties: + resolution: + default: Required + description: |- + Resolution specifies whether resolution of this reference is required. + The default is 'Required', which means the reconcile will fail if the + reference cannot be resolved. 'Optional' means this reference will be + a no-op if it cannot be resolved. + enum: + - Required + - Optional + type: string + resolve: + description: |- + Resolve specifies when this reference should be resolved. The default + is 'IfNotPresent', which will attempt to resolve the reference only when + the corresponding field is not present. Use 'Always' to resolve the + reference on every reconcile. + enum: + - Always + - IfNotPresent + type: string + type: object + required: + - name + type: object + publishConnectionDetailsTo: + description: |- + PublishConnectionDetailsTo specifies the connection secret config which + contains a name, metadata and a reference to secret store config to + which any connection details for this managed resource should be written. + Connection details frequently include the endpoint, username, + and password required to connect to the managed resource. + properties: + configRef: + default: + name: default + description: |- + SecretStoreConfigRef specifies which secret store config should be used + for this ConnectionSecret. + properties: + name: + description: Name of the referenced object. + type: string + policy: + description: Policies for referencing. + properties: + resolution: + default: Required + description: |- + Resolution specifies whether resolution of this reference is required. + The default is 'Required', which means the reconcile will fail if the + reference cannot be resolved. 'Optional' means this reference will be + a no-op if it cannot be resolved. + enum: + - Required + - Optional + type: string + resolve: + description: |- + Resolve specifies when this reference should be resolved. The default + is 'IfNotPresent', which will attempt to resolve the reference only when + the corresponding field is not present. Use 'Always' to resolve the + reference on every reconcile. + enum: + - Always + - IfNotPresent + type: string + type: object + required: + - name + type: object + metadata: + description: Metadata is the metadata for connection secret. + properties: + annotations: + additionalProperties: + type: string + description: |- + Annotations are the annotations to be added to connection secret. + - For Kubernetes secrets, this will be used as "metadata.annotations". + - It is up to Secret Store implementation for others store types. + type: object + labels: + additionalProperties: + type: string + description: |- + Labels are the labels/tags to be added to connection secret. + - For Kubernetes secrets, this will be used as "metadata.labels". + - It is up to Secret Store implementation for others store types. + type: object + type: + description: |- + Type is the SecretType for the connection secret. + - Only valid for Kubernetes Secret Stores. + type: string + type: object + name: + description: Name is the name of the connection secret. + type: string + required: + - name + type: object + writeConnectionSecretToRef: + description: |- + WriteConnectionSecretToReference specifies the namespace and name of a + Secret to which any connection details for this managed resource should + be written. Connection details frequently include the endpoint, username, + and password required to connect to the managed resource. + This field is planned to be replaced in a future release in favor of + PublishConnectionDetailsTo. Currently, both could be set independently + and connection details would be published to both without affecting + each other. + properties: + name: + description: Name of the secret. + type: string + namespace: + description: Namespace of the secret. + type: string + required: + - name + - namespace + type: object + required: + - forProvider + type: object + x-kubernetes-validations: + - message: spec.forProvider.name is a required parameter + rule: '!(''*'' in self.managementPolicies || ''Create'' in self.managementPolicies + || ''Update'' in self.managementPolicies) || has(self.forProvider.name) + || (has(self.initProvider) && has(self.initProvider.name))' + - message: spec.forProvider.serviceInstanceId is a required parameter + rule: '!(''*'' in self.managementPolicies || ''Create'' in self.managementPolicies + || ''Update'' in self.managementPolicies) || has(self.forProvider.serviceInstanceId) + || (has(self.initProvider) && has(self.initProvider.serviceInstanceId))' + - message: spec.forProvider.subaccountId is a required parameter + rule: '!(''*'' in self.managementPolicies || ''Create'' in self.managementPolicies + || ''Update'' in self.managementPolicies) || has(self.forProvider.subaccountId) + || (has(self.initProvider) && has(self.initProvider.subaccountId))' + status: + description: SubaccountServiceBindingStatus defines the observed state + of SubaccountServiceBinding. + properties: + atProvider: + properties: + bindResource: + additionalProperties: + type: string + description: |- + (Map of String) Contains the resources associated with the binding. + Contains the resources associated with the binding. + type: object + x-kubernetes-map-type: granular + context: + description: |- + (String) The contextual data for the resource. + The contextual data for the resource. + type: string + createdDate: + description: |- + (String) The date and time when the resource was created in RFC3339 format. + The date and time when the resource was created in [RFC3339](https://www.ietf.org/rfc/rfc3339.txt) format. + type: string + id: + description: (String) The ID of the service binding. + type: string + labels: + additionalProperties: + items: + type: string + type: array + description: |- + (Map of Set of String) The set of words or phrases assigned to the service binding. + The set of words or phrases assigned to the service binding. + type: object + lastModified: + description: |- + (String) The date and time when the resource was last modified in RFC3339 format. + The date and time when the resource was last modified in [RFC3339](https://www.ietf.org/rfc/rfc3339.txt) format. + type: string + name: + description: |- + (String) The name of the service binding. + The name of the service binding. + type: string + parameters: + description: |- + (String) The parameters of the service binding as a valid JSON object. + The parameters of the service binding as a valid JSON object. + type: string + ready: + description: |- + (Boolean) Shows whether the service binding is ready. + Shows whether the service binding is ready. + type: boolean + serviceInstanceId: + description: |- + (String) The ID of the service instance associated with the binding. + The ID of the service instance associated with the binding. + type: string + state: + description: |- + (String) The current state of the service binding. Possible values are: + The current state of the service binding. Possible values are: + + + | state | description | + | --- | --- | + | `in progress` | The operation or processing is in progress | + | `failed` | The operation or processing failed | + | `succeeded` | The operation or processing succeeded | + type: string + subaccountId: + description: |- + (String) The ID of the subaccount. + The ID of the subaccount. + type: string + type: object + conditions: + description: Conditions of the resource. + items: + description: A Condition that may apply to a resource. + properties: + lastTransitionTime: + description: |- + LastTransitionTime is the last time this condition transitioned from one + status to another. + format: date-time + type: string + message: + description: |- + A Message containing details about this condition's last transition from + one status to another, if any. + type: string + reason: + description: A Reason for this condition's last transition from + one status to another. + type: string + status: + description: Status of this condition; is it currently True, + False, or Unknown? + type: string + type: + description: |- + Type of this condition. At most one of each condition type may apply to + a resource at any point in time. + type: string + required: + - lastTransitionTime + - reason + - status + - type + type: object + type: array + x-kubernetes-list-map-keys: + - type + x-kubernetes-list-type: map + type: object + required: + - spec + type: object + served: true + storage: true + subresources: + status: {} diff --git a/package/crds/account.btp.sap.crossplane.io_subaccountserviceinstances.yaml b/package/crds/account.btp.sap.crossplane.io_subaccountserviceinstances.yaml new file mode 100644 index 0000000..0ccd403 --- /dev/null +++ b/package/crds/account.btp.sap.crossplane.io_subaccountserviceinstances.yaml @@ -0,0 +1,474 @@ +--- +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + annotations: + controller-gen.kubebuilder.io/version: v0.14.0 + name: subaccountserviceinstances.account.btp.sap.crossplane.io +spec: + group: account.btp.sap.crossplane.io + names: + categories: + - crossplane + - managed + - account + kind: SubaccountServiceInstance + listKind: SubaccountServiceInstanceList + plural: subaccountserviceinstances + singular: subaccountserviceinstance + scope: Cluster + versions: + - additionalPrinterColumns: + - jsonPath: .status.conditions[?(@.type=='Ready')].status + name: READY + type: string + - jsonPath: .status.conditions[?(@.type=='Synced')].status + name: SYNCED + type: string + - jsonPath: .metadata.annotations.crossplane\.io/external-name + name: EXTERNAL-NAME + type: string + - jsonPath: .metadata.creationTimestamp + name: AGE + type: date + name: v1alpha1 + schema: + openAPIV3Schema: + description: 'SubaccountServiceInstance is the Schema for the SubaccountServiceInstances + API. Creates a service instance in a subaccount. Tip: You must be assigned + to the admin or the service administrator role of the subaccount.' + properties: + apiVersion: + description: |- + APIVersion defines the versioned schema of this representation of an object. + Servers should convert recognized schemas to the latest internal value, and + may reject unrecognized values. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources + type: string + kind: + description: |- + Kind is a string value representing the REST resource this object represents. + Servers may infer this from the endpoint the client submits requests to. + Cannot be updated. + In CamelCase. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds + type: string + metadata: + type: object + spec: + description: SubaccountServiceInstanceSpec defines the desired state of + SubaccountServiceInstance + properties: + deletionPolicy: + default: Delete + description: |- + DeletionPolicy specifies what will happen to the underlying external + when this managed resource is deleted - either "Delete" or "Orphan" the + external resource. + This field is planned to be deprecated in favor of the ManagementPolicies + field in a future release. Currently, both could be set independently and + non-default values would be honored if the feature flag is enabled. + See the design doc for more information: https://github.com/crossplane/crossplane/blob/499895a25d1a1a0ba1604944ef98ac7a1a71f197/design/design-doc-observe-only-resources.md?plain=1#L223 + enum: + - Orphan + - Delete + type: string + forProvider: + properties: + labels: + additionalProperties: + items: + type: string + type: array + description: |- + (Map of Set of String) The set of words or phrases assigned to the service instance. + The set of words or phrases assigned to the service instance. + type: object + name: + description: |- + (String) The name of the service instance. + The name of the service instance. + type: string + parameters: + description: |- + (String, Sensitive) The configuration parameters for the service instance. + The configuration parameters for the service instance. + type: string + serviceplanId: + description: |- + (String) The ID of the service plan. + The ID of the service plan. + type: string + shared: + description: |- + (Boolean) The configuration parameter for service instance sharing. Ensure that the instance is created with a plan that supports instance sharing. + The configuration parameter for service instance sharing. Ensure that the instance is created with a plan that supports instance sharing. + type: boolean + subaccountId: + description: |- + (String) The ID of the subaccount. + The ID of the subaccount. + type: string + type: object + initProvider: + description: |- + THIS IS A BETA FIELD. It will be honored + unless the Management Policies feature flag is disabled. + InitProvider holds the same fields as ForProvider, with the exception + of Identifier and other resource reference fields. The fields that are + in InitProvider are merged into ForProvider when the resource is created. + The same fields are also added to the terraform ignore_changes hook, to + avoid updating them after creation. This is useful for fields that are + required on creation, but we do not desire to update them after creation, + for example because of an external controller is managing them, like an + autoscaler. + properties: + labels: + additionalProperties: + items: + type: string + type: array + description: |- + (Map of Set of String) The set of words or phrases assigned to the service instance. + The set of words or phrases assigned to the service instance. + type: object + name: + description: |- + (String) The name of the service instance. + The name of the service instance. + type: string + parameters: + description: |- + (String, Sensitive) The configuration parameters for the service instance. + The configuration parameters for the service instance. + type: string + serviceplanId: + description: |- + (String) The ID of the service plan. + The ID of the service plan. + type: string + shared: + description: |- + (Boolean) The configuration parameter for service instance sharing. Ensure that the instance is created with a plan that supports instance sharing. + The configuration parameter for service instance sharing. Ensure that the instance is created with a plan that supports instance sharing. + type: boolean + subaccountId: + description: |- + (String) The ID of the subaccount. + The ID of the subaccount. + type: string + type: object + managementPolicies: + default: + - '*' + description: |- + THIS IS A BETA FIELD. It is on by default but can be opted out + through a Crossplane feature flag. + ManagementPolicies specify the array of actions Crossplane is allowed to + take on the managed and external resources. + This field is planned to replace the DeletionPolicy field in a future + release. Currently, both could be set independently and non-default + values would be honored if the feature flag is enabled. If both are + custom, the DeletionPolicy field will be ignored. + See the design doc for more information: https://github.com/crossplane/crossplane/blob/499895a25d1a1a0ba1604944ef98ac7a1a71f197/design/design-doc-observe-only-resources.md?plain=1#L223 + and this one: https://github.com/crossplane/crossplane/blob/444267e84783136daa93568b364a5f01228cacbe/design/one-pager-ignore-changes.md + items: + description: |- + A ManagementAction represents an action that the Crossplane controllers + can take on an external resource. + enum: + - Observe + - Create + - Update + - Delete + - LateInitialize + - '*' + type: string + type: array + providerConfigRef: + default: + name: default + description: |- + ProviderConfigReference specifies how the provider that will be used to + create, observe, update, and delete this managed resource should be + configured. + properties: + name: + description: Name of the referenced object. + type: string + policy: + description: Policies for referencing. + properties: + resolution: + default: Required + description: |- + Resolution specifies whether resolution of this reference is required. + The default is 'Required', which means the reconcile will fail if the + reference cannot be resolved. 'Optional' means this reference will be + a no-op if it cannot be resolved. + enum: + - Required + - Optional + type: string + resolve: + description: |- + Resolve specifies when this reference should be resolved. The default + is 'IfNotPresent', which will attempt to resolve the reference only when + the corresponding field is not present. Use 'Always' to resolve the + reference on every reconcile. + enum: + - Always + - IfNotPresent + type: string + type: object + required: + - name + type: object + publishConnectionDetailsTo: + description: |- + PublishConnectionDetailsTo specifies the connection secret config which + contains a name, metadata and a reference to secret store config to + which any connection details for this managed resource should be written. + Connection details frequently include the endpoint, username, + and password required to connect to the managed resource. + properties: + configRef: + default: + name: default + description: |- + SecretStoreConfigRef specifies which secret store config should be used + for this ConnectionSecret. + properties: + name: + description: Name of the referenced object. + type: string + policy: + description: Policies for referencing. + properties: + resolution: + default: Required + description: |- + Resolution specifies whether resolution of this reference is required. + The default is 'Required', which means the reconcile will fail if the + reference cannot be resolved. 'Optional' means this reference will be + a no-op if it cannot be resolved. + enum: + - Required + - Optional + type: string + resolve: + description: |- + Resolve specifies when this reference should be resolved. The default + is 'IfNotPresent', which will attempt to resolve the reference only when + the corresponding field is not present. Use 'Always' to resolve the + reference on every reconcile. + enum: + - Always + - IfNotPresent + type: string + type: object + required: + - name + type: object + metadata: + description: Metadata is the metadata for connection secret. + properties: + annotations: + additionalProperties: + type: string + description: |- + Annotations are the annotations to be added to connection secret. + - For Kubernetes secrets, this will be used as "metadata.annotations". + - It is up to Secret Store implementation for others store types. + type: object + labels: + additionalProperties: + type: string + description: |- + Labels are the labels/tags to be added to connection secret. + - For Kubernetes secrets, this will be used as "metadata.labels". + - It is up to Secret Store implementation for others store types. + type: object + type: + description: |- + Type is the SecretType for the connection secret. + - Only valid for Kubernetes Secret Stores. + type: string + type: object + name: + description: Name is the name of the connection secret. + type: string + required: + - name + type: object + writeConnectionSecretToRef: + description: |- + WriteConnectionSecretToReference specifies the namespace and name of a + Secret to which any connection details for this managed resource should + be written. Connection details frequently include the endpoint, username, + and password required to connect to the managed resource. + This field is planned to be replaced in a future release in favor of + PublishConnectionDetailsTo. Currently, both could be set independently + and connection details would be published to both without affecting + each other. + properties: + name: + description: Name of the secret. + type: string + namespace: + description: Namespace of the secret. + type: string + required: + - name + - namespace + type: object + required: + - forProvider + type: object + x-kubernetes-validations: + - message: spec.forProvider.name is a required parameter + rule: '!(''*'' in self.managementPolicies || ''Create'' in self.managementPolicies + || ''Update'' in self.managementPolicies) || has(self.forProvider.name) + || (has(self.initProvider) && has(self.initProvider.name))' + - message: spec.forProvider.serviceplanId is a required parameter + rule: '!(''*'' in self.managementPolicies || ''Create'' in self.managementPolicies + || ''Update'' in self.managementPolicies) || has(self.forProvider.serviceplanId) + || (has(self.initProvider) && has(self.initProvider.serviceplanId))' + - message: spec.forProvider.subaccountId is a required parameter + rule: '!(''*'' in self.managementPolicies || ''Create'' in self.managementPolicies + || ''Update'' in self.managementPolicies) || has(self.forProvider.subaccountId) + || (has(self.initProvider) && has(self.initProvider.subaccountId))' + status: + description: SubaccountServiceInstanceStatus defines the observed state + of SubaccountServiceInstance. + properties: + atProvider: + properties: + context: + description: |- + (String) Contextual data for the resource. + Contextual data for the resource. + type: string + createdDate: + description: |- + (String) The date and time when the resource was created in RFC3339 format. + The date and time when the resource was created in [RFC3339](https://www.ietf.org/rfc/rfc3339.txt) format. + type: string + dashboardUrl: + description: |- + based management UI for the service instance. + The URL of the web-based management UI for the service instance. + type: string + id: + description: (String) The ID of the service instance. + type: string + labels: + additionalProperties: + items: + type: string + type: array + description: |- + (Map of Set of String) The set of words or phrases assigned to the service instance. + The set of words or phrases assigned to the service instance. + type: object + lastModified: + description: |- + (String) The date and time when the resource was last modified in RFC3339 format. + The date and time when the resource was last modified in [RFC3339](https://www.ietf.org/rfc/rfc3339.txt) format. + type: string + name: + description: |- + (String) The name of the service instance. + The name of the service instance. + type: string + parameters: + description: |- + (String, Sensitive) The configuration parameters for the service instance. + The configuration parameters for the service instance. + type: string + platformId: + description: |- + (String) The platform ID. + The platform ID. + type: string + ready: + description: (Boolean) + type: boolean + referencedInstanceId: + description: |- + (String) The ID of the instance to which the service instance refers. + The ID of the instance to which the service instance refers. + type: string + serviceplanId: + description: |- + (String) The ID of the service plan. + The ID of the service plan. + type: string + shared: + description: |- + (Boolean) The configuration parameter for service instance sharing. Ensure that the instance is created with a plan that supports instance sharing. + The configuration parameter for service instance sharing. Ensure that the instance is created with a plan that supports instance sharing. + type: boolean + state: + description: |- + (String) The current state of the service instance. + The current state of the service instance. + type: string + subaccountId: + description: |- + (String) The ID of the subaccount. + The ID of the subaccount. + type: string + usable: + description: |- + (Boolean) Shows whether the resource can be used. + Shows whether the resource can be used. + type: boolean + type: object + conditions: + description: Conditions of the resource. + items: + description: A Condition that may apply to a resource. + properties: + lastTransitionTime: + description: |- + LastTransitionTime is the last time this condition transitioned from one + status to another. + format: date-time + type: string + message: + description: |- + A Message containing details about this condition's last transition from + one status to another, if any. + type: string + reason: + description: A Reason for this condition's last transition from + one status to another. + type: string + status: + description: Status of this condition; is it currently True, + False, or Unknown? + type: string + type: + description: |- + Type of this condition. At most one of each condition type may apply to + a resource at any point in time. + type: string + required: + - lastTransitionTime + - reason + - status + - type + type: object + type: array + x-kubernetes-list-map-keys: + - type + x-kubernetes-list-type: map + type: object + required: + - spec + type: object + served: true + storage: true + subresources: + status: {} diff --git a/package/crds/account.btp.sap.crossplane.io_subscriptions.yaml b/package/crds/account.btp.sap.crossplane.io_subscriptions.yaml index 91c41ef..5dae74d 100644 --- a/package/crds/account.btp.sap.crossplane.io_subscriptions.yaml +++ b/package/crds/account.btp.sap.crossplane.io_subscriptions.yaml @@ -155,6 +155,7 @@ spec: forProvider: description: SubscriptionParameters are the configurable fields of a Subscription. + format: byte properties: appName: description: AppName of the app to subscribe to @@ -171,7 +172,7 @@ spec: required: - appName - planName - type: object + type: string managementPolicies: default: - '*' From 0c5b64ff577384f9a0fefb66fcfa029c93a3120f Mon Sep 17 00:00:00 2001 From: I545514 Date: Fri, 22 Nov 2024 14:29:33 +0100 Subject: [PATCH 2/5] fix: add unit test --- internal/clients/subscription/subscription.go | 6 +-- .../clients/subscription/subscription_test.go | 50 ++++++++++++++++--- 2 files changed, 47 insertions(+), 9 deletions(-) diff --git a/internal/clients/subscription/subscription.go b/internal/clients/subscription/subscription.go index 59930e3..7a152c7 100644 --- a/internal/clients/subscription/subscription.go +++ b/internal/clients/subscription/subscription.go @@ -165,14 +165,14 @@ func (s *SubscriptionTypeMapper) ConvertToCreatePayload(cr *v1alpha1.Subscriptio func (s *SubscriptionTypeMapper) ConvertToClientParams(cr *v1alpha1.Subscription) map[string]map[string]interface{} { type subparams map[string]map[string]interface{} - var sp subparams + var subscriptionParams subparams - err := json.Unmarshal(cr.Spec.ForProvider.SubscriptionParameters, &sp) + err := json.Unmarshal(cr.Spec.ForProvider.SubscriptionParameters, &subscriptionParams) if err != nil { return nil } - return sp + return subscriptionParams } func (s *SubscriptionTypeMapper) ConvertToUpdatePayload(cr *v1alpha1.Subscription) SubscriptionPut { diff --git a/internal/clients/subscription/subscription_test.go b/internal/clients/subscription/subscription_test.go index 76d3ddc..3cac41a 100644 --- a/internal/clients/subscription/subscription_test.go +++ b/internal/clients/subscription/subscription_test.go @@ -2,6 +2,7 @@ package subscription import ( "context" + "encoding/json" "net/http" "testing" @@ -103,6 +104,14 @@ func TestSubscriptionApiHandler_CreateSubscription(t *testing.T) { appName: "name1", CreateSubscriptionRequestPayload: saas_client.CreateSubscriptionRequestPayload{ PlanName: internal.Ptr("plan2"), + SubscriptionParams: map[string]map[string]interface{}{ + "param1": { + "key1": "value1", + }, + "param2": { + "key2": "value2", + }, + }, }, }, mockSubscriptionApi: apiMockPOST( @@ -117,6 +126,13 @@ func TestSubscriptionApiHandler_CreateSubscription(t *testing.T) { appName: "name1", CreateSubscriptionRequestPayload: saas_client.CreateSubscriptionRequestPayload{ PlanName: internal.Ptr("plan2"), + SubscriptionParams: map[string]map[string]interface{}{ + "param1": { + "key1": "value1", + }, + "param2": { + "key2": "value2", + }, }, }, mockSubscriptionApi: apiMockPOST( @@ -247,7 +263,8 @@ func TestSubscriptionApiHandler_UpdateSubscription(t *testing.T) { } func TestSubscriptionTypeMapper_ConvertToCreatePayload(t *testing.T) { - cr := NewSubscription("someName", "name1", "plan2") + raw := json.RawMessage(`{"name": "John", "age": 30}`) + cr := NewSubscription("someName", "name1", "plan2", raw) uut := NewSubscriptionTypeMapper() mapped := uut.ConvertToCreatePayload(cr) @@ -258,8 +275,27 @@ func TestSubscriptionTypeMapper_ConvertToCreatePayload(t *testing.T) { } +func TestSubscriptionTypeMapper_ConvertToClientParams(t *testing.T) { + raw := json.RawMessage(`{"param1": {"key1": "value1"}, "param2": {"key2": "value2"}}`) + cr := &v1alpha1.Subscription{ + Spec: v1alpha1.SubscriptionSpec{ + ForProvider: v1alpha1.SubscriptionParameters{ + SubscriptionParameters: raw, + }, + }, + } + + uut := NewSubscriptionTypeMapper() + params := uut.ConvertToClientParams(cr) + + assert.NotNil(t, params) + assert.Equal(t, "value1", params["param1"]["key1"]) + assert.Equal(t, "value2", params["param2"]["key2"]) +} + func TestSubscriptionTypeMapper_IsSynced(t *testing.T) { - cr := NewSubscription("someName", "name1", "plan2") + raw := json.RawMessage(`{"name": "John", "age": 30}`) + cr := NewSubscription("someName", "name1", "plan2", raw) get := &SubscriptionGet{ AppName: internal.Ptr("anotherName"), PlanName: internal.Ptr("anotherPlan"), @@ -310,6 +346,7 @@ func TestSubscriptionTypeMapper_IsAvailable(t *testing.T) { } func TestSubscriptionTypeMapper_SyncStatus(t *testing.T) { + raw := json.RawMessage(`{"name": "John", "age": 30}`) tests := map[string]struct { cr *v1alpha1.Subscription apiRes *SubscriptionGet @@ -317,7 +354,7 @@ func TestSubscriptionTypeMapper_SyncStatus(t *testing.T) { expectedCr *v1alpha1.Subscription }{ "SetState": { - cr: NewSubscription("someName", "name1", "plan2"), + cr: NewSubscription("someName", "name1", "plan2", raw), apiRes: &SubscriptionGet{ AppName: internal.Ptr("name1"), PlanName: internal.Ptr("plan2"), @@ -374,13 +411,14 @@ func apiMockDELETE(statusCode int, apiError error) *MockSubscriptionOperationsCo return apiMock } -func NewSubscription(crName string, appName string, planName string) *v1alpha1.Subscription { +func NewSubscription(crName string, appName string, planName string, subscriptionParameters json.RawMessage) *v1alpha1.Subscription { cr := &v1alpha1.Subscription{ ObjectMeta: metav1.ObjectMeta{Name: crName}, Spec: v1alpha1.SubscriptionSpec{ ForProvider: v1alpha1.SubscriptionParameters{ - AppName: appName, - PlanName: planName, + AppName: appName, + PlanName: planName, + SubscriptionParameters: subscriptionParameters, }, }, } From c3f220c51ee6c8f586a4414ec8faee77d9eca353 Mon Sep 17 00:00:00 2001 From: I545514 Date: Fri, 22 Nov 2024 14:37:07 +0100 Subject: [PATCH 3/5] fix: fix unit test --- internal/clients/subscription/subscription_test.go | 1 + 1 file changed, 1 insertion(+) diff --git a/internal/clients/subscription/subscription_test.go b/internal/clients/subscription/subscription_test.go index 3cac41a..e244219 100644 --- a/internal/clients/subscription/subscription_test.go +++ b/internal/clients/subscription/subscription_test.go @@ -133,6 +133,7 @@ func TestSubscriptionApiHandler_CreateSubscription(t *testing.T) { "param2": { "key2": "value2", }, + }, }, }, mockSubscriptionApi: apiMockPOST( From 85ca41c645c88a4ec01f5c655d05172936fcb252 Mon Sep 17 00:00:00 2001 From: I545514 Date: Mon, 25 Nov 2024 11:07:07 +0100 Subject: [PATCH 4/5] fix: crd generate --- apis/account/v1alpha1/subscription_types.go | 2 +- .../v1alpha1/zz_generated.resolvers.go | 1 - .../account/v1beta1/zz_generated.resolvers.go | 1 - .../v1alpha1/zz_generated.resolvers.go | 1 - .../v1alpha1/zz_generated.resolvers.go | 1 - .../subaccountservicebinding/zz_controller.go | 83 --- .../zz_controller.go | 83 --- internal/controller/zz_setup.go | 4 - ...ossplane.io_subaccountservicebindings.yaml | 457 ----------------- ...ssplane.io_subaccountserviceinstances.yaml | 474 ------------------ ...t.btp.sap.crossplane.io_subscriptions.yaml | 9 +- 11 files changed, 8 insertions(+), 1108 deletions(-) delete mode 100755 internal/controller/account/subaccountservicebinding/zz_controller.go delete mode 100755 internal/controller/account/subaccountserviceinstance/zz_controller.go delete mode 100644 package/crds/account.btp.sap.crossplane.io_subaccountservicebindings.yaml delete mode 100644 package/crds/account.btp.sap.crossplane.io_subaccountserviceinstances.yaml diff --git a/apis/account/v1alpha1/subscription_types.go b/apis/account/v1alpha1/subscription_types.go index a8fae01..3e094d3 100644 --- a/apis/account/v1alpha1/subscription_types.go +++ b/apis/account/v1alpha1/subscription_types.go @@ -29,7 +29,7 @@ type SubscriptionParameters struct { // +kubebuilder:validation:XValidation:rule="self == oldSelf",message="planName can't be updated once set" PlanName string `json:"planName"` // Subscription parameters allows you to add additional parameters - SubscriptionParameters json.RawMessage `json:",subscriptionParameters"` + SubscriptionParameters json.RawMessage `json:"subscriptionParameters"` } // SubscriptionObservation are the observable fields of a Subscription. diff --git a/apis/account/v1alpha1/zz_generated.resolvers.go b/apis/account/v1alpha1/zz_generated.resolvers.go index 6f500d5..a7ea779 100644 --- a/apis/account/v1alpha1/zz_generated.resolvers.go +++ b/apis/account/v1alpha1/zz_generated.resolvers.go @@ -20,7 +20,6 @@ package v1alpha1 import ( "context" - reference "github.com/crossplane/crossplane-runtime/pkg/reference" errors "github.com/pkg/errors" client "sigs.k8s.io/controller-runtime/pkg/client" diff --git a/apis/account/v1beta1/zz_generated.resolvers.go b/apis/account/v1beta1/zz_generated.resolvers.go index 2d601c4..66a39de 100644 --- a/apis/account/v1beta1/zz_generated.resolvers.go +++ b/apis/account/v1beta1/zz_generated.resolvers.go @@ -20,7 +20,6 @@ package v1beta1 import ( "context" - reference "github.com/crossplane/crossplane-runtime/pkg/reference" errors "github.com/pkg/errors" v1alpha1 "github.com/sap/crossplane-provider-btp/apis/account/v1alpha1" diff --git a/apis/environment/v1alpha1/zz_generated.resolvers.go b/apis/environment/v1alpha1/zz_generated.resolvers.go index f61c42f..f459d4a 100644 --- a/apis/environment/v1alpha1/zz_generated.resolvers.go +++ b/apis/environment/v1alpha1/zz_generated.resolvers.go @@ -20,7 +20,6 @@ package v1alpha1 import ( "context" - reference "github.com/crossplane/crossplane-runtime/pkg/reference" errors "github.com/pkg/errors" v1alpha1 "github.com/sap/crossplane-provider-btp/apis/account/v1alpha1" diff --git a/apis/security/v1alpha1/zz_generated.resolvers.go b/apis/security/v1alpha1/zz_generated.resolvers.go index 4390788..0cd5c78 100644 --- a/apis/security/v1alpha1/zz_generated.resolvers.go +++ b/apis/security/v1alpha1/zz_generated.resolvers.go @@ -20,7 +20,6 @@ package v1alpha1 import ( "context" - reference "github.com/crossplane/crossplane-runtime/pkg/reference" errors "github.com/pkg/errors" v1alpha1 "github.com/sap/crossplane-provider-btp/apis/account/v1alpha1" diff --git a/internal/controller/account/subaccountservicebinding/zz_controller.go b/internal/controller/account/subaccountservicebinding/zz_controller.go deleted file mode 100755 index 5139963..0000000 --- a/internal/controller/account/subaccountservicebinding/zz_controller.go +++ /dev/null @@ -1,83 +0,0 @@ -/* -Copyright 2022 The Crossplane Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// Code generated by upjet. DO NOT EDIT. - -package subaccountservicebinding - -import ( - "time" - - "github.com/crossplane/crossplane-runtime/pkg/connection" - "github.com/crossplane/crossplane-runtime/pkg/event" - "github.com/crossplane/crossplane-runtime/pkg/ratelimiter" - "github.com/crossplane/crossplane-runtime/pkg/reconciler/managed" - xpresource "github.com/crossplane/crossplane-runtime/pkg/resource" - tjcontroller "github.com/crossplane/upjet/pkg/controller" - "github.com/crossplane/upjet/pkg/controller/handler" - "github.com/crossplane/upjet/pkg/terraform" - "github.com/pkg/errors" - ctrl "sigs.k8s.io/controller-runtime" - - v1alpha1 "github.com/sap/crossplane-provider-btp/apis/account/v1alpha1" - features "github.com/sap/crossplane-provider-btp/internal/features" -) - -// Setup adds a controller that reconciles SubaccountServiceBinding managed resources. -func Setup(mgr ctrl.Manager, o tjcontroller.Options) error { - name := managed.ControllerName(v1alpha1.SubaccountServiceBinding_GroupVersionKind.String()) - var initializers managed.InitializerChain - cps := []managed.ConnectionPublisher{managed.NewAPISecretPublisher(mgr.GetClient(), mgr.GetScheme())} - if o.SecretStoreConfigGVK != nil { - cps = append(cps, connection.NewDetailsManager(mgr.GetClient(), *o.SecretStoreConfigGVK, connection.WithTLSConfig(o.ESSOptions.TLSConfig))) - } - eventHandler := handler.NewEventHandler(handler.WithLogger(o.Logger.WithValues("gvk", v1alpha1.SubaccountServiceBinding_GroupVersionKind))) - opts := []managed.ReconcilerOption{ - managed.WithExternalConnecter(tjcontroller.NewConnector(mgr.GetClient(), o.WorkspaceStore, o.SetupFn, o.Provider.Resources["btp_subaccount_service_binding"], tjcontroller.WithLogger(o.Logger), tjcontroller.WithConnectorEventHandler(eventHandler))), - managed.WithLogger(o.Logger.WithValues("controller", name)), - managed.WithRecorder(event.NewAPIRecorder(mgr.GetEventRecorderFor(name))), - managed.WithFinalizer(terraform.NewWorkspaceFinalizer(o.WorkspaceStore, xpresource.NewAPIFinalizer(mgr.GetClient(), managed.FinalizerName))), - managed.WithTimeout(3 * time.Minute), - managed.WithInitializers(initializers), - managed.WithConnectionPublishers(cps...), - managed.WithPollInterval(o.PollInterval), - } - if o.PollJitter != 0 { - opts = append(opts, managed.WithPollJitterHook(o.PollJitter)) - } - if o.Features.Enabled(features.EnableBetaManagementPolicies) { - opts = append(opts, managed.WithManagementPolicies()) - } - - // register webhooks for the kind v1alpha1.SubaccountServiceBinding - // if they're enabled. - if o.StartWebhooks { - if err := ctrl.NewWebhookManagedBy(mgr). - For(&v1alpha1.SubaccountServiceBinding{}). - Complete(); err != nil { - return errors.Wrap(err, "cannot register webhook for the kind v1alpha1.SubaccountServiceBinding") - } - } - - r := managed.NewReconciler(mgr, xpresource.ManagedKind(v1alpha1.SubaccountServiceBinding_GroupVersionKind), opts...) - - return ctrl.NewControllerManagedBy(mgr). - Named(name). - WithOptions(o.ForControllerRuntime()). - WithEventFilter(xpresource.DesiredStateChanged()). - Watches(&v1alpha1.SubaccountServiceBinding{}, eventHandler). - Complete(ratelimiter.NewReconciler(name, r, o.GlobalRateLimiter)) -} diff --git a/internal/controller/account/subaccountserviceinstance/zz_controller.go b/internal/controller/account/subaccountserviceinstance/zz_controller.go deleted file mode 100755 index 8fe15ef..0000000 --- a/internal/controller/account/subaccountserviceinstance/zz_controller.go +++ /dev/null @@ -1,83 +0,0 @@ -/* -Copyright 2022 The Crossplane Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// Code generated by upjet. DO NOT EDIT. - -package subaccountserviceinstance - -import ( - "time" - - "github.com/crossplane/crossplane-runtime/pkg/connection" - "github.com/crossplane/crossplane-runtime/pkg/event" - "github.com/crossplane/crossplane-runtime/pkg/ratelimiter" - "github.com/crossplane/crossplane-runtime/pkg/reconciler/managed" - xpresource "github.com/crossplane/crossplane-runtime/pkg/resource" - tjcontroller "github.com/crossplane/upjet/pkg/controller" - "github.com/crossplane/upjet/pkg/controller/handler" - "github.com/crossplane/upjet/pkg/terraform" - "github.com/pkg/errors" - ctrl "sigs.k8s.io/controller-runtime" - - v1alpha1 "github.com/sap/crossplane-provider-btp/apis/account/v1alpha1" - features "github.com/sap/crossplane-provider-btp/internal/features" -) - -// Setup adds a controller that reconciles SubaccountServiceInstance managed resources. -func Setup(mgr ctrl.Manager, o tjcontroller.Options) error { - name := managed.ControllerName(v1alpha1.SubaccountServiceInstance_GroupVersionKind.String()) - var initializers managed.InitializerChain - cps := []managed.ConnectionPublisher{managed.NewAPISecretPublisher(mgr.GetClient(), mgr.GetScheme())} - if o.SecretStoreConfigGVK != nil { - cps = append(cps, connection.NewDetailsManager(mgr.GetClient(), *o.SecretStoreConfigGVK, connection.WithTLSConfig(o.ESSOptions.TLSConfig))) - } - eventHandler := handler.NewEventHandler(handler.WithLogger(o.Logger.WithValues("gvk", v1alpha1.SubaccountServiceInstance_GroupVersionKind))) - opts := []managed.ReconcilerOption{ - managed.WithExternalConnecter(tjcontroller.NewConnector(mgr.GetClient(), o.WorkspaceStore, o.SetupFn, o.Provider.Resources["btp_subaccount_service_instance"], tjcontroller.WithLogger(o.Logger), tjcontroller.WithConnectorEventHandler(eventHandler))), - managed.WithLogger(o.Logger.WithValues("controller", name)), - managed.WithRecorder(event.NewAPIRecorder(mgr.GetEventRecorderFor(name))), - managed.WithFinalizer(terraform.NewWorkspaceFinalizer(o.WorkspaceStore, xpresource.NewAPIFinalizer(mgr.GetClient(), managed.FinalizerName))), - managed.WithTimeout(3 * time.Minute), - managed.WithInitializers(initializers), - managed.WithConnectionPublishers(cps...), - managed.WithPollInterval(o.PollInterval), - } - if o.PollJitter != 0 { - opts = append(opts, managed.WithPollJitterHook(o.PollJitter)) - } - if o.Features.Enabled(features.EnableBetaManagementPolicies) { - opts = append(opts, managed.WithManagementPolicies()) - } - - // register webhooks for the kind v1alpha1.SubaccountServiceInstance - // if they're enabled. - if o.StartWebhooks { - if err := ctrl.NewWebhookManagedBy(mgr). - For(&v1alpha1.SubaccountServiceInstance{}). - Complete(); err != nil { - return errors.Wrap(err, "cannot register webhook for the kind v1alpha1.SubaccountServiceInstance") - } - } - - r := managed.NewReconciler(mgr, xpresource.ManagedKind(v1alpha1.SubaccountServiceInstance_GroupVersionKind), opts...) - - return ctrl.NewControllerManagedBy(mgr). - Named(name). - WithOptions(o.ForControllerRuntime()). - WithEventFilter(xpresource.DesiredStateChanged()). - Watches(&v1alpha1.SubaccountServiceInstance{}, eventHandler). - Complete(ratelimiter.NewReconciler(name, r, o.GlobalRateLimiter)) -} diff --git a/internal/controller/zz_setup.go b/internal/controller/zz_setup.go index 17eb718..05ddd3c 100644 --- a/internal/controller/zz_setup.go +++ b/internal/controller/zz_setup.go @@ -22,8 +22,6 @@ import ( "github.com/crossplane/upjet/pkg/controller" directoryentitlement "github.com/sap/crossplane-provider-btp/internal/controller/account/directoryentitlement" - subaccountservicebinding "github.com/sap/crossplane-provider-btp/internal/controller/account/subaccountservicebinding" - subaccountserviceinstance "github.com/sap/crossplane-provider-btp/internal/controller/account/subaccountserviceinstance" providerconfig "github.com/sap/crossplane-provider-btp/internal/controller/providerconfig" globalaccounttrustconfiguration "github.com/sap/crossplane-provider-btp/internal/controller/security/globalaccounttrustconfiguration" subaccounttrustconfiguration "github.com/sap/crossplane-provider-btp/internal/controller/security/subaccounttrustconfiguration" @@ -34,8 +32,6 @@ import ( func Setup(mgr ctrl.Manager, o controller.Options) error { for _, setup := range []func(ctrl.Manager, controller.Options) error{ directoryentitlement.Setup, - subaccountservicebinding.Setup, - subaccountserviceinstance.Setup, providerconfig.Setup, globalaccounttrustconfiguration.Setup, subaccounttrustconfiguration.Setup, diff --git a/package/crds/account.btp.sap.crossplane.io_subaccountservicebindings.yaml b/package/crds/account.btp.sap.crossplane.io_subaccountservicebindings.yaml deleted file mode 100644 index 8c46d4c..0000000 --- a/package/crds/account.btp.sap.crossplane.io_subaccountservicebindings.yaml +++ /dev/null @@ -1,457 +0,0 @@ ---- -apiVersion: apiextensions.k8s.io/v1 -kind: CustomResourceDefinition -metadata: - annotations: - controller-gen.kubebuilder.io/version: v0.14.0 - name: subaccountservicebindings.account.btp.sap.crossplane.io -spec: - group: account.btp.sap.crossplane.io - names: - categories: - - crossplane - - managed - - account - kind: SubaccountServiceBinding - listKind: SubaccountServiceBindingList - plural: subaccountservicebindings - singular: subaccountservicebinding - scope: Cluster - versions: - - additionalPrinterColumns: - - jsonPath: .status.conditions[?(@.type=='Ready')].status - name: READY - type: string - - jsonPath: .status.conditions[?(@.type=='Synced')].status - name: SYNCED - type: string - - jsonPath: .metadata.annotations.crossplane\.io/external-name - name: EXTERNAL-NAME - type: string - - jsonPath: .metadata.creationTimestamp - name: AGE - type: date - name: v1alpha1 - schema: - openAPIV3Schema: - description: 'SubaccountServiceBinding is the Schema for the SubaccountServiceBindings - API. Creates a service binding, i.e. generates access details to consume - a service. Tip: You must be assigned to the admin or the service administrator - role of the subaccount.' - properties: - apiVersion: - description: |- - APIVersion defines the versioned schema of this representation of an object. - Servers should convert recognized schemas to the latest internal value, and - may reject unrecognized values. - More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources - type: string - kind: - description: |- - Kind is a string value representing the REST resource this object represents. - Servers may infer this from the endpoint the client submits requests to. - Cannot be updated. - In CamelCase. - More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds - type: string - metadata: - type: object - spec: - description: SubaccountServiceBindingSpec defines the desired state of - SubaccountServiceBinding - properties: - deletionPolicy: - default: Delete - description: |- - DeletionPolicy specifies what will happen to the underlying external - when this managed resource is deleted - either "Delete" or "Orphan" the - external resource. - This field is planned to be deprecated in favor of the ManagementPolicies - field in a future release. Currently, both could be set independently and - non-default values would be honored if the feature flag is enabled. - See the design doc for more information: https://github.com/crossplane/crossplane/blob/499895a25d1a1a0ba1604944ef98ac7a1a71f197/design/design-doc-observe-only-resources.md?plain=1#L223 - enum: - - Orphan - - Delete - type: string - forProvider: - properties: - labels: - additionalProperties: - items: - type: string - type: array - description: |- - (Map of Set of String) The set of words or phrases assigned to the service binding. - The set of words or phrases assigned to the service binding. - type: object - name: - description: |- - (String) The name of the service binding. - The name of the service binding. - type: string - parameters: - description: |- - (String) The parameters of the service binding as a valid JSON object. - The parameters of the service binding as a valid JSON object. - type: string - serviceInstanceId: - description: |- - (String) The ID of the service instance associated with the binding. - The ID of the service instance associated with the binding. - type: string - subaccountId: - description: |- - (String) The ID of the subaccount. - The ID of the subaccount. - type: string - type: object - initProvider: - description: |- - THIS IS A BETA FIELD. It will be honored - unless the Management Policies feature flag is disabled. - InitProvider holds the same fields as ForProvider, with the exception - of Identifier and other resource reference fields. The fields that are - in InitProvider are merged into ForProvider when the resource is created. - The same fields are also added to the terraform ignore_changes hook, to - avoid updating them after creation. This is useful for fields that are - required on creation, but we do not desire to update them after creation, - for example because of an external controller is managing them, like an - autoscaler. - properties: - labels: - additionalProperties: - items: - type: string - type: array - description: |- - (Map of Set of String) The set of words or phrases assigned to the service binding. - The set of words or phrases assigned to the service binding. - type: object - name: - description: |- - (String) The name of the service binding. - The name of the service binding. - type: string - parameters: - description: |- - (String) The parameters of the service binding as a valid JSON object. - The parameters of the service binding as a valid JSON object. - type: string - serviceInstanceId: - description: |- - (String) The ID of the service instance associated with the binding. - The ID of the service instance associated with the binding. - type: string - subaccountId: - description: |- - (String) The ID of the subaccount. - The ID of the subaccount. - type: string - type: object - managementPolicies: - default: - - '*' - description: |- - THIS IS A BETA FIELD. It is on by default but can be opted out - through a Crossplane feature flag. - ManagementPolicies specify the array of actions Crossplane is allowed to - take on the managed and external resources. - This field is planned to replace the DeletionPolicy field in a future - release. Currently, both could be set independently and non-default - values would be honored if the feature flag is enabled. If both are - custom, the DeletionPolicy field will be ignored. - See the design doc for more information: https://github.com/crossplane/crossplane/blob/499895a25d1a1a0ba1604944ef98ac7a1a71f197/design/design-doc-observe-only-resources.md?plain=1#L223 - and this one: https://github.com/crossplane/crossplane/blob/444267e84783136daa93568b364a5f01228cacbe/design/one-pager-ignore-changes.md - items: - description: |- - A ManagementAction represents an action that the Crossplane controllers - can take on an external resource. - enum: - - Observe - - Create - - Update - - Delete - - LateInitialize - - '*' - type: string - type: array - providerConfigRef: - default: - name: default - description: |- - ProviderConfigReference specifies how the provider that will be used to - create, observe, update, and delete this managed resource should be - configured. - properties: - name: - description: Name of the referenced object. - type: string - policy: - description: Policies for referencing. - properties: - resolution: - default: Required - description: |- - Resolution specifies whether resolution of this reference is required. - The default is 'Required', which means the reconcile will fail if the - reference cannot be resolved. 'Optional' means this reference will be - a no-op if it cannot be resolved. - enum: - - Required - - Optional - type: string - resolve: - description: |- - Resolve specifies when this reference should be resolved. The default - is 'IfNotPresent', which will attempt to resolve the reference only when - the corresponding field is not present. Use 'Always' to resolve the - reference on every reconcile. - enum: - - Always - - IfNotPresent - type: string - type: object - required: - - name - type: object - publishConnectionDetailsTo: - description: |- - PublishConnectionDetailsTo specifies the connection secret config which - contains a name, metadata and a reference to secret store config to - which any connection details for this managed resource should be written. - Connection details frequently include the endpoint, username, - and password required to connect to the managed resource. - properties: - configRef: - default: - name: default - description: |- - SecretStoreConfigRef specifies which secret store config should be used - for this ConnectionSecret. - properties: - name: - description: Name of the referenced object. - type: string - policy: - description: Policies for referencing. - properties: - resolution: - default: Required - description: |- - Resolution specifies whether resolution of this reference is required. - The default is 'Required', which means the reconcile will fail if the - reference cannot be resolved. 'Optional' means this reference will be - a no-op if it cannot be resolved. - enum: - - Required - - Optional - type: string - resolve: - description: |- - Resolve specifies when this reference should be resolved. The default - is 'IfNotPresent', which will attempt to resolve the reference only when - the corresponding field is not present. Use 'Always' to resolve the - reference on every reconcile. - enum: - - Always - - IfNotPresent - type: string - type: object - required: - - name - type: object - metadata: - description: Metadata is the metadata for connection secret. - properties: - annotations: - additionalProperties: - type: string - description: |- - Annotations are the annotations to be added to connection secret. - - For Kubernetes secrets, this will be used as "metadata.annotations". - - It is up to Secret Store implementation for others store types. - type: object - labels: - additionalProperties: - type: string - description: |- - Labels are the labels/tags to be added to connection secret. - - For Kubernetes secrets, this will be used as "metadata.labels". - - It is up to Secret Store implementation for others store types. - type: object - type: - description: |- - Type is the SecretType for the connection secret. - - Only valid for Kubernetes Secret Stores. - type: string - type: object - name: - description: Name is the name of the connection secret. - type: string - required: - - name - type: object - writeConnectionSecretToRef: - description: |- - WriteConnectionSecretToReference specifies the namespace and name of a - Secret to which any connection details for this managed resource should - be written. Connection details frequently include the endpoint, username, - and password required to connect to the managed resource. - This field is planned to be replaced in a future release in favor of - PublishConnectionDetailsTo. Currently, both could be set independently - and connection details would be published to both without affecting - each other. - properties: - name: - description: Name of the secret. - type: string - namespace: - description: Namespace of the secret. - type: string - required: - - name - - namespace - type: object - required: - - forProvider - type: object - x-kubernetes-validations: - - message: spec.forProvider.name is a required parameter - rule: '!(''*'' in self.managementPolicies || ''Create'' in self.managementPolicies - || ''Update'' in self.managementPolicies) || has(self.forProvider.name) - || (has(self.initProvider) && has(self.initProvider.name))' - - message: spec.forProvider.serviceInstanceId is a required parameter - rule: '!(''*'' in self.managementPolicies || ''Create'' in self.managementPolicies - || ''Update'' in self.managementPolicies) || has(self.forProvider.serviceInstanceId) - || (has(self.initProvider) && has(self.initProvider.serviceInstanceId))' - - message: spec.forProvider.subaccountId is a required parameter - rule: '!(''*'' in self.managementPolicies || ''Create'' in self.managementPolicies - || ''Update'' in self.managementPolicies) || has(self.forProvider.subaccountId) - || (has(self.initProvider) && has(self.initProvider.subaccountId))' - status: - description: SubaccountServiceBindingStatus defines the observed state - of SubaccountServiceBinding. - properties: - atProvider: - properties: - bindResource: - additionalProperties: - type: string - description: |- - (Map of String) Contains the resources associated with the binding. - Contains the resources associated with the binding. - type: object - x-kubernetes-map-type: granular - context: - description: |- - (String) The contextual data for the resource. - The contextual data for the resource. - type: string - createdDate: - description: |- - (String) The date and time when the resource was created in RFC3339 format. - The date and time when the resource was created in [RFC3339](https://www.ietf.org/rfc/rfc3339.txt) format. - type: string - id: - description: (String) The ID of the service binding. - type: string - labels: - additionalProperties: - items: - type: string - type: array - description: |- - (Map of Set of String) The set of words or phrases assigned to the service binding. - The set of words or phrases assigned to the service binding. - type: object - lastModified: - description: |- - (String) The date and time when the resource was last modified in RFC3339 format. - The date and time when the resource was last modified in [RFC3339](https://www.ietf.org/rfc/rfc3339.txt) format. - type: string - name: - description: |- - (String) The name of the service binding. - The name of the service binding. - type: string - parameters: - description: |- - (String) The parameters of the service binding as a valid JSON object. - The parameters of the service binding as a valid JSON object. - type: string - ready: - description: |- - (Boolean) Shows whether the service binding is ready. - Shows whether the service binding is ready. - type: boolean - serviceInstanceId: - description: |- - (String) The ID of the service instance associated with the binding. - The ID of the service instance associated with the binding. - type: string - state: - description: |- - (String) The current state of the service binding. Possible values are: - The current state of the service binding. Possible values are: - - - | state | description | - | --- | --- | - | `in progress` | The operation or processing is in progress | - | `failed` | The operation or processing failed | - | `succeeded` | The operation or processing succeeded | - type: string - subaccountId: - description: |- - (String) The ID of the subaccount. - The ID of the subaccount. - type: string - type: object - conditions: - description: Conditions of the resource. - items: - description: A Condition that may apply to a resource. - properties: - lastTransitionTime: - description: |- - LastTransitionTime is the last time this condition transitioned from one - status to another. - format: date-time - type: string - message: - description: |- - A Message containing details about this condition's last transition from - one status to another, if any. - type: string - reason: - description: A Reason for this condition's last transition from - one status to another. - type: string - status: - description: Status of this condition; is it currently True, - False, or Unknown? - type: string - type: - description: |- - Type of this condition. At most one of each condition type may apply to - a resource at any point in time. - type: string - required: - - lastTransitionTime - - reason - - status - - type - type: object - type: array - x-kubernetes-list-map-keys: - - type - x-kubernetes-list-type: map - type: object - required: - - spec - type: object - served: true - storage: true - subresources: - status: {} diff --git a/package/crds/account.btp.sap.crossplane.io_subaccountserviceinstances.yaml b/package/crds/account.btp.sap.crossplane.io_subaccountserviceinstances.yaml deleted file mode 100644 index 0ccd403..0000000 --- a/package/crds/account.btp.sap.crossplane.io_subaccountserviceinstances.yaml +++ /dev/null @@ -1,474 +0,0 @@ ---- -apiVersion: apiextensions.k8s.io/v1 -kind: CustomResourceDefinition -metadata: - annotations: - controller-gen.kubebuilder.io/version: v0.14.0 - name: subaccountserviceinstances.account.btp.sap.crossplane.io -spec: - group: account.btp.sap.crossplane.io - names: - categories: - - crossplane - - managed - - account - kind: SubaccountServiceInstance - listKind: SubaccountServiceInstanceList - plural: subaccountserviceinstances - singular: subaccountserviceinstance - scope: Cluster - versions: - - additionalPrinterColumns: - - jsonPath: .status.conditions[?(@.type=='Ready')].status - name: READY - type: string - - jsonPath: .status.conditions[?(@.type=='Synced')].status - name: SYNCED - type: string - - jsonPath: .metadata.annotations.crossplane\.io/external-name - name: EXTERNAL-NAME - type: string - - jsonPath: .metadata.creationTimestamp - name: AGE - type: date - name: v1alpha1 - schema: - openAPIV3Schema: - description: 'SubaccountServiceInstance is the Schema for the SubaccountServiceInstances - API. Creates a service instance in a subaccount. Tip: You must be assigned - to the admin or the service administrator role of the subaccount.' - properties: - apiVersion: - description: |- - APIVersion defines the versioned schema of this representation of an object. - Servers should convert recognized schemas to the latest internal value, and - may reject unrecognized values. - More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources - type: string - kind: - description: |- - Kind is a string value representing the REST resource this object represents. - Servers may infer this from the endpoint the client submits requests to. - Cannot be updated. - In CamelCase. - More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds - type: string - metadata: - type: object - spec: - description: SubaccountServiceInstanceSpec defines the desired state of - SubaccountServiceInstance - properties: - deletionPolicy: - default: Delete - description: |- - DeletionPolicy specifies what will happen to the underlying external - when this managed resource is deleted - either "Delete" or "Orphan" the - external resource. - This field is planned to be deprecated in favor of the ManagementPolicies - field in a future release. Currently, both could be set independently and - non-default values would be honored if the feature flag is enabled. - See the design doc for more information: https://github.com/crossplane/crossplane/blob/499895a25d1a1a0ba1604944ef98ac7a1a71f197/design/design-doc-observe-only-resources.md?plain=1#L223 - enum: - - Orphan - - Delete - type: string - forProvider: - properties: - labels: - additionalProperties: - items: - type: string - type: array - description: |- - (Map of Set of String) The set of words or phrases assigned to the service instance. - The set of words or phrases assigned to the service instance. - type: object - name: - description: |- - (String) The name of the service instance. - The name of the service instance. - type: string - parameters: - description: |- - (String, Sensitive) The configuration parameters for the service instance. - The configuration parameters for the service instance. - type: string - serviceplanId: - description: |- - (String) The ID of the service plan. - The ID of the service plan. - type: string - shared: - description: |- - (Boolean) The configuration parameter for service instance sharing. Ensure that the instance is created with a plan that supports instance sharing. - The configuration parameter for service instance sharing. Ensure that the instance is created with a plan that supports instance sharing. - type: boolean - subaccountId: - description: |- - (String) The ID of the subaccount. - The ID of the subaccount. - type: string - type: object - initProvider: - description: |- - THIS IS A BETA FIELD. It will be honored - unless the Management Policies feature flag is disabled. - InitProvider holds the same fields as ForProvider, with the exception - of Identifier and other resource reference fields. The fields that are - in InitProvider are merged into ForProvider when the resource is created. - The same fields are also added to the terraform ignore_changes hook, to - avoid updating them after creation. This is useful for fields that are - required on creation, but we do not desire to update them after creation, - for example because of an external controller is managing them, like an - autoscaler. - properties: - labels: - additionalProperties: - items: - type: string - type: array - description: |- - (Map of Set of String) The set of words or phrases assigned to the service instance. - The set of words or phrases assigned to the service instance. - type: object - name: - description: |- - (String) The name of the service instance. - The name of the service instance. - type: string - parameters: - description: |- - (String, Sensitive) The configuration parameters for the service instance. - The configuration parameters for the service instance. - type: string - serviceplanId: - description: |- - (String) The ID of the service plan. - The ID of the service plan. - type: string - shared: - description: |- - (Boolean) The configuration parameter for service instance sharing. Ensure that the instance is created with a plan that supports instance sharing. - The configuration parameter for service instance sharing. Ensure that the instance is created with a plan that supports instance sharing. - type: boolean - subaccountId: - description: |- - (String) The ID of the subaccount. - The ID of the subaccount. - type: string - type: object - managementPolicies: - default: - - '*' - description: |- - THIS IS A BETA FIELD. It is on by default but can be opted out - through a Crossplane feature flag. - ManagementPolicies specify the array of actions Crossplane is allowed to - take on the managed and external resources. - This field is planned to replace the DeletionPolicy field in a future - release. Currently, both could be set independently and non-default - values would be honored if the feature flag is enabled. If both are - custom, the DeletionPolicy field will be ignored. - See the design doc for more information: https://github.com/crossplane/crossplane/blob/499895a25d1a1a0ba1604944ef98ac7a1a71f197/design/design-doc-observe-only-resources.md?plain=1#L223 - and this one: https://github.com/crossplane/crossplane/blob/444267e84783136daa93568b364a5f01228cacbe/design/one-pager-ignore-changes.md - items: - description: |- - A ManagementAction represents an action that the Crossplane controllers - can take on an external resource. - enum: - - Observe - - Create - - Update - - Delete - - LateInitialize - - '*' - type: string - type: array - providerConfigRef: - default: - name: default - description: |- - ProviderConfigReference specifies how the provider that will be used to - create, observe, update, and delete this managed resource should be - configured. - properties: - name: - description: Name of the referenced object. - type: string - policy: - description: Policies for referencing. - properties: - resolution: - default: Required - description: |- - Resolution specifies whether resolution of this reference is required. - The default is 'Required', which means the reconcile will fail if the - reference cannot be resolved. 'Optional' means this reference will be - a no-op if it cannot be resolved. - enum: - - Required - - Optional - type: string - resolve: - description: |- - Resolve specifies when this reference should be resolved. The default - is 'IfNotPresent', which will attempt to resolve the reference only when - the corresponding field is not present. Use 'Always' to resolve the - reference on every reconcile. - enum: - - Always - - IfNotPresent - type: string - type: object - required: - - name - type: object - publishConnectionDetailsTo: - description: |- - PublishConnectionDetailsTo specifies the connection secret config which - contains a name, metadata and a reference to secret store config to - which any connection details for this managed resource should be written. - Connection details frequently include the endpoint, username, - and password required to connect to the managed resource. - properties: - configRef: - default: - name: default - description: |- - SecretStoreConfigRef specifies which secret store config should be used - for this ConnectionSecret. - properties: - name: - description: Name of the referenced object. - type: string - policy: - description: Policies for referencing. - properties: - resolution: - default: Required - description: |- - Resolution specifies whether resolution of this reference is required. - The default is 'Required', which means the reconcile will fail if the - reference cannot be resolved. 'Optional' means this reference will be - a no-op if it cannot be resolved. - enum: - - Required - - Optional - type: string - resolve: - description: |- - Resolve specifies when this reference should be resolved. The default - is 'IfNotPresent', which will attempt to resolve the reference only when - the corresponding field is not present. Use 'Always' to resolve the - reference on every reconcile. - enum: - - Always - - IfNotPresent - type: string - type: object - required: - - name - type: object - metadata: - description: Metadata is the metadata for connection secret. - properties: - annotations: - additionalProperties: - type: string - description: |- - Annotations are the annotations to be added to connection secret. - - For Kubernetes secrets, this will be used as "metadata.annotations". - - It is up to Secret Store implementation for others store types. - type: object - labels: - additionalProperties: - type: string - description: |- - Labels are the labels/tags to be added to connection secret. - - For Kubernetes secrets, this will be used as "metadata.labels". - - It is up to Secret Store implementation for others store types. - type: object - type: - description: |- - Type is the SecretType for the connection secret. - - Only valid for Kubernetes Secret Stores. - type: string - type: object - name: - description: Name is the name of the connection secret. - type: string - required: - - name - type: object - writeConnectionSecretToRef: - description: |- - WriteConnectionSecretToReference specifies the namespace and name of a - Secret to which any connection details for this managed resource should - be written. Connection details frequently include the endpoint, username, - and password required to connect to the managed resource. - This field is planned to be replaced in a future release in favor of - PublishConnectionDetailsTo. Currently, both could be set independently - and connection details would be published to both without affecting - each other. - properties: - name: - description: Name of the secret. - type: string - namespace: - description: Namespace of the secret. - type: string - required: - - name - - namespace - type: object - required: - - forProvider - type: object - x-kubernetes-validations: - - message: spec.forProvider.name is a required parameter - rule: '!(''*'' in self.managementPolicies || ''Create'' in self.managementPolicies - || ''Update'' in self.managementPolicies) || has(self.forProvider.name) - || (has(self.initProvider) && has(self.initProvider.name))' - - message: spec.forProvider.serviceplanId is a required parameter - rule: '!(''*'' in self.managementPolicies || ''Create'' in self.managementPolicies - || ''Update'' in self.managementPolicies) || has(self.forProvider.serviceplanId) - || (has(self.initProvider) && has(self.initProvider.serviceplanId))' - - message: spec.forProvider.subaccountId is a required parameter - rule: '!(''*'' in self.managementPolicies || ''Create'' in self.managementPolicies - || ''Update'' in self.managementPolicies) || has(self.forProvider.subaccountId) - || (has(self.initProvider) && has(self.initProvider.subaccountId))' - status: - description: SubaccountServiceInstanceStatus defines the observed state - of SubaccountServiceInstance. - properties: - atProvider: - properties: - context: - description: |- - (String) Contextual data for the resource. - Contextual data for the resource. - type: string - createdDate: - description: |- - (String) The date and time when the resource was created in RFC3339 format. - The date and time when the resource was created in [RFC3339](https://www.ietf.org/rfc/rfc3339.txt) format. - type: string - dashboardUrl: - description: |- - based management UI for the service instance. - The URL of the web-based management UI for the service instance. - type: string - id: - description: (String) The ID of the service instance. - type: string - labels: - additionalProperties: - items: - type: string - type: array - description: |- - (Map of Set of String) The set of words or phrases assigned to the service instance. - The set of words or phrases assigned to the service instance. - type: object - lastModified: - description: |- - (String) The date and time when the resource was last modified in RFC3339 format. - The date and time when the resource was last modified in [RFC3339](https://www.ietf.org/rfc/rfc3339.txt) format. - type: string - name: - description: |- - (String) The name of the service instance. - The name of the service instance. - type: string - parameters: - description: |- - (String, Sensitive) The configuration parameters for the service instance. - The configuration parameters for the service instance. - type: string - platformId: - description: |- - (String) The platform ID. - The platform ID. - type: string - ready: - description: (Boolean) - type: boolean - referencedInstanceId: - description: |- - (String) The ID of the instance to which the service instance refers. - The ID of the instance to which the service instance refers. - type: string - serviceplanId: - description: |- - (String) The ID of the service plan. - The ID of the service plan. - type: string - shared: - description: |- - (Boolean) The configuration parameter for service instance sharing. Ensure that the instance is created with a plan that supports instance sharing. - The configuration parameter for service instance sharing. Ensure that the instance is created with a plan that supports instance sharing. - type: boolean - state: - description: |- - (String) The current state of the service instance. - The current state of the service instance. - type: string - subaccountId: - description: |- - (String) The ID of the subaccount. - The ID of the subaccount. - type: string - usable: - description: |- - (Boolean) Shows whether the resource can be used. - Shows whether the resource can be used. - type: boolean - type: object - conditions: - description: Conditions of the resource. - items: - description: A Condition that may apply to a resource. - properties: - lastTransitionTime: - description: |- - LastTransitionTime is the last time this condition transitioned from one - status to another. - format: date-time - type: string - message: - description: |- - A Message containing details about this condition's last transition from - one status to another, if any. - type: string - reason: - description: A Reason for this condition's last transition from - one status to another. - type: string - status: - description: Status of this condition; is it currently True, - False, or Unknown? - type: string - type: - description: |- - Type of this condition. At most one of each condition type may apply to - a resource at any point in time. - type: string - required: - - lastTransitionTime - - reason - - status - - type - type: object - type: array - x-kubernetes-list-map-keys: - - type - x-kubernetes-list-type: map - type: object - required: - - spec - type: object - served: true - storage: true - subresources: - status: {} diff --git a/package/crds/account.btp.sap.crossplane.io_subscriptions.yaml b/package/crds/account.btp.sap.crossplane.io_subscriptions.yaml index 5dae74d..759f270 100644 --- a/package/crds/account.btp.sap.crossplane.io_subscriptions.yaml +++ b/package/crds/account.btp.sap.crossplane.io_subscriptions.yaml @@ -155,7 +155,6 @@ spec: forProvider: description: SubscriptionParameters are the configurable fields of a Subscription. - format: byte properties: appName: description: AppName of the app to subscribe to @@ -169,10 +168,16 @@ spec: x-kubernetes-validations: - message: planName can't be updated once set rule: self == oldSelf + subscriptionParameters: + description: Subscription parameters allows you to add additional + parameters + format: byte + type: string required: - appName - planName - type: string + - subscriptionParameters + type: object managementPolicies: default: - '*' From 4f2080a62539ed1ccee1718ed146571017d7315b Mon Sep 17 00:00:00 2001 From: I545514 Date: Mon, 25 Nov 2024 15:49:24 +0100 Subject: [PATCH 5/5] chore: e2e tes --- test/e2e/testdata/crs/subscription/create_flow/subscription.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/test/e2e/testdata/crs/subscription/create_flow/subscription.yaml b/test/e2e/testdata/crs/subscription/create_flow/subscription.yaml index a5eb31c..79de69a 100644 --- a/test/e2e/testdata/crs/subscription/create_flow/subscription.yaml +++ b/test/e2e/testdata/crs/subscription/create_flow/subscription.yaml @@ -7,5 +7,6 @@ spec: forProvider: appName: auditlog-viewer planName: free + subscriptionParameters: {"key1": "value1","key2": {"key3":"value3"}} cloudManagementRef: name: e2e-sub-cis-local