Skip to content

Commit 7f727df

Browse files
committed
Rename clusterscopeisolation to isolation
Signed-off-by: Mangirdas Judeikis <mangirdas@judeikis.lt> On-behalf-of: @SAP mangirdas.judeikis@sap.com
1 parent e36591a commit 7f727df

15 files changed

Lines changed: 121 additions & 58 deletions

File tree

backend/controllers/serviceexportrequest/serviceexportrequest_controller.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ type APIServiceExportRequestReconciler struct {
4949
manager mcmanager.Manager
5050
opts controller.TypedOptions[mcreconcile.Request]
5151

52-
informerScope kubebindv1alpha2.InformerScope
53-
clusterScopedIsolation kubebindv1alpha2.Isolation
54-
reconciler reconciler
52+
informerScope kubebindv1alpha2.InformerScope
53+
isolation kubebindv1alpha2.Isolation
54+
reconciler reconciler
5555
}
5656

5757
// NewAPIServiceExportRequestReconciler returns a new APIServiceExportRequestReconciler to reconcile APIServiceExportRequests.
@@ -75,14 +75,14 @@ func NewAPIServiceExportRequestReconciler(
7575
}
7676

7777
r := &APIServiceExportRequestReconciler{
78-
manager: mgr,
79-
opts: opts,
80-
informerScope: scope,
81-
clusterScopedIsolation: isolation,
78+
manager: mgr,
79+
opts: opts,
80+
informerScope: scope,
81+
isolation: isolation,
8282
reconciler: reconciler{
83-
informerScope: scope,
84-
clusterScopedIsolation: isolation,
85-
schemaSource: schemaSource,
83+
informerScope: scope,
84+
isolation: isolation,
85+
schemaSource: schemaSource,
8686
getBoundSchema: func(ctx context.Context, cl client.Client, namespace, name string) (*kubebindv1alpha2.BoundSchema, error) {
8787
var schema kubebindv1alpha2.BoundSchema
8888
key := types.NamespacedName{Namespace: namespace, Name: name}

backend/controllers/serviceexportrequest/serviceexportrequest_reconcile.go

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ import (
4040
)
4141

4242
type reconciler struct {
43-
informerScope kubebindv1alpha2.InformerScope
44-
clusterScopedIsolation kubebindv1alpha2.Isolation
45-
schemaSource string
43+
informerScope kubebindv1alpha2.InformerScope
44+
isolation kubebindv1alpha2.Isolation
45+
schemaSource string
4646

4747
getBoundSchema func(ctx context.Context, cl client.Client, namespace, name string) (*kubebindv1alpha2.BoundSchema, error)
4848
createBoundSchema func(ctx context.Context, cl client.Client, schema *kubebindv1alpha2.BoundSchema) error
@@ -134,7 +134,7 @@ func (r *reconciler) getExportedSchemas(ctx context.Context, cl client.Client) (
134134
return boundSchemas, nil
135135
}
136136

137-
func (r *reconciler) ensureBoundSchemas(ctx context.Context, cl client.Client, cache cache.Cache, req *kubebindv1alpha2.APIServiceExportRequest) error {
137+
func (r *reconciler) ensureBoundSchemas(ctx context.Context, cl client.Client, _ cache.Cache, req *kubebindv1alpha2.APIServiceExportRequest) error {
138138
exportedSchemas, err := r.getExportedSchemas(ctx, cl)
139139
if err != nil {
140140
return err
@@ -167,7 +167,7 @@ func (r *reconciler) ensureBoundSchemas(ctx context.Context, cl client.Client, c
167167
// we need to rewrite the BoundSchema's scope accordingly. For all
168168
// other isolation strategies, as well as for namespaced schemas,
169169
// no changes are necessary.
170-
if boundSchema.Spec.Scope == apiextensionsv1.NamespaceScoped && r.clusterScopedIsolation == kubebindv1alpha2.IsolationNamespaced {
170+
if boundSchema.Spec.Scope == apiextensionsv1.NamespaceScoped && r.isolation == kubebindv1alpha2.IsolationNamespaced {
171171
boundSchema.Spec.Scope = apiextensionsv1.ClusterScoped
172172
}
173173

@@ -185,7 +185,6 @@ func (r *reconciler) ensureExports(ctx context.Context, cl client.Client, cache
185185
logger := klog.FromContext(ctx)
186186

187187
var schemas []*kubebindv1alpha2.BoundSchema
188-
var scope apiextensionsv1.ResourceScope
189188
if req.Status.Phase == kubebindv1alpha2.APIServiceExportRequestPhasePending {
190189
for _, res := range req.Spec.Resources {
191190
name := res.ResourceGroupName()
@@ -207,7 +206,6 @@ func (r *reconciler) ensureExports(ctx context.Context, cl client.Client, cache
207206

208207
// Collect all schemas for hashing.
209208
// TODO(mjudeikis) Scope is same for all crds so we keep stamping it over. We might want to change this
210-
scope = boundSchema.Spec.Scope
211209
schemas = append(schemas, boundSchema)
212210
}
213211

@@ -236,11 +234,9 @@ func (r *reconciler) ensureExports(ctx context.Context, cl client.Client, cache
236234
},
237235
Spec: kubebindv1alpha2.APIServiceExportSpec{
238236
InformerScope: r.informerScope,
237+
Isolation: r.isolation,
239238
},
240239
}
241-
if scope == apiextensionsv1.ClusterScoped {
242-
export.Spec.ClusterScopedIsolation = r.clusterScopedIsolation
243-
}
244240

245241
for _, res := range req.Spec.Resources {
246242
export.Spec.Resources = append(export.Spec.Resources, kubebindv1alpha2.APIServiceExportResource{

backend/controllers/servicenamespace/servicenamespace_controller.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@ type APIServiceNamespaceReconciler struct {
5050
manager mcmanager.Manager
5151
opts controller.TypedOptions[mcreconcile.Request]
5252

53-
informerScope kubebindv1alpha2.InformerScope
54-
clusterScopedIsolation kubebindv1alpha2.Isolation
55-
reconciler reconciler
53+
informerScope kubebindv1alpha2.InformerScope
54+
isolation kubebindv1alpha2.Isolation
55+
reconciler reconciler
5656
}
5757

5858
// NewAPIServiceNamespaceReconciler returns a new APIServiceNamespaceReconciler to reconcile APIServiceNamespaces.
@@ -70,10 +70,10 @@ func NewAPIServiceNamespaceReconciler(
7070
}
7171

7272
r := &APIServiceNamespaceReconciler{
73-
manager: mgr,
74-
opts: opts,
75-
informerScope: scope,
76-
clusterScopedIsolation: isolation,
73+
manager: mgr,
74+
opts: opts,
75+
informerScope: scope,
76+
isolation: isolation,
7777
reconciler: reconciler{
7878
scope: scope,
7979

backend/oidc/oidc_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ func TestLoadTLSConfig_Success(t *testing.T) {
5353
// Verify the TLS config was created
5454
if config == nil {
5555
t.Fatal("Expected non-nil TLS config")
56+
return
5657
}
5758

5859
if config.RootCAs == nil {
@@ -194,6 +195,7 @@ func TestLoadTLSConfig_MultipleCerts(t *testing.T) {
194195
// Verify the TLS config was created
195196
if config == nil {
196197
t.Fatal("Expected non-nil TLS config")
198+
return
197199
}
198200

199201
if config.RootCAs == nil {

backend/options/options.go

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,14 @@ type ExtraOptions struct {
4848

4949
Provider string
5050

51-
NamespacePrefix string
52-
PrettyName string
53-
ConsumerScope string
54-
ClusterScopedIsolation string
55-
ExternalAddress string
56-
ExternalCAFile string
57-
ExternalCA []byte
58-
TLSExternalServerName string
51+
NamespacePrefix string
52+
PrettyName string
53+
ConsumerScope string
54+
Isolation string
55+
ExternalAddress string
56+
ExternalCAFile string
57+
ExternalCA []byte
58+
TLSExternalServerName string
5959
// Defines the source of the schema for the bind screen.
6060
// Options are:
6161
// CustomResourceDefinition.v1.apiextensions.k8s.io
@@ -101,14 +101,14 @@ func NewOptions() *Options {
101101
ProviderKcp: providerkcp.NewOptions(),
102102

103103
ExtraOptions: ExtraOptions{
104-
Provider: "kubernetes",
105-
NamespacePrefix: "cluster-",
106-
PrettyName: "Backend",
107-
ConsumerScope: string(kubebindv1alpha2.NamespacedScope),
108-
ClusterScopedIsolation: string(kubebindv1alpha2.IsolationPrefixed),
109-
SchemaSource: CustomResourceDefinitionSource.String(),
110-
Frontend: "embedded", // Not used, but indicates to use embedded frontend using SPA.
111-
TokenExpiry: 1 * time.Hour,
104+
Provider: "kubernetes",
105+
NamespacePrefix: "cluster-",
106+
PrettyName: "Backend",
107+
ConsumerScope: string(kubebindv1alpha2.NamespacedScope),
108+
Isolation: string(kubebindv1alpha2.IsolationPrefixed),
109+
SchemaSource: CustomResourceDefinitionSource.String(),
110+
Frontend: "embedded", // Not used, but indicates to use embedded frontend using SPA.
111+
TokenExpiry: 1 * time.Hour,
112112
},
113113
}
114114
return opts
@@ -151,7 +151,10 @@ func (options *Options) AddFlags(fs *pflag.FlagSet) {
151151
fs.StringVar(&options.NamespacePrefix, "namespace-prefix", options.NamespacePrefix, "The prefix to use for cluster namespaces")
152152
fs.StringVar(&options.PrettyName, "pretty-name", options.PrettyName, "Pretty name for the backend")
153153
fs.StringVar(&options.ConsumerScope, "consumer-scope", options.ConsumerScope, "How consumers access the service provider cluster. In Kubernetes, \"namespaced\" allows namespace isolation. In kcp, \"cluster\" allows workspace isolation, and with that allows cluster-scoped resources to bind and it is generally more performant.")
154-
fs.StringVar(&options.ClusterScopedIsolation, "cluster-scoped-isolation", options.ClusterScopedIsolation, "How cluster scoped service objects are isolated between multiple consumers on the provider side. Among the choices, \"prefixed\" prepends the name of the cluster namespace to an object's name; \"namespaced\" maps a consumer side object into a namespaced object inside the corresponding cluster namespace; \"none\" is used for the case of a dedicated provider where isolation is not necessary.")
154+
// TODO(mjudeikis): remove deprecated flag in future release
155+
fs.StringVar(&options.Isolation, "cluster-scoped-isolation", options.Isolation, "How cluster scoped service objects are isolated between multiple consumers on the provider side. Among the choices, \"prefixed\" prepends the name of the cluster namespace to an object's name; \"namespaced\" maps a consumer side object into a namespaced object inside the corresponding cluster namespace; \"none\" is used for the case of a dedicated provider where isolation is not necessary.")
156+
_ = fs.MarkDeprecated("cluster-scoped-isolation", "use --isolation instead")
157+
fs.StringVar(&options.Isolation, "isolation", options.Isolation, "Deprecated: use --cluster-scoped-isolation instead. How cluster scoped service objects are isolated between multiple consumers on the provider side. Among the choices, \"prefixed\" prepends the name of the cluster namespace to an object's name; \"namespaced\" maps a consumer side object into a namespaced object inside the corresponding cluster namespace; \"none\" is used for the case of a dedicated provider where isolation is not necessary.")
155158
fs.StringVar(&options.ExternalAddress, "external-address", options.ExternalAddress, "The external address for the service provider cluster, including https:// and port. If not specified, service account's hosts are used.")
156159
fs.StringVar(&options.ExternalCAFile, "external-ca-file", options.ExternalCAFile, "The external CA file for the service provider cluster. If not specified, service account's CA is used.")
157160
fs.StringVar(&options.TLSExternalServerName, "external-server-name", options.TLSExternalServerName, "The external (TLS) server name used by consumers to talk to the service provider cluster. This can be useful to select the right certificate via SNI.")
@@ -200,13 +203,13 @@ func (options *Options) Complete() (*CompletedOptions, error) {
200203
if strings.ToLower(options.ConsumerScope) == "cluster" {
201204
options.ConsumerScope = string(kubebindv1alpha2.ClusterScope)
202205
}
203-
switch strings.ToLower(options.ClusterScopedIsolation) {
206+
switch strings.ToLower(options.Isolation) {
204207
case "prefixed":
205-
options.ClusterScopedIsolation = string(kubebindv1alpha2.IsolationPrefixed)
208+
options.Isolation = string(kubebindv1alpha2.IsolationPrefixed)
206209
case "namespaced":
207-
options.ClusterScopedIsolation = string(kubebindv1alpha2.IsolationNamespaced)
210+
options.Isolation = string(kubebindv1alpha2.IsolationNamespaced)
208211
case "none":
209-
options.ClusterScopedIsolation = string(kubebindv1alpha2.IsolationNone)
212+
options.Isolation = string(kubebindv1alpha2.IsolationNone)
210213
}
211214

212215
if options.ExternalCAFile != "" && options.ExternalCA != nil {

backend/server.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ func NewServer(ctx context.Context, c *Config) (*Server, error) {
179179
s.Config.Manager,
180180
opts,
181181
kubebindv1alpha2.InformerScope(c.Options.ConsumerScope),
182-
kubebindv1alpha2.Isolation(c.Options.ClusterScopedIsolation),
182+
kubebindv1alpha2.Isolation(c.Options.Isolation),
183183
)
184184
if err != nil {
185185
return nil, fmt.Errorf("error setting up APIServiceNamespace Controller: %w", err)
@@ -195,7 +195,7 @@ func NewServer(ctx context.Context, c *Config) (*Server, error) {
195195
s.Config.Manager,
196196
opts,
197197
kubebindv1alpha2.InformerScope(c.Options.ConsumerScope),
198-
kubebindv1alpha2.Isolation(c.Options.ClusterScopedIsolation),
198+
kubebindv1alpha2.Isolation(c.Options.Isolation),
199199
c.Options.SchemaSource,
200200
)
201201
if err != nil {

contrib/kcp/deploy/resources/apiexport-kube-bind.io.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ spec:
6262
crd: {}
6363
- group: kube-bind.io
6464
name: apiserviceexports
65-
schema: v251112-503d98b.apiserviceexports.kube-bind.io
65+
schema: v251230-e36591a1.apiserviceexports.kube-bind.io
6666
storage:
6767
crd: {}
6868
- group: kube-bind.io

contrib/kcp/deploy/resources/apiresourceschema-apiserviceexports.kube-bind.io.yaml

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
apiVersion: apis.kcp.io/v1alpha1
22
kind: APIResourceSchema
33
metadata:
4-
name: v251112-503d98b.apiserviceexports.kube-bind.io
4+
name: v251230-e36591a1.apiserviceexports.kube-bind.io
55
spec:
66
conversion:
77
strategy: None
@@ -466,11 +466,15 @@ spec:
466466
description: |-
467467
ClusterScopedIsolation specifies how cluster scoped service objects are isolated between multiple consumers on the provider side.
468468
It can be "Prefixed", "Namespaced", or "None".
469+
Deprecated: use Isolation instead.
469470
enum:
470471
- Prefixed
471472
- Namespaced
472473
- None
473474
type: string
475+
x-kubernetes-validations:
476+
- message: clusterScopedIsolation is immutable
477+
rule: self == oldSelf
474478
informerScope:
475479
description: |-
476480
informerScope is the scope of the APIServiceExport. It can be either Cluster or Namespace.
@@ -486,6 +490,18 @@ spec:
486490
x-kubernetes-validations:
487491
- message: informerScope is immutable
488492
rule: self == oldSelf
493+
isolation:
494+
description: |-
495+
Isolation specifies how service objects are isolated between multiple consumers on the provider side.
496+
It can be "Prefixed", "Namespaced", or "None".
497+
enum:
498+
- Prefixed
499+
- Namespaced
500+
- None
501+
type: string
502+
x-kubernetes-validations:
503+
- message: isolation is immutable
504+
rule: self == oldSelf
489505
permissionClaims:
490506
description: |-
491507
PermissionClaims records decisions about permission claims requested by the service provider.
@@ -670,6 +686,7 @@ spec:
670686
rule: self == oldSelf
671687
required:
672688
- informerScope
689+
- isolation
673690
- resources
674691
type: object
675692
status:

deploy/charts/backend/crds/kube-bind.io_apiserviceexports.yaml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -469,11 +469,15 @@ spec:
469469
description: |-
470470
ClusterScopedIsolation specifies how cluster scoped service objects are isolated between multiple consumers on the provider side.
471471
It can be "Prefixed", "Namespaced", or "None".
472+
Deprecated: use Isolation instead.
472473
enum:
473474
- Prefixed
474475
- Namespaced
475476
- None
476477
type: string
478+
x-kubernetes-validations:
479+
- message: clusterScopedIsolation is immutable
480+
rule: self == oldSelf
477481
informerScope:
478482
description: |-
479483
informerScope is the scope of the APIServiceExport. It can be either Cluster or Namespace.
@@ -489,6 +493,18 @@ spec:
489493
x-kubernetes-validations:
490494
- message: informerScope is immutable
491495
rule: self == oldSelf
496+
isolation:
497+
description: |-
498+
Isolation specifies how service objects are isolated between multiple consumers on the provider side.
499+
It can be "Prefixed", "Namespaced", or "None".
500+
enum:
501+
- Prefixed
502+
- Namespaced
503+
- None
504+
type: string
505+
x-kubernetes-validations:
506+
- message: isolation is immutable
507+
rule: self == oldSelf
492508
permissionClaims:
493509
description: |-
494510
PermissionClaims records decisions about permission claims requested by the service provider.
@@ -673,6 +689,7 @@ spec:
673689
rule: self == oldSelf
674690
required:
675691
- informerScope
692+
- isolation
676693
- resources
677694
type: object
678695
status:

deploy/charts/backend/templates/deployment.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ spec:
7676
{{- if .Values.backend.consumerScope }}
7777
- --consumer-scope={{ .Values.backend.consumerScope }}
7878
{{- end }}
79-
{{- if .Values.backend.clusterScopeIsolation }}
80-
- --cluster-scoped-isolation={{ .Values.backend.clusterScopeIsolation }}
79+
{{- if .Values.backend.isolation }}
80+
- --isolation={{ .Values.backend.isolation }}
8181
{{- end }}
8282
{{- if .Values.backend.cookieSigningKey }}
8383
- --cookie-signing-key={{ .Values.backend.cookieSigningKey }}

0 commit comments

Comments
 (0)