Skip to content

Commit 15cec5d

Browse files
authored
fix region parameter in PROD API (#44)
* fix region parameter in PROD API Signed-off-by: Felix Breuer <f.breuer94@gmail.com> * fix tests for optional configuration options Signed-off-by: Felix Breuer <f.breuer94@gmail.com> --------- Signed-off-by: Felix Breuer <f.breuer94@gmail.com>
1 parent c9b0a4c commit 15cec5d

File tree

8 files changed

+6
-40
lines changed

8 files changed

+6
-40
lines changed

pkg/apis/stackit/validation/cloudprofile.go

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,6 @@ func ValidateCloudProfileConfig(cloudProfile *stackitv1alpha1.CloudProfileConfig
2626
allErrs := field.ErrorList{}
2727

2828
floatingPoolPath := fldPath.Child("constraints", "floatingPools")
29-
if len(cloudProfile.Constraints.FloatingPools) == 0 {
30-
allErrs = append(allErrs, field.Required(floatingPoolPath, "must provide at least one floating pool"))
31-
}
32-
3329
combinationFound := sets.NewString()
3430
for i, pool := range cloudProfile.Constraints.FloatingPools {
3531
idxPath := floatingPoolPath.Index(i)
@@ -70,10 +66,6 @@ func ValidateCloudProfileConfig(cloudProfile *stackitv1alpha1.CloudProfileConfig
7066
allErrs = append(allErrs, ValidateProviderMachineImage(idxPath, machineImage)...)
7167
}
7268
allErrs = append(allErrs, validateMachineImageMapping(machineImages, cloudProfile, field.NewPath("spec").Child("machineImages"))...)
73-
74-
if len(cloudProfile.KeyStoneURL) == 0 && len(cloudProfile.KeyStoneURLs) == 0 {
75-
allErrs = append(allErrs, field.Required(fldPath.Child("keyStoneURL"), "must provide the URL to KeyStone"))
76-
}
7769
if ca := cloudProfile.KeyStoneCACert; ca != nil && len(*ca) > 0 {
7870
_, err := utils.DecodeCertificate([]byte(*ca))
7971
if err != nil {

pkg/apis/stackit/validation/cloudprofile_test.go

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -73,17 +73,6 @@ var _ = Describe("CloudProfileConfig validation", func() {
7373
})
7474

7575
Context("floating pools constraints", func() {
76-
It("should enforce that at least one pool has been defined", func() {
77-
cloudProfileConfig.Constraints.FloatingPools = []stackitv1alpha1.FloatingPool{}
78-
79-
errorList := ValidateCloudProfileConfig(cloudProfileConfig, machineImages, fldPath)
80-
81-
Expect(errorList).To(ConsistOf(PointTo(MatchFields(IgnoreExtras, Fields{
82-
"Type": Equal(field.ErrorTypeRequired),
83-
"Field": Equal("root.constraints.floatingPools"),
84-
}))))
85-
})
86-
8776
It("should forbid unsupported pools", func() {
8877
cloudProfileConfig.Constraints.FloatingPools = []stackitv1alpha1.FloatingPool{
8978
{
@@ -159,18 +148,6 @@ var _ = Describe("CloudProfileConfig validation", func() {
159148
})
160149

161150
Context("keystone url validation", func() {
162-
It("should forbid keystone urls with unsupported format", func() {
163-
cloudProfileConfig.KeyStoneURL = ""
164-
cloudProfileConfig.KeyStoneURLs = nil
165-
166-
errorList := ValidateCloudProfileConfig(cloudProfileConfig, machineImages, fldPath)
167-
168-
Expect(errorList).To(ConsistOf(PointTo(MatchFields(IgnoreExtras, Fields{
169-
"Type": Equal(field.ErrorTypeRequired),
170-
"Field": Equal("root.keyStoneURL"),
171-
}))))
172-
})
173-
174151
It("should forbid keystone urls with missing keys", func() {
175152
cloudProfileConfig.KeyStoneURL = ""
176153
cloudProfileConfig.KeyStoneURLs = []stackitv1alpha1.KeyStoneURL{{}}

pkg/stackit/client/dns.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import (
1515
)
1616

1717
func NewDNSClient(ctx context.Context, endpoints stackitv1alpha1.APIEndpoints, credentials *stackit.Credentials) (DNSClient, error) {
18-
options := clientOptions(nil, endpoints, credentials)
18+
options := clientOptions(endpoints, credentials)
1919

2020
if endpoints.DNS != nil {
2121
options = append(options, sdkconfig.WithEndpoint(*endpoints.DNS))

pkg/stackit/client/factory.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,14 +75,11 @@ func (f factory) DNS(ctx context.Context, c client.Client, secretRef corev1.Secr
7575
return NewDNSClient(ctx, f.StackitAPIEndpoints, credentials)
7676
}
7777

78-
func clientOptions(region *string, endpoints stackitv1alpha1.APIEndpoints, credentials *stackit.Credentials) []sdkconfig.ConfigurationOption {
78+
func clientOptions(endpoints stackitv1alpha1.APIEndpoints, credentials *stackit.Credentials) []sdkconfig.ConfigurationOption {
7979
result := []sdkconfig.ConfigurationOption{
8080
sdkconfig.WithUserAgent(UserAgent),
8181
sdkconfig.WithServiceAccountKey(credentials.SaKeyJSON),
8282
}
83-
if region != nil {
84-
result = append(result, sdkconfig.WithRegion(*region))
85-
}
8683

8784
if endpoints.TokenEndpoint != nil {
8885
result = append(result, sdkconfig.WithTokenEndpoint(*endpoints.TokenEndpoint))

pkg/stackit/client/iaas.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ func (c iaasClient) GetNetworkByName(ctx context.Context, name string) ([]iaas.N
128128
}
129129

130130
func NewIaaSClient(region string, endpoints stackitv1alpha1.APIEndpoints, credentials *stackit.Credentials) (IaaSClient, error) {
131-
options := clientOptions(&region, endpoints, credentials)
131+
options := clientOptions(endpoints, credentials)
132132

133133
if endpoints.IaaS != nil {
134134
options = append(options, sdkconfig.WithEndpoint(*endpoints.IaaS))

pkg/stackit/client/loadbalancing.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ type loadBalancingClient struct {
2323
}
2424

2525
func NewLoadBalancingClient(ctx context.Context, region string, endpoints stackitv1alpha1.APIEndpoints, credentials *stackit.Credentials) (LoadBalancingClient, error) {
26-
options := clientOptions(&region, endpoints, credentials)
26+
options := clientOptions(endpoints, credentials)
2727

2828
if endpoints.LoadBalancer != nil {
2929
options = append(options, sdkconfig.WithEndpoint(*endpoints.LoadBalancer))

pkg/webhook/seedprovider/add.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ type AddOptions struct {
2727
ETCDStorage config.ETCDStorage
2828
}
2929

30-
var logger = log.Log.WithName("openstack-seedprovider-webhook")
30+
var logger = log.Log.WithName("stackit-seedprovider-webhook")
3131

3232
// AddToManagerWithOptions creates a webhook with the given options and adds it to the manager.
3333
func AddToManagerWithOptions(mgr manager.Manager, opts AddOptions) (*extensionswebhook.Webhook, error) {

pkg/webhook/seedprovider/ensurer.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import (
2121
func NewEnsurer(etcdStorage *config.ETCDStorage, logger logr.Logger) genericmutator.Ensurer {
2222
return &ensurer{
2323
etcdStorage: etcdStorage,
24-
logger: logger.WithName("openstack-seedprovider-ensurer"),
24+
logger: logger.WithName("stackit-seedprovider-ensurer"),
2525
}
2626
}
2727

0 commit comments

Comments
 (0)