Skip to content

Commit

Permalink
Add "endpoint" and "endpointURL" fields to bucket status
Browse files Browse the repository at this point in the history
  • Loading branch information
David Gubler committed Oct 24, 2022
1 parent daa008b commit cc3a006
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
8 changes: 4 additions & 4 deletions apis/cloudscale/v1/bucket_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,8 @@ type BucketParameters struct {

// +kubebuilder:validation:Required

// EndpointURL is the URL where to create the bucket.
// If the scheme is omitted (`http/s`), HTTPS is assumed.
// Changing the endpoint after initial creation might have no effect.
EndpointURL string `json:"endpointURL"`
// Deprecated: Only here for compatibility with legacy Bucket objects
EndpointURL string `json:"endpointURL,omitempty"`

// BucketName is the name of the bucket to create.
// Defaults to `metadata.name` if unset.
Expand Down Expand Up @@ -80,6 +78,8 @@ type BucketObservation struct {
// BucketStatus represents the observed state of a Bucket.
type BucketStatus struct {
xpv1.ResourceStatus `json:",inline"`
Endpoint string `json:"endpoint,omitempty"`
EndpointURL string `json:"endpointURL,omitempty"`
AtProvider BucketObservation `json:"atProvider,omitempty"`
}

Expand Down
4 changes: 3 additions & 1 deletion operator/bucketcontroller/connector.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ func (c *bucketConnector) Connect(ctx context.Context, mg resource.Managed) (man
return &NoopClient{}, nil
}

bucket.Status.Endpoint = fmt.Sprintf("objects.%s.cloudscale.ch", bucket.Spec.ForProvider.Region)
bucket.Status.EndpointURL = fmt.Sprintf("https://%s", bucket.Status.Endpoint)
pctx := &connectContext{Context: ctx, bucket: bucket}
pipe := pipeline.NewPipeline[*connectContext]()
pipe.WithBeforeHooks(pipelineutil.DebugLogger(pctx)).
Expand Down Expand Up @@ -103,7 +105,7 @@ func (c *bucketConnector) createS3Client(ctx *connectContext) error {
secret := ctx.credentialsSecret
bucket := ctx.bucket

parsed, err := url.Parse(bucket.Spec.ForProvider.EndpointURL)
parsed, err := url.Parse(bucket.Status.EndpointURL)
if err != nil {
return err
}
Expand Down
10 changes: 6 additions & 4 deletions package/crds/cloudscale.crossplane.io_buckets.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,8 @@ spec:
type: object
x-kubernetes-map-type: atomic
endpointURL:
description: EndpointURL is the URL where to create the bucket.
If the scheme is omitted (`http/s`), HTTPS is assumed. Changing
the endpoint after initial creation might have no effect.
description: 'Deprecated: Only here for compatibility with legacy
Bucket objects'
type: string
region:
description: Region is the name of the region where the bucket
Expand All @@ -117,7 +116,6 @@ spec:
type: string
required:
- credentialsSecretRef
- endpointURL
- region
type: object
providerConfigRef:
Expand Down Expand Up @@ -334,6 +332,10 @@ spec:
- type
type: object
type: array
endpoint:
type: string
endpointURL:
type: string
type: object
required:
- spec
Expand Down

0 comments on commit cc3a006

Please sign in to comment.