Skip to content

Commit 023ded7

Browse files
committed
chore: fixed merge conflicts
2 parents 35157d4 + e781d9d commit 023ded7

File tree

20 files changed

+378
-28
lines changed

20 files changed

+378
-28
lines changed

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
# [0.6.0](https://github.com/telekom/controlplane/compare/v0.5.0...v0.6.0) (2025-07-14)
2+
3+
4+
### Bug Fixes
5+
6+
* add update_install.sh ([#70](https://github.com/telekom/controlplane/issues/70)) ([989c9fb](https://github.com/telekom/controlplane/commit/989c9fb3d351ea83133faef066a09e87bfbf9905))
7+
8+
9+
### Features
10+
11+
* **visibility:** add Zone visibility feature ([e24a881](https://github.com/telekom/controlplane/commit/e24a8813afc43360dcb5c3657faeb5b96cf7e236))
12+
113
# [0.5.0](https://github.com/telekom/controlplane/compare/v0.4.0...v0.5.0) (2025-07-03)
214

315

admin/api/v1/zone_types.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,13 @@ import (
1010
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1111
)
1212

13+
type ZoneVisibility string
14+
15+
const (
16+
ZoneVisibilityWorld ZoneVisibility = "World"
17+
ZoneVisibilityEnterprise ZoneVisibility = "Enterprise"
18+
)
19+
1320
type RedisConfig struct {
1421
Host string `json:"host"`
1522
Port int `json:"port"`
@@ -54,6 +61,9 @@ type ZoneSpec struct {
5461
Gateway GatewayConfig `json:"gateway"`
5562
Redis RedisConfig `json:"redis"`
5663
TeamApis *TeamApiConfig `json:"teamApis,omitempty"`
64+
// +kubebuilder:validation:Enum=World;Enterprise
65+
// Visibility controls what subscriptions are allowed from and to this zone. It's also relevant for features like failover
66+
Visibility ZoneVisibility `json:"visibility"`
5767
}
5868

5969
type Links struct {

admin/config/crd/bases/admin.cp.ei.telekom.de_zones.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,10 +117,18 @@ spec:
117117
required:
118118
- apis
119119
type: object
120+
visibility:
121+
description: Visibility controls what subscriptions are allowed from
122+
and to this zone. It's also relevant for features like failover
123+
enum:
124+
- World
125+
- Enterprise
126+
type: string
120127
required:
121128
- gateway
122129
- identityProvider
123130
- redis
131+
- visibility
124132
type: object
125133
status:
126134
description: ZoneStatus defines the observed state of Zone

admin/internal/controller/zone_controller_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ func NewZone(name string, namespace string) *adminv1.Zone {
6666
Url: "https://test-team-api-host.de/test-team-api-v1",
6767
}},
6868
},
69+
Visibility: adminv1.ZoneVisibilityWorld,
6970
},
7071
}
7172
}

api/internal/controller/apiexposure_controller_test.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ func CreateZone(name string) *adminapi.Zone {
3131
config.EnvironmentLabelKey: testEnvironment,
3232
},
3333
},
34-
Spec: adminapi.ZoneSpec{},
34+
Spec: adminapi.ZoneSpec{
35+
Visibility: adminapi.ZoneVisibilityWorld,
36+
},
3537
}
3638

3739
err := k8sClient.Create(ctx, zone)

api/internal/handler/apisubscription/handler.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,20 @@ func (h *ApiSubscriptionHandler) CreateOrUpdate(ctx context.Context, apiSub *api
8181
apiSub.Spec.ApiBasePath, api.Spec.BasePath)
8282
}
8383

84+
// - validate visibility of apiExposure (WORLD, ENTERPRISE, ZONE) depending on subscription zone
85+
valid, err := ApiVisibilityMustBeValid(ctx, apiExposure, apiSub)
86+
if err != nil {
87+
return err
88+
}
89+
if !valid {
90+
apiSub.SetCondition(condition.NewNotReadyCondition("VisibilityConstraintViolation", "ApiExposure and ApiSubscription visibility combination is not allowed"))
91+
apiSub.SetCondition(condition.NewBlockedCondition(
92+
fmt.Sprintf("ApiSubscription is blocked. Subscriptions from zone '%s' are not allowed due to exposure visiblity constraints", apiSub.Spec.Zone.GetName())))
93+
return nil
94+
}
95+
8496
// TODO: further validations (currently contained in the old code)
8597
// - validate if team category allows subscription of api category
86-
// - validate visibility of apiExposure (WORLD, ENTERPRISE, ZONE) depending on subscription zone
8798

