Skip to content

Commit

Permalink
Revendor to g/g 1.65. (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
Gerrit91 authored Oct 16, 2023
1 parent bd71064 commit d93bc62
Show file tree
Hide file tree
Showing 19 changed files with 390 additions and 517 deletions.
7 changes: 4 additions & 3 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,16 @@ jobs:
- name: Checkout
uses: actions/checkout@v3

- name: Set up Go 1.20
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: '1.20.x'
go-version-file: 'go.mod'
cache: false

- name: Lint
uses: golangci/golangci-lint-action@v3
with:
args: --build-tags integration -p bugs -p unused --timeout=3m

- name: Test
run: make test
run: make test
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ helm
.vscode
hack/tools/bin/*
bin
gardener-extension-authn
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
FROM golang:1.20 AS builder
FROM golang:1.21 AS builder

WORKDIR /go/src/github.com/fi-ts/gardener-extension-authn
COPY . .
RUN make install \
&& strip /go/bin/gardener-extension-authn

FROM alpine:3.17
FROM alpine:3.18
WORKDIR /
COPY charts /charts
COPY --from=builder /go/bin/gardener-extension-authn /gardener-extension-authn
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.dev
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
FROM alpine:3.17
FROM alpine:3.18
COPY bin/gardener-extension-authn /gardener-extension-authn
CMD ["/gardener-extension-authn"]
21 changes: 6 additions & 15 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ LEADER_ELECTION := false
IGNORE_OPERATION_ANNOTATION := false
WEBHOOK_CONFIG_URL := localhost

GOLANGCI_LINT_VERSION := v1.48.0
GOLANGCI_LINT_VERSION := v1.54.2
GO_VERSION := 1.21

ifeq ($(CI),true)
DOCKER_TTY_ARG=""
Expand All @@ -27,19 +28,9 @@ TOOLS_DIR := hack/tools
# Rules for local development scenarios #
#########################################

.PHONY: start-authn
start-authn:
@LEADER_ELECTION_NAMESPACE=garden go run \
-ldflags $(LD_FLAGS) \
-tags netgo \
./cmd/gardener-extension-authn \
--config=./example/00-componentconfig.yaml \
--ignore-operation-annotation=$(IGNORE_OPERATION_ANNOTATION) \
--leader-election=$(LEADER_ELECTION) \
--webhook-config-server-host=$(HOSTNAME) \
--webhook-config-server-port=8443 \
--webhook-config-mode=url \
--webhook-config-url=$(WEBHOOK_CONFIG_URL)
.PHONY: build
build:
go build -ldflags $(LD_FLAGS) -tags netgo ./cmd/gardener-extension-authn

#################################################################
# Rules related to binary build, Docker image build and release #
Expand Down Expand Up @@ -90,7 +81,7 @@ generate: $(HELM)
generate-in-docker: revendor $(HELM)
# comment back in after first release:
# echo $(shell git describe --abbrev=0 --tags) > VERSION
docker run --rm -i$(DOCKER_TTY_ARG) -v $(PWD):/go/src/github.com/fi-ts/gardener-extension-authn golang:1.19.4 \
docker run --rm -i$(DOCKER_TTY_ARG) -v $(PWD):/go/src/github.com/fi-ts/gardener-extension-authn golang:$(GO_VERSION) \
sh -c "cd /go/src/github.com/fi-ts/gardener-extension-authn \
&& make generate \
# && make install generate \
Expand Down
18 changes: 17 additions & 1 deletion cmd/gardener-extension-authn/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,14 @@ import (
"github.com/fi-ts/gardener-extension-authn/pkg/controller"

extensionscontroller "github.com/gardener/gardener/extensions/pkg/controller"
heartbeatcontroller "github.com/gardener/gardener/extensions/pkg/controller/heartbeat"
"github.com/gardener/gardener/extensions/pkg/util"
gardenerhealthz "github.com/gardener/gardener/pkg/healthz"
"github.com/spf13/cobra"
corev1 "k8s.io/api/core/v1"
componentbaseconfig "k8s.io/component-base/config"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/healthz"
"sigs.k8s.io/controller-runtime/pkg/manager"
)

Expand All @@ -30,6 +33,10 @@ func NewControllerManagerCommand() *cobra.Command {
return fmt.Errorf("error completing options: %w", err)
}

if err := options.heartbeatOptions.Validate(); err != nil {
return err
}

cmd.SilenceUsage = true
return options.run(cmd.Context())
},
Expand Down Expand Up @@ -71,15 +78,24 @@ func (o *Options) run(ctx context.Context) error {
ctrlConfig.Apply(&controller.DefaultAddOptions.Config)
o.controllerOptions.Completed().Apply(&controller.DefaultAddOptions.ControllerOptions)
o.reconcileOptions.Completed().Apply(&controller.DefaultAddOptions.IgnoreOperationAnnotation)
o.heartbeatOptions.Completed().Apply(&heartbeatcontroller.DefaultAddOptions)

if err := o.controllerSwitches.Completed().AddToManager(mgr); err != nil {
return fmt.Errorf("could not add controllers to manager: %w", err)
}

if _, _, err := o.webhookOptions.Completed().AddToManager(ctx, mgr); err != nil {
if _, err := o.webhookOptions.Completed().AddToManager(ctx, mgr); err != nil {
return fmt.Errorf("could not add the mutating webhook to manager: %w", err)
}

if err := mgr.AddReadyzCheck("informer-sync", gardenerhealthz.NewCacheSyncHealthz(mgr.GetCache())); err != nil {
return fmt.Errorf("could not add ready check for informers: %w", err)
}

if err := mgr.AddHealthzCheck("ping", healthz.Ping); err != nil {
return fmt.Errorf("could not add health check to manager: %w", err)
}

if err := mgr.Start(ctx); err != nil {
return fmt.Errorf("error running manager: %w", err)
}
Expand Down
12 changes: 12 additions & 0 deletions cmd/gardener-extension-authn/app/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ import (
"os"

controllercmd "github.com/gardener/gardener/extensions/pkg/controller/cmd"
heartbeatcmd "github.com/gardener/gardener/extensions/pkg/controller/heartbeat/cmd"
webhookcmd "github.com/gardener/gardener/extensions/pkg/webhook/cmd"

"k8s.io/client-go/tools/leaderelection/resourcelock"

authncmd "github.com/fi-ts/gardener-extension-authn/pkg/cmd"
Expand All @@ -20,6 +22,7 @@ type Options struct {
restOptions *controllercmd.RESTOptions
managerOptions *controllercmd.ManagerOptions
controllerOptions *controllercmd.ControllerOptions
heartbeatOptions *heartbeatcmd.Options
healthOptions *controllercmd.ControllerOptions
controllerSwitches *controllercmd.SwitchOptions
webhookOptions *webhookcmd.AddToManagerOptions
Expand All @@ -37,6 +40,8 @@ func NewOptions() *Options {
webhookSwitches := authncmd.WebhookSwitchOptions()
webhookOptions := webhookcmd.NewAddToManagerOptions(
"fits-authn",
"",
nil,
webhookServerOptions,
webhookSwitches,
)
Expand All @@ -56,6 +61,12 @@ func NewOptions() *Options {
// This is a default value.
MaxConcurrentReconciles: 5,
},
heartbeatOptions: &heartbeatcmd.Options{
// This is a default value.
ExtensionName: ExtensionName,
RenewIntervalSeconds: 30,
Namespace: os.Getenv("LEADER_ELECTION_NAMESPACE"),
},
healthOptions: &controllercmd.ControllerOptions{
// This is a default value.
MaxConcurrentReconciles: 5,
Expand All @@ -71,6 +82,7 @@ func NewOptions() *Options {
options.managerOptions,
options.controllerOptions,
options.authnOptions,
controllercmd.PrefixOption("heartbeat-", options.heartbeatOptions),
controllercmd.PrefixOption("healthcheck-", options.healthOptions),
options.controllerSwitches,
options.reconcileOptions,
Expand Down
4 changes: 2 additions & 2 deletions cmd/gardener-extension-authn/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ import (
"os"

"github.com/fi-ts/gardener-extension-authn/cmd/gardener-extension-authn/app"
"github.com/gardener/gardener/pkg/logger"

log "github.com/gardener/gardener/pkg/logger"
runtimelog "sigs.k8s.io/controller-runtime/pkg/log"
)

func main() {
runtimelog.SetLogger(log.ZapLogger(false))
runtimelog.SetLogger(logger.MustNewZapLogger(logger.InfoLevel, logger.FormatJSON))
cmd := app.NewControllerManagerCommand()

if err := cmd.Execute(); err != nil {
Expand Down
109 changes: 52 additions & 57 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
module github.com/fi-ts/gardener-extension-authn

go 1.20
go 1.21

require (
github.com/ahmetb/gen-crd-api-reference-docs v0.3.0
github.com/gardener/gardener v1.46.3
github.com/gardener/gardener v1.65.3
github.com/go-logr/logr v1.2.4
github.com/golang/mock v1.6.0
github.com/metal-stack/metal-lib v0.11.7
github.com/metal-stack/metal-lib v0.13.3
github.com/onsi/ginkgo v1.16.5
github.com/spf13/cobra v1.7.0
github.com/spf13/pflag v1.0.5
k8s.io/api v0.25.2
k8s.io/apimachinery v0.25.2
k8s.io/api v0.26.3
k8s.io/apimachinery v0.27.4
k8s.io/client-go v11.0.1-0.20190409021438-1a26190bd76a+incompatible
k8s.io/code-generator v0.23.3
k8s.io/component-base v0.25.0
sigs.k8s.io/controller-runtime v0.13.0
k8s.io/code-generator v0.26.3
k8s.io/component-base v0.26.3
sigs.k8s.io/controller-runtime v0.14.6
)

require (
Expand All @@ -25,51 +25,55 @@ require (
github.com/Masterminds/semver v1.5.0 // indirect
github.com/Masterminds/sprig v2.22.0+incompatible // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/bronze1man/yaml2json v0.0.0-20201022121239-82e774ec909d // indirect
github.com/blang/semver/v4 v4.0.0 // indirect
github.com/bronze1man/yaml2json v0.0.0-20211227013850-8972abeaea25 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/coreos/go-systemd/v22 v22.4.0 // indirect
github.com/cyphar/filepath-securejoin v0.2.2 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/emicklei/go-restful v2.16.0+incompatible // indirect
github.com/emicklei/go-restful/v3 v3.10.2 // indirect
github.com/evanphx/json-patch v5.6.0+incompatible // indirect
github.com/evanphx/json-patch/v5 v5.6.0 // indirect
github.com/fatih/color v1.15.0 // indirect
github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/gardener/etcd-druid v0.8.0 // indirect
github.com/gardener/external-dns-management v0.12.5 // indirect
github.com/gardener/etcd-druid v0.15.3 // indirect
github.com/gardener/hvpa-controller v0.3.1 // indirect
github.com/gardener/machine-controller-manager v0.45.0 // indirect
github.com/ghodss/yaml v1.0.0 // indirect
github.com/go-logr/zapr v1.2.3 // indirect
github.com/go-openapi/jsonpointer v0.19.6 // indirect
github.com/go-openapi/jsonpointer v0.20.0 // indirect
github.com/go-openapi/jsonreference v0.20.2 // indirect
github.com/go-openapi/swag v0.22.3 // indirect
github.com/go-openapi/swag v0.22.4 // indirect
github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 // indirect
github.com/gobuffalo/flect v0.2.3 // indirect
github.com/gobuffalo/flect v0.3.0 // indirect
github.com/gobwas/glob v0.2.3 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/google/gnostic v0.5.7-v3refs // indirect
github.com/google/go-cmp v0.5.9 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/google/pprof v0.0.0-20230502171905-255e3b9b56de // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/googleapis/gnostic v0.5.5 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-multierror v1.1.1 // indirect
github.com/huandu/xstrings v1.4.0 // indirect
github.com/imdario/mergo v0.3.15 // indirect
github.com/imdario/mergo v0.3.16 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/kubernetes-csi/external-snapshotter/v2 v2.1.5 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.18 // indirect
github.com/mattn/go-isatty v0.0.19 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
github.com/mitchellh/copystructure v1.2.0 // indirect
github.com/mitchellh/hashstructure/v2 v2.0.2 // indirect
github.com/mitchellh/reflectwalk v1.0.2 // indirect
github.com/moby/spdystream v0.2.0 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/nxadm/tail v1.4.8 // indirect
github.com/onsi/ginkgo/v2 v2.9.3 // indirect
github.com/pkg/errors v0.9.1 // indirect
Expand All @@ -79,60 +83,51 @@ require (
github.com/prometheus/procfs v0.9.0 // indirect
github.com/rogpeppe/go-internal v1.10.0 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/sirupsen/logrus v1.9.0 // indirect
github.com/spf13/afero v1.9.5 // indirect
go.uber.org/atomic v1.10.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.24.0 // indirect
golang.org/x/crypto v0.8.0 // indirect
golang.org/x/mod v0.10.0 // indirect
golang.org/x/net v0.9.0 // indirect
golang.org/x/oauth2 v0.7.0 // indirect
golang.org/x/sys v0.7.0 // indirect
golang.org/x/term v0.7.0 // indirect
golang.org/x/text v0.9.0 // indirect
go.uber.org/zap v1.25.0 // indirect
golang.org/x/crypto v0.12.0 // indirect
golang.org/x/mod v0.12.0 // indirect
golang.org/x/net v0.14.0 // indirect
golang.org/x/oauth2 v0.11.0 // indirect
golang.org/x/sys v0.11.0 // indirect
golang.org/x/term v0.11.0 // indirect
golang.org/x/text v0.12.0 // indirect
golang.org/x/time v0.3.0 // indirect
golang.org/x/tools v0.8.0 // indirect
golang.org/x/tools v0.12.0 // indirect
gomodules.xyz/jsonpatch/v2 v2.2.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/protobuf v1.30.0 // indirect
google.golang.org/genproto v0.0.0-20220628213854-d9e0b6570c03 // indirect
google.golang.org/protobuf v1.31.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
istio.io/api v0.0.0-20220304035241-8c47cbbea144 // indirect
istio.io/client-go v1.12.5 // indirect
istio.io/gogo-genproto v0.0.0-20210113155706-4daf5697332f // indirect
k8s.io/apiextensions-apiserver v0.25.0 // indirect
k8s.io/apiserver v0.23.5 // indirect
istio.io/api v0.0.0-20221013011440-bc935762d2b9 // indirect
istio.io/client-go v1.15.3 // indirect
k8s.io/apiextensions-apiserver v0.26.1 // indirect
k8s.io/apiserver v0.26.1 // indirect
k8s.io/autoscaler v0.0.0-20190805135949-100e91ba756e // indirect
k8s.io/gengo v0.0.0-20210813121822-485abfe95c7c // indirect
k8s.io/gengo v0.0.0-20220902162205-c0856e24416d // indirect
k8s.io/helm v2.16.1+incompatible // indirect
k8s.io/klog v1.0.0 // indirect
k8s.io/klog/v2 v2.80.1 // indirect
k8s.io/kube-aggregator v0.23.3 // indirect
k8s.io/kube-openapi v0.0.0-20220803164354-a70c9af30aea // indirect
k8s.io/kubelet v0.23.3 // indirect
k8s.io/metrics v0.23.3 // indirect
k8s.io/utils v0.0.0-20221011040102-427025108f67 // indirect
sigs.k8s.io/controller-runtime/tools/setup-envtest v0.0.0-20211208212546-f236f0345ad2 // indirect
sigs.k8s.io/controller-tools v0.8.0 // indirect
sigs.k8s.io/json v0.0.0-20211020170558-c049b76a60c6 // indirect
k8s.io/klog/v2 v2.90.1 // indirect
k8s.io/kube-aggregator v0.26.1 // indirect
k8s.io/kube-openapi v0.0.0-20230501164219-8b0f38b5fd1f // indirect
k8s.io/kubelet v0.26.1 // indirect
k8s.io/metrics v0.26.1 // indirect
k8s.io/utils v0.0.0-20230209194617-a36077c30491 // indirect
sigs.k8s.io/controller-runtime/tools/setup-envtest v0.0.0-20221212190805-d4f1e822ca11 // indirect
sigs.k8s.io/controller-tools v0.11.3 // indirect
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect
sigs.k8s.io/yaml v1.3.0 // indirect
)

replace (
k8s.io/api => k8s.io/api v0.23.3
k8s.io/apiextensions-apiserver => k8s.io/apiextensions-apiserver v0.23.3
k8s.io/apimachinery => k8s.io/apimachinery v0.23.3
k8s.io/apiserver => k8s.io/apiserver v0.23.3
k8s.io/client-go => k8s.io/client-go v0.23.3
k8s.io/cluster-bootstrap => k8s.io/cluster-bootstrap v0.23.3
k8s.io/code-generator => k8s.io/code-generator v0.23.3
k8s.io/component-base => k8s.io/component-base v0.23.3
k8s.io/klog/v2 => k8s.io/klog/v2 v2.30.0
k8s.io/kube-aggregator => k8s.io/kube-aggregator v0.23.3
k8s.io/kube-openapi => k8s.io/kube-openapi v0.0.0-20220124234850-424119656bbf
sigs.k8s.io/controller-runtime => sigs.k8s.io/controller-runtime v0.11.0
github.com/emicklei/go-restful/v3 => github.com/emicklei/go-restful/v3 v3.8.0 // keep this value in sync with k8s.io/apiserver
google.golang.org/grpc => google.golang.org/grpc v1.47.0 // keep this value in sync with k8s.io/apiserver
k8s.io/client-go => k8s.io/client-go v0.26.3
// for some reason, newer gengo versions will fail with "hit an unsupported type"
k8s.io/gengo => k8s.io/gengo v0.0.0-20210813121822-485abfe95c7c // indirect
)
Loading

0 comments on commit d93bc62

Please sign in to comment.