Skip to content

Commit 5b57fc1

Browse files
committed
feat: support scopes & no more delete on update
Signed-off-by: BoxBoxJason <contact@boxboxjason.dev>
1 parent 7829337 commit 5b57fc1

20 files changed

Lines changed: 329 additions & 81 deletions

File tree

apis/cluster/instance/v1alpha1/zz_application_types.go

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

apis/cluster/instance/v1alpha1/zz_generated.deepcopy.go

Lines changed: 6 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apis/namespaced/instance/v1alpha1/application_types.go

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,44 +29,50 @@ import (
2929
type ApplicationParameters struct {
3030
// Name is the name of the application.
3131
// +required
32+
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="Name is immutable (delete and recreate the resource if you want to change it)."
3233
Name string `json:"name"`
3334

3435
// RedirectURI is the redirect URI of the application.
3536
// +required
37+
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="RedirectURI is immutable (delete and recreate the resource if you want to change it)."
3638
RedirectURI string `json:"redirectURI"`
3739

3840
// Scopes is the scopes of the application (space-separated).
39-
// WARNING: This field is not updated after creation. To change scopes, you must delete and recreate the application.
4041
// +required
41-
// +immutable
42+
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="Scopes is immutable (delete and recreate the resource if you want to change it)."
4243
Scopes []string `json:"scopes"`
4344

4445
// Confidential indicates whether the application is confidential.
4546
// +optional
47+
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="Confidential is immutable (delete and recreate the resource if you want to change it)."
4648
Confidential *bool `json:"confidential,omitempty"`
4749
}
4850

4951
// ApplicationObservation represents the observed state of a GitLab instance OAuth Application.
5052
type ApplicationObservation struct {
5153
// ID is the numeric ID of the application.
5254
// +optional
53-
ID int64 `json:"id,omitempty"`
55+
ID int64 `json:"id"`
5456

5557
// Name is the name of the application as stored in GitLab.
5658
// +optional
57-
Name string `json:"name,omitempty"`
59+
Name string `json:"name"`
5860

5961
// ApplicationID is the OAuth client ID.
6062
// +optional
61-
ApplicationID string `json:"applicationID,omitempty"`
63+
ApplicationID string `json:"applicationID"`
6264

6365
// CallbackURL is the callback URL of the application as stored in GitLab.
6466
// +optional
65-
CallbackURL string `json:"callbackURL,omitempty"`
67+
CallbackURL string `json:"callbackURL"`
6668

6769
// Confidential indicates whether the application is confidential.
6870
// +optional
69-
Confidential bool `json:"confidential,omitempty"`
71+
Confidential bool `json:"confidential"`
72+
73+
// Scopes is the scopes of the application as stored in GitLab
74+
// +optional
75+
Scopes []string `json:"scopes"`
7076
}
7177

7278
// ApplicationSpec defines the desired state of a GitLab instance OAuth Application.

apis/namespaced/instance/v1alpha1/zz_generated.deepcopy.go

Lines changed: 6 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ require (
88
github.com/google/go-cmp v0.7.0
99
github.com/hashicorp/go-cleanhttp v0.5.2
1010
github.com/pkg/errors v0.9.1
11-
gitlab.com/gitlab-org/api/client-go/v2 v2.34.0
11+
gitlab.com/gitlab-org/api/client-go/v2 v2.39.0
1212
go.uber.org/zap v1.27.1
1313
golang.org/x/oauth2 v0.36.0
1414
k8s.io/api v0.35.1

go.sum

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,8 @@ github.com/google/pprof v0.0.0-20251213031049-b05bdaca462f h1:HU1RgM6NALf/KW9HEY
105105
github.com/google/pprof v0.0.0-20251213031049-b05bdaca462f/go.mod h1:67FPmZWbr+KDT/VlpWtw6sO9XSjpJmLuHpoLmWiTGgY=
106106
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
107107
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
108-
github.com/graph-gophers/graphql-go v1.9.0 h1:yu0ucKHLc5qGpRwLYKIWtr9bOoxovkWasuBrPQwlHls=
109-
github.com/graph-gophers/graphql-go v1.9.0/go.mod h1:23olKZ7duEvHlF/2ELEoSZaY1aNPfShjP782SOoNTyM=
108+
github.com/graph-gophers/graphql-go v1.10.2 h1:HXu6Wu5klCH4ALn1fQHVI20cjEIa4wftavHIgbLA4Fo=
109+
github.com/graph-gophers/graphql-go v1.10.2/go.mod h1:AsADheC4CCFwd8n1/QbkduTlHgYYMsRgtPihYVAlEsk=
110110
github.com/grpc-ecosystem/grpc-gateway/v2 v2.27.7 h1:X+2YciYSxvMQK0UZ7sg45ZVabVZBeBuvMkmuI2V3Fak=
111111
github.com/grpc-ecosystem/grpc-gateway/v2 v2.27.7/go.mod h1:lW34nIZuQ8UDPdkon5fmfp2l3+ZkQ2me/+oecHYLOII=
112112
github.com/hashicorp/go-cleanhttp v0.5.2 h1:035FKYIWjmULyFRBKPs8TBQoi0x6d9G4xc9neXJWAZQ=
@@ -187,8 +187,8 @@ github.com/x448/float16 v0.8.4 h1:qLwI1I70+NjRFUR3zs1JPUCgaCXSh3SW62uAKT1mSBM=
187187
github.com/x448/float16 v0.8.4/go.mod h1:14CWIYCyZA/cWjXOioeEpHeN/83MdbZDRQHoFcYsOfg=
188188
github.com/xhit/go-str2duration/v2 v2.1.0 h1:lxklc02Drh6ynqX+DdPyp5pCKLUQpRT8bp8Ydu2Bstc=
189189
github.com/xhit/go-str2duration/v2 v2.1.0/go.mod h1:ohY8p+0f07DiV6Em5LKB0s2YpLtXVyJfNt1+BlmyAsU=
190-
gitlab.com/gitlab-org/api/client-go/v2 v2.34.0 h1:3Gv+41azLlj97fUkhkaTCnIOm45mHDwLlAcTDEwHE2s=
191-
gitlab.com/gitlab-org/api/client-go/v2 v2.34.0/go.mod h1:T+hA9p13Fxyh4FkVbcEy36HlAGs37QBCifhh7Zt4+dg=
190+
gitlab.com/gitlab-org/api/client-go/v2 v2.39.0 h1:avIIRj2sia1bGYCXy6nIeuBFWNzwQppZf+eGjVMNh7E=
191+
gitlab.com/gitlab-org/api/client-go/v2 v2.39.0/go.mod h1:SKUbKSS59KPt6WeGNJoYF8HDaf/rFMUSITlftj/HkLg=
192192
go.opentelemetry.io/auto/sdk v1.2.1 h1:jXsnJ4Lmnqd11kwkBV2LgLoFMZKizbCi5fNZ/ipaZ64=
193193
go.opentelemetry.io/auto/sdk v1.2.1/go.mod h1:KRTj+aOaElaLi+wW1kO/DZRXwkF4C5xPbEe3ZiIhN7Y=
194194
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.64.0 h1:ssfIgGNANqpVFCndZvcuyKbl0g+UAVcbBcqGkG28H0Y=

package/crds/instance.gitlab.crossplane.io_applications.yaml

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,19 +89,33 @@ spec:
8989
description: Confidential indicates whether the application is
9090
confidential.
9191
type: boolean
92+
x-kubernetes-validations:
93+
- message: Confidential is immutable (delete and recreate the
94+
resource if you want to change it).
95+
rule: self == oldSelf
9296
name:
9397
description: Name is the name of the application.
9498
type: string
99+
x-kubernetes-validations:
100+
- message: Name is immutable (delete and recreate the resource
101+
if you want to change it).
102+
rule: self == oldSelf
95103
redirectURI:
96104
description: RedirectURI is the redirect URI of the application.
97105
type: string
106+
x-kubernetes-validations:
107+
- message: RedirectURI is immutable (delete and recreate the resource
108+
if you want to change it).
109+
rule: self == oldSelf
98110
scopes:
99-
description: |-
100-
Scopes is the scopes of the application (space-separated).
101-
WARNING: This field is not updated after creation. To change scopes, you must delete and recreate the application.
111+
description: Scopes is the scopes of the application (space-separated).
102112
items:
103113
type: string
104114
type: array
115+
x-kubernetes-validations:
116+
- message: Scopes is immutable (delete and recreate the resource
117+
if you want to change it).
118+
rule: self == oldSelf
105119
required:
106120
- name
107121
- redirectURI
@@ -220,6 +234,12 @@ spec:
220234
description: Name is the name of the application as stored in
221235
GitLab.
222236
type: string
237+
scopes:
238+
description: Scopes is the scopes of the application as stored
239+
in GitLab
240+
items:
241+
type: string
242+
type: array
223243
type: object
224244
conditions:
225245
description: Conditions of the resource.

package/crds/instance.gitlab.m.crossplane.io_applications.yaml

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,19 +75,33 @@ spec:
7575
description: Confidential indicates whether the application is
7676
confidential.
7777
type: boolean
78+
x-kubernetes-validations:
79+
- message: Confidential is immutable (delete and recreate the
80+
resource if you want to change it).
81+
rule: self == oldSelf
7882
name:
7983
description: Name is the name of the application.
8084
type: string
85+
x-kubernetes-validations:
86+
- message: Name is immutable (delete and recreate the resource
87+
if you want to change it).
88+
rule: self == oldSelf
8189
redirectURI:
8290
description: RedirectURI is the redirect URI of the application.
8391
type: string
92+
x-kubernetes-validations:
93+
- message: RedirectURI is immutable (delete and recreate the resource
94+
if you want to change it).
95+
rule: self == oldSelf
8496
scopes:
85-
description: |-
86-
Scopes is the scopes of the application (space-separated).
87-
WARNING: This field is not updated after creation. To change scopes, you must delete and recreate the application.
97+
description: Scopes is the scopes of the application (space-separated).
8898
items:
8999
type: string
90100
type: array
101+
x-kubernetes-validations:
102+
- message: Scopes is immutable (delete and recreate the resource
103+
if you want to change it).
104+
rule: self == oldSelf
91105
required:
92106
- name
93107
- redirectURI
@@ -178,6 +192,12 @@ spec:
178192
description: Name is the name of the application as stored in
179193
GitLab.
180194
type: string
195+
scopes:
196+
description: Scopes is the scopes of the application as stored
197+
in GitLab
198+
items:
199+
type: string
200+
type: array
181201
type: object
182202
conditions:
183203
description: Conditions of the resource.

pkg/cluster/clients/instance/zz_application.go

Lines changed: 3 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/cluster/clients/instance/zz_application_test.go

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

0 commit comments

Comments
 (0)