Skip to content
Open
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
20 changes: 20 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
repos:
- repo: https://github.com/Lucas-C/pre-commit-hooks
rev: v1.5.1
hooks:
- id: remove-tabs

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: trailing-whitespace
- id: check-merge-conflict
- id: end-of-file-fixer
- id: check-added-large-files
args: [--maxkb=750]
- id: check-case-conflict
- id: check-yaml
args: [--allow-multiple-documents]
- id: end-of-file-fixer
- id: trailing-whitespace
56 changes: 56 additions & 0 deletions .tekton/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
---
apiVersion: tekton.dev/v1beta1
kind: PipelineRun
metadata:
name: release
annotations:
pipelinesascode.tekton.dev/on-event: "[push]"
pipelinesascode.tekton.dev/on-target-branch: "[main, refs/tags/*]"
pipelinesascode.tekton.dev/task: "[git-clone]"
pipelinesascode.tekton.dev/max-keep-runs: "5"
spec:
params:
- name: repo_url
value: "{{repo_url}}"
- name: revision
value: "{{revision}}"
pipelineSpec:
params:
- name: repo_url
- name: revision
workspaces:
- name: source
tasks:
- name: fetch-repository
taskRef:
name: git-clone
workspaces:
- name: output
workspace: source
params:
- name: url
value: $(params.repo_url)
- name: revision
value: $(params.revision)
- name: build-release-container-image
taskRef:
name: buildah-as-user
namespace: op1st-pipelines
runAfter:
- fetch-repository
workspaces:
- name: source
workspace: source
params:
- name: IMAGE
value: ghcr.io/b4mad/pre-commit-kustomize

workspaces:
- name: source
volumeClaimTemplate:
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 1Gi
17 changes: 17 additions & 0 deletions Containerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
FROM alpine:latest

LABEL org.opencontainers.image.source = "https://github.com/b4mad/pre-commit-kustomize"

RUN adduser kustomize -D \
&& apk add curl git openssh \
&& git config --global url.ssh://git@github.com/.insteadOf https://github.com/
RUN curl -L --output /tmp/kustomize_v5.0.3_linux_amd64.tar.gz https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize%2Fv5.0.3/kustomize_v5.0.3_linux_amd64.tar.gz \
&& echo "c627b1575c3fecbc7ad1c181c23a7adcacf19732dab627eb57e89a7bc4c1e929 /tmp/kustomize_v5.0.3_linux_amd64.tar.gz" | sha256sum -c \
&& tar -xvzf /tmp/kustomize_v5.0.3_linux_amd64.tar.gz -C /usr/local/bin \
&& chmod +x /usr/local/bin/kustomize \
&& mkdir ~/.ssh \
&& ssh-keyscan -t rsa github.com >> ~/.ssh/known_hosts

USER kustomize

WORKDIR /src
12 changes: 0 additions & 12 deletions Dockerfile

This file was deleted.

8 changes: 8 additions & 0 deletions OWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# See the OWNERS docs at https://go.k8s.io/owners

approvers:
- goern

reviewers:
- durandom
- goern
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# pre-commit-docker-kustomize
pre-commit hook which runs kustomize docker image. Docker image is based on https://github.com/lyft/kustomizer, but added github.com into known hosts and not running this image as root. This modification allows for remote refs in your kustomize. Other git providers will probably won't work and require further changes. Please raise an issue.

pre-commit hook which runs kustomize docker image. Container image is based on <https://github.com/lyft/kustomizer>, but added github.com into known hosts and not running this image as root. This modification allows for remote refs in your kustomize. Other git providers will probably won't work and require further changes. Please raise an issue.

## Example of .pre-commit-config.yaml that verifies that 3 overlays are not broken

```yaml
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
Expand All @@ -12,13 +14,13 @@ repos:
- id: check-yaml
args: [--allow-multiple-documents]
- id: check-added-large-files
- repo: https://github.com/dmitri-lerko/pre-commit-docker-kustomize
- repo: https://github.com/b4mad/pre-commit-kustomize
rev: f3a8533
hooks:
- id: kustomize
name: kustomize-development
args: [overlays/development]
verbose: false
verbose: true
- id: kustomize
name: kustomize-staging
args: [overlays/staging]
Expand Down
16 changes: 8 additions & 8 deletions hooks.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
- id: kustomize
name: kustomize (via docker)
description: kustomize provided by docker
entry: kustomize build
language: docker
args: [overlay/production]
always_run: true
pass_filenames: false
- id: kustomize
name: kustomize (containerized)
description: kustomize provided in a container
entry: kustomize build
language: docker
args: [overlay/production]
always_run: true
pass_filenames: false
8 changes: 8 additions & 0 deletions manifests/repository.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apiVersion: pipelinesascode.tekton.dev/v1alpha1
kind: Repository
metadata:
creationTimestamp: null
name: github-com-b4mad-pre-commit-kustomize
namespace: op1st-pipelines
spec:
url: https://github.com/b4mad/pre-commit-kustomize