Skip to content

Commit

Permalink
fix: Add validation for TwingateConnector when provider is “google” (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
ekampf committed Mar 26, 2024
1 parent 0b1e69b commit 68e188e
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
Expand Up @@ -56,6 +56,9 @@ spec:
type: object
description: "ImagePolicy defines the image to use for the Connector and a schedule to keep it up to date."
required: ["provider"]
x-kubernetes-validations:
- rule: self.provider != "google" || (self.provider == "google" && !has(self.repository))
message: "Google provider requires specifying repository."
properties:
provider:
type: string
Expand Down
20 changes: 20 additions & 0 deletions tests_integration/test_crds_connector.py
Expand Up @@ -256,3 +256,23 @@ def test_imagepolicy_validates_provider(self, unique_connector_name):
version: "^1.0.0"
"""
)

def test_google_provider_requires_repository(self, unique_connector_name):
with pytest.raises(subprocess.CalledProcessError) as ex:
kubectl_create(
f"""
apiVersion: twingate.com/v1beta
kind: TwingateConnector
metadata:
name: {unique_connector_name}
spec:
name: {unique_connector_name}
logLevel: 3
imagePolicy:
provider: "google"
version: "^1.0.0"
"""
)

stderr = ex.value.stderr.decode()
assert "Google provider requires specifying repository." in stderr

0 comments on commit 68e188e

Please sign in to comment.