This repository was archived by the owner on Aug 4, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +38
-0
lines changed
Expand file tree Collapse file tree 4 files changed +38
-0
lines changed Original file line number Diff line number Diff line change @@ -26,6 +26,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2626* New addons: * aws* to allow receiving AWS account id and region.
2727* New ` gcip.addons.container.registries.Registry.AWS() ` allows getting an ECR URL to be used in pipeline.
2828* Added ` crane.pull() ` function to ` gcip.addons.container.crane ` .
29+ * Added new gcip.addons.security.sops module and added sops_export_decrypted_values function to sops module.
2930
3031### Changed
3132* Normalize config_file_path in ` gcip.addons.container.config.DockerClientConfig `
Original file line number Diff line number Diff line change 1+ __author__ = "Daniel von Eßen"
2+ __copyright__ = "Copyright 2020 DB Systel GmbH"
3+ __credits__ = ["Daniel von Eßen" , "Thomas Steinbach" ]
4+ # SPDX-License-Identifier: Apache-2.0
5+ __license__ = "Apache-2.0"
6+ __maintainer__ = "Thomas Steinbach"
7+ __email__ = "daniel.von-essen@deutschebahn.com"
Original file line number Diff line number Diff line change 1+ __author__ = "Daniel von Eßen"
2+ __copyright__ = "Copyright 2020 DB Systel GmbH"
3+ __credits__ = ["Daniel von Eßen" , "Thomas Steinbach" ]
4+ # SPDX-License-Identifier: Apache-2.0
5+ __license__ = "Apache-2.0"
6+ __maintainer__ = "Thomas Steinbach"
7+ __email__ = "daniel.von-essen@deutschebahn.com"
8+
9+
10+ def sops_export_decrypted_values (path : str ) -> str :
11+ """Returns a helper string to embedd it into jobs to allow exporting
12+ Values which are decrypted by `sops`. e.g. 'export $(sops -d sops/encrypted_file.env)'
13+
14+ This function is usefull, if you want to use environment variables to login to e.g. a container registry.
15+
16+ Args:
17+ path (str): Path to `sops` encrypted file, must be relative to project directory.
18+
19+ Returns:
20+ str: Export string of sops decrypted file.
21+ """
22+ return f"set -eo pipefail; SOPS_OUTPUT=$(sops -d { path } ); export $SOPS_OUTPUT"
Original file line number Diff line number Diff line change 1+ from gcip .addons .security .sops import (
2+ sops_export_decrypted_values ,
3+ )
4+
5+
6+ def test_sops_export_decrypted_values ():
7+ expected = "set -eo pipefail; SOPS_OUTPUT=$(sops -d secrets/encrypted_file.env); export $SOPS_OUTPUT"
8+ assert sops_export_decrypted_values ("secrets/encrypted_file.env" ) == expected
You can’t perform that action at this time.
0 commit comments