Skip to content

Commit

Permalink
[Scaleway] Remove unused sensitive values filtering
Browse files Browse the repository at this point in the history
Signed-off-by: Lunik <lunik@tiwabbit.fr>
  • Loading branch information
Lunik committed Nov 7, 2022
1 parent f4bad50 commit 1bbe2d0
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 30 deletions.
7 changes: 0 additions & 7 deletions plugins/module_utils/scaleway.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,6 @@ def parse_pagination_link(header):
return parsed_relations


def filter_sensitive_attributes(container, attributes):
for attr in attributes:
container[attr] = "SENSITIVE_VALUE"

return container


class SecretVariables(object):
@staticmethod
def ensure_scaleway_secret_package(module):
Expand Down
13 changes: 5 additions & 8 deletions plugins/modules/scaleway_container_namespace_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,20 +73,17 @@
region: fr-par
registry_endpoint: ""
registry_namespace_id: ""
secret_environment_variables: SENSITIVE_VALUE
secret_environment_variables:
- key: MY_SECRET_VAR
value: $argon2id$v=19$m=65536,t=1,p=2$tb6UwSPWx/rH5Vyxt9Ujfw$5ZlvaIjWwNDPxD9Rdght3NarJz4IETKjpvAU3mMSmFg
status: pending
'''

from ansible_collections.community.general.plugins.module_utils.scaleway import (
SCALEWAY_ENDPOINT, SCALEWAY_REGIONS, scaleway_argument_spec, Scaleway,
filter_sensitive_attributes
SCALEWAY_ENDPOINT, SCALEWAY_REGIONS, scaleway_argument_spec, Scaleway
)
from ansible.module_utils.basic import AnsibleModule

SENSITIVE_ATTRIBUTES = (
"secret_environment_variables",
)


def info_strategy(api, wished_cn):
cn_list = api.fetch_all_resources("namespaces")
Expand Down Expand Up @@ -123,7 +120,7 @@ def core(module):

summary = info_strategy(api=api, wished_cn=wished_container_namespace)

module.exit_json(changed=False, container_namespace=filter_sensitive_attributes(summary, SENSITIVE_ATTRIBUTES))
module.exit_json(changed=False, container_namespace=summary)


def main():
Expand Down
9 changes: 2 additions & 7 deletions plugins/modules/scaleway_container_registry_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,10 @@
'''

from ansible_collections.community.general.plugins.module_utils.scaleway import (
SCALEWAY_ENDPOINT, SCALEWAY_REGIONS, scaleway_argument_spec, Scaleway,
filter_sensitive_attributes
SCALEWAY_ENDPOINT, SCALEWAY_REGIONS, scaleway_argument_spec, Scaleway
)
from ansible.module_utils.basic import AnsibleModule

SENSITIVE_ATTRIBUTES = (
"secret_environment_variables",
)


def info_strategy(api, wished_cn):
cn_list = api.fetch_all_resources("namespaces")
Expand Down Expand Up @@ -124,7 +119,7 @@ def core(module):

summary = info_strategy(api=api, wished_cn=wished_container_namespace)

module.exit_json(changed=False, container_registry=filter_sensitive_attributes(summary, SENSITIVE_ATTRIBUTES))
module.exit_json(changed=False, container_registry=summary)


def main():
Expand Down
13 changes: 5 additions & 8 deletions plugins/modules/scaleway_function_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,21 +80,18 @@
region: fr-par
runtime: python310
runtime_message: ""
secret_environment_variables: SENSITIVE_VALUE
secret_environment_variables:
- key: MY_SECRET_VAR
value: $argon2id$v=19$m=65536,t=1,p=2$tb6UwSPWx/rH5Vyxt9Ujfw$5ZlvaIjWwNDPxD9Rdght3NarJz4IETKjpvAU3mMSmFg
status: created
timeout: 300s
'''

from ansible_collections.community.general.plugins.module_utils.scaleway import (
SCALEWAY_ENDPOINT, SCALEWAY_REGIONS, scaleway_argument_spec, Scaleway,
filter_sensitive_attributes
SCALEWAY_ENDPOINT, SCALEWAY_REGIONS, scaleway_argument_spec, Scaleway
)
from ansible.module_utils.basic import AnsibleModule

SENSITIVE_ATTRIBUTES = (
"secret_environment_variables",
)


def info_strategy(api, wished_fn):
fn_list = api.fetch_all_resources("functions")
Expand Down Expand Up @@ -131,7 +128,7 @@ def core(module):

summary = info_strategy(api=api, wished_fn=wished_function)

module.exit_json(changed=False, function=filter_sensitive_attributes(summary, SENSITIVE_ATTRIBUTES))
module.exit_json(changed=False, function=summary)


def main():
Expand Down

0 comments on commit 1bbe2d0

Please sign in to comment.