Update dependencies, Go version and address CVEs (#1474)

* Update dependencies, Go version and address CVEs

Signed-off-by: Anton Troshin <anton@diagrid.io>

* update golangci-lint version and list of disabled linters form dapr/dapr

Signed-off-by: Anton Troshin <anton@diagrid.io>

* adjust golangci-lint settings and fix lint issues

Signed-off-by: Anton Troshin <anton@diagrid.io>

* fix test

Signed-off-by: Anton Troshin <anton@diagrid.io>

---------

Signed-off-by: Anton Troshin <anton@diagrid.io>
This commit is contained in:
Anton Troshin 2025-01-09 16:16:44 -06:00 committed by GitHub
parent efe1d6c1e2
commit 17f4785906
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
37 changed files with 610 additions and 1459 deletions

View File

@ -29,7 +29,7 @@ jobs:
name: Build ${{ matrix.target_os }}_${{ matrix.target_arch }} binaries name: Build ${{ matrix.target_os }}_${{ matrix.target_arch }} binaries
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
env: env:
GOLANG_CI_LINT_VER: v1.55.2 GOLANG_CI_LINT_VER: v1.61.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

View File

@ -4,7 +4,7 @@ run:
concurrency: 4 concurrency: 4
# timeout for analysis, e.g. 30s, 5m, default is 1m # timeout for analysis, e.g. 30s, 5m, default is 1m
deadline: 10m timeout: 10m
# exit code when at least one issue was found, default is 1 # exit code when at least one issue was found, default is 1
issues-exit-code: 1 issues-exit-code: 1
@ -16,28 +16,22 @@ run:
#build-tags: #build-tags:
# - mytag # - mytag
issues:
# which dirs to skip: they won't be analyzed; # which dirs to skip: they won't be analyzed;
# can use regexp here: generated.*, regexp is applied on full path; # can use regexp here: generated.*, regexp is applied on full path;
# default value is empty list, but next dirs are always skipped independently # default value is empty list, but next dirs are always skipped independently
# from this option's value: # from this option's value:
# third_party$, testdata$, examples$, Godeps$, builtin$ # third_party$, testdata$, examples$, Godeps$, builtin$
skip-dirs: exclude-dirs:
- ^pkg.*client.*clientset.*versioned.* - ^pkg.*client.*clientset.*versioned.*
- ^pkg.*client.*informers.*externalversions.* - ^pkg.*client.*informers.*externalversions.*
- pkg.*mod.*k8s.io.* - pkg.*mod.*k8s.io.*
# which files to skip: they will be analyzed, but issues from them
# won't be reported. Default value is empty list, but there is
# no need to include all autogenerated files, we confidently recognize
# autogenerated files. If it's not please let us know.
skip-files: []
# - ".*\\.my\\.go$"
# - lib/bad.go
# output configuration options # output configuration options
output: output:
# colored-line-number|line-number|json|tab|checkstyle, default is "colored-line-number" # colored-line-number|line-number|json|tab|checkstyle, default is "colored-line-number"
format: tab formats:
- format: tab
# print lines of code with issue, default is true # print lines of code with issue, default is true
print-issued-lines: true print-issued-lines: true
@ -71,9 +65,6 @@ linters-settings:
statements: 40 statements: 40
govet: govet:
# report about shadowed variables
check-shadowing: true
# settings per analyzer # settings per analyzer
settings: settings:
printf: # analyzer name, run `go tool vet help` to see all analyzers printf: # analyzer name, run `go tool vet help` to see all analyzers
@ -82,13 +73,18 @@ linters-settings:
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Warnf - (github.com/golangci/golangci-lint/pkg/logutils.Log).Warnf
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Errorf - (github.com/golangci/golangci-lint/pkg/logutils.Log).Errorf
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Fatalf - (github.com/golangci/golangci-lint/pkg/logutils.Log).Fatalf
- github.com/dapr/cli/pkg/print.FailureStatusEvent
- github.com/dapr/cli/pkg/print.SuccessStatusEvent
- github.com/dapr/cli/pkg/print.WarningStatusEvent
- github.com/dapr/cli/pkg/print.InfoStatusEvent
- github.com/dapr/cli/pkg/print.StatusEvent
- github.com/dapr/cli/pkg/print.Spinner
# enable or disable analyzers by name # enable or disable analyzers by name
enable: enable:
- atomicalign - atomicalign
enable-all: false
disable:
- shadow - shadow
enable-all: false
disable-all: false disable-all: false
revive: revive:
# linting errors below this confidence will be ignored, default is 0.8 # linting errors below this confidence will be ignored, default is 0.8
@ -106,9 +102,6 @@ linters-settings:
gocognit: gocognit:
# minimal code complexity to report, 30 by default (but we recommend 10-20) # minimal code complexity to report, 30 by default (but we recommend 10-20)
min-complexity: 10 min-complexity: 10
maligned:
# print struct with more effective memory layout or not, false by default
suggest-new: true
dupl: dupl:
# tokens count to trigger issue, 150 by default # tokens count to trigger issue, 150 by default
threshold: 100 threshold: 100
@ -141,7 +134,7 @@ linters-settings:
# XXX: if you enable this setting, unused will report a lot of false-positives in text editors: # XXX: if you enable this setting, unused will report a lot of false-positives in text editors:
# if it's called for subdir of a project it can't find funcs usages. All text editor integrations # if it's called for subdir of a project it can't find funcs usages. All text editor integrations
# with golangci-lint call it on a directory with the changed file. # with golangci-lint call it on a directory with the changed file.
check-exported: false exported-fields-are-used: false
unparam: unparam:
# Inspect exported functions, default is false. Set to true if no external program/library imports your code. # Inspect exported functions, default is false. Set to true if no external program/library imports your code.
# XXX: if you enable this setting, unparam will report a lot of false-positives in text editors: # XXX: if you enable this setting, unparam will report a lot of false-positives in text editors:
@ -216,12 +209,17 @@ linters-settings:
# Allow case blocks to end with a whitespace. # Allow case blocks to end with a whitespace.
# Allow declarations (var) to be cuddled. # Allow declarations (var) to be cuddled.
allow-cuddle-declarations: false allow-cuddle-declarations: false
testifylint:
disable:
- require-error
linters: linters:
fast: false fast: false
enable-all: true enable-all: true
disable: disable:
# TODO Enforce the below linters later # TODO Enforce the below linters later
- musttag
- dupl - dupl
- errcheck - errcheck
- funlen - funlen
@ -230,39 +228,48 @@ linters:
- gocyclo - gocyclo
- gocognit - gocognit
- godox - godox
- interfacer
- lll - lll
- maligned
- scopelint
- unparam - unparam
- wsl - wsl
- gomnd - gomnd
- testpackage - testpackage
- nestif - nestif
- goerr113
- nlreturn - nlreturn
- exhaustive - exhaustive
- gci
- noctx
- exhaustivestruct
- exhaustruct - exhaustruct
- gomoddirectives - noctx
- paralleltest - gci
- tparallel - tparallel
- wastedassign - paralleltest
- cyclop
- forbidigo
- tagliatelle
- thelper
- wrapcheck - wrapcheck
- varnamelen - tagliatelle
- forcetypeassert
- ireturn - ireturn
- golint - errchkjson
- nosnakecase - contextcheck
- gomoddirectives
- godot
- cyclop
- varnamelen
- errorlint
- forcetypeassert
- maintidx
- nilnil
- predeclared
- tenv
- thelper
- wastedassign
- containedctx
- gosimple
- nonamedreturns
- asasalint
- rowserrcheck
- sqlclosecheck
- inamedparam
- tagalign - tagalign
- varcheck - mnd
- deadcode - canonicalheader
- structcheck - exportloopref
- ifshort - execinquery
- testifylint - err113
- fatcontext
- forbidigo

View File

@ -182,7 +182,7 @@ dapr dashboard -k -p 0
// url for dashboard after port forwarding. // url for dashboard after port forwarding.
webURL := fmt.Sprintf("http://%s", net.JoinHostPort(dashboardHost, fmt.Sprint(portForward.LocalPort))) //nolint: perfsprint 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, "Dapr dashboard found in namespace:\t"+foundNamespace)
print.InfoStatusEvent(os.Stdout, fmt.Sprintf("Dapr dashboard available at:\t%s\n", webURL)) print.InfoStatusEvent(os.Stdout, fmt.Sprintf("Dapr dashboard available at:\t%s\n", webURL))
err = browser.OpenURL(webURL) err = browser.OpenURL(webURL)

View File

@ -67,7 +67,7 @@ dapr mtls export -o ./certs
} }
dir, _ := filepath.Abs(exportPath) dir, _ := filepath.Abs(exportPath)
print.SuccessStatusEvent(os.Stdout, fmt.Sprintf("Trust certs successfully exported to %s", dir)) print.SuccessStatusEvent(os.Stdout, "Trust certs successfully exported to "+dir)
}, },
PostRun: func(cmd *cobra.Command, args []string) { PostRun: func(cmd *cobra.Command, args []string) {
kubernetes.CheckForCertExpiry() kubernetes.CheckForCertExpiry()

View File

@ -103,7 +103,7 @@ dapr mtls renew-cert -k --valid-until <no of days> --restart
print.InfoStatusEvent(os.Stdout, "Using password file to generate root certificate") print.InfoStatusEvent(os.Stdout, "Using password file to generate root certificate")
err = kubernetes.RenewCertificate(kubernetes.RenewCertificateParams{ err = kubernetes.RenewCertificate(kubernetes.RenewCertificateParams{
RootPrivateKeyFilePath: privateKey, RootPrivateKeyFilePath: privateKey,
ValidUntil: time.Hour * time.Duration(validUntil*24), ValidUntil: time.Hour * time.Duration(validUntil*24), //nolint:gosec
Timeout: timeout, Timeout: timeout,
ImageVariant: imageVariant, ImageVariant: imageVariant,
}) })
@ -113,7 +113,7 @@ dapr mtls renew-cert -k --valid-until <no of days> --restart
} else { } else {
print.InfoStatusEvent(os.Stdout, "generating fresh certificates") print.InfoStatusEvent(os.Stdout, "generating fresh certificates")
err = kubernetes.RenewCertificate(kubernetes.RenewCertificateParams{ err = kubernetes.RenewCertificate(kubernetes.RenewCertificateParams{
ValidUntil: time.Hour * time.Duration(validUntil*24), ValidUntil: time.Hour * time.Duration(validUntil*24), //nolint:gosec
Timeout: timeout, Timeout: timeout,
ImageVariant: imageVariant, ImageVariant: imageVariant,
}) })
@ -129,7 +129,7 @@ dapr mtls renew-cert -k --valid-until <no of days> --restart
logErrorAndExit(err) logErrorAndExit(err)
} }
print.SuccessStatusEvent(os.Stdout, print.SuccessStatusEvent(os.Stdout,
fmt.Sprintf("Certificate rotation is successful! Your new certicate is valid through %s", expiry.Format(time.RFC1123))) "Certificate rotation is successful! Your new certicate is valid through "+expiry.Format(time.RFC1123))
if restartDaprServices { if restartDaprServices {
restartControlPlaneService() restartControlPlaneService()

View File

@ -319,14 +319,14 @@ dapr run --run-file /path/to/directory -k
stdErrPipe, pipeErr := output.AppCMD.StderrPipe() stdErrPipe, pipeErr := output.AppCMD.StderrPipe()
if pipeErr != nil { if pipeErr != nil {
print.FailureStatusEvent(os.Stderr, fmt.Sprintf("Error creating stderr for App: %s", err.Error())) print.FailureStatusEvent(os.Stderr, "Error creating stderr for App: "+err.Error())
appRunning <- false appRunning <- false
return return
} }
stdOutPipe, pipeErr := output.AppCMD.StdoutPipe() stdOutPipe, pipeErr := output.AppCMD.StdoutPipe()
if pipeErr != nil { if pipeErr != nil {
print.FailureStatusEvent(os.Stderr, fmt.Sprintf("Error creating stdout for App: %s", err.Error())) print.FailureStatusEvent(os.Stderr, "Error creating stdout for App: "+err.Error())
appRunning <- false appRunning <- false
return return
} }
@ -335,13 +335,13 @@ dapr run --run-file /path/to/directory -k
outScanner := bufio.NewScanner(stdOutPipe) outScanner := bufio.NewScanner(stdOutPipe)
go func() { go func() {
for errScanner.Scan() { for errScanner.Scan() {
fmt.Println(print.Blue(fmt.Sprintf("== APP == %s", errScanner.Text()))) fmt.Println(print.Blue("== APP == " + errScanner.Text()))
} }
}() }()
go func() { go func() {
for outScanner.Scan() { for outScanner.Scan() {
fmt.Println(print.Blue(fmt.Sprintf("== APP == %s", outScanner.Text()))) fmt.Println(print.Blue("== APP == " + outScanner.Text()))
} }
}() }()
@ -395,7 +395,7 @@ dapr run --run-file /path/to/directory -k
} }
appCommand := strings.Join(args, " ") appCommand := strings.Join(args, " ")
print.InfoStatusEvent(os.Stdout, fmt.Sprintf("Updating metadata for app command: %s", appCommand)) print.InfoStatusEvent(os.Stdout, "Updating metadata for app command: "+appCommand)
err = metadata.Put(output.DaprHTTPPort, "appCommand", appCommand, output.AppID, unixDomainSocket) err = metadata.Put(output.DaprHTTPPort, "appCommand", appCommand, output.AppID, unixDomainSocket)
if err != nil { if err != nil {
print.WarningStatusEvent(os.Stdout, "Could not update sidecar metadata for appCommand: %s", err.Error()) print.WarningStatusEvent(os.Stdout, "Could not update sidecar metadata for appCommand: %s", err.Error())

295
go.mod
View File

@ -1,125 +1,102 @@
module github.com/dapr/cli module github.com/dapr/cli
go 1.21 go 1.23.1
require ( require (
github.com/Azure/go-autorest/autorest v0.11.28 // indirect github.com/Masterminds/semver v1.5.0
github.com/Azure/go-autorest/autorest/adal v0.9.22 // indirect github.com/Masterminds/semver/v3 v3.3.0
github.com/Pallinder/sillyname-go v0.0.0-20130730142914-97aeae9e6ba1 github.com/Pallinder/sillyname-go v0.0.0-20130730142914-97aeae9e6ba1
github.com/briandowns/spinner v1.19.0 github.com/briandowns/spinner v1.19.0
github.com/dapr/dapr v1.13.0-rc.6 github.com/dapr/dapr v1.15.0-rc.3.0.20250107220753-e073759df4c1
github.com/dapr/go-sdk v1.6.1-0.20240209153236-ac26e622c4a6 github.com/dapr/go-sdk v1.11.0
github.com/docker/docker v20.10.21+incompatible github.com/dapr/kit v0.13.1-0.20241127165251-30e2c24840b4
github.com/fatih/color v1.15.0 github.com/docker/docker v25.0.6+incompatible
github.com/evanphx/json-patch/v5 v5.9.0
github.com/fatih/color v1.17.0
github.com/gocarina/gocsv v0.0.0-20220927221512-ad3251f9fa25 github.com/gocarina/gocsv v0.0.0-20220927221512-ad3251f9fa25
github.com/hashicorp/go-retryablehttp v0.7.1 github.com/hashicorp/go-retryablehttp v0.7.7
github.com/hashicorp/go-version v1.6.0 github.com/hashicorp/go-version v1.6.0
github.com/kolesnikovae/go-winjob v1.0.0
github.com/mitchellh/go-ps v1.0.0 github.com/mitchellh/go-ps v1.0.0
github.com/nightlyone/lockfile v1.0.0 github.com/nightlyone/lockfile v1.0.0
github.com/olekukonko/tablewriter v0.0.5 github.com/olekukonko/tablewriter v0.0.5
github.com/phayes/freeport v0.0.0-20220201140144-74d24b5ae9f5 github.com/phayes/freeport v0.0.0-20220201140144-74d24b5ae9f5
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c
github.com/shirou/gopsutil v3.21.11+incompatible github.com/shirou/gopsutil v3.21.11+incompatible
github.com/spf13/cobra v1.8.0 github.com/spf13/cobra v1.8.1
github.com/spf13/viper v1.13.0 github.com/spf13/viper v1.13.0
github.com/stretchr/testify v1.8.4 github.com/stretchr/testify v1.9.0
golang.org/x/sys v0.18.0 golang.org/x/mod v0.22.0
golang.org/x/sys v0.28.0
gopkg.in/yaml.v2 v2.4.0 gopkg.in/yaml.v2 v2.4.0
helm.sh/helm/v3 v3.11.1 helm.sh/helm/v3 v3.16.4
k8s.io/api v0.28.4 k8s.io/api v0.31.3
k8s.io/apiextensions-apiserver v0.28.4 k8s.io/apiextensions-apiserver v0.31.3
k8s.io/apimachinery v0.28.4 k8s.io/apimachinery v0.31.3
k8s.io/cli-runtime v0.28.4 k8s.io/cli-runtime v0.31.3
k8s.io/client-go v0.28.4 k8s.io/client-go v0.31.3
k8s.io/helm v2.16.10+incompatible k8s.io/helm v2.16.10+incompatible
sigs.k8s.io/yaml v1.4.0 sigs.k8s.io/yaml v1.4.0
) )
require ( require (
github.com/Masterminds/semver/v3 v3.2.0
golang.org/x/mod v0.14.0
)
require (
github.com/alphadose/haxmap v1.3.1 // indirect
github.com/antlr4-go/antlr/v4 v4.13.0 // indirect
github.com/armon/go-metrics v0.4.1 // indirect
github.com/boltdb/bolt v1.3.1 // indirect
github.com/evanphx/json-patch v5.7.0+incompatible // indirect
github.com/go-chi/chi/v5 v5.0.11 // indirect
github.com/go-chi/cors v1.2.1 // indirect
github.com/hashicorp/go-hclog v1.5.0 // indirect
github.com/hashicorp/go-immutable-radix v1.3.1 // indirect
github.com/hashicorp/go-msgpack v0.5.5 // indirect
github.com/hashicorp/go-msgpack/v2 v2.1.1 // indirect
github.com/hashicorp/golang-lru v1.0.2 // indirect
github.com/hashicorp/raft v1.4.0 // indirect
github.com/hashicorp/raft-boltdb v0.0.0-20230125174641-2a8082862702 // indirect
github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0 // indirect
github.com/panjf2000/ants/v2 v2.8.1 // indirect
github.com/segmentio/asm v1.2.0 // indirect
github.com/sourcegraph/conc v0.3.0 // indirect
github.com/spiffe/go-spiffe/v2 v2.1.6 // indirect
github.com/zeebo/errs v1.3.0 // indirect
go.mongodb.org/mongo-driver v1.12.1 // indirect
go.opentelemetry.io/otel/metric v1.23.1 // indirect
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/tools v0.17.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240116215550-a9fa1716bcac // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240205150955-31a09d347014 // indirect
)
require (
cloud.google.com/go/compute v1.23.3 // indirect
cloud.google.com/go/compute/metadata v0.2.3 // indirect
contrib.go.opencensus.io/exporter/prometheus v0.4.2 // indirect contrib.go.opencensus.io/exporter/prometheus v0.4.2 // indirect
github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 // indirect dario.cat/mergo v1.0.1 // indirect
github.com/Azure/go-autorest v14.2.0+incompatible // indirect github.com/AdaLogics/go-fuzz-headers v0.0.0-20230811130428-ced1acdcaa24 // indirect
github.com/Azure/go-autorest/autorest/date v0.3.0 // indirect github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 // indirect
github.com/Azure/go-autorest/logger v0.2.1 // indirect github.com/BurntSushi/toml v1.3.2 // indirect
github.com/Azure/go-autorest/tracing v0.6.0 // indirect github.com/Code-Hex/go-generics-cache v1.3.1 // indirect
github.com/BurntSushi/toml v1.2.1 // indirect
github.com/MakeNowJust/heredoc v1.0.0 // indirect github.com/MakeNowJust/heredoc v1.0.0 // indirect
github.com/Masterminds/goutils v1.1.1 // indirect github.com/Masterminds/goutils v1.1.1 // indirect
github.com/Masterminds/semver v1.5.0 github.com/Masterminds/sprig/v3 v3.3.0 // indirect
github.com/Masterminds/sprig/v3 v3.2.3 // indirect github.com/Masterminds/squirrel v1.5.4 // indirect
github.com/Masterminds/squirrel v1.5.3 // indirect github.com/Microsoft/go-winio v0.6.2 // indirect
github.com/Microsoft/go-winio v0.6.0 // indirect
github.com/Microsoft/hcsshim v0.9.6 // indirect
github.com/PuerkitoBio/purell v1.2.1 // indirect github.com/PuerkitoBio/purell v1.2.1 // indirect
github.com/andybalholm/brotli v1.0.6 // indirect github.com/aavaz-ai/pii-scrubber v0.0.0-20220812094047-3fa450ab6973 // indirect
github.com/alphadose/haxmap v1.4.0 // indirect
github.com/anshal21/go-worker v1.1.0 // indirect
github.com/antlr4-go/antlr/v4 v4.13.0 // indirect
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 // indirect github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 // indirect
github.com/beorn7/perks v1.0.1 // indirect github.com/beorn7/perks v1.0.1 // indirect
github.com/blang/semver/v4 v4.0.0 // indirect
github.com/bufbuild/protocompile v0.6.0 // indirect github.com/bufbuild/protocompile v0.6.0 // indirect
github.com/cenkalti/backoff/v4 v4.2.1 // indirect github.com/cenkalti/backoff/v4 v4.3.0 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/chai2010/gettext-go v1.0.2 // indirect github.com/chai2010/gettext-go v1.0.2 // indirect
github.com/chebyrash/promise v0.0.0-20230709133807-42ec49ba1459 // indirect github.com/chebyrash/promise v0.0.0-20230709133807-42ec49ba1459 // indirect
github.com/cloudevents/sdk-go/binding/format/protobuf/v2 v2.14.0 // indirect github.com/cloudevents/sdk-go/binding/format/protobuf/v2 v2.14.0 // indirect
github.com/cloudevents/sdk-go/v2 v2.14.0 // indirect github.com/cloudevents/sdk-go/v2 v2.15.2 // indirect
github.com/containerd/containerd v1.6.18 // indirect github.com/containerd/containerd v1.7.23 // indirect
github.com/containerd/continuity v0.3.0 // indirect github.com/containerd/errdefs v0.3.0 // indirect
github.com/cyphar/filepath-securejoin v0.2.4 // indirect github.com/containerd/log v0.1.0 // indirect
github.com/dapr/components-contrib v1.13.0-rc.4 // indirect github.com/containerd/platforms v0.2.1 // indirect
github.com/dapr/kit v0.13.0 github.com/cyphar/filepath-securejoin v0.3.4 // indirect
github.com/dapr/components-contrib v1.15.0-rc.1.0.20241216170750-aca5116d95c9 // indirect
github.com/dapr/durabletask-go v0.5.1-0.20241216172832-16da3e7c3530 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 // indirect github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 // indirect
github.com/docker/cli v20.10.21+incompatible // indirect github.com/distribution/reference v0.6.0 // indirect
github.com/docker/distribution v2.8.1+incompatible // indirect github.com/dlclark/regexp2 v1.10.0 // indirect
github.com/docker/cli v25.0.1+incompatible // indirect
github.com/docker/distribution v2.8.3+incompatible // indirect
github.com/docker/docker-credential-helpers v0.7.0 // indirect github.com/docker/docker-credential-helpers v0.7.0 // indirect
github.com/docker/go-connections v0.4.0 // indirect github.com/docker/go-connections v0.5.0 // indirect
github.com/docker/go-metrics v0.0.1 // indirect github.com/docker/go-metrics v0.0.1 // indirect
github.com/docker/go-units v0.4.0 // indirect github.com/docker/go-units v0.5.0 // indirect
github.com/emicklei/go-restful/v3 v3.11.0 // indirect github.com/emicklei/go-restful/v3 v3.11.0 // indirect
github.com/evanphx/json-patch/v5 v5.8.1 github.com/evanphx/json-patch v5.9.0+incompatible // indirect
github.com/exponent-io/jsonpath v0.0.0-20151013193312-d6023ce2651d // indirect github.com/exponent-io/jsonpath v0.0.0-20151013193312-d6023ce2651d // indirect
github.com/felixge/httpsnoop v1.0.4 // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/fxamacker/cbor/v2 v2.7.0 // indirect
github.com/ghodss/yaml v1.0.1-0.20190212211648-25d852aebe32 // indirect github.com/ghodss/yaml v1.0.1-0.20190212211648-25d852aebe32 // indirect
github.com/go-chi/chi/v5 v5.1.0 // indirect
github.com/go-chi/cors v1.2.1 // indirect
github.com/go-errors/errors v1.4.2 // indirect github.com/go-errors/errors v1.4.2 // indirect
github.com/go-gorp/gorp/v3 v3.0.2 // indirect github.com/go-gorp/gorp/v3 v3.1.0 // indirect
github.com/go-kit/log v0.2.1 // indirect github.com/go-kit/log v0.2.1 // indirect
github.com/go-logfmt/logfmt v0.5.1 // indirect github.com/go-logfmt/logfmt v0.6.0 // indirect
github.com/go-logr/logr v1.4.1 // indirect github.com/go-logr/logr v1.4.2 // indirect
github.com/go-logr/stdr v1.2.2 // indirect github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-ole/go-ole v1.2.6 // indirect github.com/go-ole/go-ole v1.2.6 // indirect
github.com/go-openapi/jsonpointer v0.20.0 // indirect github.com/go-openapi/jsonpointer v0.20.0 // indirect
@ -128,148 +105,142 @@ require (
github.com/gobwas/glob v0.2.3 // indirect github.com/gobwas/glob v0.2.3 // indirect
github.com/goccy/go-json v0.10.2 // indirect github.com/goccy/go-json v0.10.2 // indirect
github.com/gogo/protobuf v1.3.2 // indirect github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang-jwt/jwt/v4 v4.5.0 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/mock v1.6.0 // indirect github.com/golang/protobuf v1.5.4 // indirect
github.com/golang/protobuf v1.5.3 // indirect github.com/google/btree v1.1.3 // indirect
github.com/google/btree v1.1.2 // indirect github.com/google/cel-go v0.20.1 // indirect
github.com/google/cel-go v0.18.2 // indirect github.com/google/gnostic-models v0.6.8 // indirect
github.com/google/gnostic v0.6.9 // indirect
github.com/google/go-cmp v0.6.0 // indirect github.com/google/go-cmp v0.6.0 // indirect
github.com/google/gofuzz v1.2.0 // indirect github.com/google/gofuzz v1.2.0 // indirect
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect
github.com/google/uuid v1.6.0 // indirect github.com/google/uuid v1.6.0 // indirect
github.com/gorilla/mux v1.8.1 // indirect github.com/gorilla/mux v1.8.1 // indirect
github.com/gorilla/websocket v1.5.3 // indirect
github.com/gosuri/uitable v0.0.4 // indirect github.com/gosuri/uitable v0.0.4 // indirect
github.com/gregjones/httpcache v0.0.0-20190611155906-901d90724c79 // indirect github.com/gregjones/httpcache v0.0.0-20190611155906-901d90724c79 // indirect
github.com/grpc-ecosystem/go-grpc-middleware v1.4.0 // indirect github.com/grpc-ecosystem/go-grpc-middleware v1.4.0 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.16.0 // indirect github.com/grpc-ecosystem/grpc-gateway/v2 v2.22.0 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
github.com/hashicorp/go-multierror v1.1.1 // indirect
github.com/hashicorp/golang-lru/v2 v2.0.7 // indirect github.com/hashicorp/golang-lru/v2 v2.0.7 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect github.com/hashicorp/hcl v1.0.0 // indirect
github.com/huandu/xstrings v1.3.3 // indirect github.com/huandu/xstrings v1.5.0 // indirect
github.com/imdario/mergo v0.3.16 // indirect github.com/imdario/mergo v0.3.16 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/jhump/protoreflect v1.15.2 // indirect github.com/jhump/protoreflect v1.15.3 // indirect
github.com/jmoiron/sqlx v1.3.5 // indirect github.com/jmoiron/sqlx v1.4.0 // indirect
github.com/josharian/intern v1.0.0 // indirect github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/compress v1.17.4 // indirect github.com/klauspost/compress v1.17.10 // indirect
github.com/kolesnikovae/go-winjob v1.0.0
github.com/lann/builder v0.0.0-20180802200727-47ae307949d0 // indirect github.com/lann/builder v0.0.0-20180802200727-47ae307949d0 // indirect
github.com/lann/ps v0.0.0-20150810152359-62de8c46ede0 // indirect github.com/lann/ps v0.0.0-20150810152359-62de8c46ede0 // indirect
github.com/lestrrat-go/blackmagic v1.0.2 // indirect github.com/lestrrat-go/blackmagic v1.0.2 // indirect
github.com/lestrrat-go/httpcc v1.0.1 // indirect github.com/lestrrat-go/httpcc v1.0.1 // indirect
github.com/lestrrat-go/httprc v1.0.4 // indirect github.com/lestrrat-go/httprc v1.0.5 // indirect
github.com/lestrrat-go/iter v1.0.2 // indirect github.com/lestrrat-go/iter v1.0.2 // indirect
github.com/lestrrat-go/jwx/v2 v2.0.19 // indirect github.com/lestrrat-go/jwx/v2 v2.0.21 // indirect
github.com/lestrrat-go/option v1.0.1 // indirect github.com/lestrrat-go/option v1.0.1 // indirect
github.com/lib/pq v1.10.7 // indirect github.com/lib/pq v1.10.9 // indirect
github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de // indirect github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de // indirect
github.com/magiconair/properties v1.8.6 // indirect github.com/magiconair/properties v1.8.7 // indirect
github.com/mailru/easyjson v0.7.7 // indirect github.com/mailru/easyjson v0.7.7 // indirect
github.com/marusama/semaphore/v2 v2.5.0 // indirect github.com/marusama/semaphore/v2 v2.5.0 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mattn/go-runewidth v0.0.9 // indirect github.com/mattn/go-runewidth v0.0.9 // indirect
github.com/microsoft/durabletask-go v0.4.1-0.20240122160106-fb5c4c05729d // indirect
github.com/mitchellh/copystructure v1.2.0 // indirect github.com/mitchellh/copystructure v1.2.0 // indirect
github.com/mitchellh/go-wordwrap v1.0.0 // indirect github.com/mitchellh/go-wordwrap v1.0.1 // indirect
github.com/mitchellh/mapstructure v1.5.1-0.20220423185008-bf980b35cac4 // indirect github.com/mitchellh/mapstructure v1.5.1-0.20220423185008-bf980b35cac4 // indirect
github.com/mitchellh/reflectwalk v1.0.2 // indirect github.com/mitchellh/reflectwalk v1.0.2 // indirect
github.com/moby/locker v1.0.1 // indirect github.com/moby/locker v1.0.1 // indirect
github.com/moby/spdystream v0.2.0 // indirect github.com/moby/spdystream v0.4.0 // indirect
github.com/moby/term v0.0.0-20221205130635-1aeaba878587 // indirect github.com/moby/term v0.5.0 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/monochromegane/go-gitignore v0.0.0-20200626010858-205db1a8cc00 // indirect github.com/monochromegane/go-gitignore v0.0.0-20200626010858-205db1a8cc00 // indirect
github.com/morikuni/aec v1.0.0 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f // indirect
github.com/opencontainers/go-digest v1.0.0 // indirect github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/opencontainers/image-spec v1.1.0-rc2 // indirect github.com/opencontainers/image-spec v1.1.0 // indirect
github.com/opencontainers/runc v1.1.12 // indirect
github.com/openzipkin/zipkin-go v0.4.2 // indirect github.com/openzipkin/zipkin-go v0.4.2 // indirect
github.com/panjf2000/ants/v2 v2.8.1 // indirect
github.com/pelletier/go-toml v1.9.5 // indirect github.com/pelletier/go-toml v1.9.5 // indirect
github.com/pelletier/go-toml/v2 v2.0.6 // indirect github.com/pelletier/go-toml/v2 v2.0.9 // indirect
github.com/peterbourgon/diskv v2.0.1+incompatible // indirect github.com/peterbourgon/diskv v2.0.1+incompatible // indirect
github.com/pkg/errors v0.9.1 // indirect github.com/pkg/errors v0.9.1 // indirect
github.com/pkoukk/tiktoken-go v0.1.6 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/prometheus/client_golang v1.17.0 // indirect github.com/prometheus/client_golang v1.20.4 // indirect
github.com/prometheus/client_model v0.5.0 // indirect github.com/prometheus/client_model v0.6.1 // indirect
github.com/prometheus/common v0.45.0 // indirect github.com/prometheus/common v0.59.1 // indirect
github.com/prometheus/procfs v0.12.0 // indirect github.com/prometheus/procfs v0.15.1 // indirect
github.com/prometheus/statsd_exporter v0.22.7 // indirect github.com/prometheus/statsd_exporter v0.22.7 // indirect
github.com/rubenv/sql-migrate v1.2.0 // indirect github.com/rubenv/sql-migrate v1.7.0 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/shopspring/decimal v1.2.0 // indirect github.com/segmentio/asm v1.2.0 // indirect
github.com/shopspring/decimal v1.4.0 // indirect
github.com/sirupsen/logrus v1.9.3 // indirect github.com/sirupsen/logrus v1.9.3 // indirect
github.com/sony/gobreaker v0.5.0 // indirect github.com/sony/gobreaker v0.5.0 // indirect
github.com/sourcegraph/conc v0.3.0 // indirect
github.com/spf13/afero v1.8.2 // indirect github.com/spf13/afero v1.8.2 // indirect
github.com/spf13/cast v1.6.0 // indirect github.com/spf13/cast v1.7.0 // indirect
github.com/spf13/jwalterweatherman v1.1.0 // indirect github.com/spf13/jwalterweatherman v1.1.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect github.com/spf13/pflag v1.0.5 // indirect
github.com/spiffe/go-spiffe/v2 v2.1.7 // indirect
github.com/stoewer/go-strcase v1.2.0 // indirect github.com/stoewer/go-strcase v1.2.0 // indirect
github.com/stretchr/objx v0.5.0 // indirect
github.com/subosito/gotenv v1.4.1 // indirect github.com/subosito/gotenv v1.4.1 // indirect
github.com/tidwall/transform v0.0.0-20201103190739-32f242e2dbde // indirect github.com/tidwall/transform v0.0.0-20201103190739-32f242e2dbde // indirect
github.com/tklauser/go-sysconf v0.3.10 // indirect github.com/tklauser/go-sysconf v0.3.12 // indirect
github.com/tklauser/numcpus v0.4.0 // indirect github.com/tklauser/numcpus v0.6.1 // indirect
github.com/valyala/bytebufferpool v1.0.0 // indirect github.com/tmc/langchaingo v0.1.12 // indirect
github.com/valyala/fasthttp v1.51.0 // indirect github.com/x448/float16 v0.8.4 // indirect
github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb // indirect github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb // indirect
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect
github.com/xeipuuv/gojsonschema v1.2.0 // indirect github.com/xeipuuv/gojsonschema v1.2.0 // indirect
github.com/xlab/treeprint v1.2.0 // indirect github.com/xlab/treeprint v1.2.0 // indirect
github.com/yusufpapurcu/wmi v1.2.2 // indirect github.com/yusufpapurcu/wmi v1.2.3 // indirect
github.com/zeebo/errs v1.3.0 // indirect
go.mongodb.org/mongo-driver v1.14.0 // indirect
go.opencensus.io v0.24.0 // indirect go.opencensus.io v0.24.0 // indirect
go.opentelemetry.io/otel v1.23.1 // indirect go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.54.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.21.0 // indirect go.opentelemetry.io/otel v1.32.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.21.0 // indirect go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.30.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.21.0 // indirect go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.30.0 // indirect
go.opentelemetry.io/otel/exporters/zipkin v1.21.0 // indirect go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.26.0 // indirect
go.opentelemetry.io/otel/sdk v1.21.0 // indirect go.opentelemetry.io/otel/exporters/zipkin v1.26.0 // indirect
go.opentelemetry.io/otel/trace v1.23.1 // indirect go.opentelemetry.io/otel/metric v1.32.0 // indirect
go.opentelemetry.io/proto/otlp v1.0.0 // indirect go.opentelemetry.io/otel/sdk v1.30.0 // indirect
go.opentelemetry.io/otel/trace v1.32.0 // indirect
go.opentelemetry.io/proto/otlp v1.3.1 // indirect
go.starlark.net v0.0.0-20230525235612-a134d8f9ddca // indirect go.starlark.net v0.0.0-20230525235612-a134d8f9ddca // indirect
golang.org/x/crypto v0.21.0 // indirect go.uber.org/multierr v1.11.0 // indirect
golang.org/x/exp v0.0.0-20240119083558-1b970713d09a // indirect golang.org/x/crypto v0.31.0 // indirect
golang.org/x/net v0.23.0 // indirect golang.org/x/exp v0.0.0-20241204233417-43b7b7cde48d // indirect
golang.org/x/oauth2 v0.16.0 // indirect golang.org/x/net v0.33.0 // indirect
golang.org/x/sync v0.6.0 // indirect golang.org/x/oauth2 v0.23.0 // indirect
golang.org/x/term v0.18.0 // indirect golang.org/x/sync v0.10.0 // indirect
golang.org/x/text v0.14.0 // indirect golang.org/x/term v0.27.0 // indirect
golang.org/x/time v0.3.0 // indirect golang.org/x/text v0.21.0 // indirect
gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect golang.org/x/time v0.6.0 // indirect
google.golang.org/appengine v1.6.8 // indirect google.golang.org/genproto/googleapis/api v0.0.0-20240924160255-9d4c2d233b61 // indirect
google.golang.org/grpc v1.61.0 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20241202173237-19429a94021a // indirect
google.golang.org/protobuf v1.32.0 // indirect google.golang.org/grpc v1.68.1 // indirect
google.golang.org/protobuf v1.35.2 // indirect
gopkg.in/evanphx/json-patch.v4 v4.12.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/apiserver v0.28.4 // indirect k8s.io/apiserver v0.31.3 // indirect
k8s.io/component-base v0.28.4 // indirect k8s.io/component-base v0.31.3 // indirect
k8s.io/klog/v2 v2.110.1 // indirect k8s.io/klog/v2 v2.130.1 // indirect
k8s.io/kube-openapi v0.0.0-20231113174909-778a5567bc1e // indirect k8s.io/kube-openapi v0.0.0-20240228011516-70dd3763d340 // indirect
k8s.io/kubectl v0.26.0 // indirect k8s.io/kubectl v0.31.3 // indirect
k8s.io/utils v0.0.0-20240102154912-e7106e64919e // indirect k8s.io/utils v0.0.0-20240921022957-49e7df575cb6 // indirect
oras.land/oras-go v1.2.2 // indirect oras.land/oras-go v1.2.5 // indirect
sigs.k8s.io/controller-runtime v0.16.3 // indirect sigs.k8s.io/controller-runtime v0.19.0 // indirect
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
sigs.k8s.io/kustomize/api v0.15.0 // indirect sigs.k8s.io/kustomize/api v0.17.2 // indirect
sigs.k8s.io/kustomize/kyaml v0.15.0 // indirect sigs.k8s.io/kustomize/kyaml v0.17.1 // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect
) )
replace (
github.com/Azure/go-autorest => github.com/Azure/go-autorest v14.2.0+incompatible
github.com/docker/docker => github.com/moby/moby v17.12.0-ce-rc1.0.20200618181300-9dc6525e6118+incompatible
github.com/russross/blackfriday => github.com/russross/blackfriday v1.5.2
k8s.io/api => k8s.io/api v0.25.2
k8s.io/apimachinery => k8s.io/apimachinery v0.25.2
k8s.io/cli-runtime => k8s.io/cli-runtime v0.25.2
k8s.io/client => github.com/kubernetes-client/go v0.0.0-20190928040339-c757968c4c36
k8s.io/client-go => k8s.io/client-go v0.25.2
k8s.io/kube-openapi => k8s.io/kube-openapi v0.0.0-20221012153701-172d655c2280
sigs.k8s.io/kustomize/api => sigs.k8s.io/kustomize/api v0.12.1
sigs.k8s.io/kustomize/kyaml => sigs.k8s.io/kustomize/kyaml v0.13.9
)

1404
go.sum

File diff suppressed because it is too large Load Diff

View File

@ -292,7 +292,6 @@ func TestAnnotate(t *testing.T) {
var out bytes.Buffer var out bytes.Buffer
in := []io.Reader{inputFile} in := []io.Reader{inputFile}
for i, annotation := range tt.annotations { for i, annotation := range tt.annotations {
annotation := annotation
annotator := NewK8sAnnotator(K8sAnnotatorConfig{ annotator := NewK8sAnnotator(K8sAnnotatorConfig{
TargetResource: &annotation.targetResource, TargetResource: &annotation.targetResource,
TargetNamespace: &annotation.targetNamespace, TargetNamespace: &annotation.targetNamespace,
@ -334,7 +333,7 @@ func TestAnnotate(t *testing.T) {
for i := range expectedDocs { for i := range expectedDocs {
if tt.printOutput { if tt.printOutput {
t.Logf(outDocs[i]) t.Logf(outDocs[i]) //nolint:govet
} }
assert.YAMLEq(t, expectedDocs[i], outDocs[i]) assert.YAMLEq(t, expectedDocs[i], outDocs[i])
} }

View File

@ -15,7 +15,7 @@ package kubernetes
import ( import (
"bytes" "bytes"
"fmt" "errors"
"testing" "testing"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
@ -242,7 +242,7 @@ func TestComponents(t *testing.T) {
err := writeComponents(&buff, err := writeComponents(&buff,
func() (*v1alpha1.ComponentList, error) { func() (*v1alpha1.ComponentList, error) {
if len(tc.errString) > 0 { if len(tc.errString) > 0 {
return nil, fmt.Errorf(tc.errString) return nil, errors.New(tc.errString)
} }
return &v1alpha1.ComponentList{Items: tc.k8sConfig}, nil return &v1alpha1.ComponentList{Items: tc.k8sConfig}, nil

View File

@ -15,7 +15,7 @@ package kubernetes
import ( import (
"bytes" "bytes"
"fmt" "errors"
"testing" "testing"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
@ -221,7 +221,7 @@ func TestConfigurations(t *testing.T) {
err := writeConfigurations(&buff, err := writeConfigurations(&buff,
func() (*v1alpha1.ConfigurationList, error) { func() (*v1alpha1.ConfigurationList, error) {
if len(tc.errString) > 0 { if len(tc.errString) > 0 {
return nil, fmt.Errorf(tc.errString) return nil, errors.New(tc.errString)
} }
return &v1alpha1.ConfigurationList{Items: tc.k8sConfig}, nil return &v1alpha1.ConfigurationList{Items: tc.k8sConfig}, nil

View File

@ -249,10 +249,10 @@ func daprChartValues(config InitConfiguration, version string) (map[string]inter
helmVals := []string{ helmVals := []string{
fmt.Sprintf("global.ha.enabled=%t", config.EnableHA), fmt.Sprintf("global.ha.enabled=%t", config.EnableHA),
fmt.Sprintf("global.mtls.enabled=%t", config.EnableMTLS), fmt.Sprintf("global.mtls.enabled=%t", config.EnableMTLS),
fmt.Sprintf("global.tag=%s", utils.GetVariantVersion(version, config.ImageVariant)), "global.tag=" + utils.GetVariantVersion(version, config.ImageVariant),
} }
if len(config.ImageRegistryURI) != 0 { if len(config.ImageRegistryURI) != 0 {
helmVals = append(helmVals, fmt.Sprintf("global.registry=%s", config.ImageRegistryURI)) helmVals = append(helmVals, "global.registry="+config.ImageRegistryURI)
} }
helmVals = append(helmVals, config.Args...) helmVals = append(helmVals, config.Args...)
@ -265,9 +265,9 @@ func daprChartValues(config InitConfiguration, version string) (map[string]inter
if err != nil { if err != nil {
return nil, err return nil, err
} }
helmVals = append(helmVals, fmt.Sprintf("dapr_sentry.tls.root.certPEM=%s", string(rootCertBytes)), helmVals = append(helmVals, "dapr_sentry.tls.root.certPEM="+string(rootCertBytes),
fmt.Sprintf("dapr_sentry.tls.issuer.certPEM=%s", string(issuerCertBytes)), "dapr_sentry.tls.issuer.certPEM="+string(issuerCertBytes),
fmt.Sprintf("dapr_sentry.tls.issuer.keyPEM=%s", string(issuerKeyBytes)), "dapr_sentry.tls.issuer.keyPEM="+string(issuerKeyBytes),
) )
} }
@ -301,7 +301,7 @@ func install(releaseName, releaseVersion, helmRepo string, config InitConfigurat
} }
if releaseName == daprReleaseName { if releaseName == daprReleaseName {
err = applyCRDs(fmt.Sprintf("v%s", version)) err = applyCRDs("v" + version)
if err != nil { if err != nil {
return err return err
} }
@ -311,7 +311,7 @@ func install(releaseName, releaseVersion, helmRepo string, config InitConfigurat
installClient.ReleaseName = releaseName installClient.ReleaseName = releaseName
installClient.Namespace = config.Namespace installClient.Namespace = config.Namespace
installClient.Wait = config.Wait installClient.Wait = config.Wait
installClient.Timeout = time.Duration(config.Timeout) * time.Second installClient.Timeout = time.Duration(config.Timeout) * time.Second //nolint:gosec
values, err := daprChartValues(config, version) values, err := daprChartValues(config, version)
if err != nil { if err != nil {
@ -340,7 +340,7 @@ func installThirdParty(releaseName, chartName, releaseVersion, helmRepo string,
installClient.ReleaseName = releaseName installClient.ReleaseName = releaseName
installClient.Namespace = thirdPartyDevNamespace installClient.Namespace = thirdPartyDevNamespace
installClient.Wait = config.Wait installClient.Wait = config.Wait
installClient.Timeout = time.Duration(config.Timeout) * time.Second installClient.Timeout = time.Duration(config.Timeout) * time.Second //nolint:gosec
values := map[string]interface{}{} values := map[string]interface{}{}

View File

@ -28,9 +28,9 @@ func TestListPodsInterface(t *testing.T) {
output, err := ListPodsInterface(k8s, map[string]string{ output, err := ListPodsInterface(k8s, map[string]string{
"test": "test", "test": "test",
}) })
assert.Nil(t, err, "unexpected error") assert.NoError(t, err, "unexpected error")
assert.NotNil(t, output, "Expected empty list") assert.NotNil(t, output, "Expected empty list")
assert.Equal(t, 0, len(output.Items), "Expected length 0") assert.Empty(t, output.Items, "Expected length 0")
}) })
t.Run("one matching pod", func(t *testing.T) { t.Run("one matching pod", func(t *testing.T) {
k8s := fake.NewSimpleClientset((&v1.Pod{ k8s := fake.NewSimpleClientset((&v1.Pod{
@ -46,9 +46,9 @@ func TestListPodsInterface(t *testing.T) {
output, err := ListPodsInterface(k8s, map[string]string{ output, err := ListPodsInterface(k8s, map[string]string{
"test": "test", "test": "test",
}) })
assert.Nil(t, err, "unexpected error") assert.NoError(t, err, "unexpected error")
assert.NotNil(t, output, "Expected non empty list") assert.NotNil(t, output, "Expected non empty list")
assert.Equal(t, 1, len(output.Items), "Expected length 0") assert.Len(t, output.Items, 1, "Expected length 0")
assert.Equal(t, "test", output.Items[0].Name, "expected name to match") assert.Equal(t, "test", output.Items[0].Name, "expected name to match")
assert.Equal(t, "test", output.Items[0].Namespace, "expected namespace to match") assert.Equal(t, "test", output.Items[0].Namespace, "expected namespace to match")
}) })

View File

@ -14,6 +14,7 @@ limitations under the License.
package kubernetes package kubernetes
import ( import (
"errors"
"fmt" "fmt"
"io" "io"
"net/http" "net/http"
@ -133,7 +134,7 @@ func (pf *PortForward) Init() error {
return fmt.Errorf("can not get the local and remote ports: %w", err) return fmt.Errorf("can not get the local and remote ports: %w", err)
} }
if len(ports) == 0 { if len(ports) == 0 {
return fmt.Errorf("can not get the local and remote ports: error getting ports length") return errors.New("can not get the local and remote ports: error getting ports length")
} }
pf.LocalPort = int(ports[0].Local) pf.LocalPort = int(ports[0].Local)

View File

@ -121,7 +121,7 @@ func renewCertificate(rootCert, issuerCert, issuerKey []byte, timeout uint, imag
// Reuse the existing helm configuration values i.e. tags, registry, etc. // Reuse the existing helm configuration values i.e. tags, registry, etc.
upgradeClient.ReuseValues = true upgradeClient.ReuseValues = true
upgradeClient.Wait = true upgradeClient.Wait = true
upgradeClient.Timeout = time.Duration(timeout) * time.Second upgradeClient.Timeout = time.Duration(timeout) * time.Second //nolint:gosec
upgradeClient.Namespace = status[0].Namespace upgradeClient.Namespace = status[0].Namespace
// Override the helm configuration values with the new certificates. // Override the helm configuration values with the new certificates.
@ -146,12 +146,12 @@ func createHelmParamsForNewCertificates(ca, issuerCert, issuerKey string) (map[s
args := []string{} args := []string{}
if ca != "" && issuerCert != "" && issuerKey != "" { if ca != "" && issuerCert != "" && issuerKey != "" {
args = append(args, fmt.Sprintf("dapr_sentry.tls.root.certPEM=%s", ca), args = append(args, "dapr_sentry.tls.root.certPEM="+ca,
fmt.Sprintf("dapr_sentry.tls.issuer.certPEM=%s", issuerCert), "dapr_sentry.tls.issuer.certPEM="+issuerCert,
fmt.Sprintf("dapr_sentry.tls.issuer.keyPEM=%s", issuerKey), "dapr_sentry.tls.issuer.keyPEM="+issuerKey,
) )
} else { } else {
return nil, fmt.Errorf("parameters not found") return nil, errors.New("parameters not found")
} }
for _, v := range args { for _, v := range args {

View File

@ -317,7 +317,7 @@ func createDeploymentConfig(client versioned.Interface, app runfileconfig.App) d
if app.AppPort != 0 { if app.AppPort != 0 {
dep.Spec.Template.Spec.Containers[0].Ports = []corev1.ContainerPort{ dep.Spec.Template.Spec.Containers[0].Ports = []corev1.ContainerPort{
{ {
ContainerPort: int32(app.AppPort), ContainerPort: int32(app.AppPort), //nolint:gosec
}, },
} }
} }

View File

@ -65,7 +65,6 @@ func NewStatusClient() (*StatusClient, error) {
// List status for Dapr resources. // List status for Dapr resources.
func (s *StatusClient) Status() ([]StatusOutput, error) { func (s *StatusClient) Status() ([]StatusOutput, error) {
//nolint
client := s.client client := s.client
if client == nil { if client == nil {
return nil, errors.New("kubernetes client not initialized") return nil, errors.New("kubernetes client not initialized")

View File

@ -83,7 +83,7 @@ func TestStatus(t *testing.T) {
if err != nil { if err != nil {
t.Fatalf("%s status should not raise an error", err.Error()) t.Fatalf("%s status should not raise an error", err.Error())
} }
assert.Equal(t, 0, len(status), "Expected status to be empty list") assert.Empty(t, status, "Expected status to be empty list")
}) })
t.Run("one status waiting", func(t *testing.T) { t.Run("one status waiting", func(t *testing.T) {
@ -102,8 +102,8 @@ func TestStatus(t *testing.T) {
} }
k8s := newTestSimpleK8s(newDaprControlPlanePod(pd)) k8s := newTestSimpleK8s(newDaprControlPlanePod(pd))
status, err := k8s.Status() status, err := k8s.Status()
assert.Nil(t, err, "status should not raise an error") assert.NoError(t, err, "status should not raise an error")
assert.Equal(t, 1, len(status), "Expected status to be non-empty list") assert.Len(t, status, 1, "Expected status to be non-empty list")
stat := status[0] stat := status[0]
assert.Equal(t, "dapr-dashboard", stat.Name, "expected name to match") assert.Equal(t, "dapr-dashboard", stat.Name, "expected name to match")
assert.Equal(t, "dapr-system", stat.Namespace, "expected namespace to match") assert.Equal(t, "dapr-system", stat.Namespace, "expected namespace to match")
@ -131,8 +131,8 @@ func TestStatus(t *testing.T) {
} }
k8s := newTestSimpleK8s(newDaprControlPlanePod(pd)) k8s := newTestSimpleK8s(newDaprControlPlanePod(pd))
status, err := k8s.Status() status, err := k8s.Status()
assert.Nil(t, err, "status should not raise an error") assert.NoError(t, err, "status should not raise an error")
assert.Equal(t, 1, len(status), "Expected status to be non-empty list") assert.Len(t, status, 1, "Expected status to be non-empty list")
stat := status[0] stat := status[0]
assert.Equal(t, "dapr-dashboard", stat.Name, "expected name to match") assert.Equal(t, "dapr-dashboard", stat.Name, "expected name to match")
assert.Equal(t, "dapr-system", stat.Namespace, "expected namespace to match") assert.Equal(t, "dapr-system", stat.Namespace, "expected namespace to match")
@ -140,7 +140,7 @@ func TestStatus(t *testing.T) {
assert.Equal(t, "0.0.1", stat.Version, "expected version to match") assert.Equal(t, "0.0.1", stat.Version, "expected version to match")
assert.Equal(t, 1, stat.Replicas, "expected replicas to match") assert.Equal(t, 1, stat.Replicas, "expected replicas to match")
assert.Equal(t, "True", stat.Healthy, "expected health to match") assert.Equal(t, "True", stat.Healthy, "expected health to match")
assert.Equal(t, stat.Status, "Running", "expected running status") assert.Equal(t, "Running", stat.Status, "expected running status")
}) })
t.Run("one status terminated", func(t *testing.T) { t.Run("one status terminated", func(t *testing.T) {
@ -160,8 +160,8 @@ func TestStatus(t *testing.T) {
k8s := newTestSimpleK8s(newDaprControlPlanePod(pd)) k8s := newTestSimpleK8s(newDaprControlPlanePod(pd))
status, err := k8s.Status() status, err := k8s.Status()
assert.Nil(t, err, "status should not raise an error") assert.NoError(t, err, "status should not raise an error")
assert.Equal(t, 1, len(status), "Expected status to be non-empty list") assert.Len(t, status, 1, "Expected status to be non-empty list")
stat := status[0] stat := status[0]
assert.Equal(t, "dapr-dashboard", stat.Name, "expected name to match") assert.Equal(t, "dapr-dashboard", stat.Name, "expected name to match")
assert.Equal(t, "dapr-system", stat.Namespace, "expected namespace to match") assert.Equal(t, "dapr-system", stat.Namespace, "expected namespace to match")
@ -169,7 +169,7 @@ func TestStatus(t *testing.T) {
assert.Equal(t, "0.0.1", stat.Version, "expected version to match") assert.Equal(t, "0.0.1", stat.Version, "expected version to match")
assert.Equal(t, 1, stat.Replicas, "expected replicas to match") assert.Equal(t, 1, stat.Replicas, "expected replicas to match")
assert.Equal(t, "False", stat.Healthy, "expected health to match") assert.Equal(t, "False", stat.Healthy, "expected health to match")
assert.Equal(t, stat.Status, "Terminated", "expected terminated status") assert.Equal(t, "Terminated", stat.Status, "expected terminated status")
}) })
t.Run("one status pending", func(t *testing.T) { t.Run("one status pending", func(t *testing.T) {
@ -193,8 +193,8 @@ func TestStatus(t *testing.T) {
k8s := newTestSimpleK8s(pod) k8s := newTestSimpleK8s(pod)
status, err := k8s.Status() status, err := k8s.Status()
assert.Nil(t, err, "status should not raise an error") assert.NoError(t, err, "status should not raise an error")
assert.Equal(t, 1, len(status), "Expected status to be non-empty list") assert.Len(t, status, 1, "Expected status to be non-empty list")
stat := status[0] stat := status[0]
assert.Equal(t, "dapr-dashboard", stat.Name, "expected name to match") assert.Equal(t, "dapr-dashboard", stat.Name, "expected name to match")
assert.Equal(t, "dapr-system", stat.Namespace, "expected namespace to match") assert.Equal(t, "dapr-system", stat.Namespace, "expected namespace to match")
@ -202,13 +202,13 @@ func TestStatus(t *testing.T) {
assert.Equal(t, "0.0.1", stat.Version, "expected version to match") assert.Equal(t, "0.0.1", stat.Version, "expected version to match")
assert.Equal(t, 1, stat.Replicas, "expected replicas to match") assert.Equal(t, 1, stat.Replicas, "expected replicas to match")
assert.Equal(t, "False", stat.Healthy, "expected health to match") assert.Equal(t, "False", stat.Healthy, "expected health to match")
assert.Equal(t, stat.Status, "Pending", "expected pending status") assert.Equal(t, "Pending", stat.Status, "expected pending status")
}) })
t.Run("one status empty client", func(t *testing.T) { t.Run("one status empty client", func(t *testing.T) {
k8s := &StatusClient{} k8s := &StatusClient{}
status, err := k8s.Status() status, err := k8s.Status()
assert.NotNil(t, err, "status should raise an error") assert.Error(t, err, "status should raise an error")
assert.Equal(t, "kubernetes client not initialized", err.Error(), "expected errors to match") assert.Equal(t, "kubernetes client not initialized", err.Error(), "expected errors to match")
assert.Nil(t, status, "expected nil for status") assert.Nil(t, status, "expected nil for status")
}) })
@ -263,7 +263,7 @@ func TestControlPlaneServices(t *testing.T) {
k8s := newTestSimpleK8s(runtimeObj...) k8s := newTestSimpleK8s(runtimeObj...)
status, err := k8s.Status() status, err := k8s.Status()
assert.Nil(t, err, "status should not raise an error") assert.NoError(t, err, "status should not raise an error")
assert.Equal(t, len(expectedReplicas), len(status), "Expected status to be empty list") assert.Equal(t, len(expectedReplicas), len(status), "Expected status to be empty list")
@ -305,8 +305,8 @@ func TestControlPlaneVersion(t *testing.T) {
pd.imageURI = tc.imageURI pd.imageURI = tc.imageURI
k8s := newTestSimpleK8s(newDaprControlPlanePod(pd)) k8s := newTestSimpleK8s(newDaprControlPlanePod(pd))
status, err := k8s.Status() status, err := k8s.Status()
assert.Nil(t, err, "status should not raise an error") assert.NoError(t, err, "status should not raise an error")
assert.Equal(t, 1, len(status), "Expected status to be non-empty list") assert.Len(t, status, 1, "Expected status to be non-empty list")
stat := status[0] stat := status[0]
assert.Equal(t, tc.expectedVersion, stat.Version, "expected version to match") assert.Equal(t, tc.expectedVersion, stat.Version, "expected version to match")
} }

View File

@ -41,7 +41,7 @@ func Uninstall(namespace string, uninstallAll bool, uninstallDev bool, timeout u
} }
uninstallClient := helm.NewUninstall(config) uninstallClient := helm.NewUninstall(config)
uninstallClient.Timeout = time.Duration(timeout) * time.Second uninstallClient.Timeout = time.Duration(timeout) * time.Second //nolint:gosec
// Uninstall Dashboard as a best effort. // Uninstall Dashboard as a best effort.
// Chart versions < 1.11 for Dapr will delete dashboard as part of the main chart. // Chart versions < 1.11 for Dapr will delete dashboard as part of the main chart.

View File

@ -111,7 +111,7 @@ func Upgrade(conf UpgradeConfig) error {
if !hasDashboardInDaprChart && willHaveDashboardInDaprChart && dashboardExists { if !hasDashboardInDaprChart && willHaveDashboardInDaprChart && dashboardExists {
print.InfoStatusEvent(os.Stdout, "Dashboard being uninstalled prior to Dapr control plane upgrade...") print.InfoStatusEvent(os.Stdout, "Dashboard being uninstalled prior to Dapr control plane upgrade...")
uninstallClient := helm.NewUninstall(helmConf) uninstallClient := helm.NewUninstall(helmConf)
uninstallClient.Timeout = time.Duration(conf.Timeout) * time.Second uninstallClient.Timeout = time.Duration(conf.Timeout) * time.Second //nolint:gosec
_, err = uninstallClient.Run(dashboardReleaseName) _, err = uninstallClient.Run(dashboardReleaseName)
if err != nil { if err != nil {
@ -157,7 +157,7 @@ func Upgrade(conf UpgradeConfig) error {
} }
if !isDowngrade(conf.RuntimeVersion, daprVersion) { if !isDowngrade(conf.RuntimeVersion, daprVersion) {
err = applyCRDs(fmt.Sprintf("v%s", conf.RuntimeVersion)) err = applyCRDs("v" + conf.RuntimeVersion)
if err != nil { if err != nil {
return fmt.Errorf("unable to apply CRDs: %w", err) return fmt.Errorf("unable to apply CRDs: %w", err)
} }
@ -240,7 +240,7 @@ func helmUpgrade(client *helm.Upgrade, name string, chart *chart.Chart, vals map
// create a totally new helm client, this ensures that we fetch a fresh openapi schema from the server on each attempt. // create a totally new helm client, this ensures that we fetch a fresh openapi schema from the server on each attempt.
client, _, err = newUpgradeClient(client.Namespace, UpgradeConfig{ client, _, err = newUpgradeClient(client.Namespace, UpgradeConfig{
Timeout: uint(client.Timeout), Timeout: uint(client.Timeout), //nolint:gosec
}) })
if err != nil { if err != nil {
return nil, fmt.Errorf("unable to create helm client: %w", err) return nil, fmt.Errorf("unable to create helm client: %w", err)
@ -267,7 +267,7 @@ func applyCRDs(version string) error {
url := fmt.Sprintf("https://raw.githubusercontent.com/dapr/dapr/%s/charts/dapr/crds/%s.yaml", version, crd) 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 { if resp != nil && resp.StatusCode == http.StatusOK {
defer resp.Body.Close() defer resp.Body.Close()
_, err := utils.RunCmdAndWait("kubectl", "apply", "-f", url) _, err := utils.RunCmdAndWait("kubectl", "apply", "-f", url)
@ -286,18 +286,18 @@ func upgradeChartValues(ca, issuerCert, issuerKey string, haMode, mtls bool, con
if err != nil { if err != nil {
return nil, err return nil, err
} }
globalVals = append(globalVals, fmt.Sprintf("global.tag=%s", utils.GetVariantVersion(conf.RuntimeVersion, conf.ImageVariant))) globalVals = append(globalVals, "global.tag="+utils.GetVariantVersion(conf.RuntimeVersion, conf.ImageVariant))
if mtls && ca != "" && issuerCert != "" && issuerKey != "" { if mtls && ca != "" && issuerCert != "" && issuerKey != "" {
globalVals = append(globalVals, fmt.Sprintf("dapr_sentry.tls.root.certPEM=%s", ca), globalVals = append(globalVals, "dapr_sentry.tls.root.certPEM="+ca,
fmt.Sprintf("dapr_sentry.tls.issuer.certPEM=%s", issuerCert), "dapr_sentry.tls.issuer.certPEM="+issuerCert,
fmt.Sprintf("dapr_sentry.tls.issuer.keyPEM=%s", issuerKey), "dapr_sentry.tls.issuer.keyPEM="+issuerKey,
) )
} else { } else {
globalVals = append(globalVals, "global.mtls.enabled=false") globalVals = append(globalVals, "global.mtls.enabled=false")
} }
if len(conf.ImageRegistryURI) != 0 { if len(conf.ImageRegistryURI) != 0 {
globalVals = append(globalVals, fmt.Sprintf("global.registry=%s", conf.ImageRegistryURI)) globalVals = append(globalVals, "global.registry="+conf.ImageRegistryURI)
} }
if haMode { if haMode {
globalVals = append(globalVals, "global.ha.enabled=true") globalVals = append(globalVals, "global.ha.enabled=true")
@ -334,7 +334,7 @@ func newUpgradeClient(namespace string, cfg UpgradeConfig) (*helm.Upgrade, *helm
client.Namespace = namespace client.Namespace = namespace
client.CleanupOnFail = true client.CleanupOnFail = true
client.Wait = true client.Wait = true
client.Timeout = time.Duration(cfg.Timeout) * time.Second client.Timeout = time.Duration(cfg.Timeout) * time.Second //nolint:gosec
return client, helmCfg, nil return client, helmCfg, nil
} }

View File

@ -69,7 +69,7 @@ func tryGetRunDataLock() (*lockfile.Lockfile, error) {
return nil, err return nil, err
} }
for i := 0; i < 10; i++ { for range 10 {
err = lockFile.TryLock() err = lockFile.TryLock()
// Error handling is essential, as we only try to get the lock. // Error handling is essential, as we only try to get the lock.

View File

@ -14,7 +14,7 @@ limitations under the License.
package runexec package runexec
import ( import (
"fmt" "errors"
"io" "io"
"os" "os"
"os/exec" "os/exec"
@ -86,7 +86,7 @@ func (c *CmdProcess) WithOutputWriter(w io.Writer) {
// SetStdout should be called after WithOutputWriter. // SetStdout should be called after WithOutputWriter.
func (c *CmdProcess) SetStdout() error { func (c *CmdProcess) SetStdout() error {
if c.Command == nil { if c.Command == nil {
return fmt.Errorf("command is nil") return errors.New("command is nil")
} }
c.Command.Stdout = c.OutputWriter c.Command.Stdout = c.OutputWriter
return nil return nil
@ -99,7 +99,7 @@ func (c *CmdProcess) WithErrorWriter(w io.Writer) {
// SetStdErr should be called after WithErrorWriter. // SetStdErr should be called after WithErrorWriter.
func (c *CmdProcess) SetStderr() error { func (c *CmdProcess) SetStderr() error {
if c.Command == nil { if c.Command == nil {
return fmt.Errorf("command is nil") return errors.New("command is nil")
} }
c.Command.Stderr = c.ErrorWriter c.Command.Stderr = c.ErrorWriter
return nil return nil
@ -108,7 +108,7 @@ func (c *CmdProcess) SetStderr() error {
func NewOutput(config *standalone.RunConfig) (*RunOutput, error) { func NewOutput(config *standalone.RunConfig) (*RunOutput, error) {
// set default values from RunConfig struct's tag. // set default values from RunConfig struct's tag.
config.SetDefaultFromSchema() config.SetDefaultFromSchema()
//nolint
err := config.Validate() err := config.Validate()
if err != nil { if err != nil {
return nil, err return nil, err

View File

@ -80,10 +80,10 @@ func setupRun(t *testing.T) {
componentsDir := standalone.GetDaprComponentsPath(myDaprPath) componentsDir := standalone.GetDaprComponentsPath(myDaprPath)
configFile := standalone.GetDaprConfigPath(myDaprPath) configFile := standalone.GetDaprConfigPath(myDaprPath)
err = os.MkdirAll(componentsDir, 0o700) err = os.MkdirAll(componentsDir, 0o700)
assert.Equal(t, nil, err, "Unable to setup components dir before running test") assert.NoError(t, err, "Unable to setup components dir before running test")
file, err := os.Create(configFile) file, err := os.Create(configFile)
file.Close() file.Close()
assert.Equal(t, nil, err, "Unable to create config file before running test") assert.NoError(t, err, "Unable to create config file before running test")
} }
func tearDownRun(t *testing.T) { func tearDownRun(t *testing.T) {
@ -94,9 +94,9 @@ func tearDownRun(t *testing.T) {
configFile := standalone.GetDaprConfigPath(myDaprPath) configFile := standalone.GetDaprConfigPath(myDaprPath)
err = os.RemoveAll(componentsDir) err = os.RemoveAll(componentsDir)
assert.Equal(t, nil, err, "Unable to delete default components dir after running test") assert.NoError(t, err, "Unable to delete default components dir after running test")
err = os.Remove(configFile) err = os.Remove(configFile)
assert.Equal(t, nil, err, "Unable to delete default config file after running test") assert.NoError(t, err, "Unable to delete default config file after running test")
} }
func assertCommonArgs(t *testing.T, basicConfig *standalone.RunConfig, output *RunOutput) { func assertCommonArgs(t *testing.T, basicConfig *standalone.RunConfig, output *RunOutput) {
@ -301,10 +301,10 @@ func TestRun(t *testing.T) {
basicConfig.SetDefaultFromSchema() basicConfig.SetDefaultFromSchema()
assert.Equal(t, -1, basicConfig.AppPort) assert.Equal(t, -1, basicConfig.AppPort)
assert.True(t, basicConfig.HTTPPort == -1) assert.Equal(t, -1, basicConfig.HTTPPort)
assert.True(t, basicConfig.GRPCPort == -1) assert.Equal(t, -1, basicConfig.GRPCPort)
assert.True(t, basicConfig.MetricsPort == -1) assert.Equal(t, -1, basicConfig.MetricsPort)
assert.True(t, basicConfig.ProfilePort == -1) assert.Equal(t, -1, basicConfig.ProfilePort)
assert.True(t, basicConfig.EnableProfiling) assert.True(t, basicConfig.EnableProfiling)
assert.Equal(t, -1, basicConfig.MaxConcurrency) assert.Equal(t, -1, basicConfig.MaxConcurrency)
assert.Equal(t, -1, basicConfig.MaxRequestBodySize) assert.Equal(t, -1, basicConfig.MaxRequestBodySize)
@ -316,10 +316,10 @@ func TestRun(t *testing.T) {
assert.NoError(t, err) assert.NoError(t, err)
assert.Equal(t, 0, basicConfig.AppPort) assert.Equal(t, 0, basicConfig.AppPort)
assert.True(t, basicConfig.HTTPPort > 0) assert.Positive(t, basicConfig.HTTPPort)
assert.True(t, basicConfig.GRPCPort > 0) assert.Positive(t, basicConfig.GRPCPort)
assert.True(t, basicConfig.MetricsPort > 0) assert.Positive(t, basicConfig.MetricsPort)
assert.True(t, basicConfig.ProfilePort > 0) assert.Positive(t, basicConfig.ProfilePort)
assert.True(t, basicConfig.EnableProfiling) assert.True(t, basicConfig.EnableProfiling)
assert.Equal(t, -1, basicConfig.MaxConcurrency) assert.Equal(t, -1, basicConfig.MaxConcurrency)
assert.Equal(t, -1, basicConfig.MaxRequestBodySize) assert.Equal(t, -1, basicConfig.MaxRequestBodySize)

View File

@ -72,7 +72,7 @@ func (a *RunFileConfig) validateRunConfig(runFilePath string) error {
a.Common.ResourcesPaths = append(a.Common.ResourcesPaths, a.Common.ResourcesPath) a.Common.ResourcesPaths = append(a.Common.ResourcesPaths, a.Common.ResourcesPath)
} }
for i := 0; i < len(a.Apps); i++ { for i := range len(a.Apps) {
if a.Apps[i].AppDirPath == "" { if a.Apps[i].AppDirPath == "" {
return errors.New("required field 'appDirPath' not found in the provided app config file") return errors.New("required field 'appDirPath' not found in the provided app config file")
} }
@ -223,9 +223,6 @@ func (a *RunFileConfig) resolvePathToAbsAndValidate(baseDir string, paths ...*st
return err return err
} }
absPath := utils.GetAbsPath(baseDir, *path) absPath := utils.GetAbsPath(baseDir, *path)
if err != nil {
return err
}
*path = absPath *path = absPath
if err = utils.ValidateFilePath(*path); err != nil { if err = utils.ValidateFilePath(*path); err != nil {
return err return err

View File

@ -45,7 +45,7 @@ func TestRunConfigFile(t *testing.T) {
err := appsRunConfig.parseAppsConfig(validRunFilePath) err := appsRunConfig.parseAppsConfig(validRunFilePath)
assert.NoError(t, err) assert.NoError(t, err)
assert.Equal(t, 2, len(appsRunConfig.Apps)) assert.Len(t, appsRunConfig.Apps, 2)
assert.Equal(t, 1, appsRunConfig.Version) assert.Equal(t, 1, appsRunConfig.Version)
assert.NotEmpty(t, appsRunConfig.Common.ResourcesPath) assert.NotEmpty(t, appsRunConfig.Common.ResourcesPath)
@ -64,7 +64,7 @@ func TestRunConfigFile(t *testing.T) {
apps, err := config.GetApps(validRunFilePath) apps, err := config.GetApps(validRunFilePath)
assert.NoError(t, err) assert.NoError(t, err)
assert.Equal(t, 2, len(apps)) assert.Len(t, apps, 2)
assert.Equal(t, "webapp", apps[0].AppID) assert.Equal(t, "webapp", apps[0].AppID)
assert.Equal(t, "backend", apps[1].AppID) assert.Equal(t, "backend", apps[1].AppID)
assert.Equal(t, "HTTP", apps[0].AppProtocol) assert.Equal(t, "HTTP", apps[0].AppProtocol)
@ -90,8 +90,8 @@ func TestRunConfigFile(t *testing.T) {
assert.Equal(t, filepath.Join(apps[1].AppDirPath, ".dapr", "resources"), apps[1].ResourcesPaths[0]) assert.Equal(t, filepath.Join(apps[1].AppDirPath, ".dapr", "resources"), apps[1].ResourcesPaths[0])
// test merged envs from common and app sections. // test merged envs from common and app sections.
assert.Equal(t, 2, len(apps[0].Env)) assert.Len(t, apps[0].Env, 2)
assert.Equal(t, 2, len(apps[1].Env)) assert.Len(t, apps[1].Env, 2)
assert.Contains(t, apps[0].Env, "DEBUG") assert.Contains(t, apps[0].Env, "DEBUG")
assert.Contains(t, apps[0].Env, "tty") assert.Contains(t, apps[0].Env, "tty")
assert.Contains(t, apps[1].Env, "DEBUG") assert.Contains(t, apps[1].Env, "DEBUG")
@ -233,7 +233,7 @@ func TestRunConfigFile(t *testing.T) {
config := RunFileConfig{} config := RunFileConfig{}
apps, err := config.GetApps(runFileForLogDestination) apps, err := config.GetApps(runFileForLogDestination)
assert.NoError(t, err) assert.NoError(t, err)
assert.Equal(t, 6, len(apps)) assert.Len(t, apps, 6)
assert.Equal(t, "file", apps[0].DaprdLogDestination.String()) assert.Equal(t, "file", apps[0].DaprdLogDestination.String())
assert.Equal(t, "fileAndConsole", apps[0].AppLogDestination.String()) assert.Equal(t, "fileAndConsole", apps[0].AppLogDestination.String())
@ -346,7 +346,7 @@ func TestMultiResourcePathsResolution(t *testing.T) {
for _, tc := range testcases { for _, tc := range testcases {
t.Run(tc.name, func(t *testing.T) { t.Run(tc.name, func(t *testing.T) {
assert.Equal(t, tc.expectedNoOfResources, len(config.Apps[tc.appIndex].ResourcesPaths)) assert.Len(t, config.Apps[tc.appIndex].ResourcesPaths, tc.expectedNoOfResources)
var rsrcFound bool var rsrcFound bool
for _, resourcePath := range config.Apps[tc.appIndex].ResourcesPaths { for _, resourcePath := range config.Apps[tc.appIndex].ResourcesPaths {
if rsrcFound = strings.Contains(resourcePath, tc.expectedResourcesPathsContains); rsrcFound { if rsrcFound = strings.Contains(resourcePath, tc.expectedResourcesPathsContains); rsrcFound {

View File

@ -85,7 +85,6 @@ func confirmContainerIsRunningOrExists(containerName string, isRunning bool, run
// If 'docker ps' failed due to some reason. // If 'docker ps' failed due to some reason.
if err != nil { if err != nil {
//nolint
return false, fmt.Errorf("unable to confirm whether %s is running or exists. error\n%v", containerName, err.Error()) return false, fmt.Errorf("unable to confirm whether %s is running or exists. error\n%v", containerName, err.Error())
} }
// 'docker ps' worked fine, but the response did not have the container name. // 'docker ps' worked fine, but the response did not have the container name.
@ -100,7 +99,6 @@ func confirmContainerIsRunningOrExists(containerName string, isRunning bool, run
} }
func isContainerRunError(err error) bool { func isContainerRunError(err error) bool {
//nolint
if exitError, ok := err.(*exec.ExitError); ok { if exitError, ok := err.(*exec.ExitError); ok {
exitCode := exitError.ExitCode() exitCode := exitError.ExitCode()
return exitCode == 125 return exitCode == 125
@ -109,7 +107,6 @@ func isContainerRunError(err error) bool {
} }
func parseContainerRuntimeError(component string, err error) error { func parseContainerRuntimeError(component string, err error) error {
//nolint
if exitError, ok := err.(*exec.ExitError); ok { if exitError, ok := err.(*exec.ExitError); ok {
exitCode := exitError.ExitCode() exitCode := exitError.ExitCode()
if exitCode == 125 { // see https://github.com/moby/moby/pull/14012 if exitCode == 125 { // see https://github.com/moby/moby/pull/14012

View File

@ -26,8 +26,8 @@ func TestDashboardRun(t *testing.T) {
assert.NoError(t, err) assert.NoError(t, err)
assert.Contains(t, cmd.Args[0], "dashboard") assert.Contains(t, cmd.Args[0], "dashboard")
assert.Equal(t, cmd.Args[1], "--port") assert.Equal(t, "--port", cmd.Args[1])
assert.Equal(t, cmd.Args[2], "9090") assert.Equal(t, "9090", cmd.Args[2])
}) })
t.Run("start dashboard on random free port", func(t *testing.T) { t.Run("start dashboard on random free port", func(t *testing.T) {
@ -35,7 +35,7 @@ func TestDashboardRun(t *testing.T) {
assert.NoError(t, err) assert.NoError(t, err)
assert.Contains(t, cmd.Args[0], "dashboard") assert.Contains(t, cmd.Args[0], "dashboard")
assert.Equal(t, cmd.Args[1], "--port") assert.Equal(t, "--port", cmd.Args[1])
assert.NotEqual(t, cmd.Args[2], "0") assert.NotEqual(t, "0", cmd.Args[2])
}) })
} }

View File

@ -66,7 +66,7 @@ func List() ([]ListOutput, error) {
for _, proc := range processes { for _, proc := range processes {
executable := strings.ToLower(proc.Executable()) executable := strings.ToLower(proc.Executable())
if (executable == "daprd") || (executable == "daprd.exe") { if (executable == "daprd") || (executable == "daprd.exe") {
procDetails, err := process.NewProcess(int32(proc.Pid())) procDetails, err := process.NewProcess(int32(proc.Pid())) //nolint:gosec
if err != nil { if err != nil {
continue continue
} }

View File

@ -94,7 +94,7 @@ func (s *Standalone) Publish(publishAppID, pubsubName, topic string, payload []b
} }
func getDaprInstance(list []ListOutput, publishAppID string) (ListOutput, error) { func getDaprInstance(list []ListOutput, publishAppID string) (ListOutput, error) {
for i := 0; i < len(list); i++ { for i := range list {
if list[i].AppID == publishAppID { if list[i].AppID == publishAppID {
return list[i], nil return list[i], nil
} }
@ -112,7 +112,7 @@ func getQueryParams(metadata map[string]interface{}) string {
} }
// Prefix with "?" and remove the last "&". // Prefix with "?" and remove the last "&".
if queryParams != "" { if queryParams != "" {
queryParams = fmt.Sprintf("?%s", queryParams[:len(queryParams)-1]) queryParams = "?" + queryParams[:len(queryParams)-1]
} }
return queryParams return queryParams
} }

View File

@ -212,7 +212,7 @@ func TestGetQueryParams(t *testing.T) {
queryParams := getQueryParams(tc.metadata) queryParams := getQueryParams(tc.metadata)
if queryParams != "" { if queryParams != "" {
assert.True(t, queryParams[0] == '?', "expected query params to start with '?'") assert.True(t, strings.HasPrefix(queryParams, "?"), "expected query params to start with '?'")
queryParams = queryParams[1:] queryParams = queryParams[1:]
} }

View File

@ -14,6 +14,7 @@ limitations under the License.
package standalone package standalone
import ( import (
"context"
"fmt" "fmt"
"net" "net"
"os" "os"
@ -28,7 +29,7 @@ import (
"gopkg.in/yaml.v2" "gopkg.in/yaml.v2"
"github.com/dapr/cli/pkg/print" "github.com/dapr/cli/pkg/print"
"github.com/dapr/dapr/pkg/components" localloader "github.com/dapr/dapr/pkg/components/loader"
) )
type LogDestType string type LogDestType string
@ -113,8 +114,8 @@ func (config *RunConfig) validateResourcesPaths() error {
return fmt.Errorf("error validating resources path %q : %w", dirPath, err) return fmt.Errorf("error validating resources path %q : %w", dirPath, err)
} }
} }
componentsLoader := components.NewLocalComponents(dirPath...) localLoader := localloader.NewLocalLoader(config.AppID, dirPath)
_, err := componentsLoader.Load() err := localLoader.Validate(context.Background())
if err != nil { if err != nil {
return fmt.Errorf("error validating components in resources path %q : %w", dirPath, err) return fmt.Errorf("error validating components in resources path %q : %w", dirPath, err)
} }
@ -128,9 +129,9 @@ func (config *RunConfig) validatePlacementHostAddr() error {
} }
if indx := strings.Index(placementHostAddr, ":"); indx == -1 { if indx := strings.Index(placementHostAddr, ":"); indx == -1 {
if runtime.GOOS == daprWindowsOS { if runtime.GOOS == daprWindowsOS {
placementHostAddr = fmt.Sprintf("%s:6050", placementHostAddr) placementHostAddr += ":6050"
} else { } else {
placementHostAddr = fmt.Sprintf("%s:50005", placementHostAddr) placementHostAddr += ":50005"
} }
} }
config.PlacementHostAddr = placementHostAddr config.PlacementHostAddr = placementHostAddr
@ -145,9 +146,9 @@ func (config *RunConfig) validateSchedulerHostAddr() error {
if indx := strings.Index(schedulerHostAddr, ":"); indx == -1 { if indx := strings.Index(schedulerHostAddr, ":"); indx == -1 {
if runtime.GOOS == daprWindowsOS { if runtime.GOOS == daprWindowsOS {
schedulerHostAddr = fmt.Sprintf("%s:6060", schedulerHostAddr) schedulerHostAddr += ":6060"
} else { } else {
schedulerHostAddr = fmt.Sprintf("%s:50006", schedulerHostAddr) schedulerHostAddr += ":50006"
} }
} }
@ -289,7 +290,7 @@ func (meta *DaprMeta) portExists(port int) bool {
if port <= 0 { if port <= 0 {
return false return false
} }
//nolint
_, ok := meta.ExistingPorts[port] _, ok := meta.ExistingPorts[port]
if ok { if ok {
return true return true
@ -346,7 +347,7 @@ func (config *RunConfig) getArgs() []string {
// Recursive function to get all the args from the config struct. // Recursive function to get all the args from the config struct.
// This is needed because the config struct has embedded struct. // This is needed because the config struct has embedded struct.
func getArgsFromSchema(schema reflect.Value, args []string) []string { func getArgsFromSchema(schema reflect.Value, args []string) []string {
for i := 0; i < schema.NumField(); i++ { for i := range schema.NumField() {
valueField := schema.Field(i).Interface() valueField := schema.Field(i).Interface()
typeField := schema.Type().Field(i) typeField := schema.Type().Field(i)
key := typeField.Tag.Get("arg") key := typeField.Tag.Get("arg")
@ -388,7 +389,7 @@ func (config *RunConfig) SetDefaultFromSchema() {
} }
func (config *RunConfig) setDefaultFromSchemaRecursive(schema reflect.Value) { func (config *RunConfig) setDefaultFromSchemaRecursive(schema reflect.Value) {
for i := 0; i < schema.NumField(); i++ { for i := range schema.NumField() {
valueField := schema.Field(i) valueField := schema.Field(i)
typeField := schema.Type().Field(i) typeField := schema.Type().Field(i)
if typeField.Type.Kind() == reflect.Struct { if typeField.Type.Kind() == reflect.Struct {
@ -414,7 +415,7 @@ func (config *RunConfig) getEnv() []string {
// Handle values from config that have an "env" tag. // Handle values from config that have an "env" tag.
schema := reflect.ValueOf(*config) schema := reflect.ValueOf(*config)
for i := 0; i < schema.NumField(); i++ { for i := range schema.NumField() {
valueField := schema.Field(i).Interface() valueField := schema.Field(i).Interface()
typeField := schema.Type().Field(i) typeField := schema.Type().Field(i)
key := typeField.Tag.Get("env") key := typeField.Tag.Get("env")
@ -474,7 +475,7 @@ func (config *RunConfig) getAppProtocol() string {
func (config *RunConfig) GetEnv() map[string]string { func (config *RunConfig) GetEnv() map[string]string {
env := map[string]string{} env := map[string]string{}
schema := reflect.ValueOf(*config) schema := reflect.ValueOf(*config)
for i := 0; i < schema.NumField(); i++ { for i := range schema.NumField() {
valueField := schema.Field(i).Interface() valueField := schema.Field(i).Interface()
typeField := schema.Type().Field(i) typeField := schema.Type().Field(i)
key := typeField.Tag.Get("env") key := typeField.Tag.Get("env")
@ -498,7 +499,7 @@ func (config *RunConfig) GetEnv() map[string]string {
func (config *RunConfig) GetAnnotations() map[string]string { func (config *RunConfig) GetAnnotations() map[string]string {
annotations := map[string]string{} annotations := map[string]string{}
schema := reflect.ValueOf(*config) schema := reflect.ValueOf(*config)
for i := 0; i < schema.NumField(); i++ { for i := range schema.NumField() {
valueField := schema.Field(i).Interface() valueField := schema.Field(i).Interface()
typeField := schema.Type().Field(i) typeField := schema.Type().Field(i)
key := typeField.Tag.Get("annotation") key := typeField.Tag.Get("annotation")

View File

@ -888,7 +888,7 @@ func createSlimConfiguration(wg *sync.WaitGroup, errorChan chan<- error, info in
func makeDefaultComponentsDir(installDir string) error { func makeDefaultComponentsDir(installDir string) error {
// Make default components directory. // Make default components directory.
componentsDir := GetDaprComponentsPath(installDir) componentsDir := GetDaprComponentsPath(installDir)
//nolint
_, err := os.Stat(componentsDir) _, err := os.Stat(componentsDir)
if os.IsNotExist(err) { if os.IsNotExist(err) {
errDir := os.MkdirAll(componentsDir, 0o755) errDir := os.MkdirAll(componentsDir, 0o755)
@ -955,7 +955,7 @@ func unzip(r *zip.Reader, targetDir string, binaryFilePrefix string) (string, er
return "", err return "", err
} }
if strings.HasSuffix(fpath, fmt.Sprintf("%s.exe", binaryFilePrefix)) { if strings.HasSuffix(fpath, binaryFilePrefix+".exe") {
foundBinary = fpath foundBinary = fpath
} }
@ -1013,7 +1013,6 @@ func untar(reader io.Reader, targetDir string, binaryFilePrefix string) (string,
foundBinary := "" foundBinary := ""
for { for {
header, err := tr.Next() header, err := tr.Next()
//nolint
if err == io.EOF { if err == io.EOF {
break break
} else if err != nil { } else if err != nil {
@ -1036,7 +1035,7 @@ func untar(reader io.Reader, targetDir string, binaryFilePrefix string) (string,
continue continue
} }
f, err := os.OpenFile(path, os.O_CREATE|os.O_RDWR, os.FileMode(header.Mode)) f, err := os.OpenFile(path, os.O_CREATE|os.O_RDWR, os.FileMode(header.Mode)) //nolint:gosec
if err != nil { if err != nil {
return "", err return "", err
} }
@ -1085,14 +1084,14 @@ func moveFileToPath(filepath string, installLocation string) (string, error) {
if !strings.Contains(strings.ToLower(p), strings.ToLower(destDir)) { if !strings.Contains(strings.ToLower(p), strings.ToLower(destDir)) {
destDir = utils.SanitizeDir(destDir) destDir = utils.SanitizeDir(destDir)
pathCmd := "[System.Environment]::SetEnvironmentVariable('Path',[System.Environment]::GetEnvironmentVariable('Path','user') + '" + fmt.Sprintf(";%s", destDir) + "', 'user')" pathCmd := "[System.Environment]::SetEnvironmentVariable('Path',[System.Environment]::GetEnvironmentVariable('Path','user') + '" + ";" + destDir + "', 'user')"
_, err := utils.RunCmdAndWait("powershell", pathCmd) _, err := utils.RunCmdAndWait("powershell", pathCmd)
if err != nil { if err != nil {
return "", err return "", err
} }
} }
return fmt.Sprintf("%s\\daprd.exe", destDir), nil return destDir + "\\daprd.exe", nil
} }
if strings.HasPrefix(fileName, daprRuntimeFilePrefix) && installLocation != "" { if strings.HasPrefix(fileName, daprRuntimeFilePrefix) && installLocation != "" {
@ -1117,7 +1116,7 @@ func createRedisStateStore(redisHost string, componentsPath string) error {
redisStore.Spec.Metadata = []componentMetadataItem{ redisStore.Spec.Metadata = []componentMetadataItem{
{ {
Name: "redisHost", Name: "redisHost",
Value: fmt.Sprintf("%s:6379", redisHost), Value: redisHost + ":6379",
}, },
{ {
Name: "redisPassword", Name: "redisPassword",
@ -1152,7 +1151,7 @@ func createRedisPubSub(redisHost string, componentsPath string) error {
redisPubSub.Spec.Metadata = []componentMetadataItem{ redisPubSub.Spec.Metadata = []componentMetadataItem{
{ {
Name: "redisHost", Name: "redisHost",
Value: fmt.Sprintf("%s:6379", redisHost), Value: redisHost + ":6379",
}, },
{ {
Name: "redisPassword", Name: "redisPassword",

View File

@ -98,7 +98,6 @@ func TestResolveImageWithGHCR(t *testing.T) {
} }
for _, test := range tests { for _, test := range tests {
test := test
t.Run(test.name, func(t *testing.T) { t.Run(test.name, func(t *testing.T) {
t.Parallel() t.Parallel()
got, err := resolveImageURI(test.args) got, err := resolveImageURI(test.args)
@ -144,7 +143,6 @@ func TestResolveImageWithDockerHub(t *testing.T) {
} }
for _, test := range tests { for _, test := range tests {
test := test
t.Run(test.name, func(t *testing.T) { t.Run(test.name, func(t *testing.T) {
t.Parallel() t.Parallel()
got, err := resolveImageURI(test.args) got, err := resolveImageURI(test.args)
@ -190,7 +188,6 @@ func TestResolveImageWithPrivateRegistry(t *testing.T) {
} }
for _, test := range tests { for _, test := range tests {
test := test
t.Run(test.name, func(t *testing.T) { t.Run(test.name, func(t *testing.T) {
t.Parallel() t.Parallel()
got, err := resolveImageURI(test.args) got, err := resolveImageURI(test.args)
@ -329,7 +326,7 @@ func TestInitLogActualContainerRuntimeName(t *testing.T) {
} }
err := Init(latestVersion, latestVersion, "", false, "", "", test.containerRuntime, "", "", nil) err := Init(latestVersion, latestVersion, "", false, "", "", test.containerRuntime, "", "", nil)
assert.NotNil(t, err) assert.Error(t, err)
assert.Contains(t, err.Error(), test.containerRuntime) assert.Contains(t, err.Error(), test.containerRuntime)
}) })
} }

View File

@ -15,6 +15,7 @@ package version
import ( import (
"encoding/json" "encoding/json"
"errors"
"fmt" "fmt"
"io" "io"
"net/http" "net/http"
@ -112,7 +113,7 @@ func GetLatestReleaseGithub(githubURL string) (string, error) {
} }
if len(githubRepoReleases) == 0 { if len(githubRepoReleases) == 0 {
return "", fmt.Errorf("no releases") return "", errors.New("no releases")
} }
defaultVersion, _ := version.NewVersion("0.0.0") defaultVersion, _ := version.NewVersion("0.0.0")
@ -135,7 +136,7 @@ func GetLatestReleaseGithub(githubURL string) (string, error) {
} }
if latestVersion.Equal(defaultVersion) { if latestVersion.Equal(defaultVersion) {
return "", fmt.Errorf("no releases") return "", errors.New("no releases")
} }
return latestVersion.String(), nil return latestVersion.String(), nil
@ -151,7 +152,7 @@ func GetLatestReleaseHelmChart(helmChartURL string) (string, error) {
return "", err return "", err
} }
if len(helmChartReleases.Entries.Dapr) == 0 { if len(helmChartReleases.Entries.Dapr) == 0 {
return "", fmt.Errorf("no releases") return "", errors.New("no releases")
} }
for _, release := range helmChartReleases.Entries.Dapr { for _, release := range helmChartReleases.Entries.Dapr {
@ -166,6 +167,6 @@ func GetLatestReleaseHelmChart(helmChartURL string) (string, error) {
return release.Version, nil return release.Version, nil
} }
return "", fmt.Errorf("no releases") return "", errors.New("no releases")
}) })
} }

View File

@ -225,7 +225,7 @@ func TestGetVersionsGithub(t *testing.T) {
for _, tc := range tests { for _, tc := range tests {
t.Run(tc.Name, func(t *testing.T) { t.Run(tc.Name, func(t *testing.T) {
version, err := GetLatestReleaseGithub(fmt.Sprintf("http://localhost:12345%s", tc.Path)) version, err := GetLatestReleaseGithub("http://localhost:12345" + tc.Path)
assert.Equal(t, tc.ExpectedVer, version) assert.Equal(t, tc.ExpectedVer, version)
if tc.ExpectedErr != "" { if tc.ExpectedErr != "" {
assert.EqualError(t, err, tc.ExpectedErr) assert.EqualError(t, err, tc.ExpectedErr)
@ -334,7 +334,7 @@ entries:
for _, tc := range tests { for _, tc := range tests {
t.Run(tc.Name, func(t *testing.T) { t.Run(tc.Name, func(t *testing.T) {
version, err := GetLatestReleaseHelmChart(fmt.Sprintf("http://localhost:12346%s", tc.Path)) version, err := GetLatestReleaseHelmChart("http://localhost:12346" + tc.Path)
assert.Equal(t, tc.ExpectedVer, version) assert.Equal(t, tc.ExpectedVer, version)
if tc.ExpectedErr != "" { if tc.ExpectedErr != "" {
assert.EqualError(t, err, tc.ExpectedErr) assert.EqualError(t, err, tc.ExpectedErr)

View File

@ -906,7 +906,7 @@ func componentsTestOnUninstall(opts TestOptions) func(t *testing.T) {
lines := strings.Split(output, "\n") lines := strings.Split(output, "\n")
// An extra empty line is there in output. // An extra empty line is there in output.
require.Equal(t, 3, len(lines), "expected header and warning message of the output to remain") require.Len(t, lines, 3, "expected header and warning message of the output to remain")
} }
} }
@ -936,7 +936,7 @@ func httpEndpointsTestOnUninstall(opts TestOptions) func(t *testing.T) {
lines := strings.Split(output, "\n") lines := strings.Split(output, "\n")
// An extra empty line is there in output. // An extra empty line is there in output.
require.Equal(t, 2, len(lines), "expected kubernetes response message to remain") require.Len(t, lines, 2, "expected kubernetes response message to remain")
} }
} }
} }
@ -959,7 +959,7 @@ func componentOutputCheck(t *testing.T, opts TestOptions, output string) {
} }
if opts.UninstallAll { if opts.UninstallAll {
assert.Equal(t, 2, len(lines), "expected at 0 components and 2 output lines") assert.Len(t, lines, 2, "expected at 0 components and 2 output lines")
return return
} }
@ -969,9 +969,9 @@ func componentOutputCheck(t *testing.T, opts TestOptions, output string) {
// default, test statestore. // default, test statestore.
// default pubsub. // default pubsub.
// 3 components. // 3 components.
assert.Equal(t, 3, len(lines), "expected 3 components") assert.Len(t, lines, 3, "expected 3 components")
} else { } else {
assert.Equal(t, 2, len(lines), "expected 2 components") // default and test namespace components. assert.Len(t, lines, 2, "expected 2 components") // default and test namespace components.
// for fresh cluster only one component yaml has been applied. // for fresh cluster only one component yaml has been applied.
testNsFields := strings.Fields(lines[0]) testNsFields := strings.Fields(lines[0])

View File

@ -76,7 +76,6 @@ func TestContainerRuntimeUtils(t *testing.T) {
} }
for _, tc := range testcases { for _, tc := range testcases {
tc := tc
t.Run(tc.name, func(t *testing.T) { t.Run(tc.name, func(t *testing.T) {
t.Parallel() t.Parallel()
actualValid := IsValidContainerRuntime(tc.input) actualValid := IsValidContainerRuntime(tc.input)
@ -120,7 +119,6 @@ func TestContains(t *testing.T) {
} }
for _, tc := range testcases { for _, tc := range testcases {
tc := tc
t.Run(tc.name, func(t *testing.T) { t.Run(tc.name, func(t *testing.T) {
t.Parallel() t.Parallel()
actualValid := Contains(tc.input, tc.expected) actualValid := Contains(tc.input, tc.expected)
@ -165,7 +163,6 @@ func TestGetVersionAndImageVariant(t *testing.T) {
} }
for _, tc := range testcases { for _, tc := range testcases {
tc := tc
t.Run(tc.name, func(t *testing.T) { t.Run(tc.name, func(t *testing.T) {
t.Parallel() t.Parallel()
version, imageVariant := GetVersionAndImageVariant(tc.input) version, imageVariant := GetVersionAndImageVariant(tc.input)
@ -202,7 +199,6 @@ func TestValidateFilePaths(t *testing.T) {
} }
for _, tc := range testcases { for _, tc := range testcases {
tc := tc
t.Run(tc.name, func(t *testing.T) { t.Run(tc.name, func(t *testing.T) {
t.Parallel() t.Parallel()
actual := ValidateFilePath(tc.input) actual := ValidateFilePath(tc.input)
@ -244,7 +240,6 @@ func TestGetAbsPath(t *testing.T) {
} }
for _, tc := range testcases { for _, tc := range testcases {
tc := tc
t.Run(tc.name, func(t *testing.T) { t.Run(tc.name, func(t *testing.T) {
t.Parallel() t.Parallel()
actual := GetAbsPath(baseDir, tc.input) actual := GetAbsPath(baseDir, tc.input)
@ -302,7 +297,6 @@ func TestResolveHomeDir(t *testing.T) {
} }
for _, tc := range testcases { for _, tc := range testcases {
tc := tc
t.Run(tc.name, func(t *testing.T) { t.Run(tc.name, func(t *testing.T) {
if tc.skipWindows && runtime.GOOS == "windows" { if tc.skipWindows && runtime.GOOS == "windows" {
t.Skip("Skipping test on Windows") t.Skip("Skipping test on Windows")
@ -335,7 +329,6 @@ func TestReadFile(t *testing.T) {
}, },
} }
for _, tc := range testcases { for _, tc := range testcases {
tc := tc
t.Run(tc.name, func(t *testing.T) { t.Run(tc.name, func(t *testing.T) {
t.Parallel() t.Parallel()
_, actual := ReadFile(tc.input) _, actual := ReadFile(tc.input)
@ -398,7 +391,6 @@ func TestFindFileInDir(t *testing.T) {
}, },
} }
for _, tc := range testcases { for _, tc := range testcases {
tc := tc
t.Run(tc.name, func(t *testing.T) { t.Run(tc.name, func(t *testing.T) {
t.Parallel() t.Parallel()
filePath, err := FindFileInDir(tc.input, "dapr.yaml") filePath, err := FindFileInDir(tc.input, "dapr.yaml")
@ -480,7 +472,6 @@ func TestPrintDetail(t *testing.T) {
} }
for _, tc := range testcases { for _, tc := range testcases {
tc := tc
t.Run(tc.name, func(t *testing.T) { t.Run(tc.name, func(t *testing.T) {
t.Parallel() t.Parallel()
var buf bytes.Buffer var buf bytes.Buffer
@ -552,7 +543,6 @@ func TestSanitizeDir(t *testing.T) {
} }
for _, tc := range testcases { for _, tc := range testcases {
tc := tc
t.Run(tc.name, func(t *testing.T) { t.Run(tc.name, func(t *testing.T) {
t.Parallel() t.Parallel()
actual := SanitizeDir(tc.input) actual := SanitizeDir(tc.input)