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

Disallow having service account + iam_role #3991

Merged
merged 3 commits into from
Jan 8, 2025
Merged
Show file tree
Hide file tree
Changes from 2 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
8 changes: 8 additions & 0 deletions paasta_tools/cli/schemas/kubernetes_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,14 @@
]
}
]
},
{
"not": {
"required": [
"service_account_name",
"iam_role"
]
}
}
],
"properties": {
Expand Down
31 changes: 31 additions & 0 deletions tests/cli/test_cmds_validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -606,6 +606,37 @@ def test_instance_validate_schema_iam_role(
assert expected_output in output


@pytest.mark.parametrize(
"iam_role, service_account_name, instance_type, expected",
[
("arn:aws:iam::12345678:role/some_role", None, "kubernetes", True),
("arn:aws:iam::12345678:role/some_role", None, "eks", True),
("arn:aws:iam::12345678:role/some_role", "some_svc_account", "eks", False),
(None, "some_svc_account", "eks", True),
],
)
def test_instance_validate_schema_sa_and_iam_role(
iam_role,
service_account_name,
instance_type,
expected,
capsys,
):
instance_content = f"""
test_instance:
{"iam_role: "+iam_role if iam_role else ""}
{"service_account_name: "+service_account_name if service_account_name else ""}
"""
with patch(
"paasta_tools.cli.cmds.validate.get_file_contents", autospec=True
) as mock_get_file_contents:
mock_get_file_contents.return_value = instance_content
assert validate_schema("unused_service_path.yaml", instance_type) == expected
expected_output = SCHEMA_VALID if expected else SCHEMA_INVALID
output, _ = capsys.readouterr()
assert expected_output in output


@patch("paasta_tools.cli.cmds.validate.get_file_contents", autospec=True)
def test_tron_validate_schema_understands_underscores(mock_get_file_contents, capsys):
tron_content = """
Expand Down