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

Add more strict Helm Chart schema checks for image pullPolicy & dags accessMode #15040

Merged
merged 1 commit into from
Mar 26, 2021
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions chart/tests/test_basic_helm_chart.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
from typing import Any, Dict, List, Union

import jmespath
from parameterized import parameterized

from tests.helm_template_generator import render_chart

Expand Down Expand Up @@ -146,3 +147,41 @@ def test_unsupported_executor(self):
'executor must be one of the following: "LocalExecutor", "CeleryExecutor", '
'"KubernetesExecutor", "CeleryKubernetesExecutor"' in ex_ctx.exception.stderr.decode()
)

@parameterized.expand(
[
("airflow",),
("pod_template",),
("flower",),
("statsd",),
("redis",),
("pgbouncer",),
("pgbouncerExporter",),
("gitSync",),
]
)
def test_invalid_pull_policy(self, image):
with self.assertRaises(CalledProcessError) as ex_ctx:
render_chart(
"TEST-BASIC",
{
"images": {image: {"pullPolicy": "InvalidPolicy"}},
},
)
assert (
'pullPolicy must be one of the following: "Always", "Never", "IfNotPresent"'
in ex_ctx.exception.stderr.decode()
)

def test_invalid_dags_access_mode(self):
with self.assertRaises(CalledProcessError) as ex_ctx:
render_chart(
"TEST-BASIC",
{
"dags": {"persistence": {"accessMode": "InvalidMode"}},
},
)
assert (
'accessMode must be one of the following: "ReadWriteOnce", "ReadOnlyMany", "ReadWriteMany"'
in ex_ctx.exception.stderr.decode()
)
27 changes: 18 additions & 9 deletions chart/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,8 @@
},
"pullPolicy": {
"description": "The airflow image pull policy.",
"type": "string"
"type": "string",
"enum": ["Always", "Never", "IfNotPresent"]
}
}
},
Expand All @@ -216,7 +217,8 @@
},
"pullPolicy": {
"description": "The pod_template image pull policy.",
"type": "string"
"type": "string",
"enum": ["Always", "Never", "IfNotPresent"]
}
}
},
Expand All @@ -240,7 +242,8 @@
},
"pullPolicy": {
"description": "The flower image pull policy.",
"type": "string"
"type": "string",
"enum": ["Always", "Never", "IfNotPresent"]
}
}
},
Expand All @@ -258,7 +261,8 @@
},
"pullPolicy": {
"description": "The statsd image pull policy.",
"type": "string"
"type": "string",
"enum": ["Always", "Never", "IfNotPresent"]
}
}
},
Expand All @@ -276,7 +280,8 @@
},
"pullPolicy": {
"description": "The redis image pull policy.",
"type": "string"
"type": "string",
"enum": ["Always", "Never", "IfNotPresent"]
}
}
},
Expand All @@ -294,7 +299,8 @@
},
"pullPolicy": {
"description": "The PgBouncer image pull policy.",
"type": "string"
"type": "string",
"enum": ["Always", "Never", "IfNotPresent"]
}
}
},
Expand All @@ -312,7 +318,8 @@
},
"pullPolicy": {
"description": "The PgBouncer exporter image pull policy.",
"type": "string"
"type": "string",
"enum": ["Always", "Never", "IfNotPresent"]
}
}
},
Expand All @@ -330,7 +337,8 @@
},
"pullPolicy": {
"description": "The gitSync image pull policy.",
"type": "string"
"type": "string",
"enum": ["Always", "Never", "IfNotPresent"]
}
}
}
Expand Down Expand Up @@ -1386,7 +1394,8 @@
},
"accessMode": {
"description": "Access mode of the persistent volume.",
"type": "string"
"type": "string",
"enum": ["ReadWriteOnce", "ReadOnlyMany", "ReadWriteMany"]
},
"existingClaim": {
"description": "The name of an existing PVC to use.",
Expand Down