From 629d9eaae1851a39df7bf9357f59b2c6eb13a3ab Mon Sep 17 00:00:00 2001 From: Zadkiel Aharonian Date: Tue, 7 Jun 2022 18:26:44 +0200 Subject: [PATCH 01/16] feat: split extras by features --- setup.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index b69a0eb..394166f 100644 --- a/setup.py +++ b/setup.py @@ -51,8 +51,10 @@ 'pyyaml==6.0' ], extras_require={ - 'extras': [ + 'aws': [ 'boto3==1.24.2', + ], + 'vault': [ 'hvac==0.11.2' ] }, From ef504075bbe3ce16a93c9b787f8afc6899101b61 Mon Sep 17 00:00:00 2001 From: Zadkiel Aharonian Date: Tue, 7 Jun 2022 18:28:22 +0200 Subject: [PATCH 02/16] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 2825651..c339762 100644 --- a/README.md +++ b/README.md @@ -44,7 +44,7 @@ Idea came from puppet's hiera. ```sh pip install himl # or, optionally install with extras dependencies: vault and aws interpolation support -pip install himl[extras] +pip install himl[vault,aws] ``` ### Using `docker` image @@ -59,7 +59,7 @@ See all docker tags at: https://github.com/adobe/himl/pkgs/container/himl/versio ``` git clone https://github.com/adobe/himl cd himl -sudo python install -e .[extras] +sudo python install -e .[vault,aws] ``` ## Examples From ea141d6ca77ba065094cfa1f4ada5be35488ae53 Mon Sep 17 00:00:00 2001 From: Zadkiel Aharonian Date: Tue, 7 Jun 2022 18:28:48 +0200 Subject: [PATCH 03/16] Update Dockerfile --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index dbf78cd..1e86c4e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,5 +6,5 @@ ADD . /config-merger/ RUN apt-get update && apt-get install -y make curl -RUN python -m pip install --upgrade pip && pip3 install .[extras] +RUN python -m pip install --upgrade pip && pip3 install .[vault,aws] RUN rm -rf /config-merger/* From b6fc8a112a19694040080b877ef620cf43f78275 Mon Sep 17 00:00:00 2001 From: Zadkiel Aharonian Date: Tue, 7 Jun 2022 18:32:26 +0200 Subject: [PATCH 04/16] Apply suggestions from code review --- Dockerfile | 2 +- README.md | 8 +++++--- setup.py | 6 +++++- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index 1e86c4e..dbf78cd 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,5 +6,5 @@ ADD . /config-merger/ RUN apt-get update && apt-get install -y make curl -RUN python -m pip install --upgrade pip && pip3 install .[vault,aws] +RUN python -m pip install --upgrade pip && pip3 install .[extras] RUN rm -rf /config-merger/* diff --git a/README.md b/README.md index c339762..b6ebf5e 100644 --- a/README.md +++ b/README.md @@ -43,8 +43,10 @@ Idea came from puppet's hiera. ```sh pip install himl -# or, optionally install with extras dependencies: vault and aws interpolation support -pip install himl[vault,aws] +# or, optionally install with all extras dependencies: vault and aws interpolation support +pip install himl[extras] +# or, specify which extras dependencies you need +pip install himl[vault] ``` ### Using `docker` image @@ -59,7 +61,7 @@ See all docker tags at: https://github.com/adobe/himl/pkgs/container/himl/versio ``` git clone https://github.com/adobe/himl cd himl -sudo python install -e .[vault,aws] +sudo python install -e .[extras] ``` ## Examples diff --git a/setup.py b/setup.py index 394166f..148d520 100644 --- a/setup.py +++ b/setup.py @@ -51,11 +51,15 @@ 'pyyaml==6.0' ], extras_require={ + 'extras': [ + 'boto3==1.24.2', + 'hvac==0.11.2', + ], 'aws': [ 'boto3==1.24.2', ], 'vault': [ - 'hvac==0.11.2' + 'hvac==0.11.2', ] }, entry_points={ From 9d943c616ab20f27749268ebbff42dbed6c8a301 Mon Sep 17 00:00:00 2001 From: Zadkiel Aharonian Date: Tue, 7 Jun 2022 18:32:40 +0200 Subject: [PATCH 05/16] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b6ebf5e..0d93392 100644 --- a/README.md +++ b/README.md @@ -46,7 +46,7 @@ pip install himl # or, optionally install with all extras dependencies: vault and aws interpolation support pip install himl[extras] # or, specify which extras dependencies you need -pip install himl[vault] +pip install himl[vault,aws] ``` ### Using `docker` image From ade8031a8ec3cd751ae65d728c05128ce97f2450 Mon Sep 17 00:00:00 2001 From: Zadkiel Aharonian Date: Tue, 7 Jun 2022 18:33:15 +0200 Subject: [PATCH 06/16] Update setup.py --- setup.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/setup.py b/setup.py index 148d520..a667212 100644 --- a/setup.py +++ b/setup.py @@ -53,13 +53,13 @@ extras_require={ 'extras': [ 'boto3==1.24.2', - 'hvac==0.11.2', + 'hvac==0.11.2' ], 'aws': [ - 'boto3==1.24.2', + 'boto3==1.24.2' ], 'vault': [ - 'hvac==0.11.2', + 'hvac==0.11.2' ] }, entry_points={ From cefafc34b14904eb74935e18b101923bba0db307 Mon Sep 17 00:00:00 2001 From: Zadkiel Aharonian Date: Thu, 9 Jun 2022 11:51:29 +0200 Subject: [PATCH 07/16] Update setup.py --- setup.py | 40 +++++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/setup.py b/setup.py index a667212..dbe550b 100644 --- a/setup.py +++ b/setup.py @@ -9,6 +9,25 @@ with open('README.md', encoding="utf-8") as f: _readme = f.read() +install_requires = [ + 'deepmerge==1.0.1', + 'lru_cache==0.2.3', + 'backports.functools_lru_cache==1.6.4', + 'pathlib2==2.3.7.post1', + 'pyyaml==6.0', +] + +extras_require = { + 'aws': [ + 'boto3==1.24.2', + ], + 'vault': [ + 'hvac==0.11.2', + ], +} + +extras_require['extras'] = [dep for deps in extras_require.values() for dep in deps] + setup( name='himl', version="0.9.0", @@ -43,25 +62,8 @@ ], packages=['himl'], include_package_data=True, - install_requires=[ - 'deepmerge==1.0.1', - 'lru_cache==0.2.3', - 'backports.functools_lru_cache==1.6.4', - 'pathlib2==2.3.7.post1', - 'pyyaml==6.0' - ], - extras_require={ - 'extras': [ - 'boto3==1.24.2', - 'hvac==0.11.2' - ], - 'aws': [ - 'boto3==1.24.2' - ], - 'vault': [ - 'hvac==0.11.2' - ] - }, + install_requires=install_requires, + extras_require=extras_require, entry_points={ 'console_scripts': [ 'himl = himl.main:run', From cea20cb142069864cad1d5592b2a051002abd44c Mon Sep 17 00:00:00 2001 From: Zadkiel Aharonian Date: Thu, 9 Jun 2022 11:52:14 +0200 Subject: [PATCH 08/16] Update setup.py --- setup.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/setup.py b/setup.py index dbe550b..e318bf0 100644 --- a/setup.py +++ b/setup.py @@ -9,7 +9,7 @@ with open('README.md', encoding="utf-8") as f: _readme = f.read() -install_requires = [ +_install_requires = [ 'deepmerge==1.0.1', 'lru_cache==0.2.3', 'backports.functools_lru_cache==1.6.4', @@ -17,7 +17,7 @@ 'pyyaml==6.0', ] -extras_require = { +_extras_require = { 'aws': [ 'boto3==1.24.2', ], @@ -25,8 +25,7 @@ 'hvac==0.11.2', ], } - -extras_require['extras'] = [dep for deps in extras_require.values() for dep in deps] +_extras_require['extras'] = [dep for deps in _extras_require.values() for dep in deps] setup( name='himl', From 13d3e97a27738dbff545beded6b506ab7c294d56 Mon Sep 17 00:00:00 2001 From: Zadkiel Aharonian Date: Thu, 3 Aug 2023 18:54:06 +0200 Subject: [PATCH 09/16] Apply suggestions from code review --- README.md | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 292a348..4dcbb52 100644 --- a/README.md +++ b/README.md @@ -44,7 +44,7 @@ Idea came from puppet's hiera. ```sh pip install himl # or, optionally install with all extras dependencies: vault and aws interpolation support -pip install himl[extras] +pip install himl[all] # or, specify which extras dependencies you need pip install himl[vault,aws] ``` diff --git a/setup.py b/setup.py index 0dbbeef..91c6683 100644 --- a/setup.py +++ b/setup.py @@ -25,7 +25,7 @@ 'hvac==1.1.1', ], } -_extras_require['extras'] = [dep for deps in _extras_require.values() for dep in deps] +_extras_require['all'] = [dep for deps in _extras_require.values() for dep in deps] setup( name='himl', From b80572fe331126d1e5d9cce72c9a0020b4851376 Mon Sep 17 00:00:00 2001 From: Zadkiel Aharonian Date: Thu, 3 Aug 2023 19:00:33 +0200 Subject: [PATCH 10/16] Update secret_resolvers.py --- himl/secret_resolvers.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/himl/secret_resolvers.py b/himl/secret_resolvers.py index 0558c36..adfb059 100644 --- a/himl/secret_resolvers.py +++ b/himl/secret_resolvers.py @@ -33,7 +33,7 @@ def __init__(self, default_aws_profile=None): self.default_aws_profile = default_aws_profile def supports(self, secret_type): - return secret_type == "ssm" + return "boto3" in sys.modules && secret_type == "ssm" def resolve(self, secret_type, secret_params): aws_profile = secret_params.get("aws_profile", self.default_aws_profile) @@ -52,7 +52,7 @@ def __init__(self, default_aws_profile=None): self.default_aws_profile = default_aws_profile def supports(self, secret_type): - return secret_type == "s3" + return "boto3" in sys.modules && secret_type == "s3" def resolve(self, secret_type, secret_params): aws_profile = secret_params.get("aws_profile", self.default_aws_profile) @@ -71,7 +71,7 @@ def resolve(self, secret_type, secret_params): class VaultSecretResolver(SecretResolver): def supports(self, secret_type): - return secret_type == "vault" + return "hvac" in sys.modules && secret_type == "vault" def resolve(self, secret_type, secret_params): vault = SimpleVault @@ -106,4 +106,4 @@ def resolve(self, secret_type, secret_params): if resolver.supports(secret_type): return resolver.resolve(secret_type, secret_params) - raise Exception("Could not resolve secret type '{}' with params {}".format(secret_type, secret_params)) + raise Exception("Could not resolve secret type '{}' with params {}. Check if you installed the required 3rd party modules.".format(secret_type, secret_params)) From 4dfa0578ea825b8683fc980c993471663b311af8 Mon Sep 17 00:00:00 2001 From: Zadkiel Aharonian Date: Thu, 3 Aug 2023 19:05:34 +0200 Subject: [PATCH 11/16] Update secret_resolvers.py --- himl/secret_resolvers.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/himl/secret_resolvers.py b/himl/secret_resolvers.py index adfb059..fbf8370 100644 --- a/himl/secret_resolvers.py +++ b/himl/secret_resolvers.py @@ -10,9 +10,6 @@ import logging import os -from .simplessm import SimpleSSM -from .simples3 import SimpleS3 -from .simplevault import SimpleVault class SecretResolver: @@ -43,6 +40,7 @@ def resolve(self, secret_type, secret_params): path = self.get_param_or_exception("path", secret_params) region_name = secret_params.get("region_name", "us-east-1") + from .simplessm import SimpleSSM ssm = SimpleSSM(aws_profile, region_name) return ssm.get(path) @@ -65,6 +63,7 @@ def resolve(self, secret_type, secret_params): region_name = secret_params.get("region_name", "us-east-1") base64Encode = secret_params.get("base64encode", False) base64Encode = base64Encode == 'true' + from .simples3 import SimpleS3 s3 = SimpleS3(aws_profile, region_name) return s3.get(bucket, path, base64Encode) @@ -74,6 +73,7 @@ def supports(self, secret_type): return "hvac" in sys.modules && secret_type == "vault" def resolve(self, secret_type, secret_params): + from .simplevault import SimpleVault vault = SimpleVault # Generate a token for a policy From 2d6811cfd6ba48a14d783379b519cc72340e5ffb Mon Sep 17 00:00:00 2001 From: Zadkiel Aharonian Date: Thu, 3 Aug 2023 19:07:29 +0200 Subject: [PATCH 12/16] Update config_generator.py --- himl/config_generator.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/himl/config_generator.py b/himl/config_generator.py index 67eb950..ffbc54d 100755 --- a/himl/config_generator.py +++ b/himl/config_generator.py @@ -295,8 +295,8 @@ def exclude_keys(self, keys): logger.info("Excluded key %s not found or already removed", key) def add_dynamic_data(self): - remote_state_retriever = S3TerraformRemoteStateRetriever() if "remote_states" in self.generated_data: + remote_state_retriever = S3TerraformRemoteStateRetriever() state_files = self.generated_data["remote_states"] remote_states = remote_state_retriever.get_dynamic_data(state_files) self.merge_value(self.generated_data, remote_states, self.type_strategies, self.fallback_strategies, From 92c08dee9038ab8b5edde474c44b81d9ca86f479 Mon Sep 17 00:00:00 2001 From: Zadkiel Aharonian Date: Thu, 3 Aug 2023 19:08:15 +0200 Subject: [PATCH 13/16] Update config_generator.py --- himl/config_generator.py | 1 + 1 file changed, 1 insertion(+) diff --git a/himl/config_generator.py b/himl/config_generator.py index ffbc54d..042ce03 100755 --- a/himl/config_generator.py +++ b/himl/config_generator.py @@ -296,6 +296,7 @@ def exclude_keys(self, keys): def add_dynamic_data(self): if "remote_states" in self.generated_data: + from .remote_state import S3TerraformRemoteStateRetriever remote_state_retriever = S3TerraformRemoteStateRetriever() state_files = self.generated_data["remote_states"] remote_states = remote_state_retriever.get_dynamic_data(state_files) From 9587bf0187e9d63e855889195fca08ed584baa22 Mon Sep 17 00:00:00 2001 From: Zadkiel Aharonian Date: Thu, 3 Aug 2023 19:14:28 +0200 Subject: [PATCH 14/16] Update remote_state.py --- himl/remote_state.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/himl/remote_state.py b/himl/remote_state.py index 14ea6b5..e1bd5e2 100644 --- a/himl/remote_state.py +++ b/himl/remote_state.py @@ -10,8 +10,10 @@ import json -import boto3 - +try: + import boto3 +except ImportError as e: + raise Exception('Error while trying to read remote state, package "boto3" is required and cannot be imported: %s' % e) class S3TerraformRemoteStateRetriever: @staticmethod From 9230f3a832b031e1e51bfa62246c2bb2a6ea4644 Mon Sep 17 00:00:00 2001 From: Zadkiel Aharonian Date: Tue, 5 Dec 2023 17:25:33 +0100 Subject: [PATCH 15/16] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 4dcbb52..135084d 100644 --- a/README.md +++ b/README.md @@ -43,10 +43,10 @@ Idea came from puppet's hiera. ```sh pip install himl -# or, optionally install with all extras dependencies: vault and aws interpolation support +# or, optionally install with all extras dependencies: vault and s3 interpolation support pip install himl[all] # or, specify which extras dependencies you need -pip install himl[vault,aws] +pip install himl[vault,s3] ``` ### Using `docker` image From 10b64ab60aecbb4c3b6fafbb13aa0b537b2a957d Mon Sep 17 00:00:00 2001 From: Zadkiel Aharonian Date: Tue, 5 Dec 2023 17:26:03 +0100 Subject: [PATCH 16/16] Update setup.py --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 8881cda..0e3e4d9 100644 --- a/setup.py +++ b/setup.py @@ -18,7 +18,7 @@ ] _extras_require = { - 'aws': [ + 's3': [ 'boto3==1.28.44', ], 'vault': [