diff --git a/apis/account/v1alpha1/zz_generated.conversion_hubs.go b/apis/account/v1alpha1/zz_generated.conversion_hubs.go index bc4f82a..06c91c8 100755 --- a/apis/account/v1alpha1/zz_generated.conversion_hubs.go +++ b/apis/account/v1alpha1/zz_generated.conversion_hubs.go @@ -24,5 +24,8 @@ func (tr *DirectoryEntitlement) Hub() {} // Hub marks this type as a conversion hub. func (tr *SubaccountServiceBinding) Hub() {} +// Hub marks this type as a conversion hub. +func (tr *SubaccountServiceBroker) Hub() {} + // Hub marks this type as a conversion hub. func (tr *SubaccountServiceInstance) Hub() {} diff --git a/apis/account/v1alpha1/zz_generated.deepcopy.go b/apis/account/v1alpha1/zz_generated.deepcopy.go index 06d162b..117f67e 100644 --- a/apis/account/v1alpha1/zz_generated.deepcopy.go +++ b/apis/account/v1alpha1/zz_generated.deepcopy.go @@ -1938,6 +1938,261 @@ func (in *SubaccountServiceBindingStatus) DeepCopy() *SubaccountServiceBindingSt return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *SubaccountServiceBroker) DeepCopyInto(out *SubaccountServiceBroker) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + in.Status.DeepCopyInto(&out.Status) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SubaccountServiceBroker. +func (in *SubaccountServiceBroker) DeepCopy() *SubaccountServiceBroker { + if in == nil { + return nil + } + out := new(SubaccountServiceBroker) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *SubaccountServiceBroker) 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 *SubaccountServiceBrokerInitParameters) DeepCopyInto(out *SubaccountServiceBrokerInitParameters) { + *out = *in + if in.Description != nil { + in, out := &in.Description, &out.Description + *out = new(string) + **out = **in + } + if in.Name != nil { + in, out := &in.Name, &out.Name + *out = new(string) + **out = **in + } + if in.SubaccountID != nil { + in, out := &in.SubaccountID, &out.SubaccountID + *out = new(string) + **out = **in + } + if in.SubaccountRef != nil { + in, out := &in.SubaccountRef, &out.SubaccountRef + *out = new(v1.Reference) + (*in).DeepCopyInto(*out) + } + if in.SubaccountSelector != nil { + in, out := &in.SubaccountSelector, &out.SubaccountSelector + *out = new(v1.Selector) + (*in).DeepCopyInto(*out) + } + if in.URL != nil { + in, out := &in.URL, &out.URL + *out = new(string) + **out = **in + } + if in.Username != nil { + in, out := &in.Username, &out.Username + *out = new(string) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SubaccountServiceBrokerInitParameters. +func (in *SubaccountServiceBrokerInitParameters) DeepCopy() *SubaccountServiceBrokerInitParameters { + if in == nil { + return nil + } + out := new(SubaccountServiceBrokerInitParameters) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *SubaccountServiceBrokerList) DeepCopyInto(out *SubaccountServiceBrokerList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]SubaccountServiceBroker, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SubaccountServiceBrokerList. +func (in *SubaccountServiceBrokerList) DeepCopy() *SubaccountServiceBrokerList { + if in == nil { + return nil + } + out := new(SubaccountServiceBrokerList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *SubaccountServiceBrokerList) 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 *SubaccountServiceBrokerObservation) DeepCopyInto(out *SubaccountServiceBrokerObservation) { + *out = *in + if in.CreatedDate != nil { + in, out := &in.CreatedDate, &out.CreatedDate + *out = new(string) + **out = **in + } + if in.Description != nil { + in, out := &in.Description, &out.Description + *out = new(string) + **out = **in + } + if in.ID != nil { + in, out := &in.ID, &out.ID + *out = new(string) + **out = **in + } + if in.LastModified != nil { + in, out := &in.LastModified, &out.LastModified + *out = new(string) + **out = **in + } + if in.Name != nil { + in, out := &in.Name, &out.Name + *out = new(string) + **out = **in + } + if in.Ready != nil { + in, out := &in.Ready, &out.Ready + *out = new(bool) + **out = **in + } + if in.SubaccountID != nil { + in, out := &in.SubaccountID, &out.SubaccountID + *out = new(string) + **out = **in + } + if in.URL != nil { + in, out := &in.URL, &out.URL + *out = new(string) + **out = **in + } + if in.Username != nil { + in, out := &in.Username, &out.Username + *out = new(string) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SubaccountServiceBrokerObservation. +func (in *SubaccountServiceBrokerObservation) DeepCopy() *SubaccountServiceBrokerObservation { + if in == nil { + return nil + } + out := new(SubaccountServiceBrokerObservation) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *SubaccountServiceBrokerParameters) DeepCopyInto(out *SubaccountServiceBrokerParameters) { + *out = *in + if in.Description != nil { + in, out := &in.Description, &out.Description + *out = new(string) + **out = **in + } + if in.Name != nil { + in, out := &in.Name, &out.Name + *out = new(string) + **out = **in + } + out.PasswordSecretRef = in.PasswordSecretRef + if in.SubaccountID != nil { + in, out := &in.SubaccountID, &out.SubaccountID + *out = new(string) + **out = **in + } + if in.SubaccountRef != nil { + in, out := &in.SubaccountRef, &out.SubaccountRef + *out = new(v1.Reference) + (*in).DeepCopyInto(*out) + } + if in.SubaccountSelector != nil { + in, out := &in.SubaccountSelector, &out.SubaccountSelector + *out = new(v1.Selector) + (*in).DeepCopyInto(*out) + } + if in.URL != nil { + in, out := &in.URL, &out.URL + *out = new(string) + **out = **in + } + if in.Username != nil { + in, out := &in.Username, &out.Username + *out = new(string) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SubaccountServiceBrokerParameters. +func (in *SubaccountServiceBrokerParameters) DeepCopy() *SubaccountServiceBrokerParameters { + if in == nil { + return nil + } + out := new(SubaccountServiceBrokerParameters) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *SubaccountServiceBrokerSpec) DeepCopyInto(out *SubaccountServiceBrokerSpec) { + *out = *in + in.ResourceSpec.DeepCopyInto(&out.ResourceSpec) + in.ForProvider.DeepCopyInto(&out.ForProvider) + in.InitProvider.DeepCopyInto(&out.InitProvider) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SubaccountServiceBrokerSpec. +func (in *SubaccountServiceBrokerSpec) DeepCopy() *SubaccountServiceBrokerSpec { + if in == nil { + return nil + } + out := new(SubaccountServiceBrokerSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *SubaccountServiceBrokerStatus) DeepCopyInto(out *SubaccountServiceBrokerStatus) { + *out = *in + in.ResourceStatus.DeepCopyInto(&out.ResourceStatus) + in.AtProvider.DeepCopyInto(&out.AtProvider) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SubaccountServiceBrokerStatus. +func (in *SubaccountServiceBrokerStatus) DeepCopy() *SubaccountServiceBrokerStatus { + if in == nil { + return nil + } + out := new(SubaccountServiceBrokerStatus) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *SubaccountServiceInstance) DeepCopyInto(out *SubaccountServiceInstance) { *out = *in diff --git a/apis/account/v1alpha1/zz_generated.managed.go b/apis/account/v1alpha1/zz_generated.managed.go index ab0e73b..1616e32 100644 --- a/apis/account/v1alpha1/zz_generated.managed.go +++ b/apis/account/v1alpha1/zz_generated.managed.go @@ -500,6 +500,66 @@ func (mg *SubaccountServiceBinding) SetWriteConnectionSecretToReference(r *xpv1. mg.Spec.WriteConnectionSecretToReference = r } +// GetCondition of this SubaccountServiceBroker. +func (mg *SubaccountServiceBroker) GetCondition(ct xpv1.ConditionType) xpv1.Condition { + return mg.Status.GetCondition(ct) +} + +// GetDeletionPolicy of this SubaccountServiceBroker. +func (mg *SubaccountServiceBroker) GetDeletionPolicy() xpv1.DeletionPolicy { + return mg.Spec.DeletionPolicy +} + +// GetManagementPolicies of this SubaccountServiceBroker. +func (mg *SubaccountServiceBroker) GetManagementPolicies() xpv1.ManagementPolicies { + return mg.Spec.ManagementPolicies +} + +// GetProviderConfigReference of this SubaccountServiceBroker. +func (mg *SubaccountServiceBroker) GetProviderConfigReference() *xpv1.Reference { + return mg.Spec.ProviderConfigReference +} + +// GetPublishConnectionDetailsTo of this SubaccountServiceBroker. +func (mg *SubaccountServiceBroker) GetPublishConnectionDetailsTo() *xpv1.PublishConnectionDetailsTo { + return mg.Spec.PublishConnectionDetailsTo +} + +// GetWriteConnectionSecretToReference of this SubaccountServiceBroker. +func (mg *SubaccountServiceBroker) GetWriteConnectionSecretToReference() *xpv1.SecretReference { + return mg.Spec.WriteConnectionSecretToReference +} + +// SetConditions of this SubaccountServiceBroker. +func (mg *SubaccountServiceBroker) SetConditions(c ...xpv1.Condition) { + mg.Status.SetConditions(c...) +} + +// SetDeletionPolicy of this SubaccountServiceBroker. +func (mg *SubaccountServiceBroker) SetDeletionPolicy(r xpv1.DeletionPolicy) { + mg.Spec.DeletionPolicy = r +} + +// SetManagementPolicies of this SubaccountServiceBroker. +func (mg *SubaccountServiceBroker) SetManagementPolicies(r xpv1.ManagementPolicies) { + mg.Spec.ManagementPolicies = r +} + +// SetProviderConfigReference of this SubaccountServiceBroker. +func (mg *SubaccountServiceBroker) SetProviderConfigReference(r *xpv1.Reference) { + mg.Spec.ProviderConfigReference = r +} + +// SetPublishConnectionDetailsTo of this SubaccountServiceBroker. +func (mg *SubaccountServiceBroker) SetPublishConnectionDetailsTo(r *xpv1.PublishConnectionDetailsTo) { + mg.Spec.PublishConnectionDetailsTo = r +} + +// SetWriteConnectionSecretToReference of this SubaccountServiceBroker. +func (mg *SubaccountServiceBroker) SetWriteConnectionSecretToReference(r *xpv1.SecretReference) { + mg.Spec.WriteConnectionSecretToReference = r +} + // GetCondition of this SubaccountServiceInstance. func (mg *SubaccountServiceInstance) GetCondition(ct xpv1.ConditionType) xpv1.Condition { return mg.Status.GetCondition(ct) diff --git a/apis/account/v1alpha1/zz_generated.managedlist.go b/apis/account/v1alpha1/zz_generated.managedlist.go index 5f60c75..91c48f0 100644 --- a/apis/account/v1alpha1/zz_generated.managedlist.go +++ b/apis/account/v1alpha1/zz_generated.managedlist.go @@ -92,6 +92,15 @@ func (l *SubaccountServiceBindingList) GetItems() []resource.Managed { return items } +// GetItems of this SubaccountServiceBrokerList. +func (l *SubaccountServiceBrokerList) GetItems() []resource.Managed { + items := make([]resource.Managed, len(l.Items)) + for i := range l.Items { + items[i] = &l.Items[i] + } + return items +} + // GetItems of this SubaccountServiceInstanceList. func (l *SubaccountServiceInstanceList) GetItems() []resource.Managed { items := make([]resource.Managed, len(l.Items)) diff --git a/apis/account/v1alpha1/zz_generated.resolvers.go b/apis/account/v1alpha1/zz_generated.resolvers.go index a7ea779..e0ab841 100644 --- a/apis/account/v1alpha1/zz_generated.resolvers.go +++ b/apis/account/v1alpha1/zz_generated.resolvers.go @@ -245,6 +245,48 @@ func (mg *Subaccount) ResolveReferences(ctx context.Context, c client.Reader) er return nil } +// ResolveReferences of this SubaccountServiceBroker. +func (mg *SubaccountServiceBroker) ResolveReferences(ctx context.Context, c client.Reader) error { + r := reference.NewAPIResolver(c, mg) + + var rsp reference.ResolutionResponse + var err error + + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.SubaccountID), + Extract: reference.ExternalName(), + Reference: mg.Spec.ForProvider.SubaccountRef, + Selector: mg.Spec.ForProvider.SubaccountSelector, + To: reference.To{ + List: &SubaccountList{}, + Managed: &Subaccount{}, + }, + }) + if err != nil { + return errors.Wrap(err, "mg.Spec.ForProvider.SubaccountID") + } + mg.Spec.ForProvider.SubaccountID = reference.ToPtrValue(rsp.ResolvedValue) + mg.Spec.ForProvider.SubaccountRef = rsp.ResolvedReference + + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.SubaccountID), + Extract: reference.ExternalName(), + Reference: mg.Spec.InitProvider.SubaccountRef, + Selector: mg.Spec.InitProvider.SubaccountSelector, + To: reference.To{ + List: &SubaccountList{}, + Managed: &Subaccount{}, + }, + }) + if err != nil { + return errors.Wrap(err, "mg.Spec.InitProvider.SubaccountID") + } + mg.Spec.InitProvider.SubaccountID = reference.ToPtrValue(rsp.ResolvedValue) + mg.Spec.InitProvider.SubaccountRef = rsp.ResolvedReference + + return nil +} + // ResolveReferences of this Subscription. func (mg *Subscription) ResolveReferences(ctx context.Context, c client.Reader) error { r := reference.NewAPIResolver(c, mg) diff --git a/apis/account/v1alpha1/zz_subaccountservicebroker_terraformed.go b/apis/account/v1alpha1/zz_subaccountservicebroker_terraformed.go new file mode 100755 index 0000000..aff9161 --- /dev/null +++ b/apis/account/v1alpha1/zz_subaccountservicebroker_terraformed.go @@ -0,0 +1,141 @@ +/* +Copyright 2022 The Crossplane Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by upjet. DO NOT EDIT. + +package v1alpha1 + +import ( + "dario.cat/mergo" + "github.com/pkg/errors" + + "github.com/crossplane/upjet/pkg/resource" + "github.com/crossplane/upjet/pkg/resource/json" +) + +// GetTerraformResourceType returns Terraform resource type for this SubaccountServiceBroker +func (mg *SubaccountServiceBroker) GetTerraformResourceType() string { + return "btp_subaccount_service_broker" +} + +// GetConnectionDetailsMapping for this SubaccountServiceBroker +func (tr *SubaccountServiceBroker) GetConnectionDetailsMapping() map[string]string { + return map[string]string{"password": "spec.forProvider.passwordSecretRef"} +} + +// GetObservation of this SubaccountServiceBroker +func (tr *SubaccountServiceBroker) GetObservation() (map[string]any, error) { + o, err := json.TFParser.Marshal(tr.Status.AtProvider) + if err != nil { + return nil, err + } + base := map[string]any{} + return base, json.TFParser.Unmarshal(o, &base) +} + +// SetObservation for this SubaccountServiceBroker +func (tr *SubaccountServiceBroker) SetObservation(obs map[string]any) error { + p, err := json.TFParser.Marshal(obs) + if err != nil { + return err + } + return json.TFParser.Unmarshal(p, &tr.Status.AtProvider) +} + +// GetID returns ID of underlying Terraform resource of this SubaccountServiceBroker +func (tr *SubaccountServiceBroker) GetID() string { + if tr.Status.AtProvider.ID == nil { + return "" + } + return *tr.Status.AtProvider.ID +} + +// GetParameters of this SubaccountServiceBroker +func (tr *SubaccountServiceBroker) GetParameters() (map[string]any, error) { + p, err := json.TFParser.Marshal(tr.Spec.ForProvider) + if err != nil { + return nil, err + } + base := map[string]any{} + return base, json.TFParser.Unmarshal(p, &base) +} + +// SetParameters for this SubaccountServiceBroker +func (tr *SubaccountServiceBroker) SetParameters(params map[string]any) error { + p, err := json.TFParser.Marshal(params) + if err != nil { + return err + } + return json.TFParser.Unmarshal(p, &tr.Spec.ForProvider) +} + +// GetInitParameters of this SubaccountServiceBroker +func (tr *SubaccountServiceBroker) GetInitParameters() (map[string]any, error) { + p, err := json.TFParser.Marshal(tr.Spec.InitProvider) + if err != nil { + return nil, err + } + base := map[string]any{} + return base, json.TFParser.Unmarshal(p, &base) +} + +// GetInitParameters of this SubaccountServiceBroker +func (tr *SubaccountServiceBroker) GetMergedParameters(shouldMergeInitProvider bool) (map[string]any, error) { + params, err := tr.GetParameters() + if err != nil { + return nil, errors.Wrapf(err, "cannot get parameters for resource '%q'", tr.GetName()) + } + if !shouldMergeInitProvider { + return params, nil + } + + initParams, err := tr.GetInitParameters() + if err != nil { + return nil, errors.Wrapf(err, "cannot get init parameters for resource '%q'", tr.GetName()) + } + + // Note(lsviben): mergo.WithSliceDeepCopy is needed to merge the + // slices from the initProvider to forProvider. As it also sets + // overwrite to true, we need to set it back to false, we don't + // want to overwrite the forProvider fields with the initProvider + // fields. + err = mergo.Merge(¶ms, initParams, mergo.WithSliceDeepCopy, func(c *mergo.Config) { + c.Overwrite = false + }) + if err != nil { + return nil, errors.Wrapf(err, "cannot merge spec.initProvider and spec.forProvider parameters for resource '%q'", tr.GetName()) + } + + return params, nil +} + +// LateInitialize this SubaccountServiceBroker using its observed tfState. +// returns True if there are any spec changes for the resource. +func (tr *SubaccountServiceBroker) LateInitialize(attrs []byte) (bool, error) { + params := &SubaccountServiceBrokerParameters{} + if err := json.TFParser.Unmarshal(attrs, params); err != nil { + return false, errors.Wrap(err, "failed to unmarshal Terraform state parameters for late-initialization") + } + opts := []resource.GenericLateInitializerOption{resource.WithZeroValueJSONOmitEmptyFilter(resource.CNameWildcard)} + + li := resource.NewGenericLateInitializer(opts...) + return li.LateInitialize(&tr.Spec.ForProvider, params) +} + +// GetTerraformSchemaVersion returns the associated Terraform schema version +func (tr *SubaccountServiceBroker) GetTerraformSchemaVersion() int { + return 0 +} diff --git a/apis/account/v1alpha1/zz_subaccountservicebroker_types.go b/apis/account/v1alpha1/zz_subaccountservicebroker_types.go new file mode 100755 index 0000000..bf266cd --- /dev/null +++ b/apis/account/v1alpha1/zz_subaccountservicebroker_types.go @@ -0,0 +1,209 @@ +/* +Copyright 2022 The Crossplane Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by upjet. DO NOT EDIT. + +package v1alpha1 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime/schema" + + v1 "github.com/crossplane/crossplane-runtime/apis/common/v1" +) + +type SubaccountServiceBrokerInitParameters struct { + + // (String) The description of the service broker. + // The description of the service broker. + Description *string `json:"description,omitempty" tf:"description,omitempty"` + + // (String) The name of the service broker. + // The name of the service broker. + Name *string `json:"name,omitempty" tf:"name,omitempty"` + + // (String) The ID of the subaccount. + // The ID of the subaccount. + // +crossplane:generate:reference:type=github.com/sap/crossplane-provider-btp/apis/account/v1alpha1.Subaccount + // +crossplane:generate:reference:extractor=github.com/crossplane/crossplane-runtime/pkg/reference.ExternalName() + // +crossplane:generate:reference:refFieldName=SubaccountRef + // +crossplane:generate:reference:selectorFieldName=SubaccountSelector + SubaccountID *string `json:"subaccountId,omitempty" tf:"subaccount_id,omitempty"` + + // Reference to a Subaccount in account to populate subaccountId. + // +kubebuilder:validation:Optional + SubaccountRef *v1.Reference `json:"subaccountRef,omitempty" tf:"-"` + + // Selector for a Subaccount in account to populate subaccountId. + // +kubebuilder:validation:Optional + SubaccountSelector *v1.Selector `json:"subaccountSelector,omitempty" tf:"-"` + + // (String) The URL of the service broker. + // The URL of the service broker. + URL *string `json:"url,omitempty" tf:"url,omitempty"` + + // (String) The username for basic authentication against the service broker. + // The username for basic authentication against the service broker. + Username *string `json:"username,omitempty" tf:"username,omitempty"` +} + +type SubaccountServiceBrokerObservation struct { + + // (String) The date and time when the resource was created in RFC3339 format. + // The date and time when the resource was created in [RFC3339](https://www.ietf.org/rfc/rfc3339.txt) format. + CreatedDate *string `json:"createdDate,omitempty" tf:"created_date,omitempty"` + + // (String) The description of the service broker. + // The description of the service broker. + Description *string `json:"description,omitempty" tf:"description,omitempty"` + + // (String) The ID of the service broker. + ID *string `json:"id,omitempty" tf:"id,omitempty"` + + // (String) The date and time when the resource was last modified in RFC3339 format. + // The date and time when the resource was last modified in [RFC3339](https://www.ietf.org/rfc/rfc3339.txt) format. + LastModified *string `json:"lastModified,omitempty" tf:"last_modified,omitempty"` + + // (String) The name of the service broker. + // The name of the service broker. + Name *string `json:"name,omitempty" tf:"name,omitempty"` + + // (Boolean) Shows whether the service broker is ready. + // Shows whether the service broker is ready. + Ready *bool `json:"ready,omitempty" tf:"ready,omitempty"` + + // (String) The ID of the subaccount. + // The ID of the subaccount. + SubaccountID *string `json:"subaccountId,omitempty" tf:"subaccount_id,omitempty"` + + // (String) The URL of the service broker. + // The URL of the service broker. + URL *string `json:"url,omitempty" tf:"url,omitempty"` + + // (String) The username for basic authentication against the service broker. + // The username for basic authentication against the service broker. + Username *string `json:"username,omitempty" tf:"username,omitempty"` +} + +type SubaccountServiceBrokerParameters struct { + + // (String) The description of the service broker. + // The description of the service broker. + // +kubebuilder:validation:Optional + Description *string `json:"description,omitempty" tf:"description,omitempty"` + + // (String) The name of the service broker. + // The name of the service broker. + // +kubebuilder:validation:Optional + Name *string `json:"name,omitempty" tf:"name,omitempty"` + + // (String, Sensitive) The password for basic authentication against the service broker. + // The password for basic authentication against the service broker. + // +kubebuilder:validation:Optional + PasswordSecretRef v1.SecretKeySelector `json:"passwordSecretRef" tf:"-"` + + // (String) The ID of the subaccount. + // The ID of the subaccount. + // +crossplane:generate:reference:type=github.com/sap/crossplane-provider-btp/apis/account/v1alpha1.Subaccount + // +crossplane:generate:reference:extractor=github.com/crossplane/crossplane-runtime/pkg/reference.ExternalName() + // +crossplane:generate:reference:refFieldName=SubaccountRef + // +crossplane:generate:reference:selectorFieldName=SubaccountSelector + // +kubebuilder:validation:Optional + SubaccountID *string `json:"subaccountId,omitempty" tf:"subaccount_id,omitempty"` + + // Reference to a Subaccount in account to populate subaccountId. + // +kubebuilder:validation:Optional + SubaccountRef *v1.Reference `json:"subaccountRef,omitempty" tf:"-"` + + // Selector for a Subaccount in account to populate subaccountId. + // +kubebuilder:validation:Optional + SubaccountSelector *v1.Selector `json:"subaccountSelector,omitempty" tf:"-"` + + // (String) The URL of the service broker. + // The URL of the service broker. + // +kubebuilder:validation:Optional + URL *string `json:"url,omitempty" tf:"url,omitempty"` + + // (String) The username for basic authentication against the service broker. + // The username for basic authentication against the service broker. + // +kubebuilder:validation:Optional + Username *string `json:"username,omitempty" tf:"username,omitempty"` +} + +// SubaccountServiceBrokerSpec defines the desired state of SubaccountServiceBroker +type SubaccountServiceBrokerSpec struct { + v1.ResourceSpec `json:",inline"` + ForProvider SubaccountServiceBrokerParameters `json:"forProvider"` + // THIS IS A BETA FIELD. It will be honored + // unless the Management Policies feature flag is disabled. + // InitProvider holds the same fields as ForProvider, with the exception + // of Identifier and other resource reference fields. The fields that are + // in InitProvider are merged into ForProvider when the resource is created. + // The same fields are also added to the terraform ignore_changes hook, to + // avoid updating them after creation. This is useful for fields that are + // required on creation, but we do not desire to update them after creation, + // for example because of an external controller is managing them, like an + // autoscaler. + InitProvider SubaccountServiceBrokerInitParameters `json:"initProvider,omitempty"` +} + +// SubaccountServiceBrokerStatus defines the observed state of SubaccountServiceBroker. +type SubaccountServiceBrokerStatus struct { + v1.ResourceStatus `json:",inline"` + AtProvider SubaccountServiceBrokerObservation `json:"atProvider,omitempty"` +} + +// +kubebuilder:object:root=true +// +kubebuilder:subresource:status +// +kubebuilder:storageversion + +// SubaccountServiceBroker is the Schema for the SubaccountServiceBrokers API. Registers a service service broker in a subaccount. Tip: You must be assigned to the admin role of the subaccount. +// +kubebuilder:printcolumn:name="READY",type="string",JSONPath=".status.conditions[?(@.type=='Ready')].status" +// +kubebuilder:printcolumn:name="SYNCED",type="string",JSONPath=".status.conditions[?(@.type=='Synced')].status" +// +kubebuilder:printcolumn:name="EXTERNAL-NAME",type="string",JSONPath=".metadata.annotations.crossplane\\.io/external-name" +// +kubebuilder:printcolumn:name="AGE",type="date",JSONPath=".metadata.creationTimestamp" +// +kubebuilder:resource:scope=Cluster,categories={crossplane,managed,account} +type SubaccountServiceBroker struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + // +kubebuilder:validation:XValidation:rule="!('*' in self.managementPolicies || 'Create' in self.managementPolicies || 'Update' in self.managementPolicies) || has(self.forProvider.name) || (has(self.initProvider) && has(self.initProvider.name))",message="spec.forProvider.name is a required parameter" + // +kubebuilder:validation:XValidation:rule="!('*' in self.managementPolicies || 'Create' in self.managementPolicies || 'Update' in self.managementPolicies) || has(self.forProvider.passwordSecretRef)",message="spec.forProvider.passwordSecretRef is a required parameter" + // +kubebuilder:validation:XValidation:rule="!('*' in self.managementPolicies || 'Create' in self.managementPolicies || 'Update' in self.managementPolicies) || has(self.forProvider.url) || (has(self.initProvider) && has(self.initProvider.url))",message="spec.forProvider.url is a required parameter" + // +kubebuilder:validation:XValidation:rule="!('*' in self.managementPolicies || 'Create' in self.managementPolicies || 'Update' in self.managementPolicies) || has(self.forProvider.username) || (has(self.initProvider) && has(self.initProvider.username))",message="spec.forProvider.username is a required parameter" + Spec SubaccountServiceBrokerSpec `json:"spec"` + Status SubaccountServiceBrokerStatus `json:"status,omitempty"` +} + +// +kubebuilder:object:root=true + +// SubaccountServiceBrokerList contains a list of SubaccountServiceBrokers +type SubaccountServiceBrokerList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + Items []SubaccountServiceBroker `json:"items"` +} + +// Repository type metadata. +var ( + SubaccountServiceBroker_Kind = "SubaccountServiceBroker" + SubaccountServiceBroker_GroupKind = schema.GroupKind{Group: CRDGroup, Kind: SubaccountServiceBroker_Kind}.String() + SubaccountServiceBroker_KindAPIVersion = SubaccountServiceBroker_Kind + "." + CRDGroupVersion.String() + SubaccountServiceBroker_GroupVersionKind = CRDGroupVersion.WithKind(SubaccountServiceBroker_Kind) +) + +func init() { + SchemeBuilder.Register(&SubaccountServiceBroker{}, &SubaccountServiceBrokerList{}) +} diff --git a/config/external_name.go b/config/external_name.go index f1506ac..7792118 100644 --- a/config/external_name.go +++ b/config/external_name.go @@ -14,6 +14,7 @@ var ExternalNameConfigs = map[string]config.ExternalName{ "btp_directory_entitlement": config.IdentifierFromProvider, "btp_subaccount_service_instance": config.IdentifierFromProvider, "btp_subaccount_service_binding": config.IdentifierFromProvider, + "btp_subaccount_service_broker": config.IdentifierFromProvider, } // ExternalNameConfigurations applies all external name configs listed in the diff --git a/config/provider.go b/config/provider.go index 02d4bb6..d0088d9 100644 --- a/config/provider.go +++ b/config/provider.go @@ -12,6 +12,7 @@ import ( directoryentitlement "github.com/sap/crossplane-provider-btp/config/directory_entitlement" global_trustconfig "github.com/sap/crossplane-provider-btp/config/globalaccount_trust_configuration" servicebinding "github.com/sap/crossplane-provider-btp/config/subaccount_service_binding" + servicebroker "github.com/sap/crossplane-provider-btp/config/subaccount_service_broker" serviceinstance "github.com/sap/crossplane-provider-btp/config/subaccount_service_instance" trustconfig "github.com/sap/crossplane-provider-btp/config/subaccount_trust_configuration" ) @@ -44,6 +45,7 @@ func GetProvider() *ujconfig.Provider { directoryentitlement.Configure, serviceinstance.Configure, servicebinding.Configure, + servicebroker.Configure, } { configure(pc) } diff --git a/config/subaccount_service_broker/config.go b/config/subaccount_service_broker/config.go new file mode 100644 index 0000000..efb2bc0 --- /dev/null +++ b/config/subaccount_service_broker/config.go @@ -0,0 +1,32 @@ +package subaccountservicebroker + +import ( + "context" + + "github.com/crossplane/upjet/pkg/config" +) + +// Configure configures individual resources by adding custom ResourceConfigurators. +func Configure(p *config.Provider) { + p.AddResourceConfigurator("btp_subaccount_service_broker", func(r *config.Resource) { + r.ShortGroup = "account" + r.Kind = "SubaccountServiceBroker" + + r.ExternalName.GetIDFn = func(_ context.Context, externalName string, _ map[string]any, _ map[string]any) (string, error) { + // When using "" as ID the API endpoint call will fail, so we need to use anything else that + // won't yield a result + if externalName == "" { + return "NOT_EMPTY_GUID", nil + } + return externalName, nil + } + + r.References["subaccount_id"] = config.Reference{ + Type: "github.com/sap/crossplane-provider-btp/apis/account/v1alpha1.Subaccount", + Extractor: "github.com/crossplane/crossplane-runtime/pkg/reference.ExternalName()", + RefFieldName: "SubaccountRef", + SelectorFieldName: "SubaccountSelector", + } + + }) +} diff --git a/examples-generated/account/v1alpha1/subaccountservicebroker.yaml b/examples-generated/account/v1alpha1/subaccountservicebroker.yaml new file mode 100644 index 0000000..8b9bbeb --- /dev/null +++ b/examples-generated/account/v1alpha1/subaccountservicebroker.yaml @@ -0,0 +1,21 @@ +apiVersion: account.btp.sap.crossplane.io/v1alpha1 +kind: SubaccountServiceBroker +metadata: + annotations: + meta.upbound.io/example-id: account/v1alpha1/subaccountservicebroker + labels: + testing.upbound.io/example-name: my_broker + name: my-broker +spec: + forProvider: + description: Service broker for provisioning example services. + name: my-broker + passwordSecretRef: + key: example-key + name: example-secret + namespace: upbound-system + subaccountSelector: + matchLabels: + testing.upbound.io/example-name: example + url: https://my.broker.com + username: platform_user diff --git a/internal/controller/account/subaccountservicebroker/zz_controller.go b/internal/controller/account/subaccountservicebroker/zz_controller.go new file mode 100755 index 0000000..b4bde20 --- /dev/null +++ b/internal/controller/account/subaccountservicebroker/zz_controller.go @@ -0,0 +1,86 @@ +/* +Copyright 2022 The Crossplane Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by upjet. DO NOT EDIT. + +package subaccountservicebroker + +import ( + "time" + + "github.com/crossplane/crossplane-runtime/pkg/connection" + "github.com/crossplane/crossplane-runtime/pkg/event" + "github.com/crossplane/crossplane-runtime/pkg/ratelimiter" + "github.com/crossplane/crossplane-runtime/pkg/reconciler/managed" + xpresource "github.com/crossplane/crossplane-runtime/pkg/resource" + tjcontroller "github.com/crossplane/upjet/pkg/controller" + "github.com/crossplane/upjet/pkg/controller/handler" + "github.com/crossplane/upjet/pkg/terraform" + "github.com/pkg/errors" + ctrl "sigs.k8s.io/controller-runtime" + + v1alpha1 "github.com/sap/crossplane-provider-btp/apis/account/v1alpha1" + features "github.com/sap/crossplane-provider-btp/internal/features" +) + +// Setup adds a controller that reconciles SubaccountServiceBroker managed resources. +func Setup(mgr ctrl.Manager, o tjcontroller.Options) error { + name := managed.ControllerName(v1alpha1.SubaccountServiceBroker_GroupVersionKind.String()) + var initializers managed.InitializerChain + cps := []managed.ConnectionPublisher{managed.NewAPISecretPublisher(mgr.GetClient(), mgr.GetScheme())} + if o.SecretStoreConfigGVK != nil { + cps = append(cps, connection.NewDetailsManager(mgr.GetClient(), *o.SecretStoreConfigGVK, connection.WithTLSConfig(o.ESSOptions.TLSConfig))) + } + eventHandler := handler.NewEventHandler(handler.WithLogger(o.Logger.WithValues("gvk", v1alpha1.SubaccountServiceBroker_GroupVersionKind))) + ac := tjcontroller.NewAPICallbacks(mgr, xpresource.ManagedKind(v1alpha1.SubaccountServiceBroker_GroupVersionKind), tjcontroller.WithEventHandler(eventHandler)) + opts := []managed.ReconcilerOption{ + managed.WithExternalConnecter(tjcontroller.NewConnector(mgr.GetClient(), o.WorkspaceStore, o.SetupFn, o.Provider.Resources["btp_subaccount_service_broker"], tjcontroller.WithLogger(o.Logger), tjcontroller.WithConnectorEventHandler(eventHandler), + tjcontroller.WithCallbackProvider(ac), + )), + managed.WithLogger(o.Logger.WithValues("controller", name)), + managed.WithRecorder(event.NewAPIRecorder(mgr.GetEventRecorderFor(name))), + managed.WithFinalizer(terraform.NewWorkspaceFinalizer(o.WorkspaceStore, xpresource.NewAPIFinalizer(mgr.GetClient(), managed.FinalizerName))), + managed.WithTimeout(3 * time.Minute), + managed.WithInitializers(initializers), + managed.WithConnectionPublishers(cps...), + managed.WithPollInterval(o.PollInterval), + } + if o.PollJitter != 0 { + opts = append(opts, managed.WithPollJitterHook(o.PollJitter)) + } + if o.Features.Enabled(features.EnableBetaManagementPolicies) { + opts = append(opts, managed.WithManagementPolicies()) + } + + // register webhooks for the kind v1alpha1.SubaccountServiceBroker + // if they're enabled. + if o.StartWebhooks { + if err := ctrl.NewWebhookManagedBy(mgr). + For(&v1alpha1.SubaccountServiceBroker{}). + Complete(); err != nil { + return errors.Wrap(err, "cannot register webhook for the kind v1alpha1.SubaccountServiceBroker") + } + } + + r := managed.NewReconciler(mgr, xpresource.ManagedKind(v1alpha1.SubaccountServiceBroker_GroupVersionKind), opts...) + + return ctrl.NewControllerManagedBy(mgr). + Named(name). + WithOptions(o.ForControllerRuntime()). + WithEventFilter(xpresource.DesiredStateChanged()). + Watches(&v1alpha1.SubaccountServiceBroker{}, eventHandler). + Complete(ratelimiter.NewReconciler(name, r, o.GlobalRateLimiter)) +} diff --git a/internal/controller/zz_setup.go b/internal/controller/zz_setup.go index 05ddd3c..5dcdb4d 100644 --- a/internal/controller/zz_setup.go +++ b/internal/controller/zz_setup.go @@ -22,6 +22,7 @@ import ( "github.com/crossplane/upjet/pkg/controller" directoryentitlement "github.com/sap/crossplane-provider-btp/internal/controller/account/directoryentitlement" + subaccountservicebroker "github.com/sap/crossplane-provider-btp/internal/controller/account/subaccountservicebroker" providerconfig "github.com/sap/crossplane-provider-btp/internal/controller/providerconfig" globalaccounttrustconfiguration "github.com/sap/crossplane-provider-btp/internal/controller/security/globalaccounttrustconfiguration" subaccounttrustconfiguration "github.com/sap/crossplane-provider-btp/internal/controller/security/subaccounttrustconfiguration" @@ -32,6 +33,7 @@ import ( func Setup(mgr ctrl.Manager, o controller.Options) error { for _, setup := range []func(ctrl.Manager, controller.Options) error{ directoryentitlement.Setup, + subaccountservicebroker.Setup, providerconfig.Setup, globalaccounttrustconfiguration.Setup, subaccounttrustconfiguration.Setup, diff --git a/package/crds/account.btp.sap.crossplane.io_subaccountservicebrokers.yaml b/package/crds/account.btp.sap.crossplane.io_subaccountservicebrokers.yaml new file mode 100644 index 0000000..ca96557 --- /dev/null +++ b/package/crds/account.btp.sap.crossplane.io_subaccountservicebrokers.yaml @@ -0,0 +1,593 @@ +--- +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + annotations: + controller-gen.kubebuilder.io/version: v0.14.0 + name: subaccountservicebrokers.account.btp.sap.crossplane.io +spec: + group: account.btp.sap.crossplane.io + names: + categories: + - crossplane + - managed + - account + kind: SubaccountServiceBroker + listKind: SubaccountServiceBrokerList + plural: subaccountservicebrokers + singular: subaccountservicebroker + scope: Cluster + versions: + - additionalPrinterColumns: + - jsonPath: .status.conditions[?(@.type=='Ready')].status + name: READY + type: string + - jsonPath: .status.conditions[?(@.type=='Synced')].status + name: SYNCED + type: string + - jsonPath: .metadata.annotations.crossplane\.io/external-name + name: EXTERNAL-NAME + type: string + - jsonPath: .metadata.creationTimestamp + name: AGE + type: date + name: v1alpha1 + schema: + openAPIV3Schema: + description: 'SubaccountServiceBroker is the Schema for the SubaccountServiceBrokers + API. Registers a service service broker in a subaccount. Tip: You must be + assigned to the admin role of the subaccount.' + properties: + apiVersion: + description: |- + APIVersion defines the versioned schema of this representation of an object. + Servers should convert recognized schemas to the latest internal value, and + may reject unrecognized values. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources + type: string + kind: + description: |- + Kind is a string value representing the REST resource this object represents. + Servers may infer this from the endpoint the client submits requests to. + Cannot be updated. + In CamelCase. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds + type: string + metadata: + type: object + spec: + description: SubaccountServiceBrokerSpec defines the desired state of + SubaccountServiceBroker + properties: + deletionPolicy: + default: Delete + description: |- + DeletionPolicy specifies what will happen to the underlying external + when this managed resource is deleted - either "Delete" or "Orphan" the + external resource. + This field is planned to be deprecated in favor of the ManagementPolicies + field in a future release. Currently, both could be set independently and + non-default values would be honored if the feature flag is enabled. + See the design doc for more information: https://github.com/crossplane/crossplane/blob/499895a25d1a1a0ba1604944ef98ac7a1a71f197/design/design-doc-observe-only-resources.md?plain=1#L223 + enum: + - Orphan + - Delete + type: string + forProvider: + properties: + description: + description: |- + (String) The description of the service broker. + The description of the service broker. + type: string + name: + description: |- + (String) The name of the service broker. + The name of the service broker. + type: string + passwordSecretRef: + description: |- + (String, Sensitive) The password for basic authentication against the service broker. + The password for basic authentication against the service broker. + properties: + key: + description: The key to select. + type: string + name: + description: Name of the secret. + type: string + namespace: + description: Namespace of the secret. + type: string + required: + - key + - name + - namespace + type: object + subaccountId: + description: |- + (String) The ID of the subaccount. + The ID of the subaccount. + type: string + subaccountRef: + description: Reference to a Subaccount in account to populate + subaccountId. + properties: + name: + description: Name of the referenced object. + type: string + policy: + description: Policies for referencing. + properties: + resolution: + default: Required + description: |- + Resolution specifies whether resolution of this reference is required. + The default is 'Required', which means the reconcile will fail if the + reference cannot be resolved. 'Optional' means this reference will be + a no-op if it cannot be resolved. + enum: + - Required + - Optional + type: string + resolve: + description: |- + Resolve specifies when this reference should be resolved. The default + is 'IfNotPresent', which will attempt to resolve the reference only when + the corresponding field is not present. Use 'Always' to resolve the + reference on every reconcile. + enum: + - Always + - IfNotPresent + type: string + type: object + required: + - name + type: object + subaccountSelector: + description: Selector for a Subaccount in account to populate + subaccountId. + properties: + matchControllerRef: + description: |- + MatchControllerRef ensures an object with the same controller reference + as the selecting object is selected. + type: boolean + matchLabels: + additionalProperties: + type: string + description: MatchLabels ensures an object with matching labels + is selected. + type: object + policy: + description: Policies for selection. + properties: + resolution: + default: Required + description: |- + Resolution specifies whether resolution of this reference is required. + The default is 'Required', which means the reconcile will fail if the + reference cannot be resolved. 'Optional' means this reference will be + a no-op if it cannot be resolved. + enum: + - Required + - Optional + type: string + resolve: + description: |- + Resolve specifies when this reference should be resolved. The default + is 'IfNotPresent', which will attempt to resolve the reference only when + the corresponding field is not present. Use 'Always' to resolve the + reference on every reconcile. + enum: + - Always + - IfNotPresent + type: string + type: object + type: object + url: + description: |- + (String) The URL of the service broker. + The URL of the service broker. + type: string + username: + description: |- + (String) The username for basic authentication against the service broker. + The username for basic authentication against the service broker. + type: string + type: object + initProvider: + description: |- + THIS IS A BETA FIELD. It will be honored + unless the Management Policies feature flag is disabled. + InitProvider holds the same fields as ForProvider, with the exception + of Identifier and other resource reference fields. The fields that are + in InitProvider are merged into ForProvider when the resource is created. + The same fields are also added to the terraform ignore_changes hook, to + avoid updating them after creation. This is useful for fields that are + required on creation, but we do not desire to update them after creation, + for example because of an external controller is managing them, like an + autoscaler. + properties: + description: + description: |- + (String) The description of the service broker. + The description of the service broker. + type: string + name: + description: |- + (String) The name of the service broker. + The name of the service broker. + type: string + subaccountId: + description: |- + (String) The ID of the subaccount. + The ID of the subaccount. + type: string + subaccountRef: + description: Reference to a Subaccount in account to populate + subaccountId. + properties: + name: + description: Name of the referenced object. + type: string + policy: + description: Policies for referencing. + properties: + resolution: + default: Required + description: |- + Resolution specifies whether resolution of this reference is required. + The default is 'Required', which means the reconcile will fail if the + reference cannot be resolved. 'Optional' means this reference will be + a no-op if it cannot be resolved. + enum: + - Required + - Optional + type: string + resolve: + description: |- + Resolve specifies when this reference should be resolved. The default + is 'IfNotPresent', which will attempt to resolve the reference only when + the corresponding field is not present. Use 'Always' to resolve the + reference on every reconcile. + enum: + - Always + - IfNotPresent + type: string + type: object + required: + - name + type: object + subaccountSelector: + description: Selector for a Subaccount in account to populate + subaccountId. + properties: + matchControllerRef: + description: |- + MatchControllerRef ensures an object with the same controller reference + as the selecting object is selected. + type: boolean + matchLabels: + additionalProperties: + type: string + description: MatchLabels ensures an object with matching labels + is selected. + type: object + policy: + description: Policies for selection. + properties: + resolution: + default: Required + description: |- + Resolution specifies whether resolution of this reference is required. + The default is 'Required', which means the reconcile will fail if the + reference cannot be resolved. 'Optional' means this reference will be + a no-op if it cannot be resolved. + enum: + - Required + - Optional + type: string + resolve: + description: |- + Resolve specifies when this reference should be resolved. The default + is 'IfNotPresent', which will attempt to resolve the reference only when + the corresponding field is not present. Use 'Always' to resolve the + reference on every reconcile. + enum: + - Always + - IfNotPresent + type: string + type: object + type: object + url: + description: |- + (String) The URL of the service broker. + The URL of the service broker. + type: string + username: + description: |- + (String) The username for basic authentication against the service broker. + The username for basic authentication against the service broker. + type: string + type: object + managementPolicies: + default: + - '*' + description: |- + THIS IS A BETA FIELD. It is on by default but can be opted out + through a Crossplane feature flag. + ManagementPolicies specify the array of actions Crossplane is allowed to + take on the managed and external resources. + This field is planned to replace the DeletionPolicy field in a future + release. Currently, both could be set independently and non-default + values would be honored if the feature flag is enabled. If both are + custom, the DeletionPolicy field will be ignored. + See the design doc for more information: https://github.com/crossplane/crossplane/blob/499895a25d1a1a0ba1604944ef98ac7a1a71f197/design/design-doc-observe-only-resources.md?plain=1#L223 + and this one: https://github.com/crossplane/crossplane/blob/444267e84783136daa93568b364a5f01228cacbe/design/one-pager-ignore-changes.md + items: + description: |- + A ManagementAction represents an action that the Crossplane controllers + can take on an external resource. + enum: + - Observe + - Create + - Update + - Delete + - LateInitialize + - '*' + type: string + type: array + providerConfigRef: + default: + name: default + description: |- + ProviderConfigReference specifies how the provider that will be used to + create, observe, update, and delete this managed resource should be + configured. + properties: + name: + description: Name of the referenced object. + type: string + policy: + description: Policies for referencing. + properties: + resolution: + default: Required + description: |- + Resolution specifies whether resolution of this reference is required. + The default is 'Required', which means the reconcile will fail if the + reference cannot be resolved. 'Optional' means this reference will be + a no-op if it cannot be resolved. + enum: + - Required + - Optional + type: string + resolve: + description: |- + Resolve specifies when this reference should be resolved. The default + is 'IfNotPresent', which will attempt to resolve the reference only when + the corresponding field is not present. Use 'Always' to resolve the + reference on every reconcile. + enum: + - Always + - IfNotPresent + type: string + type: object + required: + - name + type: object + publishConnectionDetailsTo: + description: |- + PublishConnectionDetailsTo specifies the connection secret config which + contains a name, metadata and a reference to secret store config to + which any connection details for this managed resource should be written. + Connection details frequently include the endpoint, username, + and password required to connect to the managed resource. + properties: + configRef: + default: + name: default + description: |- + SecretStoreConfigRef specifies which secret store config should be used + for this ConnectionSecret. + properties: + name: + description: Name of the referenced object. + type: string + policy: + description: Policies for referencing. + properties: + resolution: + default: Required + description: |- + Resolution specifies whether resolution of this reference is required. + The default is 'Required', which means the reconcile will fail if the + reference cannot be resolved. 'Optional' means this reference will be + a no-op if it cannot be resolved. + enum: + - Required + - Optional + type: string + resolve: + description: |- + Resolve specifies when this reference should be resolved. The default + is 'IfNotPresent', which will attempt to resolve the reference only when + the corresponding field is not present. Use 'Always' to resolve the + reference on every reconcile. + enum: + - Always + - IfNotPresent + type: string + type: object + required: + - name + type: object + metadata: + description: Metadata is the metadata for connection secret. + properties: + annotations: + additionalProperties: + type: string + description: |- + Annotations are the annotations to be added to connection secret. + - For Kubernetes secrets, this will be used as "metadata.annotations". + - It is up to Secret Store implementation for others store types. + type: object + labels: + additionalProperties: + type: string + description: |- + Labels are the labels/tags to be added to connection secret. + - For Kubernetes secrets, this will be used as "metadata.labels". + - It is up to Secret Store implementation for others store types. + type: object + type: + description: |- + Type is the SecretType for the connection secret. + - Only valid for Kubernetes Secret Stores. + type: string + type: object + name: + description: Name is the name of the connection secret. + type: string + required: + - name + type: object + writeConnectionSecretToRef: + description: |- + WriteConnectionSecretToReference specifies the namespace and name of a + Secret to which any connection details for this managed resource should + be written. Connection details frequently include the endpoint, username, + and password required to connect to the managed resource. + This field is planned to be replaced in a future release in favor of + PublishConnectionDetailsTo. Currently, both could be set independently + and connection details would be published to both without affecting + each other. + properties: + name: + description: Name of the secret. + type: string + namespace: + description: Namespace of the secret. + type: string + required: + - name + - namespace + type: object + required: + - forProvider + type: object + x-kubernetes-validations: + - message: spec.forProvider.name is a required parameter + rule: '!(''*'' in self.managementPolicies || ''Create'' in self.managementPolicies + || ''Update'' in self.managementPolicies) || has(self.forProvider.name) + || (has(self.initProvider) && has(self.initProvider.name))' + - message: spec.forProvider.passwordSecretRef is a required parameter + rule: '!(''*'' in self.managementPolicies || ''Create'' in self.managementPolicies + || ''Update'' in self.managementPolicies) || has(self.forProvider.passwordSecretRef)' + - message: spec.forProvider.url is a required parameter + rule: '!(''*'' in self.managementPolicies || ''Create'' in self.managementPolicies + || ''Update'' in self.managementPolicies) || has(self.forProvider.url) + || (has(self.initProvider) && has(self.initProvider.url))' + - message: spec.forProvider.username is a required parameter + rule: '!(''*'' in self.managementPolicies || ''Create'' in self.managementPolicies + || ''Update'' in self.managementPolicies) || has(self.forProvider.username) + || (has(self.initProvider) && has(self.initProvider.username))' + status: + description: SubaccountServiceBrokerStatus defines the observed state + of SubaccountServiceBroker. + properties: + atProvider: + properties: + createdDate: + description: |- + (String) The date and time when the resource was created in RFC3339 format. + The date and time when the resource was created in [RFC3339](https://www.ietf.org/rfc/rfc3339.txt) format. + type: string + description: + description: |- + (String) The description of the service broker. + The description of the service broker. + type: string + id: + description: (String) The ID of the service broker. + type: string + lastModified: + description: |- + (String) The date and time when the resource was last modified in RFC3339 format. + The date and time when the resource was last modified in [RFC3339](https://www.ietf.org/rfc/rfc3339.txt) format. + type: string + name: + description: |- + (String) The name of the service broker. + The name of the service broker. + type: string + ready: + description: |- + (Boolean) Shows whether the service broker is ready. + Shows whether the service broker is ready. + type: boolean + subaccountId: + description: |- + (String) The ID of the subaccount. + The ID of the subaccount. + type: string + url: + description: |- + (String) The URL of the service broker. + The URL of the service broker. + type: string + username: + description: |- + (String) The username for basic authentication against the service broker. + The username for basic authentication against the service broker. + type: string + type: object + conditions: + description: Conditions of the resource. + items: + description: A Condition that may apply to a resource. + properties: + lastTransitionTime: + description: |- + LastTransitionTime is the last time this condition transitioned from one + status to another. + format: date-time + type: string + message: + description: |- + A Message containing details about this condition's last transition from + one status to another, if any. + type: string + reason: + description: A Reason for this condition's last transition from + one status to another. + type: string + status: + description: Status of this condition; is it currently True, + False, or Unknown? + type: string + type: + description: |- + Type of this condition. At most one of each condition type may apply to + a resource at any point in time. + type: string + required: + - lastTransitionTime + - reason + - status + - type + type: object + type: array + x-kubernetes-list-map-keys: + - type + x-kubernetes-list-type: map + type: object + required: + - spec + type: object + served: true + storage: true + subresources: + status: {} diff --git a/test/e2e/subaccount_service_broker_v1alpha1_test.go b/test/e2e/subaccount_service_broker_v1alpha1_test.go new file mode 100755 index 0000000..a681032 --- /dev/null +++ b/test/e2e/subaccount_service_broker_v1alpha1_test.go @@ -0,0 +1,59 @@ +//go:build e2e + +/* +Copyright 2022 The Crossplane Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code initially generated by test-generator. + +package e2e + +import ( + "context" + "testing" + + "github.com/crossplane-contrib/xp-testing/pkg/resources" + meta_api "github.com/sap/crossplane-provider-btp/apis" + res "sigs.k8s.io/e2e-framework/klient/k8s/resources" + "sigs.k8s.io/e2e-framework/pkg/envconf" + "sigs.k8s.io/e2e-framework/pkg/features" +) + +func Test_SubaccountServiceBroker_v1alpha1(t *testing.T) { + t.Skip("Requires a working service broker to test, won't be fully implemented until promoting to v1beta1, skipping test until then") + t.Parallel() + + resource := resources.NewResourceTestConfig(nil, "SubaccountServiceBroker") + + fB := features.New(resource.Kind) + fB.WithLabel("kind", resource.Kind) + fB.Setup( + func(ctx context.Context, t *testing.T, cfg *envconf.Config) context.Context { + // as soon as we move to use the xp-testing framework, we can remove this manually setup and use the preconfigured one + r, _ := res.New(cfg.Client().RESTConfig()) + _ = meta_api.AddToScheme(r.GetScheme()) + + t.Logf("Apply %s", resource.Kind) + resources.ImportResources(ctx, t, cfg, resource.Kind) + + return ctx + }, + ) + fB.Assess("create", resource.AssessCreate) + fB.Assess("delete", resource.AssessDelete) + fB.Teardown(resource.Teardown) + + testenv.TestInParallel(t, fB.Feature()) +}