diff --git a/.github/workflows/dapr_cli.yaml b/.github/workflows/dapr_cli.yaml index 4233f7675..1983bdfea 100644 --- a/.github/workflows/dapr_cli.yaml +++ b/.github/workflows/dapr_cli.yaml @@ -29,7 +29,7 @@ jobs: name: Build ${{ matrix.target_os }}_${{ matrix.target_arch }} binaries runs-on: ${{ matrix.os }} env: - GOLANG_CI_LINT_VER: v1.51.2 + GOLANG_CI_LINT_VER: v1.55.2 GOOS: ${{ matrix.target_os }} GOARCH: ${{ matrix.target_arch }} GOPROXY: https://proxy.golang.org @@ -132,14 +132,14 @@ jobs: if: matrix.target_arch == 'amd64' && matrix.target_os == 'linux' run: | [ ! -z "${{ env.REL_VERSION }}" ] && echo "${{ env.REL_VERSION }}" > "${{ env.ARCHIVE_OUTDIR }}/release_version.txt" - - name: upload artifacts - uses: actions/upload-artifact@master + - name: upload artifacts ## Following migration guide in https://github.com/actions/upload-artifact/blob/main/docs/MIGRATION.md + uses: actions/upload-artifact@v4 with: - name: cli_drop + name: cli_drop-${{ matrix.target_os }}_${{ matrix.target_arch }} path: ${{ env.ARCHIVE_OUTDIR }} - name: Upload test results if: always() - uses: actions/upload-artifact@master + uses: actions/upload-artifact@v4 with: name: ${{ matrix.target_os }}_${{ matrix.target_arch }}_test_unit.json path: ${{ env.TEST_OUTPUT_FILE }} @@ -152,9 +152,10 @@ jobs: runs-on: ubuntu-latest steps: - name: download artifacts - uses: actions/download-artifact@master + uses: actions/download-artifact@v4 with: - name: cli_drop + pattern: cli_drop-* + merge-multiple: true path: ${{ env.ARTIFACT_DIR }} - name: Set Release Version run: | diff --git a/.github/workflows/kind_e2e.yaml b/.github/workflows/kind_e2e.yaml index 529b0138a..1e5c79826 100644 --- a/.github/workflows/kind_e2e.yaml +++ b/.github/workflows/kind_e2e.yaml @@ -195,7 +195,7 @@ jobs: shell: bash - name: Upload test results if: always() - uses: actions/upload-artifact@master + uses: actions/upload-artifact@v4 with: name: ${{ matrix.k8s-version }}_${{ matrix.mode }}_e2e_k8s.json path: ${{ env.TEST_OUTPUT_FILE }} diff --git a/.github/workflows/self_hosted_e2e.yaml b/.github/workflows/self_hosted_e2e.yaml index f9abdfcb0..a814ad281 100644 --- a/.github/workflows/self_hosted_e2e.yaml +++ b/.github/workflows/self_hosted_e2e.yaml @@ -40,8 +40,8 @@ jobs: ARCHIVE_OUTDIR: dist/archives DAPR_RUNTIME_PINNED_VERSION: "1.12.0" DAPR_DASHBOARD_PINNED_VERSION: 0.14.0 - DAPR_RUNTIME_LATEST_STABLE_VERSION: - DAPR_DASHBOARD_LATEST_STABLE_VERSION: + DAPR_RUNTIME_LATEST_STABLE_VERSION: "" + DAPR_DASHBOARD_LATEST_STABLE_VERSION: "" GOLANG_PROTOBUF_REGISTRATION_CONFLICT: warn PODMAN_VERSION: 4.4.4 strategy: @@ -179,7 +179,7 @@ jobs: shell: bash - name: Upload test results if: always() - uses: actions/upload-artifact@master + uses: actions/upload-artifact@v4 with: - name: ${{ matrix.target_os }}_${{ matrix.target_arch }}_e2e_standalone.json + name: ${{ matrix.target_os }}_${{ matrix.target_arch }}_${{ matrix.dapr_install_mode }}_e2e_standalone.json path: ${{ env.TEST_OUTPUT_FILE }} diff --git a/.github/workflows/upgrade_e2e.yaml b/.github/workflows/upgrade_e2e.yaml index fefc9570d..b6eb580d2 100644 --- a/.github/workflows/upgrade_e2e.yaml +++ b/.github/workflows/upgrade_e2e.yaml @@ -158,7 +158,7 @@ jobs: - name: Upload test results if: always() - uses: actions/upload-artifact@master + uses: actions/upload-artifact@v4 with: name: ${{ matrix.k8s-version }}_${{ matrix.mode }}_e2e_upgrade_k8s.json path: ${{ env.TEST_OUTPUT_FILE }} diff --git a/.golangci.yml b/.golangci.yml index 6e989ca69..d26599d7f 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -118,13 +118,11 @@ linters-settings: # minimal occurrences count to trigger, 3 by default min-occurrences: 5 depguard: - list-type: blacklist - include-go-root: false - packages: - - github.com/Sirupsen/logrus - packages-with-error-messages: - # specify an error message to output when a blacklisted package is used - github.com/Sirupsen/logrus: "must use github.com/sirupsen/logrus" + rules: + main: + deny: + - pkg: "github.com/Sirupsen/logrus" + desc: "must use github.com/sirupsen/logrus" misspell: # Correct spellings using locale preferences for US or UK. # Default is to use a neutral variety of English. @@ -216,7 +214,6 @@ linters-settings: # Allow multiline assignments to be cuddled. Default is true. allow-multiline-assign: true # Allow case blocks to end with a whitespace. - allow-case-traling-whitespace: true # Allow declarations (var) to be cuddled. allow-cuddle-declarations: false @@ -262,4 +259,10 @@ linters: - forcetypeassert - ireturn - golint - - nosnakecase \ No newline at end of file + - nosnakecase + - tagalign + - varcheck + - deadcode + - structcheck + - ifshort + - testifylint \ No newline at end of file diff --git a/cmd/dashboard.go b/cmd/dashboard.go index 7bf936898..d75be1b42 100644 --- a/cmd/dashboard.go +++ b/cmd/dashboard.go @@ -180,7 +180,7 @@ dapr dashboard -k -p 0 }() // url for dashboard after port forwarding. - webURL := fmt.Sprintf("http://%s", net.JoinHostPort(dashboardHost, fmt.Sprint(portForward.LocalPort))) + webURL := fmt.Sprintf("http://%s", net.JoinHostPort(dashboardHost, fmt.Sprint(portForward.LocalPort))) //nolint: perfsprint print.InfoStatusEvent(os.Stdout, fmt.Sprintf("Dapr dashboard found in namespace:\t%s", foundNamespace)) print.InfoStatusEvent(os.Stdout, fmt.Sprintf("Dapr dashboard available at:\t%s\n", webURL)) diff --git a/pkg/kubernetes/annotator.go b/pkg/kubernetes/annotator.go index 83c3955a4..251a9c646 100644 --- a/pkg/kubernetes/annotator.go +++ b/pkg/kubernetes/annotator.go @@ -82,7 +82,7 @@ const ( ) type Annotator interface { - Annotate(io.Reader, io.Writer) error + Annotate(io.Reader, io.Writer) error //nolint: inamedparam } type K8sAnnotator struct { diff --git a/pkg/kubernetes/annotator_test.go b/pkg/kubernetes/annotator_test.go index 97ecb6487..e038fc79a 100644 --- a/pkg/kubernetes/annotator_test.go +++ b/pkg/kubernetes/annotator_test.go @@ -2,11 +2,11 @@ package kubernetes import ( "bytes" - "fmt" "io" "os" "path" "sort" + "strconv" "strings" "testing" @@ -292,6 +292,7 @@ func TestAnnotate(t *testing.T) { var out bytes.Buffer in := []io.Reader{inputFile} for i, annotation := range tt.annotations { + annotation := annotation annotator := NewK8sAnnotator(K8sAnnotatorConfig{ TargetResource: &annotation.targetResource, TargetNamespace: &annotation.targetNamespace, @@ -423,7 +424,7 @@ func TestGetDaprAnnotations(t *testing.T) { assert.Equal(t, "true", annotations[daprEnabledKey]) assert.Equal(t, appID, annotations[daprAppIDKey]) - assert.Equal(t, fmt.Sprintf("%d", appPort), annotations[daprAppPortKey]) + assert.Equal(t, strconv.Itoa(appPort), annotations[daprAppPortKey]) assert.Equal(t, config, annotations[daprConfigKey]) assert.Equal(t, appProtocol, annotations[daprAppProtocolKey]) assert.Equal(t, "true", annotations[daprEnableProfilingKey]) @@ -431,31 +432,31 @@ func TestGetDaprAnnotations(t *testing.T) { assert.Equal(t, apiTokenSecret, annotations[daprAPITokenSecretKey]) assert.Equal(t, appTokenSecret, annotations[daprAppTokenSecretKey]) assert.Equal(t, "true", annotations[daprLogAsJSONKey]) - assert.Equal(t, fmt.Sprintf("%d", appMaxConcurrency), annotations[daprAppMaxConcurrencyKey]) + assert.Equal(t, strconv.Itoa(appMaxConcurrency), annotations[daprAppMaxConcurrencyKey]) assert.Equal(t, "true", annotations[daprEnableMetricsKey]) - assert.Equal(t, fmt.Sprintf("%d", metricsPort), annotations[daprMetricsPortKey]) + assert.Equal(t, strconv.Itoa(metricsPort), annotations[daprMetricsPortKey]) assert.Equal(t, "true", annotations[daprEnableDebugKey]) - assert.Equal(t, fmt.Sprintf("%d", debugPort), annotations[daprDebugPortKey]) + assert.Equal(t, strconv.Itoa(debugPort), annotations[daprDebugPortKey]) assert.Equal(t, env, annotations[daprEnvKey]) assert.Equal(t, cpuLimit, annotations[daprCPULimitKey]) assert.Equal(t, memoryLimit, annotations[daprMemoryLimitKey]) assert.Equal(t, cpuRequest, annotations[daprCPURequestKey]) assert.Equal(t, memoryRequest, annotations[daprMemoryRequestKey]) assert.Equal(t, listenAddresses, annotations[daprListenAddressesKey]) - assert.Equal(t, fmt.Sprintf("%d", livenessProbeDelay), annotations[daprLivenessProbeDelayKey]) - assert.Equal(t, fmt.Sprintf("%d", livenessProbeTimeout), annotations[daprLivenessProbeTimeoutKey]) - assert.Equal(t, fmt.Sprintf("%d", livenessProbePeriod), annotations[daprLivenessProbePeriodKey]) - assert.Equal(t, fmt.Sprintf("%d", livenessProbeThreshold), annotations[daprLivenessProbeThresholdKey]) - assert.Equal(t, fmt.Sprintf("%d", readinessProbeDelay), annotations[daprReadinessProbeDelayKey]) - assert.Equal(t, fmt.Sprintf("%d", readinessProbeTimeout), annotations[daprReadinessProbeTimeoutKey]) - assert.Equal(t, fmt.Sprintf("%d", readinessProbePeriod), annotations[daprReadinessProbePeriodKey]) - assert.Equal(t, fmt.Sprintf("%d", readinessProbeThreshold), annotations[daprReadinessProbeThresholdKey]) + assert.Equal(t, strconv.Itoa(livenessProbeDelay), annotations[daprLivenessProbeDelayKey]) + assert.Equal(t, strconv.Itoa(livenessProbeTimeout), annotations[daprLivenessProbeTimeoutKey]) + assert.Equal(t, strconv.Itoa(livenessProbePeriod), annotations[daprLivenessProbePeriodKey]) + assert.Equal(t, strconv.Itoa(livenessProbeThreshold), annotations[daprLivenessProbeThresholdKey]) + assert.Equal(t, strconv.Itoa(readinessProbeDelay), annotations[daprReadinessProbeDelayKey]) + assert.Equal(t, strconv.Itoa(readinessProbeTimeout), annotations[daprReadinessProbeTimeoutKey]) + assert.Equal(t, strconv.Itoa(readinessProbePeriod), annotations[daprReadinessProbePeriodKey]) + assert.Equal(t, strconv.Itoa(readinessProbeThreshold), annotations[daprReadinessProbeThresholdKey]) assert.Equal(t, daprImage, annotations[daprImageKey]) assert.Equal(t, "true", annotations[daprAppSSLKey]) - assert.Equal(t, fmt.Sprintf("%d", maxRequestBodySize), annotations[daprMaxRequestBodySizeKey]) - assert.Equal(t, fmt.Sprintf("%d", readBufferSize), annotations[daprReadBufferSizeKey]) + assert.Equal(t, strconv.Itoa(maxRequestBodySize), annotations[daprMaxRequestBodySizeKey]) + assert.Equal(t, strconv.Itoa(readBufferSize), annotations[daprReadBufferSizeKey]) assert.Equal(t, "true", annotations[daprHTTPStreamRequestBodyKey]) - assert.Equal(t, fmt.Sprintf("%d", gracefulShutdownSeconds), annotations[daprGracefulShutdownSecondsKey]) + assert.Equal(t, strconv.Itoa(gracefulShutdownSeconds), annotations[daprGracefulShutdownSecondsKey]) assert.Equal(t, "true", annotations[daprEnableAPILoggingKey]) assert.Equal(t, unixDomainSocketPath, annotations[daprUnixDomainSocketPathKey]) assert.Equal(t, volumeMountsReadOnly, annotations[daprVolumeMountsReadOnlyKey]) diff --git a/pkg/standalone/invoke.go b/pkg/standalone/invoke.go index df059912f..597b2730b 100644 --- a/pkg/standalone/invoke.go +++ b/pkg/standalone/invoke.go @@ -64,7 +64,7 @@ func (s *Standalone) Invoke(appID, method string, data []byte, verb string, path } func makeEndpoint(lo ListOutput, method string) string { - return fmt.Sprintf("http://127.0.0.1:%s/v%s/invoke/%s/method/%s", fmt.Sprintf("%v", lo.HTTPPort), api.RuntimeAPIVersion, lo.AppID, method) + return fmt.Sprintf("http://127.0.0.1:%s/v%s/invoke/%s/method/%s", fmt.Sprintf("%v", lo.HTTPPort), api.RuntimeAPIVersion, lo.AppID, method) //nolint: perfsprint } func handleResponse(response *http.Response) (string, error) { diff --git a/pkg/standalone/publish.go b/pkg/standalone/publish.go index b80c91841..30ae646fe 100644 --- a/pkg/standalone/publish.go +++ b/pkg/standalone/publish.go @@ -62,7 +62,7 @@ func (s *Standalone) Publish(publishAppID, pubsubName, topic string, payload []b }, } } else { - url = fmt.Sprintf("http://localhost:%s/v%s/publish/%s/%s%s", fmt.Sprintf("%v", instance.HTTPPort), api.RuntimeAPIVersion, pubsubName, topic, queryParams) + url = fmt.Sprintf("http://localhost:%s/v%s/publish/%s/%s%s", fmt.Sprintf("%v", instance.HTTPPort), api.RuntimeAPIVersion, pubsubName, topic, queryParams) //nolint: perfsprint } contentType := "application/json" diff --git a/pkg/standalone/stop.go b/pkg/standalone/stop.go index f70e80856..78a75a968 100644 --- a/pkg/standalone/stop.go +++ b/pkg/standalone/stop.go @@ -31,10 +31,10 @@ func Stop(appID string, cliPIDToNoOfApps map[int]int, apps []ListOutput) error { // Kill the Daprd process if Daprd was started without CLI, otherwise // kill the CLI process which also kills the associated Daprd process. if a.CliPID == 0 || cliPIDToNoOfApps[a.CliPID] > 1 { - pid = fmt.Sprintf("%v", a.DaprdPID) + pid = fmt.Sprintf("%v", a.DaprdPID) //nolint: perfsprint cliPIDToNoOfApps[a.CliPID]-- } else { - pid = fmt.Sprintf("%v", a.CliPID) + pid = fmt.Sprintf("%v", a.CliPID) //nolint: perfsprint } _, err := utils.RunCmdAndWait("kill", pid) @@ -57,7 +57,7 @@ func StopAppsWithRunFile(runTemplatePath string) error { pgid, err := syscall.Getpgid(a.CliPID) if err != nil { // Fall back to cliPID if pgid is not available. - _, err = utils.RunCmdAndWait("kill", fmt.Sprintf("%v", a.CliPID)) + _, err = utils.RunCmdAndWait("kill", fmt.Sprintf("%v", a.CliPID)) //nolint:perfsprint return err } // Kill the whole process group. diff --git a/tests/e2e/upgrade/upgrade_test.go b/tests/e2e/upgrade/upgrade_test.go index 865383b57..48c8f6a26 100644 --- a/tests/e2e/upgrade/upgrade_test.go +++ b/tests/e2e/upgrade/upgrade_test.go @@ -22,6 +22,8 @@ import ( "github.com/dapr/cli/tests/e2e/common" ) +const deleteCRDs = "delete CRDs " + type upgradePath struct { previous common.VersionDetails next common.VersionDetails @@ -129,8 +131,8 @@ func getTestsOnUpgrade(p upgradePath, installOpts, upgradeOpts common.TestOption // delete CRDs if exist. 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)}) + common.TestCase{Name: deleteCRDs + p.previous.RuntimeVersion, Callable: common.DeleteCRD(p.previous.CustomResourceDefs)}, + common.TestCase{Name: deleteCRDs + p.next.RuntimeVersion, Callable: common.DeleteCRD(p.next.CustomResourceDefs)}) return tests } @@ -142,8 +144,8 @@ func TestUpgradePathNonHAModeMTLSDisabled(t *testing.T) { common.EnsureUninstall(false, false) // does not wait for pod deletion. for _, p := range supportedUpgradePaths { t.Run(fmt.Sprintf("setup v%s to v%s", p.previous.RuntimeVersion, p.next.RuntimeVersion), func(t *testing.T) { - t.Run("delete CRDs "+p.previous.RuntimeVersion, common.DeleteCRD(p.previous.CustomResourceDefs)) - t.Run("delete CRDs "+p.next.RuntimeVersion, common.DeleteCRD(p.next.CustomResourceDefs)) + t.Run(deleteCRDs+p.previous.RuntimeVersion, common.DeleteCRD(p.previous.CustomResourceDefs)) + t.Run(deleteCRDs+p.next.RuntimeVersion, common.DeleteCRD(p.next.CustomResourceDefs)) }) } @@ -187,8 +189,8 @@ func TestUpgradePathNonHAModeMTLSEnabled(t *testing.T) { common.EnsureUninstall(false, false) // does not wait for pod deletion. for _, p := range supportedUpgradePaths { t.Run(fmt.Sprintf("setup v%s to v%s", p.previous.RuntimeVersion, p.next.RuntimeVersion), func(t *testing.T) { - t.Run("delete CRDs "+p.previous.RuntimeVersion, common.DeleteCRD(p.previous.CustomResourceDefs)) - t.Run("delete CRDs "+p.next.RuntimeVersion, common.DeleteCRD(p.next.CustomResourceDefs)) + t.Run(deleteCRDs+p.previous.RuntimeVersion, common.DeleteCRD(p.previous.CustomResourceDefs)) + t.Run(deleteCRDs+p.next.RuntimeVersion, common.DeleteCRD(p.next.CustomResourceDefs)) }) } @@ -232,8 +234,8 @@ func TestUpgradePathHAModeMTLSDisabled(t *testing.T) { common.EnsureUninstall(false, false) // does not wait for pod deletion. for _, p := range supportedUpgradePaths { t.Run(fmt.Sprintf("setup v%s to v%s", p.previous.RuntimeVersion, p.next.RuntimeVersion), func(t *testing.T) { - t.Run("delete CRDs "+p.previous.RuntimeVersion, common.DeleteCRD(p.previous.CustomResourceDefs)) - t.Run("delete CRDs "+p.next.RuntimeVersion, common.DeleteCRD(p.next.CustomResourceDefs)) + t.Run(deleteCRDs+p.previous.RuntimeVersion, common.DeleteCRD(p.previous.CustomResourceDefs)) + t.Run(deleteCRDs+p.next.RuntimeVersion, common.DeleteCRD(p.next.CustomResourceDefs)) }) } @@ -277,8 +279,8 @@ func TestUpgradePathHAModeMTLSEnabled(t *testing.T) { common.EnsureUninstall(false, false) // does not wait for pod deletion. for _, p := range supportedUpgradePaths { t.Run(fmt.Sprintf("setup v%s to v%s", p.previous.RuntimeVersion, p.next.RuntimeVersion), func(t *testing.T) { - t.Run("delete CRDs "+p.previous.RuntimeVersion, common.DeleteCRD(p.previous.CustomResourceDefs)) - t.Run("delete CRDs "+p.next.RuntimeVersion, common.DeleteCRD(p.next.CustomResourceDefs)) + t.Run(deleteCRDs+p.previous.RuntimeVersion, common.DeleteCRD(p.previous.CustomResourceDefs)) + t.Run(deleteCRDs+p.next.RuntimeVersion, common.DeleteCRD(p.next.CustomResourceDefs)) }) } @@ -324,8 +326,8 @@ func TestUpgradeWithHTTPEndpoint(t *testing.T) { common.EnsureUninstall(false, false) // does not wait for pod deletion. for _, p := range supportedUpgradePaths { t.Run(fmt.Sprintf("setup v%s to v%s", p.previous.RuntimeVersion, p.next.RuntimeVersion), func(t *testing.T) { - t.Run("delete CRDs "+p.previous.RuntimeVersion, common.DeleteCRD(p.previous.CustomResourceDefs)) - t.Run("delete CRDs "+p.next.RuntimeVersion, common.DeleteCRD(p.next.CustomResourceDefs)) + t.Run(deleteCRDs+p.previous.RuntimeVersion, common.DeleteCRD(p.previous.CustomResourceDefs)) + t.Run(deleteCRDs+p.next.RuntimeVersion, common.DeleteCRD(p.next.CustomResourceDefs)) }) }