-
Notifications
You must be signed in to change notification settings - Fork 0
/
objectbucket.go
36 lines (28 loc) · 1.06 KB
/
objectbucket.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package vshnpostgres
import (
"context"
"fmt"
xfnproto "github.com/crossplane/function-sdk-go/proto/v1beta1"
appcatv1 "github.com/vshn/appcat/v4/apis/v1"
vshnv1 "github.com/vshn/appcat/v4/apis/vshn/v1"
"github.com/vshn/appcat/v4/pkg/comp-functions/runtime"
)
// EnsureObjectBucketLabels just gets the bucket present from the PnT part and adds it again to the
// desired state. This ensures that the correct labels are injected.
func EnsureObjectBucketLabels(ctx context.Context, svc *runtime.ServiceRuntime) *xfnproto.Result {
comp := &vshnv1.VSHNPostgreSQL{}
err := svc.GetObservedComposite(comp)
if err != nil {
return runtime.NewFatalResult(fmt.Errorf("Cannot get composite from function io: %w", err))
}
bucket := &appcatv1.XObjectBucket{}
err = svc.GetDesiredComposedResourceByName(bucket, "pg-bucket")
if err != nil {
return runtime.NewWarningResult("cannot get xobjectbucket")
}
err = svc.SetDesiredComposedResourceWithName(bucket, "pg-bucket")
if err != nil {
return runtime.NewWarningResult("cannot add xobjectbucket to desired map")
}
return nil
}