[PR #11314/b3c066b9 backport][stable-12] Adding scw_profile parameter to Scaleway module utilities. (#11337)

Adding scw_profile parameter to Scaleway module utilities. (#11314)

* Adding scw_profile parameter to Scaleway module utilities.

* Setting param name to profile for consistency and adding scw_profile as an alias.

* Adding changelog fragment.

* Forgot to import 'os' library.

* Type in variable type for Scaleway profile.

* Also forgot to include the yaml library, code taking from plugins/inventory/scaleway.py.

* Adding default 'profile' value of empty string and changing check to a length check.

* Treated wrong variable, checking XDG_CONFIG_HOME is a string.

* Explicitly setting default of environment path vars to empty strings instead of None.

* Letting ruff reformat the dict for 'profile'.

* Changes from code review.

* Fixing ruff formatting issue with error message.

* Properly catching PyYAML import issues.

* Adding PyYAML requirement when 'profile' is used.

* Ruff wants an extra line after the PyYAML import code.

* Fixing PyYAML dependency code as per review.

* Removing extraneous var declaration.

* Moving SCW_CONFIG loading to a function.

* Fixing type errors with os.getenv calls.

* Cannot send None to os.path.exists() or open().

* Oops, inversed logic!

* Setting os.getenv() default to empty string so it is never None.



* None check no longer needed as scw_config_path is never None.



---------


(cherry picked from commit b3c066b99f)

Co-authored-by: Greg Harvey <greg.harvey@gmail.com>
Co-authored-by: Felix Fontein <felix@fontein.de>
This commit is contained in:
patchback[bot]
2025-12-28 21:24:54 +01:00
committed by GitHub
parent 51d8c4b5fd
commit 39a49e4d98
3 changed files with 57 additions and 3 deletions

View File

@@ -12,8 +12,8 @@ options:
api_token:
description:
- Scaleway OAuth token.
- This is required if O(profile) is not specified.
type: str
required: true
aliases: [oauth_token]
api_url:
description:
@@ -27,6 +27,13 @@ options:
type: int
default: 30
aliases: [timeout]
profile:
description:
- The config profile in config file to load the Scaleway OAuth token from, use instead of O(api_token).
- It is also possible to set E(SCW_PROFILE) to use a SCW CLI config profile.
type: str
aliases: [scw_profile]
version_added: 12.2.0
query_parameters:
description:
- List of parameters passed to the query string.
@@ -37,6 +44,8 @@ options:
- Validate SSL certs of the Scaleway API.
type: bool
default: true
requirements:
- PyYAML (when O(profile) is used)
notes:
- Also see the API documentation on U(https://developer.scaleway.com/).
- If O(api_token) is not set within the module, the following environment variables can be used in decreasing order of precedence