diff --git a/charmcraft/models/config.py b/charmcraft/models/config.py index 550d2fd17..464f1618b 100644 --- a/charmcraft/models/config.py +++ b/charmcraft/models/config.py @@ -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 diff --git a/tests/test_models.py b/tests/test_models.py index 90ee8446d..2eda78678 100644 --- a/tests/test_models.py +++ b/tests/test_models.py @@ -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 """ ) ) @@ -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"}, }, } @@ -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 """ ), ) @@ -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"}, }, } @@ -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 """ ) )