mirror of
https://github.com/replicatedhq/troubleshoot.git
synced 2026-04-15 07:16:34 +00:00
Merge branch 'main' into main
This commit is contained in:
@@ -206,3 +206,79 @@ type Analyze struct {
|
||||
WeaveReport *WeaveReportAnalyze `json:"weaveReport,omitempty" yaml:"weaveReport,omitempty"`
|
||||
Sysctl *SysctlAnalyze `json:"sysctl,omitempty" yaml:"sysctl,omitempty"`
|
||||
}
|
||||
|
||||
func (a *Analyze) GetExclude() *multitype.BoolOrString {
|
||||
if a.ClusterVersion != nil {
|
||||
return a.ClusterVersion.Exclude
|
||||
}
|
||||
if a.StorageClass != nil {
|
||||
return a.StorageClass.Exclude
|
||||
}
|
||||
if a.CustomResourceDefinition != nil {
|
||||
return a.CustomResourceDefinition.Exclude
|
||||
}
|
||||
if a.Ingress != nil {
|
||||
return a.Ingress.Exclude
|
||||
}
|
||||
if a.Secret != nil {
|
||||
return a.Secret.Exclude
|
||||
}
|
||||
if a.ConfigMap != nil {
|
||||
return a.ConfigMap.Exclude
|
||||
}
|
||||
if a.ImagePullSecret != nil {
|
||||
return a.ImagePullSecret.Exclude
|
||||
}
|
||||
if a.DeploymentStatus != nil {
|
||||
return a.DeploymentStatus.Exclude
|
||||
}
|
||||
if a.StatefulsetStatus != nil {
|
||||
return a.StatefulsetStatus.Exclude
|
||||
}
|
||||
if a.JobStatus != nil {
|
||||
return a.JobStatus.Exclude
|
||||
}
|
||||
if a.ReplicaSetStatus != nil {
|
||||
return a.ReplicaSetStatus.Exclude
|
||||
}
|
||||
if a.ClusterPodStatuses != nil {
|
||||
return a.ClusterPodStatuses.Exclude
|
||||
}
|
||||
if a.ContainerRuntime != nil {
|
||||
return a.ContainerRuntime.Exclude
|
||||
}
|
||||
if a.Distribution != nil {
|
||||
return a.Distribution.Exclude
|
||||
}
|
||||
if a.NodeResources != nil {
|
||||
return a.NodeResources.Exclude
|
||||
}
|
||||
if a.TextAnalyze != nil {
|
||||
return a.TextAnalyze.Exclude
|
||||
}
|
||||
if a.Postgres != nil {
|
||||
return a.Postgres.Exclude
|
||||
}
|
||||
if a.Mysql != nil {
|
||||
return a.Mysql.Exclude
|
||||
}
|
||||
if a.Redis != nil {
|
||||
return a.Redis.Exclude
|
||||
}
|
||||
if a.CephStatus != nil {
|
||||
return a.CephStatus.Exclude
|
||||
}
|
||||
if a.Longhorn != nil {
|
||||
return a.Longhorn.Exclude
|
||||
}
|
||||
if a.RegistryImages != nil {
|
||||
return a.RegistryImages.Exclude
|
||||
}
|
||||
if a.WeaveReport != nil {
|
||||
return a.WeaveReport.Exclude
|
||||
}
|
||||
if a.Sysctl != nil {
|
||||
return a.Sysctl.Exclude
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -64,6 +64,9 @@ func hasStrictAnalyzer(analyzerMap map[string]interface{}) (bool, error) {
|
||||
if err != nil {
|
||||
return false, errors.Wrap(err, "error while un-marshalling marshalledAnalyzers")
|
||||
}
|
||||
if analyzeMeta.Exclude.BoolOrDefaultFalse() {
|
||||
continue
|
||||
}
|
||||
if analyzeMeta.Strict.BoolOrDefaultFalse() {
|
||||
return true, nil
|
||||
}
|
||||
|
||||
@@ -46,6 +46,16 @@ var (
|
||||
StrVal: "1",
|
||||
},
|
||||
}
|
||||
analyzeMetaStrictTrueExcludeTrue = troubleshootv1beta2.AnalyzeMeta{
|
||||
Exclude: &multitype.BoolOrString{
|
||||
Type: multitype.Bool,
|
||||
BoolVal: true,
|
||||
},
|
||||
Strict: &multitype.BoolOrString{
|
||||
Type: multitype.Bool,
|
||||
BoolVal: true,
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
func TestHasStrictAnalyzers(t *testing.T) {
|
||||
@@ -238,6 +248,36 @@ func TestHasStrictAnalyzers(t *testing.T) {
|
||||
want: true,
|
||||
wantErr: false,
|
||||
},
|
||||
{
|
||||
name: "expect false when preflight spec's analyzer has analyzer with strict true and exclude true",
|
||||
preflight: &troubleshootv1beta2.Preflight{
|
||||
Spec: troubleshootv1beta2.PreflightSpec{
|
||||
Analyzers: []*troubleshootv1beta2.Analyze{
|
||||
{
|
||||
ClusterVersion: &troubleshootv1beta2.ClusterVersion{AnalyzeMeta: analyzeMetaStrictTrueExcludeTrue},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
want: false,
|
||||
wantErr: false,
|
||||
},
|
||||
{
|
||||
name: "expect true when preflight spec's analyzer has analyzer with strict true in one of multiple analyzers, but one analyzer with strict true is exclude true",
|
||||
preflight: &troubleshootv1beta2.Preflight{
|
||||
Spec: troubleshootv1beta2.PreflightSpec{
|
||||
Analyzers: []*troubleshootv1beta2.Analyze{
|
||||
{
|
||||
ClusterVersion: &troubleshootv1beta2.ClusterVersion{AnalyzeMeta: analyzeMetaStrictTrueExcludeTrue},
|
||||
StorageClass: &troubleshootv1beta2.StorageClass{AnalyzeMeta: analyzeMetaStrictFalseInt},
|
||||
Secret: &troubleshootv1beta2.AnalyzeSecret{AnalyzeMeta: analyzeMetaStrictTrueBool},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
want: true,
|
||||
wantErr: false,
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user