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

added validations with kubebuilder's markers #26

Merged

Conversation

itamar-marom
Copy link
Collaborator

@itamar-marom itamar-marom commented Mar 11, 2023

Fixes #25

Description

Kubebuilder supports object validation markers. Instead of validating the object inside the reconcile function (in the verifyDruidSpec function, we should let Kubebuilder do it.

For every required field we're adding the // +required marker.
For example, nodeType that now looks like this:

// Druid node type
// +required
// +kubebuilder:validation:Enum:=historical;overlord;middleManager;indexer;broker;coordinator;router
NodeType string `json:"nodeType"`

will return:

The Druid "tiny-cluster" is invalid: spec.nodes.brokers.nodeType: Required value If not specified.
The Druid "tiny-cluster" is invalid: spec.nodes.brokers.nodeType: Unsupported value: "brokerr": supported values: "historical", "overlord", "middleManager", "indexer", "broker", "coordinator", "router" If using unsupported value.


This PR has:

  • been tested on a real K8S cluster to ensure creation of a brand new Druid cluster works.
  • been tested for backward compatibility on a real K*S cluster by applying the changes introduced here on an existing Druid cluster. If there are any backward incompatible changes then they have been noted in the PR description.
  • added comments explaining the "why" and the intent of the code wherever would not be obvious for an unfamiliar reader.
  • added documentation for new or modified features or behaviors.

Key changed/added files in this PR

@AdheipSingh
Copy link
Contributor

Thank You @itamar-marom

@AdheipSingh AdheipSingh merged commit 59061da into datainfrahq:master Mar 11, 2023
@itamar-marom itamar-marom deleted the feature/markers-object-valdiation branch March 11, 2023 14:24
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.

Using Kubebuilder markers for object validation
2 participants