mirror of https://github.com/dapr/cli.git
Upgrade linter to 1.49.0 (#1051)
* Upgrade linter to 1.49.0 Signed-off-by: Mukundan Sundararajan <65565396+mukundansundar@users.noreply.github.com> * fix linter error Signed-off-by: Mukundan Sundararajan <65565396+mukundansundar@users.noreply.github.com> Signed-off-by: Mukundan Sundararajan <65565396+mukundansundar@users.noreply.github.com>
This commit is contained in:
parent
eaca34bc0d
commit
65855d5aa0
|
@ -30,7 +30,7 @@ jobs:
|
|||
runs-on: ${{ matrix.os }}
|
||||
env:
|
||||
GOVER: 1.18
|
||||
GOLANG_CI_LINT_VER: v1.46.2
|
||||
GOLANG_CI_LINT_VER: v1.49.0
|
||||
GOOS: ${{ matrix.target_os }}
|
||||
GOARCH: ${{ matrix.target_arch }}
|
||||
GOPROXY: https://proxy.golang.org
|
||||
|
@ -65,11 +65,10 @@ jobs:
|
|||
uses: golangci/golangci-lint-action@v3.2.0
|
||||
with:
|
||||
version: ${{ env.GOLANG_CI_LINT_VER }}
|
||||
only-new-issues: true
|
||||
skip-cache: true
|
||||
- name: Run make go.mod check-diff
|
||||
- name: Run make modtidy check-diff
|
||||
if: matrix.target_arch == 'amd64' && matrix.target_os == 'linux'
|
||||
run: make go.mod check-diff
|
||||
run: make modtidy check-diff
|
||||
- name: Parse release version and set REL_VERSION
|
||||
run: python ./.github/scripts/get_release_version.py
|
||||
- name: Setup test output
|
||||
|
|
|
@ -260,4 +260,5 @@ linters:
|
|||
- varnamelen
|
||||
- forcetypeassert
|
||||
- ireturn
|
||||
- golint
|
||||
- golint
|
||||
- nosnakecase
|
6
Makefile
6
Makefile
|
@ -184,10 +184,10 @@ test-e2e-sh: test-deps
|
|||
e2e-build-run-sh: build test-e2e-sh
|
||||
|
||||
################################################################################
|
||||
# Target: go.mod #
|
||||
# Target: modtidy #
|
||||
################################################################################
|
||||
.PHONY: go.mod
|
||||
go.mod:
|
||||
.PHONY: modtidy
|
||||
modtidy:
|
||||
go mod tidy -compat=1.18
|
||||
|
||||
################################################################################
|
||||
|
|
|
@ -113,7 +113,7 @@ WARNING: If an app id is not provided, we will generate one using the format '<n
|
|||
if annotateTargetResource != "" {
|
||||
config = kubernetes.K8sAnnotatorConfig{
|
||||
TargetResource: &annotateTargetResource,
|
||||
} // nolint:exhaustivestruct
|
||||
} //nolint:exhaustivestruct
|
||||
if annotateTargetNamespace != "" {
|
||||
config.TargetNamespace = &annotateTargetNamespace
|
||||
}
|
||||
|
|
|
@ -160,7 +160,7 @@ func (p *K8sAnnotator) processInput(input io.Reader, out io.Writer, opts Annotat
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
items = append(items, runtime.RawExtension{Raw: annotatedJSON}) // nolint:exhaustivestruct
|
||||
items = append(items, runtime.RawExtension{Raw: annotatedJSON}) //nolint:exhaustivestruct
|
||||
}
|
||||
sourceList.Items = items
|
||||
result, err = yaml.Marshal(sourceList)
|
||||
|
@ -235,7 +235,7 @@ func (p *K8sAnnotator) annotateYAML(input []byte, config AnnotateOptions) ([]byt
|
|||
kind := strings.ToLower(metaType.Kind)
|
||||
switch kind {
|
||||
case pod:
|
||||
pod := &corev1.Pod{} // nolint:exhaustivestruct
|
||||
pod := &corev1.Pod{} //nolint:exhaustivestruct
|
||||
if err := yaml.Unmarshal(input, pod); err != nil {
|
||||
return nil, false, err
|
||||
}
|
||||
|
@ -244,7 +244,7 @@ func (p *K8sAnnotator) annotateYAML(input []byte, config AnnotateOptions) ([]byt
|
|||
path = podAnnotationsPath
|
||||
ns = getNamespaceOrDefault(pod)
|
||||
case cronjob:
|
||||
cronjob := &batchv1beta1.CronJob{} // nolint:exhaustivestruct
|
||||
cronjob := &batchv1beta1.CronJob{} //nolint:exhaustivestruct
|
||||
if err := yaml.Unmarshal(input, cronjob); err != nil {
|
||||
return nil, false, err
|
||||
}
|
||||
|
@ -253,7 +253,7 @@ func (p *K8sAnnotator) annotateYAML(input []byte, config AnnotateOptions) ([]byt
|
|||
path = cronjobAnnotationsPath
|
||||
ns = getNamespaceOrDefault(cronjob)
|
||||
case deployment:
|
||||
deployment := &appsv1.Deployment{} // nolint:exhaustivestruct
|
||||
deployment := &appsv1.Deployment{} //nolint:exhaustivestruct
|
||||
if err := yaml.Unmarshal(input, deployment); err != nil {
|
||||
return nil, false, err
|
||||
}
|
||||
|
@ -262,7 +262,7 @@ func (p *K8sAnnotator) annotateYAML(input []byte, config AnnotateOptions) ([]byt
|
|||
path = templateAnnotationsPath
|
||||
ns = getNamespaceOrDefault(deployment)
|
||||
case replicaset:
|
||||
replicaset := &appsv1.ReplicaSet{} // nolint:exhaustivestruct
|
||||
replicaset := &appsv1.ReplicaSet{} //nolint:exhaustivestruct
|
||||
if err := yaml.Unmarshal(input, replicaset); err != nil {
|
||||
return nil, false, err
|
||||
}
|
||||
|
@ -271,7 +271,7 @@ func (p *K8sAnnotator) annotateYAML(input []byte, config AnnotateOptions) ([]byt
|
|||
path = templateAnnotationsPath
|
||||
ns = getNamespaceOrDefault(replicaset)
|
||||
case job:
|
||||
job := &batchv1.Job{} // nolint:exhaustivestruct
|
||||
job := &batchv1.Job{} //nolint:exhaustivestruct
|
||||
if err := yaml.Unmarshal(input, job); err != nil {
|
||||
return nil, false, err
|
||||
}
|
||||
|
@ -280,7 +280,7 @@ func (p *K8sAnnotator) annotateYAML(input []byte, config AnnotateOptions) ([]byt
|
|||
path = templateAnnotationsPath
|
||||
ns = getNamespaceOrDefault(job)
|
||||
case statefulset:
|
||||
statefulset := &appsv1.StatefulSet{} // nolint:exhaustivestruct
|
||||
statefulset := &appsv1.StatefulSet{} //nolint:exhaustivestruct
|
||||
if err := yaml.Unmarshal(input, statefulset); err != nil {
|
||||
return nil, false, err
|
||||
}
|
||||
|
@ -289,7 +289,7 @@ func (p *K8sAnnotator) annotateYAML(input []byte, config AnnotateOptions) ([]byt
|
|||
path = templateAnnotationsPath
|
||||
ns = getNamespaceOrDefault(statefulset)
|
||||
case daemonset:
|
||||
daemonset := &appsv1.DaemonSet{} // nolint:exhaustivestruct
|
||||
daemonset := &appsv1.DaemonSet{} //nolint:exhaustivestruct
|
||||
if err := yaml.Unmarshal(input, daemonset); err != nil {
|
||||
return nil, false, err
|
||||
}
|
||||
|
|
|
@ -47,7 +47,7 @@ type AnnotateOptions struct {
|
|||
type AnnoteOption func(*AnnotateOptions)
|
||||
|
||||
func NewAnnotateOptions(opts ...AnnoteOption) AnnotateOptions {
|
||||
config := AnnotateOptions{} // nolint:exhaustivestruct
|
||||
config := AnnotateOptions{} //nolint:exhaustivestruct
|
||||
for _, opt := range opts {
|
||||
opt(&config)
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@ type annotation struct {
|
|||
optionFactory func() AnnotateOptions
|
||||
}
|
||||
|
||||
// nolint
|
||||
//nolint:maintidx
|
||||
func TestAnnotate(t *testing.T) {
|
||||
// Helper function used to order test documents.
|
||||
sortDocs := func(docs []string) {
|
||||
|
|
|
@ -59,9 +59,7 @@ func Init(config InitConfiguration) error {
|
|||
|
||||
stopSpinning := print.Spinner(os.Stdout, msg)
|
||||
defer stopSpinning(print.Failure)
|
||||
// nolint
|
||||
err := install(config)
|
||||
if err != nil {
|
||||
if err := install(config); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ import (
|
|||
|
||||
const (
|
||||
systemConfigName = "daprsystem"
|
||||
trustBundleSecretName = "dapr-trust-bundle" // nolint:gosec
|
||||
trustBundleSecretName = "dapr-trust-bundle" //nolint:gosec
|
||||
warningDaysForCertExpiry = 30 // in days.
|
||||
)
|
||||
|
||||
|
|
|
@ -143,7 +143,7 @@ func applyCRDs(version string) error {
|
|||
for _, crd := range crds {
|
||||
url := fmt.Sprintf("https://raw.githubusercontent.com/dapr/dapr/%s/charts/dapr/crds/%s.yaml", version, crd)
|
||||
|
||||
resp, _ := http.Get(url) // nolint:gosec
|
||||
resp, _ := http.Get(url) //nolint:gosec
|
||||
if resp != nil && resp.StatusCode == 200 {
|
||||
defer resp.Body.Close()
|
||||
|
||||
|
|
|
@ -189,7 +189,7 @@ func (meta *DaprMeta) portExists(port int) bool {
|
|||
if port <= 0 {
|
||||
return false
|
||||
}
|
||||
// nolint
|
||||
//nolint
|
||||
_, ok := meta.ExistingPorts[port]
|
||||
if ok {
|
||||
return true
|
||||
|
@ -344,7 +344,7 @@ func getAppCommand(config *RunConfig) *exec.Cmd {
|
|||
}
|
||||
|
||||
func Run(config *RunConfig) (*RunOutput, error) {
|
||||
// nolint
|
||||
//nolint
|
||||
err := config.validate()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -355,7 +355,7 @@ func Run(config *RunConfig) (*RunOutput, error) {
|
|||
return nil, err
|
||||
}
|
||||
|
||||
// nolint
|
||||
//nolint
|
||||
var appCMD *exec.Cmd = getAppCommand(config)
|
||||
return &RunOutput{
|
||||
DaprCMD: daprCMD,
|
||||
|
|
|
@ -696,7 +696,7 @@ func createSlimConfiguration(wg *sync.WaitGroup, errorChan chan<- error, info in
|
|||
func makeDefaultComponentsDir() error {
|
||||
// Make default components directory.
|
||||
componentsDir := DefaultComponentsDirPath()
|
||||
// nolint
|
||||
//nolint
|
||||
_, err := os.Stat(componentsDir)
|
||||
if os.IsNotExist(err) {
|
||||
errDir := os.MkdirAll(componentsDir, 0o755)
|
||||
|
@ -821,7 +821,7 @@ func untar(reader io.Reader, targetDir string, binaryFilePrefix string) (string,
|
|||
foundBinary := ""
|
||||
for {
|
||||
header, err := tr.Next()
|
||||
// nolint
|
||||
//nolint
|
||||
if err == io.EOF {
|
||||
break
|
||||
} else if err != nil {
|
||||
|
@ -1068,7 +1068,7 @@ func downloadFile(dir string, url string) (string, error) {
|
|||
},
|
||||
}
|
||||
|
||||
req, err := http.NewRequest("GET", url, nil)
|
||||
req, err := http.NewRequest(http.MethodGet, url, nil)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
@ -1080,9 +1080,9 @@ func downloadFile(dir string, url string) (string, error) {
|
|||
|
||||
defer resp.Body.Close()
|
||||
|
||||
if resp.StatusCode == 404 {
|
||||
if resp.StatusCode == http.StatusNotFound {
|
||||
return "", fmt.Errorf("version not found from url: %s", url)
|
||||
} else if resp.StatusCode != 200 {
|
||||
} else if resp.StatusCode != http.StatusOK {
|
||||
return "", fmt.Errorf("download failed with %d", resp.StatusCode)
|
||||
}
|
||||
|
||||
|
|
|
@ -19,6 +19,7 @@ import (
|
|||
"net"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"time"
|
||||
|
||||
"github.com/dapr/cli/utils"
|
||||
)
|
||||
|
@ -48,7 +49,8 @@ func getTestServer(expectedPath, resp string) (*httptest.Server, int) {
|
|||
|
||||
func getTestSocketServerFunc(handler http.Handler, appID, path string) (*http.Server, net.Listener) {
|
||||
s := &http.Server{
|
||||
Handler: handler,
|
||||
Handler: handler,
|
||||
ReadHeaderTimeout: time.Duration(5) * time.Second,
|
||||
}
|
||||
|
||||
socket := utils.GetSocket(path, appID, "http")
|
||||
|
@ -61,7 +63,8 @@ func getTestSocketServerFunc(handler http.Handler, appID, path string) (*http.Se
|
|||
|
||||
func getTestSocketServer(expectedPath, resp, appID, path string) (*http.Server, net.Listener) {
|
||||
s := &http.Server{
|
||||
Handler: handlerTestPathResp(expectedPath, resp),
|
||||
Handler: handlerTestPathResp(expectedPath, resp),
|
||||
ReadHeaderTimeout: time.Duration(5) * time.Second,
|
||||
}
|
||||
|
||||
socket := utils.GetSocket(path, appID, "http")
|
||||
|
|
|
@ -71,7 +71,7 @@ func GetDaprVersion() (string, error) {
|
|||
}
|
||||
|
||||
func GetVersionFromURL(releaseURL string, parseVersion func(body []byte) (string, error)) (string, error) {
|
||||
req, err := http.NewRequest("GET", releaseURL, nil)
|
||||
req, err := http.NewRequest(http.MethodGet, releaseURL, nil)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ import (
|
|||
"fmt"
|
||||
"net/http"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
@ -163,7 +164,7 @@ func TestGetVersionsGithub(t *testing.T) {
|
|||
},
|
||||
}
|
||||
m := http.NewServeMux()
|
||||
s := http.Server{Addr: ":12345", Handler: m}
|
||||
s := http.Server{Addr: ":12345", Handler: m, ReadHeaderTimeout: time.Duration(5) * time.Second}
|
||||
|
||||
for _, tc := range tests {
|
||||
body := tc.ResponseBody
|
||||
|
@ -272,7 +273,7 @@ entries:
|
|||
},
|
||||
}
|
||||
m := http.NewServeMux()
|
||||
s := http.Server{Addr: ":12346", Handler: m}
|
||||
s := http.Server{Addr: ":12346", Handler: m, ReadHeaderTimeout: time.Duration(5) * time.Second}
|
||||
|
||||
for _, tc := range tests {
|
||||
body := tc.ResponseBody
|
||||
|
|
|
@ -77,7 +77,7 @@ var supportedUpgradePaths = []upgradePath{
|
|||
CustomResourceDefs: []string{"components.dapr.io", "configurations.dapr.io", "subscriptions.dapr.io", "resiliencies.dapr.io"},
|
||||
},
|
||||
},
|
||||
// test downgrade
|
||||
// test downgrade.
|
||||
{
|
||||
previous: common.VersionDetails{
|
||||
RuntimeVersion: "1.8.0",
|
||||
|
@ -121,13 +121,13 @@ func getTestsOnUpgrade(p upgradePath, installOpts, upgradeOpts common.TestOption
|
|||
details := p.next
|
||||
|
||||
tests = append(tests, []common.TestCase{
|
||||
{"upgrade to " + details.RuntimeVersion, common.UpgradeTest(details, upgradeOpts)},
|
||||
{"crds exist " + details.RuntimeVersion, common.CRDTest(details, upgradeOpts)},
|
||||
{"clusterroles exist " + details.RuntimeVersion, common.ClusterRolesTest(details, upgradeOpts)},
|
||||
{"clusterrolebindings exist " + details.RuntimeVersion, common.ClusterRoleBindingsTest(details, upgradeOpts)},
|
||||
{"previously applied components exist " + details.RuntimeVersion, common.ComponentsTestOnInstallUpgrade(upgradeOpts)},
|
||||
{"check mtls " + details.RuntimeVersion, common.MTLSTestOnInstallUpgrade(upgradeOpts)},
|
||||
{"status check " + details.RuntimeVersion, common.StatusTestOnInstallUpgrade(details, upgradeOpts)},
|
||||
{Name: "upgrade to " + details.RuntimeVersion, Callable: common.UpgradeTest(details, upgradeOpts)},
|
||||
{Name: "crds exist " + details.RuntimeVersion, Callable: common.CRDTest(details, upgradeOpts)},
|
||||
{Name: "clusterroles exist " + details.RuntimeVersion, Callable: common.ClusterRolesTest(details, upgradeOpts)},
|
||||
{Name: "clusterrolebindings exist " + details.RuntimeVersion, Callable: common.ClusterRoleBindingsTest(details, upgradeOpts)},
|
||||
{Name: "previously applied components exist " + details.RuntimeVersion, Callable: common.ComponentsTestOnInstallUpgrade(upgradeOpts)},
|
||||
{Name: "check mtls " + details.RuntimeVersion, Callable: common.MTLSTestOnInstallUpgrade(upgradeOpts)},
|
||||
{Name: "status check " + details.RuntimeVersion, Callable: common.StatusTestOnInstallUpgrade(details, upgradeOpts)},
|
||||
}...)
|
||||
|
||||
// uninstall.
|
||||
|
@ -141,8 +141,9 @@ func getTestsOnUpgrade(p upgradePath, installOpts, upgradeOpts common.TestOption
|
|||
})...)
|
||||
|
||||
// delete CRDs if exist.
|
||||
tests = append(tests, common.TestCase{"delete CRDs " + p.previous.RuntimeVersion, common.DeleteCRD(p.previous.CustomResourceDefs)})
|
||||
tests = append(tests, common.TestCase{"delete CRDs " + p.next.RuntimeVersion, common.DeleteCRD(p.next.CustomResourceDefs)})
|
||||
tests = append(tests,
|
||||
common.TestCase{Name: "delete CRDs " + p.previous.RuntimeVersion, Callable: common.DeleteCRD(p.previous.CustomResourceDefs)},
|
||||
common.TestCase{Name: "delete CRDs " + p.next.RuntimeVersion, Callable: common.DeleteCRD(p.next.CustomResourceDefs)})
|
||||
|
||||
return tests
|
||||
}
|
||||
|
|
|
@ -118,7 +118,7 @@ func RunCmdAndWait(name string, args ...string) (string, error) {
|
|||
}
|
||||
errB, err := io.ReadAll(stderr)
|
||||
if err != nil {
|
||||
// nolint
|
||||
//nolint
|
||||
return "", nil
|
||||
}
|
||||
|
||||
|
@ -151,7 +151,7 @@ func CreateDirectory(dir string) error {
|
|||
|
||||
// IsDockerInstalled checks whether docker is installed/running.
|
||||
func IsDockerInstalled() bool {
|
||||
// nolint:staticcheck
|
||||
//nolint:staticcheck
|
||||
cli, err := client.NewEnvClient()
|
||||
if err != nil {
|
||||
return false
|
||||
|
|
Loading…
Reference in New Issue