Skip to content

Commit fbb9949

Browse files
janiszclaude
andcommitted
Add Kustomize support to kube-linter
Integrate k8s-manifests-lib to enable linting of Kustomize manifests. Kustomization directories are automatically detected and rendered, with each kustomization treated as a separate lint context similar to Helm charts. Changes: - Add isKustomizeDir() detection for kustomization.yaml/yml files - Add loadObjectsFromKustomize() to render manifests using k8s-manifests-lib - Add unit tests for Kustomize support - Add e2e BATS test for Kustomize rendering and linting - Add test fixtures in tests/testdata/mykustomize/ 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent f8f1795 commit fbb9949

File tree

9 files changed

+292
-46
lines changed

9 files changed

+292
-46
lines changed

e2etests/bats-tests.sh

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1146,3 +1146,23 @@ get_value_from() {
11461146
[[ "${count}" == "1" ]]
11471147
}
11481148

1149+
@test "kustomize-support" {
1150+
tmp="tests/testdata/mykustomize"
1151+
cmd="${KUBE_LINTER_BIN} lint --format json ${tmp}"
1152+
run ${cmd}
1153+
1154+
print_info "${status}" "${output}" "${cmd}" "${tmp}"
1155+
[ "$status" -eq 1 ]
1156+
1157+
# Verify that kustomize manifests were rendered and linted
1158+
deployment_name=$(get_value_from "${lines[0]}" '.Reports[0].Object.K8sObject.Name')
1159+
deployment_kind=$(get_value_from "${lines[0]}" '.Reports[0].Object.K8sObject.GroupVersionKind.Kind')
1160+
count=$(get_value_from "${lines[0]}" '.Reports | length')
1161+
1162+
# The deployment name should have the kustomize namePrefix applied
1163+
[[ "${deployment_name}" == "kustomize-test-deployment" ]]
1164+
[[ "${deployment_kind}" == "Deployment" ]]
1165+
# There should be lint errors for the deployment
1166+
[[ "${count}" -ge 1 ]]
1167+
}
1168+

go.mod

