feat: add user configuration of gcp_kms_key #1

This commit is contained in:
2022-01-17 23:14:02 +00:00
parent 573ab8ca2d
commit f654d199ee
2 changed files with 18 additions and 2 deletions

View File

@@ -0,0 +1,14 @@
import os
from typing import Any
import panaetius
_config_path = os.environ.get("CSOPS_CONFIG")
if _config_path is not None:
CONFIG: Any = panaetius.Config("csops", _config_path, skiper_header_init=True)
else:
CONFIG = panaetius.Config("csops", "~/.config")
panaetius.set_config(CONFIG, "gcp_kms_key")

View File

@@ -2,12 +2,14 @@ import argparse
import pathlib import pathlib
import subprocess import subprocess
from csops import CONFIG
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( subprocess.run(
"sops --encrypt --gcp-kms " "sops --encrypt --gcp-kms "
f" projects/plex-mozilla-sops/locations/global/keyRings/sops/cryptoKeys/sops-key {args.file} > {encrypted_filename}", f"{CONFIG.gcp_kms_key} {args.file} > {encrypted_filename}",
check=True, check=True,
text=True, text=True,
shell=True, shell=True,