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 nodePort declaration to chart/values.schema.json #26945

Merged
merged 8 commits into from
Nov 14, 2022
6 changes: 6 additions & 0 deletions chart/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -3465,6 +3465,12 @@
"integer"
]
},
"nodePort": {
"type": [
"string",
"integer"
]
},
"protocol": {
"type": "string"
}
Expand Down
29 changes: 29 additions & 0 deletions tests/charts/test_webserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -719,6 +719,35 @@ def test_should_add_component_specific_labels(self):
assert "test_label" in jmespath.search("metadata.labels", docs[0])
assert jmespath.search("metadata.labels", docs[0])["test_label"] == "test_label_value"

@pytest.mark.parametrize(
"ports, expected_ports",
[
(
[{"nodePort": "31000", "port": "8080"}],
[{"nodePort": 31000, "port": 8080}],
),
(
[{"port": "8080"}],
[{"port": 8080}],
),
],
)
def test_nodeport_service(self, ports, expected_ports):
Copy link
Contributor

@dstandish dstandish Oct 10, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like your params aren't consistent with those provided in expand
but let's see what the tests tell us
i'd also add an entry (in expand) for when no nodePort is provided

Copy link
Contributor Author

@joseph-max-coalfire joseph-max-coalfire Oct 10, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like your params aren't consistent with those provided in expand

@dstandish Not sure I follow-- I used the test_ports_overrides param structure as a reference, and it looks like CI checks are passing

i'd also add an entry (in expand) for when no nodePort is provided

Added (lines 730-733) and tested locally with success. We'll see if the remote CI checks pass as well

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

all good.

one thing though.

looking here, it looks like name is not a valid attr for nodeport. probably best to remov that.

docs = render_chart(
values={
"webserver": {
"service": {
"type": "NodePort",
"ports": ports,
}
},
},
show_only=["templates/webserver/webserver-service.yaml"],
)

assert "NodePort" == jmespath.search("spec.type", docs[0])
assert expected_ports == jmespath.search("spec.ports", docs[0])


class TestWebserverConfigmap:
def test_no_webserver_config_configmap_by_default(self):
Expand Down