Skip to content

Commit

Permalink
BoolOrString pollutes marshalling, does not respect omitempty (#566)
Browse files Browse the repository at this point in the history
* BoolOrString pollutes marshalling, does not respect omitempty

* fix panic
  • Loading branch information
emosbaugh committed May 5, 2022
1 parent e6e9df1 commit 2c9a37a
Show file tree
Hide file tree
Showing 14 changed files with 313 additions and 202 deletions.
6 changes: 5 additions & 1 deletion pkg/analyze/analyzer.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,11 @@ type AnalyzeResult struct {
type getCollectedFileContents func(string) ([]byte, error)
type getChildCollectedFileContents func(string) (map[string][]byte, error)

func isExcluded(excludeVal multitype.BoolOrString) (bool, error) {
func isExcluded(excludeVal *multitype.BoolOrString) (bool, error) {
if excludeVal == nil {
return false, nil
}

if excludeVal.Type == multitype.Bool {
return excludeVal.BoolVal, nil
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/apis/troubleshoot/v1beta1/analyzer_shared.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,8 @@ type DatabaseAnalyze struct {
}

type AnalyzeMeta struct {
CheckName string `json:"checkName,omitempty" yaml:"checkName,omitempty"`
Exclude multitype.BoolOrString `json:"exclude,omitempty" yaml:"exclude,omitempty"`
CheckName string `json:"checkName,omitempty" yaml:"checkName,omitempty"`
Exclude *multitype.BoolOrString `json:"exclude,omitempty" yaml:"exclude,omitempty"`
}

type Analyze struct {
Expand Down
2 changes: 1 addition & 1 deletion pkg/apis/troubleshoot/v1beta1/collector_shared.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
type CollectorMeta struct {
CollectorName string `json:"collectorName,omitempty" yaml:"collectorName,omitempty"`
// +optional
Exclude multitype.BoolOrString `json:"exclude,omitempty" yaml:"exclude,omitempty"`
Exclude *multitype.BoolOrString `json:"exclude,omitempty" yaml:"exclude,omitempty"`
}

type ClusterInfo struct {
Expand Down
73 changes: 41 additions & 32 deletions pkg/apis/troubleshoot/v1beta1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions pkg/apis/troubleshoot/v1beta2/analyzer_shared.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,9 @@ type SysctlAnalyze struct {
}

type AnalyzeMeta struct {
CheckName string `json:"checkName,omitempty" yaml:"checkName,omitempty"`
Exclude multitype.BoolOrString `json:"exclude,omitempty" yaml:"exclude,omitempty"`
Strict multitype.BoolOrString `json:"strict,omitempty" yaml:"strict,omitempty"`
CheckName string `json:"checkName,omitempty" yaml:"checkName,omitempty"`
Exclude *multitype.BoolOrString `json:"exclude,omitempty" yaml:"exclude,omitempty"`
Strict *multitype.BoolOrString `json:"strict,omitempty" yaml:"strict,omitempty"`
}

type Analyze struct {
Expand Down
2 changes: 1 addition & 1 deletion pkg/apis/troubleshoot/v1beta2/collector_shared.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
type CollectorMeta struct {
CollectorName string `json:"collectorName,omitempty" yaml:"collectorName,omitempty"`
// +optional
Exclude multitype.BoolOrString `json:"exclude,omitempty" yaml:"exclude,omitempty"`
Exclude *multitype.BoolOrString `json:"exclude,omitempty" yaml:"exclude,omitempty"`
}

type ClusterInfo struct {
Expand Down
2 changes: 1 addition & 1 deletion pkg/apis/troubleshoot/v1beta2/hostcollector_shared.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
type HostCollectorMeta struct {
CollectorName string `json:"collectorName,omitempty" yaml:"collectorName,omitempty"`
// +optional
Exclude multitype.BoolOrString `json:"exclude,omitempty" yaml:"exclude,omitempty"`
Exclude *multitype.BoolOrString `json:"exclude,omitempty" yaml:"exclude,omitempty"`
}

type CPU struct {
Expand Down
2 changes: 1 addition & 1 deletion pkg/apis/troubleshoot/v1beta2/remote_collector_shared.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
type RemoteCollectorMeta struct {
CollectorName string `json:"collectorName,omitempty" yaml:"collectorName,omitempty"`
// +optional
Exclude multitype.BoolOrString `json:"exclude,omitempty" yaml:"exclude,omitempty"`
Exclude *multitype.BoolOrString `json:"exclude,omitempty" yaml:"exclude,omitempty"`
}

type RemoteCPU struct {
Expand Down

0 comments on commit 2c9a37a

Please sign in to comment.