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:
Mukundan Sundararajan 2022-08-25 16:58:54 +05:30 committed by GitHub
parent eaca34bc0d
commit 65855d5aa0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
17 changed files with 52 additions and 49 deletions

View File

@ -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

View File

@ -261,3 +261,4 @@ linters:
- forcetypeassert
- ireturn
- golint
- nosnakecase

View File

@ -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
################################################################################

View File

@ -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) {

View File

@ -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
}

View File

@ -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)
}

View File

@ -19,6 +19,7 @@ import (
"net"
"net/http"
"net/http/httptest"
"time"
"github.com/dapr/cli/utils"
)
@ -49,6 +50,7 @@ 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,
ReadHeaderTimeout: time.Duration(5) * time.Second,
}
socket := utils.GetSocket(path, appID, "http")
@ -62,6 +64,7 @@ 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),
ReadHeaderTimeout: time.Duration(5) * time.Second,
}
socket := utils.GetSocket(path, appID, "http")

View File

@ -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
}

View File

@ -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

View File

@ -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
}