mirror of
https://github.com/dtomlinson91/csops.git
synced 2025-12-22 05:45:45 +00:00
feat: add user configuration of gcp_kms_key #1
This commit is contained in:
@@ -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")
|
||||||
|
|||||||
@@ -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,
|
||||||
|
|||||||
Reference in New Issue
Block a user