-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #83 from ClarkSource/cli_tests
- Loading branch information
Showing
47 changed files
with
612 additions
and
0 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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,34 @@ | ||
# ISC License | ||
# | ||
# Copyright 2019 FL Fintech E GmbH | ||
# | ||
# Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. | ||
# | ||
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
|
||
import os | ||
|
||
from click.testing import CliRunner | ||
|
||
from k8t.cli import root | ||
|
||
|
||
def test_single_cluster(): | ||
runner = CliRunner() | ||
|
||
result = runner.invoke(root, ['get', 'clusters', 'examples/single-cluster']) | ||
|
||
assert result.exit_code == 0 | ||
assert result.output == '' | ||
|
||
result = runner.invoke(root, ['get', 'environments', 'examples/single-cluster']) | ||
|
||
assert result.exit_code == 0 | ||
assert 'production' in result.output | ||
|
||
result = runner.invoke(root, ['validate', 'examples/single-cluster']) | ||
|
||
assert result.exit_code == 0 | ||
assert 'hello-world-deployment.yaml.j2: ✔' in result.output | ||
assert 'hello-world-secret.yaml.j2: ✔' in result.output | ||
assert 'hello-world-service.yaml.j2: ✔' in result.output |
Empty file.
Empty file.
11 changes: 11 additions & 0 deletions
11
tests/resources/bad/templates/composite-invalid-yaml-template.yaml.j2
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,11 @@ | ||
foo: 1 | ||
bar: 2 | ||
buz: 3 | ||
--- | ||
foo: 1 | ||
bar: { | ||
buz: 3 | ||
--- | ||
foo: { | ||
bar: 2 | ||
buz: 3 |
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,10 @@ | ||
--- | ||
one: 1 | ||
two: 2 | ||
three: {{ 2 + 1 }} | ||
four: {{ four }} | ||
--- | ||
one: 1 | ||
two: 2 | ||
three: {{ 2 + 1 }} | ||
four: {{ four }} |
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,4 @@ | ||
one: 1 | ||
{# two: {{ 2 | not_existing_filter }} #} | ||
three: {{ three | default(3) }} | ||
four: {{ test.four | default(4) }} |
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,3 @@ | ||
foo: 1 | ||
bar: { | ||
buz: 3 |
4 changes: 4 additions & 0 deletions
4
tests/resources/bad/templates/nested-value-adding-template.yaml.j2
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,4 @@ | ||
one: 1 | ||
two: {{ test.one + 1 }} | ||
three: 3 | ||
four: {{2 + 2}} |
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,4 @@ | ||
one: 1 | ||
two: {{ test.two }} | ||
three: 3 | ||
four: {{2 + 2}} |
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,4 @@ | ||
one: "{{ get_secret('/one', 24) | b64encode }}" | ||
two: 2 | ||
three: {{ 2 + 1 }} | ||
four: {{ four }} |
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,4 @@ | ||
one: {{ one }} | ||
two: {{ two }} | ||
three: {{three }} | ||
four: {{ four }} |
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,4 @@ | ||
one: 1 | ||
two: 2 | ||
three: {{ 2 + 1 }} | ||
four: {{ four }} |
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,2 @@ | ||
test: | ||
foo: bar |
Empty file.
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,4 @@ | ||
secrets: | ||
provider: ssm | ||
region: 'eu-central-1' | ||
prefix: '/cluster-1' |
Empty file.
5 changes: 5 additions & 0 deletions
5
...ters/cluster-1/environments/cluster-specific-env/templates/cluster-1-env-template.yaml.j2
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,5 @@ | ||
env: "{{env}}" | ||
cluster: "{{cls}}" | ||
foo: "{{foo}}" | ||
bar: "{{bar}}" | ||
buz: "{{buz | default('buz_default')}}" |
1 change: 1 addition & 0 deletions
1
tests/resources/good/clusters/cluster-1/environments/cluster-specific-env/values.yaml
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 @@ | ||
env: cluster-1-env |
Empty file.
6 changes: 6 additions & 0 deletions
6
...rces/good/clusters/cluster-1/environments/common-env/templates/cluster-1-template.yaml.j2
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,6 @@ | ||
env: "{{env}}" | ||
cluster: "{{cls}}" | ||
foo: "{{foo}}" | ||
bar: "{{bar}}" | ||
buz: "{{buz | default('buz_default')}}" | ||
overwritten-in-env: true |
1 change: 1 addition & 0 deletions
1
tests/resources/good/clusters/cluster-1/environments/common-env/values.yaml
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 @@ | ||
env: cluster-1-common-env |
6 changes: 6 additions & 0 deletions
6
tests/resources/good/clusters/cluster-1/templates/cluster-1-template.yaml.j2
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,6 @@ | ||
env: "{{env}}" | ||
cluster: "{{cls}}" | ||
foo: "{{foo}}" | ||
bar: "{{bar}}" | ||
buz: "{{buz | default('buz_default')}}" | ||
secret: "{{get_secret('/test', 12) | b64encode}}" |
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 @@ | ||
cls: cluster-1 |
Empty file.
8 changes: 8 additions & 0 deletions
8
tests/resources/good/clusters/cluster-2/templates/composite-template.yaml.j2
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,8 @@ | ||
--- | ||
template: 1 | ||
env: "{{env}}" | ||
cluster: "{{cls}}" | ||
--- | ||
template: 2 | ||
env: "{{env}}" | ||
cluster: "{{cls}}" |
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,2 @@ | ||
cls: cluster-2 | ||
buz: 'buz' |
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,2 @@ | ||
secrets: | ||
provider: random |
Empty file.
5 changes: 5 additions & 0 deletions
5
tests/resources/good/environments/common-env/templates/common-env-template.yaml.j2
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,5 @@ | ||
env: "{{env}}" | ||
cluster: "{{cls}}" | ||
foo: "{{foo}}" | ||
bar: "{{bar}}" | ||
buz: "{{buz | default('buz_default')}}" |
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 @@ | ||
env: common-env |
Empty file.
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 @@ | ||
env: some-env |
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,5 @@ | ||
env: "{{env}}" | ||
cluster: "{{cls}}" | ||
foo: "{{foo}}" | ||
bar: "{{bar}}" | ||
buz: "{{buz | default('buz_default')}}" |
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,4 @@ | ||
cls: none | ||
env: none | ||
foo: 1 | ||
bar: test |
Empty file.
Empty file.
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,2 @@ | ||
test: "{{test}}" | ||
buz: "{{buz | default('buz_default')}}" |
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 @@ | ||
test: something |
Empty file.
22 changes: 22 additions & 0 deletions
22
tests/resources/results/cluster-1-cluster-specific-env.yaml
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,22 @@ | ||
--- | ||
# Source: cluster-1-env-template.yaml.j2 | ||
env: "cluster-1-env" | ||
cluster: "cluster-1" | ||
foo: "1" | ||
bar: "test" | ||
buz: "buz_default" | ||
--- | ||
# Source: cluster-1-template.yaml.j2 | ||
env: "cluster-1-env" | ||
cluster: "cluster-1" | ||
foo: "1" | ||
bar: "test" | ||
buz: "buz_default" | ||
secret: "c3RyaW5nX3ZhbHVl" | ||
--- | ||
# Source: common-template.yaml.j2 | ||
env: "cluster-1-env" | ||
cluster: "cluster-1" | ||
foo: "1" | ||
bar: "test" | ||
buz: "buz_default" |
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,22 @@ | ||
--- | ||
# Source: cluster-1-template.yaml.j2 | ||
env: "cluster-1-common-env" | ||
cluster: "cluster-1" | ||
foo: "1" | ||
bar: "test" | ||
buz: "buz_default" | ||
overwritten-in-env: true | ||
--- | ||
# Source: common-env-template.yaml.j2 | ||
env: "cluster-1-common-env" | ||
cluster: "cluster-1" | ||
foo: "1" | ||
bar: "test" | ||
buz: "buz_default" | ||
--- | ||
# Source: common-template.yaml.j2 | ||
env: "cluster-1-common-env" | ||
cluster: "cluster-1" | ||
foo: "1" | ||
bar: "test" | ||
buz: "buz_default" |
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,15 @@ | ||
--- | ||
# Source: cluster-1-template.yaml.j2 | ||
env: "none" | ||
cluster: "cluster-1" | ||
foo: "1" | ||
bar: "test" | ||
buz: "buz_default" | ||
secret: "c3RyaW5nX3ZhbHVl" | ||
--- | ||
# Source: common-template.yaml.j2 | ||
env: "none" | ||
cluster: "cluster-1" | ||
foo: "1" | ||
bar: "test" | ||
buz: "buz_default" |
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,17 @@ | ||
--- | ||
# Source: common-template.yaml.j2 | ||
env: "none" | ||
cluster: "cluster-2" | ||
foo: "1" | ||
bar: "test" | ||
buz: "buz" | ||
--- | ||
# Source: composite-template.yaml.j2 | ||
--- | ||
template: 1 | ||
env: "none" | ||
cluster: "cluster-2" | ||
--- | ||
template: 2 | ||
env: "none" | ||
cluster: "cluster-2" |
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,14 @@ | ||
--- | ||
# Source: common-env-template.yaml.j2 | ||
env: "common-env" | ||
cluster: "none" | ||
foo: "1" | ||
bar: "test" | ||
buz: "buz_default" | ||
--- | ||
# Source: common-template.yaml.j2 | ||
env: "common-env" | ||
cluster: "none" | ||
foo: "1" | ||
bar: "test" | ||
buz: "buz_default" |
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,7 @@ | ||
--- | ||
# Source: common-template.yaml.j2 | ||
env: "none" | ||
cluster: "none" | ||
foo: "1" | ||
bar: "test" | ||
buz: "buz_default" |
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,7 @@ | ||
--- | ||
# Source: common-template.yaml.j2 | ||
env: "some-env" | ||
cluster: "none" | ||
foo: "1" | ||
bar: "test" | ||
buz: "buz_default" |