[collection] remove module defaults where API defaults are the same (#13037)

Providing defaults for API parameters where the API already provides
defaults leads to some confusing scenarios, because we end up always
sending those collection-defaulted fields in the request even if the
field isn't provided by the user.

For example, we previously set the `scm_type` default to 'manual' and
someone using the collection to update a project who does not explicitly
include the `scm_type` every time they call the module, would
inadvertently change the `scm_type` of the project back to 'manual'
which is surprising behavior.

This change removes the collection defaults for API parameters, unless
they differed from the API default. We let the API handle the defaults
or otherwise ignore fields not given by the user so that the user does
not end up changing unexpected fields when they use a module.

Signed-off-by: Rick Elrod <rick@elrod.me>
This commit is contained in:
Rick Elrod
2023-02-01 15:37:08 -06:00
committed by GitHub
parent 93d84fe2c9
commit 0815f935ca
17 changed files with 53 additions and 74 deletions

View File

@@ -41,31 +41,26 @@ options:
- Signifies that this InstanceGroup should act as a ContainerGroup. If no credential is specified, the underlying Pod's ServiceAccount will be used.
required: False
type: bool
default: False
policy_instance_percentage:
description:
- Minimum percentage of all instances that will be automatically assigned to this group when new instances come online.
required: False
type: int
default: '0'
policy_instance_minimum:
description:
- Static minimum number of Instances that will be automatically assign to this group when new instances come online.
required: False
type: int
default: '0'
max_concurrent_jobs:
description:
- Maximum number of concurrent jobs to run on this group. Zero means no limit.
required: False
type: int
default: '0'
max_forks:
description:
- Max forks to execute on this group. Zero means no limit.
required: False
type: int
default: '0'
policy_instance_list:
description:
- List of exact-match Instances that will be assigned to this group
@@ -104,14 +99,14 @@ def main():
name=dict(required=True),
new_name=dict(),
credential=dict(),
is_container_group=dict(type='bool', default=False),
policy_instance_percentage=dict(type='int', default='0'),
policy_instance_minimum=dict(type='int', default='0'),
max_concurrent_jobs=dict(type='int', default='0'),
max_forks=dict(type='int', default='0'),
is_container_group=dict(type='bool'),
policy_instance_percentage=dict(type='int'),
policy_instance_minimum=dict(type='int'),
max_concurrent_jobs=dict(type='int'),
max_forks=dict(type='int'),
policy_instance_list=dict(type='list', elements='str'),
pod_spec_override=dict(),
instances=dict(required=False, type="list", elements='str', default=None),
instances=dict(required=False, type="list", elements='str'),
state=dict(choices=['present', 'absent'], default='present'),
)