Skip to content

Commit

Permalink
add examples for gitlab and github, extend Readme
Browse files Browse the repository at this point in the history
  • Loading branch information
schlapzz committed May 13, 2023
1 parent 683ebdf commit 950c0ce
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 12 deletions.
5 changes: 3 additions & 2 deletions Readme.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
GOFF
===

The GitOps Diff tool. Review your changes in deep.
Inspired from Kostis K... talk at the KubeCon about [How to Preview and Diff Your Argo CD Deployments](https://youtu.be/X392bJX0AEs) we relased our own GitOps Diff tool (Goff). This tool helps you to preview your changes in your GitOps Repository,


# Usage

Expand Down Expand Up @@ -33,7 +34,7 @@ Use "goff [command] --help" for more information about a command.
| Plain manifests ||
| Helm | ✅ Supported through plain manifests |
| Kustomize ||
| ArgoCD Application | ✅ Needs the ArgoCD Repo Server |
| ArgoCD Application | ✅ Needs a local ArgoCD Repo server instance |
| ArgoCD ApplicationSet | 🚧 Not yet supported |

# Build binary from source
Expand Down
12 changes: 2 additions & 10 deletions cmd/diff.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ var diffCmd = &cobra.Command{
Use: "diff",
Short: "Diff files [sourceDir] [targetDir]",
Args: cobra.ExactArgs(2),
Long: `Generate diff between directories`,
Long: `Generate diff between two directories`,
Run: func(cmd *cobra.Command, args []string) {
diff.Diff(*title, *markdown, args[0], args[1], *outputDir)
},
Expand All @@ -31,15 +31,7 @@ var diffCmd = &cobra.Command{
func init() {
rootCmd.AddCommand(diffCmd)

// Here you will define your flags and configuration settings.

// Cobra supports Persistent Flags which will work for this command
// and all subcommands, e.g.:
// diffCmd.PersistentFlags().String("foo", "", "A help for foo")

// Cobra supports local flags which will only run when this command
// is called directly, e.g.:
markdown = diffCmd.Flags().StringP("markdown", "m", "markdown", "Markdown template")
title = diffCmd.Flags().StringP("title", "t", "title", "Title for markdown")
title = diffCmd.Flags().StringP("title", "t", "Preview", "Title for markdown")
outputDir = diffCmd.Flags().StringP("output-dir", "o", ".", "Output directory")
}
38 changes: 38 additions & 0 deletions doc/github/helm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
on:
pull_request:
types: [opened, synchronize]
paths:
- "helm/**"

permissions:
contents: read
pull-requests: write

name: Diff GitOps Environments

jobs:
diff-env:
# The type of runner that the job will run on
runs-on: ubuntu-latest
container:
image: registry.puzzle.ch/cicd/goff:latest
steps:
- name: Checkout PR
uses: actions/checkout@v3
with:
path: source
- name: Checkout Target of PR
uses: actions/checkout@v3
with:
path: target
ref: ${{ github.event.pull_request.base.ref }}
- run: |
helm template mychart ./source/helm/mychart --output-dir /tmp/source/out
helm template mychart ./target/helm/mychart --output-dir /tmp/target/out
goff diff "/tmp/source" "/tmp/target" --output-dir .
- name: comment PR
uses: machine-learning-apps/pr-comment@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
path: diff.md
38 changes: 38 additions & 0 deletions doc/github/kustomize.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
on:
pull_request:
types: [opened, synchronize]
paths:
- "kustomize/**"

permissions:
contents: read
pull-requests: write

name: Diff GitOps Environments

jobs:
diff-env:
# The type of runner that the job will run on
runs-on: ubuntu-latest
container:
image: registry.puzzle.ch/cicd/goff:latest
steps:
- name: Checkout PR
uses: actions/checkout@v3
with:
path: source
- name: Checkout Target of PR
uses: actions/checkout@v3
with:
path: target
ref: ${{ github.event.pull_request.base.ref }}
- run: |
goff kustomize build ./source/kustomize --output-dir /tmp/source/out
goff kustomize build ./target/kustomize --output-dir /tmp/target/out
goff diff "/tmp/source" "/tmp/target" --title=Preview --output-dir .
- name: comment PR
uses: machine-learning-apps/pr-comment@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
path: diff.md

0 comments on commit 950c0ce

Please sign in to comment.