Skip to content

Commit 919982b

Browse files
author
Matthew Barnes
committed
api: Remove ClusterCapabilitiesProfile
We decided to structure optional features differently after a lengthy discussion in openshift-online/ocm-api-model#1037 This keeps the nice test framework in ocm_test.go even though it doesn't do much now. This can be expanded upon in the future.
1 parent 317e8bc commit 919982b

File tree

13 files changed

+8
-286
lines changed

13 files changed

+8
-286
lines changed

api/redhatopenshift/HcpCluster.Management/hcpCluster-models.tsp

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -68,29 +68,6 @@ model HcpOpenShiftClusterProperties {
6868
/** Azure platform configuration */
6969
@visibility(Lifecycle.Read, Lifecycle.Create)
7070
platform: PlatformProfile;
71-
72-
/** Configure cluter capabilities. */
73-
@visibility(Lifecycle.Read, Lifecycle.Create)
74-
capabilities?: ClusterCapabilitiesProfile;
75-
}
76-
77-
/** Cluster capabilities configuration. */
78-
model ClusterCapabilitiesProfile {
79-
/**
80-
* Immutable list of disabled capabilities. May only contain "ImageRegistry" at
81-
* this time. Additional capabilities may be available in the future. Clients
82-
* should expect to handle additional values.
83-
*/
84-
@visibility(Lifecycle.Read, Lifecycle.Create)
85-
disabled?: OptionalClusterCapability[];
86-
}
87-
88-
/** Cluster capabilities that can be disabled. */
89-
union OptionalClusterCapability {
90-
string,
91-
92-
/** Enables the OpenShift internal image registry. */
93-
ImageRegistry: "ImageRegistry",
9471
}
9572

9673
/** The resource provisioning state. */

api/redhatopenshift/resource-manager/Microsoft.RedHatOpenShift/hcpclusters/preview/2024-06-10-preview/openapi.json

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1063,23 +1063,6 @@
10631063
}
10641064
]
10651065
},
1066-
"ClusterCapabilitiesProfile": {
1067-
"type": "object",
1068-
"description": "Cluster capabilities configuration.",
1069-
"properties": {
1070-
"disabled": {
1071-
"type": "array",
1072-
"description": "Immutable list of disabled capabilities. May only contain \"ImageRegistry\" at\nthis time. Additional capabilities may be available in the future. Clients\nshould expect to handle additional values.",
1073-
"items": {
1074-
"$ref": "#/definitions/OptionalClusterCapability"
1075-
},
1076-
"x-ms-mutability": [
1077-
"read",
1078-
"create"
1079-
]
1080-
}
1081-
}
1082-
},
10831066
"ConsoleProfile": {
10841067
"type": "object",
10851068
"description": "Configuration of the cluster web console",
@@ -1255,14 +1238,6 @@
12551238
"read",
12561239
"create"
12571240
]
1258-
},
1259-
"capabilities": {
1260-
"$ref": "#/definitions/ClusterCapabilitiesProfile",
1261-
"description": "Configure cluter capabilities.",
1262-
"x-ms-mutability": [
1263-
"read",
1264-
"create"
1265-
]
12661241
}
12671242
},
12681243
"required": [
@@ -1796,24 +1771,6 @@
17961771
"userAssignedIdentities"
17971772
]
17981773
},
1799-
"OptionalClusterCapability": {
1800-
"type": "string",
1801-
"description": "Cluster capabilities that can be disabled.",
1802-
"enum": [
1803-
"ImageRegistry"
1804-
],
1805-
"x-ms-enum": {
1806-
"name": "OptionalClusterCapability",
1807-
"modelAsString": true,
1808-
"values": [
1809-
{
1810-
"name": "ImageRegistry",
1811-
"value": "ImageRegistry",
1812-
"description": "Enables the OpenShift internal image registry."
1813-
}
1814-
]
1815-
}
1816-
},
18171774
"PlatformProfile": {
18181775
"type": "object",
18191776
"description": "Azure specific configuration",

frontend/pkg/frontend/ocm.go

Lines changed: 1 addition & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -81,38 +81,6 @@ func convertOutboundTypeRPToCS(outboundTypeRP api.OutboundType) (outboundTypeCS
8181
return
8282
}
8383

84-
func convertDisabledCapabilitiesToCS(in []api.OptionalClusterCapability) []string {
85-
var out []string
86-
for _, c := range in {
87-
out = append(out, string(c))
88-
}
89-
return out
90-
}
91-
92-
func convertDisableCapabilitiesToRP(in []string) []api.OptionalClusterCapability {
93-
var out []api.OptionalClusterCapability
94-
for _, c := range in {
95-
out = append(out, api.OptionalClusterCapability(c))
96-
}
97-
return out
98-
}
99-
100-
func convertClusterCapabilitiesToRP(in *arohcpv1alpha1.Cluster) api.ClusterCapabilitiesProfile {
101-
out := api.ClusterCapabilitiesProfile{}
102-
if in == nil {
103-
return out
104-
}
105-
if in.Capabilities() != nil {
106-
out.Disabled = convertDisableCapabilitiesToRP(in.Capabilities().Disabled())
107-
}
108-
return out
109-
}
110-
111-
func convertClusterCapabilitiesToCSBuilder(in api.ClusterCapabilitiesProfile) *arohcpv1alpha1.ClusterCapabilitiesBuilder {
112-
return arohcpv1alpha1.NewClusterCapabilities().
113-
Disabled(convertDisabledCapabilitiesToCS(in.Disabled)...)
114-
}
115-
11684
func convertEnableEncryptionAtHostToCSBuilder(in api.NodePoolPlatformProfile) *arohcpv1alpha1.AzureNodePoolEncryptionAtHostBuilder {
11785
var state string
11886

@@ -175,7 +143,6 @@ func ConvertCStoHCPOpenShiftCluster(resourceID *azcorearm.ResourceID, cluster *a
175143
NetworkSecurityGroupID: cluster.Azure().NetworkSecurityGroupResourceID(),
176144
IssuerURL: "",
177145
},
178-
Capabilities: convertClusterCapabilitiesToRP(cluster),
179146
},
180147
}
181148

