Skip to content

Commit

Permalink
Merge pull request #50 from banzaicloud/update-dependencies
Browse files Browse the repository at this point in the history
Update dependencies
  • Loading branch information
sagikazarmark authored Apr 15, 2023
2 parents a7cf1f8 + c7c25da commit 9bd182e
Show file tree
Hide file tree
Showing 22 changed files with 531 additions and 730 deletions.
5 changes: 5 additions & 0 deletions .github/dependabot.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ updates:
schedule:
interval: "daily"

- package-ecosystem: "gomod"
directory: "/api"
schedule:
interval: "daily"

- package-ecosystem: "docker"
directory: "/"
schedule:
Expand Down
7 changes: 2 additions & 5 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
pull_request:

env:
GO_VERSION: 1.17
GO_VERSION: '1.20'

permissions:
contents: read
Expand All @@ -16,9 +16,6 @@ jobs:
name: Checks
runs-on: ubuntu-latest

env:
GOLANGCI_LINT_VERSION: 1.26.0

steps:
- name: Checkout repository
uses: actions/checkout@83b7061638ee4956cf7545a6f7efe594e5ad0247 # v3.5.1
Expand Down Expand Up @@ -55,7 +52,7 @@ jobs:
run: go mod vendor && make license-check

- name: Run lint
run: GOLANGCI_VERSION=${{ env.GOLANGCI_LINT_VERSION }} make lint
run: make lint

build:
name: Build
Expand Down
16 changes: 15 additions & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,28 @@ linters:
- nestif
- testpackage
- nolintlint
- wrapcheck
- varnamelen
- ireturn
- exhaustivestruct
- exhaustruct
- gomoddirectives
- exhaustive
- cyclop
- ifshort

linters-settings:
golint:
min-confidence: 0.1
gocyclo:
min-complexity: 40
gci:
sections:
- standard
- default
- prefix(github.com/banzaicloud/imps)
goimports:
local-prefixes: github.com/banzaicloud
local-prefixes: github.com/banzaicloud/imps
gocritic:
disabled-checks:
- ifElseChain
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ CRD_OPTIONS ?= "crd"
# TODO: Use this when allowDangerousTypes feature is released to support floats
# CRD_OPTIONS ?= "crd:trivialVersions=true,allowDangerousTypes=true"
LICENSEI_VERSION = 0.7.0
GOLANGCI_VERSION ?= 1.45.2
GOLANGCI_VERSION ?= 1.52.2

# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
ifeq (,$(shell go env GOBIN))
Expand Down
6 changes: 3 additions & 3 deletions api/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/banzaicloud/imps/api

go 1.17
go 1.18

