Skip to content

Commit

Permalink
remove bundle injection, make golangci-lint config consistent
Browse files Browse the repository at this point in the history
Signed-off-by: Joe Lanford <[email protected]>
  • Loading branch information
joelanford committed Apr 25, 2024
1 parent 838dd0a commit a6286fb
Show file tree
Hide file tree
Showing 27 changed files with 372 additions and 238 deletions.
6 changes: 3 additions & 3 deletions .bingo/Variables.mk
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ $(BINGO): $(BINGO_DIR)/bingo.mod
@echo "(re)installing $(GOBIN)/bingo-v0.9.0"
@cd $(BINGO_DIR) && GOWORK=off $(GO) build -mod=mod -modfile=bingo.mod -o=$(GOBIN)/bingo-v0.9.0 "github.com/bwplotka/bingo"

GOLANGCI_LINT := $(GOBIN)/golangci-lint-v1.55.2
GOLANGCI_LINT := $(GOBIN)/golangci-lint-v1.57.2
$(GOLANGCI_LINT): $(BINGO_DIR)/golangci-lint.mod
@# Install binary/ries using Go 1.14+ build command. This is using bwplotka/bingo-controlled, separate go module with pinned dependencies.
@echo "(re)installing $(GOBIN)/golangci-lint-v1.55.2"
@cd $(BINGO_DIR) && GOWORK=off $(GO) build -mod=mod -modfile=golangci-lint.mod -o=$(GOBIN)/golangci-lint-v1.55.2 "github.com/golangci/golangci-lint/cmd/golangci-lint"
@echo "(re)installing $(GOBIN)/golangci-lint-v1.57.2"
@cd $(BINGO_DIR) && GOWORK=off $(GO) build -mod=mod -modfile=golangci-lint.mod -o=$(GOBIN)/golangci-lint-v1.57.2 "github.com/golangci/golangci-lint/cmd/golangci-lint"

GORELEASER := $(GOBIN)/goreleaser-v1.20.0
$(GORELEASER): $(BINGO_DIR)/goreleaser.mod
Expand Down
6 changes: 4 additions & 2 deletions .bingo/golangci-lint.mod
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
module _ // Auto generated by https://github.com/bwplotka/bingo. DO NOT EDIT

go 1.20
go 1.21

require github.com/golangci/golangci-lint v1.55.2 // cmd/golangci-lint
toolchain go1.22.2

require github.com/golangci/golangci-lint v1.57.2 // cmd/golangci-lint
185 changes: 185 additions & 0 deletions .bingo/golangci-lint.sum

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion .bingo/variables.env
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ fi

BINGO="${GOBIN}/bingo-v0.9.0"

GOLANGCI_LINT="${GOBIN}/golangci-lint-v1.55.2"
GOLANGCI_LINT="${GOBIN}/golangci-lint-v1.57.2"

GORELEASER="${GOBIN}/goreleaser-v1.20.0"

96 changes: 74 additions & 22 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1,77 @@
########
# NOTE
#
# This file is duplicated in the following repos:
# - operator-framework/kubectl-operator
# - operator-framework/catalogd
# - operator-framework/operator-controller
# - operator-framework/rukpak
#
# If you are making a change, please make it in ALL
# of the above repositories!
#
# TODO: Find a way to have a shared golangci config.
########

run:
# Default timeout is 1m, up to give more room
timeout: 4m

linters:
auto-fix: false
enable:
- errcheck
- goimports
- golint
- gosec
- misspell
- scopelint
- unconvert
- unparam
- interfacer
- nakedret
- gocyclo
- dupl
- goconst
- lll
run:
- asciicheck
- bodyclose
- errorlint
- gci
- gofmt
- gosec
- importas
- misspell
- nestif
- nonamedreturns
- prealloc
- stylecheck
- tparallel
- unconvert
- unparam
- unused
- whitespace

linters-settings:
errcheck:
check-type-assertions: true
lll:
line-length: 250
dupl:
threshold: 400
gci:
sections:
- standard
- dot
- default
- prefix(github.com/operator-framework)

# TODO: change this to `localmodule` when golangci-lint
# is updated to 1.58+
- prefix(github.com/operator-framework/kubectl-operator)
custom-order: true

errorlint:
errorf: false

importas:
alias:
- pkg: k8s.io/apimachinery/pkg/apis/meta/v1
alias: metav1
- pkg: k8s.io/apimachinery/pkg/api/errors
alias: apierrors
- pkg: k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1
alias: apiextensionsv1
- pkg: k8s.io/apimachinery/pkg/util/runtime
alias: utilruntime
- pkg: "^k8s\\.io/api/([^/]+)/(v[^/]+)$"
alias: $1$2
- pkg: sigs.k8s.io/controller-runtime
alias: ctrl
- pkg: github.com/operator-framework/rukpak/api/v1alpha2
alias: rukpakv1alpha2
- pkg: github.com/blang/semver/v4
alias: bsemver