@@ -284,8 +251,7 @@ func withImmutableAttributes(clusterBuilder *arohcpv1alpha1.ClusterBuilder, hcpC
284251
MachineCIDR(hcpCluster.Properties.Network.MachineCIDR).
285252
HostPrefix(int(hcpCluster.Properties.Network.HostPrefix))).
286253
API(arohcpv1alpha1.NewClusterAPI().
287-
Listening(convertVisibilityToListening(hcpCluster.Properties.API.Visibility))).
288-
Capabilities(convertClusterCapabilitiesToCSBuilder(hcpCluster.Properties.Capabilities))
254+
Listening(convertVisibilityToListening(hcpCluster.Properties.API.Visibility)))
289255

290256
azureBuilder := arohcpv1alpha1.NewAzure().
291257
TenantID(tenantID).

frontend/pkg/frontend/ocm_test.go

Lines changed: 0 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -84,30 +84,6 @@ func TestConvertCStoHCPOpenShiftCluster(t *testing.T) {
8484
cluster: arohcpv1alpha1.NewCluster(),
8585
want: clusterResource(),
8686
},
87-
{
88-
name: "disabled capability",
89-
cluster: arohcpv1alpha1.NewCluster().
90-
Capabilities(
91-
arohcpv1alpha1.NewClusterCapabilities().
92-
Disabled("red"),
93-
),
94-
want: clusterResource(withDisabledCapabilities("red")),
95-
},
96-
{
97-
name: "disabled capabilities",
98-
cluster: arohcpv1alpha1.NewCluster().
99-
Capabilities(
100-
arohcpv1alpha1.NewClusterCapabilities().
101-
Disabled("red", "green", "blue"),
102-
),
103-
want: clusterResource(withDisabledCapabilities("red", "green", "blue")),
104-
},
105-
{
106-
name: "disabled capabilities empty",
107-
cluster: arohcpv1alpha1.NewCluster().
108-
Capabilities(arohcpv1alpha1.NewClusterCapabilities()),
109-
want: clusterResource(),
110-
},
11187
}
11288
for _, tc := range testCases {
11389
t.Run(tc.name, func(t *testing.T) {
@@ -135,39 +111,6 @@ func TestWithImmutableAttributes(t *testing.T) {
135111
},
136112
want: ocmCluster(t, withOCMClusterDefaults()),
137113
},
138-
{
139-
name: "disabled capability",
140-
hcpCluster: &api.HCPOpenShiftCluster{
141-
Properties: api.HCPOpenShiftClusterProperties{
142-
Platform: api.PlatformProfile{
143-
ManagedResourceGroup: "test",
144-
},
145-
Capabilities: api.ClusterCapabilitiesProfile{
146-
Disabled: []api.OptionalClusterCapability{
147-
api.OptionalClusterCapability("TEST_ONE"),
148-
},
149-
},
150-
},
151-
},
152-
want: ocmCluster(t, withOCMClusterDefaults(), withOCMDisabledCapabilities("TEST_ONE")),
153-
},
154-
{
155-
name: "disabled capabilities",
156-
hcpCluster: &api.HCPOpenShiftCluster{
157-
Properties: api.HCPOpenShiftClusterProperties{
158-
Platform: api.PlatformProfile{
159-
ManagedResourceGroup: "test",
160-
},
161-
Capabilities: api.ClusterCapabilitiesProfile{
162-
Disabled: []api.OptionalClusterCapability{
163-
api.OptionalClusterCapability("TEST_ONE"),
164-
api.OptionalClusterCapability("TEST_TWO"),
165-
},
166-
},
167-
},
168-
},
169-
want: ocmCluster(t, withOCMClusterDefaults(), withOCMDisabledCapabilities("TEST_ONE", "TEST_TWO")),
170-
},
171114
}
172115

173116
for _, tc := range testCases {
@@ -208,14 +151,6 @@ func clusterResource(opts ...func(*api.HCPOpenShiftCluster)) *api.HCPOpenShiftCl
208151
return c
209152
}
210153

211-
func withDisabledCapabilities(caps ...string) func(*api.HCPOpenShiftCluster) {
212-
return func(c *api.HCPOpenShiftCluster) {
213-
for _, capability := range caps {
214-
c.Properties.Capabilities.Disabled = append(c.Properties.Capabilities.Disabled, api.OptionalClusterCapability(capability))
215-
}
216-
}
217-
}
218-
219154
func ocmCluster(t *testing.T, opts ...func(*arohcpv1alpha1.ClusterBuilder) *arohcpv1alpha1.ClusterBuilder) *arohcpv1alpha1.Cluster {
220155
b := arohcpv1alpha1.NewCluster()
221156
for _, opt := range opts {
@@ -225,11 +160,6 @@ func ocmCluster(t *testing.T, opts ...func(*arohcpv1alpha1.ClusterBuilder) *aroh
225160
assert.NoError(t, err)
226161
return c
227162
}
228-
func withOCMDisabledCapabilities(values ...string) func(*arohcpv1alpha1.ClusterBuilder) *arohcpv1alpha1.ClusterBuilder {
229-
return func(b *arohcpv1alpha1.ClusterBuilder) *arohcpv1alpha1.ClusterBuilder {
230-
return b.Capabilities(arohcpv1alpha1.NewClusterCapabilities().Disabled(values...))
231-
}
232-
}
233163

234164
func withOCMClusterDefaults() func(*arohcpv1alpha1.ClusterBuilder) *arohcpv1alpha1.ClusterBuilder {
235165
return func(b *arohcpv1alpha1.ClusterBuilder) *arohcpv1alpha1.ClusterBuilder {
@@ -248,8 +178,6 @@ func withOCMClusterDefaults() func(*arohcpv1alpha1.ClusterBuilder) *arohcpv1alph
248178
SubscriptionID("test").
249179
TenantID("test"),
250180
).
251-
Capabilities(arohcpv1alpha1.NewClusterCapabilities().
252-
Disabled()).
253181
CCS(arohcpv1alpha1.NewCCS().Enabled(true)).
254182
CloudProvider(cmv1.NewCloudProvider().
255183
ID("azure")).

internal/api/enums.go

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,3 @@ const (
5656
// EffectPreferNoSchedule - PreferNoSchedule taint effect
5757
EffectPreferNoSchedule Effect = "PreferNoSchedule"
5858
)
59-
60-
// OptionalClusterCapability - Cluster capabilities that can be disabled.
61-
type OptionalClusterCapability string
62-
63-
const (
64-
// OptionalClusterCapabilityImageRegistry - Enables the OpenShift internal image registry.
65-
OptionalClusterCapabilityImageRegistry OptionalClusterCapability = "ImageRegistry"
66-
)

internal/api/hcpopenshiftcluster.go

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,13 @@ type HCPOpenShiftCluster struct {
3535

3636
// HCPOpenShiftClusterProperties represents the property bag of a HCPOpenShiftCluster resource.
3737
type HCPOpenShiftClusterProperties struct {
38-
ProvisioningState arm.ProvisioningState `json:"provisioningState,omitempty" visibility:"read"`
39-
Version VersionProfile `json:"version,omitempty"`
40-
DNS DNSProfile `json:"dns,omitempty"`
41-
Network NetworkProfile `json:"network,omitempty" visibility:"read create"`
42-
Console ConsoleProfile `json:"console,omitempty" visibility:"read"`
43-
API APIProfile `json:"api,omitempty"`
44-
Platform PlatformProfile `json:"platform,omitempty" visibility:"read create"`
45-
Capabilities ClusterCapabilitiesProfile `json:"capabilities,omitempty" visibility:"read create"`
38+
ProvisioningState arm.ProvisioningState `json:"provisioningState,omitempty" visibility:"read"`
39+
Version VersionProfile `json:"version,omitempty"`
40+
DNS DNSProfile `json:"dns,omitempty"`
41+
Network NetworkProfile `json:"network,omitempty" visibility:"read create"`
42+
Console ConsoleProfile `json:"console,omitempty" visibility:"read"`
43+
API APIProfile `json:"api,omitempty"`
44+
Platform PlatformProfile `json:"platform,omitempty" visibility:"read create"`
4645
}
4746

4847
// VersionProfile represents the cluster control plane version.
@@ -107,13 +106,6 @@ type UserAssignedIdentitiesProfile struct {
107106
ServiceManagedIdentity string `json:"serviceManagedIdentity,omitempty" validate:"omitempty,resource_id=Microsoft.ManagedIdentity/userAssignedIdentities"`
108107
}
109108

110-
// ClusterCapabilitiesProfile - Cluster capabilities configuration.
111-
// Visibility for the entire struct is "read create".
112-
type ClusterCapabilitiesProfile struct {
113-
// Disabled cluter capabilities.
114-
Disabled []OptionalClusterCapability `json:"disabled,omitempty" validate:"dive,enum_optionalclustercapability"`
115-
}
116-
117109
// Creates an HCPOpenShiftCluster with any non-zero default values.
118110
func NewDefaultHCPOpenShiftCluster() *HCPOpenShiftCluster {
119111
return &HCPOpenShiftCluster{

internal/api/testhelpers.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,6 @@ func NewTestValidator() *validator.Validate {
8686
arm.ManagedServiceIdentityTypeSystemAssigned,
8787
arm.ManagedServiceIdentityTypeSystemAssignedUserAssigned,
8888
arm.ManagedServiceIdentityTypeUserAssigned))
89-
validate.RegisterAlias("enum_optionalclustercapability", EnumValidateTag(
90-
OptionalClusterCapabilityImageRegistry))
9189

9290
return validate
9391
}

internal/api/v20240610preview/generated/constants.go

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

internal/api/v20240610preview/generated/models.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.

0 commit comments

Comments
 (0)