Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ Adding hubClusterArn validation in spec #356

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,10 @@ spec:
- awsirsa
type: string
hubClusterArn:
description: This represents the hub cluster ARN
description: |-
This represents the hub cluster ARN
Example - arn:eks:us-west-2:12345678910:cluster/hub-cluster1
pattern: ^arn:aws:eks:([a-zA-Z0-9-]+):(\d{12}):cluster/([a-zA-Z0-9-]+)$
type: string
type: object
type: array
Expand Down
2 changes: 2 additions & 0 deletions operator/v1/types_clustermanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,9 @@ type RegistrationDriverHub struct {
AuthType string `json:"authType,omitempty"`

// This represents the hub cluster ARN
// Example - arn:eks:us-west-2:12345678910:cluster/hub-cluster1
// +optional
// +kubebuilder:validation:Pattern=`^arn:aws:eks:([a-zA-Z0-9-]+):(\d{12}):cluster/([a-zA-Z0-9-]+)$`
HubClusterArn string `json:"hubClusterArn,omitempty"`
}

Expand Down
2 changes: 1 addition & 1 deletion operator/v1/zz_generated.swagger_doc_generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

40 changes: 40 additions & 0 deletions test/integration/api/clustermanager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,46 @@ var _ = Describe("ClusterManager API test with RegistrationConfiguration", func(
Expect(clusterManager.Spec.RegistrationConfiguration.FeatureGates[0].Mode).Should(Equal(operatorv1.FeatureGateModeTypeDisable))
Expect(clusterManager.Spec.RegistrationConfiguration.FeatureGates[1].Mode).Should(Equal(operatorv1.FeatureGateModeTypeEnable))
})

It("Create a cluster manager with aws registration and invalid hubClusterArn", func() {
clusterManager := &operatorv1.ClusterManager{
ObjectMeta: metav1.ObjectMeta{
Name: clusterManagerName,
},
Spec: operatorv1.ClusterManagerSpec{
RegistrationConfiguration: &operatorv1.RegistrationHubConfiguration{
RegistrationDrivers: []operatorv1.RegistrationDriverHub{
{
AuthType: "awsirsa",
HubClusterArn: "arn:aws:bks:us-west-2:123456789012:cluster/hub-cluster1",
},
},
},
},
}
_, err := operatorClient.OperatorV1().ClusterManagers().Create(context.TODO(), clusterManager, metav1.CreateOptions{})
Expect(err).ToNot(BeNil())
})

It("Create a cluster manager with aws registration and valid hubClusterArn", func() {
clusterManager := &operatorv1.ClusterManager{
ObjectMeta: metav1.ObjectMeta{
Name: clusterManagerName,
},
Spec: operatorv1.ClusterManagerSpec{
RegistrationConfiguration: &operatorv1.RegistrationHubConfiguration{
RegistrationDrivers: []operatorv1.RegistrationDriverHub{
{
AuthType: "awsirsa",
HubClusterArn: "arn:aws:eks:us-west-2:123456789012:cluster/hub-cluster1",
},
},
},
},
}
_, err := operatorClient.OperatorV1().ClusterManagers().Create(context.TODO(), clusterManager, metav1.CreateOptions{})
Expect(err).To(BeNil())
})
})

var _ = Describe("ClusterManager API test with WorkConfiguration", func() {
Expand Down
Loading