Skip to content

Commit

Permalink
Bumping golang 1.20.3 and golint changes (#743)
Browse files Browse the repository at this point in the history
Signed-off-by: sethiyash <[email protected]>
  • Loading branch information
sethiyash authored May 4, 2023
1 parent 0ffc5fc commit 5770b80
Show file tree
Hide file tree
Showing 28 changed files with 44 additions and 45 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.19.5
go-version: 1.20.3
- uses: actions/checkout@v2
with:
fetch-depth: '0'
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
uses: golangci/golangci-lint-action@v3.4.0
with:
version: v1.45.2
version: v1.52.2
args: -v
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.19.5
go-version: 1.20.3
- name: Retrieve version
run: |
echo "TAG_NAME=$(echo ${{ github.ref }} | grep -Eo 'v[0-9].*')" >> $GITHUB_OUTPUT
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-gh-k8s-1.16.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.19.5
go-version: 1.20.3
- name: Check out code into the Go module directory
uses: actions/checkout@v2
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-gh.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.19.5
go-version: 1.20.3
- name: Check out code into the Go module directory
uses: actions/checkout@v2
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/trivy-scan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
with:
repo: carvel-dev/kapp
tool: kapp
goVersion: 1.19.5
goVersion: 1.20.3
secrets:
githubToken: ${{ secrets.GITHUB_TOKEN }}
slackWebhookURL: ${{ secrets.SLACK_WEBHOOK_URL }}
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/vmware-tanzu/carvel-kapp

go 1.19
go 1.20

require (
github.com/cppforlife/cobrautil v0.0.0-20221130162803-acdfead391ef
Expand Down
4 changes: 2 additions & 2 deletions pkg/kapp/app/labeled_app.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func (a *LabeledApp) UsedGVs() ([]schema.GroupVersion, error)
func (a *LabeledApp) UsedGKs() (*[]schema.GroupKind, error) { return nil, nil }
func (a *LabeledApp) UpdateUsedGVsAndGKs([]schema.GroupVersion, []schema.GroupKind) error { return nil }

func (a *LabeledApp) CreateOrUpdate(prevAppName string, labels map[string]string, isDiffRun bool) (bool, error) {
func (a *LabeledApp) CreateOrUpdate(_ string, _ map[string]string, _ bool) (bool, error) {
return false, nil
}
func (a *LabeledApp) Exists() (bool, string, error) { return true, "", nil }
Expand Down Expand Up @@ -78,6 +78,6 @@ func (a *LabeledApp) Meta() (Meta, error) { return Meta{}, nil }
func (a *LabeledApp) Changes() ([]Change, error) { return nil, nil }
func (a *LabeledApp) LastChange() (Change, error) { return nil, nil }
func (a *LabeledApp) BeginChange(ChangeMeta) (Change, error) { return NoopChange{}, nil }
func (a *LabeledApp) GCChanges(max int, reviewFunc func(changesToDelete []Change) error) (int, int, error) {
func (a *LabeledApp) GCChanges(_ int, _ func(changesToDelete []Change) error) (int, int, error) {
return 0, 0, nil
}
2 changes: 1 addition & 1 deletion pkg/kapp/clusterapply/converged_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ var (
uiWaitChildMsgPrefix = " " + uiWaitMsgPrefix
)

func (c ConvergedResource) buildParentDescMsg(res ctlres.Resource, state ctlresm.DoneApplyState) []string {
func (c ConvergedResource) buildParentDescMsg(_ ctlres.Resource, state ctlresm.DoneApplyState) []string {
if len(state.Message) > 0 {
return []string{uiWaitMsgPrefix + state.Message}
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/kapp/cmd/app/deploy_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func NewDeployConfigOptions(ui ui.UI, depsFactory cmdcore.DepsFactory) *DeployCo
return &DeployConfigOptions{ui: ui, depsFactory: depsFactory}
}

func NewDeployConfigCmd(o *DeployConfigOptions, flagsFactory cmdcore.FlagsFactory) *cobra.Command {
func NewDeployConfigCmd(o *DeployConfigOptions, _ cmdcore.FlagsFactory) *cobra.Command {
cmd := &cobra.Command{
Use: "deploy-config",
Short: "Show default deploy config",
Expand Down
2 changes: 1 addition & 1 deletion pkg/kapp/cmd/core/generate_name_flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ type GenerateNameFlags struct {
GenerateName bool
}

func (s *GenerateNameFlags) Set(cmd *cobra.Command, flagsFactory FlagsFactory) {
func (s *GenerateNameFlags) Set(cmd *cobra.Command, _ FlagsFactory) {
cmd.Flags().BoolVar(&s.GenerateName, "generate-name", false, "Set to generate name")
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/kapp/cmd/core/kube_api_flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ type KubeAPIFlags struct {
Burst int
}

func (f *KubeAPIFlags) Set(cmd *cobra.Command, flagsFactory FlagsFactory) {
func (f *KubeAPIFlags) Set(cmd *cobra.Command, _ FlagsFactory) {
// Similar names are used by kubelet and other controllers
cmd.PersistentFlags().Float32Var(&f.QPS, "kube-api-qps", 1000, "Set Kubernetes API client QPS limit")
cmd.PersistentFlags().IntVar(&f.Burst, "kube-api-burst", 1000, "Set Kubernetes API client burst limit")
Expand Down
2 changes: 1 addition & 1 deletion pkg/kapp/cmd/core/kubeconfig_flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ type KubeconfigFlags struct {
YAML *KubeconfigYAMLFlag
}

func (f *KubeconfigFlags) Set(cmd *cobra.Command, flagsFactory FlagsFactory) {
func (f *KubeconfigFlags) Set(cmd *cobra.Command, _ FlagsFactory) {
f.Path = NewKubeconfigPathFlag()
cmd.PersistentFlags().Var(f.Path, "kubeconfig", "Path to the kubeconfig file ($KAPP_KUBECONFIG)")

Expand Down
4 changes: 2 additions & 2 deletions pkg/kapp/cmd/core/unknown_bool_value.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@ func (t ValueUnknownBool) String() string {
return ""
}

func (t ValueUnknownBool) Value() uitable.Value { return t }
func (t ValueUnknownBool) Compare(other uitable.Value) int { panic("Never called") }
func (t ValueUnknownBool) Value() uitable.Value { return t }
func (t ValueUnknownBool) Compare(_ uitable.Value) int { panic("Never called") }
2 changes: 1 addition & 1 deletion pkg/kapp/cmd/logger_flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ type LoggerFlags struct {
Debug bool
}

func (f *LoggerFlags) Set(cmd *cobra.Command, flagsFactory cmdcore.FlagsFactory) {
func (f *LoggerFlags) Set(cmd *cobra.Command, _ cmdcore.FlagsFactory) {
cmd.PersistentFlags().BoolVar(&f.Debug, "debug", false, "Include debug output")
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/kapp/cmd/tools/diff.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func NewDiffOptions(ui ui.UI, depsFactory cmdcore.DepsFactory) *DiffOptions {
return &DiffOptions{ui: ui, depsFactory: depsFactory}
}

func NewDiffCmd(o *DiffOptions, flagsFactory cmdcore.FlagsFactory) *cobra.Command {
func NewDiffCmd(o *DiffOptions, _ cmdcore.FlagsFactory) *cobra.Command {
cmd := &cobra.Command{
Use: "diff",
Short: "Diff files against files2",
Expand Down
2 changes: 1 addition & 1 deletion pkg/kapp/cmd/tools/inspect.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func NewInspectOptions(ui ui.UI, depsFactory cmdcore.DepsFactory) *InspectOption
return &InspectOptions{ui: ui, depsFactory: depsFactory}
}

func NewInspectCmd(o *InspectOptions, flagsFactory cmdcore.FlagsFactory) *cobra.Command {
func NewInspectCmd(o *InspectOptions, _ cmdcore.FlagsFactory) *cobra.Command {
cmd := &cobra.Command{
Use: "inspect",
Aliases: []string{"i"},
Expand Down
6 changes: 3 additions & 3 deletions pkg/kapp/cmd/tools/inspect_tree_view.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,9 +204,9 @@ type ValueColored struct {
Func func(string, ...interface{}) string
}

func (t ValueColored) String() string { return t.S }
func (t ValueColored) Value() uitable.Value { return t }
func (t ValueColored) Compare(other uitable.Value) int { panic("Never called") }
func (t ValueColored) String() string { return t.S }
func (t ValueColored) Value() uitable.Value { return t }
func (t ValueColored) Compare(_ uitable.Value) int { panic("Never called") }

func (t ValueColored) Fprintf(w io.Writer, pattern string, rest ...interface{}) (int, error) {
return fmt.Fprintf(w, "%s", t.Func(pattern, rest...))
Expand Down
2 changes: 1 addition & 1 deletion pkg/kapp/cmd/tools/list_labels.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func NewListLabelsOptions(ui ui.UI, depsFactory cmdcore.DepsFactory, logger logg
return &ListLabelsOptions{ui: ui, depsFactory: depsFactory, logger: logger}
}

func NewListLabelsCmd(o *ListLabelsOptions, flagsFactory cmdcore.FlagsFactory) *cobra.Command {
func NewListLabelsCmd(o *ListLabelsOptions, _ cmdcore.FlagsFactory) *cobra.Command {
cmd := &cobra.Command{
Use: "list-labels",
Aliases: []string{"ls-labels"},
Expand Down
2 changes: 1 addition & 1 deletion pkg/kapp/cmd/ui_flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ type UIFlags struct {
Columns []string
}

func (f *UIFlags) Set(cmd *cobra.Command, flagsFactory cmdcore.FlagsFactory) {
func (f *UIFlags) Set(cmd *cobra.Command, _ cmdcore.FlagsFactory) {
cmd.PersistentFlags().BoolVar(&f.Color, "color", true, "Set color output")
cmd.PersistentFlags().BoolVar(&f.JSON, "json", false, "Output as JSON")
cmd.PersistentFlags().BoolVarP(&f.NonInteractive, "yes", "y", false, "Assume yes for any prompt")
Expand Down
2 changes: 1 addition & 1 deletion pkg/kapp/cmd/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func NewVersionOptions(ui ui.UI) *VersionOptions {
return &VersionOptions{ui}
}

func NewVersionCmd(o *VersionOptions, flagsFactory cmdcore.FlagsFactory) *cobra.Command {
func NewVersionCmd(o *VersionOptions, _ cmdcore.FlagsFactory) *cobra.Command {
cmd := &cobra.Command{
Use: "version",
Short: "Print client version",
Expand Down
2 changes: 1 addition & 1 deletion pkg/kapp/cmd/warning_flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ type WarningFlags struct {
Warnings bool
}

func (f *WarningFlags) Set(cmd *cobra.Command, flagsFactory cmdcore.FlagsFactory) {
func (f *WarningFlags) Set(cmd *cobra.Command, _ cmdcore.FlagsFactory) {
cmd.PersistentFlags().BoolVar(&f.Warnings, "warnings", true, "Show warnings")
}

Expand Down
12 changes: 6 additions & 6 deletions pkg/kapp/diffgraph/change.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,15 +185,15 @@ func (c *Change) AllRules() ([]ChangeRule, error) {
}

func (c *Change) ApplicableRules() ([]ChangeRule, error) {
var upsert, delete bool
var isUpsert, isDelete bool

op := c.Change.Op()

switch op {
case ActualChangeOpUpsert:
upsert = true
isUpsert = true
case ActualChangeOpDelete:
delete = true
isDelete = true
case ActualChangeOpNoop:
default:
return nil, fmt.Errorf("Unknown change operation: %s", op)
Expand All @@ -206,15 +206,15 @@ func (c *Change) ApplicableRules() ([]ChangeRule, error) {

var applicableRules []ChangeRule
for _, rule := range rules {
if (upsert && rule.Action == ChangeRuleActionUpsert) ||
(delete && rule.Action == ChangeRuleActionDelete) {
if (isUpsert && rule.Action == ChangeRuleActionUpsert) ||
(isDelete && rule.Action == ChangeRuleActionDelete) {
applicableRules = append(applicableRules, rule)
}
}
return applicableRules, nil
}

func (cs Changes) MatchesRule(rule ChangeRule, exceptChange *Change) ([]*Change, error) {
func (cs Changes) MatchesRule(rule ChangeRule, _ *Change) ([]*Change, error) {
var result []*Change

for _, change := range cs {
Expand Down
2 changes: 1 addition & 1 deletion pkg/kapp/diffui/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ type diffDataChange struct {
WaitingForIDs []string `json:"waitingForIDs"`
}

func (s *Server) mainHandler(w http.ResponseWriter, r *http.Request) {
func (s *Server) mainHandler(w http.ResponseWriter, _ *http.Request) {
changesGraph := s.opts.DiffDataFunc()

allChanges := changesGraph.All()
Expand Down
10 changes: 5 additions & 5 deletions pkg/kapp/logger/noop.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ var _ Logger = NoopLogger{}
func NewNoopLogger() NoopLogger { return NoopLogger{} }
func NewTODOLogger() NoopLogger { return NewNoopLogger() }

func (l NoopLogger) Error(msg string, args ...interface{}) {}
func (l NoopLogger) Info(msg string, args ...interface{}) {}
func (l NoopLogger) Debug(msg string, args ...interface{}) {}
func (l NoopLogger) DebugFunc(name string) FuncLogger { return NoopFuncLogger{} }
func (l NoopLogger) NewPrefixed(name string) Logger { return l }
func (l NoopLogger) Error(_ string, _ ...interface{}) {}
func (l NoopLogger) Info(_ string, _ ...interface{}) {}
func (l NoopLogger) Debug(_ string, _ ...interface{}) {}
func (l NoopLogger) DebugFunc(_ string) FuncLogger { return NoopFuncLogger{} }
func (l NoopLogger) NewPrefixed(_ string) Logger { return l }

type NoopFuncLogger struct{}

Expand Down
5 changes: 2 additions & 3 deletions pkg/kapp/logs/pod_container_log.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,9 @@ func (l PodContainerLog) Tail(ui ui.UI, cancelCh chan struct{}) error {
// Making it 1sec instead of 500ms as some times for initContainers, it fetches the older stream if we go by 500ms.
time.Sleep(1 * time.Second)
continue
} else {
ui.BeginLinef("%s# ending tailing '%s' logs\n", linePrefix, l.tag)
return nil
}
ui.BeginLinef("%s# ending tailing '%s' logs\n", linePrefix, l.tag)
return nil

}
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion pkg/kapp/resources/identified_resources_list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func (r *FakeResources) Create(ctlres.Resource) (ctlres.Resource, error) { retur

type FakeResourceTypes struct{}

func (r *FakeResourceTypes) All(ignoreCachedResTypes bool) ([]ctlres.ResourceType, error) {
func (r *FakeResourceTypes) All(_ bool) ([]ctlres.ResourceType, error) {
return nil, nil
}
func (r *FakeResourceTypes) Find(ctlres.Resource) (ctlres.ResourceType, error) {
Expand Down
2 changes: 1 addition & 1 deletion pkg/kapp/resourcesmisc/apps_v1_stateful_set.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ type AppsV1StatefulSet struct {
resource ctlres.Resource
}

func NewAppsV1StatefulSet(resource ctlres.Resource, associatedRs []ctlres.Resource) *AppsV1StatefulSet {
func NewAppsV1StatefulSet(resource ctlres.Resource, _ []ctlres.Resource) *AppsV1StatefulSet {
matcher := ctlres.APIVersionKindMatcher{
APIVersion: "apps/v1",
Kind: "StatefulSet",
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/fallback_allowed_ns_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ data:
})
}

func ScopedContext(t *testing.T, kubectl Kubectl, serviceAccountName, contextName, userName string) func() {
func ScopedContext(t *testing.T, kubectl Kubectl, _, contextName, userName string) func() {
token := kubectl.Run([]string{"get", "secret", "scoped-sa", "-o", "jsonpath={.data.token}"})

tokenDecoded, err := base64.StdEncoding.DecodeString(token)
Expand Down

0 comments on commit 5770b80

Please sign in to comment.