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

feat(config): support type:secret in config.options #1623

Merged
merged 2 commits into from
Apr 11, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 2 additions & 2 deletions charmcraft/models/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@ def validate_actions(cls, options):
if "type" not in option:
raise ValueError(f"'{name}' is missing a type")

if option["type"] not in ["string", "int", "float", "boolean"]:
if option["type"] not in ["string", "int", "float", "boolean", "secret"]:
raise ValueError(
f"'{option}' has an invalid type '{option['type']}', "
"must be one of: string, int, float, boolean"
"must be one of: string, int, float, boolean, secret"
)

return options
8 changes: 8 additions & 0 deletions tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1135,6 +1135,8 @@ def test_load_config_in_charmcraft_yaml(tmp_path, prepare_charmcraft_yaml):
test-bool:
default: true
type: boolean
test-secret:
type: secret
"""
)
)
Expand All @@ -1146,6 +1148,7 @@ def test_load_config_in_charmcraft_yaml(tmp_path, prepare_charmcraft_yaml):
"test-string": {"description": "test-2", "type": "string"},
"test-float": {"default": 1.23, "type": "float"},
"test-bool": {"default": True, "type": "boolean"},
"test-secret": {"type": "secret"},
},
}

Expand Down Expand Up @@ -1179,6 +1182,8 @@ def test_load_config_in_config_yaml(tmp_path, prepare_charmcraft_yaml, prepare_c
test-bool:
default: true
type: boolean
test-secret:
type: secret
"""
),
)
Expand All @@ -1190,6 +1195,7 @@ def test_load_config_in_config_yaml(tmp_path, prepare_charmcraft_yaml, prepare_c
"test-string": {"description": "test-2", "type": "string"},
"test-float": {"default": 1.23, "type": "float"},
"test-bool": {"default": True, "type": "boolean"},
"test-secret": {"type": "secret"},
},
}

Expand Down Expand Up @@ -1248,6 +1254,8 @@ def test_load_bad_config_in_charmcraft_yaml(tmp_path, prepare_charmcraft_yaml):
test-bool:
default: true
type: boolean
test-secret:
type: secret
"""
)
)
Expand Down
Loading