kube-object-storage / lib-bucket-provisioner

Library for the dynamic provisioning of object store buckets to be used by object store providers.
Apache License 2.0
20 stars 22 forks source link

should honor empty `SubRegion` #214

Open rootfs opened 3 years ago

rootfs commented 3 years ago

SubRegion can be empty. It currently has the following definition

type Endpoint struct {
        BucketHost           string            `json:"bucketHost"`
        BucketPort           int               `json:"bucketPort"`
        BucketName           string            `json:"bucketName"`
        Region               string            `json:"region"`
        SubRegion            string            `json:"subRegion"`
        AdditionalConfigData map[string]string `json:"additionalConfig"`
} 

That causes trouble when provisioner doesn't set it with meaningful value as in here

It should cope with this situation by


type Endpoint struct {
        BucketHost           string            `json:"bucketHost"`
        BucketPort           int               `json:"bucketPort"`
        BucketName           string            `json:"bucketName"`
        Region               string            `json:"region"`
        SubRegion            string            `json:"subRegion,omitempty"`
        AdditionalConfigData map[string]string `json:"additionalConfig"`
}

@leseb @copejon

copejon commented 3 years ago

This is due to the OpenAPIV3 scheme. The subRegion is defined as type: string, meaning it will not accept null type by default. The fix should be to add nullable: true to the subRegion schema.

https://github.com/kube-object-storage/lib-bucket-provisioner/blob/4bea5edaff58c0e80e3ad0c56f2894a7d456cc87/deploy/crds/objectbucket_v1alpha1_objectbucket_crd.yaml#L96-L98