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

fix: Add validation for TwingateConnector when provider is “google” #224

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 @@ -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