8899
// get application from cluster and get clientId from status
89100
application, err := util.GetApplication(ctx, apiSub.Spec.Requestor.Application)

api/internal/handler/apisubscription/validation.go

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@ package apisubscription
66

77
import (
88
"context"
9-
9+
"fmt"
1010
"github.com/pkg/errors"
11+
adminv1 "github.com/telekom/controlplane/admin/api/v1"
1112
apiapi "github.com/telekom/controlplane/api/api/v1"
1213
cclient "github.com/telekom/controlplane/common/pkg/client"
1314
"github.com/telekom/controlplane/common/pkg/condition"
@@ -85,3 +86,40 @@ func ApiExposureMustExist(ctx context.Context, obj types.Object) (bool, *apiapi.
8586

8687
return true, &apiExposureList.Items[0], nil
8788
}
89+
90+
func ApiVisibilityMustBeValid(ctx context.Context, apiExposure *apiapi.ApiExposure, apiSubscription *apiapi.ApiSubscription) (bool, error) {
91+
scopedClient := cclient.ClientFromContextOrDie(ctx)
92+
log := log.FromContext(ctx)
93+
94+
exposureVisibility := apiExposure.Spec.Visibility
95+
96+
// any subscription is valid for a WORLD exposure
97+
if exposureVisibility == apiapi.VisibilityWorld {
98+
return true, nil
99+
}
100+
101+
// get the subscription zone
102+
subZone := &adminv1.Zone{}
103+
err := scopedClient.Get(ctx, apiSubscription.Spec.Zone.K8s(), subZone)
104+
if err != nil {
105+
log.Error(err, "unable to get zone", "name", apiSubscription.Spec.Zone.K8s())
106+
return false, errors.Wrapf(err, "Zone '%s' not found", apiSubscription.Spec.Zone.GetName())
107+
}
108+
109+
// only same zone
110+
if exposureVisibility == apiapi.VisibilityZone {
111+
if apiExposure.Spec.Zone.GetName() != subZone.GetName() {
112+
log.Info(fmt.Sprintf("Exposure visibility is ZONE and it doesnt match the subscription zone '%s'", subZone.GetName()))
113+
return false, nil
114+
}
115+
}
116+
117+
// only enterprise zones
118+
if exposureVisibility == apiapi.VisibilityEnterprise {
119+
if subZone.Spec.Visibility != adminv1.ZoneVisibilityEnterprise {
120+
log.Info(fmt.Sprintf("Api is exposed with visibility '%s', but subscriptions is from zone with visibility '%s'", apiapi.VisibilityEnterprise, subZone.Spec.Visibility))
121+
return false, nil
122+
}
123+
}
124+
return true, nil
125+
}

api/internal/handler/util_proxy_route_test.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ func CreateZone(name string) *adminapi.Zone {
3131
config.EnvironmentLabelKey: testEnvironment,
3232
},
3333
},
34-
Spec: adminapi.ZoneSpec{},
34+
Spec: adminapi.ZoneSpec{
35+
Visibility: adminapi.ZoneVisibilityWorld,
36+
},
3537
}
3638

3739
err := k8sClient.Create(ctx, zone)

application/internal/controller/application_controller_test.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,9 @@ var _ = Describe("Application Controller", func() {
4545
config.EnvironmentLabelKey: testEnvironment,
4646
},
4747
},
48-
Spec: adminv1.ZoneSpec{},
48+
Spec: adminv1.ZoneSpec{
49+
Visibility: adminv1.ZoneVisibilityWorld,
50+
},
4951
}
5052
Expect(k8sClient.Create(ctx, zoneA)).To(Succeed())
5153

@@ -58,7 +60,9 @@ var _ = Describe("Application Controller", func() {
5860
config.EnvironmentLabelKey: testEnvironment,
5961
},
6062
},
61-
Spec: adminv1.ZoneSpec{},
63+
Spec: adminv1.ZoneSpec{
64+
Visibility: adminv1.ZoneVisibilityWorld,
65+
},
6266
}
6367
Expect(k8sClient.Create(ctx, zoneB)).To(Succeed())
6468

common-server/helm/Chart.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
# SPDX-License-Identifier: Apache-2.0
44

55
apiVersion: v2
6-
appVersion: 0.5.0
6+
appVersion: 0.6.0
77
description: A helm chart to deploy a generic common-server instance
88
name: common-server
99
type: application
10-
version: 0.5.0
10+
version: 0.6.0
1111
icon: https://raw.githubusercontent.com/telekom/controlplane/refs/heads/main/docs/img/Open-Telekom-Integration-Platform_Visual.svg

0 commit comments

Comments
 (0)