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

Remove useless omitempty #402

Merged
merged 6 commits into from
Jun 29, 2022

Conversation

jiangpengcheng
Copy link
Member

Fixes #383

Motivation

Remove omitempty if it's required

Modifications

Verifying this change

  • Make sure that the change passes the CI checks.

This change is a trivial rework / code cleanup without any test coverage.

Documentation

Check the box below.

Need to update docs?

  • doc-required

    (If you need help on updating docs, create a doc issue)

  • no-need-doc

    tiny fix

  • doc

    (If this PR contains doc changes)

@github-actions github-actions bot added the no-need-doc This pr does not need any document label Jun 21, 2022
@jiangpengcheng
Copy link
Member Author

jiangpengcheng commented Jun 21, 2022

it looks like only when // +kubebuilder:validation:Required is specified and no omitempty is added, the field would be marked as required

refers:

  1. +kubebuilder:validation:Required take precedence over omitempty kubernetes-sigs/controller-tools#642
  2. +kubebuilder:validation:Required marker not working kubernetes-sigs/controller-tools#599

@@ -30,15 +30,14 @@ import (
type FunctionSpec struct {
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
// Important: Run "make" to regenerate code after modifying this file
// +kubebuilder:validation:Required
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think spec.name is not required

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for Function CRD it should be non-required since it is duplicated with .metadata.name, but for Mesh CRD, which reuses FunctionSpec and uses the .spec.name in Mesh controller as well.

@freeznet freeznet added type/enhancement Indicates an improvement to an existing feature m/2022-07 labels Jun 23, 2022
Copy link
Contributor

@tpiperatgod tpiperatgod left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@jiangpengcheng
Copy link
Member Author

seems need to update the CRD content in charts/

@tpiperatgod
Copy link
Contributor

seems need to update the CRD content in charts/

we may then need a function to generate them automatically 🤣

@freeznet
Copy link
Member

freeznet commented Jun 23, 2022

we may then need a function to generate them automatically 🤣

@tpiperatgod Seems we need to change helm-crds in Makefile as well.

@freeznet freeznet requested a review from a team as a code owner June 24, 2022 12:50
@jiangpengcheng
Copy link
Member Author

since #409 is merged, do we need to update the generated YAML in this PR and also other PRs which make changes to the CRD content?
@freeznet @tpiperatgod HDYT?

@freeznet
Copy link
Member

@jiangpengcheng yes, please update the CRDs with this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
m/2022-07 no-need-doc This pr does not need any document type/enhancement Indicates an improvement to an existing feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

cleanup omitempty for required fields
3 participants