output:
formats:
- format: tab
7 changes: 2 additions & 5 deletions internal/cmd/catalog_add.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ import (
"io"
"time"

"github.com/operator-framework/operator-registry/pkg/image/containerdregistry"
"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"github.com/spf13/pflag"

"github.com/operator-framework/operator-registry/pkg/image/containerdregistry"

"github.com/operator-framework/kubectl-operator/internal/cmd/internal/log"
internalaction "github.com/operator-framework/kubectl-operator/internal/pkg/action"
"github.com/operator-framework/kubectl-operator/pkg/action"
Expand Down Expand Up @@ -49,8 +50,4 @@ func bindCatalogAddFlags(fs *pflag.FlagSet, a *internalaction.CatalogAdd) {
fs.StringVarP(&a.DisplayName, "display-name", "d", "", "display name of the index")
fs.StringVarP(&a.Publisher, "publisher", "p", "", "publisher of the index")
fs.DurationVar(&a.CleanupTimeout, "cleanup-timeout", time.Minute, "the amount of time to wait before cancelling cleanup")

fs.StringArrayVarP(&a.InjectBundles, "inject-bundles", "b", nil, "inject extra bundles into the index at runtime")
fs.StringVarP(&a.InjectBundleMode, "inject-bundle-mode", "m", "", "mode to use to inject bundles")
_ = fs.MarkHidden("inject-bundle-mode")
}
6 changes: 3 additions & 3 deletions internal/cmd/catalog_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"time"

"github.com/spf13/cobra"
v1 "k8s.io/api/core/v1"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/util/duration"

"github.com/operator-framework/kubectl-operator/internal/cmd/internal/log"
Expand All @@ -23,15 +23,15 @@ func newCatalogListCmd(cfg *action.Configuration) *cobra.Command {
Short: "List installed operator catalogs",
Run: func(cmd *cobra.Command, args []string) {
if allNamespaces {
cfg.Namespace = v1.NamespaceAll
cfg.Namespace = corev1.NamespaceAll
}
catalogs, err := l.Run(cmd.Context())
if err != nil {
log.Fatal(err)
}

if len(catalogs) == 0 {
if cfg.Namespace == v1.NamespaceAll {
if cfg.Namespace == corev1.NamespaceAll {
log.Print("No resources found")
} else {
log.Printf("No resources found in %s namespace.", cfg.Namespace)
Expand Down
1 change: 0 additions & 1 deletion internal/cmd/operator_describe.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ func newOperatorDescribeCmd(cfg *action.Configuration) *cobra.Command {
for _, v := range out {
fmt.Print(v)
}

},
}

Expand Down
3 changes: 2 additions & 1 deletion internal/cmd/operator_install.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ import (
"fmt"
"time"

"github.com/operator-framework/api/pkg/operators/v1alpha1"
"github.com/spf13/cobra"
"github.com/spf13/pflag"

"github.com/operator-framework/api/pkg/operators/v1alpha1"

"github.com/operator-framework/kubectl-operator/internal/cmd/internal/log"
internalaction "github.com/operator-framework/kubectl-operator/internal/pkg/action"
"github.com/operator-framework/kubectl-operator/pkg/action"
Expand Down
7 changes: 3 additions & 4 deletions internal/cmd/operator_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"time"

"github.com/spf13/cobra"
v1 "k8s.io/api/core/v1"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/util/duration"

"github.com/operator-framework/kubectl-operator/internal/cmd/internal/log"
Expand All @@ -26,15 +26,15 @@ func newOperatorListCmd(cfg *action.Configuration) *cobra.Command {
Args: cobra.ExactArgs(0),
Run: func(cmd *cobra.Command, args []string) {
if allNamespaces {
cfg.Namespace = v1.NamespaceAll
cfg.Namespace = corev1.NamespaceAll
}
subs, err := l.Run(cmd.Context())
if err != nil {
log.Fatalf("list operators: %v", err)
}

if len(subs) == 0 {
if cfg.Namespace == v1.NamespaceAll {
if cfg.Namespace == corev1.NamespaceAll {
log.Print("No resources found")
} else {
log.Printf("No resources found in %s namespace.", cfg.Namespace)
Expand All @@ -60,7 +60,6 @@ func newOperatorListCmd(cfg *action.Configuration) *cobra.Command {
_, _ = fmt.Fprintf(tw, "%s%s\t%s\t%s\t%s\t%s\t%s\n", sub.Spec.Package, ns, sub.Name, sub.Status.InstalledCSV, sub.Status.CurrentCSV, sub.Status.State, duration.HumanDuration(age))
}
_ = tw.Flush()

},
}
cmd.Flags().BoolVarP(&allNamespaces, "all-namespaces", "A", false, "list operators in all namespaces")
Expand Down
4 changes: 2 additions & 2 deletions internal/cmd/operator_list_available.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (

"github.com/spf13/cobra"
"github.com/spf13/pflag"
v1 "k8s.io/api/core/v1"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/util/duration"

"github.com/operator-framework/kubectl-operator/internal/cmd/internal/log"
Expand All @@ -35,7 +35,7 @@ func newOperatorListAvailableCmd(cfg *action.Configuration) *cobra.Command {
}

if len(operators) == 0 {
if cfg.Namespace == v1.NamespaceAll {
if cfg.Namespace == corev1.NamespaceAll {
log.Print("No resources found")
} else {
log.Printf("No resources found in %s namespace.\n", cfg.Namespace)
Expand Down
Loading

0 comments on commit a6286fb

Please sign in to comment.