From 63362d32eefac19c2a09f6a8d75428c51aa25d4f Mon Sep 17 00:00:00 2001 From: Jalaja Ganapathy Date: Mon, 2 May 2022 09:51:49 -0700 Subject: [PATCH 1/4] Include osd disk usage (#563) * Include osd disk usage * add timeouts to ceph commands * removed df, collect from host --- pkg/collect/ceph.go | 88 ++++++++++++++++++++++++++------------------- 1 file changed, 52 insertions(+), 36 deletions(-) diff --git a/pkg/collect/ceph.go b/pkg/collect/ceph.go index 1d0dbfafb..6f823d4ad 100644 --- a/pkg/collect/ceph.go +++ b/pkg/collect/ceph.go @@ -27,52 +27,60 @@ type CephCommand struct { var CephCommands = []CephCommand{ { - ID: "status", - Command: []string{"ceph", "status"}, - Args: []string{"-f", "json-pretty"}, - Format: "json", + ID: "status", + Command: []string{"ceph", "status"}, + Args: []string{"-f", "json-pretty"}, + Format: "json", + DefaultTimeout: "30s", }, { - ID: "fs", - Command: []string{"ceph", "fs", "status"}, - Args: []string{"-f", "json-pretty"}, - Format: "json", + ID: "fs", + Command: []string{"ceph", "fs", "status"}, + Args: []string{"-f", "json-pretty"}, + Format: "json", + DefaultTimeout: "30s", }, { - ID: "fs-ls", - Command: []string{"ceph", "fs", "ls"}, - Args: []string{"-f", "json-pretty"}, - Format: "json", + ID: "fs-ls", + Command: []string{"ceph", "fs", "ls"}, + Args: []string{"-f", "json-pretty"}, + Format: "json", + DefaultTimeout: "30s", }, { - ID: "osd-status", - Command: []string{"ceph", "osd", "status"}, - Args: []string{"-f", "json-pretty"}, - Format: "txt", + ID: "osd-status", + Command: []string{"ceph", "osd", "status"}, + Args: []string{"-f", "json-pretty"}, + Format: "txt", + DefaultTimeout: "30s", }, { - ID: "osd-tree", - Command: []string{"ceph", "osd", "tree"}, - Args: []string{"-f", "json-pretty"}, - Format: "json", + ID: "osd-tree", + Command: []string{"ceph", "osd", "tree"}, + Args: []string{"-f", "json-pretty"}, + Format: "json", + DefaultTimeout: "30s", }, { - ID: "osd-pool", - Command: []string{"ceph", "osd", "pool", "ls", "detail"}, - Args: []string{"-f", "json-pretty"}, - Format: "json", + ID: "osd-pool", + Command: []string{"ceph", "osd", "pool", "ls", "detail"}, + Args: []string{"-f", "json-pretty"}, + Format: "json", + DefaultTimeout: "30s", }, { - ID: "health", - Command: []string{"ceph", "health", "detail"}, - Args: []string{"-f", "json-pretty"}, - Format: "json", + ID: "health", + Command: []string{"ceph", "health", "detail"}, + Args: []string{"-f", "json-pretty"}, + Format: "json", + DefaultTimeout: "30s", }, { - ID: "auth", - Command: []string{"ceph", "auth", "ls"}, - Args: []string{"-f", "json-pretty"}, - Format: "json", + ID: "auth", + Command: []string{"ceph", "auth", "ls"}, + Args: []string{"-f", "json-pretty"}, + Format: "json", + DefaultTimeout: "30s", }, { ID: "rgw-stats", // the disk usage (and other stats) of each object store bucket @@ -82,10 +90,18 @@ var CephCommands = []CephCommand{ DefaultTimeout: "30s", // include a default timeout because this command will hang if the RGW daemon isn't running/is unhealthy }, { - ID: "rbd-du", // the disk usage of each PVC - Command: []string{"rbd", "du"}, - Args: []string{"--pool=replicapool"}, - Format: "txt", + ID: "rbd-du", // the disk usage of each PVC + Command: []string{"rbd", "du"}, + Args: []string{"--pool=replicapool"}, + Format: "txt", + DefaultTimeout: "30s", + }, + { + ID: "osd-df", + Command: []string{"ceph", "osd", "df"}, + Args: []string{"-f", "json-pretty"}, + Format: "json", + DefaultTimeout: "30s", }, } From 72891347573434eac6f5c8342e4af8b0563bea95 Mon Sep 17 00:00:00 2001 From: Edgar Ochoa Date: Wed, 4 May 2022 12:42:37 -0500 Subject: [PATCH 2/4] Add Mysql variables to collector (#562) * Add Mysql variables to collector * Cleanup row scanning and a few updates based on feedback * Close db connection * Move defer db.close * Updates based on feedback * Use vars in loop instead of struct * Only pull parameters specified in collector config Co-authored-by: Ethan Mosbaugh --- .../troubleshoot/v1beta2/collector_shared.go | 3 +- pkg/collect/database_shared.go | 7 ++-- pkg/collect/mysql.go | 34 +++++++++++++++++++ 3 files changed, 40 insertions(+), 4 deletions(-) diff --git a/pkg/apis/troubleshoot/v1beta2/collector_shared.go b/pkg/apis/troubleshoot/v1beta2/collector_shared.go index abb258427..c0443f859 100644 --- a/pkg/apis/troubleshoot/v1beta2/collector_shared.go +++ b/pkg/apis/troubleshoot/v1beta2/collector_shared.go @@ -156,7 +156,8 @@ type Put struct { type Database struct { CollectorMeta `json:",inline" yaml:",inline"` - URI string `json:"uri" yaml:"uri"` + URI string `json:"uri" yaml:"uri"` + Parameters []string `json:"parameters,omitempty"` } type Collectd struct { diff --git a/pkg/collect/database_shared.go b/pkg/collect/database_shared.go index 89a94cc30..5a4d0ea44 100644 --- a/pkg/collect/database_shared.go +++ b/pkg/collect/database_shared.go @@ -1,7 +1,8 @@ package collect type DatabaseConnection struct { - IsConnected bool `json:"isConnected"` - Error string `json:"error,omitempty"` - Version string `json:"version,omitempty"` + IsConnected bool `json:"isConnected"` + Error string `json:"error,omitempty"` + Version string `json:"version,omitempty"` + Variables map[string]string `json:"variables,omitempty"` } diff --git a/pkg/collect/mysql.go b/pkg/collect/mysql.go index efd4ae1e3..b5febfc63 100644 --- a/pkg/collect/mysql.go +++ b/pkg/collect/mysql.go @@ -18,8 +18,10 @@ func Mysql(c *Collector, databaseCollector *troubleshootv1beta2.Database) (Colle if err != nil { databaseConnection.Error = err.Error() } else { + defer db.Close() query := `select version()` row := db.QueryRow(query) + version := "" if err := row.Scan(&version); err != nil { databaseConnection.Error = err.Error() @@ -27,6 +29,38 @@ func Mysql(c *Collector, databaseCollector *troubleshootv1beta2.Database) (Colle databaseConnection.IsConnected = true databaseConnection.Version = version } + + requestedParameters := databaseCollector.Parameters + if len(requestedParameters) > 0 { + rows, err := db.Query("SHOW VARIABLES") + + if err != nil { + databaseConnection.Error = err.Error() + } else { + defer rows.Close() + + variables := map[string]string{} + for rows.Next() { + var key, value string + err = rows.Scan(&key, &value) + if err != nil { + databaseConnection.Error = err.Error() + break + } + variables[key] = value + } + filteredVariables := map[string]string{} + + for _, key := range requestedParameters { + if value, ok := variables[key]; ok { + filteredVariables[key] = value + } + + } + databaseConnection.Variables = filteredVariables + } + } + } b, err := json.Marshal(databaseConnection) From 755220cd4cf2be4f6a5c475c96d9be8dae935d4e Mon Sep 17 00:00:00 2001 From: Ethan Mosbaugh Date: Wed, 4 May 2022 17:44:25 +0000 Subject: [PATCH 3/4] Mysql collector example --- examples/support-bundle/mysql-collector.yaml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 examples/support-bundle/mysql-collector.yaml diff --git a/examples/support-bundle/mysql-collector.yaml b/examples/support-bundle/mysql-collector.yaml new file mode 100644 index 000000000..e590878ea --- /dev/null +++ b/examples/support-bundle/mysql-collector.yaml @@ -0,0 +1,17 @@ +apiVersion: troubleshoot.sh/v1beta2 +kind: SupportBundle +metadata: + name: mysql +spec: + collectors: + - mysql: + collectorName: mysql + uri: 'root:my-secret-pw@tcp(localhost:3306)/mysql' + parameters: + - character_set_server + - collation_server + - init_connect + - innodb_file_format + - innodb_large_prefix + - innodb_strict_mode + - log_bin_trust_function_creators From 2c9a37a4f11cc45ffa087bfee8746ce89ff4b544 Mon Sep 17 00:00:00 2001 From: Ethan Mosbaugh Date: Thu, 5 May 2022 16:10:05 -0700 Subject: [PATCH 4/4] BoolOrString pollutes marshalling, does not respect omitempty (#566) * BoolOrString pollutes marshalling, does not respect omitempty * fix panic --- pkg/analyze/analyzer.go | 6 +- .../troubleshoot/v1beta1/analyzer_shared.go | 4 +- .../troubleshoot/v1beta1/collector_shared.go | 2 +- .../v1beta1/zz_generated.deepcopy.go | 73 +++-- .../troubleshoot/v1beta2/analyzer_shared.go | 6 +- .../troubleshoot/v1beta2/collector_shared.go | 2 +- .../v1beta2/hostcollector_shared.go | 2 +- .../v1beta2/remote_collector_shared.go | 2 +- .../v1beta2/zz_generated.deepcopy.go | 298 ++++++++++-------- pkg/collect/collector.go | 6 +- pkg/collect/collector_test.go | 10 +- pkg/multitype/boolstring.go | 32 +- pkg/multitype/boolstring_test.go | 58 ++++ pkg/preflight/util_test.go | 14 +- 14 files changed, 313 insertions(+), 202 deletions(-) diff --git a/pkg/analyze/analyzer.go b/pkg/analyze/analyzer.go index 2b78fa3fb..a992d8706 100644 --- a/pkg/analyze/analyzer.go +++ b/pkg/analyze/analyzer.go @@ -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 } diff --git a/pkg/apis/troubleshoot/v1beta1/analyzer_shared.go b/pkg/apis/troubleshoot/v1beta1/analyzer_shared.go index 913c95bcc..864ddc105 100644 --- a/pkg/apis/troubleshoot/v1beta1/analyzer_shared.go +++ b/pkg/apis/troubleshoot/v1beta1/analyzer_shared.go @@ -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 { diff --git a/pkg/apis/troubleshoot/v1beta1/collector_shared.go b/pkg/apis/troubleshoot/v1beta1/collector_shared.go index 6193303d1..738da9005 100644 --- a/pkg/apis/troubleshoot/v1beta1/collector_shared.go +++ b/pkg/apis/troubleshoot/v1beta1/collector_shared.go @@ -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 { diff --git a/pkg/apis/troubleshoot/v1beta1/zz_generated.deepcopy.go b/pkg/apis/troubleshoot/v1beta1/zz_generated.deepcopy.go index 597135259..2326fb574 100644 --- a/pkg/apis/troubleshoot/v1beta1/zz_generated.deepcopy.go +++ b/pkg/apis/troubleshoot/v1beta1/zz_generated.deepcopy.go @@ -22,6 +22,7 @@ limitations under the License. package v1beta1 import ( + "github.com/replicatedhq/troubleshoot/pkg/multitype" runtime "k8s.io/apimachinery/pkg/runtime" ) @@ -143,7 +144,11 @@ func (in *Analyze) DeepCopy() *Analyze { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *AnalyzeMeta) DeepCopyInto(out *AnalyzeMeta) { *out = *in - out.Exclude = in.Exclude + if in.Exclude != nil { + in, out := &in.Exclude, &out.Exclude + *out = new(multitype.BoolOrString) + **out = **in + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AnalyzeMeta. @@ -159,7 +164,7 @@ func (in *AnalyzeMeta) DeepCopy() *AnalyzeMeta { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *AnalyzeSecret) DeepCopyInto(out *AnalyzeSecret) { *out = *in - out.AnalyzeMeta = in.AnalyzeMeta + in.AnalyzeMeta.DeepCopyInto(&out.AnalyzeMeta) if in.Outcomes != nil { in, out := &in.Outcomes, &out.Outcomes *out = make([]*Outcome, len(*in)) @@ -286,7 +291,7 @@ func (in *AnalyzerStatus) DeepCopy() *AnalyzerStatus { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ClusterInfo) DeepCopyInto(out *ClusterInfo) { *out = *in - out.CollectorMeta = in.CollectorMeta + in.CollectorMeta.DeepCopyInto(&out.CollectorMeta) } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterInfo. @@ -302,7 +307,7 @@ func (in *ClusterInfo) DeepCopy() *ClusterInfo { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ClusterResources) DeepCopyInto(out *ClusterResources) { *out = *in - out.CollectorMeta = in.CollectorMeta + in.CollectorMeta.DeepCopyInto(&out.CollectorMeta) } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterResources. @@ -318,7 +323,7 @@ func (in *ClusterResources) DeepCopy() *ClusterResources { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ClusterVersion) DeepCopyInto(out *ClusterVersion) { *out = *in - out.AnalyzeMeta = in.AnalyzeMeta + in.AnalyzeMeta.DeepCopyInto(&out.AnalyzeMeta) if in.Outcomes != nil { in, out := &in.Outcomes, &out.Outcomes *out = make([]*Outcome, len(*in)) @@ -348,17 +353,17 @@ func (in *Collect) DeepCopyInto(out *Collect) { if in.ClusterInfo != nil { in, out := &in.ClusterInfo, &out.ClusterInfo *out = new(ClusterInfo) - **out = **in + (*in).DeepCopyInto(*out) } if in.ClusterResources != nil { in, out := &in.ClusterResources, &out.ClusterResources *out = new(ClusterResources) - **out = **in + (*in).DeepCopyInto(*out) } if in.Secret != nil { in, out := &in.Secret, &out.Secret *out = new(Secret) - **out = **in + (*in).DeepCopyInto(*out) } if in.Logs != nil { in, out := &in.Logs, &out.Logs @@ -378,7 +383,7 @@ func (in *Collect) DeepCopyInto(out *Collect) { if in.Data != nil { in, out := &in.Data, &out.Data *out = new(Data) - **out = **in + (*in).DeepCopyInto(*out) } if in.Copy != nil { in, out := &in.Copy, &out.Copy @@ -393,17 +398,17 @@ func (in *Collect) DeepCopyInto(out *Collect) { if in.Postgres != nil { in, out := &in.Postgres, &out.Postgres *out = new(Database) - **out = **in + (*in).DeepCopyInto(*out) } if in.Mysql != nil { in, out := &in.Mysql, &out.Mysql *out = new(Database) - **out = **in + (*in).DeepCopyInto(*out) } if in.Redis != nil { in, out := &in.Redis, &out.Redis *out = new(Database) - **out = **in + (*in).DeepCopyInto(*out) } } @@ -479,7 +484,11 @@ func (in *CollectorList) DeepCopyObject() runtime.Object { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *CollectorMeta) DeepCopyInto(out *CollectorMeta) { *out = *in - out.Exclude = in.Exclude + if in.Exclude != nil { + in, out := &in.Exclude, &out.Exclude + *out = new(multitype.BoolOrString) + **out = **in + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CollectorMeta. @@ -547,7 +556,7 @@ func (in *CollectorStatus) DeepCopy() *CollectorStatus { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ContainerRuntime) DeepCopyInto(out *ContainerRuntime) { *out = *in - out.AnalyzeMeta = in.AnalyzeMeta + in.AnalyzeMeta.DeepCopyInto(&out.AnalyzeMeta) if in.Outcomes != nil { in, out := &in.Outcomes, &out.Outcomes *out = make([]*Outcome, len(*in)) @@ -574,7 +583,7 @@ func (in *ContainerRuntime) DeepCopy() *ContainerRuntime { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *Copy) DeepCopyInto(out *Copy) { *out = *in - out.CollectorMeta = in.CollectorMeta + in.CollectorMeta.DeepCopyInto(&out.CollectorMeta) if in.Selector != nil { in, out := &in.Selector, &out.Selector *out = make([]string, len(*in)) @@ -595,7 +604,7 @@ func (in *Copy) DeepCopy() *Copy { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *CustomResourceDefinition) DeepCopyInto(out *CustomResourceDefinition) { *out = *in - out.AnalyzeMeta = in.AnalyzeMeta + in.AnalyzeMeta.DeepCopyInto(&out.AnalyzeMeta) if in.Outcomes != nil { in, out := &in.Outcomes, &out.Outcomes *out = make([]*Outcome, len(*in)) @@ -622,7 +631,7 @@ func (in *CustomResourceDefinition) DeepCopy() *CustomResourceDefinition { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *Data) DeepCopyInto(out *Data) { *out = *in - out.CollectorMeta = in.CollectorMeta + in.CollectorMeta.DeepCopyInto(&out.CollectorMeta) } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Data. @@ -638,7 +647,7 @@ func (in *Data) DeepCopy() *Data { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *Database) DeepCopyInto(out *Database) { *out = *in - out.CollectorMeta = in.CollectorMeta + in.CollectorMeta.DeepCopyInto(&out.CollectorMeta) } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Database. @@ -654,7 +663,7 @@ func (in *Database) DeepCopy() *Database { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *DatabaseAnalyze) DeepCopyInto(out *DatabaseAnalyze) { *out = *in - out.AnalyzeMeta = in.AnalyzeMeta + in.AnalyzeMeta.DeepCopyInto(&out.AnalyzeMeta) if in.Outcomes != nil { in, out := &in.Outcomes, &out.Outcomes *out = make([]*Outcome, len(*in)) @@ -681,7 +690,7 @@ func (in *DatabaseAnalyze) DeepCopy() *DatabaseAnalyze { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *DeploymentStatus) DeepCopyInto(out *DeploymentStatus) { *out = *in - out.AnalyzeMeta = in.AnalyzeMeta + in.AnalyzeMeta.DeepCopyInto(&out.AnalyzeMeta) if in.Outcomes != nil { in, out := &in.Outcomes, &out.Outcomes *out = make([]*Outcome, len(*in)) @@ -708,7 +717,7 @@ func (in *DeploymentStatus) DeepCopy() *DeploymentStatus { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *Distribution) DeepCopyInto(out *Distribution) { *out = *in - out.AnalyzeMeta = in.AnalyzeMeta + in.AnalyzeMeta.DeepCopyInto(&out.AnalyzeMeta) if in.Outcomes != nil { in, out := &in.Outcomes, &out.Outcomes *out = make([]*Outcome, len(*in)) @@ -735,7 +744,7 @@ func (in *Distribution) DeepCopy() *Distribution { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *Exec) DeepCopyInto(out *Exec) { *out = *in - out.CollectorMeta = in.CollectorMeta + in.CollectorMeta.DeepCopyInto(&out.CollectorMeta) if in.Selector != nil { in, out := &in.Selector, &out.Selector *out = make([]string, len(*in)) @@ -808,7 +817,7 @@ func (in *Get) DeepCopy() *Get { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *HTTP) DeepCopyInto(out *HTTP) { *out = *in - out.CollectorMeta = in.CollectorMeta + in.CollectorMeta.DeepCopyInto(&out.CollectorMeta) if in.Get != nil { in, out := &in.Get, &out.Get *out = new(Get) @@ -839,7 +848,7 @@ func (in *HTTP) DeepCopy() *HTTP { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ImagePullSecret) DeepCopyInto(out *ImagePullSecret) { *out = *in - out.AnalyzeMeta = in.AnalyzeMeta + in.AnalyzeMeta.DeepCopyInto(&out.AnalyzeMeta) if in.Outcomes != nil { in, out := &in.Outcomes, &out.Outcomes *out = make([]*Outcome, len(*in)) @@ -888,7 +897,7 @@ func (in *ImagePullSecrets) DeepCopy() *ImagePullSecrets { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *Ingress) DeepCopyInto(out *Ingress) { *out = *in - out.AnalyzeMeta = in.AnalyzeMeta + in.AnalyzeMeta.DeepCopyInto(&out.AnalyzeMeta) if in.Outcomes != nil { in, out := &in.Outcomes, &out.Outcomes *out = make([]*Outcome, len(*in)) @@ -930,7 +939,7 @@ func (in *LogLimits) DeepCopy() *LogLimits { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *Logs) DeepCopyInto(out *Logs) { *out = *in - out.CollectorMeta = in.CollectorMeta + in.CollectorMeta.DeepCopyInto(&out.CollectorMeta) if in.Selector != nil { in, out := &in.Selector, &out.Selector *out = make([]string, len(*in)) @@ -1003,7 +1012,7 @@ func (in *NodeResourceSelectors) DeepCopy() *NodeResourceSelectors { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *NodeResources) DeepCopyInto(out *NodeResources) { *out = *in - out.AnalyzeMeta = in.AnalyzeMeta + in.AnalyzeMeta.DeepCopyInto(&out.AnalyzeMeta) if in.Outcomes != nil { in, out := &in.Outcomes, &out.Outcomes *out = make([]*Outcome, len(*in)) @@ -1397,7 +1406,7 @@ func (in *ResultRequest) DeepCopy() *ResultRequest { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *Run) DeepCopyInto(out *Run) { *out = *in - out.CollectorMeta = in.CollectorMeta + in.CollectorMeta.DeepCopyInto(&out.CollectorMeta) if in.Command != nil { in, out := &in.Command, &out.Command *out = make([]string, len(*in)) @@ -1428,7 +1437,7 @@ func (in *Run) DeepCopy() *Run { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *Secret) DeepCopyInto(out *Secret) { *out = *in - out.CollectorMeta = in.CollectorMeta + in.CollectorMeta.DeepCopyInto(&out.CollectorMeta) } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Secret. @@ -1459,7 +1468,7 @@ func (in *SingleOutcome) DeepCopy() *SingleOutcome { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *StatefulsetStatus) DeepCopyInto(out *StatefulsetStatus) { *out = *in - out.AnalyzeMeta = in.AnalyzeMeta + in.AnalyzeMeta.DeepCopyInto(&out.AnalyzeMeta) if in.Outcomes != nil { in, out := &in.Outcomes, &out.Outcomes *out = make([]*Outcome, len(*in)) @@ -1486,7 +1495,7 @@ func (in *StatefulsetStatus) DeepCopy() *StatefulsetStatus { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *StorageClass) DeepCopyInto(out *StorageClass) { *out = *in - out.AnalyzeMeta = in.AnalyzeMeta + in.AnalyzeMeta.DeepCopyInto(&out.AnalyzeMeta) if in.Outcomes != nil { in, out := &in.Outcomes, &out.Outcomes *out = make([]*Outcome, len(*in)) @@ -1666,7 +1675,7 @@ func (in *SupportBundleVersionSpec) DeepCopy() *SupportBundleVersionSpec { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *TextAnalyze) DeepCopyInto(out *TextAnalyze) { *out = *in - out.AnalyzeMeta = in.AnalyzeMeta + in.AnalyzeMeta.DeepCopyInto(&out.AnalyzeMeta) if in.Outcomes != nil { in, out := &in.Outcomes, &out.Outcomes *out = make([]*Outcome, len(*in)) diff --git a/pkg/apis/troubleshoot/v1beta2/analyzer_shared.go b/pkg/apis/troubleshoot/v1beta2/analyzer_shared.go index 844c27dbd..e68ae1af2 100644 --- a/pkg/apis/troubleshoot/v1beta2/analyzer_shared.go +++ b/pkg/apis/troubleshoot/v1beta2/analyzer_shared.go @@ -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 { diff --git a/pkg/apis/troubleshoot/v1beta2/collector_shared.go b/pkg/apis/troubleshoot/v1beta2/collector_shared.go index c0443f859..e3c1398d0 100644 --- a/pkg/apis/troubleshoot/v1beta2/collector_shared.go +++ b/pkg/apis/troubleshoot/v1beta2/collector_shared.go @@ -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 { diff --git a/pkg/apis/troubleshoot/v1beta2/hostcollector_shared.go b/pkg/apis/troubleshoot/v1beta2/hostcollector_shared.go index 60317e281..bb6b2d0e6 100644 --- a/pkg/apis/troubleshoot/v1beta2/hostcollector_shared.go +++ b/pkg/apis/troubleshoot/v1beta2/hostcollector_shared.go @@ -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 { diff --git a/pkg/apis/troubleshoot/v1beta2/remote_collector_shared.go b/pkg/apis/troubleshoot/v1beta2/remote_collector_shared.go index b44494240..0ada95fb5 100644 --- a/pkg/apis/troubleshoot/v1beta2/remote_collector_shared.go +++ b/pkg/apis/troubleshoot/v1beta2/remote_collector_shared.go @@ -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 { diff --git a/pkg/apis/troubleshoot/v1beta2/zz_generated.deepcopy.go b/pkg/apis/troubleshoot/v1beta2/zz_generated.deepcopy.go index d8df308c1..c05172b8d 100644 --- a/pkg/apis/troubleshoot/v1beta2/zz_generated.deepcopy.go +++ b/pkg/apis/troubleshoot/v1beta2/zz_generated.deepcopy.go @@ -22,6 +22,7 @@ limitations under the License. package v1beta2 import ( + "github.com/replicatedhq/troubleshoot/pkg/multitype" runtime "k8s.io/apimachinery/pkg/runtime" ) @@ -166,7 +167,7 @@ func (in *Analyze) DeepCopyInto(out *Analyze) { if in.WeaveReport != nil { in, out := &in.WeaveReport, &out.WeaveReport *out = new(WeaveReportAnalyze) - **out = **in + (*in).DeepCopyInto(*out) } if in.Sysctl != nil { in, out := &in.Sysctl, &out.Sysctl @@ -188,7 +189,7 @@ func (in *Analyze) DeepCopy() *Analyze { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *AnalyzeConfigMap) DeepCopyInto(out *AnalyzeConfigMap) { *out = *in - out.AnalyzeMeta = in.AnalyzeMeta + in.AnalyzeMeta.DeepCopyInto(&out.AnalyzeMeta) if in.Outcomes != nil { in, out := &in.Outcomes, &out.Outcomes *out = make([]*Outcome, len(*in)) @@ -215,8 +216,16 @@ func (in *AnalyzeConfigMap) DeepCopy() *AnalyzeConfigMap { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *AnalyzeMeta) DeepCopyInto(out *AnalyzeMeta) { *out = *in - out.Exclude = in.Exclude - out.Strict = in.Strict + if in.Exclude != nil { + in, out := &in.Exclude, &out.Exclude + *out = new(multitype.BoolOrString) + **out = **in + } + if in.Strict != nil { + in, out := &in.Strict, &out.Strict + *out = new(multitype.BoolOrString) + **out = **in + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AnalyzeMeta. @@ -232,7 +241,7 @@ func (in *AnalyzeMeta) DeepCopy() *AnalyzeMeta { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *AnalyzeSecret) DeepCopyInto(out *AnalyzeSecret) { *out = *in - out.AnalyzeMeta = in.AnalyzeMeta + in.AnalyzeMeta.DeepCopyInto(&out.AnalyzeMeta) if in.Outcomes != nil { in, out := &in.Outcomes, &out.Outcomes *out = make([]*Outcome, len(*in)) @@ -359,7 +368,7 @@ func (in *AnalyzerStatus) DeepCopy() *AnalyzerStatus { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *BlockDevicesAnalyze) DeepCopyInto(out *BlockDevicesAnalyze) { *out = *in - out.AnalyzeMeta = in.AnalyzeMeta + in.AnalyzeMeta.DeepCopyInto(&out.AnalyzeMeta) if in.Outcomes != nil { in, out := &in.Outcomes, &out.Outcomes *out = make([]*Outcome, len(*in)) @@ -386,7 +395,7 @@ func (in *BlockDevicesAnalyze) DeepCopy() *BlockDevicesAnalyze { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *CPU) DeepCopyInto(out *CPU) { *out = *in - out.HostCollectorMeta = in.HostCollectorMeta + in.HostCollectorMeta.DeepCopyInto(&out.HostCollectorMeta) } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CPU. @@ -402,7 +411,7 @@ func (in *CPU) DeepCopy() *CPU { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *CPUAnalyze) DeepCopyInto(out *CPUAnalyze) { *out = *in - out.AnalyzeMeta = in.AnalyzeMeta + in.AnalyzeMeta.DeepCopyInto(&out.AnalyzeMeta) if in.Outcomes != nil { in, out := &in.Outcomes, &out.Outcomes *out = make([]*Outcome, len(*in)) @@ -429,7 +438,7 @@ func (in *CPUAnalyze) DeepCopy() *CPUAnalyze { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *Ceph) DeepCopyInto(out *Ceph) { *out = *in - out.CollectorMeta = in.CollectorMeta + in.CollectorMeta.DeepCopyInto(&out.CollectorMeta) } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Ceph. @@ -445,7 +454,7 @@ func (in *Ceph) DeepCopy() *Ceph { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *CephStatusAnalyze) DeepCopyInto(out *CephStatusAnalyze) { *out = *in - out.AnalyzeMeta = in.AnalyzeMeta + in.AnalyzeMeta.DeepCopyInto(&out.AnalyzeMeta) if in.Outcomes != nil { in, out := &in.Outcomes, &out.Outcomes *out = make([]*Outcome, len(*in)) @@ -472,7 +481,7 @@ func (in *CephStatusAnalyze) DeepCopy() *CephStatusAnalyze { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *Certificate) DeepCopyInto(out *Certificate) { *out = *in - out.HostCollectorMeta = in.HostCollectorMeta + in.HostCollectorMeta.DeepCopyInto(&out.HostCollectorMeta) } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Certificate. @@ -488,7 +497,7 @@ func (in *Certificate) DeepCopy() *Certificate { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *CertificateAnalyze) DeepCopyInto(out *CertificateAnalyze) { *out = *in - out.AnalyzeMeta = in.AnalyzeMeta + in.AnalyzeMeta.DeepCopyInto(&out.AnalyzeMeta) if in.Outcomes != nil { in, out := &in.Outcomes, &out.Outcomes *out = make([]*Outcome, len(*in)) @@ -515,7 +524,7 @@ func (in *CertificateAnalyze) DeepCopy() *CertificateAnalyze { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ClusterInfo) DeepCopyInto(out *ClusterInfo) { *out = *in - out.CollectorMeta = in.CollectorMeta + in.CollectorMeta.DeepCopyInto(&out.CollectorMeta) } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterInfo. @@ -531,7 +540,7 @@ func (in *ClusterInfo) DeepCopy() *ClusterInfo { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ClusterPodStatuses) DeepCopyInto(out *ClusterPodStatuses) { *out = *in - out.AnalyzeMeta = in.AnalyzeMeta + in.AnalyzeMeta.DeepCopyInto(&out.AnalyzeMeta) if in.Outcomes != nil { in, out := &in.Outcomes, &out.Outcomes *out = make([]*Outcome, len(*in)) @@ -563,7 +572,7 @@ func (in *ClusterPodStatuses) DeepCopy() *ClusterPodStatuses { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ClusterResources) DeepCopyInto(out *ClusterResources) { *out = *in - out.CollectorMeta = in.CollectorMeta + in.CollectorMeta.DeepCopyInto(&out.CollectorMeta) if in.Namespaces != nil { in, out := &in.Namespaces, &out.Namespaces *out = make([]string, len(*in)) @@ -584,7 +593,7 @@ func (in *ClusterResources) DeepCopy() *ClusterResources { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ClusterVersion) DeepCopyInto(out *ClusterVersion) { *out = *in - out.AnalyzeMeta = in.AnalyzeMeta + in.AnalyzeMeta.DeepCopyInto(&out.AnalyzeMeta) if in.Outcomes != nil { in, out := &in.Outcomes, &out.Outcomes *out = make([]*Outcome, len(*in)) @@ -614,7 +623,7 @@ func (in *Collect) DeepCopyInto(out *Collect) { if in.ClusterInfo != nil { in, out := &in.ClusterInfo, &out.ClusterInfo *out = new(ClusterInfo) - **out = **in + (*in).DeepCopyInto(*out) } if in.ClusterResources != nil { in, out := &in.ClusterResources, &out.ClusterResources @@ -649,7 +658,7 @@ func (in *Collect) DeepCopyInto(out *Collect) { if in.Data != nil { in, out := &in.Data, &out.Data *out = new(Data) - **out = **in + (*in).DeepCopyInto(*out) } if in.Copy != nil { in, out := &in.Copy, &out.Copy @@ -669,17 +678,17 @@ func (in *Collect) DeepCopyInto(out *Collect) { if in.Postgres != nil { in, out := &in.Postgres, &out.Postgres *out = new(Database) - **out = **in + (*in).DeepCopyInto(*out) } if in.Mysql != nil { in, out := &in.Mysql, &out.Mysql *out = new(Database) - **out = **in + (*in).DeepCopyInto(*out) } if in.Redis != nil { in, out := &in.Redis, &out.Redis *out = new(Database) - **out = **in + (*in).DeepCopyInto(*out) } if in.Collectd != nil { in, out := &in.Collectd, &out.Collectd @@ -689,12 +698,12 @@ func (in *Collect) DeepCopyInto(out *Collect) { if in.Ceph != nil { in, out := &in.Ceph, &out.Ceph *out = new(Ceph) - **out = **in + (*in).DeepCopyInto(*out) } if in.Longhorn != nil { in, out := &in.Longhorn, &out.Longhorn *out = new(Longhorn) - **out = **in + (*in).DeepCopyInto(*out) } if in.RegistryImages != nil { in, out := &in.RegistryImages, &out.RegistryImages @@ -721,7 +730,7 @@ func (in *Collect) DeepCopy() *Collect { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *Collectd) DeepCopyInto(out *Collectd) { *out = *in - out.CollectorMeta = in.CollectorMeta + in.CollectorMeta.DeepCopyInto(&out.CollectorMeta) if in.ImagePullSecret != nil { in, out := &in.ImagePullSecret, &out.ImagePullSecret *out = new(ImagePullSecrets) @@ -742,7 +751,7 @@ func (in *Collectd) DeepCopy() *Collectd { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *CollectdAnalyze) DeepCopyInto(out *CollectdAnalyze) { *out = *in - out.AnalyzeMeta = in.AnalyzeMeta + in.AnalyzeMeta.DeepCopyInto(&out.AnalyzeMeta) if in.Outcomes != nil { in, out := &in.Outcomes, &out.Outcomes *out = make([]*Outcome, len(*in)) @@ -828,7 +837,11 @@ func (in *CollectorList) DeepCopyObject() runtime.Object { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *CollectorMeta) DeepCopyInto(out *CollectorMeta) { *out = *in - out.Exclude = in.Exclude + if in.Exclude != nil { + in, out := &in.Exclude, &out.Exclude + *out = new(multitype.BoolOrString) + **out = **in + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CollectorMeta. @@ -896,7 +909,7 @@ func (in *CollectorStatus) DeepCopy() *CollectorStatus { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ConfigMap) DeepCopyInto(out *ConfigMap) { *out = *in - out.CollectorMeta = in.CollectorMeta + in.CollectorMeta.DeepCopyInto(&out.CollectorMeta) if in.Selector != nil { in, out := &in.Selector, &out.Selector *out = make([]string, len(*in)) @@ -917,7 +930,7 @@ func (in *ConfigMap) DeepCopy() *ConfigMap { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ContainerRuntime) DeepCopyInto(out *ContainerRuntime) { *out = *in - out.AnalyzeMeta = in.AnalyzeMeta + in.AnalyzeMeta.DeepCopyInto(&out.AnalyzeMeta) if in.Outcomes != nil { in, out := &in.Outcomes, &out.Outcomes *out = make([]*Outcome, len(*in)) @@ -944,7 +957,7 @@ func (in *ContainerRuntime) DeepCopy() *ContainerRuntime { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *Copy) DeepCopyInto(out *Copy) { *out = *in - out.CollectorMeta = in.CollectorMeta + in.CollectorMeta.DeepCopyInto(&out.CollectorMeta) if in.Selector != nil { in, out := &in.Selector, &out.Selector *out = make([]string, len(*in)) @@ -965,7 +978,7 @@ func (in *Copy) DeepCopy() *Copy { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *CopyFromHost) DeepCopyInto(out *CopyFromHost) { *out = *in - out.CollectorMeta = in.CollectorMeta + in.CollectorMeta.DeepCopyInto(&out.CollectorMeta) if in.ImagePullSecret != nil { in, out := &in.ImagePullSecret, &out.ImagePullSecret *out = new(ImagePullSecrets) @@ -986,7 +999,7 @@ func (in *CopyFromHost) DeepCopy() *CopyFromHost { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *CustomResourceDefinition) DeepCopyInto(out *CustomResourceDefinition) { *out = *in - out.AnalyzeMeta = in.AnalyzeMeta + in.AnalyzeMeta.DeepCopyInto(&out.AnalyzeMeta) if in.Outcomes != nil { in, out := &in.Outcomes, &out.Outcomes *out = make([]*Outcome, len(*in)) @@ -1013,7 +1026,7 @@ func (in *CustomResourceDefinition) DeepCopy() *CustomResourceDefinition { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *Data) DeepCopyInto(out *Data) { *out = *in - out.CollectorMeta = in.CollectorMeta + in.CollectorMeta.DeepCopyInto(&out.CollectorMeta) } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Data. @@ -1029,7 +1042,12 @@ func (in *Data) DeepCopy() *Data { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *Database) DeepCopyInto(out *Database) { *out = *in - out.CollectorMeta = in.CollectorMeta + in.CollectorMeta.DeepCopyInto(&out.CollectorMeta) + if in.Parameters != nil { + in, out := &in.Parameters, &out.Parameters + *out = make([]string, len(*in)) + copy(*out, *in) + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Database. @@ -1045,7 +1063,7 @@ func (in *Database) DeepCopy() *Database { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *DatabaseAnalyze) DeepCopyInto(out *DatabaseAnalyze) { *out = *in - out.AnalyzeMeta = in.AnalyzeMeta + in.AnalyzeMeta.DeepCopyInto(&out.AnalyzeMeta) if in.Outcomes != nil { in, out := &in.Outcomes, &out.Outcomes *out = make([]*Outcome, len(*in)) @@ -1072,7 +1090,7 @@ func (in *DatabaseAnalyze) DeepCopy() *DatabaseAnalyze { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *DeploymentStatus) DeepCopyInto(out *DeploymentStatus) { *out = *in - out.AnalyzeMeta = in.AnalyzeMeta + in.AnalyzeMeta.DeepCopyInto(&out.AnalyzeMeta) if in.Outcomes != nil { in, out := &in.Outcomes, &out.Outcomes *out = make([]*Outcome, len(*in)) @@ -1104,7 +1122,7 @@ func (in *DeploymentStatus) DeepCopy() *DeploymentStatus { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *DiskUsage) DeepCopyInto(out *DiskUsage) { *out = *in - out.HostCollectorMeta = in.HostCollectorMeta + in.HostCollectorMeta.DeepCopyInto(&out.HostCollectorMeta) } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DiskUsage. @@ -1120,7 +1138,7 @@ func (in *DiskUsage) DeepCopy() *DiskUsage { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *DiskUsageAnalyze) DeepCopyInto(out *DiskUsageAnalyze) { *out = *in - out.AnalyzeMeta = in.AnalyzeMeta + in.AnalyzeMeta.DeepCopyInto(&out.AnalyzeMeta) if in.Outcomes != nil { in, out := &in.Outcomes, &out.Outcomes *out = make([]*Outcome, len(*in)) @@ -1147,7 +1165,7 @@ func (in *DiskUsageAnalyze) DeepCopy() *DiskUsageAnalyze { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *Distribution) DeepCopyInto(out *Distribution) { *out = *in - out.AnalyzeMeta = in.AnalyzeMeta + in.AnalyzeMeta.DeepCopyInto(&out.AnalyzeMeta) if in.Outcomes != nil { in, out := &in.Outcomes, &out.Outcomes *out = make([]*Outcome, len(*in)) @@ -1174,7 +1192,7 @@ func (in *Distribution) DeepCopy() *Distribution { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *Exec) DeepCopyInto(out *Exec) { *out = *in - out.CollectorMeta = in.CollectorMeta + in.CollectorMeta.DeepCopyInto(&out.CollectorMeta) if in.Selector != nil { in, out := &in.Selector, &out.Selector *out = make([]string, len(*in)) @@ -1225,7 +1243,7 @@ func (in *FileSelector) DeepCopy() *FileSelector { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *FilesystemPerformance) DeepCopyInto(out *FilesystemPerformance) { *out = *in - out.HostCollectorMeta = in.HostCollectorMeta + in.HostCollectorMeta.DeepCopyInto(&out.HostCollectorMeta) } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FilesystemPerformance. @@ -1241,7 +1259,7 @@ func (in *FilesystemPerformance) DeepCopy() *FilesystemPerformance { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *FilesystemPerformanceAnalyze) DeepCopyInto(out *FilesystemPerformanceAnalyze) { *out = *in - out.AnalyzeMeta = in.AnalyzeMeta + in.AnalyzeMeta.DeepCopyInto(&out.AnalyzeMeta) if in.Outcomes != nil { in, out := &in.Outcomes, &out.Outcomes *out = make([]*Outcome, len(*in)) @@ -1290,7 +1308,7 @@ func (in *Get) DeepCopy() *Get { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *HTTP) DeepCopyInto(out *HTTP) { *out = *in - out.CollectorMeta = in.CollectorMeta + in.CollectorMeta.DeepCopyInto(&out.CollectorMeta) if in.Get != nil { in, out := &in.Get, &out.Get *out = new(Get) @@ -1321,7 +1339,7 @@ func (in *HTTP) DeepCopy() *HTTP { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *HTTPAnalyze) DeepCopyInto(out *HTTPAnalyze) { *out = *in - out.AnalyzeMeta = in.AnalyzeMeta + in.AnalyzeMeta.DeepCopyInto(&out.AnalyzeMeta) if in.Outcomes != nil { in, out := &in.Outcomes, &out.Outcomes *out = make([]*Outcome, len(*in)) @@ -1348,7 +1366,7 @@ func (in *HTTPAnalyze) DeepCopy() *HTTPAnalyze { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *HTTPLoadBalancer) DeepCopyInto(out *HTTPLoadBalancer) { *out = *in - out.HostCollectorMeta = in.HostCollectorMeta + in.HostCollectorMeta.DeepCopyInto(&out.HostCollectorMeta) } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HTTPLoadBalancer. @@ -1364,7 +1382,7 @@ func (in *HTTPLoadBalancer) DeepCopy() *HTTPLoadBalancer { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *HTTPLoadBalancerAnalyze) DeepCopyInto(out *HTTPLoadBalancerAnalyze) { *out = *in - out.AnalyzeMeta = in.AnalyzeMeta + in.AnalyzeMeta.DeepCopyInto(&out.AnalyzeMeta) if in.Outcomes != nil { in, out := &in.Outcomes, &out.Outcomes *out = make([]*Outcome, len(*in)) @@ -1491,7 +1509,7 @@ func (in *HostAnalyze) DeepCopy() *HostAnalyze { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *HostBlockDevices) DeepCopyInto(out *HostBlockDevices) { *out = *in - out.HostCollectorMeta = in.HostCollectorMeta + in.HostCollectorMeta.DeepCopyInto(&out.HostCollectorMeta) } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HostBlockDevices. @@ -1510,42 +1528,42 @@ func (in *HostCollect) DeepCopyInto(out *HostCollect) { if in.CPU != nil { in, out := &in.CPU, &out.CPU *out = new(CPU) - **out = **in + (*in).DeepCopyInto(*out) } if in.Memory != nil { in, out := &in.Memory, &out.Memory *out = new(Memory) - **out = **in + (*in).DeepCopyInto(*out) } if in.TCPLoadBalancer != nil { in, out := &in.TCPLoadBalancer, &out.TCPLoadBalancer *out = new(TCPLoadBalancer) - **out = **in + (*in).DeepCopyInto(*out) } if in.HTTPLoadBalancer != nil { in, out := &in.HTTPLoadBalancer, &out.HTTPLoadBalancer *out = new(HTTPLoadBalancer) - **out = **in + (*in).DeepCopyInto(*out) } if in.TCPPortStatus != nil { in, out := &in.TCPPortStatus, &out.TCPPortStatus *out = new(TCPPortStatus) - **out = **in + (*in).DeepCopyInto(*out) } if in.Kubernetes != nil { in, out := &in.Kubernetes, &out.Kubernetes *out = new(Kubernetes) - **out = **in + (*in).DeepCopyInto(*out) } if in.IPV4Interfaces != nil { in, out := &in.IPV4Interfaces, &out.IPV4Interfaces *out = new(IPV4Interfaces) - **out = **in + (*in).DeepCopyInto(*out) } if in.DiskUsage != nil { in, out := &in.DiskUsage, &out.DiskUsage *out = new(DiskUsage) - **out = **in + (*in).DeepCopyInto(*out) } if in.HTTP != nil { in, out := &in.HTTP, &out.HTTP @@ -1555,12 +1573,12 @@ func (in *HostCollect) DeepCopyInto(out *HostCollect) { if in.Time != nil { in, out := &in.Time, &out.Time *out = new(HostTime) - **out = **in + (*in).DeepCopyInto(*out) } if in.BlockDevices != nil { in, out := &in.BlockDevices, &out.BlockDevices *out = new(HostBlockDevices) - **out = **in + (*in).DeepCopyInto(*out) } if in.SystemPackages != nil { in, out := &in.SystemPackages, &out.SystemPackages @@ -1570,32 +1588,32 @@ func (in *HostCollect) DeepCopyInto(out *HostCollect) { if in.KernelModules != nil { in, out := &in.KernelModules, &out.KernelModules *out = new(HostKernelModules) - **out = **in + (*in).DeepCopyInto(*out) } if in.TCPConnect != nil { in, out := &in.TCPConnect, &out.TCPConnect *out = new(TCPConnect) - **out = **in + (*in).DeepCopyInto(*out) } if in.FilesystemPerformance != nil { in, out := &in.FilesystemPerformance, &out.FilesystemPerformance *out = new(FilesystemPerformance) - **out = **in + (*in).DeepCopyInto(*out) } if in.Certificate != nil { in, out := &in.Certificate, &out.Certificate *out = new(Certificate) - **out = **in + (*in).DeepCopyInto(*out) } if in.HostServices != nil { in, out := &in.HostServices, &out.HostServices *out = new(HostServices) - **out = **in + (*in).DeepCopyInto(*out) } if in.HostOS != nil { in, out := &in.HostOS, &out.HostOS *out = new(HostOS) - **out = **in + (*in).DeepCopyInto(*out) } } @@ -1671,7 +1689,11 @@ func (in *HostCollectorList) DeepCopyObject() runtime.Object { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *HostCollectorMeta) DeepCopyInto(out *HostCollectorMeta) { *out = *in - out.Exclude = in.Exclude + if in.Exclude != nil { + in, out := &in.Exclude, &out.Exclude + *out = new(multitype.BoolOrString) + **out = **in + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HostCollectorMeta. @@ -1739,7 +1761,7 @@ func (in *HostCollectorStatus) DeepCopy() *HostCollectorStatus { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *HostHTTP) DeepCopyInto(out *HostHTTP) { *out = *in - out.HostCollectorMeta = in.HostCollectorMeta + in.HostCollectorMeta.DeepCopyInto(&out.HostCollectorMeta) if in.Get != nil { in, out := &in.Get, &out.Get *out = new(Get) @@ -1770,7 +1792,7 @@ func (in *HostHTTP) DeepCopy() *HostHTTP { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *HostKernelModules) DeepCopyInto(out *HostKernelModules) { *out = *in - out.HostCollectorMeta = in.HostCollectorMeta + in.HostCollectorMeta.DeepCopyInto(&out.HostCollectorMeta) } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HostKernelModules. @@ -1786,7 +1808,7 @@ func (in *HostKernelModules) DeepCopy() *HostKernelModules { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *HostOS) DeepCopyInto(out *HostOS) { *out = *in - out.HostCollectorMeta = in.HostCollectorMeta + in.HostCollectorMeta.DeepCopyInto(&out.HostCollectorMeta) } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HostOS. @@ -1802,7 +1824,7 @@ func (in *HostOS) DeepCopy() *HostOS { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *HostOSAnalyze) DeepCopyInto(out *HostOSAnalyze) { *out = *in - out.AnalyzeMeta = in.AnalyzeMeta + in.AnalyzeMeta.DeepCopyInto(&out.AnalyzeMeta) if in.Outcomes != nil { in, out := &in.Outcomes, &out.Outcomes *out = make([]*Outcome, len(*in)) @@ -1951,7 +1973,7 @@ func (in *HostPreflightStatus) DeepCopy() *HostPreflightStatus { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *HostServices) DeepCopyInto(out *HostServices) { *out = *in - out.HostCollectorMeta = in.HostCollectorMeta + in.HostCollectorMeta.DeepCopyInto(&out.HostCollectorMeta) } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HostServices. @@ -1967,7 +1989,7 @@ func (in *HostServices) DeepCopy() *HostServices { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *HostServicesAnalyze) DeepCopyInto(out *HostServicesAnalyze) { *out = *in - out.AnalyzeMeta = in.AnalyzeMeta + in.AnalyzeMeta.DeepCopyInto(&out.AnalyzeMeta) if in.Outcomes != nil { in, out := &in.Outcomes, &out.Outcomes *out = make([]*Outcome, len(*in)) @@ -1994,7 +2016,7 @@ func (in *HostServicesAnalyze) DeepCopy() *HostServicesAnalyze { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *HostSystemPackages) DeepCopyInto(out *HostSystemPackages) { *out = *in - out.HostCollectorMeta = in.HostCollectorMeta + in.HostCollectorMeta.DeepCopyInto(&out.HostCollectorMeta) if in.Ubuntu != nil { in, out := &in.Ubuntu, &out.Ubuntu *out = make([]string, len(*in)) @@ -2085,7 +2107,7 @@ func (in *HostSystemPackages) DeepCopy() *HostSystemPackages { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *HostTime) DeepCopyInto(out *HostTime) { *out = *in - out.HostCollectorMeta = in.HostCollectorMeta + in.HostCollectorMeta.DeepCopyInto(&out.HostCollectorMeta) } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HostTime. @@ -2101,7 +2123,7 @@ func (in *HostTime) DeepCopy() *HostTime { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *IPV4Interfaces) DeepCopyInto(out *IPV4Interfaces) { *out = *in - out.HostCollectorMeta = in.HostCollectorMeta + in.HostCollectorMeta.DeepCopyInto(&out.HostCollectorMeta) } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new IPV4Interfaces. @@ -2117,7 +2139,7 @@ func (in *IPV4Interfaces) DeepCopy() *IPV4Interfaces { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *IPV4InterfacesAnalyze) DeepCopyInto(out *IPV4InterfacesAnalyze) { *out = *in - out.AnalyzeMeta = in.AnalyzeMeta + in.AnalyzeMeta.DeepCopyInto(&out.AnalyzeMeta) if in.Outcomes != nil { in, out := &in.Outcomes, &out.Outcomes *out = make([]*Outcome, len(*in)) @@ -2144,7 +2166,7 @@ func (in *IPV4InterfacesAnalyze) DeepCopy() *IPV4InterfacesAnalyze { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ImagePullSecret) DeepCopyInto(out *ImagePullSecret) { *out = *in - out.AnalyzeMeta = in.AnalyzeMeta + in.AnalyzeMeta.DeepCopyInto(&out.AnalyzeMeta) if in.Outcomes != nil { in, out := &in.Outcomes, &out.Outcomes *out = make([]*Outcome, len(*in)) @@ -2193,7 +2215,7 @@ func (in *ImagePullSecrets) DeepCopy() *ImagePullSecrets { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *Ingress) DeepCopyInto(out *Ingress) { *out = *in - out.AnalyzeMeta = in.AnalyzeMeta + in.AnalyzeMeta.DeepCopyInto(&out.AnalyzeMeta) if in.Outcomes != nil { in, out := &in.Outcomes, &out.Outcomes *out = make([]*Outcome, len(*in)) @@ -2220,7 +2242,7 @@ func (in *Ingress) DeepCopy() *Ingress { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *JobStatus) DeepCopyInto(out *JobStatus) { *out = *in - out.AnalyzeMeta = in.AnalyzeMeta + in.AnalyzeMeta.DeepCopyInto(&out.AnalyzeMeta) if in.Outcomes != nil { in, out := &in.Outcomes, &out.Outcomes *out = make([]*Outcome, len(*in)) @@ -2252,7 +2274,7 @@ func (in *JobStatus) DeepCopy() *JobStatus { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *KernelModulesAnalyze) DeepCopyInto(out *KernelModulesAnalyze) { *out = *in - out.AnalyzeMeta = in.AnalyzeMeta + in.AnalyzeMeta.DeepCopyInto(&out.AnalyzeMeta) if in.Outcomes != nil { in, out := &in.Outcomes, &out.Outcomes *out = make([]*Outcome, len(*in)) @@ -2279,7 +2301,7 @@ func (in *KernelModulesAnalyze) DeepCopy() *KernelModulesAnalyze { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *Kubernetes) DeepCopyInto(out *Kubernetes) { *out = *in - out.HostCollectorMeta = in.HostCollectorMeta + in.HostCollectorMeta.DeepCopyInto(&out.HostCollectorMeta) } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Kubernetes. @@ -2311,7 +2333,7 @@ func (in *LogLimits) DeepCopy() *LogLimits { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *Logs) DeepCopyInto(out *Logs) { *out = *in - out.CollectorMeta = in.CollectorMeta + in.CollectorMeta.DeepCopyInto(&out.CollectorMeta) if in.Selector != nil { in, out := &in.Selector, &out.Selector *out = make([]string, len(*in)) @@ -2342,7 +2364,7 @@ func (in *Logs) DeepCopy() *Logs { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *Longhorn) DeepCopyInto(out *Longhorn) { *out = *in - out.CollectorMeta = in.CollectorMeta + in.CollectorMeta.DeepCopyInto(&out.CollectorMeta) } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Longhorn. @@ -2358,7 +2380,7 @@ func (in *Longhorn) DeepCopy() *Longhorn { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *LonghornAnalyze) DeepCopyInto(out *LonghornAnalyze) { *out = *in - out.AnalyzeMeta = in.AnalyzeMeta + in.AnalyzeMeta.DeepCopyInto(&out.AnalyzeMeta) if in.Outcomes != nil { in, out := &in.Outcomes, &out.Outcomes *out = make([]*Outcome, len(*in)) @@ -2385,7 +2407,7 @@ func (in *LonghornAnalyze) DeepCopy() *LonghornAnalyze { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *Memory) DeepCopyInto(out *Memory) { *out = *in - out.HostCollectorMeta = in.HostCollectorMeta + in.HostCollectorMeta.DeepCopyInto(&out.HostCollectorMeta) } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Memory. @@ -2401,7 +2423,7 @@ func (in *Memory) DeepCopy() *Memory { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *MemoryAnalyze) DeepCopyInto(out *MemoryAnalyze) { *out = *in - out.AnalyzeMeta = in.AnalyzeMeta + in.AnalyzeMeta.DeepCopyInto(&out.AnalyzeMeta) if in.Outcomes != nil { in, out := &in.Outcomes, &out.Outcomes *out = make([]*Outcome, len(*in)) @@ -2470,7 +2492,7 @@ func (in *NodeResourceSelectors) DeepCopy() *NodeResourceSelectors { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *NodeResources) DeepCopyInto(out *NodeResources) { *out = *in - out.AnalyzeMeta = in.AnalyzeMeta + in.AnalyzeMeta.DeepCopyInto(&out.AnalyzeMeta) if in.Outcomes != nil { in, out := &in.Outcomes, &out.Outcomes *out = make([]*Outcome, len(*in)) @@ -2830,7 +2852,7 @@ func (in *Regex) DeepCopy() *Regex { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *RegistryImages) DeepCopyInto(out *RegistryImages) { *out = *in - out.CollectorMeta = in.CollectorMeta + in.CollectorMeta.DeepCopyInto(&out.CollectorMeta) if in.Images != nil { in, out := &in.Images, &out.Images *out = make([]string, len(*in)) @@ -2856,7 +2878,7 @@ func (in *RegistryImages) DeepCopy() *RegistryImages { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *RegistryImagesAnalyze) DeepCopyInto(out *RegistryImagesAnalyze) { *out = *in - out.AnalyzeMeta = in.AnalyzeMeta + in.AnalyzeMeta.DeepCopyInto(&out.AnalyzeMeta) if in.Outcomes != nil { in, out := &in.Outcomes, &out.Outcomes *out = make([]*Outcome, len(*in)) @@ -2883,7 +2905,7 @@ func (in *RegistryImagesAnalyze) DeepCopy() *RegistryImagesAnalyze { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *RemoteBlockDevices) DeepCopyInto(out *RemoteBlockDevices) { *out = *in - out.RemoteCollectorMeta = in.RemoteCollectorMeta + in.RemoteCollectorMeta.DeepCopyInto(&out.RemoteCollectorMeta) } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RemoteBlockDevices. @@ -2899,7 +2921,7 @@ func (in *RemoteBlockDevices) DeepCopy() *RemoteBlockDevices { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *RemoteCPU) DeepCopyInto(out *RemoteCPU) { *out = *in - out.RemoteCollectorMeta = in.RemoteCollectorMeta + in.RemoteCollectorMeta.DeepCopyInto(&out.RemoteCollectorMeta) } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RemoteCPU. @@ -2915,7 +2937,7 @@ func (in *RemoteCPU) DeepCopy() *RemoteCPU { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *RemoteCertificate) DeepCopyInto(out *RemoteCertificate) { *out = *in - out.RemoteCollectorMeta = in.RemoteCollectorMeta + in.RemoteCollectorMeta.DeepCopyInto(&out.RemoteCollectorMeta) } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RemoteCertificate. @@ -2934,37 +2956,37 @@ func (in *RemoteCollect) DeepCopyInto(out *RemoteCollect) { if in.CPU != nil { in, out := &in.CPU, &out.CPU *out = new(RemoteCPU) - **out = **in + (*in).DeepCopyInto(*out) } if in.Memory != nil { in, out := &in.Memory, &out.Memory *out = new(RemoteMemory) - **out = **in + (*in).DeepCopyInto(*out) } if in.TCPLoadBalancer != nil { in, out := &in.TCPLoadBalancer, &out.TCPLoadBalancer *out = new(RemoteTCPLoadBalancer) - **out = **in + (*in).DeepCopyInto(*out) } if in.HTTPLoadBalancer != nil { in, out := &in.HTTPLoadBalancer, &out.HTTPLoadBalancer *out = new(RemoteHTTPLoadBalancer) - **out = **in + (*in).DeepCopyInto(*out) } if in.TCPPortStatus != nil { in, out := &in.TCPPortStatus, &out.TCPPortStatus *out = new(RemoteTCPPortStatus) - **out = **in + (*in).DeepCopyInto(*out) } if in.IPV4Interfaces != nil { in, out := &in.IPV4Interfaces, &out.IPV4Interfaces *out = new(RemoteIPV4Interfaces) - **out = **in + (*in).DeepCopyInto(*out) } if in.DiskUsage != nil { in, out := &in.DiskUsage, &out.DiskUsage *out = new(RemoteDiskUsage) - **out = **in + (*in).DeepCopyInto(*out) } if in.HTTP != nil { in, out := &in.HTTP, &out.HTTP @@ -2974,42 +2996,42 @@ func (in *RemoteCollect) DeepCopyInto(out *RemoteCollect) { if in.Time != nil { in, out := &in.Time, &out.Time *out = new(RemoteTime) - **out = **in + (*in).DeepCopyInto(*out) } if in.BlockDevices != nil { in, out := &in.BlockDevices, &out.BlockDevices *out = new(RemoteBlockDevices) - **out = **in + (*in).DeepCopyInto(*out) } if in.SystemPackages != nil { in, out := &in.SystemPackages, &out.SystemPackages *out = new(RemoteSystemPackages) - **out = **in + (*in).DeepCopyInto(*out) } if in.KernelModules != nil { in, out := &in.KernelModules, &out.KernelModules *out = new(RemoteKernelModules) - **out = **in + (*in).DeepCopyInto(*out) } if in.TCPConnect != nil { in, out := &in.TCPConnect, &out.TCPConnect *out = new(RemoteTCPConnect) - **out = **in + (*in).DeepCopyInto(*out) } if in.FilesystemPerformance != nil { in, out := &in.FilesystemPerformance, &out.FilesystemPerformance *out = new(RemoteFilesystemPerformance) - **out = **in + (*in).DeepCopyInto(*out) } if in.Certificate != nil { in, out := &in.Certificate, &out.Certificate *out = new(RemoteCertificate) - **out = **in + (*in).DeepCopyInto(*out) } if in.HostServices != nil { in, out := &in.HostServices, &out.HostServices *out = new(RemoteServices) - **out = **in + (*in).DeepCopyInto(*out) } } @@ -3085,7 +3107,11 @@ func (in *RemoteCollectorList) DeepCopyObject() runtime.Object { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *RemoteCollectorMeta) DeepCopyInto(out *RemoteCollectorMeta) { *out = *in - out.Exclude = in.Exclude + if in.Exclude != nil { + in, out := &in.Exclude, &out.Exclude + *out = new(multitype.BoolOrString) + **out = **in + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RemoteCollectorMeta. @@ -3145,7 +3171,7 @@ func (in *RemoteCollectorSpec) DeepCopy() *RemoteCollectorSpec { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *RemoteDiskUsage) DeepCopyInto(out *RemoteDiskUsage) { *out = *in - out.RemoteCollectorMeta = in.RemoteCollectorMeta + in.RemoteCollectorMeta.DeepCopyInto(&out.RemoteCollectorMeta) } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RemoteDiskUsage. @@ -3161,7 +3187,7 @@ func (in *RemoteDiskUsage) DeepCopy() *RemoteDiskUsage { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *RemoteFilesystemPerformance) DeepCopyInto(out *RemoteFilesystemPerformance) { *out = *in - out.RemoteCollectorMeta = in.RemoteCollectorMeta + in.RemoteCollectorMeta.DeepCopyInto(&out.RemoteCollectorMeta) } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RemoteFilesystemPerformance. @@ -3177,7 +3203,7 @@ func (in *RemoteFilesystemPerformance) DeepCopy() *RemoteFilesystemPerformance { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *RemoteHTTP) DeepCopyInto(out *RemoteHTTP) { *out = *in - out.RemoteCollectorMeta = in.RemoteCollectorMeta + in.RemoteCollectorMeta.DeepCopyInto(&out.RemoteCollectorMeta) if in.Get != nil { in, out := &in.Get, &out.Get *out = new(Get) @@ -3208,7 +3234,7 @@ func (in *RemoteHTTP) DeepCopy() *RemoteHTTP { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *RemoteHTTPLoadBalancer) DeepCopyInto(out *RemoteHTTPLoadBalancer) { *out = *in - out.RemoteCollectorMeta = in.RemoteCollectorMeta + in.RemoteCollectorMeta.DeepCopyInto(&out.RemoteCollectorMeta) } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RemoteHTTPLoadBalancer. @@ -3224,7 +3250,7 @@ func (in *RemoteHTTPLoadBalancer) DeepCopy() *RemoteHTTPLoadBalancer { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *RemoteIPV4Interfaces) DeepCopyInto(out *RemoteIPV4Interfaces) { *out = *in - out.RemoteCollectorMeta = in.RemoteCollectorMeta + in.RemoteCollectorMeta.DeepCopyInto(&out.RemoteCollectorMeta) } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RemoteIPV4Interfaces. @@ -3240,7 +3266,7 @@ func (in *RemoteIPV4Interfaces) DeepCopy() *RemoteIPV4Interfaces { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *RemoteKernelModules) DeepCopyInto(out *RemoteKernelModules) { *out = *in - out.RemoteCollectorMeta = in.RemoteCollectorMeta + in.RemoteCollectorMeta.DeepCopyInto(&out.RemoteCollectorMeta) } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RemoteKernelModules. @@ -3256,7 +3282,7 @@ func (in *RemoteKernelModules) DeepCopy() *RemoteKernelModules { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *RemoteKubernetes) DeepCopyInto(out *RemoteKubernetes) { *out = *in - out.RemoteCollectorMeta = in.RemoteCollectorMeta + in.RemoteCollectorMeta.DeepCopyInto(&out.RemoteCollectorMeta) } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RemoteKubernetes. @@ -3272,7 +3298,7 @@ func (in *RemoteKubernetes) DeepCopy() *RemoteKubernetes { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *RemoteMemory) DeepCopyInto(out *RemoteMemory) { *out = *in - out.RemoteCollectorMeta = in.RemoteCollectorMeta + in.RemoteCollectorMeta.DeepCopyInto(&out.RemoteCollectorMeta) } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RemoteMemory. @@ -3288,7 +3314,7 @@ func (in *RemoteMemory) DeepCopy() *RemoteMemory { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *RemoteServices) DeepCopyInto(out *RemoteServices) { *out = *in - out.RemoteCollectorMeta = in.RemoteCollectorMeta + in.RemoteCollectorMeta.DeepCopyInto(&out.RemoteCollectorMeta) } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RemoteServices. @@ -3304,7 +3330,7 @@ func (in *RemoteServices) DeepCopy() *RemoteServices { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *RemoteSystemPackages) DeepCopyInto(out *RemoteSystemPackages) { *out = *in - out.RemoteCollectorMeta = in.RemoteCollectorMeta + in.RemoteCollectorMeta.DeepCopyInto(&out.RemoteCollectorMeta) } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RemoteSystemPackages. @@ -3320,7 +3346,7 @@ func (in *RemoteSystemPackages) DeepCopy() *RemoteSystemPackages { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *RemoteTCPConnect) DeepCopyInto(out *RemoteTCPConnect) { *out = *in - out.RemoteCollectorMeta = in.RemoteCollectorMeta + in.RemoteCollectorMeta.DeepCopyInto(&out.RemoteCollectorMeta) } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RemoteTCPConnect. @@ -3336,7 +3362,7 @@ func (in *RemoteTCPConnect) DeepCopy() *RemoteTCPConnect { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *RemoteTCPLoadBalancer) DeepCopyInto(out *RemoteTCPLoadBalancer) { *out = *in - out.RemoteCollectorMeta = in.RemoteCollectorMeta + in.RemoteCollectorMeta.DeepCopyInto(&out.RemoteCollectorMeta) } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RemoteTCPLoadBalancer. @@ -3352,7 +3378,7 @@ func (in *RemoteTCPLoadBalancer) DeepCopy() *RemoteTCPLoadBalancer { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *RemoteTCPPortStatus) DeepCopyInto(out *RemoteTCPPortStatus) { *out = *in - out.RemoteCollectorMeta = in.RemoteCollectorMeta + in.RemoteCollectorMeta.DeepCopyInto(&out.RemoteCollectorMeta) } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RemoteTCPPortStatus. @@ -3368,7 +3394,7 @@ func (in *RemoteTCPPortStatus) DeepCopy() *RemoteTCPPortStatus { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *RemoteTime) DeepCopyInto(out *RemoteTime) { *out = *in - out.RemoteCollectorMeta = in.RemoteCollectorMeta + in.RemoteCollectorMeta.DeepCopyInto(&out.RemoteCollectorMeta) } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RemoteTime. @@ -3414,7 +3440,7 @@ func (in *Removals) DeepCopy() *Removals { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ReplicaSetStatus) DeepCopyInto(out *ReplicaSetStatus) { *out = *in - out.AnalyzeMeta = in.AnalyzeMeta + in.AnalyzeMeta.DeepCopyInto(&out.AnalyzeMeta) if in.Outcomes != nil { in, out := &in.Outcomes, &out.Outcomes *out = make([]*Outcome, len(*in)) @@ -3466,7 +3492,7 @@ func (in *ResultRequest) DeepCopy() *ResultRequest { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *Run) DeepCopyInto(out *Run) { *out = *in - out.CollectorMeta = in.CollectorMeta + in.CollectorMeta.DeepCopyInto(&out.CollectorMeta) if in.Command != nil { in, out := &in.Command, &out.Command *out = make([]string, len(*in)) @@ -3497,7 +3523,7 @@ func (in *Run) DeepCopy() *Run { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *Secret) DeepCopyInto(out *Secret) { *out = *in - out.CollectorMeta = in.CollectorMeta + in.CollectorMeta.DeepCopyInto(&out.CollectorMeta) if in.Selector != nil { in, out := &in.Selector, &out.Selector *out = make([]string, len(*in)) @@ -3533,7 +3559,7 @@ func (in *SingleOutcome) DeepCopy() *SingleOutcome { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *StatefulsetStatus) DeepCopyInto(out *StatefulsetStatus) { *out = *in - out.AnalyzeMeta = in.AnalyzeMeta + in.AnalyzeMeta.DeepCopyInto(&out.AnalyzeMeta) if in.Outcomes != nil { in, out := &in.Outcomes, &out.Outcomes *out = make([]*Outcome, len(*in)) @@ -3565,7 +3591,7 @@ func (in *StatefulsetStatus) DeepCopy() *StatefulsetStatus { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *StorageClass) DeepCopyInto(out *StorageClass) { *out = *in - out.AnalyzeMeta = in.AnalyzeMeta + in.AnalyzeMeta.DeepCopyInto(&out.AnalyzeMeta) if in.Outcomes != nil { in, out := &in.Outcomes, &out.Outcomes *out = make([]*Outcome, len(*in)) @@ -3745,7 +3771,7 @@ func (in *SupportBundleVersionSpec) DeepCopy() *SupportBundleVersionSpec { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *Sysctl) DeepCopyInto(out *Sysctl) { *out = *in - out.CollectorMeta = in.CollectorMeta + in.CollectorMeta.DeepCopyInto(&out.CollectorMeta) if in.ImagePullSecret != nil { in, out := &in.ImagePullSecret, &out.ImagePullSecret *out = new(ImagePullSecrets) @@ -3766,7 +3792,7 @@ func (in *Sysctl) DeepCopy() *Sysctl { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *SysctlAnalyze) DeepCopyInto(out *SysctlAnalyze) { *out = *in - out.AnalyzeMeta = in.AnalyzeMeta + in.AnalyzeMeta.DeepCopyInto(&out.AnalyzeMeta) if in.Outcomes != nil { in, out := &in.Outcomes, &out.Outcomes *out = make([]*Outcome, len(*in)) @@ -3793,7 +3819,7 @@ func (in *SysctlAnalyze) DeepCopy() *SysctlAnalyze { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *SystemPackagesAnalyze) DeepCopyInto(out *SystemPackagesAnalyze) { *out = *in - out.AnalyzeMeta = in.AnalyzeMeta + in.AnalyzeMeta.DeepCopyInto(&out.AnalyzeMeta) if in.Outcomes != nil { in, out := &in.Outcomes, &out.Outcomes *out = make([]*Outcome, len(*in)) @@ -3820,7 +3846,7 @@ func (in *SystemPackagesAnalyze) DeepCopy() *SystemPackagesAnalyze { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *TCPConnect) DeepCopyInto(out *TCPConnect) { *out = *in - out.HostCollectorMeta = in.HostCollectorMeta + in.HostCollectorMeta.DeepCopyInto(&out.HostCollectorMeta) } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TCPConnect. @@ -3836,7 +3862,7 @@ func (in *TCPConnect) DeepCopy() *TCPConnect { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *TCPConnectAnalyze) DeepCopyInto(out *TCPConnectAnalyze) { *out = *in - out.AnalyzeMeta = in.AnalyzeMeta + in.AnalyzeMeta.DeepCopyInto(&out.AnalyzeMeta) if in.Outcomes != nil { in, out := &in.Outcomes, &out.Outcomes *out = make([]*Outcome, len(*in)) @@ -3863,7 +3889,7 @@ func (in *TCPConnectAnalyze) DeepCopy() *TCPConnectAnalyze { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *TCPLoadBalancer) DeepCopyInto(out *TCPLoadBalancer) { *out = *in - out.HostCollectorMeta = in.HostCollectorMeta + in.HostCollectorMeta.DeepCopyInto(&out.HostCollectorMeta) } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TCPLoadBalancer. @@ -3879,7 +3905,7 @@ func (in *TCPLoadBalancer) DeepCopy() *TCPLoadBalancer { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *TCPLoadBalancerAnalyze) DeepCopyInto(out *TCPLoadBalancerAnalyze) { *out = *in - out.AnalyzeMeta = in.AnalyzeMeta + in.AnalyzeMeta.DeepCopyInto(&out.AnalyzeMeta) if in.Outcomes != nil { in, out := &in.Outcomes, &out.Outcomes *out = make([]*Outcome, len(*in)) @@ -3906,7 +3932,7 @@ func (in *TCPLoadBalancerAnalyze) DeepCopy() *TCPLoadBalancerAnalyze { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *TCPPortStatus) DeepCopyInto(out *TCPPortStatus) { *out = *in - out.HostCollectorMeta = in.HostCollectorMeta + in.HostCollectorMeta.DeepCopyInto(&out.HostCollectorMeta) } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TCPPortStatus. @@ -3922,7 +3948,7 @@ func (in *TCPPortStatus) DeepCopy() *TCPPortStatus { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *TCPPortStatusAnalyze) DeepCopyInto(out *TCPPortStatusAnalyze) { *out = *in - out.AnalyzeMeta = in.AnalyzeMeta + in.AnalyzeMeta.DeepCopyInto(&out.AnalyzeMeta) if in.Outcomes != nil { in, out := &in.Outcomes, &out.Outcomes *out = make([]*Outcome, len(*in)) @@ -3949,7 +3975,7 @@ func (in *TCPPortStatusAnalyze) DeepCopy() *TCPPortStatusAnalyze { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *TextAnalyze) DeepCopyInto(out *TextAnalyze) { *out = *in - out.AnalyzeMeta = in.AnalyzeMeta + in.AnalyzeMeta.DeepCopyInto(&out.AnalyzeMeta) if in.Outcomes != nil { in, out := &in.Outcomes, &out.Outcomes *out = make([]*Outcome, len(*in)) @@ -3976,7 +4002,7 @@ func (in *TextAnalyze) DeepCopy() *TextAnalyze { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *TimeAnalyze) DeepCopyInto(out *TimeAnalyze) { *out = *in - out.AnalyzeMeta = in.AnalyzeMeta + in.AnalyzeMeta.DeepCopyInto(&out.AnalyzeMeta) if in.Outcomes != nil { in, out := &in.Outcomes, &out.Outcomes *out = make([]*Outcome, len(*in)) @@ -4003,7 +4029,7 @@ func (in *TimeAnalyze) DeepCopy() *TimeAnalyze { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *WeaveReportAnalyze) DeepCopyInto(out *WeaveReportAnalyze) { *out = *in - out.AnalyzeMeta = in.AnalyzeMeta + in.AnalyzeMeta.DeepCopyInto(&out.AnalyzeMeta) } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new WeaveReportAnalyze. diff --git a/pkg/collect/collector.go b/pkg/collect/collector.go index b0c117b93..2eda407c9 100644 --- a/pkg/collect/collector.go +++ b/pkg/collect/collector.go @@ -26,7 +26,11 @@ type Collector struct { type Collectors []*Collector -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 } diff --git a/pkg/collect/collector_test.go b/pkg/collect/collector_test.go index 4b828974f..a6580d454 100644 --- a/pkg/collect/collector_test.go +++ b/pkg/collect/collector_test.go @@ -21,7 +21,6 @@ func TestCollector_RunCollectorSyncNoRedact(t *testing.T) { Data: &troubleshootv1beta2.Data{ CollectorMeta: troubleshootv1beta2.CollectorMeta{ CollectorName: "datacollectorname", - Exclude: multitype.BoolOrString{}, }, Name: "data", Data: `abc 123 @@ -54,7 +53,6 @@ pwd=***HIDDEN***; Data: &troubleshootv1beta2.Data{ CollectorMeta: troubleshootv1beta2.CollectorMeta{ CollectorName: "datacollectorname", - Exclude: multitype.BoolOrString{}, }, Name: "data", Data: `abc 123 @@ -89,7 +87,6 @@ pwd=***HIDDEN***; Data: &troubleshootv1beta2.Data{ CollectorMeta: troubleshootv1beta2.CollectorMeta{ CollectorName: "datacollectorname", - Exclude: multitype.BoolOrString{}, }, Name: "data", Data: `abc 123 @@ -124,7 +121,6 @@ pwd=***HIDDEN***; Data: &troubleshootv1beta2.Data{ CollectorMeta: troubleshootv1beta2.CollectorMeta{ CollectorName: "datacollectorname", - Exclude: multitype.BoolOrString{}, }, Name: "data", Data: `abc 123 @@ -162,7 +158,6 @@ pwd=***HIDDEN***; Data: &troubleshootv1beta2.Data{ CollectorMeta: troubleshootv1beta2.CollectorMeta{ CollectorName: "data/collectorname", - Exclude: multitype.BoolOrString{}, }, Name: "data", Data: `abc 123 @@ -200,7 +195,6 @@ pwd=***HIDDEN***; Data: &troubleshootv1beta2.Data{ CollectorMeta: troubleshootv1beta2.CollectorMeta{ CollectorName: "datacollectorname", - Exclude: multitype.BoolOrString{}, }, Name: "data", Data: `abc 123 @@ -228,7 +222,6 @@ another line here Data: &troubleshootv1beta2.Data{ CollectorMeta: troubleshootv1beta2.CollectorMeta{ CollectorName: "datacollectorname", - Exclude: multitype.BoolOrString{}, }, Name: "data", Data: `xyz123 @@ -265,7 +258,7 @@ abc Data: &troubleshootv1beta2.Data{ CollectorMeta: troubleshootv1beta2.CollectorMeta{ CollectorName: "datacollectorname", - Exclude: multitype.BoolOrString{Type: multitype.String, StrVal: "true"}, + Exclude: multitype.FromString("true"), }, Name: "data", Data: `abc 123 @@ -310,7 +303,6 @@ func TestCollector_RunCollectorSync(t *testing.T) { Data: &troubleshootv1beta2.Data{ CollectorMeta: troubleshootv1beta2.CollectorMeta{ CollectorName: "datacollectorname", - Exclude: multitype.BoolOrString{}, }, Name: "data", Data: `abc 123 diff --git a/pkg/multitype/boolstring.go b/pkg/multitype/boolstring.go index eeee915a0..bb6f7e0a0 100644 --- a/pkg/multitype/boolstring.go +++ b/pkg/multitype/boolstring.go @@ -34,22 +34,25 @@ const ( ) // FromBool creates an BoolOrString object with a bool value. -func FromBool(val bool) BoolOrString { - return BoolOrString{Type: Bool, BoolVal: val} +func FromBool(val bool) *BoolOrString { + return &BoolOrString{Type: Bool, BoolVal: val} } // FromString creates an BoolOrString object with a string value. -func FromString(val string) BoolOrString { - return BoolOrString{Type: String, StrVal: val} +func FromString(val string) *BoolOrString { + return &BoolOrString{Type: String, StrVal: val} } // Parse the given string -func Parse(val string) BoolOrString { +func Parse(val string) *BoolOrString { return FromString(val) } // UnmarshalJSON implements the json.Unmarshaller boolerface. func (boolstr *BoolOrString) UnmarshalJSON(value []byte) error { + if boolstr == nil { + return nil + } if value[0] == '"' { boolstr.Type = String return json.Unmarshal(value, &boolstr.StrVal) @@ -60,6 +63,9 @@ func (boolstr *BoolOrString) UnmarshalJSON(value []byte) error { // String returns the string value, '1' for true, or '0' for false. func (boolstr *BoolOrString) String() string { + if boolstr == nil { + return "0" + } if boolstr.Type == String { return boolstr.StrVal } else if boolstr.BoolVal { @@ -70,7 +76,10 @@ func (boolstr *BoolOrString) String() string { } // MarshalJSON implements the json.Marshaller interface. -func (boolstr BoolOrString) MarshalJSON() ([]byte, error) { +func (boolstr *BoolOrString) MarshalJSON() ([]byte, error) { + if boolstr == nil { + return []byte{}, nil + } switch boolstr.Type { case Bool: return json.Marshal(boolstr.BoolVal) @@ -82,7 +91,10 @@ func (boolstr BoolOrString) MarshalJSON() ([]byte, error) { } // MarshalYAML implements the yaml.Marshaller interface https://godoc.org/gopkg.in/yaml.v3#Marshaler -func (boolstr BoolOrString) MarshalYAML() (interface{}, error) { +func (boolstr *BoolOrString) MarshalYAML() (interface{}, error) { + if boolstr == nil { + return []byte{}, nil + } switch boolstr.Type { case Bool: return boolstr.BoolVal, nil @@ -120,6 +132,9 @@ func (boolstr *BoolOrString) Fuzz(c fuzz.Continue) { // BoolOrDefaultFalse returns bool val, if strValu is parsed returns parsed value else false as default when parse error func (boolstr *BoolOrString) BoolOrDefaultFalse() bool { + if boolstr == nil { + return false + } val, err := boolstr.Bool() if err != nil { return false @@ -129,6 +144,9 @@ func (boolstr *BoolOrString) BoolOrDefaultFalse() bool { // Bool returns bool val, if strValu is parsed returns parsed value else false with parse error func (boolstr *BoolOrString) Bool() (bool, error) { + if boolstr == nil { + return false, nil + } if boolstr.Type == Bool { return boolstr.BoolVal, nil } diff --git a/pkg/multitype/boolstring_test.go b/pkg/multitype/boolstring_test.go index 93f9c80e6..f010a02fd 100644 --- a/pkg/multitype/boolstring_test.go +++ b/pkg/multitype/boolstring_test.go @@ -3,9 +3,12 @@ package multitype import ( + "encoding/json" + "strings" "testing" "github.com/stretchr/testify/require" + "gopkg.in/yaml.v2" ) func TestBoolOrString_Bool(t *testing.T) { @@ -87,3 +90,58 @@ func TestBoolOrString_Bool(t *testing.T) { }) } } + +func TestBoolOrString_MarshalOmitempty(t *testing.T) { + type S struct { + String string `json:"string,omitempty" yaml:"string,omitempty"` + Multi *BoolOrString `json:"multi,omitempty" yaml:"multi,omitempty"` + } + tests := []struct { + name string + wantJSON string + wantYAML string + }{ + { + wantJSON: `{"string":"string"}`, + wantYAML: "string: string", + }, + { + wantJSON: `{"string":"string","multi":false}`, + wantYAML: "string: string\nmulti: false", + }, + { + wantJSON: `{"string":"string","multi":"false"}`, + wantYAML: "string: string\nmulti: \"false\"", + }, + { + wantJSON: `{"string":"string","multi":true}`, + wantYAML: "string: string\nmulti: true", + }, + { + wantJSON: `{"string":"string","multi":"true"}`, + wantYAML: "string: string\nmulti: \"true\"", + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + req := require.New(t) + ass := require.New(t) + + var sJSON S + err := json.Unmarshal([]byte(tt.wantJSON), &sJSON) + req.NoError(err) + + out, err := json.Marshal(sJSON) + req.NoError(err) + ass.Equal(tt.wantJSON, strings.TrimSpace(string(out))) + + var sYAML S + err = json.Unmarshal([]byte(tt.wantJSON), &sYAML) + req.NoError(err) + + out, err = yaml.Marshal(sYAML) + req.NoError(err) + ass.Equal(tt.wantYAML, strings.TrimSpace(string(out))) + }) + } +} diff --git a/pkg/preflight/util_test.go b/pkg/preflight/util_test.go index 2fc5edd89..9805fa669 100644 --- a/pkg/preflight/util_test.go +++ b/pkg/preflight/util_test.go @@ -9,39 +9,39 @@ import ( var ( analyzeMetaStrictFalseStr = troubleshootv1beta2.AnalyzeMeta{ - Strict: multitype.BoolOrString{ + Strict: &multitype.BoolOrString{ StrVal: "false", }, } analyzeMetaStrictInvalidStr = troubleshootv1beta2.AnalyzeMeta{ - Strict: multitype.BoolOrString{ + Strict: &multitype.BoolOrString{ StrVal: "invalid", }, } analyzeMetaStrictTrueStr = troubleshootv1beta2.AnalyzeMeta{ - Strict: multitype.BoolOrString{ + Strict: &multitype.BoolOrString{ StrVal: "true", }, } analyzeMetaStrictFalseBool = troubleshootv1beta2.AnalyzeMeta{ - Strict: multitype.BoolOrString{ + Strict: &multitype.BoolOrString{ Type: multitype.Bool, BoolVal: false, }, } analyzeMetaStrictTrueBool = troubleshootv1beta2.AnalyzeMeta{ - Strict: multitype.BoolOrString{ + Strict: &multitype.BoolOrString{ Type: multitype.Bool, BoolVal: true, }, } analyzeMetaStrictFalseInt = troubleshootv1beta2.AnalyzeMeta{ - Strict: multitype.BoolOrString{ + Strict: &multitype.BoolOrString{ StrVal: "0", }, } analyzeMetaStrictTrueInt = troubleshootv1beta2.AnalyzeMeta{ - Strict: multitype.BoolOrString{ + Strict: &multitype.BoolOrString{ Type: multitype.String, StrVal: "1", },