require (
emperror.dev/errors v0.8.0
Expand All @@ -20,8 +20,8 @@ require (
github.com/pkg/errors v0.9.1 // indirect
go.uber.org/atomic v1.7.0 // indirect
go.uber.org/multierr v1.6.0 // indirect
golang.org/x/net v0.0.0-20210520170846-37e1c6afe023 // indirect
golang.org/x/text v0.3.6 // indirect
golang.org/x/net v0.7.0 // indirect
golang.org/x/text v0.7.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
k8s.io/klog/v2 v2.9.0 // indirect
Expand Down
14 changes: 5 additions & 9 deletions api/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -349,8 +349,8 @@ golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/
golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
golang.org/x/net v0.0.0-20210520170846-37e1c6afe023 h1:ADo5wSpq2gqaCGQWzk7S5vd//0iyyLeAratkEoG5dLE=
golang.org/x/net v0.0.0-20210520170846-37e1c6afe023/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/net v0.7.0 h1:rJrUqqhjsgNp7KqAIc25s9pZnjU7TUcSY7HcVZjdn1g=
golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
Expand Down Expand Up @@ -383,18 +383,15 @@ golang.org/x/sys v0.0.0-20200106162015-b016eb3dc98e/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201112073958-5cba982894dd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210423082822-04245dca01da h1:b3NXsE2LusjYGGjL5bxEVZZORm/YEFFrWFjR8eFrw/c=
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/sys v0.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU=
golang.org/x/text v0.0.0-20160726164857-2910a502d2bf/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.6 h1:aRYxNxv6iGQlyVaZmk6ZgYEDa+Jg18DxebPSrd6bg1M=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.7.0 h1:4BRB4x83lYWy72KwLD/qYDuTu7q9PjSagHvijDw7cLo=
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
Expand Down Expand Up @@ -487,7 +484,6 @@ k8s.io/gengo v0.0.0-20200114144118-36b2048a9120/go.mod h1:ezvh/TsK7cY6rbqRK0oQQ8
k8s.io/gengo v0.0.0-20200413195148-3a45101e95ac/go.mod h1:ezvh/TsK7cY6rbqRK0oQQ8IAqLxYwwyPxAX1Pzy0ii0=
k8s.io/klog v0.0.0-20181102134211-b9b56d5dfc92/go.mod h1:Gq+BEi5rUBO/HRz0bTSXDUcqjScdoY3a9IHpCEIOOfk=
k8s.io/klog v0.3.0/go.mod h1:Gq+BEi5rUBO/HRz0bTSXDUcqjScdoY3a9IHpCEIOOfk=
k8s.io/klog v1.0.0 h1:Pt+yjF5aB1xDSVbau4VsWe+dQNzA0qv1LlXdC2dF6Q8=
k8s.io/klog v1.0.0/go.mod h1:4Bi6QPql/J/LkTDqv7R/cd3hPo4k2DG6Ptcz060Ez5I=
k8s.io/klog/v2 v2.0.0/go.mod h1:PBfzABfn139FHAV07az/IF9Wp1bkk3vpT2XSJ76fSDE=
k8s.io/klog/v2 v2.4.0/go.mod h1:Od+F08eJP+W3HUb4pSrPpgp9DGU4GzlpG/TmITuYh/Y=
Expand Down
20 changes: 7 additions & 13 deletions cmd/controller/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,21 @@ import (
"strings"
"time"

"github.com/banzaicloud/imps/pkg/ecr"

"github.com/banzaicloud/operator-tools/pkg/reconciler"

logrintegration "logur.dev/integration/logr"

"github.com/banzaicloud/imps/internal/errorhandler"

// +kubebuilder:scaffold:imports
"github.com/cisco-open/operator-tools/pkg/reconciler"
"github.com/spf13/pflag"
"github.com/spf13/viper"
"k8s.io/apimachinery/pkg/runtime"

"github.com/banzaicloud/imps/controllers"
"github.com/banzaicloud/imps/internal/log"

clientgoscheme "k8s.io/client-go/kubernetes/scheme"
logrintegration "logur.dev/integration/logr"
"logur.dev/logur"
ctrl "sigs.k8s.io/controller-runtime"

"github.com/banzaicloud/imps/api/v1alpha1"
// +kubebuilder:scaffold:imports
"github.com/banzaicloud/imps/controllers"
"github.com/banzaicloud/imps/internal/errorhandler"
"github.com/banzaicloud/imps/internal/log"
"github.com/banzaicloud/imps/pkg/ecr"
)

var (
Expand Down
2 changes: 1 addition & 1 deletion cmd/refresher/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"time"

"emperror.dev/errors"
"github.com/cisco-open/operator-tools/pkg/reconciler"
"github.com/spf13/pflag"
"github.com/spf13/viper"
"k8s.io/apimachinery/pkg/runtime"
Expand All @@ -20,7 +21,6 @@ import (
"github.com/banzaicloud/imps/internal/errorhandler"
"github.com/banzaicloud/imps/internal/log"
"github.com/banzaicloud/imps/pkg/ecr"
"github.com/banzaicloud/operator-tools/pkg/reconciler"
)

var (
Expand Down
20 changes: 15 additions & 5 deletions controllers/imagepullsecret_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,21 @@ import (
"time"

"emperror.dev/emperror"
"logur.dev/logur"
"sigs.k8s.io/controller-runtime/pkg/reconcile"

"github.com/cisco-open/operator-tools/pkg/reconciler"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/types"
"k8s.io/client-go/tools/record"
"logur.dev/logur"
ctrl "sigs.k8s.io/controller-runtime"
ctrlBuilder "sigs.k8s.io/controller-runtime/pkg/builder"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/handler"
"sigs.k8s.io/controller-runtime/pkg/predicate"
"sigs.k8s.io/controller-runtime/pkg/reconcile"
"sigs.k8s.io/controller-runtime/pkg/source"

"github.com/banzaicloud/imps/api/v1alpha1"
"github.com/banzaicloud/imps/internal/cron"
"github.com/banzaicloud/operator-tools/pkg/reconciler"
)

// AlertingPolicyReconciler reconciles a AlertingPolicy object
Expand All @@ -58,6 +57,7 @@ func (r *ImagePullSecretReconciler) Reconcile(ctx context.Context, req ctrl.Requ
if err != nil {
r.ErrorHandler.Handle(err)
}

return result, err
}

Expand Down Expand Up @@ -87,6 +87,7 @@ func (r *ImagePullSecretReconciler) impsMatchingNamespace(obj client.Object) []c
ns, ok := obj.(*corev1.Namespace)
if !ok {
r.Log.Info("object is not a Namespace")

return []ctrl.Request{}
}

Expand All @@ -95,6 +96,7 @@ func (r *ImagePullSecretReconciler) impsMatchingNamespace(obj client.Object) []c
err := r.Client.List(context.TODO(), impsList)
if err != nil {
r.Log.Info(err.Error())

return []ctrl.Request{}
}

Expand All @@ -107,6 +109,7 @@ func (r *ImagePullSecretReconciler) impsMatchingNamespace(obj client.Object) []c
"namespace": ns,
"error": err,
})

continue
}

Expand All @@ -119,13 +122,15 @@ func (r *ImagePullSecretReconciler) impsMatchingNamespace(obj client.Object) []c
})
}
}

