Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Make TwingateConnector's containerExtra and podExtra mutable #223

Merged
merged 3 commits into from Mar 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -19,10 +19,6 @@ spec:
x-kubernetes-validations:
- rule: (!has(oldSelf.id) || self.id == oldSelf.id)
message: "id is immutable once set"
- rule: (!has(oldSelf.containerExtra) || self.containerExtra == oldSelf.containerExtra)
message: "containerExtra is immutable once set"
- rule: (!has(oldSelf.podExtra) || self.podExtra == oldSelf.podExtra)
message: "podExtra is immutable once set"
- rule: (has(self.image) && !has(self.imagePolicy)) || (!has(self.image) && has(self.imagePolicy)) || (!has(self.image) && !has(self.imagePolicy))
message: "Can define either `image` or `imagePolicy`, not both."
properties:
Expand Down
18 changes: 18 additions & 0 deletions tests_integration/test_connector_flows.py
Expand Up @@ -90,6 +90,24 @@ def test_connector_flows(run_kopf, ci_run_number):
assert pod["metadata"]["ownerReferences"][0]["name"] == connector_name
assert pod["metadata"]["ownerReferences"][0]["kind"] == "TwingateConnector"

# Check patching TwingateConnector updates the pod
kubectl_patch(
f"tc/{connector_name}",
{
"spec": {
"containerExtra": {"env": [{"name": "FOO", "value": "bar"}]},
"podExtra": {"restartPolicy": "OnFailure"},
}
},
)
time.sleep(10)
pod = kubectl_get("pod", connector_name)

assert pod["status"]["phase"] == "Running"
assert pod["spec"]["restartPolicy"] == "OnFailure"
assert pod["spec"]["containers"][0]["env"][-1]["name"] == "FOO"
assert pod["spec"]["containers"][0]["env"][-1]["value"] == "bar"

kubectl_delete(f"tc/{connector_name}")
time.sleep(10)

Expand Down