mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-04-15 16:31:30 +00:00
modules s[a-e]*: use f-strings (#10976)
* modules s[a-e]*: use f-strings * add changelog frag
This commit is contained in:
parent
32dd5f04c5
commit
73452acf84
28 changed files with 243 additions and 280 deletions
|
|
@ -178,10 +178,9 @@ def absent_strategy(api, wished_cn):
|
|||
return changed, {"status": "Container namespace would be destroyed"}
|
||||
|
||||
api.wait_to_complete_state_transition(resource=target_cn, stable_states=STABLE_STATES, force_wait=True)
|
||||
response = api.delete(path=api.api_path + "/%s" % target_cn["id"])
|
||||
response = api.delete(path=f"{api.api_path}/{target_cn['id']}")
|
||||
if not response.ok:
|
||||
api.module.fail_json(msg='Error deleting container namespace [{0}: {1}]'.format(
|
||||
response.status_code, response.json))
|
||||
api.module.fail_json(msg=f'Error deleting container namespace [{response.status_code}: {response.json}]')
|
||||
|
||||
api.wait_to_complete_state_transition(resource=target_cn, stable_states=STABLE_STATES)
|
||||
return changed, response.json
|
||||
|
|
@ -206,13 +205,12 @@ def present_strategy(api, wished_cn):
|
|||
data=payload_cn)
|
||||
|
||||
if not creation_response.ok:
|
||||
msg = "Error during container namespace creation: %s: '%s' (%s)" % (creation_response.info['msg'],
|
||||
creation_response.json['message'],
|
||||
creation_response.json)
|
||||
msg = (f"Error during container namespace creation: {creation_response.info['msg']}: "
|
||||
f"'{creation_response.json['message']}' ({creation_response.json})")
|
||||
api.module.fail_json(msg=msg)
|
||||
|
||||
api.wait_to_complete_state_transition(resource=creation_response.json, stable_states=STABLE_STATES)
|
||||
response = api.get(path=api.api_path + "/%s" % creation_response.json["id"])
|
||||
response = api.get(path=f"{api.api_path}/{creation_response.json['id']}")
|
||||
return changed, response.json
|
||||
|
||||
target_cn = cn_lookup[wished_cn["name"]]
|
||||
|
|
@ -231,15 +229,14 @@ def present_strategy(api, wished_cn):
|
|||
if api.module.check_mode:
|
||||
return changed, {"status": "Container namespace attributes would be changed."}
|
||||
|
||||
cn_patch_response = api.patch(path=api.api_path + "/%s" % target_cn["id"],
|
||||
cn_patch_response = api.patch(path=f"{api.api_path}/{target_cn['id']}",
|
||||
data=patch_payload)
|
||||
|
||||
if not cn_patch_response.ok:
|
||||
api.module.fail_json(msg='Error during container namespace attributes update: [{0}: {1}]'.format(
|
||||
cn_patch_response.status_code, cn_patch_response.json['message']))
|
||||
api.module.fail_json(msg=f"Error during container namespace attributes update: [{cn_patch_response.status_code}: {cn_patch_response.json['message']}]")
|
||||
|
||||
api.wait_to_complete_state_transition(resource=target_cn, stable_states=STABLE_STATES)
|
||||
response = api.get(path=api.api_path + "/%s" % target_cn["id"])
|
||||
response = api.get(path=f"{api.api_path}/{target_cn['id']}")
|
||||
return changed, cn_patch_response.json
|
||||
|
||||
|
||||
|
|
@ -263,7 +260,7 @@ def core(module):
|
|||
}
|
||||
|
||||
api = Scaleway(module=module)
|
||||
api.api_path = "containers/v1beta1/regions/%s/namespaces" % region
|
||||
api.api_path = f"containers/v1beta1/regions/{region}/namespaces"
|
||||
|
||||
changed, summary = state_strategy[wished_container_namespace["state"]](api=api, wished_cn=wished_container_namespace)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue