Skip to content

Commit

Permalink
Fix unused-parameter golangci-lint revive linter (kyma-project#9857)
Browse files Browse the repository at this point in the history
* Fix unused-parameter golangci-lint revive linter

* Add more place
  • Loading branch information
Sawthis authored Feb 13, 2024
1 parent 7897704 commit 8ff8b1f
Show file tree
Hide file tree
Showing 11 changed files with 36 additions and 14 deletions.
4 changes: 3 additions & 1 deletion cmd/gardener-rotate/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ package main

import (
"context"
"github.com/kyma-project/test-infra/pkg/gcp/secretmanager"
"os"

"github.com/kyma-project/test-infra/pkg/gcp/secretmanager"

"github.com/sirupsen/logrus"
"github.com/spf13/cobra"

Expand Down Expand Up @@ -60,6 +61,7 @@ func main() {
Use: "gardener-rotate",
Short: "gardener-rotate rotates kubeconfig saved in Secret Manager",
Long: `gardener-rotate creates new gardener service account token and saves updated kubeconfig in Secret Manager`,
//nolint:revive
Run: func(cmd *cobra.Command, args []string) {
log.SetLevel(logrus.InfoLevel)
ctx := context.Background()
Expand Down
6 changes: 5 additions & 1 deletion cmd/image-detector/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ package main
import (
"context"
"fmt"
"github.com/kyma-project/test-infra/pkg/github/bumper"
"io"
"log"
"os"
"sort"

"github.com/kyma-project/test-infra/pkg/github/bumper"

"github.com/kyma-project/test-infra/pkg/extractimageurls"
"github.com/kyma-project/test-infra/pkg/securityconfig"
"github.com/spf13/cobra"
Expand Down Expand Up @@ -46,6 +47,7 @@ var rootCmd = &cobra.Command{
Use: "image-detector",
Short: "Image Detector CLI",
Long: "Command-Line tool to retrieve list of images and update security-config",
//nolint:revive
Run: func(cmd *cobra.Command, args []string) {
// load security config
reader, err := os.Open(SecScannerConfig)
Expand Down Expand Up @@ -193,6 +195,8 @@ type client struct {

// Changes returns a slice of functions, each one does some stuff, and
// returns commit message for the changes
//
//nolint:revive
func (c *client) Changes() []func(context.Context) (string, []string, error) {
return []func(context.Context) (string, []string, error){
func(ctx context.Context) (string, []string, error) {
Expand Down
4 changes: 3 additions & 1 deletion cmd/image-syncer/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ package main
import (
"context"
"fmt"
"github.com/kyma-project/test-infra/pkg/imagesync"
"os"
"os/signal"
"syscall"

"github.com/kyma-project/test-infra/pkg/imagesync"

"github.com/google/go-containerregistry/pkg/authn"
"github.com/google/go-containerregistry/pkg/name"
"github.com/google/go-containerregistry/pkg/v1/remote"
Expand Down Expand Up @@ -221,6 +222,7 @@ func main() {
Use: "image-syncer",
Short: "image-syncer copies images between docker registries",
Long: `image-syncer copies docker images. It compares checksum between source and target and protects target images against overriding`,
//nolint:revive
Run: func(cmd *cobra.Command, args []string) {
logLevel := logrus.InfoLevel
if cfg.Debug {
Expand Down
6 changes: 4 additions & 2 deletions cmd/image-url-helper/cmd/check.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ package cmd

import (
"fmt"
"os"
"path/filepath"

"github.com/kyma-project/test-infra/pkg/image-url-helper/check"
"github.com/kyma-project/test-infra/pkg/image-url-helper/common"
"github.com/kyma-project/test-infra/pkg/image-url-helper/list"
"os"
"path/filepath"

"github.com/jamiealquiza/envy"
"github.com/spf13/cobra"
Expand All @@ -26,6 +27,7 @@ func CheckCmd() *cobra.Command {
Long: "Find all image usages that doesn't use imageurl template",
Example: "image-url-helper list",
Args: cobra.ExactArgs(0),
//nolint:revive
Run: func(cmd *cobra.Command, args []string) {
// remove trailing slash to have consistent paths
ResourcesDirectoryClean := filepath.Clean(ResourcesDirectory)
Expand Down
6 changes: 4 additions & 2 deletions cmd/image-url-helper/cmd/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ package cmd

import (
"fmt"
"github.com/kyma-project/test-infra/pkg/image-url-helper/common"
"github.com/kyma-project/test-infra/pkg/image-url-helper/list"
"os"
"path/filepath"

"github.com/kyma-project/test-infra/pkg/image-url-helper/common"
"github.com/kyma-project/test-infra/pkg/image-url-helper/list"

"github.com/jamiealquiza/envy"
"github.com/spf13/cobra"
)
Expand All @@ -25,6 +26,7 @@ func ListCmd() *cobra.Command {
Long: "List all images used in Helm charts by checking values.yaml files",
Example: "image-url-helper list",
Args: cobra.ExactArgs(0),
//nolint:revive
Run: func(cmd *cobra.Command, args []string) {

// remove trailing slash to have consistent paths
Expand Down
6 changes: 4 additions & 2 deletions cmd/image-url-helper/cmd/missing.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package cmd

import (
"os"
"path/filepath"

"github.com/kyma-project/test-infra/pkg/image-url-helper/common"
"github.com/kyma-project/test-infra/pkg/image-url-helper/list"
"github.com/kyma-project/test-infra/pkg/image-url-helper/missing"
"os"
"path/filepath"

"github.com/jamiealquiza/envy"
"github.com/spf13/cobra"
Expand All @@ -26,6 +27,7 @@ func MissingCmd() *cobra.Command {
Long: "Find all images that don't exist",
Example: "image-url-helper missing",
Args: cobra.ExactArgs(0),
//nolint:revive
Run: func(cmd *cobra.Command, args []string) {
// remove trailing slash to have consistent paths
ResourcesDirectoryClean := filepath.Clean(ResourcesDirectory)
Expand Down
6 changes: 4 additions & 2 deletions cmd/image-url-helper/cmd/promote.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ package cmd

import (
"fmt"
"github.com/kyma-project/test-infra/pkg/image-url-helper/common"
"github.com/kyma-project/test-infra/pkg/image-url-helper/promote"
"os"
"path/filepath"

"github.com/kyma-project/test-infra/pkg/image-url-helper/common"
"github.com/kyma-project/test-infra/pkg/image-url-helper/promote"

"github.com/jamiealquiza/envy"
"github.com/spf13/cobra"
)
Expand All @@ -27,6 +28,7 @@ func PromoteCmd() *cobra.Command {
Long: "Replace container registry and image version values in values.yaml files with selected ones",
Example: "image-url-helper promote --target-container-registry abc --target-tag release-1",
Args: cobra.ExactArgs(0),
//nolint:revive
Run: func(cmd *cobra.Command, args []string) {
// remove trailing slash to have consistent paths
ResourcesDirectoryClean := filepath.Clean(ResourcesDirectory)
Expand Down
5 changes: 4 additions & 1 deletion cmd/markdown-index/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ import (
"bufio"
"context"
"fmt"
"github.com/kyma-project/test-infra/pkg/github/bumper"
"log"
"os"
"path/filepath"
"strings"

"github.com/kyma-project/test-infra/pkg/github/bumper"

"github.com/sirupsen/logrus"
flag "github.com/spf13/pflag"
"sigs.k8s.io/yaml"
Expand All @@ -25,6 +26,7 @@ type client struct {
// returns commit message for the changes
func (c *client) Changes() []func(context.Context) (string, []string, error) {
return []func(context.Context) (string, []string, error){
//nolint:revive
func(ctx context.Context) (string, []string, error) {
return "Bumping index.md", []string{"docs/index.md"}, nil
},
Expand Down Expand Up @@ -56,6 +58,7 @@ func main() {
}

startPath, err := os.Getwd()
//nolint:revive
filepath.Walk(startPath, func(path string, info os.FileInfo, e error) error {
if filterByFileExtension(path) && filterByFolderName(path, o) && filterByFileName(path, o) {
mdLine := getDescription(path, o)
Expand Down
4 changes: 3 additions & 1 deletion cmd/tools/prtagbuilder/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ package main

import (
"fmt"
"github.com/kyma-project/test-infra/pkg/tools/prtagbuilder"
"os"

"github.com/kyma-project/test-infra/pkg/tools/prtagbuilder"

"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
Expand All @@ -17,6 +18,7 @@ var (
rootCmd = &cobra.Command{
Use: "prtagbuilder [-o, --org string], [-r, --repo string], [-b --baseref string], [-O --numberonly]",
Short: "prtagbuilder will find pull request number for commit or branch head.",
//nolint:revive
RunE: func(cmd *cobra.Command, args []string) error {
numFlags := cmd.Flags().NFlag()
if numFlags == 1 && !cmd.Flags().Changed("numberonly") || numFlags > 1 {
Expand Down
1 change: 1 addition & 0 deletions pkg/extractimageurls/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ func FromFiles(files []string, extract ExtractFunc) ([]string, error) {
// FindFilesInDirectory returns list of files that match regexp under specified directory
func FindFilesInDirectory(rootPath, regex string) ([]string, error) {
var files []string
//nolint:revive
err := filepath.Walk(rootPath, func(path string, info fs.FileInfo, err error) error {
re := regexp.MustCompile(regex)

Expand Down
2 changes: 1 addition & 1 deletion prow/images/golangci-lint/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

This folder contains the Golangci-lint image that is based on the upstream Golangci-lint image. Use it to lint Go source files.

The image contains `golangci-lint vv1.46.2`.
The image contains `golangci-lint v1.56.1`.

## Installation

Expand Down

0 comments on commit 8ff8b1f

Please sign in to comment.