Skip to content

Commit 91b5392

Browse files
committed
Add support for 'changed files' and 'watch-pattern' annotation (#50)
1 parent 9c51e4a commit 91b5392

15 files changed

Lines changed: 446 additions & 122 deletions

File tree

.github/workflows/generate-diff.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ on:
99
- "examples/**"
1010

1111
jobs:
12-
build:
12+
render-diff:
1313
runs-on: ubuntu-latest
1414
permissions:
1515
contents: read

.github/workflows/mkdocs.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,12 @@ on:
44
branches:
55
- master
66
- main
7+
paths:
8+
- "docs/**"
9+
710
permissions:
811
contents: write
12+
913
jobs:
1014
deploy:
1115
runs-on: ubuntu-latest

.github/workflows/pr-build.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ on:
44
pull_request:
55
branches:
66
- "main"
7+
paths:
8+
- "src/**"
9+
- Cargo.toml
710

811
jobs:
912
build-amd64:

Cargo.lock

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "argocd-diff-preview"
3-
version = "0.0.19"
3+
version = "0.0.20"
44
edition = "2021"
55

66
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
@@ -10,7 +10,7 @@ tokio = {version="1.40.0",features = ["full"]}
1010
base64 = "0.22.1"
1111
serde = "1.0.210"
1212
serde_yaml = "0.9.33"
13-
serde_json = "1.0.128"
13+
serde_json = "1.0.131"
1414
walkdir = "2.5.0"
1515
schemars = "0.8.21"
1616
structopt = { version = "0.3" }
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
apiVersion: argoproj.io/v1alpha1
2+
kind: Application
3+
metadata:
4+
name: my-app-labels
5+
namespace: argocd
6+
labels:
7+
team: my-team
8+
spec:
9+
project: default
10+
destination:
11+
name: in-cluster
12+
namespace: default
13+
sources:
14+
- repoURL: https://github.com/dag-andersen/argocd-diff-preview
15+
ref: local-files
16+
- path: examples/helm/charts/myApp
17+
repoURL: https://github.com/dag-andersen/argocd-diff-preview
18+
helm:
19+
valueFiles:
20+
- $local-files/examples/helm/values/values.yaml
21+
valuesObject:
22+
replicaCount: 5
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
apiVersion: argoproj.io/v1alpha1
2+
kind: Application
3+
metadata:
4+
name: my-app-watch-pattern-broken-regex
5+
namespace: argocd
6+
annotations:
7+
argocd-diff-preview/watch-pattern: '\'
8+
spec:
9+
project: default
10+
destination:
11+
name: in-cluster
12+
namespace: default
13+
sources:
14+
- repoURL: https://github.com/dag-andersen/argocd-diff-preview
15+
ref: local-files
16+
- path: examples/helm/charts/myApp
17+
repoURL: https://github.com/dag-andersen/argocd-diff-preview
18+
helm:
19+
valueFiles:
20+
- $local-files/examples/helm/values/values.yaml
21+
valuesObject:
22+
replicaCount: 5
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
apiVersion: argoproj.io/v1alpha1
2+
kind: Application
3+
metadata:
4+
name: my-app-watch-pattern-valid-regex
5+
namespace: argocd
6+
annotations:
7+
argocd-diff-preview/watch-pattern: "examples/helm/values/.*"
8+
spec:
9+
project: default
10+
destination:
11+
name: in-cluster
12+
namespace: default
13+
sources:
14+
- repoURL: https://github.com/dag-andersen/argocd-diff-preview
15+
ref: local-files
16+
- path: examples/helm/charts/myApp
17+
repoURL: https://github.com/dag-andersen/argocd-diff-preview
18+
helm:
19+
valueFiles:
20+
- $local-files/examples/helm/values/values.yaml
21+
valuesObject:
22+
replicaCount: 5

makefile

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,18 @@ pull-repostory:
1010
cd base-branch && gh repo clone $(github_org)/$(gitops_repo) -- --depth=1 --branch "$(base_branch)" && cp -r $(gitops_repo)/. . && rm -rf .git && echo "*" > .gitignore && rm -rf $(gitops_repo) && cd -
1111
cd target-branch && gh repo clone $(github_org)/$(gitops_repo) -- --depth=1 --branch "$(target_branch)" && cp -r $(gitops_repo)/. . && rm -rf .git && echo "*" > .gitignore && rm -rf $(gitops_repo) && cd -
1212

13-
local-test-cargo: pull-repostory
14-
cargo run -- -b "$(base_branch)" -t "$(target_branch)" --repo $(github_org)/$(gitops_repo) -r "$(regex)" --debug --diff-ignore "$(diff-ignore)" --timeout $(timeout) -l "$(selector)"
13+
run-with-cargo: pull-repostory
14+
cargo run -- -b "$(base_branch)" \
15+
-t "$(target_branch)" \
16+
--repo $(github_org)/$(gitops_repo) \
17+
--debug \
18+
-r "$(regex)" \
19+
--diff-ignore "$(diff_ignore)" \
20+
--timeout $(timeout) \
21+
-l "$(selector)" \
22+
--files-changed="$(files_changed)"
1523

16-
local-test-docker: pull-repostory
24+
run-with-docker: pull-repostory
1725
docker build . -f $(docker_file) -t image
1826
docker run \
1927
--network=host \
@@ -27,6 +35,8 @@ local-test-docker: pull-repostory
2735
-e TARGET_BRANCH=$(target_branch) \
2836
-e REPO=$(github_org)/$(gitops_repo) \
2937
-e FILE_REGEX="$(regex)" \
30-
-e DIFF_IGNORE="$(diff-ignore)" \
38+
-e DIFF_IGNORE="$(diff_ignore)" \
3139
-e TIMEOUT=$(timeout) \
40+
-e SELECTOR="$(selector)" \
41+
-e FILES_CHANGED="$(files_changed)" \
3242
image

src/argocd.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,6 @@ pub async fn install_argo_cd(options: ArgoCDOptions<'_>) -> Result<(), Box<dyn E
6060
}
6161
}
6262

63-
info!("🦑 Installing Argo CD Helm Chart");
64-
6563
let helm_install_command = format!(
6664
"helm install argocd argo/argo-cd -n argocd {} {} {}",
6765
values.unwrap_or_default(),
@@ -121,10 +119,8 @@ pub async fn install_argo_cd(options: ArgoCDOptions<'_>) -> Result<(), Box<dyn E
121119
let password_decoded = BASE64_STANDARD
122120
.decode(password_encoded)
123121
.expect("failed to decode password");
124-
let password =
125-
String::from_utf8(password_decoded).expect("failed to convert password to string");
126122

127-
password
123+
String::from_utf8(password_decoded).expect("failed to convert password to string")
128124
};
129125

130126
// sleep for 5 seconds

0 commit comments

Comments
 (0)