From 4fa5b8ffc1364899885de03af3aecd885d95d6c8 Mon Sep 17 00:00:00 2001 From: Pavan <25031267+Pavan-SAP@users.noreply.github.com> Date: Fri, 24 Jul 2026 11:39:27 +0200 Subject: [PATCH] [Feat] Operator: Subscription handling revamped Split subscription aspects into independent resources. --- crds/sme.sap.com_subscriptionproviders.yaml | 123 +++++++++ crds/sme.sap.com_subscriptions.yaml | 125 ++++++++++ internal/controller/controller.go | 6 + internal/controller/informers.go | 23 +- .../controller/reconcile-capapplication.go | 76 +++++- .../reconcile-captenantoperation.go | 47 +++- internal/controller/reconcile-subscription.go | 172 +++++++++++++ .../reconcile-subscriptionprovider.go | 156 ++++++++++++ internal/controller/reconcile.go | 1 + pkg/apis/sme.sap.com/v1alpha1/register.go | 10 + pkg/apis/sme.sap.com/v1alpha1/types.go | 136 ++++++++++ pkg/apis/sme.sap.com/v1alpha1/utils.go | 15 ++ .../v1alpha1/zz_generated.deepcopy.go | 205 +++++++++++++++ .../sme.sap.com/v1alpha1/subscription.go | 236 ++++++++++++++++++ .../sme.sap.com/v1alpha1/subscriptioninfo.go | 49 ++++ .../v1alpha1/subscriptionprovider.go | 236 ++++++++++++++++++ .../v1alpha1/subscriptionproviderspec.go | 49 ++++ .../v1alpha1/subscriptionproviderstatus.go | 66 +++++ .../sme.sap.com/v1alpha1/subscriptionspec.go | 69 +++++ .../v1alpha1/subscriptionstatus.go | 66 +++++ pkg/client/applyconfiguration/utils.go | 14 ++ .../v1alpha1/fake/fake_sme.sap.com_client.go | 8 + .../v1alpha1/fake/fake_subscription.go | 42 ++++ .../fake/fake_subscriptionprovider.go | 42 ++++ .../v1alpha1/generated_expansion.go | 4 + .../v1alpha1/sme.sap.com_client.go | 10 + .../sme.sap.com/v1alpha1/subscription.go | 63 +++++ .../v1alpha1/subscriptionprovider.go | 65 +++++ .../informers/externalversions/generic.go | 4 + .../sme.sap.com/v1alpha1/interface.go | 14 ++ .../sme.sap.com/v1alpha1/subscription.go | 105 ++++++++ .../v1alpha1/subscriptionprovider.go | 105 ++++++++ .../v1alpha1/expansion_generated.go | 16 ++ .../sme.sap.com/v1alpha1/subscription.go | 59 +++++ .../v1alpha1/subscriptionprovider.go | 59 +++++ 35 files changed, 2471 insertions(+), 5 deletions(-) create mode 100644 crds/sme.sap.com_subscriptionproviders.yaml create mode 100644 crds/sme.sap.com_subscriptions.yaml create mode 100644 internal/controller/reconcile-subscription.go create mode 100644 internal/controller/reconcile-subscriptionprovider.go create mode 100644 pkg/client/applyconfiguration/sme.sap.com/v1alpha1/subscription.go create mode 100644 pkg/client/applyconfiguration/sme.sap.com/v1alpha1/subscriptioninfo.go create mode 100644 pkg/client/applyconfiguration/sme.sap.com/v1alpha1/subscriptionprovider.go create mode 100644 pkg/client/applyconfiguration/sme.sap.com/v1alpha1/subscriptionproviderspec.go create mode 100644 pkg/client/applyconfiguration/sme.sap.com/v1alpha1/subscriptionproviderstatus.go create mode 100644 pkg/client/applyconfiguration/sme.sap.com/v1alpha1/subscriptionspec.go create mode 100644 pkg/client/applyconfiguration/sme.sap.com/v1alpha1/subscriptionstatus.go create mode 100644 pkg/client/clientset/versioned/typed/sme.sap.com/v1alpha1/fake/fake_subscription.go create mode 100644 pkg/client/clientset/versioned/typed/sme.sap.com/v1alpha1/fake/fake_subscriptionprovider.go create mode 100644 pkg/client/clientset/versioned/typed/sme.sap.com/v1alpha1/subscription.go create mode 100644 pkg/client/clientset/versioned/typed/sme.sap.com/v1alpha1/subscriptionprovider.go create mode 100644 pkg/client/informers/externalversions/sme.sap.com/v1alpha1/subscription.go create mode 100644 pkg/client/informers/externalversions/sme.sap.com/v1alpha1/subscriptionprovider.go create mode 100644 pkg/client/listers/sme.sap.com/v1alpha1/subscription.go create mode 100644 pkg/client/listers/sme.sap.com/v1alpha1/subscriptionprovider.go diff --git a/crds/sme.sap.com_subscriptionproviders.yaml b/crds/sme.sap.com_subscriptionproviders.yaml new file mode 100644 index 00000000..d12be9e5 --- /dev/null +++ b/crds/sme.sap.com_subscriptionproviders.yaml @@ -0,0 +1,123 @@ +--- +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + annotations: + controller-gen.kubebuilder.io/version: v0.21.0 + name: subscriptionproviders.sme.sap.com +spec: + group: sme.sap.com + names: + kind: SubscriptionProvider + listKind: SubscriptionProviderList + plural: subscriptionproviders + shortNames: + - subpro + singular: subscriptionprovider + scope: Namespaced + versions: + - additionalPrinterColumns: + - jsonPath: .spec.appName + name: SubscriptionProvider + type: string + - jsonPath: .metadata.creationTimestamp + name: Age + type: date + - jsonPath: .status.state + name: State + type: string + name: v1alpha1 + schema: + openAPIV3Schema: + properties: + apiVersion: + type: string + kind: + type: string + metadata: + type: object + spec: + properties: + appName: + type: string + providerSubaccountId: + type: string + subscriptionInfo: + properties: + authSecret: + type: string + subscriptionSecret: + type: string + type: + type: string + required: + - subscriptionSecret + - type + type: object + required: + - appName + - providerSubaccountId + - subscriptionInfo + type: object + status: + properties: + conditions: + items: + properties: + lastTransitionTime: + format: date-time + type: string + message: + maxLength: 32768 + type: string + observedGeneration: + format: int64 + minimum: 0 + type: integer + reason: + maxLength: 1024 + minLength: 1 + pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$ + type: string + status: + enum: + - "True" + - "False" + - Unknown + type: string + type: + maxLength: 316 + pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$ + type: string + required: + - lastTransitionTime + - message + - reason + - status + - type + type: object + type: array + dependencies: + type: string + observedGeneration: + format: int64 + type: integer + state: + enum: + - "" + - Ready + - Error + - Processing + - Deleting + type: string + required: + - state + type: object + required: + - metadata + - spec + type: object + served: true + storage: true + subresources: + status: {} diff --git a/crds/sme.sap.com_subscriptions.yaml b/crds/sme.sap.com_subscriptions.yaml new file mode 100644 index 00000000..67d9df03 --- /dev/null +++ b/crds/sme.sap.com_subscriptions.yaml @@ -0,0 +1,125 @@ +--- +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + annotations: + controller-gen.kubebuilder.io/version: v0.21.0 + name: subscriptions.sme.sap.com +spec: + group: sme.sap.com + names: + kind: Subscription + listKind: SubscriptionList + plural: subscriptions + shortNames: + - sub + singular: subscription + scope: Namespaced + versions: + - additionalPrinterColumns: + - jsonPath: .spec.appName + name: App + type: string + - jsonPath: .spec.subscriptionGuid + name: Guid + type: string + - jsonPath: .metadata.creationTimestamp + name: Age + type: date + - jsonPath: .status.state + name: State + type: string + - jsonPath: .status.url + name: Url + type: string + name: v1alpha1 + schema: + openAPIV3Schema: + properties: + apiVersion: + type: string + kind: + type: string + metadata: + type: object + spec: + properties: + appName: + type: string + providerSubaccountId: + type: string + subscriptionGuid: + type: string + subscriptionRequestPayload: + type: string + tenantId: + type: string + required: + - appName + - providerSubaccountId + - subscriptionGuid + - subscriptionRequestPayload + - tenantId + type: object + status: + properties: + conditions: + items: + properties: + lastTransitionTime: + format: date-time + type: string + message: + maxLength: 32768 + type: string + observedGeneration: + format: int64 + minimum: 0 + type: integer + reason: + maxLength: 1024 + minLength: 1 + pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$ + type: string + status: + enum: + - "True" + - "False" + - Unknown + type: string + type: + maxLength: 316 + pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$ + type: string + required: + - lastTransitionTime + - message + - reason + - status + - type + type: object + type: array + observedGeneration: + format: int64 + type: integer + state: + enum: + - "" + - Ready + - Error + - Processing + - Deleting + type: string + url: + type: string + required: + - state + type: object + required: + - metadata + - spec + type: object + served: true + storage: true + subresources: + status: {} diff --git a/internal/controller/controller.go b/internal/controller/controller.go index 07842168..965fad8f 100644 --- a/internal/controller/controller.go +++ b/internal/controller/controller.go @@ -87,6 +87,8 @@ func NewController(client kubernetes.Interface, crdClient versioned.Interface, i ResourceCAPTenantOperation: workqueue.NewTypedRateLimitingQueueWithConfig(customRateLimiter(), workqueue.TypedRateLimitingQueueConfig[QueueItem]{Name: KindMap[ResourceCAPTenantOperation]}), ResourceDomain: workqueue.NewTypedRateLimitingQueueWithConfig(workqueue.DefaultTypedControllerRateLimiter[QueueItem](), workqueue.TypedRateLimitingQueueConfig[QueueItem]{Name: KindMap[ResourceDomain]}), ResourceClusterDomain: workqueue.NewTypedRateLimitingQueueWithConfig(workqueue.DefaultTypedControllerRateLimiter[QueueItem](), workqueue.TypedRateLimitingQueueConfig[QueueItem]{Name: KindMap[ResourceClusterDomain]}), + ResourceSubscriptionProvider: workqueue.NewTypedRateLimitingQueueWithConfig(workqueue.DefaultTypedControllerRateLimiter[QueueItem](), workqueue.TypedRateLimitingQueueConfig[QueueItem]{Name: KindMap[ResourceSubscriptionProvider]}), + ResourceSubscription: workqueue.NewTypedRateLimitingQueueWithConfig(customRateLimiter(), workqueue.TypedRateLimitingQueueConfig[QueueItem]{Name: KindMap[ResourceSubscription]}), } // Use 30mins as the default Resync interval for kube / proprietary resources @@ -310,6 +312,10 @@ func (c *Controller) processQueueItem(ctx context.Context, key, workerId int) er result, err = c.reconcileDomain(ctx, item, attempts) case ResourceClusterDomain: result, err = c.reconcileClusterDomain(ctx, item, attempts) + case ResourceSubscriptionProvider: + result, err = c.reconcileSubscriptionProvider(ctx, item, attempts) + case ResourceSubscription: + result, err = c.reconcileSubscription(ctx, item, attempts) default: err = errors.New("unidentified queue item") skipItem = true diff --git a/internal/controller/informers.go b/internal/controller/informers.go index 9ec4d3bb..f2d38dad 100644 --- a/internal/controller/informers.go +++ b/internal/controller/informers.go @@ -24,6 +24,8 @@ const ( ResourceCAPTenantOperation ResourceDomain ResourceClusterDomain + ResourceSubscriptionProvider + ResourceSubscription ResourceSecret ResourceJob ResourceGateway @@ -45,6 +47,8 @@ var ( ResourceCAPTenantOperation: v1alpha1.CAPTenantOperationKind, ResourceDomain: v1alpha1.DomainKind, ResourceClusterDomain: v1alpha1.ClusterDomainKind, + ResourceSubscriptionProvider: v1alpha1.SubscriptionProviderKind, + ResourceSubscription: v1alpha1.SubscriptionKind, } ) @@ -56,10 +60,12 @@ type NamespacedResourceKey struct { var QueueMapping map[int]map[int]string = map[int]map[int]string{ ResourceCAPApplication: {ResourceCAPApplication: v1alpha1.CAPApplicationKind}, ResourceCAPApplicationVersion: {ResourceCAPApplicationVersion: v1alpha1.CAPApplicationVersionKind, ResourceCAPApplication: v1alpha1.CAPApplicationKind}, - ResourceCAPTenant: {ResourceCAPTenant: v1alpha1.CAPTenantKind, ResourceCAPApplication: v1alpha1.CAPApplicationKind}, + ResourceCAPTenant: {ResourceCAPTenant: v1alpha1.CAPTenantKind, ResourceCAPApplication: v1alpha1.CAPApplicationKind, ResourceSubscription: v1alpha1.SubscriptionKind}, ResourceCAPTenantOperation: {ResourceCAPTenantOperation: v1alpha1.CAPTenantOperationKind, ResourceCAPTenant: v1alpha1.CAPTenantKind}, ResourceDomain: {ResourceDomain: v1alpha1.DomainKind}, ResourceClusterDomain: {ResourceClusterDomain: v1alpha1.ClusterDomainKind}, + ResourceSubscriptionProvider: {ResourceSubscriptionProvider: v1alpha1.SubscriptionProviderKind}, + ResourceSubscription: {ResourceSubscription: v1alpha1.SubscriptionKind}, ResourceJob: {ResourceCAPTenantOperation: v1alpha1.CAPTenantOperationKind, ResourceCAPApplicationVersion: v1alpha1.CAPApplicationVersionKind}, ResourceGateway: {ResourceDomain: v1alpha1.DomainKind, ResourceClusterDomain: v1alpha1.ClusterDomainKind}, ResourceCertificate: {ResourceDomain: v1alpha1.DomainKind, ResourceClusterDomain: v1alpha1.ClusterDomainKind}, @@ -80,23 +86,28 @@ func (c *Controller) initializeInformers() { c.registerCAPTenantOperationListeners() c.registerDomainListeners() c.registerClusterDomainListeners() + c.registerSubscriptionProviderListeners() + c.registerSubscriptionListeners() c.registerJobListeners() c.registerSecretListeners() c.registerGatewayListeners() c.registerVirtualServiceListeners() c.registerDestinationRuleListeners() + switch certificateManager() { case certManagerGardener: c.registerGardenerCertificateListeners() case certManagerCertManagerIO: c.registerCertManagerCertificateListeners() } + switch dnsManager() { case dnsManagerGardener: c.registerGardenerDNSEntrytListeners() case dnsManagerKubernetes: // no activity needed on our side so far } + klog.InfoS("informers initialized") } @@ -148,6 +159,16 @@ func (c *Controller) registerDomainListeners() { AddEventHandler(c.getEventHandlerFuncsForResource(ResourceDomain)) } +func (c *Controller) registerSubscriptionProviderListeners() { + c.crdInformerFactory.Sme().V1alpha1().SubscriptionProviders().Informer(). + AddEventHandler(c.getEventHandlerFuncsForResource(ResourceSubscriptionProvider)) +} + +func (c *Controller) registerSubscriptionListeners() { + c.crdInformerFactory.Sme().V1alpha1().Subscriptions().Informer(). + AddEventHandler(c.getEventHandlerFuncsForResource(ResourceSubscription)) +} + func (c *Controller) registerJobListeners() { c.kubeInformerFactory.Batch().V1().Jobs().Informer(). AddEventHandler(c.getEventHandlerFuncsForResource(ResourceJob)) diff --git a/internal/controller/reconcile-capapplication.go b/internal/controller/reconcile-capapplication.go index 2a65dc39..9aabfc55 100644 --- a/internal/controller/reconcile-capapplication.go +++ b/internal/controller/reconcile-capapplication.go @@ -29,12 +29,14 @@ const ( CAPApplicationEventMissingIngressGatewayInfo = "MissingIngressGatewayInfo" CAPApplicationEventProviderTenantCreated = "ProviderTenantCreated" CAPApplicationEventNewCAVTriggeredTenantUpgrade = "NewCAVTriggeredTenantUpgrade" + CAPApplicationEventSubscriptionProviderCreated = "SubscriptionProviderCreated" ) const ( - EventActionProcessingSecrets = "ProcessingSecrets" - EventActionProviderTenantProcessing = "ProviderTenantProcessing" - EventActionCheckForVersion = "CheckForVersion" + EventActionProcessingSecrets = "ProcessingSecrets" + EventActionProviderTenantProcessing = "ProviderTenantProcessing" + EventActionSubscriptionProviderProcessing = "SubscriptionProviderProcessing" + EventActionCheckForVersion = "CheckForVersion" ) func (c *Controller) reconcileCAPApplication(ctx context.Context, item QueueItem, _ int) (result *ReconcileResult, err error) { @@ -131,6 +133,11 @@ func (c *Controller) handleCAPApplicationDependentResources(ctx context.Context, } // We can already update LatestVersionReady to "true" at this point in time, but as this method is called several times, we do not do it here (during initial Provisioning as CA itself is may not be Consistent) + // Create SubscriptionProvider resource for non services only scenario if not already created + if err = c.resolveSubscriptionProvider(ctx, ca); err != nil { + return + } + // step 4 - validate provider tenant, create if not available if processing, err = c.reconcileCAPApplicationProviderTenant(ctx, ca, cav); err != nil || processing { return @@ -495,6 +502,69 @@ func (c *Controller) createProviderTenant(ctx context.Context, ca *v1alpha1.CAPA return } +func (c *Controller) resolveSubscriptionProvider(ctx context.Context, ca *v1alpha1.CAPApplication) error { + if ca.IsServicesOnly() { + return nil + } + _, err := c.crdInformerFactory.Sme().V1alpha1().SubscriptionProviders().Lister().SubscriptionProviders(ca.Namespace).Get(ca.Name) + if err != nil { + if !k8sErrors.IsNotFound(err) { + ca.SetStatusWithReadyCondition(v1alpha1.CAPApplicationStateError, metav1.ConditionFalse, "SubscriptionProviderError", err.Error()) + return err + } + return c.createSubscriptionProvider(ctx, ca) + } + return nil +} + +func (c *Controller) createSubscriptionProvider(ctx context.Context, ca *v1alpha1.CAPApplication) error { + var subscriptionInfo v1alpha1.SubscriptionInfo + for _, svc := range ca.Spec.BTP.Services { + switch svc.Class { + case "subscription-manager": + subscriptionInfo.Type = "subscription-manager" + subscriptionInfo.SubscriptionSecret = svc.Secret + case "saas-registry": + subscriptionInfo.Type = "saas-registry" + subscriptionInfo.SubscriptionSecret = svc.Secret + if xsuaaInfo := util.GetXSUAAInfo(ca.Spec.BTP.Services, ca); xsuaaInfo != nil { + subscriptionInfo.AuthSecret = xsuaaInfo.Secret + } + } + if subscriptionInfo.SubscriptionSecret != "" { + break + } + } + + labels := map[string]string{ + LabelAppIdHash: sha1Sum(ca.Spec.ProviderSubaccountId, ca.Spec.BTPAppName), + } + + util.LogInfo("Creating SubscriptionProvider", string(Processing), ca, nil) + subPro, err := c.crdClient.SmeV1alpha1().SubscriptionProviders(ca.Namespace).Create( + ctx, &v1alpha1.SubscriptionProvider{ + ObjectMeta: metav1.ObjectMeta{ + Name: ca.Name, + Namespace: ca.Namespace, + Labels: labels, + OwnerReferences: []metav1.OwnerReference{ + *metav1.NewControllerRef(ca, v1alpha1.SchemeGroupVersion.WithKind(v1alpha1.CAPApplicationKind)), + }, + }, + Spec: v1alpha1.SubscriptionProviderSpec{ + AppName: ca.Spec.BTPAppName, + ProviderSubaccountID: ca.Spec.ProviderSubaccountId, + SubscriptionInfo: subscriptionInfo, + }, + }, metav1.CreateOptions{}) + if err != nil { + ca.SetStatusWithReadyCondition(v1alpha1.CAPApplicationStateError, metav1.ConditionFalse, "SubscriptionProviderError", err.Error()) + return err + } + c.Event(ca, subPro, corev1.EventTypeNormal, CAPApplicationEventSubscriptionProviderCreated, EventActionSubscriptionProviderProcessing, fmt.Sprintf("created SubscriptionProvider %s.%s", subPro.Namespace, subPro.Name)) + return nil +} + func (c *Controller) handleCAPApplicationDeletion(ctx context.Context, ca *v1alpha1.CAPApplication) (*ReconcileResult, error) { var err error diff --git a/internal/controller/reconcile-captenantoperation.go b/internal/controller/reconcile-captenantoperation.go index 9e801210..4ffe4f5a 100644 --- a/internal/controller/reconcile-captenantoperation.go +++ b/internal/controller/reconcile-captenantoperation.go @@ -417,6 +417,16 @@ func (c *Controller) initiateJobForCAPTenantOperationStep(ctx context.Context, c params.providerSubdomain = relatedResources.CAPApplication.Spec.Provider.SubDomain } + // For provisioning, resolve the subscription request payload to be passed to the tenant operation job + if ctop.Spec.Operation == v1alpha1.CAPTenantOperationTypeProvisioning { + payload, err := c.getSubscriptionRequestPayload(ctop) + if err != nil { + util.LogError(err, "Failed to resolve subscription request payload", string(Processing), ctop, nil, "tenantId", ctop.Spec.TenantId, "operation", ctop.Spec.Operation) + return nil, err + } + params.subscriptionPayload = payload + } + var job *batchv1.Job if ctop.Spec.Steps[*ctop.Status.CurrentStep-1].Type == v1alpha1.JobTenantOperation { job, err = c.createTenantOperationJob(ctx, ctop, workload, params) @@ -449,6 +459,7 @@ type jobCreateParams struct { providerTenantId string providerSubdomain string tenantType string + subscriptionPayload string } func (c *Controller) createTenantOperationJob(ctx context.Context, ctop *v1alpha1.CAPTenantOperation, workload *v1alpha1.WorkloadDetails, params *jobCreateParams) (*batchv1.Job, error) { @@ -630,7 +641,13 @@ func getCTOPEnv(params *jobCreateParams, ctop *v1alpha1.CAPTenantOperation, step switch ctop.Spec.Operation { case v1alpha1.CAPTenantOperationTypeProvisioning: operation = "subscribe" - env = append(env, corev1.EnvVar{Name: EnvCAPOpSubscriptionPayload, ValueFrom: &corev1.EnvVarSource{SecretKeyRef: &corev1.SecretKeySelector{LocalObjectReference: corev1.LocalObjectReference{Name: ctop.Annotations[AnnotationSubscriptionContextSecret]}, Key: SubscriptionContext}}}) + // Prefer the subscription request payload resolved from the Subscription resource. + // Fall back to the (deprecated) subscription context secret for provider tenants which have no Subscription. + if params.subscriptionPayload != "" { + env = append(env, corev1.EnvVar{Name: EnvCAPOpSubscriptionPayload, Value: params.subscriptionPayload}) + } else if ctop.Annotations[AnnotationSubscriptionContextSecret] != "" { + env = append(env, corev1.EnvVar{Name: EnvCAPOpSubscriptionPayload, ValueFrom: &corev1.EnvVarSource{SecretKeyRef: &corev1.SecretKeySelector{LocalObjectReference: corev1.LocalObjectReference{Name: ctop.Annotations[AnnotationSubscriptionContextSecret]}, Key: SubscriptionContext}}}) + } case v1alpha1.CAPTenantOperationTypeUpgrade: operation = "upgrade" default: // deprovisioning @@ -642,6 +659,34 @@ func getCTOPEnv(params *jobCreateParams, ctop *v1alpha1.CAPTenantOperation, step return env } +// getSubscriptionRequestPayload resolves the subscription request payload for a tenant operation by locating the +// Subscription resource that owns the tenant (identified via the subscription-guid label) and returning its +// SubscriptionRequestPayload from the spec. Returns an empty string (no error) when no Subscription is found, +// allowing the caller to fall back to the (deprecated) subscription context secret. +func (c *Controller) getSubscriptionRequestPayload(ctop *v1alpha1.CAPTenantOperation) (string, error) { + subscriptionGUID := ctop.Labels[MetadataSubscriptionGUID] + if subscriptionGUID == "" { + return "", nil + } + + selector, err := labels.ValidatedSelectorFromSet(map[string]string{ + MetadataSubscriptionGUID: subscriptionGUID, + }) + if err != nil { + return "", err + } + + subscriptions, err := c.crdInformerFactory.Sme().V1alpha1().Subscriptions().Lister().Subscriptions(ctop.Namespace).List(selector) + if err != nil { + return "", err + } + if len(subscriptions) == 0 { + return "", nil + } + // Assume only one Subscription matches the subscriptionGUID + return subscriptions[0].Spec.SubscriptionRequestPayload, nil +} + // Collect tenant operation metrics based on the status of the tenant operation func collectTenantOperationMetrics(ctop *v1alpha1.CAPTenantOperation) { relevantAppIdHash := ctop.Labels[LabelAppIdHash] diff --git a/internal/controller/reconcile-subscription.go b/internal/controller/reconcile-subscription.go new file mode 100644 index 00000000..2ba5b0ca --- /dev/null +++ b/internal/controller/reconcile-subscription.go @@ -0,0 +1,172 @@ +/* +SPDX-FileCopyrightText: 2026 SAP SE or an SAP affiliate company and cap-operator contributors +SPDX-License-Identifier: Apache-2.0 +*/ + +package controller + +import ( + "context" + "fmt" + + "github.com/sap/cap-operator/internal/util" + "github.com/sap/cap-operator/pkg/apis/sme.sap.com/v1alpha1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/labels" +) + +func (c *Controller) reconcileSubscription(ctx context.Context, item QueueItem, _ int) (result *ReconcileResult, err error) { + cached, err := c.crdInformerFactory.Sme().V1alpha1().Subscriptions().Lister().Subscriptions(item.ResourceKey.Namespace).Get(item.ResourceKey.Name) + if err != nil { + return nil, handleOperatorResourceErrors(err) + } + sub := cached.DeepCopy() + + defer func() { + if statusErr := c.updateSubscriptionStatus(ctx, sub); statusErr != nil && err == nil { + err = statusErr + } + }() + + // Ensure the subscription-guid label is set on the Subscription (used to correlate it with tenant operations) + if sub.Labels[MetadataSubscriptionGUID] != sub.Spec.SubscriptionGuid { + updated, updateErr := c.updateSubscriptionLabels(ctx, sub) + if updateErr != nil { + return nil, updateErr + } + *sub = *updated + } + + // Start by ensuring the Subscription is in the Processing state before doing any work + if sub.Status.State != v1alpha1.SubscriptionStateProcessing { + sub.SetStatusWithReadyCondition(v1alpha1.SubscriptionStateProcessing, metav1.ConditionFalse, "Processing", "Processing subscription") + sub.SetStatusCondition(string(v1alpha1.ConditionTypeTenantReady), metav1.ConditionFalse, "Processing", "Processing subscription") + result = NewReconcileResultWithResource(ResourceSubscription, sub.Name, sub.Namespace, 0) + return + } + + // Identify (or create) the CAPTenant owned by this Subscription + tenant, err := c.getOrCreateSubscriptionTenant(ctx, sub) + if err != nil { + sub.SetStatusWithReadyCondition(v1alpha1.SubscriptionStateError, metav1.ConditionFalse, "TenantError", err.Error()) + return + } + + // Wait for the owned tenant to become ready + if !isCROConditionReady(tenant.Status.GenericStatus) { + if tenant.Status.State == v1alpha1.CAPTenantStateProvisioningError || tenant.Status.State == v1alpha1.CAPTenantStateUpgradeError { + err = fmt.Errorf("tenant %s.%s in state %s", tenant.Namespace, tenant.Name, tenant.Status.State) + sub.SetStatusCondition(string(v1alpha1.ConditionTypeTenantReady), metav1.ConditionFalse, "TenantError", err.Error()) + sub.SetStatusWithReadyCondition(v1alpha1.SubscriptionStateError, metav1.ConditionFalse, "TenantError", err.Error()) + return + } + + msg := fmt.Sprintf("waiting for tenant %s.%s to be ready", tenant.Namespace, tenant.Name) + util.LogInfo("Waiting for tenant to be ready", string(Processing), sub, tenant, "tenantId", sub.Spec.TenantId) + sub.SetStatusCondition(string(v1alpha1.ConditionTypeTenantReady), metav1.ConditionFalse, "TenantNotReady", msg) + sub.SetStatusWithReadyCondition(v1alpha1.SubscriptionStateProcessing, metav1.ConditionFalse, "TenantNotReady", msg) + result = NewReconcileResultWithResource(ResourceSubscription, sub.Name, sub.Namespace, defaultDependantDelay) + return + } + + // Tenant is ready --> mark the Subscription ready + sub.SetStatusCondition(string(v1alpha1.ConditionTypeTenantReady), metav1.ConditionTrue, "TenantReady", "Tenant is ready") + sub.SetStatusWithReadyCondition(v1alpha1.SubscriptionStateReady, metav1.ConditionTrue, "Ready", "Subscription is ready") + return +} + +// getOrCreateSubscriptionTenant identifies an existing CAPTenant for the subscription (via subscriptionGuid) or creates one owned by the Subscription. +func (c *Controller) getOrCreateSubscriptionTenant(ctx context.Context, sub *v1alpha1.Subscription) (*v1alpha1.CAPTenant, error) { + // First check if a tenant already exists for this subscription (identified by subscriptionGuid) + tenant, err := c.getSubscriptionTenant(sub) + if err != nil { + return nil, err + } + if tenant != nil { + return tenant, nil + } + + // No tenant found; create one using the providerSubaccountId + btpAppName to identify the owning application (AppIdHash) + return c.createSubscriptionTenant(ctx, sub) +} + +// getSubscriptionTenant looks up the CAPTenant for the subscription using the subscriptionGuid (and tenantId) labels. +func (c *Controller) getSubscriptionTenant(sub *v1alpha1.Subscription) (*v1alpha1.CAPTenant, error) { + selector, err := labels.ValidatedSelectorFromSet(map[string]string{ + MetadataSubscriptionGUID: sub.Spec.SubscriptionGuid, + LabelTenantId: sub.Spec.TenantId, + }) + if err != nil { + return nil, err + } + + tenants, err := c.crdInformerFactory.Sme().V1alpha1().CAPTenants().Lister().CAPTenants(sub.Namespace).List(selector) + if err != nil { + return nil, err + } + if len(tenants) == 0 { + return nil, nil + } + // Assume only one tenant matches the selector + return tenants[0], nil +} + +// createSubscriptionTenant creates a CAPTenant (owned by the Subscription) using the providerSubaccountId and btpAppName to derive the AppIdHash label/annotation. +func (c *Controller) createSubscriptionTenant(ctx context.Context, sub *v1alpha1.Subscription) (*v1alpha1.CAPTenant, error) { + appIdHash := sha1Sum(sub.Spec.ProviderSubaccountId, sub.Spec.AppName) + + util.LogInfo("Creating tenant for subscription", string(Processing), sub, nil, "tenantId", sub.Spec.TenantId, "subscriptionGuid", sub.Spec.SubscriptionGuid) + + tenant, err := c.crdClient.SmeV1alpha1().CAPTenants(sub.Namespace).Create(ctx, &v1alpha1.CAPTenant{ + ObjectMeta: metav1.ObjectMeta{ + GenerateName: sub.Name + "-", + Namespace: sub.Namespace, + OwnerReferences: []metav1.OwnerReference{ + *metav1.NewControllerRef(sub, v1alpha1.SchemeGroupVersion.WithKind(v1alpha1.SubscriptionKind)), + }, + Annotations: map[string]string{ + AnnotationAppId: fmt.Sprintf("%s.%s", sub.Spec.ProviderSubaccountId, sub.Spec.AppName), + MetadataSubscriptionGUID: sub.Spec.SubscriptionGuid, + }, + Labels: map[string]string{ + LabelAppIdHash: appIdHash, + LabelTenantId: sub.Spec.TenantId, + LabelTenantType: TenantTypeConsumer, + MetadataSubscriptionGUID: sub.Spec.SubscriptionGuid, + }, + }, + Spec: v1alpha1.CAPTenantSpec{ + BTPTenantIdentification: v1alpha1.BTPTenantIdentification{ + TenantId: sub.Spec.TenantId, + }, + }, + }, metav1.CreateOptions{}) + if err != nil { + util.LogError(err, "Error creating tenant for subscription", string(Processing), sub, nil, "tenantId", sub.Spec.TenantId) + return nil, err + } + + util.LogInfo("Tenant created for subscription", string(Processing), sub, tenant, "tenantId", sub.Spec.TenantId) + return tenant, nil +} + +// updateSubscriptionLabels ensures the subscription-guid label is set on the Subscription resource itself +// (used to correlate it with the CAPTenant / CAPTenantOperation that carry the same label). +func (c *Controller) updateSubscriptionLabels(ctx context.Context, sub *v1alpha1.Subscription) (*v1alpha1.Subscription, error) { + if sub.Labels == nil { + sub.Labels = map[string]string{} + } + sub.Labels[MetadataSubscriptionGUID] = sub.Spec.SubscriptionGuid + return c.crdClient.SmeV1alpha1().Subscriptions(sub.Namespace).Update(ctx, sub, metav1.UpdateOptions{}) +} + +func (c *Controller) updateSubscriptionStatus(ctx context.Context, sub *v1alpha1.Subscription) error { + if isDeletionImminent(&sub.ObjectMeta) { + return nil + } + updated, err := c.crdClient.SmeV1alpha1().Subscriptions(sub.Namespace).UpdateStatus(ctx, sub, metav1.UpdateOptions{}) + if updated != nil { + *sub = *updated + } + return err +} diff --git a/internal/controller/reconcile-subscriptionprovider.go b/internal/controller/reconcile-subscriptionprovider.go new file mode 100644 index 00000000..5cbe9d18 --- /dev/null +++ b/internal/controller/reconcile-subscriptionprovider.go @@ -0,0 +1,156 @@ +/* +SPDX-FileCopyrightText: 2026 SAP SE or an SAP affiliate company and cap-operator contributors +SPDX-License-Identifier: Apache-2.0 +*/ + +package controller + +import ( + "context" + "encoding/json" + "fmt" + + "github.com/sap/cap-operator/internal/util" + "github.com/sap/cap-operator/pkg/apis/sme.sap.com/v1alpha1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +type serviceMetaInfo struct { + Plan string `json:"plan"` + Credentials serviceCredentials `json:"credentials"` +} + +type serviceCredentials struct { + XSAppName string `json:"xsappname"` + SaasRegistryEnabled bool `json:"saasregistryenabled"` + UAA *struct { + XSAppName string `json:"xsappname"` + } `json:"uaa"` +} + +func (c *serviceCredentials) xsAppName() string { + if c.XSAppName != "" { + return c.XSAppName + } + if c.UAA != nil && c.UAA.XSAppName != "" { + return c.UAA.XSAppName + } + return "" +} + +func (c *Controller) reconcileSubscriptionProvider(ctx context.Context, item QueueItem, _ int) (result *ReconcileResult, err error) { + cached, err := c.crdInformerFactory.Sme().V1alpha1().SubscriptionProviders().Lister().SubscriptionProviders(item.ResourceKey.Namespace).Get(item.ResourceKey.Name) + if err != nil { + return nil, handleOperatorResourceErrors(err) + } + subPro := cached.DeepCopy() + + defer func() { + if statusErr := c.updateSubscriptionProviderStatus(ctx, subPro); statusErr != nil && err == nil { + err = statusErr + } + }() + + if subPro.Status.State != v1alpha1.SubscriptionProviderStateProcessing { + subPro.SetStatusWithReadyCondition(v1alpha1.SubscriptionProviderStateProcessing, metav1.ConditionFalse, "Processing", "Processing subscription provider") + result = NewReconcileResultWithResource(ResourceSubscriptionProvider, subPro.Name, subPro.Namespace, 0) + return + } + + // Fetch owning CAPApplication + ownerRef, ok := getOwnerByKind(subPro.GetOwnerReferences(), v1alpha1.CAPApplicationKind) + if !ok { + err = fmt.Errorf("SubscriptionProvider %s.%s has no owning CAPApplication", subPro.Namespace, subPro.Name) + subPro.SetStatusWithReadyCondition(v1alpha1.SubscriptionProviderStateError, metav1.ConditionFalse, "MissingOwner", err.Error()) + return + } + ca, err := c.crdInformerFactory.Sme().V1alpha1().CAPApplications().Lister().CAPApplications(subPro.Namespace).Get(ownerRef.Name) + if err != nil { + subPro.SetStatusWithReadyCondition(v1alpha1.SubscriptionProviderStateError, metav1.ConditionFalse, "OwnerNotFound", err.Error()) + return + } + + dependencies, err := c.buildSubscriptionDependencies(ca) + if err != nil { + subPro.SetStatusWithReadyCondition(v1alpha1.SubscriptionProviderStateError, metav1.ConditionFalse, "DependencyResolutionFailed", err.Error()) + return + } + + subPro.Status.Dependencies = dependencies + subPro.SetStatusWithReadyCondition(v1alpha1.SubscriptionProviderStateReady, metav1.ConditionTrue, "Ready", "Subscription dependencies resolved") + return +} + +func (c *Controller) buildSubscriptionDependencies(ca *v1alpha1.CAPApplication) (string, error) { + var dependenciesArray []map[string]string + for _, service := range ca.Spec.BTP.Services { + serviceCredInfo, err := util.ReadServiceCredentialsFromSecret[serviceMetaInfo](&service, ca.Namespace, c.kubeClient, true) + if err != nil { + util.LogError(err, "Failed to read secret for service", string(Processing), ca, nil, "service", service.Name, "secret", service.Secret) + return "", err + } + + dep := getSubscriptionProviderServiceDependency(service, serviceCredInfo) + if dep != nil { + dependenciesArray = append(dependenciesArray, dep) + } + } + + if len(dependenciesArray) == 0 { + util.LogInfo("No subscription dependencies found", string(Processing), ca, nil) + return "", nil + } + + b, err := json.Marshal(dependenciesArray) + if err != nil { + return "", fmt.Errorf("failed to marshal subscription dependencies: %w", err) + } + + util.LogInfo("Subscription dependencies resolved", string(Processing), ca, nil, "count", len(dependenciesArray), "dependencies", string(b)) + return string(b), nil +} + +func getSubscriptionProviderServiceDependency(service v1alpha1.ServiceInfo, serviceCredInfo *serviceMetaInfo) map[string]string { + if isSubscriptionServiceRelevantForDependencies(service, serviceCredInfo) { + if name := serviceCredInfo.Credentials.xsAppName(); name != "" { + if isSubscriptionSpecialDependency(service, serviceCredInfo) { + return map[string]string{ + "appName": service.Class, + "appId": name, + } + } else { + return map[string]string{ + "xsappname": name, + } + } + } + } + return nil +} + +func isSubscriptionServiceRelevantForDependencies(serviceInfo v1alpha1.ServiceInfo, creds *serviceMetaInfo) bool { + if serviceInfo.GetSubscriptionDependency() == v1alpha1.SubscriptionDependencyAlways { + return true + } + if serviceInfo.GetSubscriptionDependency() == v1alpha1.SubscriptionDependencyAuto { + return isSubscriptionSpecialDependency(serviceInfo, creds) || creds.Credentials.SaasRegistryEnabled + } + return false +} + +func isSubscriptionSpecialDependency(serviceInfo v1alpha1.ServiceInfo, creds *serviceMetaInfo) bool { + return serviceInfo.Class == "destination" || + serviceInfo.Class == "connectivity" || + (serviceInfo.Class == "auditlog" && creds.Plan == "oauth2") +} + +func (c *Controller) updateSubscriptionProviderStatus(ctx context.Context, subPro *v1alpha1.SubscriptionProvider) error { + if isDeletionImminent(&subPro.ObjectMeta) { + return nil + } + updated, err := c.crdClient.SmeV1alpha1().SubscriptionProviders(subPro.Namespace).UpdateStatus(ctx, subPro, metav1.UpdateOptions{}) + if updated != nil { + *subPro = *updated + } + return err +} diff --git a/internal/controller/reconcile.go b/internal/controller/reconcile.go index 4f829395..49657c7b 100644 --- a/internal/controller/reconcile.go +++ b/internal/controller/reconcile.go @@ -75,6 +75,7 @@ const ( ) const TenantTypeProvider = "provider" +const TenantTypeConsumer = "consumer" const ( EnvCAPOpAppVersion = "CAPOP_APP_VERSION" diff --git a/pkg/apis/sme.sap.com/v1alpha1/register.go b/pkg/apis/sme.sap.com/v1alpha1/register.go index 3690f750..2ed81e81 100644 --- a/pkg/apis/sme.sap.com/v1alpha1/register.go +++ b/pkg/apis/sme.sap.com/v1alpha1/register.go @@ -68,6 +68,16 @@ func addKnownTypes(scheme *runtime.Scheme) error { &ClusterDomain{}, &ClusterDomainList{}, ) + scheme.AddKnownTypes( + SchemeGroupVersion, + &SubscriptionProvider{}, + &SubscriptionProviderList{}, + ) + scheme.AddKnownTypes( + SchemeGroupVersion, + &Subscription{}, + &SubscriptionList{}, + ) metaV1.AddToGroupVersion(scheme, SchemeGroupVersion) return nil } diff --git a/pkg/apis/sme.sap.com/v1alpha1/types.go b/pkg/apis/sme.sap.com/v1alpha1/types.go index fd737af0..931fe0a7 100644 --- a/pkg/apis/sme.sap.com/v1alpha1/types.go +++ b/pkg/apis/sme.sap.com/v1alpha1/types.go @@ -30,6 +30,10 @@ const ( DomainResource = "domains" ClusterDomainKind = "ClusterDomain" ClusterDomainResource = "clusterdomains" + SubscriptionProviderKind = "SubscriptionProvider" + SubscriptionProviderResource = "subscriptionproviders" + SubscriptionKind = "Subscription" + SubscriptionResource = "subscriptions" ) // +kubebuilder:resource:shortName=ca @@ -914,3 +918,135 @@ type ClusterDomainList struct { metav1.ListMeta `json:"metadata"` Items []ClusterDomain `json:"items"` } + +// +kubebuilder:resource:shortName=subpro +// +kubebuilder:subresource:status +// +kubebuilder:printcolumn:name="SubscriptionProvider",type="string",JSONPath=".spec.appName" +// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp" +// +kubebuilder:printcolumn:name="State",type="string",JSONPath=".status.state" +// +genclient +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// SubscriptionProvider is the schema for subscriptionproviders API +type SubscriptionProvider struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata"` + // SubscriptionProvider spec + Spec SubscriptionProviderSpec `json:"spec"` + // +kubebuilder:validation:Optional + // SubscriptionProvider status + Status SubscriptionProviderStatus `json:"status"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// SubscriptionProviderList contains a list of SubscriptionProvider +type SubscriptionProviderList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata"` + Items []SubscriptionProvider `json:"items"` +} + +type SubscriptionProviderSpec struct { + // Name of the application that is being subscribed to + AppName string `json:"appName"` + // Provider subaccount ID for the application that is being subscribed to + ProviderSubaccountID string `json:"providerSubaccountId"` + // The secret(s) containing the subscription credentials that are necessary to create a subscription for the application (Fetched from the same namespace as this resource). + SubscriptionInfo SubscriptionInfo `json:"subscriptionInfo"` +} + +type SubscriptionInfo struct { + // Type of Subscription (subscription-manager / saas-registry) + Type string `json:"type"` + // Name of the Subscription Credential + SubscriptionSecret string `json:"subscriptionSecret"` + // Name of the Auth Credential (Optional) + AuthSecret string `json:"authSecret,omitempty"` +} + +type SubscriptionProviderStatus struct { + GenericStatus `json:",inline"` + // State of the Domain + State SubscriptionProviderState `json:"state"` + // List of subscription dependencies discovered for the services specified in the spec + Dependencies string `json:"dependencies,omitempty"` +} + +// +kubebuilder:validation:Enum="";Ready;Error;Processing;Deleting +type SubscriptionProviderState string + +const ( + SubscriptionProviderStateProcessing SubscriptionProviderState = "Processing" + SubscriptionProviderStateError SubscriptionProviderState = "Error" + SubscriptionProviderStateDeleting SubscriptionProviderState = "Deleting" + SubscriptionProviderStateReady SubscriptionProviderState = "Ready" +) + +// +kubebuilder:resource:shortName=sub +// +kubebuilder:subresource:status +// +kubebuilder:printcolumn:name="App",type="string",JSONPath=".spec.appName" +// +kubebuilder:printcolumn:name="Guid",type="string",JSONPath=".spec.subscriptionGuid" +// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp" +// +kubebuilder:printcolumn:name="State",type="string",JSONPath=".status.state" +// +kubebuilder:printcolumn:name="Url",type="string",JSONPath=".status.url" +// +genclient +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// Subscription is the schema for subscriptions API +type Subscription struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata"` + // SubscriptionProvider spec + Spec SubscriptionSpec `json:"spec"` + // +kubebuilder:validation:Optional + // SubscriptionProvider status + Status SubscriptionStatus `json:"status"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// SubscriptionList contains a list of Subscription +type SubscriptionList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata"` + Items []Subscription `json:"items"` +} + +type SubscriptionSpec struct { + // Name of the application that is being subscribed to + AppName string `json:"appName"` + // Provider subaccount ID of the application that is being subscribed to (used to identify the owning CAPApplication) + ProviderSubaccountId string `json:"providerSubaccountId"` + // TenantId of the consumer subaccount subscribing to the application + TenantId string `json:"tenantId"` + // SubscriptionGuid of the subscription + SubscriptionGuid string `json:"subscriptionGuid"` + // Payload of the subscription request (JSON string). + SubscriptionRequestPayload string `json:"subscriptionRequestPayload"` +} + +type SubscriptionStatus struct { + GenericStatus `json:",inline"` + // State of the Domain + State SubscriptionState `json:"state"` + // Tenant specific URL of the subscribed application + Url string `json:"url,omitempty"` +} + +// +kubebuilder:validation:Enum="";Ready;Error;Processing;Deleting +type SubscriptionState string + +const ( + SubscriptionStateProcessing SubscriptionState = "Processing" + SubscriptionStateError SubscriptionState = "Error" + SubscriptionStateDeleting SubscriptionState = "Deleting" + SubscriptionStateReady SubscriptionState = "Ready" +) + +type SubscriptionStatusConditionType string + +const ( + // Condition reflecting whether the owned CAPTenant is ready + ConditionTypeTenantReady SubscriptionStatusConditionType = "TenantReady" +) diff --git a/pkg/apis/sme.sap.com/v1alpha1/utils.go b/pkg/apis/sme.sap.com/v1alpha1/utils.go index eaa119a8..e93e92ac 100644 --- a/pkg/apis/sme.sap.com/v1alpha1/utils.go +++ b/pkg/apis/sme.sap.com/v1alpha1/utils.go @@ -212,6 +212,21 @@ func (cdom *ClusterDomain) GetStatusReadyConditionMessage() string { return "" } +func (subPro *SubscriptionProvider) SetStatusWithReadyCondition(state SubscriptionProviderState, readyStatus metav1.ConditionStatus, reason string, message string) { + subPro.Status.State = state + subPro.Status.SetStatusCondition(metav1.Condition{Type: readyType, Status: readyStatus, Reason: reason, Message: message, ObservedGeneration: subPro.Generation}) +} + +func (sub *Subscription) SetStatusWithReadyCondition(state SubscriptionState, readyStatus metav1.ConditionStatus, reason string, message string) { + sub.Status.State = state + sub.SetStatusCondition(readyType, readyStatus, reason, message) +} + +// SetStatusCondition updates/sets a condition in the Status of the Subscription. +func (sub *Subscription) SetStatusCondition(conditionType string, status metav1.ConditionStatus, reason string, message string) { + sub.Status.SetStatusCondition(metav1.Condition{Type: conditionType, Status: status, Reason: reason, Message: message, ObservedGeneration: sub.Generation}) +} + func (serviceInfo ServiceInfo) GetSubscriptionDependency() SubscriptionDependency { if serviceInfo.SubscriptionDependency == nil { return SubscriptionDependencyAuto diff --git a/pkg/apis/sme.sap.com/v1alpha1/zz_generated.deepcopy.go b/pkg/apis/sme.sap.com/v1alpha1/zz_generated.deepcopy.go index 877b1244..8387014d 100644 --- a/pkg/apis/sme.sap.com/v1alpha1/zz_generated.deepcopy.go +++ b/pkg/apis/sme.sap.com/v1alpha1/zz_generated.deepcopy.go @@ -1347,6 +1347,211 @@ func (in *StickinessHash) DeepCopy() *StickinessHash { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Subscription) DeepCopyInto(out *Subscription) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + out.Spec = in.Spec + in.Status.DeepCopyInto(&out.Status) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Subscription. +func (in *Subscription) DeepCopy() *Subscription { + if in == nil { + return nil + } + out := new(Subscription) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *Subscription) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *SubscriptionInfo) DeepCopyInto(out *SubscriptionInfo) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SubscriptionInfo. +func (in *SubscriptionInfo) DeepCopy() *SubscriptionInfo { + if in == nil { + return nil + } + out := new(SubscriptionInfo) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *SubscriptionList) DeepCopyInto(out *SubscriptionList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]Subscription, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SubscriptionList. +func (in *SubscriptionList) DeepCopy() *SubscriptionList { + if in == nil { + return nil + } + out := new(SubscriptionList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *SubscriptionList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *SubscriptionProvider) DeepCopyInto(out *SubscriptionProvider) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + out.Spec = in.Spec + in.Status.DeepCopyInto(&out.Status) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SubscriptionProvider. +func (in *SubscriptionProvider) DeepCopy() *SubscriptionProvider { + if in == nil { + return nil + } + out := new(SubscriptionProvider) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *SubscriptionProvider) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *SubscriptionProviderList) DeepCopyInto(out *SubscriptionProviderList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]SubscriptionProvider, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SubscriptionProviderList. +func (in *SubscriptionProviderList) DeepCopy() *SubscriptionProviderList { + if in == nil { + return nil + } + out := new(SubscriptionProviderList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *SubscriptionProviderList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *SubscriptionProviderSpec) DeepCopyInto(out *SubscriptionProviderSpec) { + *out = *in + out.SubscriptionInfo = in.SubscriptionInfo + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SubscriptionProviderSpec. +func (in *SubscriptionProviderSpec) DeepCopy() *SubscriptionProviderSpec { + if in == nil { + return nil + } + out := new(SubscriptionProviderSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *SubscriptionProviderStatus) DeepCopyInto(out *SubscriptionProviderStatus) { + *out = *in + in.GenericStatus.DeepCopyInto(&out.GenericStatus) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SubscriptionProviderStatus. +func (in *SubscriptionProviderStatus) DeepCopy() *SubscriptionProviderStatus { + if in == nil { + return nil + } + out := new(SubscriptionProviderStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *SubscriptionSpec) DeepCopyInto(out *SubscriptionSpec) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SubscriptionSpec. +func (in *SubscriptionSpec) DeepCopy() *SubscriptionSpec { + if in == nil { + return nil + } + out := new(SubscriptionSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *SubscriptionStatus) DeepCopyInto(out *SubscriptionStatus) { + *out = *in + in.GenericStatus.DeepCopyInto(&out.GenericStatus) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SubscriptionStatus. +func (in *SubscriptionStatus) DeepCopy() *SubscriptionStatus { + if in == nil { + return nil + } + out := new(SubscriptionStatus) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *TenantOperationWorkloadReference) DeepCopyInto(out *TenantOperationWorkloadReference) { *out = *in diff --git a/pkg/client/applyconfiguration/sme.sap.com/v1alpha1/subscription.go b/pkg/client/applyconfiguration/sme.sap.com/v1alpha1/subscription.go new file mode 100644 index 00000000..b7c8ebe5 --- /dev/null +++ b/pkg/client/applyconfiguration/sme.sap.com/v1alpha1/subscription.go @@ -0,0 +1,236 @@ +/* +SPDX-FileCopyrightText: 2026 SAP SE or an SAP affiliate company and cap-operator contributors +SPDX-License-Identifier: Apache-2.0 +*/ + +// Code generated by applyconfiguration-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + types "k8s.io/apimachinery/pkg/types" + v1 "k8s.io/client-go/applyconfigurations/meta/v1" +) + +// SubscriptionApplyConfiguration represents a declarative configuration of the Subscription type for use +// with apply. +// +// Subscription is the schema for subscriptions API +type SubscriptionApplyConfiguration struct { + v1.TypeMetaApplyConfiguration `json:",inline"` + *v1.ObjectMetaApplyConfiguration `json:"metadata,omitempty"` + // SubscriptionProvider spec + Spec *SubscriptionSpecApplyConfiguration `json:"spec,omitempty"` + // SubscriptionProvider status + Status *SubscriptionStatusApplyConfiguration `json:"status,omitempty"` +} + +// Subscription constructs a declarative configuration of the Subscription type for use with +// apply. +func Subscription(name, namespace string) *SubscriptionApplyConfiguration { + b := &SubscriptionApplyConfiguration{} + b.WithName(name) + b.WithNamespace(namespace) + b.WithKind("Subscription") + b.WithAPIVersion("sme.sap.com/v1alpha1") + return b +} + +func (b SubscriptionApplyConfiguration) IsApplyConfiguration() {} + +// WithKind sets the Kind field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Kind field is set to the value of the last call. +func (b *SubscriptionApplyConfiguration) WithKind(value string) *SubscriptionApplyConfiguration { + b.TypeMetaApplyConfiguration.Kind = &value + return b +} + +// WithAPIVersion sets the APIVersion field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the APIVersion field is set to the value of the last call. +func (b *SubscriptionApplyConfiguration) WithAPIVersion(value string) *SubscriptionApplyConfiguration { + b.TypeMetaApplyConfiguration.APIVersion = &value + return b +} + +// WithName sets the Name field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Name field is set to the value of the last call. +func (b *SubscriptionApplyConfiguration) WithName(value string) *SubscriptionApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.ObjectMetaApplyConfiguration.Name = &value + return b +} + +// WithGenerateName sets the GenerateName field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the GenerateName field is set to the value of the last call. +func (b *SubscriptionApplyConfiguration) WithGenerateName(value string) *SubscriptionApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.ObjectMetaApplyConfiguration.GenerateName = &value + return b +} + +// WithNamespace sets the Namespace field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Namespace field is set to the value of the last call. +func (b *SubscriptionApplyConfiguration) WithNamespace(value string) *SubscriptionApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.ObjectMetaApplyConfiguration.Namespace = &value + return b +} + +// WithUID sets the UID field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the UID field is set to the value of the last call. +func (b *SubscriptionApplyConfiguration) WithUID(value types.UID) *SubscriptionApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.ObjectMetaApplyConfiguration.UID = &value + return b +} + +// WithResourceVersion sets the ResourceVersion field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the ResourceVersion field is set to the value of the last call. +func (b *SubscriptionApplyConfiguration) WithResourceVersion(value string) *SubscriptionApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.ObjectMetaApplyConfiguration.ResourceVersion = &value + return b +} + +// WithGeneration sets the Generation field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Generation field is set to the value of the last call. +func (b *SubscriptionApplyConfiguration) WithGeneration(value int64) *SubscriptionApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.ObjectMetaApplyConfiguration.Generation = &value + return b +} + +// WithCreationTimestamp sets the CreationTimestamp field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the CreationTimestamp field is set to the value of the last call. +func (b *SubscriptionApplyConfiguration) WithCreationTimestamp(value metav1.Time) *SubscriptionApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.ObjectMetaApplyConfiguration.CreationTimestamp = &value + return b +} + +// WithDeletionTimestamp sets the DeletionTimestamp field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the DeletionTimestamp field is set to the value of the last call. +func (b *SubscriptionApplyConfiguration) WithDeletionTimestamp(value metav1.Time) *SubscriptionApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.ObjectMetaApplyConfiguration.DeletionTimestamp = &value + return b +} + +// WithDeletionGracePeriodSeconds sets the DeletionGracePeriodSeconds field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the DeletionGracePeriodSeconds field is set to the value of the last call. +func (b *SubscriptionApplyConfiguration) WithDeletionGracePeriodSeconds(value int64) *SubscriptionApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.ObjectMetaApplyConfiguration.DeletionGracePeriodSeconds = &value + return b +} + +// WithLabels puts the entries into the Labels field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, the entries provided by each call will be put on the Labels field, +// overwriting an existing map entries in Labels field with the same key. +func (b *SubscriptionApplyConfiguration) WithLabels(entries map[string]string) *SubscriptionApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + if b.ObjectMetaApplyConfiguration.Labels == nil && len(entries) > 0 { + b.ObjectMetaApplyConfiguration.Labels = make(map[string]string, len(entries)) + } + for k, v := range entries { + b.ObjectMetaApplyConfiguration.Labels[k] = v + } + return b +} + +// WithAnnotations puts the entries into the Annotations field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, the entries provided by each call will be put on the Annotations field, +// overwriting an existing map entries in Annotations field with the same key. +func (b *SubscriptionApplyConfiguration) WithAnnotations(entries map[string]string) *SubscriptionApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + if b.ObjectMetaApplyConfiguration.Annotations == nil && len(entries) > 0 { + b.ObjectMetaApplyConfiguration.Annotations = make(map[string]string, len(entries)) + } + for k, v := range entries { + b.ObjectMetaApplyConfiguration.Annotations[k] = v + } + return b +} + +// WithOwnerReferences adds the given value to the OwnerReferences field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the OwnerReferences field. +func (b *SubscriptionApplyConfiguration) WithOwnerReferences(values ...*v1.OwnerReferenceApplyConfiguration) *SubscriptionApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + for i := range values { + if values[i] == nil { + panic("nil value passed to WithOwnerReferences") + } + b.ObjectMetaApplyConfiguration.OwnerReferences = append(b.ObjectMetaApplyConfiguration.OwnerReferences, *values[i]) + } + return b +} + +// WithFinalizers adds the given value to the Finalizers field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the Finalizers field. +func (b *SubscriptionApplyConfiguration) WithFinalizers(values ...string) *SubscriptionApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + for i := range values { + b.ObjectMetaApplyConfiguration.Finalizers = append(b.ObjectMetaApplyConfiguration.Finalizers, values[i]) + } + return b +} + +func (b *SubscriptionApplyConfiguration) ensureObjectMetaApplyConfigurationExists() { + if b.ObjectMetaApplyConfiguration == nil { + b.ObjectMetaApplyConfiguration = &v1.ObjectMetaApplyConfiguration{} + } +} + +// WithSpec sets the Spec field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Spec field is set to the value of the last call. +func (b *SubscriptionApplyConfiguration) WithSpec(value *SubscriptionSpecApplyConfiguration) *SubscriptionApplyConfiguration { + b.Spec = value + return b +} + +// WithStatus sets the Status field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Status field is set to the value of the last call. +func (b *SubscriptionApplyConfiguration) WithStatus(value *SubscriptionStatusApplyConfiguration) *SubscriptionApplyConfiguration { + b.Status = value + return b +} + +// GetKind retrieves the value of the Kind field in the declarative configuration. +func (b *SubscriptionApplyConfiguration) GetKind() *string { + return b.TypeMetaApplyConfiguration.Kind +} + +// GetAPIVersion retrieves the value of the APIVersion field in the declarative configuration. +func (b *SubscriptionApplyConfiguration) GetAPIVersion() *string { + return b.TypeMetaApplyConfiguration.APIVersion +} + +// GetName retrieves the value of the Name field in the declarative configuration. +func (b *SubscriptionApplyConfiguration) GetName() *string { + b.ensureObjectMetaApplyConfigurationExists() + return b.ObjectMetaApplyConfiguration.Name +} + +// GetNamespace retrieves the value of the Namespace field in the declarative configuration. +func (b *SubscriptionApplyConfiguration) GetNamespace() *string { + b.ensureObjectMetaApplyConfigurationExists() + return b.ObjectMetaApplyConfiguration.Namespace +} diff --git a/pkg/client/applyconfiguration/sme.sap.com/v1alpha1/subscriptioninfo.go b/pkg/client/applyconfiguration/sme.sap.com/v1alpha1/subscriptioninfo.go new file mode 100644 index 00000000..a1544593 --- /dev/null +++ b/pkg/client/applyconfiguration/sme.sap.com/v1alpha1/subscriptioninfo.go @@ -0,0 +1,49 @@ +/* +SPDX-FileCopyrightText: 2026 SAP SE or an SAP affiliate company and cap-operator contributors +SPDX-License-Identifier: Apache-2.0 +*/ + +// Code generated by applyconfiguration-gen. DO NOT EDIT. + +package v1alpha1 + +// SubscriptionInfoApplyConfiguration represents a declarative configuration of the SubscriptionInfo type for use +// with apply. +type SubscriptionInfoApplyConfiguration struct { + // Type of Subscription (subscription-manager / saas-registry) + Type *string `json:"type,omitempty"` + // Name of the Subscription Credential + SubscriptionSecret *string `json:"subscriptionSecret,omitempty"` + // Name of the Auth Credential (Optional) + AuthSecret *string `json:"authSecret,omitempty"` +} + +// SubscriptionInfoApplyConfiguration constructs a declarative configuration of the SubscriptionInfo type for use with +// apply. +func SubscriptionInfo() *SubscriptionInfoApplyConfiguration { + return &SubscriptionInfoApplyConfiguration{} +} + +// WithType sets the Type field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Type field is set to the value of the last call. +func (b *SubscriptionInfoApplyConfiguration) WithType(value string) *SubscriptionInfoApplyConfiguration { + b.Type = &value + return b +} + +// WithSubscriptionSecret sets the SubscriptionSecret field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the SubscriptionSecret field is set to the value of the last call. +func (b *SubscriptionInfoApplyConfiguration) WithSubscriptionSecret(value string) *SubscriptionInfoApplyConfiguration { + b.SubscriptionSecret = &value + return b +} + +// WithAuthSecret sets the AuthSecret field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the AuthSecret field is set to the value of the last call. +func (b *SubscriptionInfoApplyConfiguration) WithAuthSecret(value string) *SubscriptionInfoApplyConfiguration { + b.AuthSecret = &value + return b +} diff --git a/pkg/client/applyconfiguration/sme.sap.com/v1alpha1/subscriptionprovider.go b/pkg/client/applyconfiguration/sme.sap.com/v1alpha1/subscriptionprovider.go new file mode 100644 index 00000000..9f2f1138 --- /dev/null +++ b/pkg/client/applyconfiguration/sme.sap.com/v1alpha1/subscriptionprovider.go @@ -0,0 +1,236 @@ +/* +SPDX-FileCopyrightText: 2026 SAP SE or an SAP affiliate company and cap-operator contributors +SPDX-License-Identifier: Apache-2.0 +*/ + +// Code generated by applyconfiguration-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + types "k8s.io/apimachinery/pkg/types" + v1 "k8s.io/client-go/applyconfigurations/meta/v1" +) + +// SubscriptionProviderApplyConfiguration represents a declarative configuration of the SubscriptionProvider type for use +// with apply. +// +// SubscriptionProvider is the schema for subscriptionproviders API +type SubscriptionProviderApplyConfiguration struct { + v1.TypeMetaApplyConfiguration `json:",inline"` + *v1.ObjectMetaApplyConfiguration `json:"metadata,omitempty"` + // SubscriptionProvider spec + Spec *SubscriptionProviderSpecApplyConfiguration `json:"spec,omitempty"` + // SubscriptionProvider status + Status *SubscriptionProviderStatusApplyConfiguration `json:"status,omitempty"` +} + +// SubscriptionProvider constructs a declarative configuration of the SubscriptionProvider type for use with +// apply. +func SubscriptionProvider(name, namespace string) *SubscriptionProviderApplyConfiguration { + b := &SubscriptionProviderApplyConfiguration{} + b.WithName(name) + b.WithNamespace(namespace) + b.WithKind("SubscriptionProvider") + b.WithAPIVersion("sme.sap.com/v1alpha1") + return b +} + +func (b SubscriptionProviderApplyConfiguration) IsApplyConfiguration() {} + +// WithKind sets the Kind field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Kind field is set to the value of the last call. +func (b *SubscriptionProviderApplyConfiguration) WithKind(value string) *SubscriptionProviderApplyConfiguration { + b.TypeMetaApplyConfiguration.Kind = &value + return b +} + +// WithAPIVersion sets the APIVersion field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the APIVersion field is set to the value of the last call. +func (b *SubscriptionProviderApplyConfiguration) WithAPIVersion(value string) *SubscriptionProviderApplyConfiguration { + b.TypeMetaApplyConfiguration.APIVersion = &value + return b +} + +// WithName sets the Name field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Name field is set to the value of the last call. +func (b *SubscriptionProviderApplyConfiguration) WithName(value string) *SubscriptionProviderApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.ObjectMetaApplyConfiguration.Name = &value + return b +} + +// WithGenerateName sets the GenerateName field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the GenerateName field is set to the value of the last call. +func (b *SubscriptionProviderApplyConfiguration) WithGenerateName(value string) *SubscriptionProviderApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.ObjectMetaApplyConfiguration.GenerateName = &value + return b +} + +// WithNamespace sets the Namespace field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Namespace field is set to the value of the last call. +func (b *SubscriptionProviderApplyConfiguration) WithNamespace(value string) *SubscriptionProviderApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.ObjectMetaApplyConfiguration.Namespace = &value + return b +} + +// WithUID sets the UID field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the UID field is set to the value of the last call. +func (b *SubscriptionProviderApplyConfiguration) WithUID(value types.UID) *SubscriptionProviderApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.ObjectMetaApplyConfiguration.UID = &value + return b +} + +// WithResourceVersion sets the ResourceVersion field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the ResourceVersion field is set to the value of the last call. +func (b *SubscriptionProviderApplyConfiguration) WithResourceVersion(value string) *SubscriptionProviderApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.ObjectMetaApplyConfiguration.ResourceVersion = &value + return b +} + +// WithGeneration sets the Generation field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Generation field is set to the value of the last call. +func (b *SubscriptionProviderApplyConfiguration) WithGeneration(value int64) *SubscriptionProviderApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.ObjectMetaApplyConfiguration.Generation = &value + return b +} + +// WithCreationTimestamp sets the CreationTimestamp field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the CreationTimestamp field is set to the value of the last call. +func (b *SubscriptionProviderApplyConfiguration) WithCreationTimestamp(value metav1.Time) *SubscriptionProviderApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.ObjectMetaApplyConfiguration.CreationTimestamp = &value + return b +} + +// WithDeletionTimestamp sets the DeletionTimestamp field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the DeletionTimestamp field is set to the value of the last call. +func (b *SubscriptionProviderApplyConfiguration) WithDeletionTimestamp(value metav1.Time) *SubscriptionProviderApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.ObjectMetaApplyConfiguration.DeletionTimestamp = &value + return b +} + +// WithDeletionGracePeriodSeconds sets the DeletionGracePeriodSeconds field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the DeletionGracePeriodSeconds field is set to the value of the last call. +func (b *SubscriptionProviderApplyConfiguration) WithDeletionGracePeriodSeconds(value int64) *SubscriptionProviderApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.ObjectMetaApplyConfiguration.DeletionGracePeriodSeconds = &value + return b +} + +// WithLabels puts the entries into the Labels field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, the entries provided by each call will be put on the Labels field, +// overwriting an existing map entries in Labels field with the same key. +func (b *SubscriptionProviderApplyConfiguration) WithLabels(entries map[string]string) *SubscriptionProviderApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + if b.ObjectMetaApplyConfiguration.Labels == nil && len(entries) > 0 { + b.ObjectMetaApplyConfiguration.Labels = make(map[string]string, len(entries)) + } + for k, v := range entries { + b.ObjectMetaApplyConfiguration.Labels[k] = v + } + return b +} + +// WithAnnotations puts the entries into the Annotations field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, the entries provided by each call will be put on the Annotations field, +// overwriting an existing map entries in Annotations field with the same key. +func (b *SubscriptionProviderApplyConfiguration) WithAnnotations(entries map[string]string) *SubscriptionProviderApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + if b.ObjectMetaApplyConfiguration.Annotations == nil && len(entries) > 0 { + b.ObjectMetaApplyConfiguration.Annotations = make(map[string]string, len(entries)) + } + for k, v := range entries { + b.ObjectMetaApplyConfiguration.Annotations[k] = v + } + return b +} + +// WithOwnerReferences adds the given value to the OwnerReferences field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the OwnerReferences field. +func (b *SubscriptionProviderApplyConfiguration) WithOwnerReferences(values ...*v1.OwnerReferenceApplyConfiguration) *SubscriptionProviderApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + for i := range values { + if values[i] == nil { + panic("nil value passed to WithOwnerReferences") + } + b.ObjectMetaApplyConfiguration.OwnerReferences = append(b.ObjectMetaApplyConfiguration.OwnerReferences, *values[i]) + } + return b +} + +// WithFinalizers adds the given value to the Finalizers field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the Finalizers field. +func (b *SubscriptionProviderApplyConfiguration) WithFinalizers(values ...string) *SubscriptionProviderApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + for i := range values { + b.ObjectMetaApplyConfiguration.Finalizers = append(b.ObjectMetaApplyConfiguration.Finalizers, values[i]) + } + return b +} + +func (b *SubscriptionProviderApplyConfiguration) ensureObjectMetaApplyConfigurationExists() { + if b.ObjectMetaApplyConfiguration == nil { + b.ObjectMetaApplyConfiguration = &v1.ObjectMetaApplyConfiguration{} + } +} + +// WithSpec sets the Spec field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Spec field is set to the value of the last call. +func (b *SubscriptionProviderApplyConfiguration) WithSpec(value *SubscriptionProviderSpecApplyConfiguration) *SubscriptionProviderApplyConfiguration { + b.Spec = value + return b +} + +// WithStatus sets the Status field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Status field is set to the value of the last call. +func (b *SubscriptionProviderApplyConfiguration) WithStatus(value *SubscriptionProviderStatusApplyConfiguration) *SubscriptionProviderApplyConfiguration { + b.Status = value + return b +} + +// GetKind retrieves the value of the Kind field in the declarative configuration. +func (b *SubscriptionProviderApplyConfiguration) GetKind() *string { + return b.TypeMetaApplyConfiguration.Kind +} + +// GetAPIVersion retrieves the value of the APIVersion field in the declarative configuration. +func (b *SubscriptionProviderApplyConfiguration) GetAPIVersion() *string { + return b.TypeMetaApplyConfiguration.APIVersion +} + +// GetName retrieves the value of the Name field in the declarative configuration. +func (b *SubscriptionProviderApplyConfiguration) GetName() *string { + b.ensureObjectMetaApplyConfigurationExists() + return b.ObjectMetaApplyConfiguration.Name +} + +// GetNamespace retrieves the value of the Namespace field in the declarative configuration. +func (b *SubscriptionProviderApplyConfiguration) GetNamespace() *string { + b.ensureObjectMetaApplyConfigurationExists() + return b.ObjectMetaApplyConfiguration.Namespace +} diff --git a/pkg/client/applyconfiguration/sme.sap.com/v1alpha1/subscriptionproviderspec.go b/pkg/client/applyconfiguration/sme.sap.com/v1alpha1/subscriptionproviderspec.go new file mode 100644 index 00000000..9272324e --- /dev/null +++ b/pkg/client/applyconfiguration/sme.sap.com/v1alpha1/subscriptionproviderspec.go @@ -0,0 +1,49 @@ +/* +SPDX-FileCopyrightText: 2026 SAP SE or an SAP affiliate company and cap-operator contributors +SPDX-License-Identifier: Apache-2.0 +*/ + +// Code generated by applyconfiguration-gen. DO NOT EDIT. + +package v1alpha1 + +// SubscriptionProviderSpecApplyConfiguration represents a declarative configuration of the SubscriptionProviderSpec type for use +// with apply. +type SubscriptionProviderSpecApplyConfiguration struct { + // Name of the application that is being subscribed to + AppName *string `json:"appName,omitempty"` + // Provider subaccount ID for the application that is being subscribed to + ProviderSubaccountID *string `json:"providerSubaccountId,omitempty"` + // The secret(s) containing the subscription credentials that are necessary to create a subscription for the application (Fetched from the same namespace as this resource). + SubscriptionInfo *SubscriptionInfoApplyConfiguration `json:"subscriptionInfo,omitempty"` +} + +// SubscriptionProviderSpecApplyConfiguration constructs a declarative configuration of the SubscriptionProviderSpec type for use with +// apply. +func SubscriptionProviderSpec() *SubscriptionProviderSpecApplyConfiguration { + return &SubscriptionProviderSpecApplyConfiguration{} +} + +// WithAppName sets the AppName field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the AppName field is set to the value of the last call. +func (b *SubscriptionProviderSpecApplyConfiguration) WithAppName(value string) *SubscriptionProviderSpecApplyConfiguration { + b.AppName = &value + return b +} + +// WithProviderSubaccountID sets the ProviderSubaccountID field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the ProviderSubaccountID field is set to the value of the last call. +func (b *SubscriptionProviderSpecApplyConfiguration) WithProviderSubaccountID(value string) *SubscriptionProviderSpecApplyConfiguration { + b.ProviderSubaccountID = &value + return b +} + +// WithSubscriptionInfo sets the SubscriptionInfo field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the SubscriptionInfo field is set to the value of the last call. +func (b *SubscriptionProviderSpecApplyConfiguration) WithSubscriptionInfo(value *SubscriptionInfoApplyConfiguration) *SubscriptionProviderSpecApplyConfiguration { + b.SubscriptionInfo = value + return b +} diff --git a/pkg/client/applyconfiguration/sme.sap.com/v1alpha1/subscriptionproviderstatus.go b/pkg/client/applyconfiguration/sme.sap.com/v1alpha1/subscriptionproviderstatus.go new file mode 100644 index 00000000..435a761c --- /dev/null +++ b/pkg/client/applyconfiguration/sme.sap.com/v1alpha1/subscriptionproviderstatus.go @@ -0,0 +1,66 @@ +/* +SPDX-FileCopyrightText: 2026 SAP SE or an SAP affiliate company and cap-operator contributors +SPDX-License-Identifier: Apache-2.0 +*/ + +// Code generated by applyconfiguration-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + smesapcomv1alpha1 "github.com/sap/cap-operator/pkg/apis/sme.sap.com/v1alpha1" + v1 "k8s.io/client-go/applyconfigurations/meta/v1" +) + +// SubscriptionProviderStatusApplyConfiguration represents a declarative configuration of the SubscriptionProviderStatus type for use +// with apply. +type SubscriptionProviderStatusApplyConfiguration struct { + GenericStatusApplyConfiguration `json:",inline"` + // State of the Domain + State *smesapcomv1alpha1.SubscriptionProviderState `json:"state,omitempty"` + // List of subscription dependencies discovered for the services specified in the spec + Dependencies *string `json:"dependencies,omitempty"` +} + +// SubscriptionProviderStatusApplyConfiguration constructs a declarative configuration of the SubscriptionProviderStatus type for use with +// apply. +func SubscriptionProviderStatus() *SubscriptionProviderStatusApplyConfiguration { + return &SubscriptionProviderStatusApplyConfiguration{} +} + +// WithObservedGeneration sets the ObservedGeneration field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the ObservedGeneration field is set to the value of the last call. +func (b *SubscriptionProviderStatusApplyConfiguration) WithObservedGeneration(value int64) *SubscriptionProviderStatusApplyConfiguration { + b.GenericStatusApplyConfiguration.ObservedGeneration = &value + return b +} + +// WithConditions adds the given value to the Conditions field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the Conditions field. +func (b *SubscriptionProviderStatusApplyConfiguration) WithConditions(values ...*v1.ConditionApplyConfiguration) *SubscriptionProviderStatusApplyConfiguration { + for i := range values { + if values[i] == nil { + panic("nil value passed to WithConditions") + } + b.GenericStatusApplyConfiguration.Conditions = append(b.GenericStatusApplyConfiguration.Conditions, *values[i]) + } + return b +} + +// WithState sets the State field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the State field is set to the value of the last call. +func (b *SubscriptionProviderStatusApplyConfiguration) WithState(value smesapcomv1alpha1.SubscriptionProviderState) *SubscriptionProviderStatusApplyConfiguration { + b.State = &value + return b +} + +// WithDependencies sets the Dependencies field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Dependencies field is set to the value of the last call. +func (b *SubscriptionProviderStatusApplyConfiguration) WithDependencies(value string) *SubscriptionProviderStatusApplyConfiguration { + b.Dependencies = &value + return b +} diff --git a/pkg/client/applyconfiguration/sme.sap.com/v1alpha1/subscriptionspec.go b/pkg/client/applyconfiguration/sme.sap.com/v1alpha1/subscriptionspec.go new file mode 100644 index 00000000..4cfcf0b6 --- /dev/null +++ b/pkg/client/applyconfiguration/sme.sap.com/v1alpha1/subscriptionspec.go @@ -0,0 +1,69 @@ +/* +SPDX-FileCopyrightText: 2026 SAP SE or an SAP affiliate company and cap-operator contributors +SPDX-License-Identifier: Apache-2.0 +*/ + +// Code generated by applyconfiguration-gen. DO NOT EDIT. + +package v1alpha1 + +// SubscriptionSpecApplyConfiguration represents a declarative configuration of the SubscriptionSpec type for use +// with apply. +type SubscriptionSpecApplyConfiguration struct { + // Name of the application that is being subscribed to + AppName *string `json:"appName,omitempty"` + // Provider subaccount ID of the application that is being subscribed to (used to identify the owning CAPApplication) + ProviderSubaccountId *string `json:"providerSubaccountId,omitempty"` + // TenantId of the consumer subaccount subscribing to the application + TenantId *string `json:"tenantId,omitempty"` + // SubscriptionGuid of the subscription + SubscriptionGuid *string `json:"subscriptionGuid,omitempty"` + // Payload of the subscription request (JSON string). + SubscriptionRequestPayload *string `json:"subscriptionRequestPayload,omitempty"` +} + +// SubscriptionSpecApplyConfiguration constructs a declarative configuration of the SubscriptionSpec type for use with +// apply. +func SubscriptionSpec() *SubscriptionSpecApplyConfiguration { + return &SubscriptionSpecApplyConfiguration{} +} + +// WithAppName sets the AppName field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the AppName field is set to the value of the last call. +func (b *SubscriptionSpecApplyConfiguration) WithAppName(value string) *SubscriptionSpecApplyConfiguration { + b.AppName = &value + return b +} + +// WithProviderSubaccountId sets the ProviderSubaccountId field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the ProviderSubaccountId field is set to the value of the last call. +func (b *SubscriptionSpecApplyConfiguration) WithProviderSubaccountId(value string) *SubscriptionSpecApplyConfiguration { + b.ProviderSubaccountId = &value + return b +} + +// WithTenantId sets the TenantId field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the TenantId field is set to the value of the last call. +func (b *SubscriptionSpecApplyConfiguration) WithTenantId(value string) *SubscriptionSpecApplyConfiguration { + b.TenantId = &value + return b +} + +// WithSubscriptionGuid sets the SubscriptionGuid field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the SubscriptionGuid field is set to the value of the last call. +func (b *SubscriptionSpecApplyConfiguration) WithSubscriptionGuid(value string) *SubscriptionSpecApplyConfiguration { + b.SubscriptionGuid = &value + return b +} + +// WithSubscriptionRequestPayload sets the SubscriptionRequestPayload field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the SubscriptionRequestPayload field is set to the value of the last call. +func (b *SubscriptionSpecApplyConfiguration) WithSubscriptionRequestPayload(value string) *SubscriptionSpecApplyConfiguration { + b.SubscriptionRequestPayload = &value + return b +} diff --git a/pkg/client/applyconfiguration/sme.sap.com/v1alpha1/subscriptionstatus.go b/pkg/client/applyconfiguration/sme.sap.com/v1alpha1/subscriptionstatus.go new file mode 100644 index 00000000..a6a02591 --- /dev/null +++ b/pkg/client/applyconfiguration/sme.sap.com/v1alpha1/subscriptionstatus.go @@ -0,0 +1,66 @@ +/* +SPDX-FileCopyrightText: 2026 SAP SE or an SAP affiliate company and cap-operator contributors +SPDX-License-Identifier: Apache-2.0 +*/ + +// Code generated by applyconfiguration-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + smesapcomv1alpha1 "github.com/sap/cap-operator/pkg/apis/sme.sap.com/v1alpha1" + v1 "k8s.io/client-go/applyconfigurations/meta/v1" +) + +// SubscriptionStatusApplyConfiguration represents a declarative configuration of the SubscriptionStatus type for use +// with apply. +type SubscriptionStatusApplyConfiguration struct { + GenericStatusApplyConfiguration `json:",inline"` + // State of the Domain + State *smesapcomv1alpha1.SubscriptionState `json:"state,omitempty"` + // Tenant specific URL of the subscribed application + Url *string `json:"url,omitempty"` +} + +// SubscriptionStatusApplyConfiguration constructs a declarative configuration of the SubscriptionStatus type for use with +// apply. +func SubscriptionStatus() *SubscriptionStatusApplyConfiguration { + return &SubscriptionStatusApplyConfiguration{} +} + +// WithObservedGeneration sets the ObservedGeneration field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the ObservedGeneration field is set to the value of the last call. +func (b *SubscriptionStatusApplyConfiguration) WithObservedGeneration(value int64) *SubscriptionStatusApplyConfiguration { + b.GenericStatusApplyConfiguration.ObservedGeneration = &value + return b +} + +// WithConditions adds the given value to the Conditions field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the Conditions field. +func (b *SubscriptionStatusApplyConfiguration) WithConditions(values ...*v1.ConditionApplyConfiguration) *SubscriptionStatusApplyConfiguration { + for i := range values { + if values[i] == nil { + panic("nil value passed to WithConditions") + } + b.GenericStatusApplyConfiguration.Conditions = append(b.GenericStatusApplyConfiguration.Conditions, *values[i]) + } + return b +} + +// WithState sets the State field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the State field is set to the value of the last call. +func (b *SubscriptionStatusApplyConfiguration) WithState(value smesapcomv1alpha1.SubscriptionState) *SubscriptionStatusApplyConfiguration { + b.State = &value + return b +} + +// WithUrl sets the Url field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Url field is set to the value of the last call. +func (b *SubscriptionStatusApplyConfiguration) WithUrl(value string) *SubscriptionStatusApplyConfiguration { + b.Url = &value + return b +} diff --git a/pkg/client/applyconfiguration/utils.go b/pkg/client/applyconfiguration/utils.go index 7a806870..66ba82bf 100644 --- a/pkg/client/applyconfiguration/utils.go +++ b/pkg/client/applyconfiguration/utils.go @@ -105,6 +105,20 @@ func ForKind(kind schema.GroupVersionKind) interface{} { return &smesapcomv1alpha1.StickinessApplyConfiguration{} case v1alpha1.SchemeGroupVersion.WithKind("StickinessHash"): return &smesapcomv1alpha1.StickinessHashApplyConfiguration{} + case v1alpha1.SchemeGroupVersion.WithKind("Subscription"): + return &smesapcomv1alpha1.SubscriptionApplyConfiguration{} + case v1alpha1.SchemeGroupVersion.WithKind("SubscriptionInfo"): + return &smesapcomv1alpha1.SubscriptionInfoApplyConfiguration{} + case v1alpha1.SchemeGroupVersion.WithKind("SubscriptionProvider"): + return &smesapcomv1alpha1.SubscriptionProviderApplyConfiguration{} + case v1alpha1.SchemeGroupVersion.WithKind("SubscriptionProviderSpec"): + return &smesapcomv1alpha1.SubscriptionProviderSpecApplyConfiguration{} + case v1alpha1.SchemeGroupVersion.WithKind("SubscriptionProviderStatus"): + return &smesapcomv1alpha1.SubscriptionProviderStatusApplyConfiguration{} + case v1alpha1.SchemeGroupVersion.WithKind("SubscriptionSpec"): + return &smesapcomv1alpha1.SubscriptionSpecApplyConfiguration{} + case v1alpha1.SchemeGroupVersion.WithKind("SubscriptionStatus"): + return &smesapcomv1alpha1.SubscriptionStatusApplyConfiguration{} case v1alpha1.SchemeGroupVersion.WithKind("TenantOperations"): return &smesapcomv1alpha1.TenantOperationsApplyConfiguration{} case v1alpha1.SchemeGroupVersion.WithKind("TenantOperationWorkloadReference"): diff --git a/pkg/client/clientset/versioned/typed/sme.sap.com/v1alpha1/fake/fake_sme.sap.com_client.go b/pkg/client/clientset/versioned/typed/sme.sap.com/v1alpha1/fake/fake_sme.sap.com_client.go index c716a6d8..60b06804 100644 --- a/pkg/client/clientset/versioned/typed/sme.sap.com/v1alpha1/fake/fake_sme.sap.com_client.go +++ b/pkg/client/clientset/versioned/typed/sme.sap.com/v1alpha1/fake/fake_sme.sap.com_client.go @@ -45,6 +45,14 @@ func (c *FakeSmeV1alpha1) Domains(namespace string) v1alpha1.DomainInterface { return newFakeDomains(c, namespace) } +func (c *FakeSmeV1alpha1) Subscriptions(namespace string) v1alpha1.SubscriptionInterface { + return newFakeSubscriptions(c, namespace) +} + +func (c *FakeSmeV1alpha1) SubscriptionProviders(namespace string) v1alpha1.SubscriptionProviderInterface { + return newFakeSubscriptionProviders(c, namespace) +} + // RESTClient returns a RESTClient that is used to communicate // with API server by this client implementation. func (c *FakeSmeV1alpha1) RESTClient() rest.Interface { diff --git a/pkg/client/clientset/versioned/typed/sme.sap.com/v1alpha1/fake/fake_subscription.go b/pkg/client/clientset/versioned/typed/sme.sap.com/v1alpha1/fake/fake_subscription.go new file mode 100644 index 00000000..c2ce77d1 --- /dev/null +++ b/pkg/client/clientset/versioned/typed/sme.sap.com/v1alpha1/fake/fake_subscription.go @@ -0,0 +1,42 @@ +/* +SPDX-FileCopyrightText: 2026 SAP SE or an SAP affiliate company and cap-operator contributors +SPDX-License-Identifier: Apache-2.0 +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package fake + +import ( + v1alpha1 "github.com/sap/cap-operator/pkg/apis/sme.sap.com/v1alpha1" + smesapcomv1alpha1 "github.com/sap/cap-operator/pkg/client/applyconfiguration/sme.sap.com/v1alpha1" + typedsmesapcomv1alpha1 "github.com/sap/cap-operator/pkg/client/clientset/versioned/typed/sme.sap.com/v1alpha1" + gentype "k8s.io/client-go/gentype" +) + +// fakeSubscriptions implements SubscriptionInterface +type fakeSubscriptions struct { + *gentype.FakeClientWithListAndApply[*v1alpha1.Subscription, *v1alpha1.SubscriptionList, *smesapcomv1alpha1.SubscriptionApplyConfiguration] + Fake *FakeSmeV1alpha1 +} + +func newFakeSubscriptions(fake *FakeSmeV1alpha1, namespace string) typedsmesapcomv1alpha1.SubscriptionInterface { + return &fakeSubscriptions{ + gentype.NewFakeClientWithListAndApply[*v1alpha1.Subscription, *v1alpha1.SubscriptionList, *smesapcomv1alpha1.SubscriptionApplyConfiguration]( + fake.Fake, + namespace, + v1alpha1.SchemeGroupVersion.WithResource("subscriptions"), + v1alpha1.SchemeGroupVersion.WithKind("Subscription"), + func() *v1alpha1.Subscription { return &v1alpha1.Subscription{} }, + func() *v1alpha1.SubscriptionList { return &v1alpha1.SubscriptionList{} }, + func(dst, src *v1alpha1.SubscriptionList) { dst.ListMeta = src.ListMeta }, + func(list *v1alpha1.SubscriptionList) []*v1alpha1.Subscription { + return gentype.ToPointerSlice(list.Items) + }, + func(list *v1alpha1.SubscriptionList, items []*v1alpha1.Subscription) { + list.Items = gentype.FromPointerSlice(items) + }, + ), + fake, + } +} diff --git a/pkg/client/clientset/versioned/typed/sme.sap.com/v1alpha1/fake/fake_subscriptionprovider.go b/pkg/client/clientset/versioned/typed/sme.sap.com/v1alpha1/fake/fake_subscriptionprovider.go new file mode 100644 index 00000000..f3e7d914 --- /dev/null +++ b/pkg/client/clientset/versioned/typed/sme.sap.com/v1alpha1/fake/fake_subscriptionprovider.go @@ -0,0 +1,42 @@ +/* +SPDX-FileCopyrightText: 2026 SAP SE or an SAP affiliate company and cap-operator contributors +SPDX-License-Identifier: Apache-2.0 +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package fake + +import ( + v1alpha1 "github.com/sap/cap-operator/pkg/apis/sme.sap.com/v1alpha1" + smesapcomv1alpha1 "github.com/sap/cap-operator/pkg/client/applyconfiguration/sme.sap.com/v1alpha1" + typedsmesapcomv1alpha1 "github.com/sap/cap-operator/pkg/client/clientset/versioned/typed/sme.sap.com/v1alpha1" + gentype "k8s.io/client-go/gentype" +) + +// fakeSubscriptionProviders implements SubscriptionProviderInterface +type fakeSubscriptionProviders struct { + *gentype.FakeClientWithListAndApply[*v1alpha1.SubscriptionProvider, *v1alpha1.SubscriptionProviderList, *smesapcomv1alpha1.SubscriptionProviderApplyConfiguration] + Fake *FakeSmeV1alpha1 +} + +func newFakeSubscriptionProviders(fake *FakeSmeV1alpha1, namespace string) typedsmesapcomv1alpha1.SubscriptionProviderInterface { + return &fakeSubscriptionProviders{ + gentype.NewFakeClientWithListAndApply[*v1alpha1.SubscriptionProvider, *v1alpha1.SubscriptionProviderList, *smesapcomv1alpha1.SubscriptionProviderApplyConfiguration]( + fake.Fake, + namespace, + v1alpha1.SchemeGroupVersion.WithResource("subscriptionproviders"), + v1alpha1.SchemeGroupVersion.WithKind("SubscriptionProvider"), + func() *v1alpha1.SubscriptionProvider { return &v1alpha1.SubscriptionProvider{} }, + func() *v1alpha1.SubscriptionProviderList { return &v1alpha1.SubscriptionProviderList{} }, + func(dst, src *v1alpha1.SubscriptionProviderList) { dst.ListMeta = src.ListMeta }, + func(list *v1alpha1.SubscriptionProviderList) []*v1alpha1.SubscriptionProvider { + return gentype.ToPointerSlice(list.Items) + }, + func(list *v1alpha1.SubscriptionProviderList, items []*v1alpha1.SubscriptionProvider) { + list.Items = gentype.FromPointerSlice(items) + }, + ), + fake, + } +} diff --git a/pkg/client/clientset/versioned/typed/sme.sap.com/v1alpha1/generated_expansion.go b/pkg/client/clientset/versioned/typed/sme.sap.com/v1alpha1/generated_expansion.go index d1371a90..8588a09e 100644 --- a/pkg/client/clientset/versioned/typed/sme.sap.com/v1alpha1/generated_expansion.go +++ b/pkg/client/clientset/versioned/typed/sme.sap.com/v1alpha1/generated_expansion.go @@ -20,3 +20,7 @@ type CAPTenantOutputExpansion interface{} type ClusterDomainExpansion interface{} type DomainExpansion interface{} + +type SubscriptionExpansion interface{} + +type SubscriptionProviderExpansion interface{} diff --git a/pkg/client/clientset/versioned/typed/sme.sap.com/v1alpha1/sme.sap.com_client.go b/pkg/client/clientset/versioned/typed/sme.sap.com/v1alpha1/sme.sap.com_client.go index 07813cb3..4639cf56 100644 --- a/pkg/client/clientset/versioned/typed/sme.sap.com/v1alpha1/sme.sap.com_client.go +++ b/pkg/client/clientset/versioned/typed/sme.sap.com/v1alpha1/sme.sap.com_client.go @@ -24,6 +24,8 @@ type SmeV1alpha1Interface interface { CAPTenantOutputsGetter ClusterDomainsGetter DomainsGetter + SubscriptionsGetter + SubscriptionProvidersGetter } // SmeV1alpha1Client is used to interact with features provided by the sme.sap.com group. @@ -59,6 +61,14 @@ func (c *SmeV1alpha1Client) Domains(namespace string) DomainInterface { return newDomains(c, namespace) } +func (c *SmeV1alpha1Client) Subscriptions(namespace string) SubscriptionInterface { + return newSubscriptions(c, namespace) +} + +func (c *SmeV1alpha1Client) SubscriptionProviders(namespace string) SubscriptionProviderInterface { + return newSubscriptionProviders(c, namespace) +} + // NewForConfig creates a new SmeV1alpha1Client for the given config. // NewForConfig is equivalent to NewForConfigAndClient(c, httpClient), // where httpClient was generated with rest.HTTPClientFor(c). diff --git a/pkg/client/clientset/versioned/typed/sme.sap.com/v1alpha1/subscription.go b/pkg/client/clientset/versioned/typed/sme.sap.com/v1alpha1/subscription.go new file mode 100644 index 00000000..082a19f6 --- /dev/null +++ b/pkg/client/clientset/versioned/typed/sme.sap.com/v1alpha1/subscription.go @@ -0,0 +1,63 @@ +/* +SPDX-FileCopyrightText: 2026 SAP SE or an SAP affiliate company and cap-operator contributors +SPDX-License-Identifier: Apache-2.0 +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + context "context" + + smesapcomv1alpha1 "github.com/sap/cap-operator/pkg/apis/sme.sap.com/v1alpha1" + applyconfigurationsmesapcomv1alpha1 "github.com/sap/cap-operator/pkg/client/applyconfiguration/sme.sap.com/v1alpha1" + scheme "github.com/sap/cap-operator/pkg/client/clientset/versioned/scheme" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + gentype "k8s.io/client-go/gentype" +) + +// SubscriptionsGetter has a method to return a SubscriptionInterface. +// A group's client should implement this interface. +type SubscriptionsGetter interface { + Subscriptions(namespace string) SubscriptionInterface +} + +// SubscriptionInterface has methods to work with Subscription resources. +type SubscriptionInterface interface { + Create(ctx context.Context, subscription *smesapcomv1alpha1.Subscription, opts v1.CreateOptions) (*smesapcomv1alpha1.Subscription, error) + Update(ctx context.Context, subscription *smesapcomv1alpha1.Subscription, opts v1.UpdateOptions) (*smesapcomv1alpha1.Subscription, error) + // Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). + UpdateStatus(ctx context.Context, subscription *smesapcomv1alpha1.Subscription, opts v1.UpdateOptions) (*smesapcomv1alpha1.Subscription, error) + Delete(ctx context.Context, name string, opts v1.DeleteOptions) error + DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error + Get(ctx context.Context, name string, opts v1.GetOptions) (*smesapcomv1alpha1.Subscription, error) + List(ctx context.Context, opts v1.ListOptions) (*smesapcomv1alpha1.SubscriptionList, error) + Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) + Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *smesapcomv1alpha1.Subscription, err error) + Apply(ctx context.Context, subscription *applyconfigurationsmesapcomv1alpha1.SubscriptionApplyConfiguration, opts v1.ApplyOptions) (result *smesapcomv1alpha1.Subscription, err error) + // Add a +genclient:noStatus comment above the type to avoid generating ApplyStatus(). + ApplyStatus(ctx context.Context, subscription *applyconfigurationsmesapcomv1alpha1.SubscriptionApplyConfiguration, opts v1.ApplyOptions) (result *smesapcomv1alpha1.Subscription, err error) + SubscriptionExpansion +} + +// subscriptions implements SubscriptionInterface +type subscriptions struct { + *gentype.ClientWithListAndApply[*smesapcomv1alpha1.Subscription, *smesapcomv1alpha1.SubscriptionList, *applyconfigurationsmesapcomv1alpha1.SubscriptionApplyConfiguration] +} + +// newSubscriptions returns a Subscriptions +func newSubscriptions(c *SmeV1alpha1Client, namespace string) *subscriptions { + return &subscriptions{ + gentype.NewClientWithListAndApply[*smesapcomv1alpha1.Subscription, *smesapcomv1alpha1.SubscriptionList, *applyconfigurationsmesapcomv1alpha1.SubscriptionApplyConfiguration]( + "subscriptions", + c.RESTClient(), + scheme.ParameterCodec, + namespace, + func() *smesapcomv1alpha1.Subscription { return &smesapcomv1alpha1.Subscription{} }, + func() *smesapcomv1alpha1.SubscriptionList { return &smesapcomv1alpha1.SubscriptionList{} }, + ), + } +} diff --git a/pkg/client/clientset/versioned/typed/sme.sap.com/v1alpha1/subscriptionprovider.go b/pkg/client/clientset/versioned/typed/sme.sap.com/v1alpha1/subscriptionprovider.go new file mode 100644 index 00000000..6437e765 --- /dev/null +++ b/pkg/client/clientset/versioned/typed/sme.sap.com/v1alpha1/subscriptionprovider.go @@ -0,0 +1,65 @@ +/* +SPDX-FileCopyrightText: 2026 SAP SE or an SAP affiliate company and cap-operator contributors +SPDX-License-Identifier: Apache-2.0 +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + context "context" + + smesapcomv1alpha1 "github.com/sap/cap-operator/pkg/apis/sme.sap.com/v1alpha1" + applyconfigurationsmesapcomv1alpha1 "github.com/sap/cap-operator/pkg/client/applyconfiguration/sme.sap.com/v1alpha1" + scheme "github.com/sap/cap-operator/pkg/client/clientset/versioned/scheme" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + gentype "k8s.io/client-go/gentype" +) + +// SubscriptionProvidersGetter has a method to return a SubscriptionProviderInterface. +// A group's client should implement this interface. +type SubscriptionProvidersGetter interface { + SubscriptionProviders(namespace string) SubscriptionProviderInterface +} + +// SubscriptionProviderInterface has methods to work with SubscriptionProvider resources. +type SubscriptionProviderInterface interface { + Create(ctx context.Context, subscriptionProvider *smesapcomv1alpha1.SubscriptionProvider, opts v1.CreateOptions) (*smesapcomv1alpha1.SubscriptionProvider, error) + Update(ctx context.Context, subscriptionProvider *smesapcomv1alpha1.SubscriptionProvider, opts v1.UpdateOptions) (*smesapcomv1alpha1.SubscriptionProvider, error) + // Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). + UpdateStatus(ctx context.Context, subscriptionProvider *smesapcomv1alpha1.SubscriptionProvider, opts v1.UpdateOptions) (*smesapcomv1alpha1.SubscriptionProvider, error) + Delete(ctx context.Context, name string, opts v1.DeleteOptions) error + DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error + Get(ctx context.Context, name string, opts v1.GetOptions) (*smesapcomv1alpha1.SubscriptionProvider, error) + List(ctx context.Context, opts v1.ListOptions) (*smesapcomv1alpha1.SubscriptionProviderList, error) + Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) + Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *smesapcomv1alpha1.SubscriptionProvider, err error) + Apply(ctx context.Context, subscriptionProvider *applyconfigurationsmesapcomv1alpha1.SubscriptionProviderApplyConfiguration, opts v1.ApplyOptions) (result *smesapcomv1alpha1.SubscriptionProvider, err error) + // Add a +genclient:noStatus comment above the type to avoid generating ApplyStatus(). + ApplyStatus(ctx context.Context, subscriptionProvider *applyconfigurationsmesapcomv1alpha1.SubscriptionProviderApplyConfiguration, opts v1.ApplyOptions) (result *smesapcomv1alpha1.SubscriptionProvider, err error) + SubscriptionProviderExpansion +} + +// subscriptionProviders implements SubscriptionProviderInterface +type subscriptionProviders struct { + *gentype.ClientWithListAndApply[*smesapcomv1alpha1.SubscriptionProvider, *smesapcomv1alpha1.SubscriptionProviderList, *applyconfigurationsmesapcomv1alpha1.SubscriptionProviderApplyConfiguration] +} + +// newSubscriptionProviders returns a SubscriptionProviders +func newSubscriptionProviders(c *SmeV1alpha1Client, namespace string) *subscriptionProviders { + return &subscriptionProviders{ + gentype.NewClientWithListAndApply[*smesapcomv1alpha1.SubscriptionProvider, *smesapcomv1alpha1.SubscriptionProviderList, *applyconfigurationsmesapcomv1alpha1.SubscriptionProviderApplyConfiguration]( + "subscriptionproviders", + c.RESTClient(), + scheme.ParameterCodec, + namespace, + func() *smesapcomv1alpha1.SubscriptionProvider { return &smesapcomv1alpha1.SubscriptionProvider{} }, + func() *smesapcomv1alpha1.SubscriptionProviderList { + return &smesapcomv1alpha1.SubscriptionProviderList{} + }, + ), + } +} diff --git a/pkg/client/informers/externalversions/generic.go b/pkg/client/informers/externalversions/generic.go index a4865180..eec009a9 100644 --- a/pkg/client/informers/externalversions/generic.go +++ b/pkg/client/informers/externalversions/generic.go @@ -56,6 +56,10 @@ func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource return &genericInformer{resource: resource.GroupResource(), informer: f.Sme().V1alpha1().ClusterDomains().Informer()}, nil case v1alpha1.SchemeGroupVersion.WithResource("domains"): return &genericInformer{resource: resource.GroupResource(), informer: f.Sme().V1alpha1().Domains().Informer()}, nil + case v1alpha1.SchemeGroupVersion.WithResource("subscriptions"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Sme().V1alpha1().Subscriptions().Informer()}, nil + case v1alpha1.SchemeGroupVersion.WithResource("subscriptionproviders"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Sme().V1alpha1().SubscriptionProviders().Informer()}, nil } diff --git a/pkg/client/informers/externalversions/sme.sap.com/v1alpha1/interface.go b/pkg/client/informers/externalversions/sme.sap.com/v1alpha1/interface.go index bde41118..b94b95be 100644 --- a/pkg/client/informers/externalversions/sme.sap.com/v1alpha1/interface.go +++ b/pkg/client/informers/externalversions/sme.sap.com/v1alpha1/interface.go @@ -27,6 +27,10 @@ type Interface interface { ClusterDomains() ClusterDomainInformer // Domains returns a DomainInformer. Domains() DomainInformer + // Subscriptions returns a SubscriptionInformer. + Subscriptions() SubscriptionInformer + // SubscriptionProviders returns a SubscriptionProviderInformer. + SubscriptionProviders() SubscriptionProviderInformer } type version struct { @@ -74,3 +78,13 @@ func (v *version) ClusterDomains() ClusterDomainInformer { func (v *version) Domains() DomainInformer { return &domainInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} } + +// Subscriptions returns a SubscriptionInformer. +func (v *version) Subscriptions() SubscriptionInformer { + return &subscriptionInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} +} + +// SubscriptionProviders returns a SubscriptionProviderInformer. +func (v *version) SubscriptionProviders() SubscriptionProviderInformer { + return &subscriptionProviderInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} +} diff --git a/pkg/client/informers/externalversions/sme.sap.com/v1alpha1/subscription.go b/pkg/client/informers/externalversions/sme.sap.com/v1alpha1/subscription.go new file mode 100644 index 00000000..ae223391 --- /dev/null +++ b/pkg/client/informers/externalversions/sme.sap.com/v1alpha1/subscription.go @@ -0,0 +1,105 @@ +/* +SPDX-FileCopyrightText: 2026 SAP SE or an SAP affiliate company and cap-operator contributors +SPDX-License-Identifier: Apache-2.0 +*/ + +// Code generated by informer-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + context "context" + time "time" + + apissmesapcomv1alpha1 "github.com/sap/cap-operator/pkg/apis/sme.sap.com/v1alpha1" + versioned "github.com/sap/cap-operator/pkg/client/clientset/versioned" + internalinterfaces "github.com/sap/cap-operator/pkg/client/informers/externalversions/internalinterfaces" + smesapcomv1alpha1 "github.com/sap/cap-operator/pkg/client/listers/sme.sap.com/v1alpha1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + schema "k8s.io/apimachinery/pkg/runtime/schema" + watch "k8s.io/apimachinery/pkg/watch" + cache "k8s.io/client-go/tools/cache" +) + +// SubscriptionInformer provides access to a shared informer and lister for +// Subscriptions. +type SubscriptionInformer interface { + Informer() cache.SharedIndexInformer + Lister() smesapcomv1alpha1.SubscriptionLister +} + +type subscriptionInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc + namespace string +} + +// NewSubscriptionInformer constructs a new informer for Subscription type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewSubscriptionInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewSubscriptionInformerWithOptions(client, namespace, internalinterfaces.InformerOptions{ResyncPeriod: resyncPeriod, Indexers: indexers}) +} + +// NewFilteredSubscriptionInformer constructs a new informer for Subscription type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewFilteredSubscriptionInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer { + return NewSubscriptionInformerWithOptions(client, namespace, internalinterfaces.InformerOptions{ResyncPeriod: resyncPeriod, Indexers: indexers, TweakListOptions: tweakListOptions}) +} + +// NewSubscriptionInformerWithOptions constructs a new informer for Subscription type with additional options. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewSubscriptionInformerWithOptions(client versioned.Interface, namespace string, options internalinterfaces.InformerOptions) cache.SharedIndexInformer { + gvr := schema.GroupVersionResource{Group: "sme.sap.com", Version: "v1alpha1", Resource: "subscriptions"} + identifier := options.InformerName.WithResource(gvr) + tweakListOptions := options.TweakListOptions + return cache.NewSharedIndexInformerWithOptions( + cache.ToListWatcherWithWatchListSemantics(&cache.ListWatch{ + ListFunc: func(opts v1.ListOptions) (runtime.Object, error) { + if tweakListOptions != nil { + tweakListOptions(&opts) + } + return client.SmeV1alpha1().Subscriptions(namespace).List(context.Background(), opts) + }, + WatchFunc: func(opts v1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&opts) + } + return client.SmeV1alpha1().Subscriptions(namespace).Watch(context.Background(), opts) + }, + ListWithContextFunc: func(ctx context.Context, opts v1.ListOptions) (runtime.Object, error) { + if tweakListOptions != nil { + tweakListOptions(&opts) + } + return client.SmeV1alpha1().Subscriptions(namespace).List(ctx, opts) + }, + WatchFuncWithContext: func(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&opts) + } + return client.SmeV1alpha1().Subscriptions(namespace).Watch(ctx, opts) + }, + }, client), + &apissmesapcomv1alpha1.Subscription{}, + cache.SharedIndexInformerOptions{ + ResyncPeriod: options.ResyncPeriod, + Indexers: options.Indexers, + Identifier: identifier, + }, + ) +} + +func (f *subscriptionInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewSubscriptionInformerWithOptions(client, f.namespace, internalinterfaces.InformerOptions{ResyncPeriod: resyncPeriod, Indexers: cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, InformerName: f.factory.InformerName(), TweakListOptions: f.tweakListOptions}) +} + +func (f *subscriptionInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&apissmesapcomv1alpha1.Subscription{}, f.defaultInformer) +} + +func (f *subscriptionInformer) Lister() smesapcomv1alpha1.SubscriptionLister { + return smesapcomv1alpha1.NewSubscriptionLister(f.Informer().GetIndexer()) +} diff --git a/pkg/client/informers/externalversions/sme.sap.com/v1alpha1/subscriptionprovider.go b/pkg/client/informers/externalversions/sme.sap.com/v1alpha1/subscriptionprovider.go new file mode 100644 index 00000000..29d6cadb --- /dev/null +++ b/pkg/client/informers/externalversions/sme.sap.com/v1alpha1/subscriptionprovider.go @@ -0,0 +1,105 @@ +/* +SPDX-FileCopyrightText: 2026 SAP SE or an SAP affiliate company and cap-operator contributors +SPDX-License-Identifier: Apache-2.0 +*/ + +// Code generated by informer-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + context "context" + time "time" + + apissmesapcomv1alpha1 "github.com/sap/cap-operator/pkg/apis/sme.sap.com/v1alpha1" + versioned "github.com/sap/cap-operator/pkg/client/clientset/versioned" + internalinterfaces "github.com/sap/cap-operator/pkg/client/informers/externalversions/internalinterfaces" + smesapcomv1alpha1 "github.com/sap/cap-operator/pkg/client/listers/sme.sap.com/v1alpha1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + schema "k8s.io/apimachinery/pkg/runtime/schema" + watch "k8s.io/apimachinery/pkg/watch" + cache "k8s.io/client-go/tools/cache" +) + +// SubscriptionProviderInformer provides access to a shared informer and lister for +// SubscriptionProviders. +type SubscriptionProviderInformer interface { + Informer() cache.SharedIndexInformer + Lister() smesapcomv1alpha1.SubscriptionProviderLister +} + +type subscriptionProviderInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc + namespace string +} + +// NewSubscriptionProviderInformer constructs a new informer for SubscriptionProvider type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewSubscriptionProviderInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewSubscriptionProviderInformerWithOptions(client, namespace, internalinterfaces.InformerOptions{ResyncPeriod: resyncPeriod, Indexers: indexers}) +} + +// NewFilteredSubscriptionProviderInformer constructs a new informer for SubscriptionProvider type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewFilteredSubscriptionProviderInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer { + return NewSubscriptionProviderInformerWithOptions(client, namespace, internalinterfaces.InformerOptions{ResyncPeriod: resyncPeriod, Indexers: indexers, TweakListOptions: tweakListOptions}) +} + +// NewSubscriptionProviderInformerWithOptions constructs a new informer for SubscriptionProvider type with additional options. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewSubscriptionProviderInformerWithOptions(client versioned.Interface, namespace string, options internalinterfaces.InformerOptions) cache.SharedIndexInformer { + gvr := schema.GroupVersionResource{Group: "sme.sap.com", Version: "v1alpha1", Resource: "subscriptionproviders"} + identifier := options.InformerName.WithResource(gvr) + tweakListOptions := options.TweakListOptions + return cache.NewSharedIndexInformerWithOptions( + cache.ToListWatcherWithWatchListSemantics(&cache.ListWatch{ + ListFunc: func(opts v1.ListOptions) (runtime.Object, error) { + if tweakListOptions != nil { + tweakListOptions(&opts) + } + return client.SmeV1alpha1().SubscriptionProviders(namespace).List(context.Background(), opts) + }, + WatchFunc: func(opts v1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&opts) + } + return client.SmeV1alpha1().SubscriptionProviders(namespace).Watch(context.Background(), opts) + }, + ListWithContextFunc: func(ctx context.Context, opts v1.ListOptions) (runtime.Object, error) { + if tweakListOptions != nil { + tweakListOptions(&opts) + } + return client.SmeV1alpha1().SubscriptionProviders(namespace).List(ctx, opts) + }, + WatchFuncWithContext: func(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&opts) + } + return client.SmeV1alpha1().SubscriptionProviders(namespace).Watch(ctx, opts) + }, + }, client), + &apissmesapcomv1alpha1.SubscriptionProvider{}, + cache.SharedIndexInformerOptions{ + ResyncPeriod: options.ResyncPeriod, + Indexers: options.Indexers, + Identifier: identifier, + }, + ) +} + +func (f *subscriptionProviderInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewSubscriptionProviderInformerWithOptions(client, f.namespace, internalinterfaces.InformerOptions{ResyncPeriod: resyncPeriod, Indexers: cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, InformerName: f.factory.InformerName(), TweakListOptions: f.tweakListOptions}) +} + +func (f *subscriptionProviderInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&apissmesapcomv1alpha1.SubscriptionProvider{}, f.defaultInformer) +} + +func (f *subscriptionProviderInformer) Lister() smesapcomv1alpha1.SubscriptionProviderLister { + return smesapcomv1alpha1.NewSubscriptionProviderLister(f.Informer().GetIndexer()) +} diff --git a/pkg/client/listers/sme.sap.com/v1alpha1/expansion_generated.go b/pkg/client/listers/sme.sap.com/v1alpha1/expansion_generated.go index c973f8a2..9ee6f6e4 100644 --- a/pkg/client/listers/sme.sap.com/v1alpha1/expansion_generated.go +++ b/pkg/client/listers/sme.sap.com/v1alpha1/expansion_generated.go @@ -62,3 +62,19 @@ type DomainListerExpansion interface{} // DomainNamespaceListerExpansion allows custom methods to be added to // DomainNamespaceLister. type DomainNamespaceListerExpansion interface{} + +// SubscriptionListerExpansion allows custom methods to be added to +// SubscriptionLister. +type SubscriptionListerExpansion interface{} + +// SubscriptionNamespaceListerExpansion allows custom methods to be added to +// SubscriptionNamespaceLister. +type SubscriptionNamespaceListerExpansion interface{} + +// SubscriptionProviderListerExpansion allows custom methods to be added to +// SubscriptionProviderLister. +type SubscriptionProviderListerExpansion interface{} + +// SubscriptionProviderNamespaceListerExpansion allows custom methods to be added to +// SubscriptionProviderNamespaceLister. +type SubscriptionProviderNamespaceListerExpansion interface{} diff --git a/pkg/client/listers/sme.sap.com/v1alpha1/subscription.go b/pkg/client/listers/sme.sap.com/v1alpha1/subscription.go new file mode 100644 index 00000000..97153df1 --- /dev/null +++ b/pkg/client/listers/sme.sap.com/v1alpha1/subscription.go @@ -0,0 +1,59 @@ +/* +SPDX-FileCopyrightText: 2026 SAP SE or an SAP affiliate company and cap-operator contributors +SPDX-License-Identifier: Apache-2.0 +*/ + +// Code generated by lister-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + smesapcomv1alpha1 "github.com/sap/cap-operator/pkg/apis/sme.sap.com/v1alpha1" + labels "k8s.io/apimachinery/pkg/labels" + listers "k8s.io/client-go/listers" + cache "k8s.io/client-go/tools/cache" +) + +// SubscriptionLister helps list Subscriptions. +// All objects returned here must be treated as read-only. +type SubscriptionLister interface { + // List lists all Subscriptions in the indexer. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*smesapcomv1alpha1.Subscription, err error) + // Subscriptions returns an object that can list and get Subscriptions. + Subscriptions(namespace string) SubscriptionNamespaceLister + SubscriptionListerExpansion +} + +// subscriptionLister implements the SubscriptionLister interface. +type subscriptionLister struct { + listers.ResourceIndexer[*smesapcomv1alpha1.Subscription] +} + +// NewSubscriptionLister returns a new SubscriptionLister. +func NewSubscriptionLister(indexer cache.Indexer) SubscriptionLister { + return &subscriptionLister{listers.New[*smesapcomv1alpha1.Subscription](indexer, smesapcomv1alpha1.Resource("subscription"))} +} + +// Subscriptions returns an object that can list and get Subscriptions. +func (s *subscriptionLister) Subscriptions(namespace string) SubscriptionNamespaceLister { + return subscriptionNamespaceLister{listers.NewNamespaced[*smesapcomv1alpha1.Subscription](s.ResourceIndexer, namespace)} +} + +// SubscriptionNamespaceLister helps list and get Subscriptions. +// All objects returned here must be treated as read-only. +type SubscriptionNamespaceLister interface { + // List lists all Subscriptions in the indexer for a given namespace. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*smesapcomv1alpha1.Subscription, err error) + // Get retrieves the Subscription from the indexer for a given namespace and name. + // Objects returned here must be treated as read-only. + Get(name string) (*smesapcomv1alpha1.Subscription, error) + SubscriptionNamespaceListerExpansion +} + +// subscriptionNamespaceLister implements the SubscriptionNamespaceLister +// interface. +type subscriptionNamespaceLister struct { + listers.ResourceIndexer[*smesapcomv1alpha1.Subscription] +} diff --git a/pkg/client/listers/sme.sap.com/v1alpha1/subscriptionprovider.go b/pkg/client/listers/sme.sap.com/v1alpha1/subscriptionprovider.go new file mode 100644 index 00000000..5c16618c --- /dev/null +++ b/pkg/client/listers/sme.sap.com/v1alpha1/subscriptionprovider.go @@ -0,0 +1,59 @@ +/* +SPDX-FileCopyrightText: 2026 SAP SE or an SAP affiliate company and cap-operator contributors +SPDX-License-Identifier: Apache-2.0 +*/ + +// Code generated by lister-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + smesapcomv1alpha1 "github.com/sap/cap-operator/pkg/apis/sme.sap.com/v1alpha1" + labels "k8s.io/apimachinery/pkg/labels" + listers "k8s.io/client-go/listers" + cache "k8s.io/client-go/tools/cache" +) + +// SubscriptionProviderLister helps list SubscriptionProviders. +// All objects returned here must be treated as read-only. +type SubscriptionProviderLister interface { + // List lists all SubscriptionProviders in the indexer. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*smesapcomv1alpha1.SubscriptionProvider, err error) + // SubscriptionProviders returns an object that can list and get SubscriptionProviders. + SubscriptionProviders(namespace string) SubscriptionProviderNamespaceLister + SubscriptionProviderListerExpansion +} + +// subscriptionProviderLister implements the SubscriptionProviderLister interface. +type subscriptionProviderLister struct { + listers.ResourceIndexer[*smesapcomv1alpha1.SubscriptionProvider] +} + +// NewSubscriptionProviderLister returns a new SubscriptionProviderLister. +func NewSubscriptionProviderLister(indexer cache.Indexer) SubscriptionProviderLister { + return &subscriptionProviderLister{listers.New[*smesapcomv1alpha1.SubscriptionProvider](indexer, smesapcomv1alpha1.Resource("subscriptionprovider"))} +} + +// SubscriptionProviders returns an object that can list and get SubscriptionProviders. +func (s *subscriptionProviderLister) SubscriptionProviders(namespace string) SubscriptionProviderNamespaceLister { + return subscriptionProviderNamespaceLister{listers.NewNamespaced[*smesapcomv1alpha1.SubscriptionProvider](s.ResourceIndexer, namespace)} +} + +// SubscriptionProviderNamespaceLister helps list and get SubscriptionProviders. +// All objects returned here must be treated as read-only. +type SubscriptionProviderNamespaceLister interface { + // List lists all SubscriptionProviders in the indexer for a given namespace. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*smesapcomv1alpha1.SubscriptionProvider, err error) + // Get retrieves the SubscriptionProvider from the indexer for a given namespace and name. + // Objects returned here must be treated as read-only. + Get(name string) (*smesapcomv1alpha1.SubscriptionProvider, error) + SubscriptionProviderNamespaceListerExpansion +} + +// subscriptionProviderNamespaceLister implements the SubscriptionProviderNamespaceLister +// interface. +type subscriptionProviderNamespaceLister struct { + listers.ResourceIndexer[*smesapcomv1alpha1.SubscriptionProvider] +}