Skip to content
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
28 changes: 28 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
version: "2"
linters:
default: standard
enable:
- unparam

formatters:
enable:
- gofmt
- goimports
settings:
gofmt:
rewrite-rules:
- pattern: 'interface{}'
replacement: 'any'

issues:
max-same-issues: 100

exclude-files:
- generated.*\\.go

exclude-dirs:
- client
- vendor

run:
timeout: 10m
6 changes: 2 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ REPO := $(notdir $(shell pwd))
BIN := webhook-runtime

# https://github.com/appscodelabs/gengo-builder
CODE_GENERATOR_IMAGE ?= ghcr.io/appscode/gengo:release-1.29
CODE_GENERATOR_IMAGE ?= ghcr.io/appscode/gengo:release-1.32

# This version-strategy uses git tags to set the version string
git_branch := $(shell git rev-parse --abbrev-ref HEAD)
Expand Down Expand Up @@ -191,8 +191,6 @@ unit-tests: $(BUILD_DIRS)
./hack/test.sh $(SRC_DIRS) \
"

ADDTL_LINTERS := gofmt,goimports,unparam

.PHONY: lint
lint: $(BUILD_DIRS)
@echo "running linter"
Expand All @@ -210,7 +208,7 @@ lint: $(BUILD_DIRS)
--env GO111MODULE=on \
--env GOFLAGS="-mod=vendor" \
$(BUILD_IMAGE) \
golangci-lint run --enable $(ADDTL_LINTERS) --timeout=10m --exclude-files="generated.*\.go$\" --exclude-dirs-use-default
golangci-lint run

