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

Validate that CR name is 'cluster' #17

Merged
merged 4 commits into from
May 31, 2023
Merged

Validate that CR name is 'cluster' #17

merged 4 commits into from
May 31, 2023

Conversation

loganmc10
Copy link
Contributor

@loganmc10 loganmc10 commented May 30, 2023

Fixes #16

This adds a validateCR function which checks that the CR name is cluster. It updates the Ready condition of the CR based on whether this validation succeeded or not.

The validateCR could be expanded in the future to add other validations.

Example of success:

apiVersion: rhsyseng.github.io/v1beta1
kind: ClusterRelocation
metadata:
  annotations:
    kubectl.kubernetes.io/last-applied-configuration: |
      {"apiVersion":"rhsyseng.github.io/v1beta1","kind":"ClusterRelocation","metadata":{"annotations":{},"name":"cluster"},"spec":{"domain":"hello.com"}}
  creationTimestamp: "2023-05-30T18:10:55Z"
  generation: 1
  name: cluster
  resourceVersion: "423570"
  uid: 4bd05411-e61f-404e-818c-ad6b0e689bf3
spec:
  domain: hello.com
status:
  conditions:
  - lastTransitionTime: "2023-05-30T18:10:57Z"
    message: ""
    observedGeneration: 1
    reason: ValidationSucceeded
    status: "True"
    type: Ready

Example of failure:

apiVersion: rhsyseng.github.io/v1beta1
kind: ClusterRelocation
metadata:
  annotations:
    kubectl.kubernetes.io/last-applied-configuration: |
      {"apiVersion":"rhsyseng.github.io/v1beta1","kind":"ClusterRelocation","metadata":{"annotations":{},"name":"testname"},"spec":{"domain":"hello.com"}}
  creationTimestamp: "2023-05-30T18:11:16Z"
  generation: 1
  name: testname
  resourceVersion: "423689"
  uid: d2389bf5-f377-4df1-a148-9a6d023b24e8
spec:
  domain: hello.com
status:
  conditions:
  - lastTransitionTime: "2023-05-30T18:11:19Z"
    message: 'invalid name: testname. CR name must be: cluster'
    observedGeneration: 1
    reason: ValidationFailed
    status: "False"
    type: Ready

@loganmc10 loganmc10 requested a review from danielchg May 30, 2023 18:07
@loganmc10 loganmc10 self-assigned this May 30, 2023
@danielchg danielchg merged commit a6d6290 into main May 31, 2023
@danielchg danielchg deleted the cluster branch May 31, 2023 13:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Ensure that only 1 copy of the CR exists
2 participants