Lines changed: 33 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -29,51 +29,69 @@ require (
2929

3030
require (
3131
cel.dev/expr v0.24.0 // indirect
32-
dario.cat/mergo v1.0.1 // indirect
32+
dario.cat/mergo v1.0.2 // indirect
3333
github.com/Azure/go-ansiterm v0.0.0-20250102033503-faa5f7b0171c // indirect
3434
github.com/BurntSushi/toml v1.5.0 // indirect
3535
github.com/MakeNowJust/heredoc v1.0.0 // indirect
3636
github.com/Masterminds/goutils v1.1.1 // indirect
3737
github.com/Masterminds/semver/v3 v3.4.0 // indirect
38+
github.com/Masterminds/squirrel v1.5.4 // indirect
3839
github.com/antlr4-go/antlr/v4 v4.13.1 // indirect
40+
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 // indirect
3941
github.com/blang/semver/v4 v4.0.0 // indirect
40-
github.com/chai2010/gettext-go v1.0.2 // indirect
42+
github.com/chai2010/gettext-go v1.0.3 // indirect
4143
github.com/containerd/containerd v1.7.28 // indirect
42-
github.com/containerd/errdefs v0.3.0 // indirect
44+
github.com/containerd/errdefs v1.0.0 // indirect
4345
github.com/containerd/log v0.1.0 // indirect
4446
github.com/containerd/platforms v0.2.1 // indirect
45-
github.com/cyphar/filepath-securejoin v0.4.1 // indirect
47+
github.com/cyphar/filepath-securejoin v0.5.0 // indirect
4648
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
4749
github.com/emicklei/go-restful/v3 v3.13.0 // indirect
4850
github.com/evanphx/json-patch v5.9.11+incompatible // indirect
4951
github.com/exponent-io/jsonpath v0.0.0-20210407135951-1de76d718b3f // indirect
5052
github.com/fsnotify/fsnotify v1.9.0 // indirect
5153
github.com/fxamacker/cbor/v2 v2.9.0 // indirect
5254
github.com/go-errors/errors v1.5.1 // indirect
55+
github.com/go-gorp/gorp/v3 v3.1.0 // indirect
5356
github.com/go-logr/logr v1.4.3 // indirect
5457
github.com/go-openapi/jsonpointer v0.22.1 // indirect
5558
github.com/go-openapi/jsonreference v0.21.2 // indirect
56-
github.com/go-openapi/swag v0.23.1 // indirect
59+
github.com/go-openapi/swag v0.25.1 // indirect
60+
github.com/go-openapi/swag/cmdutils v0.25.1 // indirect
61+
github.com/go-openapi/swag/conv v0.25.1 // indirect
62+
github.com/go-openapi/swag/fileutils v0.25.1 // indirect
5763
github.com/go-openapi/swag/jsonname v0.25.1 // indirect
64+
github.com/go-openapi/swag/jsonutils v0.25.1 // indirect
65+
github.com/go-openapi/swag/loading v0.25.1 // indirect
66+
github.com/go-openapi/swag/mangling v0.25.1 // indirect
67+
github.com/go-openapi/swag/netutils v0.25.1 // indirect
68+
github.com/go-openapi/swag/stringutils v0.25.1 // indirect
69+
github.com/go-openapi/swag/typeutils v0.25.1 // indirect
70+
github.com/go-openapi/swag/yamlutils v0.25.1 // indirect
5871
github.com/gobwas/glob v0.2.3 // indirect
5972
github.com/gogo/protobuf v1.3.2 // indirect
6073
github.com/google/btree v1.1.3 // indirect
6174
github.com/google/gnostic-models v0.7.0 // indirect
6275
github.com/google/go-cmp v0.7.0 // indirect
6376
github.com/google/uuid v1.6.0 // indirect
6477
github.com/gorilla/websocket v1.5.4-0.20250319132907-e064f32e3674 // indirect
78+
github.com/gosuri/uitable v0.0.4 // indirect
6579
github.com/gregjones/httpcache v0.0.0-20190611155906-901d90724c79 // indirect
6680
github.com/hashicorp/errwrap v1.1.0 // indirect
6781
github.com/hashicorp/go-multierror v1.1.1 // indirect
6882
github.com/huandu/xstrings v1.5.0 // indirect
6983
github.com/inconshreveable/mousetrap v1.1.0 // indirect
70-
github.com/josharian/intern v1.0.0 // indirect
84+
github.com/jmoiron/sqlx v1.4.0 // indirect
7185
github.com/json-iterator/go v1.1.12 // indirect
7286
github.com/klauspost/compress v1.18.0 // indirect
87+
github.com/lann/builder v0.0.0-20180802200727-47ae307949d0 // indirect
88+
github.com/lann/ps v0.0.0-20150810152359-62de8c46ede0 // indirect
89+
github.com/lburgazzoli/k8s-manifests-lib v0.1.1 // indirect
90+
github.com/lib/pq v1.10.9 // indirect
7391
github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de // indirect
74-
github.com/mailru/easyjson v0.9.0 // indirect
7592
github.com/mattn/go-colorable v0.1.13 // indirect
7693
github.com/mattn/go-isatty v0.0.20 // indirect
94+
github.com/mattn/go-runewidth v0.0.15 // indirect
7795
github.com/mitchellh/copystructure v1.2.0 // indirect
7896
github.com/mitchellh/go-wordwrap v1.0.1 // indirect
7997
github.com/mitchellh/reflectwalk v1.0.2 // indirect
@@ -84,14 +102,16 @@ require (
84102
github.com/monochromegane/go-gitignore v0.0.0-20200626010858-205db1a8cc00 // indirect
85103
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
86104
github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f // indirect
87-
github.com/onsi/ginkgo/v2 v2.23.4 // indirect
88-
github.com/onsi/gomega v1.37.0 // indirect
105+
github.com/onsi/ginkgo/v2 v2.25.1 // indirect
106+
github.com/onsi/gomega v1.38.2 // indirect
89107
github.com/opencontainers/go-digest v1.0.0 // indirect
90108
github.com/opencontainers/image-spec v1.1.1 // indirect
91109
github.com/pelletier/go-toml/v2 v2.2.4 // indirect
92110
github.com/peterbourgon/diskv v2.0.1+incompatible // indirect
93111
github.com/pkg/errors v0.9.1 // indirect
94112
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
113+
github.com/rivo/uniseg v0.4.7 // indirect
114+
github.com/rubenv/sql-migrate v1.8.0 // indirect
95115
github.com/russross/blackfriday/v2 v2.1.0 // indirect
96116
github.com/sagikazarmark/locafero v0.11.0 // indirect
97117
github.com/santhosh-tekuri/jsonschema/v6 v6.0.2 // indirect
@@ -120,16 +140,17 @@ require (
120140
google.golang.org/genproto/googleapis/api v0.0.0-20250721164621-a45f3dfb1074 // indirect
121141
google.golang.org/genproto/googleapis/rpc v0.0.0-20250929231259-57b25ae835d4 // indirect
122142
google.golang.org/grpc v1.75.1 // indirect
123-
google.golang.org/protobuf v1.36.9 // indirect
143+
google.golang.org/protobuf v1.36.10 // indirect
124144
gopkg.in/evanphx/json-patch.v4 v4.13.0 // indirect
125145
gopkg.in/inf.v0 v0.9.1 // indirect
126146
gopkg.in/yaml.v3 v3.0.1 // indirect
127147
k8s.io/apiextensions-apiserver v0.34.1 // indirect
128-
k8s.io/cli-runtime v0.34.0 // indirect
148+
k8s.io/apiserver v0.34.1 // indirect
149+
k8s.io/cli-runtime v0.34.1 // indirect
129150
k8s.io/component-base v0.34.1 // indirect
130151
k8s.io/klog/v2 v2.130.1 // indirect
131152
k8s.io/kube-openapi v0.0.0-20250910181357-589584f1c912 // indirect
132-
k8s.io/kubectl v0.34.0 // indirect
153+
k8s.io/kubectl v0.34.1 // indirect
133154
k8s.io/utils v0.0.0-20251002143259-bc988d571ff4 // indirect
134155
oras.land/oras-go/v2 v2.6.0 // indirect
135156
sigs.k8s.io/gateway-api v1.4.0 // indirect

0 commit comments

Comments
 (0)