$(BUILD_DIRS):
@mkdir -p $@
Expand Down
72 changes: 36 additions & 36 deletions client/workload/v1/workload.go
Original file line number Diff line number Diff line change
Expand Up @@ -270,48 +270,48 @@ func (c *workloads) Update(ctx context.Context, w *v1.Workload, opts metav1.Upda
func (c *workloads) Delete(ctx context.Context, obj runtime.Object, options metav1.DeleteOptions) error {
switch t := obj.(type) {
case *core.Pod:
return c.kc.CoreV1().Pods(c.ns).Delete(ctx, t.ObjectMeta.Name, options)
return c.kc.CoreV1().Pods(c.ns).Delete(ctx, t.Name, options)
// ReplicationController
case *core.ReplicationController:
return c.kc.CoreV1().ReplicationControllers(c.ns).Delete(ctx, t.ObjectMeta.Name, options)
return c.kc.CoreV1().ReplicationControllers(c.ns).Delete(ctx, t.Name, options)
// Deployment
case *extensions.Deployment:
return c.kc.ExtensionsV1beta1().Deployments(c.ns).Delete(ctx, t.ObjectMeta.Name, options)
return c.kc.ExtensionsV1beta1().Deployments(c.ns).Delete(ctx, t.Name, options)
case *appsv1beta1.Deployment:
return c.kc.AppsV1beta1().Deployments(c.ns).Delete(ctx, t.ObjectMeta.Name, options)
return c.kc.AppsV1beta1().Deployments(c.ns).Delete(ctx, t.Name, options)
case *appsv1beta2.Deployment:
return c.kc.AppsV1beta2().Deployments(c.ns).Delete(ctx, t.ObjectMeta.Name, options)
return c.kc.AppsV1beta2().Deployments(c.ns).Delete(ctx, t.Name, options)
case *appsv1.Deployment:
return c.kc.AppsV1().Deployments(c.ns).Delete(ctx, t.ObjectMeta.Name, options)
return c.kc.AppsV1().Deployments(c.ns).Delete(ctx, t.Name, options)
// DaemonSet
case *extensions.DaemonSet:
return c.kc.ExtensionsV1beta1().DaemonSets(c.ns).Delete(ctx, t.ObjectMeta.Name, options)
return c.kc.ExtensionsV1beta1().DaemonSets(c.ns).Delete(ctx, t.Name, options)
case *appsv1beta2.DaemonSet:
return c.kc.AppsV1beta2().DaemonSets(c.ns).Delete(ctx, t.ObjectMeta.Name, options)
return c.kc.AppsV1beta2().DaemonSets(c.ns).Delete(ctx, t.Name, options)
case *appsv1.DaemonSet:
return c.kc.AppsV1().DaemonSets(c.ns).Delete(ctx, t.ObjectMeta.Name, options)
return c.kc.AppsV1().DaemonSets(c.ns).Delete(ctx, t.Name, options)
// ReplicaSet
case *extensions.ReplicaSet:
return c.kc.ExtensionsV1beta1().ReplicaSets(c.ns).Delete(ctx, t.ObjectMeta.Name, options)
return c.kc.ExtensionsV1beta1().ReplicaSets(c.ns).Delete(ctx, t.Name, options)
case *appsv1beta2.ReplicaSet:
return c.kc.AppsV1beta2().ReplicaSets(c.ns).Delete(ctx, t.ObjectMeta.Name, options)
return c.kc.AppsV1beta2().ReplicaSets(c.ns).Delete(ctx, t.Name, options)
case *appsv1.ReplicaSet:
return c.kc.AppsV1().ReplicaSets(c.ns).Delete(ctx, t.ObjectMeta.Name, options)
return c.kc.AppsV1().ReplicaSets(c.ns).Delete(ctx, t.Name, options)
// StatefulSet
case *appsv1beta1.StatefulSet:
return c.kc.AppsV1beta1().StatefulSets(c.ns).Delete(ctx, t.ObjectMeta.Name, options)
return c.kc.AppsV1beta1().StatefulSets(c.ns).Delete(ctx, t.Name, options)
case *appsv1beta2.StatefulSet:
return c.kc.AppsV1beta2().StatefulSets(c.ns).Delete(ctx, t.ObjectMeta.Name, options)
return c.kc.AppsV1beta2().StatefulSets(c.ns).Delete(ctx, t.Name, options)
case *appsv1.StatefulSet:
return c.kc.AppsV1().StatefulSets(c.ns).Delete(ctx, t.ObjectMeta.Name, options)
return c.kc.AppsV1().StatefulSets(c.ns).Delete(ctx, t.Name, options)
// Job
case *batchv1.Job:
return c.kc.BatchV1().Jobs(c.ns).Delete(ctx, t.ObjectMeta.Name, options)
return c.kc.BatchV1().Jobs(c.ns).Delete(ctx, t.Name, options)
// CronJob
case *batchv1beta1.CronJob:
return c.kc.BatchV1beta1().CronJobs(c.ns).Delete(ctx, t.ObjectMeta.Name, options)
return c.kc.BatchV1beta1().CronJobs(c.ns).Delete(ctx, t.Name, options)
case *ocapps.DeploymentConfig:
return c.oc.AppsV1().DeploymentConfigs(c.ns).Delete(ctx, t.ObjectMeta.Name, options)
return c.oc.AppsV1().DeploymentConfigs(c.ns).Delete(ctx, t.Name, options)
default:
return fmt.Errorf("the object is not a pod or does not have a pod template")
}
Expand All @@ -322,48 +322,48 @@ func (c *workloads) Get(ctx context.Context, obj runtime.Object, opts metav1.Get
var err error
switch t := obj.(type) {
case *core.Pod:
out, err = c.kc.CoreV1().Pods(c.ns).Get(ctx, t.ObjectMeta.Name, opts)
out, err = c.kc.CoreV1().Pods(c.ns).Get(ctx, t.Name, opts)
// ReplicationController
case *core.ReplicationController:
out, err = c.kc.CoreV1().ReplicationControllers(c.ns).Get(ctx, t.ObjectMeta.Name, opts)
out, err = c.kc.CoreV1().ReplicationControllers(c.ns).Get(ctx, t.Name, opts)
// Deployment
case *extensions.Deployment:
out, err = c.kc.ExtensionsV1beta1().Deployments(c.ns).Get(ctx, t.ObjectMeta.Name, opts)
out, err = c.kc.ExtensionsV1beta1().Deployments(c.ns).Get(ctx, t.Name, opts)
case *appsv1beta1.Deployment:
out, err = c.kc.AppsV1beta1().Deployments(c.ns).Get(ctx, t.ObjectMeta.Name, opts)
out, err = c.kc.AppsV1beta1().Deployments(c.ns).Get(ctx, t.Name, opts)
case *appsv1beta2.Deployment:
out, err = c.kc.AppsV1beta2().Deployments(c.ns).Get(ctx, t.ObjectMeta.Name, opts)
out, err = c.kc.AppsV1beta2().Deployments(c.ns).Get(ctx, t.Name, opts)
case *appsv1.Deployment:
out, err = c.kc.AppsV1().Deployments(c.ns).Get(ctx, t.ObjectMeta.Name, opts)
out, err = c.kc.AppsV1().Deployments(c.ns).Get(ctx, t.Name, opts)
// DaemonSet
case *extensions.DaemonSet:
out, err = c.kc.ExtensionsV1beta1().DaemonSets(c.ns).Get(ctx, t.ObjectMeta.Name, opts)
out, err = c.kc.ExtensionsV1beta1().DaemonSets(c.ns).Get(ctx, t.Name, opts)
case *appsv1beta2.DaemonSet:
out, err = c.kc.AppsV1beta2().DaemonSets(c.ns).Get(ctx, t.ObjectMeta.Name, opts)
out, err = c.kc.AppsV1beta2().DaemonSets(c.ns).Get(ctx, t.Name, opts)
case *appsv1.DaemonSet:
out, err = c.kc.AppsV1().DaemonSets(c.ns).Get(ctx, t.ObjectMeta.Name, opts)
out, err = c.kc.AppsV1().DaemonSets(c.ns).Get(ctx, t.Name, opts)
// ReplicaSet
case *extensions.ReplicaSet:
out, err = c.kc.ExtensionsV1beta1().ReplicaSets(c.ns).Get(ctx, t.ObjectMeta.Name, opts)
out, err = c.kc.ExtensionsV1beta1().ReplicaSets(c.ns).Get(ctx, t.Name, opts)
case *appsv1beta2.ReplicaSet:
out, err = c.kc.AppsV1beta2().ReplicaSets(c.ns).Get(ctx, t.ObjectMeta.Name, opts)
out, err = c.kc.AppsV1beta2().ReplicaSets(c.ns).Get(ctx, t.Name, opts)
case *appsv1.ReplicaSet:
out, err = c.kc.AppsV1().ReplicaSets(c.ns).Get(ctx, t.ObjectMeta.Name, opts)
out, err = c.kc.AppsV1().ReplicaSets(c.ns).Get(ctx, t.Name, opts)
// StatefulSet
case *appsv1beta1.StatefulSet:
out, err = c.kc.AppsV1beta1().StatefulSets(c.ns).Get(ctx, t.ObjectMeta.Name, opts)
out, err = c.kc.AppsV1beta1().StatefulSets(c.ns).Get(ctx, t.Name, opts)
case *appsv1beta2.StatefulSet:
out, err = c.kc.AppsV1beta2().StatefulSets(c.ns).Get(ctx, t.ObjectMeta.Name, opts)
out, err = c.kc.AppsV1beta2().StatefulSets(c.ns).Get(ctx, t.Name, opts)
case *appsv1.StatefulSet:
out, err = c.kc.AppsV1().StatefulSets(c.ns).Get(ctx, t.ObjectMeta.Name, opts)
out, err = c.kc.AppsV1().StatefulSets(c.ns).Get(ctx, t.Name, opts)
// Job
case *batchv1.Job:
out, err = c.kc.BatchV1().Jobs(c.ns).Get(ctx, t.ObjectMeta.Name, opts)
out, err = c.kc.BatchV1().Jobs(c.ns).Get(ctx, t.Name, opts)
// CronJob
case *batchv1beta1.CronJob:
out, err = c.kc.BatchV1beta1().CronJobs(c.ns).Get(ctx, t.ObjectMeta.Name, opts)
out, err = c.kc.BatchV1beta1().CronJobs(c.ns).Get(ctx, t.Name, opts)
case *ocapps.DeploymentConfig:
out, err = c.oc.AppsV1().DeploymentConfigs(c.ns).Get(ctx, t.ObjectMeta.Name, opts)
out, err = c.oc.AppsV1().DeploymentConfigs(c.ns).Get(ctx, t.Name, opts)
default:
err = fmt.Errorf("the object is not a pod or does not have a pod template")
}
Expand Down
76 changes: 37 additions & 39 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,22 +1,20 @@
module kmodules.xyz/webhook-runtime

go 1.23.0

toolchain go1.24.0
go 1.24.0

require (
github.com/evanphx/json-patch v5.9.11+incompatible
github.com/json-iterator/go v1.1.12
gomodules.xyz/jsonpatch/v2 v2.5.0
k8s.io/api v0.32.2
k8s.io/apimachinery v0.32.2
k8s.io/apiserver v0.32.2
k8s.io/client-go v0.32.2
k8s.io/api v0.34.3
k8s.io/apimachinery v0.34.3
k8s.io/apiserver v0.34.3
k8s.io/client-go v0.34.3
k8s.io/klog/v2 v2.130.1
k8s.io/kubernetes v1.32.3
kmodules.xyz/client-go v0.32.0
k8s.io/kubernetes v1.34.3
kmodules.xyz/client-go v0.34.2
kmodules.xyz/openshift v0.29.0
sigs.k8s.io/controller-runtime v0.20.2
sigs.k8s.io/controller-runtime v0.22.4
)

require (
Expand All @@ -26,65 +24,65 @@ require (
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/distribution/reference v0.6.0 // indirect
github.com/emicklei/go-restful/v3 v3.12.1 // indirect
github.com/emicklei/go-restful/v3 v3.12.2 // indirect
github.com/evanphx/json-patch/v5 v5.9.11 // indirect
github.com/fatih/structs v1.1.0 // indirect
github.com/fxamacker/cbor/v2 v2.7.0 // indirect
github.com/go-logr/logr v1.4.2 // indirect
github.com/fxamacker/cbor/v2 v2.9.0 // indirect
github.com/go-logr/logr v1.4.3 // indirect
github.com/go-openapi/jsonpointer v0.21.0 // indirect
github.com/go-openapi/jsonreference v0.21.0 // indirect
github.com/go-openapi/swag v0.23.0 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/google/gnostic-models v0.6.9 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/google/gnostic-models v0.7.0 // indirect
github.com/google/go-cmp v0.7.0 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/google/uuid v1.6.0 // 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/klauspost/compress v1.17.11 // indirect
github.com/klauspost/cpuid/v2 v2.0.9 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mattn/go-isatty v0.0.16 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/modern-go/reflect2 v1.0.3-0.20250322232337-35a7c28c31ee // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/nxadm/tail v1.4.11 // indirect
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/prometheus/client_golang v1.20.5 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/prometheus/client_golang v1.22.0 // indirect
github.com/prometheus/client_model v0.6.1 // indirect
github.com/prometheus/common v0.55.0 // indirect
github.com/prometheus/common v0.62.0 // indirect
github.com/prometheus/procfs v0.15.1 // indirect
github.com/sergi/go-diff v1.2.0 // indirect
github.com/spf13/cobra v1.8.1 // indirect
github.com/spf13/pflag v1.0.6 // indirect
github.com/x448/float16 v0.8.4 // indirect
github.com/yudai/gojsondiff v1.0.0 // indirect
github.com/yudai/golcs v0.0.0-20170316035057-ecda9a501e82 // indirect
github.com/zeebo/xxh3 v1.0.2 // indirect
go.opentelemetry.io/otel v1.33.0 // indirect
go.opentelemetry.io/otel/trace v1.33.0 // indirect
golang.org/x/net v0.36.0 // indirect
golang.org/x/oauth2 v0.27.0 // indirect
golang.org/x/sys v0.30.0 // indirect
golang.org/x/term v0.29.0 // indirect
golang.org/x/text v0.22.0 // indirect
go.opentelemetry.io/otel v1.36.0 // indirect
go.opentelemetry.io/otel/trace v1.36.0 // indirect
go.yaml.in/yaml/v2 v2.4.2 // indirect
go.yaml.in/yaml/v3 v3.0.4 // indirect
golang.org/x/net v0.47.0 // indirect
golang.org/x/oauth2 v0.30.0 // indirect
golang.org/x/sys v0.39.0 // indirect
golang.org/x/term v0.38.0 // indirect
golang.org/x/text v0.32.0 // indirect
golang.org/x/time v0.10.0 // indirect
google.golang.org/protobuf v1.36.3 // indirect
google.golang.org/protobuf v1.36.5 // indirect
gopkg.in/evanphx/json-patch.v4 v4.12.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/apiextensions-apiserver v0.32.2 // indirect
k8s.io/component-base v0.32.2 // indirect
k8s.io/component-helpers v0.32.2 // indirect
k8s.io/controller-manager v0.32.2 // indirect
k8s.io/kube-openapi v0.0.0-20241212222426-2c72e554b1e7 // indirect
k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738 // indirect
k8s.io/apiextensions-apiserver v0.34.3 // indirect
k8s.io/component-base v0.34.3 // indirect
k8s.io/component-helpers v0.34.3 // indirect
k8s.io/controller-manager v0.34.3 // indirect
k8s.io/kube-openapi v0.0.0-20250710124328-f3f2b991d03b // indirect
k8s.io/utils v0.0.0-20250604170112-4c0f3b243397 // indirect
kmodules.xyz/apiversion v0.2.0 // indirect
sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3 // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.4.3 // indirect
sigs.k8s.io/yaml v1.4.0 // indirect
sigs.k8s.io/json v0.0.0-20241014173422-cfa47c3a1cc8 // indirect
sigs.k8s.io/randfill v1.0.0 // indirect
sigs.k8s.io/structured-merge-diff/v6 v6.3.0 // indirect
sigs.k8s.io/yaml v1.6.0 // indirect
)
Loading
Loading