Skip to content

Commit 210f0c2

Browse files
first commit
0 parents  commit 210f0c2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+4081
-0
lines changed

.github/workflows/auto-release.yaml

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
---
2+
name: Auto Release
3+
4+
on: push
5+
6+
jobs:
7+
build:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- name: checkout
11+
uses: actions/checkout@v3
12+
- name: set up go version
13+
uses: actions/setup-go@v3
14+
- name: Go Build x64
15+
run: go build -o mani-diffy
16+
- name: Go Build arm64
17+
run: GOOS=darwin GOARCH=arm64 go build -o mani-diffy-darwin-arm64
18+
- name: Create Release Text
19+
run: echo ${{ github.sha }} > Release.txt
20+
- name: Test Build x64
21+
run: file mani-diffy | grep "x86-64"
22+
- name: Test Build arm64
23+
run: file mani-diffy-darwin-arm64 | grep "arm64"
24+
- name: Release
25+
uses: softprops/action-gh-release@v1
26+
if: startsWith(github.ref, 'refs/tags/')
27+
with:
28+
files: |
29+
mani-diffy
30+
mani-diffy-darwin-arm64
31+
Release.txt
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Generate manifests for demo
2+
on: [push]
3+
4+
jobs:
5+
build-and-run:
6+
runs-on: ubuntu-latest
7+
steps:
8+
- name: Checkout code
9+
uses: actions/checkout@v2
10+
11+
- name: Set up Git
12+
run: |
13+
git config --global user.name 'Bot'
14+
git config --global user.email '[email protected]'
15+
16+
- name: Compile
17+
run: |
18+
make build-binaries
19+
20+
- name: Run for demo
21+
run: |
22+
cd demo
23+
rm -rf .zz.auto-generated
24+
../mani-diffy -hash-store=json
25+
26+
- name: Commit and push changes to /demo
27+
run: |
28+
if git diff --quiet; then
29+
echo "No changes to commit"
30+
else
31+
git add .
32+
git commit -m "Some manifests have changed in the demo."
33+
git push
34+
fi
35+
cd ..

.github/workflows/tests.yaml

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
---
2+
name: tests
3+
4+
on:
5+
pull_request:
6+
types: [assigned, opened, synchronize, reopened, ready_for_review]
7+
8+
jobs:
9+
go_test:
10+
# strategy:
11+
# matrix:
12+
# go-versions: [1.18.x]
13+
# os: [ubuntu-latest, macos-latest]
14+
# runs-on: ${{ matrix.os }}
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: checkout
18+
uses: actions/checkout@v3
19+
- name: set up go version
20+
uses: actions/setup-go@v3
21+
with:
22+
# go-version: ${{ matrix.go-versions }}
23+
go-version: '1.20'
24+
- name: run go tests
25+
run: |
26+
go test -v ./...
27+
golangci:
28+
# https://github.com/golangci/golangci-lint-action
29+
name: lint
30+
runs-on: ubuntu-latest
31+
steps:
32+
- uses: actions/setup-go@v3
33+
- uses: actions/checkout@v3
34+
- name: golangci-lint
35+
uses: golangci/golangci-lint-action@v3
36+
with:
37+
version: v1.53
38+
# use config in .golangci.yaml to configure the action further

.gitignore

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# ignore binaries build during testing
2+
mani-diffy*
3+
hashes.json
4+
hash.sum
5+
6+
.idea
7+
.DS_Store

.golangci.yaml

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# https://golangci-lint.run/usage/configuration/#config-file
2+
run:
3+
allow-parallel-runners: true
4+
timeout: 5m
5+
go: '1.20'
6+
7+
linters:
8+
enable:
9+
- errcheck
10+
- errorlint
11+
- exportloopref
12+
- gocritic
13+
- gofmt
14+
- goimports
15+
- gosec
16+
- govet
17+
- misspell
18+
- revive
19+
- staticcheck
20+
- tenv
21+
- unconvert
22+
- unused
23+
- unparam
24+
25+
issues:
26+
# Excluding configuration per-path, per-linter, per-text and per-source
27+
exclude-rules:
28+
- text: "G306:"
29+
linters:
30+
- gosec
31+
- text: "G204:"
32+
linters:
33+
- gosec
34+
- text: "G112:"
35+
linters:
36+
- gosec

