-
Notifications
You must be signed in to change notification settings - Fork 448
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
Fixing the cluster spec output formatting issue #724
Conversation
@viggy28 Thanks for your PR! Can you rework the commit message and description with something more descriptive like:
|
Hi @sgotti, thanks for looking. Updated it. |
@viggy28 Thinking and testing this PR I noticed that it will break the One possible solution will require the creation (in stolonctl_spec.go), of two different cluster spec structs (identical to the original cluster spec, one with all json tags with omitempty and one without omitempty) that could be converted from the original clusterspec so their marshalling will work for both cases (this will also help detecting when we forgot to add new fields to all the structs at compilation time). |
Thanks @sgotti. Updated the PR. Let me know if that works. |
@@ -290,6 +290,86 @@ type ClusterSpec struct { | |||
AutomaticPgRestart *bool `json:"automaticPgRestart"` | |||
} | |||
|
|||
type ClusterSpecNew struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's the need of two different cluster spec structs identical to the original cluster spec:
- one with all json tags with omitempty for normal output
- one with all json tags without omitempty for --default output
internal/cluster/cluster.go
Outdated
@@ -290,6 +290,86 @@ type ClusterSpec struct { | |||
AutomaticPgRestart *bool `json:"automaticPgRestart"` | |||
} | |||
|
|||
type ClusterSpecNew struct { | |||
// Interval to wait before next check |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just remove all the fields comments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated.
make the clusterspec struct fields tagged as json `omitempty` so they will be omitted when null marshaled. This won't have any side effect on clusterdata writing but will make stolonctl don't show them.
@viggy28 Sorry if I wasn't clear but I meant to use two new structs inside stolonctl/cmd/spec.go, take a look at this compare: |
To address #723.