Skip to content

Commit

Permalink
Merge pull request #703 from replicatedhq/xav/gofmt
Browse files Browse the repository at this point in the history
run make fmt across repo
  • Loading branch information
chris-sanders committed Sep 8, 2022
2 parents 91c387b + 92382e6 commit 7403e39
Show file tree
Hide file tree
Showing 14 changed files with 63 additions and 65 deletions.
6 changes: 3 additions & 3 deletions 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) {
Expand Down Expand Up @@ -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
Expand Down
18 changes: 9 additions & 9 deletions pkg/analyze/deployment_status_test.go
Expand Up @@ -21,7 +21,7 @@ func Test_deploymentStatus(t *testing.T) {
Outcomes: []*troubleshootv1beta2.Outcome{
{
Fail: &troubleshootv1beta2.SingleOutcome{
When: "absent",
When: "absent",
Message: "fail",
},
},
Expand All @@ -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",
Expand All @@ -58,7 +58,7 @@ func Test_deploymentStatus(t *testing.T) {
Outcomes: []*troubleshootv1beta2.Outcome{
{
Fail: &troubleshootv1beta2.SingleOutcome{
When: "absent",
When: "absent",
Message: "fail",
},
},
Expand Down Expand Up @@ -100,7 +100,7 @@ func Test_deploymentStatus(t *testing.T) {
Outcomes: []*troubleshootv1beta2.Outcome{
{
Fail: &troubleshootv1beta2.SingleOutcome{
When: "absent",
When: "absent",
Message: "fail",
},
},
Expand Down Expand Up @@ -142,7 +142,7 @@ func Test_deploymentStatus(t *testing.T) {
Outcomes: []*troubleshootv1beta2.Outcome{
{
Fail: &troubleshootv1beta2.SingleOutcome{
When: "absent",
When: "absent",
Message: "fail",
},
},
Expand Down
1 change: 0 additions & 1 deletion pkg/analyze/host_kernel_modules.go
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions pkg/analyze/longhorn.go
Expand Up @@ -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)
Expand Down
14 changes: 7 additions & 7 deletions pkg/analyze/statefulset_status_test.go
Expand Up @@ -21,7 +21,7 @@ func Test_analyzeStatefulsetStatus(t *testing.T) {
Outcomes: []*troubleshootv1beta2.Outcome{
{
Fail: &troubleshootv1beta2.SingleOutcome{
When: "absent",
When: "absent",
Message: "fail",
},
},
Expand All @@ -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),
},
},
{
Expand Down
14 changes: 7 additions & 7 deletions pkg/client/troubleshootclientset/fake/register.go

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

14 changes: 7 additions & 7 deletions pkg/client/troubleshootclientset/scheme/register.go

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

1 change: 0 additions & 1 deletion pkg/collect/cluster_resources.go
Expand Up @@ -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))
Expand Down
2 changes: 1 addition & 1 deletion pkg/collect/copy.go
Expand Up @@ -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 {
Expand Down
22 changes: 11 additions & 11 deletions pkg/collect/host_kernel_modules.go
Expand Up @@ -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
Expand Down
14 changes: 7 additions & 7 deletions pkg/longhorn/client/clientset/versioned/fake/register.go

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

14 changes: 7 additions & 7 deletions pkg/longhorn/client/clientset/versioned/scheme/register.go

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

3 changes: 1 addition & 2 deletions pkg/longhorn/types/resource.go
Expand Up @@ -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"`
Expand Down
1 change: 1 addition & 0 deletions pkg/longhorn/types/types.go
Expand Up @@ -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
Expand Down

0 comments on commit 7403e39

Please sign in to comment.