Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix the golangci yml name #125

Merged
merged 1 commit into from
Jun 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions golangci.yml → .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,13 @@ run:

# default linters are enabled `golangci-lint help linters`
linters:
disable-all: true
enable:
- gosec
disable:
- depguard
- gochecknoglobals
- gochecknoinits
- lll
- errcheck
- gosec
- gosimple
- govet
- ineffassign
- staticcheck
- typecheck
- unused
12 changes: 7 additions & 5 deletions cmd/ocm-backplane/cloud/credentials_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,20 @@ import (
. "github.com/onsi/gomega"

cmv1 "github.com/openshift-online/ocm-sdk-go/clustersmgmt/v1"
"github.com/openshift/backplane-cli/pkg/cli/config"
"github.com/openshift/backplane-cli/pkg/client/mocks"
"github.com/openshift/backplane-cli/pkg/info"
"github.com/openshift/backplane-cli/pkg/utils"
mocks2 "github.com/openshift/backplane-cli/pkg/utils/mocks"
log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"k8s.io/client-go/tools/clientcmd"
"k8s.io/client-go/tools/clientcmd/api"
"sigs.k8s.io/yaml"

"github.com/openshift/backplane-cli/pkg/cli/config"
"github.com/openshift/backplane-cli/pkg/client/mocks"
"github.com/openshift/backplane-cli/pkg/info"
"github.com/openshift/backplane-cli/pkg/utils"
mocks2 "github.com/openshift/backplane-cli/pkg/utils/mocks"
)

//nolint:gosec
var _ = Describe("Cloud console command", func() {

var (
Expand Down
8 changes: 4 additions & 4 deletions cmd/ocm-backplane/testJob/createTestJob_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ var _ = Describe("testJob create command", func() {

tempDir, _ = os.MkdirTemp("", "createJobTest")

_ = os.WriteFile(path.Join(tempDir, "metadata.yaml"), []byte(MetadataYaml), 0755)
_ = os.WriteFile(path.Join(tempDir, "script.sh"), []byte("echo hello"), 0755)
_ = os.WriteFile(path.Join(tempDir, "metadata.yaml"), []byte(MetadataYaml), 0600)
_ = os.WriteFile(path.Join(tempDir, "script.sh"), []byte("echo hello"), 0600)

_ = os.Chdir(tempDir)

Expand Down Expand Up @@ -261,9 +261,9 @@ echo_touch "Hello"

GetGitRepoPath = exec.Command("echo", tempDir)
// tmp/createJobTest3397561583
_ = os.WriteFile(path.Join(tempDir, "script.sh"), []byte(script), 0755)
_ = os.WriteFile(path.Join(tempDir, "script.sh"), []byte(script), 0600)
_ = os.Mkdir(path.Join(tempDir, "scripts"), 0755)
_ = os.WriteFile(path.Join(tempDir, "scripts", "lib.sh"), []byte(lib), 0755)
_ = os.WriteFile(path.Join(tempDir, "scripts", "lib.sh"), []byte(lib), 0600)
mockOcmInterface.EXPECT().IsProduction().Return(false, nil)
// It should query for the internal cluster id first
mockOcmInterface.EXPECT().GetTargetCluster(testClusterId).Return(trueClusterId, testClusterId, nil)
Expand Down
4 changes: 2 additions & 2 deletions pkg/elevate/elevate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ import (
func fakeExecCommandError(command string, args ...string) *exec.Cmd {
cs := []string{"-test.run=TestHelperProcessError", "--", command}
cs = append(cs, args...)
cmd := exec.Command(os.Args[0], cs...)
cmd := exec.Command(os.Args[0], cs...) //#nosec: G204
cmd.Env = []string{"GO_WANT_HELPER_PROCESS=1"}
return cmd
}

func fakeExecCommandSuccess(command string, args ...string) *exec.Cmd {
cs := []string{"-test.run=TestHelperProcessSuccess", "--", command}
cs = append(cs, args...)
cmd := exec.Command(os.Args[0], cs...)
cmd := exec.Command(os.Args[0], cs...) //#nosec: G204
cmd.Env = []string{"GO_WANT_HELPER_PROCESS=1"}
return cmd
}
Expand Down
22 changes: 12 additions & 10 deletions pkg/monitoring/monitoring.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,24 @@ package monitoring
import (
"context"
"fmt"
"github.com/Masterminds/semver"
routev1typedclient "github.com/openshift/client-go/route/clientset/versioned/typed/route/v1"
userv1typedclient "github.com/openshift/client-go/user/clientset/versioned/typed/user/v1"
"github.com/pkg/browser"
logger "github.com/sirupsen/logrus"
"io"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
restclient "k8s.io/client-go/rest"
"k8s.io/client-go/tools/clientcmd"
"log"
"net"
"net/http"
"net/http/httputil"
"net/url"
"strings"

"github.com/Masterminds/semver"
"github.com/openshift/backplane-cli/pkg/cli/config"
"github.com/openshift/backplane-cli/pkg/utils"
routev1typedclient "github.com/openshift/client-go/route/clientset/versioned/typed/route/v1"
userv1typedclient "github.com/openshift/client-go/user/clientset/versioned/typed/user/v1"
"github.com/pkg/browser"
logger "github.com/sirupsen/logrus"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
restclient "k8s.io/client-go/rest"
"k8s.io/client-go/tools/clientcmd"
)

const (
Expand Down Expand Up @@ -138,7 +138,9 @@ func (c Client) RunMonitoring(monitoringType string) error {
if err != nil {
return err
}
http.DefaultTransport = &http.Transport{Proxy: http.ProxyURL(proxyUrl)}
http.DefaultTransport = &http.Transport{
Proxy: http.ProxyURL(proxyUrl),
}

logger.Debugf("Using backplane Proxy URL: %s\n", proxyUrl)
}
Expand Down Expand Up @@ -195,7 +197,7 @@ func (c Client) RunMonitoring(monitoringType string) error {
if !MonitoringOpts.Browser {
fmt.Printf("Serving %s at %s\n", monitoringType, serveUrl.String())
}
return http.Serve(l, proxy)
return http.Serve(l, proxy) //#nosec: G114
} else {
return nil
}
Expand Down