-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
v2-lib: auto add labels from a top level structure (#746)
* auto add labels from a top level structure * improve message
- Loading branch information
Showing
50 changed files
with
114 additions
and
46 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
import pytest | ||
|
||
from render import Render | ||
|
||
|
||
@pytest.fixture | ||
def mock_values(): | ||
return { | ||
"images": { | ||
"test_image": { | ||
"repository": "nginx", | ||
"tag": "latest", | ||
} | ||
}, | ||
} | ||
|
||
|
||
def test_add_disallowed_label(mock_values): | ||
render = Render(mock_values) | ||
c1 = render.add_container("test_container", "test_image") | ||
c1.healthcheck.disable() | ||
with pytest.raises(Exception): | ||
c1.labels.add_label("com.docker.compose.service", "test_service") | ||
|
||
|
||
def test_add_duplicate_label(mock_values): | ||
render = Render(mock_values) | ||
c1 = render.add_container("test_container", "test_image") | ||
c1.healthcheck.disable() | ||
c1.labels.add_label("my.custom.label", "test_value") | ||
with pytest.raises(Exception): | ||
c1.labels.add_label("my.custom.label", "test_value1") | ||
|
||
|
||
def test_add_label_on_non_existing_container(mock_values): | ||
mock_values["labels"] = [ | ||
{ | ||
"key": "my.custom.label1", | ||
"value": "test_value1", | ||
"containers": ["test_container", "test_container2"], | ||
}, | ||
] | ||
render = Render(mock_values) | ||
c1 = render.add_container("test_container", "test_image") | ||
c1.healthcheck.disable() | ||
with pytest.raises(Exception): | ||
render.render() | ||
|
||
|
||
def test_add_label(mock_values): | ||
render = Render(mock_values) | ||
c1 = render.add_container("test_container", "test_image") | ||
c1.healthcheck.disable() | ||
c1.labels.add_label("my.custom.label1", "test_value1") | ||
c1.labels.add_label("my.custom.label2", "test_value2") | ||
output = render.render() | ||
assert output["services"]["test_container"]["labels"] == { | ||
"my.custom.label1": "test_value1", | ||
"my.custom.label2": "test_value2", | ||
} | ||
|
||
|
||
def test_auto_add_labels(mock_values): | ||
mock_values["labels"] = [ | ||
{ | ||
"key": "my.custom.label1", | ||
"value": "test_value1", | ||
"containers": ["test_container", "test_container2"], | ||
}, | ||
{ | ||
"key": "my.custom.label2", | ||
"value": "test_value2", | ||
"containers": ["test_container"], | ||
}, | ||
] | ||
render = Render(mock_values) | ||
c1 = render.add_container("test_container", "test_image") | ||
c2 = render.add_container("test_container2", "test_image") | ||
c1.healthcheck.disable() | ||
c2.healthcheck.disable() | ||
output = render.render() | ||
assert output["services"]["test_container"]["labels"] == { | ||
"my.custom.label1": "test_value1", | ||
"my.custom.label2": "test_value2", | ||
} | ||
assert output["services"]["test_container2"]["labels"] == { | ||
"my.custom.label1": "test_value1", | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
0.0.1: f074617a82a86d2a6cc78a4c8a4296fc9d168e456f12713e50c696557b302133 | ||
1.1.4: 6e32ff5969906d9c3a10fea2b17fdd3197afb052d3432344da03188d8a907113 | ||
2.0.3: 8ebbf2ffeaccfe0c0f608d93eb536667570974c415a4a75b0f0e8400f42fe427 | ||
2.0.4: 0e79e3390d3ea73649ee2ac05a4af9ed944a02e95289b5c7e2eb047d475a4651 |