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

centralize the kustomize walking logic, upgrade linting #359

Merged
merged 3 commits into from
Feb 3, 2025
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
1 change: 1 addition & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dotenv_if_exists
16 changes: 16 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
run:
tests: false

linters:
enable:
- bodyclose
- durationcheck
- errcheck
- gosimple
- govet
- ineffassign
- staticcheck
- unparam
- unused
- usestdlibvars
- usetesting
5 changes: 2 additions & 3 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
earthly 0.8.15
golang 1.22.7
golangci-lint 1.62.2
golangci-lint 1.63.4
helm 3.16.3
helm-cr 1.6.1
helm-ct 3.11.0
kubeconform 0.6.7
kustomize 5.5.0
kustomize 5.6.0
mockery 2.46.3
staticcheck 2024.1.1
tilt 0.33.2
23 changes: 0 additions & 23 deletions Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ test:

ci-golang:
BUILD +fmt-golang
BUILD +staticcheck-golang
BUILD +golang-ci-lint
BUILD +validate-golang
BUILD +test-golang
Expand Down Expand Up @@ -173,28 +172,6 @@ golang-ci-lint:

RUN golangci-lint --timeout 15m run --verbose

staticcheck-golang:
ARG --required STATICCHECK_VERSION

FROM +go-deps

# install staticcheck
RUN FILE=staticcheck.tgz \
&& URL=https://github.com/dominikh/go-tools/releases/download/$STATICCHECK_VERSION/staticcheck_linux_$USERARCH.tar.gz \
&& wget ${URL} \
--output-document ${FILE} \
&& tar \
--extract \
--verbose \
--directory /bin \
--strip-components=1 \
--file ${FILE} \
&& staticcheck -version

WORKDIR /src
COPY . /src
RUN staticcheck ./...

test-helm:
ARG CHART_TESTING_VERSION="3.7.1"
FROM quay.io/helmpack/chart-testing:v${CHART_TESTING_VERSION}
Expand Down
3 changes: 1 addition & 2 deletions Tiltfile
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,6 @@ earthly_build(
'--HELM_VERSION='+tool_versions.get('helm'),
'--KUBECONFORM_VERSION='+tool_versions.get('kubeconform'),
'--KUSTOMIZE_VERSION='+tool_versions.get('kustomize'),
'--STATICCHECK_VERSION='+tool_versions.get('staticcheck'),
'--GIT_COMMIT='+git_commit,
],
)
Expand All @@ -208,7 +207,7 @@ cmd_button('restart-pod',
)


helm_resource(name='kubechecks',
helm_resource(name='kubechecks',
chart='./charts/kubechecks',
image_deps=['kubechecks'],
image_keys=[('deployment.image.name', 'deployment.image.tag')],
Expand Down
1 change: 0 additions & 1 deletion earthly.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,5 @@ earthly $* \
--HELM_VERSION=${helm_tool_version} \
--KUBECONFORM_VERSION=${kubeconform_tool_version} \
--KUSTOMIZE_VERSION=${kustomize_tool_version} \
--STATICCHECK_VERSION=${staticcheck_tool_version} \
--GIT_COMMIT=$(git rev-parse --short HEAD) \
--KUBECHECKS_LOG_LEVEL=debug
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
apiVersion: networking.k8s.io/v1beta1
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: httpbin-external
Expand All @@ -11,5 +11,8 @@ spec:
paths:
- path: /httpbin/(.*)
backend:
serviceName: httpbin
servicePort: 8080
service:
name: httpbin
port:
name: http
pathType: ImplementationSpecific
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,8 @@ spec:
paths:
- path: /helloworld/(.*)
backend:
serviceName: helloworld-svc
servicePort: 8080
service:
name: helloworld-svc
port:
name: http
pathType: ImplementationSpecific
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
apiVersion: networking.k8s.io/v1beta1
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: httpdump-external
Expand All @@ -9,8 +9,10 @@ spec:
rules:
- http:
paths:
- path: /httpdump/(.*)
pathType: ImplementationSpecific
- path: /httpbin/(.*)
backend:
serviceName: httpdump
servicePort: 8080
service:
name: httpbin
port:
name: http
pathType: ImplementationSpecific
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ spec:
rules:
- http:
paths:
- path: /helloworld/(.*)
pathType: ImplementationSpecific
- path: /httpbin/(.*)
backend:
serviceName: helloworld-svc
servicePort: 8080
service:
name: httpbin
port:
name: http
pathType: ImplementationSpecific
15 changes: 11 additions & 4 deletions pkg/appdir/vcstoargomap.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"github.com/argoproj/argo-cd/v2/pkg/apis/application/v1alpha1"
"github.com/rs/zerolog/log"
"github.com/zapier/kubechecks/pkg"
"github.com/zapier/kubechecks/pkg/kustomize"
)

type VcsToArgoMap struct {
Expand Down Expand Up @@ -60,20 +61,26 @@ func (v2a VcsToArgoMap) GetAppSetsInRepo(repoCloneUrl string) *AppSetDirectory {
return appSetDir
}

func (v2a VcsToArgoMap) WalkKustomizeApps(cloneURL string, fs fs.FS) *AppDirectory {
func (v2a VcsToArgoMap) WalkKustomizeApps(cloneURL string, rootFS fs.FS) *AppDirectory {
var (
err error

result = NewAppDirectory()
appdir = v2a.GetAppsInRepo(cloneURL)
apps = appdir.GetApps(nil)
)

for _, app := range apps {
appPath := app.Spec.GetSource().Path
if err = walkKustomizeFiles(result, fs, app.Name, appPath); err != nil {

kustomizeFiles, kustomizeDir, err := kustomize.ProcessKustomizationFile(rootFS, appPath)
if err != nil {
log.Error().Err(err).Msgf("failed to parse kustomize.yaml in %s", appPath)
}
for _, file := range kustomizeFiles {
result.addFile(app.Name, file)
}
for _, dir := range kustomizeDir {
result.addDir(app.Name, dir)
}
}

return result
Expand Down
124 changes: 0 additions & 124 deletions pkg/appdir/walk_kustomize_files.go

This file was deleted.

Loading