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

fix: application/v1alpha1 add json tag omitzero to status field #22233

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

wmcnamee-coreweave
Copy link

omitzero was introduced in go 1.24 as a way to allow non-pointer structs to not be marshalled when that struct has a "zero" value this solves the problem that when using ArgoCD as a library, marshalling Applications to json do not include the status field, which would otherwise have to be ignored (if using the app of apps pattern)

https://pkg.go.dev/encoding/json#Marshal

Checklist:

  • Either (a) I've created an enhancement proposal and discussed it with the community, (b) this is a bug fix, or (c) this does not need to be in the release notes.
  • The title of the PR states what changed and the related issues number (used for the release note).
  • The title of the PR conforms to the Toolchain Guide
  • I've included "Closes [ISSUE #]" or "Fixes [ISSUE #]" in the description to automatically close the associated issue.
  • I've updated both the CLI and UI to expose my feature, or I plan to submit a second PR with them.
  • Does this PR require documentation updates?
  • I've updated documentation as required by this PR.
  • I have signed off all my commits as required by DCO
  • I have written unit and/or e2e tests for my change. PRs without these are unlikely to be merged.
  • My build is green (troubleshooting builds).
  • My new feature complies with the feature status guidelines.
  • I have added a brief description of why this PR is necessary and/or what this PR solves.
  • Optional. My organization is added to USERS.md.
  • Optional. For bug fixes, I've indicated what older releases this fix should be cherry-picked into (this may or may not happen depending on risk/complexity).

@wmcnamee-coreweave wmcnamee-coreweave requested a review from a team as a code owner March 6, 2025 23:23
Copy link

bunnyshell bot commented Mar 6, 2025

✅ Preview Environment deployed on Bunnyshell

Component Endpoints
argocd https://argocd-aijucx.bunnyenv.com/
argocd-ttyd https://argocd-web-cli-aijucx.bunnyenv.com/

See: Environment Details | Pipeline Logs

Available commands (reply to this comment):

  • 🔴 /bns:stop to stop the environment
  • 🚀 /bns:deploy to redeploy the environment
  • /bns:delete to remove the environment

omitzero was introduced in go 1.24 as a way to allow non-pointer structs to not be marshalled when that struct has a "zero" value
this solves the problem that when using ArgoCD as a library, marshalling Applications to json do not include the status field, which would otherwise have to be ignored (if using the app of apps pattern)

https://pkg.go.dev/encoding/json#Marshal
Signed-off-by: Wes McNamee <[email protected]>
@wmcnamee-coreweave wmcnamee-coreweave force-pushed the fix/add-omitzero-for-status branch from 8df029e to 6cd2af6 Compare March 6, 2025 23:26
@@ -56,7 +56,7 @@ type Application struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata" protobuf:"bytes,1,opt,name=metadata"`
Spec ApplicationSpec `json:"spec" protobuf:"bytes,2,opt,name=spec"`
Status ApplicationStatus `json:"status,omitempty" protobuf:"bytes,3,opt,name=status"`
Status ApplicationStatus `json:"status,omitempty,omitzero" protobuf:"bytes,3,opt,name=status"`
Copy link
Contributor

Choose a reason for hiding this comment

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

This syntax isn't still valid since the Go version that Argo CD uses is Go.123.x

Copy link
Member

Choose a reason for hiding this comment

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

You are correct @sivchari, this PR would also need a bump to 1.24 (or create a PR upgrading Golang to 1.24)

Copy link
Contributor

@sivchari sivchari Mar 7, 2025

Choose a reason for hiding this comment

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

@blakepettersson
Originally, I'm trying to upgrade to Go1.23.6 to avoid vulnerability in
#21929

But it seems like a good to upgrade to latest version.
So I do it by opening other PR and above one will be closed.

Copy link
Contributor

Choose a reason for hiding this comment

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

When #22242 is merged, this PR will pass.

@@ -1517,7 +1517,7 @@ type ComparedTo struct {
// SyncStatus contains information about the currently observed live and desired states of an application
type SyncStatus struct {
// Status is the sync state of the comparison
Status SyncStatusCode `json:"status" protobuf:"bytes,1,opt,name=status,casttype=SyncStatusCode"`
Status SyncStatusCode `json:"status,omitempty" protobuf:"bytes,1,opt,name=status,casttype=SyncStatusCode"`
Copy link
Contributor

Choose a reason for hiding this comment

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

You need to update manifets.
Maybe, there is the reason why the e2e are failed.

@sivchari sivchari mentioned this pull request Mar 7, 2025
14 tasks
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.

3 participants