Skip to content

Commit 2c9a37a

Browse files
authored
BoolOrString pollutes marshalling, does not respect omitempty (#566)
* BoolOrString pollutes marshalling, does not respect omitempty * fix panic
1 parent e6e9df1 commit 2c9a37a

File tree

14 files changed

+313
-202
lines changed

14 files changed

+313
-202
lines changed

pkg/analyze/analyzer.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,11 @@ type AnalyzeResult struct {
2828
type getCollectedFileContents func(string) ([]byte, error)
2929
type getChildCollectedFileContents func(string) (map[string][]byte, error)
3030

31-
func isExcluded(excludeVal multitype.BoolOrString) (bool, error) {
31+
func isExcluded(excludeVal *multitype.BoolOrString) (bool, error) {
32+
if excludeVal == nil {
33+
return false, nil
34+
}
35+
3236
if excludeVal.Type == multitype.Bool {
3337
return excludeVal.BoolVal, nil
3438
}

pkg/apis/troubleshoot/v1beta1/analyzer_shared.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,8 @@ type DatabaseAnalyze struct {
116116
}
117117

118118
type AnalyzeMeta struct {
119-
CheckName string `json:"checkName,omitempty" yaml:"checkName,omitempty"`
120-
Exclude multitype.BoolOrString `json:"exclude,omitempty" yaml:"exclude,omitempty"`
119+
CheckName string `json:"checkName,omitempty" yaml:"checkName,omitempty"`
120+
Exclude *multitype.BoolOrString `json:"exclude,omitempty" yaml:"exclude,omitempty"`
121121
}
122122

123123
type Analyze struct {

pkg/apis/troubleshoot/v1beta1/collector_shared.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import (
1111
type CollectorMeta struct {
1212
CollectorName string `json:"collectorName,omitempty" yaml:"collectorName,omitempty"`
1313
// +optional
14-
Exclude multitype.BoolOrString `json:"exclude,omitempty" yaml:"exclude,omitempty"`
14+
Exclude *multitype.BoolOrString `json:"exclude,omitempty" yaml:"exclude,omitempty"`
1515
}
1616

1717
type ClusterInfo struct {

pkg/apis/troubleshoot/v1beta1/zz_generated.deepcopy.go

Lines changed: 41 additions & 32 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/apis/troubleshoot/v1beta2/analyzer_shared.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -175,9 +175,9 @@ type SysctlAnalyze struct {
175175
}
176176

177177
type AnalyzeMeta struct {
178-
CheckName string `json:"checkName,omitempty" yaml:"checkName,omitempty"`
179-
Exclude multitype.BoolOrString `json:"exclude,omitempty" yaml:"exclude,omitempty"`
180-
Strict multitype.BoolOrString `json:"strict,omitempty" yaml:"strict,omitempty"`
178+
CheckName string `json:"checkName,omitempty" yaml:"checkName,omitempty"`
179+
Exclude *multitype.BoolOrString `json:"exclude,omitempty" yaml:"exclude,omitempty"`
180+
Strict *multitype.BoolOrString `json:"strict,omitempty" yaml:"strict,omitempty"`
181181
}
182182

183183
type Analyze struct {

pkg/apis/troubleshoot/v1beta2/collector_shared.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212
type CollectorMeta struct {
1313
CollectorName string `json:"collectorName,omitempty" yaml:"collectorName,omitempty"`
1414
// +optional
15-
Exclude multitype.BoolOrString `json:"exclude,omitempty" yaml:"exclude,omitempty"`
15+
Exclude *multitype.BoolOrString `json:"exclude,omitempty" yaml:"exclude,omitempty"`
1616
}
1717

1818
type ClusterInfo struct {

pkg/apis/troubleshoot/v1beta2/hostcollector_shared.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
type HostCollectorMeta struct {
88
CollectorName string `json:"collectorName,omitempty" yaml:"collectorName,omitempty"`
99
// +optional
10-
Exclude multitype.BoolOrString `json:"exclude,omitempty" yaml:"exclude,omitempty"`
10+
Exclude *multitype.BoolOrString `json:"exclude,omitempty" yaml:"exclude,omitempty"`
1111
}
1212

1313
type CPU struct {

pkg/apis/troubleshoot/v1beta2/remote_collector_shared.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
type RemoteCollectorMeta struct {
1111
CollectorName string `json:"collectorName,omitempty" yaml:"collectorName,omitempty"`
1212
// +optional
13-
Exclude multitype.BoolOrString `json:"exclude,omitempty" yaml:"exclude,omitempty"`
13+
Exclude *multitype.BoolOrString `json:"exclude,omitempty" yaml:"exclude,omitempty"`
1414
}
1515

1616
type RemoteCPU struct {

0 commit comments

Comments
 (0)