Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(go.mod/go.sum): update minor dependencies (golang) #4

Merged
merged 4 commits into from
Aug 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 32 additions & 32 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
module github.com/sap/pod-reloader

go 1.19
go 1.21

require (
github.com/pkg/errors v0.9.1
k8s.io/api v0.26.3
k8s.io/apimachinery v0.26.3
k8s.io/client-go v0.26.3
sigs.k8s.io/controller-runtime v0.14.6
k8s.io/api v0.28.1
k8s.io/apimachinery v0.28.1
k8s.io/client-go v0.28.1
sigs.k8s.io/controller-runtime v0.16.0
)

require (
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.1.2 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/emicklei/go-restful/v3 v3.9.0 // indirect
github.com/evanphx/json-patch/v5 v5.6.0 // indirect
github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/go-logr/logr v1.2.3 // indirect
github.com/go-logr/zapr v1.2.3 // indirect
github.com/go-openapi/jsonpointer v0.19.5 // indirect
github.com/go-openapi/jsonreference v0.20.0 // indirect
github.com/go-logr/logr v1.2.4 // indirect
github.com/go-logr/zapr v1.2.4 // indirect
github.com/go-openapi/jsonpointer v0.19.6 // indirect
github.com/go-openapi/jsonreference v0.20.2 // indirect
github.com/go-openapi/swag v0.22.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.2 // indirect
github.com/google/gnostic v0.6.9 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/google/gnostic-models v0.6.8 // indirect
github.com/google/go-cmp v0.5.9 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/google/uuid v1.3.0 // indirect
Expand All @@ -37,32 +37,32 @@ require (
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/prometheus/client_golang v1.14.0 // indirect
github.com/prometheus/client_model v0.3.0 // indirect
github.com/prometheus/common v0.37.0 // indirect
github.com/prometheus/procfs v0.8.0 // indirect
github.com/prometheus/client_golang v1.16.0 // indirect
github.com/prometheus/client_model v0.4.0 // indirect
github.com/prometheus/common v0.44.0 // indirect
github.com/prometheus/procfs v0.10.1 // indirect
github.com/spf13/pflag v1.0.5 // indirect
go.uber.org/atomic v1.10.0 // indirect
go.uber.org/multierr v1.8.0 // indirect
go.uber.org/zap v1.24.0 // indirect
golang.org/x/net v0.7.0 // indirect
golang.org/x/oauth2 v0.1.0 // indirect
golang.org/x/sys v0.5.0 // indirect
golang.org/x/term v0.5.0 // indirect
golang.org/x/text v0.7.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.25.0 // indirect
golang.org/x/exp v0.0.0-20220722155223-a9213eeb770e // indirect
golang.org/x/net v0.13.0 // indirect
golang.org/x/oauth2 v0.8.0 // indirect
golang.org/x/sys v0.11.0 // indirect
golang.org/x/term v0.10.0 // indirect
golang.org/x/text v0.11.0 // indirect
golang.org/x/time v0.3.0 // indirect
gomodules.xyz/jsonpatch/v2 v2.2.0 // indirect
gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/protobuf v1.28.1 // indirect
google.golang.org/protobuf v1.30.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/apiextensions-apiserver v0.26.1 // indirect
k8s.io/component-base v0.26.1 // indirect
k8s.io/klog/v2 v2.80.1 // indirect
k8s.io/kube-openapi v0.0.0-20221012153701-172d655c2280 // indirect
k8s.io/utils v0.0.0-20221128185143-99ec85e7a448 // indirect
sigs.k8s.io/json v0.0.0-20220713155537-f223a00ba0e2 // indirect
k8s.io/apiextensions-apiserver v0.28.0 // indirect
k8s.io/component-base v0.28.0 // indirect
k8s.io/klog/v2 v2.100.1 // indirect
k8s.io/kube-openapi v0.0.0-20230717233707-2695361300d9 // indirect
k8s.io/utils v0.0.0-20230406110748-d93618cff8a2 // 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
)
686 changes: 174 additions & 512 deletions go.sum

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion internal/controller/handle-configmap.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func setupConfigMapHandler(mgr ctrl.Manager) error {
if err != nil {
return err
}
if err := c.Watch(&source.Kind{Type: &corev1.ConfigMap{}}, &handler.EnqueueRequestForObject{}); err != nil {
if err := c.Watch(source.Kind(mgr.GetCache(), &corev1.ConfigMap{}), &handler.EnqueueRequestForObject{}); err != nil {
return err
}
return nil
Expand Down
2 changes: 1 addition & 1 deletion internal/controller/handle-secret.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func setupSecretHandler(mgr ctrl.Manager) error {
if err != nil {
return err
}
if err := c.Watch(&source.Kind{Type: &corev1.Secret{}}, &handler.EnqueueRequestForObject{}); err != nil {
if err := c.Watch(source.Kind(mgr.GetCache(), &corev1.Secret{}), &handler.EnqueueRequestForObject{}); err != nil {
return err
}
return nil
Expand Down
2 changes: 1 addition & 1 deletion internal/controller/handle.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func (h *genericHandler) handle(ctx context.Context, kind string, namespace stri
}
annotations[reloader.AnnotationConfigHash] = hash
object.SetAnnotations(annotations)
if err := h.client.Update(ctx, object, &ctrlclient.UpdateOptions{}); err != nil {
if err := h.client.Update(ctx, object); err != nil {
return err
}
h.recorder.Eventf(object, corev1.EventTypeNormal, "ConfigurationChanged", "Reload triggered due to change of referenced %s %s/%s", kind, namespace, name)
Expand Down
2 changes: 2 additions & 0 deletions internal/reloader/hash.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
func GenerateHash(ctx context.Context, client ctrlclient.Client, namespace string, configMapNames []string, secretNames []string) (string, error) {
s := ""
for _, configMapName := range configMapNames {
s += "configmap/" + namespace + "/" + configMapName + "/"
configMap := corev1.ConfigMap{}
err := client.Get(ctx, ctrlclient.ObjectKey{Namespace: namespace, Name: configMapName}, &configMap)
if err == nil {
Expand All @@ -31,6 +32,7 @@ func GenerateHash(ctx context.Context, client ctrlclient.Client, namespace strin
}
}
for _, secretName := range secretNames {
s += "secret/" + namespace + "/" + secretName + "/"
secret := corev1.Secret{}
err := client.Get(ctx, ctrlclient.ObjectKey{Namespace: namespace, Name: secretName}, &secret)
if err == nil {
Expand Down
7 changes: 1 addition & 6 deletions internal/webhook/mutator.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,6 @@ func (m *mutator) Handle(ctx context.Context, req admission.Request) admission.R
return admission.PatchResponseFromRaw(req.Object.Raw, rawObject)
}

func (m *mutator) InjectDecoder(d *admission.Decoder) error {
m.decoder = d
return nil
}

func (m *mutator) handleCreateOrUpdate(ctx context.Context, object runtime.Object) error {
log := ctrl.LoggerFrom(ctx)
log.V(1).Info("running mutation webhook")
Expand Down Expand Up @@ -99,7 +94,7 @@ func (m *mutator) handleCreateOrUpdate(ctx context.Context, object runtime.Objec

hash, err := reloader.GenerateHashForObject(ctx, m.client, objMeta)
if err != nil {
return nil
return err
}

if injectedHash, ok := objMeta.Annotations[reloader.AnnotationConfigHash]; ok {
Expand Down
6 changes: 5 additions & 1 deletion internal/webhook/webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,12 @@ package webhook
import (
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/webhook"
"sigs.k8s.io/controller-runtime/pkg/webhook/admission"
)

func SetupMutatingWebhookWithManager(mgr ctrl.Manager) {
mgr.GetWebhookServer().Register("/mutate", &webhook.Admission{Handler: &mutator{scheme: mgr.GetScheme(), client: mgr.GetClient()}})
scheme := mgr.GetScheme()
client := mgr.GetClient()
decoder := admission.NewDecoder(scheme)
mgr.GetWebhookServer().Register("/mutate", &webhook.Admission{Handler: &mutator{scheme: scheme, client: client, decoder: decoder}})
}
27 changes: 17 additions & 10 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ import (
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/healthz"
"sigs.k8s.io/controller-runtime/pkg/log/zap"
metricsserver "sigs.k8s.io/controller-runtime/pkg/metrics/server"
ctrlwebhook "sigs.k8s.io/controller-runtime/pkg/webhook"

"github.com/sap/pod-reloader/internal/controller"
"github.com/sap/pod-reloader/internal/webhook"
Expand Down Expand Up @@ -68,7 +70,7 @@ func main() {
os.Exit(1)
}

host, port, err := parseAddress(webhookAddr)
webhookHost, webhookPort, err := parseAddress(webhookAddr)
if err != nil {
setupLog.Error(err, "unable to parse webhook bind address")
os.Exit(1)
Expand All @@ -84,15 +86,20 @@ func main() {
}

mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{
Scheme: scheme,
MetricsBindAddress: metricsAddr,
HealthProbeBindAddress: probeAddr,
Host: host,
Port: port,
LeaderElection: enableLeaderElection,
LeaderElectionNamespace: leaderElectionNamespace,
LeaderElectionID: LeaderElectionID,
CertDir: webhookCertDir,
Scheme: scheme,
LeaderElection: enableLeaderElection,
LeaderElectionNamespace: leaderElectionNamespace,
LeaderElectionID: LeaderElectionID,
LeaderElectionReleaseOnCancel: true,
WebhookServer: ctrlwebhook.NewServer(ctrlwebhook.Options{
Host: webhookHost,
Port: webhookPort,
CertDir: webhookCertDir,
}),
Metrics: metricsserver.Options{
BindAddress: metricsAddr,
},
HealthProbeBindAddress: probeAddr,
})
if err != nil {
setupLog.Error(err, "unable to start manager")
Expand Down