return res
}

func (r *ImagePullSecretReconciler) impsMatchingPod(obj client.Object) []ctrl.Request {
pod, ok := obj.(*corev1.Pod)
if !ok {
r.Log.Info("object is not a Pod or Namespace")

return []ctrl.Request{}
}

Expand All @@ -135,7 +140,6 @@ func (r *ImagePullSecretReconciler) impsMatchingPod(obj client.Object) []ctrl.Re
err := r.Client.Get(context.TODO(), types.NamespacedName{
Name: pod.Namespace,
}, podsNamespace)

if err != nil {
r.Log.Warn("cannot get pod's namespace, please authorize the controller to list namespaces, or too many reconcilations will be executed", map[string]interface{}{
"error": err,
Expand All @@ -149,6 +153,7 @@ func (r *ImagePullSecretReconciler) impsMatchingPod(obj client.Object) []ctrl.Re
err = r.Client.List(context.TODO(), impsList)
if err != nil {
r.Log.Info(err.Error())

return []ctrl.Request{}
}
var res []ctrl.Request
Expand All @@ -160,6 +165,7 @@ func (r *ImagePullSecretReconciler) impsMatchingPod(obj client.Object) []ctrl.Re
"pod": pod,
"error": err,
})

continue
}

Expand All @@ -184,13 +190,15 @@ func (r *ImagePullSecretReconciler) impsMatchingPod(obj client.Object) []ctrl.Re
})
}
}

return res
}

func (r *ImagePullSecretReconciler) impsReferencingSecret(obj client.Object) []ctrl.Request {
secret, ok := obj.(*corev1.Secret)
if !ok {
r.Log.Info("object is not a Secret")

return []ctrl.Request{}
}

Expand All @@ -199,6 +207,7 @@ func (r *ImagePullSecretReconciler) impsReferencingSecret(obj client.Object) []c
err := r.Client.List(context.TODO(), impsList)
if err != nil {
r.Log.Info(err.Error())

return []ctrl.Request{}
}

Expand All @@ -215,5 +224,6 @@ func (r *ImagePullSecretReconciler) impsReferencingSecret(obj client.Object) []c
}
}
}

return res
}
Loading

0 comments on commit 9bd182e

Please sign in to comment.