Skip to content

Commit 4e5db9d

Browse files
committed
E2E: role-create-full PASS
1 parent 366613b commit 4e5db9d

File tree

15 files changed

+65
-109
lines changed

15 files changed

+65
-109
lines changed

api/v1alpha1/role_types.go

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,16 @@ type RoleResourceSpec struct {
2323
// +optional
2424
Name *OpenStackName `json:"name,omitempty"`
2525

26+
// TODO(dlawton): Waiting on Gophercloud release to include description.
27+
// Will update this field when description field is available.
2628
// description is a human-readable description for the resource.
2729
// +kubebuilder:validation:MinLength:=1
2830
// +kubebuilder:validation:MaxLength:=255
2931
// +optional
30-
Description *string `json:"description,omitempty"`
32+
// Description *string `json:"description,omitempty"`
3133

3234
// TODO(scaffolding): Add more types.
33-
// To see what is supported, you can take inspiration from the CreateOpts stucture from
35+
// To see what is supported, you can take inspiration from the CreateOpts structure from
3436
// github.com/gophercloud/gophercloud/v2/openstack/identity/v3/roles
3537
//
3638
// Until you have implemented mutability for the field, you must add a CEL validation
@@ -45,14 +47,16 @@ type RoleFilter struct {
4547
// +optional
4648
Name *OpenStackName `json:"name,omitempty"`
4749

50+
// TODO(dlawton): Waiting on Gophercloud release to include description.
51+
// Will update this field when description field is available.
4852
// description of the existing resource
4953
// +kubebuilder:validation:MinLength:=1
5054
// +kubebuilder:validation:MaxLength:=255
5155
// +optional
52-
Description *string `json:"description,omitempty"`
56+
// Description *string `json:"description,omitempty"`
5357

5458
// TODO(scaffolding): Add more types.
55-
// To see what is supported, you can take inspiration from the ListOpts stucture from
59+
// To see what is supported, you can take inspiration from the ListOpts structure from
5660
// github.com/gophercloud/gophercloud/v2/openstack/identity/v3/roles
5761
}
5862

@@ -63,14 +67,17 @@ type RoleResourceStatus struct {
6367
// +optional
6468
Name string `json:"name,omitempty"`
6569

70+
// TODO(dlawton): Waiting on Gophercloud release to include description.
71+
// Will update this field when description field is available.
6672
// description is a human-readable description for the resource.
6773
// +kubebuilder:validation:MaxLength=1024
6874
// +optional
69-
Description string `json:"description,omitempty"`
75+
// Description string `json:"description,omitempty"`
7076

71-
//DomainID string `json:"domainID,omitempty"`
77+
// TODO(dlawton): Will update when Domain Controller is built
78+
// DomainID string `json:"domainID,omitempty"`
7279

7380
// TODO(scaffolding): Add more types.
74-
// To see what is supported, you can take inspiration from the Role stucture from
81+
// To see what is supported, you can take inspiration from the Role structure from
7582
// github.com/gophercloud/gophercloud/v2/openstack/identity/v3/roles
7683
}

api/v1alpha1/zz_generated.deepcopy.go

Lines changed: 0 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cmd/models-schema/zz_generated.openapi.go

Lines changed: 0 additions & 21 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/crd/bases/openstack.k-orc.cloud_roles.yaml

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,6 @@ spec:
9191
error state and will not continue to retry.
9292
minProperties: 1
9393
properties:
94-
description:
95-
description: description of the existing resource
96-
maxLength: 255
97-
minLength: 1
98-
type: string
9994
name:
10095
description: name of the existing resource
10196
maxLength: 255
@@ -149,12 +144,6 @@ spec:
149144
150145
resource must be specified if the management policy is `managed`.
151146
properties:
152-
description:
153-
description: description is a human-readable description for the
154-
resource.
155-
maxLength: 255
156-
minLength: 1
157-
type: string
158147
name:
159148
description: |-
160149
name will be the name of the created resource. If not specified, the
@@ -266,11 +255,6 @@ spec:
266255
description: resource contains the observed state of the OpenStack
267256
resource.
268257
properties:
269-
description:
270-
description: description is a human-readable description for the
271-
resource.
272-
maxLength: 1024
273-
type: string
274258
name:
275259
description: name is a Human-readable name for the resource. Might
276260
not be unique.

internal/controllers/role/actuator.go

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ package role
1919
import (
2020
"context"
2121
"iter"
22-
"time"
2322

2423
"github.com/gophercloud/gophercloud/v2/openstack/identity/v3/roles"
2524
corev1 "k8s.io/api/core/v1"
@@ -45,12 +44,6 @@ type (
4544
helperFactory = interfaces.ResourceHelperFactory[orcObjectPT, orcObjectT, resourceSpecT, filterT, osResourceT]
4645
)
4746

48-
// The frequency to poll when waiting for the resource to become available
49-
const roleAvailablePollingPeriod = 15 * time.Second
50-
51-
// The frequency to poll when waiting for the resource to be deleted
52-
const roleDeletingPollingPeriod = 15 * time.Second
53-
5447
type roleActuator struct {
5548
osClient osclients.RoleClient
5649
k8sClient client.Client
@@ -83,7 +76,7 @@ func (actuator roleActuator) ListOSResourcesForAdoption(ctx context.Context, orc
8376

8477
listOpts := roles.ListOpts{
8578
Name: getResourceName(orcObject),
86-
//Description: ptr.Deref(resourceSpec.Description, ""),
79+
// Description: ptr.Deref(resourceSpec.Description, ""),
8780
}
8881

8982
return actuator.osClient.ListRoles(ctx, listOpts), true
@@ -96,7 +89,7 @@ func (actuator roleActuator) ListOSResourcesForImport(ctx context.Context, obj o
9689

9790
listOpts := roles.ListOpts{
9891
Name: string(ptr.Deref(filter.Name, "")),
99-
//Description: string(ptr.Deref(filter.Description, "")),
92+
// Description: string(ptr.Deref(filter.Description, "")),
10093
// TODO(scaffolding): Add more import filters
10194
}
10295

@@ -113,7 +106,7 @@ func (actuator roleActuator) CreateResource(ctx context.Context, obj orcObjectPT
113106
}
114107
createOpts := roles.CreateOpts{
115108
Name: getResourceName(obj),
116-
//Description: ptr.Deref(resource.Description, ""),
109+
// Description: ptr.Deref(resource.Description, ""),
117110
// TODO(scaffolding): Add more fields
118111
}
119112

@@ -148,7 +141,7 @@ func (actuator roleActuator) updateResource(ctx context.Context, obj orcObjectPT
148141
updateOpts := roles.UpdateOpts{}
149142

150143
handleNameUpdate(&updateOpts, obj, osResource)
151-
//handleDescriptionUpdate(&updateOpts, resource, osResource)
144+
// handleDescriptionUpdate(&updateOpts, resource, osResource)
152145

153146
// TODO(scaffolding): add handler for all fields supporting mutability
154147

@@ -197,7 +190,7 @@ func handleNameUpdate(updateOpts *roles.UpdateOpts, obj orcObjectPT, osResource
197190
}
198191
}
199192

200-
//func handleDescriptionUpdate(updateOpts *roles.UpdateOpts, resource *resourceSpecT, osResource *osResourceT) {
193+
// func handleDescriptionUpdate(updateOpts *roles.UpdateOpts, resource *resourceSpecT, osResource *osResourceT) {
201194
// description := ptr.Deref(resource.Description, "")
202195
// if osResource.Description != description {
203196
// updateOpts.Description = &description

internal/controllers/role/actuator_test.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ func TestNeedsUpdate(t *testing.T) {
3737
},
3838
{
3939
name: "Updated opts",
40-
updateOpts: roles.UpdateOpts{Name: ptr.To("updated")},
40+
updateOpts: roles.UpdateOpts{Name: "updated"},
4141
expectChange: true,
4242
},
4343
}
@@ -87,6 +87,8 @@ func TestHandleNameUpdate(t *testing.T) {
8787
}
8888
}
8989

90+
// TODO(dlawton): Add test back in when description field is available in next gophercloud release.
91+
/*
9092
func TestHandleDescriptionUpdate(t *testing.T) {
9193
ptrToDescription := ptr.To[string]
9294
testCases := []struct {
@@ -117,3 +119,4 @@ func TestHandleDescriptionUpdate(t *testing.T) {
117119
118120
}
119121
}
122+
*/
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
apiVersion: openstack.k-orc.cloud/v1alpha1
3+
kind: Role
4+
metadata:
5+
name: role-create-full
6+
status:
7+
resource:
8+
name: role-create-full-override
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
apiVersion: openstack.k-orc.cloud/v1alpha1
3+
kind: Role
4+
metadata:
5+
name: role-create-full
6+
spec:
7+
cloudCredentialsRef:
8+
# TODO(scaffolding): Use openstack-admin if the resouce needs admin credentials to be created
9+
cloudName: openstack-admin
10+
secretName: openstack-clouds
11+
managementPolicy: managed
12+
resource:
13+
name: role-create-full-override
14+
# TODO(scaffolding): Add all fields the resource supports
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
apiVersion: kuttl.dev/v1beta1
3+
kind: TestStep
4+
commands:
5+
- command: kubectl create secret generic openstack-clouds --from-file=clouds.yaml=${E2E_KUTTL_OSCLOUDS} ${E2E_KUTTL_CACERT_OPT}
6+
namespaced: true
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Create a Role with all the options
2+
3+
## Step 00
4+
5+
Create a Role using all available fields, and verify that the observed state corresponds to the spec.
6+
7+
Also validate that the OpenStack resource uses the name from the spec when it is specified.
8+
9+
## Reference
10+
11+
https://k-orc.cloud/development/writing-tests/#create-full

0 commit comments

Comments
 (0)