Skip to content

Conversation

@BlaineEXE
Copy link
Contributor

@BlaineEXE BlaineEXE commented Dec 9, 2025

Add kube-api-linter to make lint.

kube-api-linter is based on golangci-lint v2, so it is upgraded to the latest version.

kube-api-linter could be integrated with COSI CI in many ways. After experimentation, it is fastest to run it as a standalone install rather than build it each time make lint is run.

Related to API review #199

Resolves #195

@k8s-ci-robot
Copy link
Contributor

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@k8s-ci-robot k8s-ci-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Dec 9, 2025
@netlify
Copy link

netlify bot commented Dec 9, 2025

Deploy Preview for container-object-storage-interface ready!

Name Link
🔨 Latest commit 67f5f31
🔍 Latest deploy log https://app.netlify.com/projects/container-object-storage-interface/deploys/693b43ed0ffe5a000899b108
😎 Deploy Preview https://deploy-preview-201--container-object-storage-interface.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@k8s-ci-robot k8s-ci-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Dec 9, 2025
Comment on lines 159 to +163
// status defines the observed state of Bucket
// +optional
Status BucketStatus `json:"status,omitempty,omitzero"`
Status BucketStatus `json:"status,omitzero"`
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@JoelSpeed I'm having some challenges coming up with the best action to take based KAL's response on the status here. Do you have a recommended pattern for validations to apply here to avoid a pointer status and allow KAL to pass?

apis/objectstorage/v1alpha2/bucket_types.go:163:2: optionalfields: field Bucket.Status has a valid zero value ({}), but the validation is not complete (e.g. min properties/adding required fields). The field should be a pointer to allow the zero value to be set. If the zero value is not a valid use case, complete the validation and remove the pointer. (kubeapilinter)
        Status BucketStatus `json:"status,omitzero"`
        ^

Choose a reason for hiding this comment

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

KAL will only suggest this to be a pointer if your validations allow {} to be persisted. That means your validations imply a semantic difference between omitted and the empty struct. That's not desirable in 99% of cases.

The solution is to make {} invalid. That can be done by adding a required field to status (this is probably the right path, which fields should the status always have?) or to add a +kubebuilder:validation:MinProperties=1 marker to make sure at least one property is set.

My advice would be to add a required field.

optionalfields: field Bucket.Status has a valid zero value ({}), but the validation is not complete (e.g. min properties/adding required fields). The field should be a pointer to allow the zero value to be set. If the zero value is not a valid use case, complete the validation and remove the pointer.

I think I'm just repeating the error message here no? 😅

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think I finally got my head around this. Thanks for your patience. For now, I made ReadyToUse required, and I realized I needed to configure KAL slightly for CRDs.

@k8s-ci-robot k8s-ci-robot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Dec 9, 2025
@BlaineEXE
Copy link
Contributor Author

/ok-to-test

@k8s-ci-robot k8s-ci-robot added the ok-to-test Indicates a non-member PR verified by an org member that is safe to test. label Dec 9, 2025
@BlaineEXE
Copy link
Contributor Author

/ok-to-test

Add kube-api-linter to `make lint`.

kube-api-linter is based on golangci-lint v2, so it is upgraded to the
latest version.

kube-api-linter could be integrated with COSI CI in many ways. After
experimentation, it is fastest to run it as a standalone install rather
than build it each time `make lint` is run.

Signed-off-by: Blaine Gardner <[email protected]>
@BlaineEXE BlaineEXE marked this pull request as ready for review December 11, 2025 22:21
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Dec 11, 2025
Comment on lines +15 to +23
settings:
linters:
enable:
- statussubresource
- optionalfields # instead of nonpointerstructs
- requiredfields # instead of nonpointerstructs
disable:
- nonpointerstructs # not intended for CRDs
- statusoptional
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@JoelSpeed do these linters make sense for our CRD-based project? I am not 100 certain about statusoptional, but I presume this to be reasonable based on your suggestion to make a status field required.

The others are documented well regarding CRD usage.

Choose a reason for hiding this comment

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

I would avoid statusoptional personally. It's a preference for some (historically all status fields were optional) but I've discussed this with other API reviewers and I think that's a legacy pattern that we don't need to repeat

@xing-yang
Copy link
Contributor

/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Dec 12, 2025
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: BlaineEXE, xing-yang

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:
  • OWNERS [BlaineEXE,xing-yang]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot merged commit f3bf0f5 into kubernetes-sigs:main Dec 12, 2025
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Incorporate Kube API linter into CI

4 participants