Add additional options under "repositories:" for parity with repo-create #303.

This commit is contained in:
Dan Helfman
2025-03-18 20:54:14 -07:00
parent 711f5fa6cb
commit 63b0c69794
5 changed files with 41 additions and 9 deletions
+3 -3
View File
@@ -41,9 +41,9 @@ def run_repo_create(
encryption_mode,
repo_create_arguments.source_repository,
repo_create_arguments.copy_crypt_key,
repo_create_arguments.append_only,
repo_create_arguments.storage_quota,
repo_create_arguments.make_parent_dirs,
repo_create_arguments.append_only or repository.get('append_only'),
repo_create_arguments.storage_quota or repository.get('storage_quota'),
repo_create_arguments.make_parent_dirs or repository.get('make_parent_dirs'),
local_path=local_path,
remote_path=remote_path,
)
+3
View File
@@ -303,6 +303,8 @@ DEFAULT_FALSE_FLAG_NAMES = {
'check_i_know_what_i_am_doing',
'postgresql_databases[0].no_owner',
'healthchecks.create_slug',
'repositories[0].append_only',
'repositories[0].make_parent_dirs',
}
@@ -401,6 +403,7 @@ def add_arguments_from_schema(arguments_group, schema, unparsed_arguments, names
arguments_group.add_argument(
full_flag_name,
action='store_true',
default=None,
help=description,
)
else:
+7 -2
View File
@@ -93,11 +93,16 @@ def convert_value_type(value, option_type):
Given a string value and its schema type as a string, determine its logical type (string,
boolean, integer, etc.), and return it converted to that type.
If the option type is a string, leave the value as a string so that special characters in it
don't get interpreted as YAML during conversion.
If the destination option type is a string, then leave the value as-is so that special
characters in it don't get interpreted as YAML during conversion.
And if the source value isn't a string, return it as-is.
Raise ruamel.yaml.error.YAMLError if there's a parse issue with the YAML.
'''
if not isinstance(value, str):
return value
if option_type == 'string':
return value
+8 -4
View File
@@ -22,6 +22,9 @@ def insert_newline_before_comment(config, field_name):
)
SCALAR_SCHEMA_TYPES = {'string', 'boolean', 'integer', 'number'}
def schema_to_sample_configuration(schema, source_config=None, level=0, parent_is_sequence=False):
'''
Given a loaded configuration schema and a source configuration, generate and return sample
@@ -33,9 +36,6 @@ def schema_to_sample_configuration(schema, source_config=None, level=0, parent_i
schema_type = schema.get('type')
example = schema.get('example')
if example is not None:
return example
if schema_type == 'array' or (isinstance(schema_type, list) and 'array' in schema_type):
config = ruamel.yaml.comments.CommentedSeq(
[
@@ -53,7 +53,7 @@ def schema_to_sample_configuration(schema, source_config=None, level=0, parent_i
[
(
field_name,
schema_to_sample_configuration(
sub_schema.get('example') if field_name == 'source_directories' else schema_to_sample_configuration(
sub_schema, (source_config or {}).get(field_name, {}), level + 1
),
)
@@ -64,6 +64,10 @@ def schema_to_sample_configuration(schema, source_config=None, level=0, parent_i
add_comments_to_configuration_object(
config, schema, source_config, indent=indent, skip_first=parent_is_sequence
)
elif isinstance(schema_type, list) and all(element_schema_type in SCALAR_SCHEMA_TYPES for element_schema_type in schema_type):
return example
elif schema_type in SCALAR_SCHEMA_TYPES:
return example
else:
raise ValueError(f'Schema at level {level} is unsupported: {schema}')
+20
View File
@@ -53,6 +53,26 @@ properties:
available encryption modes, run "borg init --help" with
Borg 1 or "borg repo-create --help" with Borg 2.
example: repokey-blake2
append_only:
type: boolean
description: |
Whether the repository should be created append-only,
only used for the repo-create action. Defaults to false.
example: false
storage_quota:
type: string
description: |
The storage quota with which to create the repository,
only used for the repo-create action. Defaults to no
quota.
example: 5G
make_parent_dirs:
type: boolean
description: |
Whether any missing parent directories of the repository
path should be created, only used for the repo-create
action. Defaults to false.
example: true
description: |
A required list of local or remote repositories with paths and
optional labels (which can be used with the --repository flag to