Skip to content

Commit ee80170

Browse files
author
Mykhailo Pechkurov
committed
fix[114]: fixing ServiceInstance creation without credentials
1 parent 411af5c commit ee80170

5 files changed

Lines changed: 40 additions & 13 deletions

File tree

examples/resources/orgspace.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
apiVersion: cloudfoundry.crossplane.io/v1alpha1
3-
kind: Org
3+
kind: Organization
44
metadata:
55
namespace: default
66
name: my-org
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
# UPS without service credentials
3+
apiVersion: cloudfoundry.crossplane.io/v1alpha1
4+
kind: ServiceInstance
5+
metadata:
6+
name: my-ups
7+
spec:
8+
forProvider:
9+
type: user-provided
10+
name: my-ups
11+
routeServiceUrl: https://my-route-service.example.com
12+
syslogDrainUrl: syslog-tls://example.log-aggregator.com:6514
13+
spaceRef:
14+
name: my-space
15+
policy:
16+
resolve: Always

internal/clients/serviceinstance/serviceinstance.go

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ func (c *Client) Create(ctx context.Context, spec v1alpha1.ServiceInstanceParame
152152
return c.createManaged(ctx, spec, creds)
153153

154154
case v1alpha1.UserProvidedService:
155-
return c.createUserProvided(ctx, spec, creds)
155+
return c.createUserProvided(ctx, spec)
156156
default:
157157
return nil, errors.New("unknown service instance type")
158158
}
@@ -185,12 +185,7 @@ func (c *Client) createManaged(ctx context.Context, spec v1alpha1.ServiceInstanc
185185
}
186186

187187
// createUserProvided creates a user-provided service instance according to CR's ForProvider spec
188-
func (c *Client) createUserProvided(ctx context.Context, spec v1alpha1.ServiceInstanceParameters, creds json.RawMessage) (*resource.ServiceInstance, error) {
189-
// Credential is required for UPS
190-
if creds == nil {
191-
return nil, errors.New("Missing or invalid credentials")
192-
}
193-
188+
func (c *Client) createUserProvided(ctx context.Context, spec v1alpha1.ServiceInstanceParameters) (*resource.ServiceInstance, error) {
194189
// throw error if no space is provided
195190
if spec.Space == nil {
196191
return nil, errors.New("no space reference provided")
@@ -204,7 +199,6 @@ func (c *Client) createUserProvided(ctx context.Context, spec v1alpha1.ServiceIn
204199

205200
// workaround: cf-goclient supports few ups options at creation time.
206201
upt := resource.NewServiceInstanceUserProvidedUpdate().
207-
WithCredentials(creds).
208202
WithRouteServiceURL(spec.RouteServiceURL).
209203
WithSyslogDrainURL(spec.SyslogDrainURL)
210204

test/e2e/cloudfoundry_services_test.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,11 @@ func TestCloudFoundryServices(t *testing.T) {
2828
// updated checks if resource is updated, normally by observing a new value on managed field.
2929
updated func(k8s.Object) (bool, error)
3030
}{
31-
"space": {name: "service-space", obj: &v1alpha1.Space{}},
32-
"service_instance": {name: "e2e-service-instance", obj: &v1alpha1.ServiceInstance{}},
33-
"ups": {name: "e2e-ups", obj: &v1alpha1.ServiceInstance{}},
34-
"scb_key": {name: "e2e-scb-key", obj: &v1alpha1.ServiceCredentialBinding{}},
31+
"space": {name: "service-space", obj: &v1alpha1.Space{}},
32+
"service_instance": {name: "e2e-service-instance", obj: &v1alpha1.ServiceInstance{}},
33+
"ups": {name: "e2e-ups", obj: &v1alpha1.ServiceInstance{}},
34+
"ups_no_credentials": {name: "e2e-ups-no-credentials", obj: &v1alpha1.ServiceInstance{}},
35+
"scb_key": {name: "e2e-scb-key", obj: &v1alpha1.ServiceCredentialBinding{}},
3536
}
3637

3738
var feat = features.New("CO-159 cloudfoundry e2e test services").Setup(
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
apiVersion: cloudfoundry.crossplane.io/v1alpha1
3+
kind: ServiceInstance
4+
metadata:
5+
namespace: service-test
6+
name: e2e-ups-no-credentials
7+
spec:
8+
forProvider:
9+
type: user-provided
10+
name: 2e-ups-no-credentials
11+
routeServiceUrl: https://e2e-route-service.example.com
12+
syslogDrainUrl: syslog-tls://example.log-aggregator.com:6514
13+
spaceRef:
14+
name: service-space
15+
policy:
16+
resolve: Always

0 commit comments

Comments
 (0)