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 }}
|
runs-on: ${{ matrix.os }}
|
||||||
env:
|
env:
|
||||||
GOVER: 1.18
|
GOVER: 1.18
|
||||||
GOLANG_CI_LINT_VER: v1.46.2
|
GOLANG_CI_LINT_VER: v1.49.0
|
||||||
GOOS: ${{ matrix.target_os }}
|
GOOS: ${{ matrix.target_os }}
|
||||||
GOARCH: ${{ matrix.target_arch }}
|
GOARCH: ${{ matrix.target_arch }}
|
||||||
GOPROXY: https://proxy.golang.org
|
GOPROXY: https://proxy.golang.org
|
||||||
|
|
@ -65,11 +65,10 @@ jobs:
|
||||||
uses: golangci/golangci-lint-action@v3.2.0
|
uses: golangci/golangci-lint-action@v3.2.0
|
||||||
with:
|
with:
|
||||||
version: ${{ env.GOLANG_CI_LINT_VER }}
|
version: ${{ env.GOLANG_CI_LINT_VER }}
|
||||||
only-new-issues: true
|
|
||||||
skip-cache: 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'
|
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
|
- name: Parse release version and set REL_VERSION
|
||||||
run: python ./.github/scripts/get_release_version.py
|
run: python ./.github/scripts/get_release_version.py
|
||||||
- name: Setup test output
|
- name: Setup test output
|
||||||
|
|
|
||||||
|
|
@ -261,3 +261,4 @@ linters:
|
||||||
- forcetypeassert
|
- forcetypeassert
|
||||||
- ireturn
|
- 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
|
e2e-build-run-sh: build test-e2e-sh
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
# Target: go.mod #
|
# Target: modtidy #
|
||||||
################################################################################
|
################################################################################
|
||||||
.PHONY: go.mod
|
.PHONY: modtidy
|
||||||
go.mod:
|
modtidy:
|
||||||
go mod tidy -compat=1.18
|
go mod tidy -compat=1.18
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ type annotation struct {
|
||||||
optionFactory func() AnnotateOptions
|
optionFactory func() AnnotateOptions
|
||||||
}
|
}
|
||||||
|
|
||||||
// nolint
|
//nolint:maintidx
|
||||||
func TestAnnotate(t *testing.T) {
|
func TestAnnotate(t *testing.T) {
|
||||||
// Helper function used to order test documents.
|
// Helper function used to order test documents.
|
||||||
sortDocs := func(docs []string) {
|
sortDocs := func(docs []string) {
|
||||||
|
|
|
||||||
|
|
@ -59,9 +59,7 @@ func Init(config InitConfiguration) error {
|
||||||
|
|
||||||
stopSpinning := print.Spinner(os.Stdout, msg)
|
stopSpinning := print.Spinner(os.Stdout, msg)
|
||||||
defer stopSpinning(print.Failure)
|
defer stopSpinning(print.Failure)
|
||||||
// nolint
|
if err := install(config); err != nil {
|
||||||
err := install(config)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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 {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
@ -1080,9 +1080,9 @@ func downloadFile(dir string, url string) (string, error) {
|
||||||
|
|
||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
|
|
||||||
if resp.StatusCode == 404 {
|
if resp.StatusCode == http.StatusNotFound {
|
||||||
return "", fmt.Errorf("version not found from url: %s", url)
|
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)
|
return "", fmt.Errorf("download failed with %d", resp.StatusCode)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,7 @@ import (
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/http/httptest"
|
"net/http/httptest"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/dapr/cli/utils"
|
"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) {
|
func getTestSocketServerFunc(handler http.Handler, appID, path string) (*http.Server, net.Listener) {
|
||||||
s := &http.Server{
|
s := &http.Server{
|
||||||
Handler: handler,
|
Handler: handler,
|
||||||
|
ReadHeaderTimeout: time.Duration(5) * time.Second,
|
||||||
}
|
}
|
||||||
|
|
||||||
socket := utils.GetSocket(path, appID, "http")
|
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) {
|
func getTestSocketServer(expectedPath, resp, appID, path string) (*http.Server, net.Listener) {
|
||||||
s := &http.Server{
|
s := &http.Server{
|
||||||
Handler: handlerTestPathResp(expectedPath, resp),
|
Handler: handlerTestPathResp(expectedPath, resp),
|
||||||
|
ReadHeaderTimeout: time.Duration(5) * time.Second,
|
||||||
}
|
}
|
||||||
|
|
||||||
socket := utils.GetSocket(path, appID, "http")
|
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) {
|
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 {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"testing"
|
"testing"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
|
|
@ -163,7 +164,7 @@ func TestGetVersionsGithub(t *testing.T) {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
m := http.NewServeMux()
|
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 {
|
for _, tc := range tests {
|
||||||
body := tc.ResponseBody
|
body := tc.ResponseBody
|
||||||
|
|
@ -272,7 +273,7 @@ entries:
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
m := http.NewServeMux()
|
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 {
|
for _, tc := range tests {
|
||||||
body := tc.ResponseBody
|
body := tc.ResponseBody
|
||||||
|
|
|
||||||
|
|
@ -77,7 +77,7 @@ var supportedUpgradePaths = []upgradePath{
|
||||||
CustomResourceDefs: []string{"components.dapr.io", "configurations.dapr.io", "subscriptions.dapr.io", "resiliencies.dapr.io"},
|
CustomResourceDefs: []string{"components.dapr.io", "configurations.dapr.io", "subscriptions.dapr.io", "resiliencies.dapr.io"},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
// test downgrade
|
// test downgrade.
|
||||||
{
|
{
|
||||||
previous: common.VersionDetails{
|
previous: common.VersionDetails{
|
||||||
RuntimeVersion: "1.8.0",
|
RuntimeVersion: "1.8.0",
|
||||||
|
|
@ -121,13 +121,13 @@ func getTestsOnUpgrade(p upgradePath, installOpts, upgradeOpts common.TestOption
|
||||||
details := p.next
|
details := p.next
|
||||||
|
|
||||||
tests = append(tests, []common.TestCase{
|
tests = append(tests, []common.TestCase{
|
||||||
{"upgrade to " + details.RuntimeVersion, common.UpgradeTest(details, upgradeOpts)},
|
{Name: "upgrade to " + details.RuntimeVersion, Callable: common.UpgradeTest(details, upgradeOpts)},
|
||||||
{"crds exist " + details.RuntimeVersion, common.CRDTest(details, upgradeOpts)},
|
{Name: "crds exist " + details.RuntimeVersion, Callable: common.CRDTest(details, upgradeOpts)},
|
||||||
{"clusterroles exist " + details.RuntimeVersion, common.ClusterRolesTest(details, upgradeOpts)},
|
{Name: "clusterroles exist " + details.RuntimeVersion, Callable: common.ClusterRolesTest(details, upgradeOpts)},
|
||||||
{"clusterrolebindings exist " + details.RuntimeVersion, common.ClusterRoleBindingsTest(details, upgradeOpts)},
|
{Name: "clusterrolebindings exist " + details.RuntimeVersion, Callable: common.ClusterRoleBindingsTest(details, upgradeOpts)},
|
||||||
{"previously applied components exist " + details.RuntimeVersion, common.ComponentsTestOnInstallUpgrade(upgradeOpts)},
|
{Name: "previously applied components exist " + details.RuntimeVersion, Callable: common.ComponentsTestOnInstallUpgrade(upgradeOpts)},
|
||||||
{"check mtls " + details.RuntimeVersion, common.MTLSTestOnInstallUpgrade(upgradeOpts)},
|
{Name: "check mtls " + details.RuntimeVersion, Callable: common.MTLSTestOnInstallUpgrade(upgradeOpts)},
|
||||||
{"status check " + details.RuntimeVersion, common.StatusTestOnInstallUpgrade(details, upgradeOpts)},
|
{Name: "status check " + details.RuntimeVersion, Callable: common.StatusTestOnInstallUpgrade(details, upgradeOpts)},
|
||||||
}...)
|
}...)
|
||||||
|
|
||||||
// uninstall.
|
// uninstall.
|
||||||
|
|
@ -141,8 +141,9 @@ func getTestsOnUpgrade(p upgradePath, installOpts, upgradeOpts common.TestOption
|
||||||
})...)
|
})...)
|
||||||
|
|
||||||
// delete CRDs if exist.
|
// delete CRDs if exist.
|
||||||
tests = append(tests, common.TestCase{"delete CRDs " + p.previous.RuntimeVersion, common.DeleteCRD(p.previous.CustomResourceDefs)})
|
tests = append(tests,
|
||||||
tests = append(tests, common.TestCase{"delete CRDs " + p.next.RuntimeVersion, common.DeleteCRD(p.next.CustomResourceDefs)})
|
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
|
return tests
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue