From 92382e600f6beb51b4164b2d3152cb451c3df501 Mon Sep 17 00:00:00 2001 From: Xav Paice Date: Thu, 8 Sep 2022 15:07:10 +1200 Subject: [PATCH] run make fmt across repo --- pkg/analyze/common_status.go | 6 ++--- pkg/analyze/deployment_status_test.go | 18 +++++++-------- pkg/analyze/host_kernel_modules.go | 1 - pkg/analyze/longhorn.go | 4 ++-- pkg/analyze/statefulset_status_test.go | 14 ++++++------ .../troubleshootclientset/fake/register.go | 14 ++++++------ .../troubleshootclientset/scheme/register.go | 14 ++++++------ pkg/collect/cluster_resources.go | 1 - pkg/collect/copy.go | 2 +- pkg/collect/host_kernel_modules.go | 22 +++++++++---------- .../clientset/versioned/fake/register.go | 14 ++++++------ .../clientset/versioned/scheme/register.go | 14 ++++++------ pkg/longhorn/types/resource.go | 3 +-- pkg/longhorn/types/types.go | 1 + 14 files changed, 63 insertions(+), 65 deletions(-) diff --git a/pkg/analyze/common_status.go b/pkg/analyze/common_status.go index cce09d2d3..316b20731 100644 --- a/pkg/analyze/common_status.go +++ b/pkg/analyze/common_status.go @@ -1,11 +1,11 @@ package analyzer import ( - "strconv" - "strings" "fmt" "github.com/pkg/errors" troubleshootv1beta2 "github.com/replicatedhq/troubleshoot/pkg/apis/troubleshoot/v1beta2" + "strconv" + "strings" ) func commonStatus(outcomes []*troubleshootv1beta2.Outcome, name string, iconKey string, iconURI string, readyReplicas int, exists bool, resourceType string) (*AnalyzeResult, error) { @@ -36,7 +36,7 @@ func commonStatus(outcomes []*troubleshootv1beta2.Outcome, name string, iconKey return result, nil } - if outcome.Fail.When == "absent" { + if outcome.Fail.When == "absent" { if exists == false { result.IsFail = true result.Message = outcome.Fail.Message diff --git a/pkg/analyze/deployment_status_test.go b/pkg/analyze/deployment_status_test.go index 663820820..43bcbd635 100644 --- a/pkg/analyze/deployment_status_test.go +++ b/pkg/analyze/deployment_status_test.go @@ -21,7 +21,7 @@ func Test_deploymentStatus(t *testing.T) { Outcomes: []*troubleshootv1beta2.Outcome{ { Fail: &troubleshootv1beta2.SingleOutcome{ - When: "absent", + When: "absent", Message: "fail", }, }, @@ -33,14 +33,14 @@ func Test_deploymentStatus(t *testing.T) { }, }, Namespace: "default", - Name: "nonexistant-deployment", + Name: "nonexistant-deployment", }, expectResult: []*AnalyzeResult{ { - IsPass: false, - IsWarn: false, - IsFail: true, - Title: "nonexistant-deployment Status", + IsPass: false, + IsWarn: false, + IsFail: true, + Title: "nonexistant-deployment Status", Message: "fail", IconKey: "kubernetes_deployment_status", IconURI: "https://troubleshoot.sh/images/analyzer-icons/deployment-status.svg?w=17&h=17", @@ -58,7 +58,7 @@ func Test_deploymentStatus(t *testing.T) { Outcomes: []*troubleshootv1beta2.Outcome{ { Fail: &troubleshootv1beta2.SingleOutcome{ - When: "absent", + When: "absent", Message: "fail", }, }, @@ -100,7 +100,7 @@ func Test_deploymentStatus(t *testing.T) { Outcomes: []*troubleshootv1beta2.Outcome{ { Fail: &troubleshootv1beta2.SingleOutcome{ - When: "absent", + When: "absent", Message: "fail", }, }, @@ -142,7 +142,7 @@ func Test_deploymentStatus(t *testing.T) { Outcomes: []*troubleshootv1beta2.Outcome{ { Fail: &troubleshootv1beta2.SingleOutcome{ - When: "absent", + When: "absent", Message: "fail", }, }, diff --git a/pkg/analyze/host_kernel_modules.go b/pkg/analyze/host_kernel_modules.go index 53af7cc8a..2b02f2c9d 100644 --- a/pkg/analyze/host_kernel_modules.go +++ b/pkg/analyze/host_kernel_modules.go @@ -40,7 +40,6 @@ func (a *AnalyzeHostKernelModules) IsExcluded() (bool, error) { // - a default fail will only trigger if there are no matching non-default pass outcomes. // - a default warn will only trigger if there are no matching non-default pass or fail outcomes. // - a default pass will only trigger if there are no matching non-default fail outcomes. -// func (a *AnalyzeHostKernelModules) Analyze(getCollectedFileContents func(string) ([]byte, error)) ([]*AnalyzeResult, error) { hostAnalyzer := a.hostAnalyzer contents, err := getCollectedFileContents(collect.HostKernelModulesPath) diff --git a/pkg/analyze/longhorn.go b/pkg/analyze/longhorn.go index c23608e67..d836a015a 100644 --- a/pkg/analyze/longhorn.go +++ b/pkg/analyze/longhorn.go @@ -133,8 +133,8 @@ func longhorn(analyzer *troubleshootv1beta2.LonghornAnalyze, getCollectedFileCon // Check Volume replicas if volume.Spec.NumberOfReplicas < 2 { result := &AnalyzeResult{ - Title: "Longhorn volume with low replicas", - IsWarn: true, + Title: "Longhorn volume with low replicas", + IsWarn: true, Message: fmt.Sprintf("Longhorn volume %s has less than two replicas, this could lead to issues with volume availability", volume.Name), } results = append(results, result) diff --git a/pkg/analyze/statefulset_status_test.go b/pkg/analyze/statefulset_status_test.go index 2a0887766..6597ca26b 100644 --- a/pkg/analyze/statefulset_status_test.go +++ b/pkg/analyze/statefulset_status_test.go @@ -21,7 +21,7 @@ func Test_analyzeStatefulsetStatus(t *testing.T) { Outcomes: []*troubleshootv1beta2.Outcome{ { Fail: &troubleshootv1beta2.SingleOutcome{ - When: "absent", + When: "absent", Message: "fail", }, }, @@ -33,21 +33,21 @@ func Test_analyzeStatefulsetStatus(t *testing.T) { }, }, Namespace: "default", - Name: "nonexistant", + Name: "nonexistant", }, expectResult: []*AnalyzeResult{ { - IsPass: false, - IsWarn: false, - IsFail: true, - Title: "nonexistant Status", + IsPass: false, + IsWarn: false, + IsFail: true, + Title: "nonexistant Status", Message: "fail", IconKey: "kubernetes_statefulset_status", IconURI: "https://troubleshoot.sh/images/analyzer-icons/statefulset-status.svg?w=23&h=14", }, }, files: map[string][]byte{ - "cluster-resources/statefulsets/default.json": []byte(defaultStatefulSets), + "cluster-resources/statefulsets/default.json": []byte(defaultStatefulSets), }, }, { diff --git a/pkg/client/troubleshootclientset/fake/register.go b/pkg/client/troubleshootclientset/fake/register.go index 89d94f581..8e4e17307 100644 --- a/pkg/client/troubleshootclientset/fake/register.go +++ b/pkg/client/troubleshootclientset/fake/register.go @@ -38,14 +38,14 @@ var localSchemeBuilder = runtime.SchemeBuilder{ // AddToScheme adds all types of this clientset into the given scheme. This allows composition // of clientsets, like in: // -// import ( -// "k8s.io/client-go/kubernetes" -// clientsetscheme "k8s.io/client-go/kubernetes/scheme" -// aggregatorclientsetscheme "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/scheme" -// ) +// import ( +// "k8s.io/client-go/kubernetes" +// clientsetscheme "k8s.io/client-go/kubernetes/scheme" +// aggregatorclientsetscheme "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/scheme" +// ) // -// kclientset, _ := kubernetes.NewForConfig(c) -// _ = aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme) +// kclientset, _ := kubernetes.NewForConfig(c) +// _ = aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme) // // After this, RawExtensions in Kubernetes types will serialize kube-aggregator types // correctly. diff --git a/pkg/client/troubleshootclientset/scheme/register.go b/pkg/client/troubleshootclientset/scheme/register.go index 6ff4d4891..10758a72c 100644 --- a/pkg/client/troubleshootclientset/scheme/register.go +++ b/pkg/client/troubleshootclientset/scheme/register.go @@ -38,14 +38,14 @@ var localSchemeBuilder = runtime.SchemeBuilder{ // AddToScheme adds all types of this clientset into the given scheme. This allows composition // of clientsets, like in: // -// import ( -// "k8s.io/client-go/kubernetes" -// clientsetscheme "k8s.io/client-go/kubernetes/scheme" -// aggregatorclientsetscheme "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/scheme" -// ) +// import ( +// "k8s.io/client-go/kubernetes" +// clientsetscheme "k8s.io/client-go/kubernetes/scheme" +// aggregatorclientsetscheme "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/scheme" +// ) // -// kclientset, _ := kubernetes.NewForConfig(c) -// _ = aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme) +// kclientset, _ := kubernetes.NewForConfig(c) +// _ = aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme) // // After this, RawExtensions in Kubernetes types will serialize kube-aggregator types // correctly. diff --git a/pkg/collect/cluster_resources.go b/pkg/collect/cluster_resources.go index 94d045181..15ae77b5a 100644 --- a/pkg/collect/cluster_resources.go +++ b/pkg/collect/cluster_resources.go @@ -185,7 +185,6 @@ func ClusterResources(c *Collector, clusterResourcesCollector *troubleshootv1bet } output.SaveResult(c.BundlePath, "cluster-resources/network-policy-errors.json", marshalErrors(networkPolicyErrors)) - // storage classes storageClasses, storageErrors := storageClasses(ctx, client) output.SaveResult(c.BundlePath, "cluster-resources/storage-classes.json", bytes.NewBuffer(storageClasses)) diff --git a/pkg/collect/copy.go b/pkg/collect/copy.go index a3e437153..71aa76bd0 100644 --- a/pkg/collect/copy.go +++ b/pkg/collect/copy.go @@ -19,7 +19,7 @@ import ( "k8s.io/client-go/tools/remotecommand" ) -//Copy function gets a file or folder from a container specified in the specs. +// Copy function gets a file or folder from a container specified in the specs. func Copy(c *Collector, copyCollector *troubleshootv1beta2.Copy) (CollectorResult, error) { client, err := kubernetes.NewForConfig(c.ClientConfig) if err != nil { diff --git a/pkg/collect/host_kernel_modules.go b/pkg/collect/host_kernel_modules.go index 2e4bccd90..ce7925d8d 100644 --- a/pkg/collect/host_kernel_modules.go +++ b/pkg/collect/host_kernel_modules.go @@ -60,17 +60,17 @@ func (c *CollectHostKernelModules) IsExcluded() (bool, error) { // Collect the kernel module status from the host. Modules are returned as a // map keyed on the module name used by the kernel, e.g: // -// { -// "system/kernel_modules.json": { -// ... -// "dm_snapshot": { -// "instances": 8, -// "size": 45056, -// "status": "loaded" -// }, -// ... -// }, -// } +// { +// "system/kernel_modules.json": { +// ... +// "dm_snapshot": { +// "instances": 8, +// "size": 45056, +// "status": "loaded" +// }, +// ... +// }, +// } // // Module status may be: loaded, loadable, loading, unloading or unknown. When // a module is loaded, it may have one or more instances. The size represents diff --git a/pkg/longhorn/client/clientset/versioned/fake/register.go b/pkg/longhorn/client/clientset/versioned/fake/register.go index 775215ae4..af24ad951 100644 --- a/pkg/longhorn/client/clientset/versioned/fake/register.go +++ b/pkg/longhorn/client/clientset/versioned/fake/register.go @@ -37,14 +37,14 @@ var localSchemeBuilder = runtime.SchemeBuilder{ // AddToScheme adds all types of this clientset into the given scheme. This allows composition // of clientsets, like in: // -// import ( -// "k8s.io/client-go/kubernetes" -// clientsetscheme "k8s.io/client-go/kubernetes/scheme" -// aggregatorclientsetscheme "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/scheme" -// ) +// import ( +// "k8s.io/client-go/kubernetes" +// clientsetscheme "k8s.io/client-go/kubernetes/scheme" +// aggregatorclientsetscheme "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/scheme" +// ) // -// kclientset, _ := kubernetes.NewForConfig(c) -// _ = aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme) +// kclientset, _ := kubernetes.NewForConfig(c) +// _ = aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme) // // After this, RawExtensions in Kubernetes types will serialize kube-aggregator types // correctly. diff --git a/pkg/longhorn/client/clientset/versioned/scheme/register.go b/pkg/longhorn/client/clientset/versioned/scheme/register.go index 8efc22342..011d440e4 100644 --- a/pkg/longhorn/client/clientset/versioned/scheme/register.go +++ b/pkg/longhorn/client/clientset/versioned/scheme/register.go @@ -37,14 +37,14 @@ var localSchemeBuilder = runtime.SchemeBuilder{ // AddToScheme adds all types of this clientset into the given scheme. This allows composition // of clientsets, like in: // -// import ( -// "k8s.io/client-go/kubernetes" -// clientsetscheme "k8s.io/client-go/kubernetes/scheme" -// aggregatorclientsetscheme "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/scheme" -// ) +// import ( +// "k8s.io/client-go/kubernetes" +// clientsetscheme "k8s.io/client-go/kubernetes/scheme" +// aggregatorclientsetscheme "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/scheme" +// ) // -// kclientset, _ := kubernetes.NewForConfig(c) -// _ = aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme) +// kclientset, _ := kubernetes.NewForConfig(c) +// _ = aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme) // // After this, RawExtensions in Kubernetes types will serialize kube-aggregator types // correctly. diff --git a/pkg/longhorn/types/resource.go b/pkg/longhorn/types/resource.go index 96497b9ca..6b91b4ef0 100644 --- a/pkg/longhorn/types/resource.go +++ b/pkg/longhorn/types/resource.go @@ -183,8 +183,7 @@ const ( ) // RecurringJob is a deprecated struct. -// TODO: Should be removed when recurringJobs gets removed from the volume -// spec. +// TODO: Should be removed when recurringJobs gets removed from the volume spec. type RecurringJob struct { Name string `json:"name"` Groups []string `json:"groups,omitempty"` diff --git a/pkg/longhorn/types/types.go b/pkg/longhorn/types/types.go index 0c22bdd90..31099475c 100644 --- a/pkg/longhorn/types/types.go +++ b/pkg/longhorn/types/types.go @@ -595,6 +595,7 @@ type DiskSpecWithName struct { // UnmarshalToDisks input format should be: // `[{"path":"/mnt/disk1","allowScheduling":false}, // {"path":"/mnt/disk2","allowScheduling":false,"storageReserved":1024,"tags":["ssd","fast"]}]` + func UnmarshalToDisks(s string) (ret []DiskSpecWithName, err error) { if err := json.Unmarshal([]byte(s), &ret); err != nil { return nil, err