CODEOWNERS

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* @1debit/infrastructure-eng

CODE_OF_CONDUCT.md

+74
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# Contributor Covenant Code of Conduct
2+
3+
## Our Pledge
4+
5+
In the interest of fostering an open and welcoming environment, we as
6+
contributors and maintainers pledge to making participation in our project and
7+
our community a harassment-free experience for everyone, regardless of age, body
8+
size, disability, ethnicity, gender identity and expression, level of experience,
9+
nationality, personal appearance, race, religion, or sexual identity and
10+
orientation.
11+
12+
## Our Standards
13+
14+
Examples of behavior that contributes to creating a positive environment
15+
include:
16+
17+
* Using welcoming and inclusive language
18+
* Being respectful of differing viewpoints and experiences
19+
* Gracefully accepting constructive criticism
20+
* Focusing on what is best for the community
21+
* Showing empathy towards other community members
22+
23+
Examples of unacceptable behavior by participants include:
24+
25+
* The use of sexualized language or imagery and unwelcome sexual attention or
26+
advances
27+
* Trolling, insulting/derogatory comments, and personal or political attacks
28+
* Public or private harassment
29+
* Publishing others' private information, such as a physical or electronic
30+
address, without explicit permission
31+
* Other conduct which could reasonably be considered inappropriate in a
32+
professional setting
33+
34+
## Our Responsibilities
35+
36+
Project maintainers are responsible for clarifying the standards of acceptable
37+
behavior and are expected to take appropriate and fair corrective action in
38+
response to any instances of unacceptable behavior.
39+
40+
Project maintainers have the right and responsibility to remove, edit, or
41+
reject comments, commits, code, wiki edits, issues, and other contributions
42+
that are not aligned to this Code of Conduct, or to ban temporarily or
43+
permanently any contributor for other behaviors that they deem inappropriate,
44+
threatening, offensive, or harmful.
45+
46+
## Scope
47+
48+
This Code of Conduct applies both within project spaces and in public spaces
49+
when an individual is representing the project or its community. Examples of
50+
representing a project or community include using an official project e-mail
51+
address, posting via an official social media account, or acting as an appointed
52+
representative at an online or offline event. Representation of a project may be
53+
further defined and clarified by project maintainers.
54+
55+
## Enforcement
56+
57+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
58+
reported by contacting the project team at "[email protected]". All
59+
complaints will be reviewed and investigated and will result in a response that
60+
is deemed necessary and appropriate to the circumstances. The project team is
61+
obligated to maintain confidentiality with regard to the reporter of an incident.
62+
Further details of specific enforcement policies may be posted separately.
63+
64+
Project maintainers who do not follow or enforce the Code of Conduct in good
65+
faith may face temporary or permanent repercussions as determined by other
66+
members of the project's leadership.
67+
68+
## Attribution
69+
70+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71+
available at [http://contributor-covenant.org/version/1/4][version]
72+
73+
[homepage]: http://contributor-covenant.org
74+
[version]: http://contributor-covenant.org/version/1/4/

LICENSE.txt

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2023 Chime Financial
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in
13+
all copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
THE SOFTWARE.

Makefile

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
test:
2+
go test ./...
3+
4+
test-verbose:
5+
go test -v ./...
6+
7+
benchmark:
8+
go test -bench=.
9+
10+
benchmark-all:
11+
go test ./... -bench=.
12+
13+
lint:
14+
golangci-lint run
15+
16+
build-binaries:
17+
go build -o mani-diffy

README.md

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# mani-diffy
2+
3+
![Tests](https://github.com/1debit/mani-diffy/actions/workflows/tests.yaml/badge.svg)
4+
5+
This program walks a hierarchy of Argo CD Application templates, renders Kubernetes manifests from the input templates, and posts the rendered files back for the user to review and validate.
6+
7+
It is designed to be called from a CI job within a pull request, enabling the author to update templates and see the resulting manifests directly within the pull request before the changes are applied to the Kubernetes cluster.
8+
9+
The rendered manifests are kept within the repository, making diffs between revisions easy to parse, dramatically improving safety when updating complex application templates.
10+
11+
---
12+
## How it works:
13+
1. A user makes their desired change to the application's templates (charts, overrides, etc) and submits a PR with the change.
14+
2. A CI job executes `mani-diffy`, rendering all manifests affected by the change.
15+
3. Any updated manifests are submitted back to the same PR as a new commit.
16+
4. The author and any reviewers will be able to review the diff between the new changes and the previous version of the manifests.
17+
18+
## Post Renderers
19+
20+
`mani-diffy` also supports something called a "post renderer". This is a command that will be called immediately after an Application is rendered. This can be used to run linting, or alter the output of the generated manifest.
21+
22+
```
23+
mani-diffy -post-renderer="bin/post-render" -output=.zz-auto-generated
24+
```
25+
26+
The command will be called with the output directory as the first argument (e.g. `.zz-auto-generated/<application name>`)
27+
28+
---
29+
30+
## Pre-requisites
31+
32+
This is for a new user that is looking to use mani-diffy on a new repo.
33+
34+
In order to make use of mani-diffy on the repo that holds all of your ArgoCD applications the pre-requisites are:
35+
36+
- You have a "root" Application
37+
- All of your charts and Application manifests live in the same repo.
38+
39+
`mani-diffy` itself makes no assumptions about how the repo is structured, as long as it can successfully render the charts it encounters while walking the Application tree.
40+
41+
However, you may find it useful to organize your repo similarly to the demo app, with 3 key directories :
42+
43+
1. a "root" or "bootstrap" directory that holds all the ArgoCD applications manifests.
44+
2. a "charts" directory that contains all the helm charts needed for the ArgoCD applications.
45+
3. a "rendered" or "generated" directory, where all rendered charts will be committed.
46+
47+
You can see an example of that in the [`demo`](demo/README.md) directory.
48+
49+
# FAQ
50+
51+
Q: Is ArgoCD using the rendered manifests in `.zz.auto-generated` ?
52+
53+
A: No, ArgoCD renders the charts itself. There is no expected discrepancy between the manifest files rendered by mani-diffy and by ArgoCD as long as they are using the same version of Helm.
54+
55+
56+
57+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
---
2+
# Source: app-of-apps/templates/apps.yaml
3+
apiVersion: argoproj.io/v1alpha1
4+
kind: Application
5+
metadata:
6+
name: prod-service-bar
7+
spec:
8+
destination:
9+
namespace: argocd
10+
server: https://kubernetes.default.svc
11+
project: default
12+
source:
13+
repoURL: https://github.com/my-org/my-repo.git
14+
path: charts/service
15+
helm:
16+
version: v3
17+
parameters:
18+
- name: env
19+
value: prod
20+
valueFiles:
21+
- ../../overrides/service/bar/base.yaml
22+
- ../../overrides/service/bar/prod.yaml
23+
syncPolicy:
24+
automated: {}
25+
---
26+
# Source: app-of-apps/templates/apps.yaml
27+
apiVersion: argoproj.io/v1alpha1
28+
kind: Application
29+
metadata:
30+
name: prod-service-foo
31+
spec:
32+
destination:
33+
namespace: argocd
34+
server: https://kubernetes.default.svc
35+
project: default
36+
source:
37+
repoURL: https://github.com/my-org/my-repo.git
38+
path: charts/service
39+
helm:
40+
version: v3
41+
parameters:
42+
- name: env
43+
value: prod
44+
valueFiles:
45+
- ../../overrides/service/foo/base.yaml
46+
- ../../overrides/service/foo/prod.yaml
47+
syncPolicy:
48+
automated: {}

0 commit comments

Comments
 (0)