Skip to content

Commit 286dd13

Browse files
committed
feat: add status conditions & e2e tests
1 parent 741bfbf commit 286dd13

21 files changed

Lines changed: 582 additions & 162 deletions

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ all: controller
1414

1515
# Run tests
1616
test: generate fmt vet manifests misspell
17-
go test ./pkg/... -coverprofile cover.out
17+
go test -v ./pkg/... -coverprofile cover.out
1818

1919
e2e: generate manifests
2020
go mod download

api/v1/harborrobotaccount_types.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ type HarborRobotAccountSpec struct {
2828

2929
// +kubebuilder:object:root=true
3030
// +kubebuilder:resource:scope=Cluster
31+
// +kubebuilder:subresource:status
3132

3233
// HarborRobotAccount is the Schema for the harborrobotaccounts API
3334
type HarborRobotAccount struct {

api/v1/types.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,12 +102,20 @@ type WebhookUpdatePayload struct {
102102

103103
// HarborSyncStatus defines the observed state of HarborSync
104104
type HarborSyncStatus struct {
105-
ProjectList []string `json:"managedProjects,omitempty"`
105+
// +optional
106+
ProjectList []ProjectStatus `json:"projectStatus,omitempty"`
106107

107108
// +optional
108109
Conditions []HarborSyncStatusCondition `json:"conditions,omitempty"`
109110
}
110111

112+
type ProjectStatus struct {
113+
Name string `json:"projectName"`
114+
LastRobotReconciliation metav1.Time `json:"lastRobotReconciliation,omitempty"`
115+
// +optional
116+
ManagedNamespaces []string `json:"managedNamespaces,omitempty"`
117+
}
118+
111119
type HarborSyncConditionType string
112120

113121
const (
@@ -138,6 +146,7 @@ type RobotAccountCredential struct {
138146

139147
// +kubebuilder:object:root=true
140148
// +kubebuilder:resource:scope=Cluster
149+
// +kubebuilder:subresource:status
141150

142151
// HarborSync is the Schema for the harborsyncs API
143152
type HarborSync struct {

api/v1/zz_generated.deepcopy.go

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

cmd/controller_standalone.go

Lines changed: 0 additions & 87 deletions
This file was deleted.

config/crd/bases/crd.harborsync.io_harborrobotaccounts.yaml

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ spec:
1515
plural: harborrobotaccounts
1616
singular: harborrobotaccount
1717
scope: Cluster
18+
subresources:
19+
status: {}
1820
validation:
1921
openAPIV3Schema:
2022
description: HarborRobotAccount is the Schema for the harborrobotaccounts API
@@ -36,7 +38,8 @@ spec:
3638
properties:
3739
credential:
3840
description: RobotAccountCredential holds the robot account name & token
39-
to access the harbor API
41+
to access the harbor API this is also part of the webhook API change
42+
here might impact downstream users
4043
properties:
4144
created_at:
4245
format: int64
@@ -56,11 +59,31 @@ spec:
5659
status:
5760
description: HarborRobotAccountStatus defines the observed state of HarborRobotAccount
5861
properties:
59-
last_sync:
60-
format: int64
61-
type: integer
62-
required:
63-
- last_sync
62+
conditions:
63+
items:
64+
properties:
65+
lastTransitionTime:
66+
format: date-time
67+
type: string
68+
message:
69+
type: string
70+
reason:
71+
type: string
72+
status:
73+
type: string
74+
type:
75+
type: string
76+
required:
77+
- status
78+
- type
79+
type: object
80+
type: array
81+
refreshTime:
82+
description: refreshTime is the time and date the robot account was
83+
fetched and the target secret updated
84+
format: date-time
85+
nullable: true
86+
type: string
6487
type: object
6588
type: object
6689
version: v1

config/crd/bases/crd.harborsync.io_harborsyncs.yaml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ spec:
1515
plural: harborsyncs
1616
singular: harborsync
1717
scope: Cluster
18+
subresources:
19+
status: {}
1820
validation:
1921
openAPIV3Schema:
2022
description: HarborSync is the Schema for the harborsyncs API
@@ -105,6 +107,42 @@ spec:
105107
type: object
106108
status:
107109
description: HarborSyncStatus defines the observed state of HarborSync
110+
properties:
111+
conditions:
112+
items:
113+
properties:
114+
lastTransitionTime:
115+
format: date-time
116+
type: string
117+
message:
118+
type: string
119+
reason:
120+
type: string
121+
status:
122+
type: string
123+
type:
124+
type: string
125+
required:
126+
- status
127+
- type
128+
type: object
129+
type: array
130+
projectStatus:
131+
items:
132+
properties:
133+
lastRobotReconciliation:
134+
format: date-time
135+
type: string
136+
managedNamespaces:
137+
items:
138+
type: string
139+
type: array
140+
projectName:
141+
type: string
142+
required:
143+
- projectName
144+
type: object
145+
type: array
108146
type: object
109147
type: object
110148
version: v1

0 commit comments

Comments
 (0)