6 Commits
v0.2.0 ... main

8 changed files with 39 additions and 13 deletions

2
.gitignore vendored
View File

@@ -152,3 +152,5 @@ cython_debug/
#.idea/ #.idea/
.vscode/

View File

@@ -3,8 +3,22 @@
All notable changes to this project will be documented in this file. All notable changes to this project will be documented in this file.
<!-- marker --> <!-- marker -->
## [v0.2.1](https://github.com/dtomlinson91/csops/commits/v0.2.1) - 2022-01-27
<small>[Compare with v0.2.0](https://github.com/dtomlinson91/csops/compare/v0.2.0...v0.2.1)</small>
### ✨ Features
- Add `--version` flag ([a375ac1](https://github.com/dtomlinson91/csops/commit/a375ac18075341ffc3cf410d26837d327d682ea7))
### 📘 Documentation
- Reformat environment variable example ([1a90618](https://github.com/dtomlinson91/csops/commit/1a9061880814d6171f599fc3a0d14eead0514d9a))
### 🛠 Refactor/Improvement
- Disable spawning a shell on subprocess ([91519e2](https://github.com/dtomlinson91/csops/commit/91519e232d1f1cfe19fd13a7a0ac45c80506195c))
## [v0.2.0](https://github.com/dtomlinson91/csops/commits/v0.2.0) - 2022-01-17 ## [v0.2.0](https://github.com/dtomlinson91/csops/commits/v0.2.0) - 2022-01-17
<small>[Compare with v0.1.0](https://github.com/dtomlinson91/csops/compare/v0.1.0..v0.2.0)</small> <small>[Compare with v0.1.0](https://github.com/dtomlinson91/csops/compare/v0.1.0...v0.2.0)</small>
### ✨ Features ### ✨ Features

View File

@@ -21,7 +21,10 @@ csops:
gcp_kms_key: projects/plex-mozilla-sops/locations/global/keyRings/sops/cryptoKeys/sops-key gcp_kms_key: projects/plex-mozilla-sops/locations/global/keyRings/sops/cryptoKeys/sops-key
``` ```
Or set the environment variable `CSOPS_GCP_KMS_KEY="projects/plex-mozilla-sops/locations/global/keyRings/sops/cryptoKeys/sops-keys"` Or set the environment variable
```bash
CSOPS_GCP_KMS_KEY="projects/plex-mozilla-sops/locations/global/keyRings/sops/cryptoKeys/sops-keys"
```
## Usage ## Usage

View File

@@ -1,3 +1,3 @@
"""Module containing the version of csops.""" """Module containing the version of csops."""
__version__ = "0.2.0" __version__ = "0.2.1"

View File

@@ -3,29 +3,35 @@ import pathlib
import subprocess import subprocess
from csops import CONFIG from csops import CONFIG
from csops._version import __version__
def encrypt(args): def encrypt(args):
encrypted_filename = f"{args.file.stem}.enc{args.file.suffix}" encrypted_filename = f"{args.file.stem}.enc{args.file.suffix}"
subprocess.run( encrypted_contents = subprocess.run(
"sops --encrypt --gcp-kms " ["sops", "--encrypt", "--gcp-kms", CONFIG.gcp_kms_key, args.file],
f"{CONFIG.gcp_kms_key} {args.file} > {encrypted_filename}",
check=True, check=True,
text=True, text=True,
shell=True, shell=False,
capture_output=True,
) )
with pathlib.Path(encrypted_filename).open("w", encoding="utf-8") as file:
file.write(encrypted_contents.stdout)
print(encrypted_filename) print(encrypted_filename)
raise SystemExit(0) raise SystemExit(0)
def decrypt(args): def decrypt(args):
decrypted_filename = f"{args.file.stem.split('.')[0]}{args.file.suffix}" decrypted_filename = f"{args.file.stem.split('.')[0]}{args.file.suffix}"
subprocess.run( decrypted_contents = subprocess.run(
f"sops --decrypt {args.file} > {decrypted_filename}", ["sops", "--decrypt", args.file],
check=True, check=True,
text=True, text=True,
shell=True, shell=False,
capture_output=True,
) )
with pathlib.Path(decrypted_filename).open("w", encoding="utf-8") as file:
file.write(decrypted_contents.stdout)
print(decrypted_filename) print(decrypted_filename)
raise SystemExit(0) raise SystemExit(0)
@@ -34,6 +40,7 @@ def run():
parser = argparse.ArgumentParser() parser = argparse.ArgumentParser()
parser.add_argument("flag", type=str, nargs=1) parser.add_argument("flag", type=str, nargs=1)
parser.add_argument("file", type=pathlib.Path) parser.add_argument("file", type=pathlib.Path)
parser.add_argument("-v", "--version", action="version", version="%(prog)s " + __version__)
args = parser.parse_args() args = parser.parse_args()
try: try:

View File

@@ -345,7 +345,7 @@ def changelog(ctx, planned_release: Optional[str] = None, previous_release: Opti
generated_changelog: list = generated_changelog.splitlines() generated_changelog: list = generated_changelog.splitlines()
generated_changelog.insert( generated_changelog.insert(
1, 1,
f"<small>[Compare with {previous_release}]({REPO_URL}/compare/{previous_release}..{planned_release})</small>", f"<small>[Compare with {previous_release}]({REPO_URL}/compare/{previous_release}...{planned_release})</small>",
) )
generated_changelog: str = "\n".join([line for line in generated_changelog]) + "\n" generated_changelog: str = "\n".join([line for line in generated_changelog]) + "\n"
new_changelog = [] new_changelog = []

View File

@@ -1,6 +1,6 @@
[tool.poetry] [tool.poetry]
name = "csops" name = "csops"
version = "0.2.0" version = "0.2.1"
description = "" description = ""
authors = ["Daniel Tomlinson <dtomlinson@panaetius.co.uk>"] authors = ["Daniel Tomlinson <dtomlinson@panaetius.co.uk>"]

View File

@@ -15,7 +15,7 @@ entry_points = \
setup_kwargs = { setup_kwargs = {
'name': 'csops', 'name': 'csops',
'version': '0.2.0', 'version': '0.2.1',
'description': '', 'description': '',
'long_description': None, 'long_description': None,
'author': 'Daniel Tomlinson', 'author': 'Daniel Tomlinson',