Skip to content

Commit

Permalink
Merge pull request #9 from rarchk/pre-commit-hooks
Browse files Browse the repository at this point in the history
updating generalized helm differ
  • Loading branch information
rarchk authored Oct 25, 2023
2 parents a40d904 + 4e3adbb commit 97e7a5b
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 2 deletions.
45 changes: 45 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -167,3 +167,48 @@ jobs:
ARTIFACTORY_USERNAME: ${{ secrets.ARTIFACTORY_HELM_USERNAME }}
ARTIFACTORY_PASSWORD: ${{ secrets.ARTIFACTORY_HELM_PASSWORD }}
```

## Diff as a template
Diff can be used to compute differences between complex helm distributions

```mermaid
graph TD
subgraph ComplexHelmDistributions
HelmFile --> ListOfHelmCharts
CustomRelease --> ListOfHelmCharts
end
subgraph CD_Workflows
ArgoCDApplication --> HelmChart
end
subgraph HELM_Repos
B[HelmChart]
end
CD_Workflows --> D
ComplexHelmDistributions -.-> D
ComplexHelmDistributions -.-> D
ComplexHelmDistributions -.-> D
HELM_Repos --> D
D[[Diff Action Template]]
D --> C(fa:fa-genderless)
```
### Algorithm
1. We would need previous and next version
2. We would need access to remote chart repository
3. We can use this command to generate templates locally and remotely
4. We take following inputs
1. previous version
2. current version[optional] or can be generated locally

```bash
# local templating
helm template <chart_name>.tgz -f values.yaml
# remote templating
helm template <remote_repo>/chart_name --version 1.17.1 -f values.yaml
# search for all versions
helm search repo <remote_repo>/chart_name --versions
```
4. Diff it
9 changes: 7 additions & 2 deletions main.sh
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ case "${ACTION}" in
OUTPUT=$(sh -c "dyff between /tmp/upstream_values.yaml /tmp/current_values.yaml -c on" 2>&1)
OUTPUT1=$(sh -c "dyff between /tmp/upstream_values.yaml /tmp/current_values.yaml" 2>&1)
if [ $? -ge 2 ]; then
OUTPUT=$(sh -c "diff --color /tmp/upstream_values.yaml /tmp/current_values.yaml" 2>&1)
OUTPUT1=$(sh -c "diff /tmp/upstream_values.yaml /tmp/current_values.yaml" 2>&1)
OUTPUT=$(sh -c "diff -u --color /tmp/upstream_values.yaml /tmp/current_values.yaml" 2>&1)
OUTPUT1=$(sh -c "diff -u /tmp/upstream_values.yaml /tmp/current_values.yaml" 2>&1)
fi
SUCCESS=$?
echo -e '\033[1mComputed Helm Diff\033[0m'
Expand All @@ -71,7 +71,12 @@ case "${ACTION}" in
COMMENT="#### \`Computed Helm Diff\` Output
<details>
<summary>Details</summary>
```bash
$OUTPUT1
```
</details>"
PAYLOAD=$(echo '{}' | jq --arg body "$COMMENT" '.body = $body')

Expand Down

0 comments on commit 97e7a5b

Please sign in to comment.