-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: impl k8s strategic merge patch
Signed-off-by: peefy <[email protected]>
- Loading branch information
Showing
8 changed files
with
206 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
[package] | ||
name = "looper" | ||
version = "0.0.1" | ||
version = "0.1.0" | ||
description = "`looper` is a KCL loop library" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
[package] | ||
name = "strategic_merge_patch" | ||
version = "0.0.1" | ||
version = "0.1.0" | ||
description = "`strategic_merge_patch` is a module for applying Kubernetes strategic merge patches for KCL values." | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import yaml | ||
|
||
test_merge = lambda { | ||
original = { | ||
"metadata": { | ||
"name": "my-deployment" | ||
"labels": {"app": "my-app"} | ||
} | ||
"spec": { | ||
"replicas": 3 | ||
"template": { | ||
"spec": {"containers": [ | ||
{ | ||
"name": "my-container-1" | ||
"image": "my-image-1" | ||
} | ||
{ | ||
"name": "my-container-2" | ||
"image": "my-image-2" | ||
} | ||
]} | ||
} | ||
} | ||
} | ||
patch = { | ||
"metadata": { | ||
"labels": {"version": "v1"} | ||
} | ||
"spec": { | ||
"replicas": 4 | ||
"template": { | ||
"spec": {"containers": [ | ||
{ | ||
"name": "my-container-1" | ||
"image" = "my-new-image-1" | ||
} | ||
{ | ||
"name": "my-container-3" | ||
"image" = "my-image-3" | ||
} | ||
]} | ||
} | ||
} | ||
} | ||
expected = yaml.decode("""\ | ||
metadata: | ||
name: my-deployment | ||
labels: | ||
app: my-app | ||
version: v1 | ||
spec: | ||
replicas: 4 | ||
template: | ||
spec: | ||
containers: | ||
- name: my-container-1 | ||
image: my-new-image-1 | ||
- name: my-container-2 | ||
image: my-image-2 | ||
- name: my-container-3 | ||
image: my-image-3 | ||
""") | ||
got = merge(original, patch) | ||
assert str(got) == str(expected), "expected ${expected}, got ${got}" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters