-
Notifications
You must be signed in to change notification settings - Fork 1
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 'config print'. #727
Merged
Merged
Add 'config print'. #727
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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 | ||||
---|---|---|---|---|---|---|
|
@@ -23,12 +23,15 @@ import fs | |||||
import .utils | ||||||
|
||||||
APP_NAME ::= "artemis" | ||||||
|
||||||
// When adding a new config don't forget to update the 'config show' command. | ||||||
CONFIG_DEVICE_DEFAULT_KEY ::= "device.default" | ||||||
CONFIG_BROKER_DEFAULT_KEY ::= "server.broker.default" | ||||||
CONFIG_ARTEMIS_DEFAULT_KEY ::= "server.artemis.default" | ||||||
CONFIG_SERVERS_KEY ::= "servers" | ||||||
CONFIG_SERVER_AUTHS_KEY ::= "auths" | ||||||
CONFIG_ORGANIZATION_DEFAULT_KEY ::= "organization.default" | ||||||
// When adding a new config don't forget to update the 'config show' command. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. going with 'show'. |
||||||
|
||||||
class ConfigLocalStorage implements supabase.LocalStorage: | ||||||
config_/Config | ||||||
|
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,69 @@ | ||
// Copyright (C) 2022 Toitware ApS. | ||
|
||
import artemis.shared.server_config show ServerConfigHttp | ||
import expect show * | ||
import .utils | ||
|
||
main args: | ||
with_fleet --args=args --count=1: | test_cli/TestCli fake_devices/List fleet_dir/string | | ||
run_test test_cli fake_devices fleet_dir | ||
|
||
run_test test_cli/TestCli fake_devices/List fleet_dir/string: | ||
json_config := test_cli.run --json [ | ||
"config", "show" | ||
] | ||
expect_equals "$test_cli.tmp_dir/config" json_config["path"] | ||
expect_equals "test-broker" json_config["default-broker"] | ||
servers := json_config["servers"] | ||
expect (servers.contains "test-broker") | ||
expect (servers.contains "test-artemis-server") | ||
|
||
broker_config := servers["test-broker"] | ||
artemis_config := servers["test-artemis-server"] | ||
expect_equals "toit-http" broker_config["type"] | ||
expect_equals "toit-http" artemis_config["type"] | ||
|
||
artemis_server_config := test_cli.artemis.server_config as ServerConfigHttp | ||
broker_server_config := test_cli.broker.server_config as ServerConfigHttp | ||
|
||
expect_equals artemis_server_config.host broker_server_config.host | ||
test_cli.replacements[artemis_server_config.host] = "<HOST>" | ||
expect_equals broker_server_config.host broker_config["host"] | ||
expect_equals artemis_server_config.host artemis_config["host"] | ||
expect_equals broker_server_config.port broker_config["port"] | ||
test_cli.replacements["$broker_server_config.port"] = "<B-PORT>" | ||
expect_equals artemis_server_config.port artemis_config["port"] | ||
test_cli.replacements["$artemis_server_config.port"] = "<A-PORT>" | ||
|
||
test_cli.replacements["$artemis_config["auth"]"] = "<ARTEMIS_AUTH>" | ||
|
||
test_cli.run_gold "BAA-config-show" | ||
"Print the test config" | ||
[ | ||
"config", "show" | ||
] | ||
|
||
fake_device := fake_devices[0] as FakeDevice | ||
|
||
test_cli.run [ | ||
"--fleet-root", fleet_dir, | ||
"device", "default", "$fake_device.alias_id", | ||
] | ||
|
||
test_cli.run [ | ||
"--fleet-root", fleet_dir, | ||
"org", "default", "$fake_device.organization_id", | ||
] | ||
|
||
json_config = test_cli.run --json [ | ||
"--fleet-root", fleet_dir, | ||
"config", "show" | ||
] | ||
expect_equals "$fake_device.alias_id" json_config["default-device"] | ||
expect_equals "$fake_device.organization_id" json_config["default-org"] | ||
|
||
test_cli.run_gold "BBA-config-show-default-values-set" | ||
"Print the test config with default values set" | ||
[ | ||
"config", "show" | ||
] |
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,26 @@ | ||
# Print the test config | ||
# [config, show] | ||
Configuration file: TMP_DIR/config | ||
Default broker: test-broker | ||
Servers: | ||
test-artemis-server: | ||
type: toit-http | ||
host: <HOST> | ||
path: / | ||
poll_interval: 500000 | ||
port: <A-PORT> | ||
device_headers: | ||
X-Artemis-Header: true | ||
admin_headers: | ||
X-Artemis-Header: true | ||
auth: <ARTEMIS_AUTH> | ||
test-broker: | ||
type: toit-http | ||
host: <HOST> | ||
path: / | ||
poll_interval: 500000 | ||
port: <B-PORT> | ||
device_headers: | ||
X-Artemis-Header: true | ||
admin_headers: | ||
X-Artemis-Header: true |
28 changes: 28 additions & 0 deletions
28
tests/gold/cmd_config_test/BBA-config-show-default-values-set.txt
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,28 @@ | ||
# Print the test config with default values set | ||
# [config, show] | ||
Configuration file: TMP_DIR/config | ||
Default device: -={| UUID-FOR-FAKE-DEVICE 00000 |}=- | ||
Default broker: test-broker | ||
Default organization: 4b6d9e35-cae9-44c0-8da0-6b0e485987e2 | ||
Servers: | ||
test-artemis-server: | ||
type: toit-http | ||
host: <HOST> | ||
path: / | ||
poll_interval: 500000 | ||
port: <A-PORT> | ||
device_headers: | ||
X-Artemis-Header: true | ||
admin_headers: | ||
X-Artemis-Header: true | ||
auth: <ARTEMIS_AUTH> | ||
test-broker: | ||
type: toit-http | ||
host: <HOST> | ||
path: / | ||
poll_interval: 500000 | ||
port: <B-PORT> | ||
device_headers: | ||
X-Artemis-Header: true | ||
admin_headers: | ||
X-Artemis-Header: true |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
going with 'show'.