Skip to content

Commit 7d43644

Browse files
authored
Merge pull request #74 from ClarkSource/secret-provider
2 parents ea0c8be + d37fae6 commit 7d43644

File tree

3 files changed

+56
-6
lines changed

3 files changed

+56
-6
lines changed

default.nix

+49-5
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,55 @@
11
with import <nixpkgs> {};
22

3-
pkgs.mkShell {
3+
let
4+
simple_tools = python3.pkgs.buildPythonPackage rec {
5+
pname = "simple_tools";
6+
version = "0.2.0.post2";
7+
8+
src = python3.pkgs.fetchPypi {
9+
inherit pname version;
10+
sha256 = "16xxpsngv76fzsxji1714m7b6b74wk459sjs8p15nj8h4xy0b7b9";
11+
};
12+
13+
doCheck = false;
14+
15+
meta = {
16+
homepage = "https://github.com/afriemann/simple_tools/";
17+
description = "A collection of various snippets and tools that come up regularly.";
18+
};
19+
};
20+
21+
k8t = with python3.pkgs; buildPythonApplication rec {
22+
pname = "k8t";
23+
version = "dev";
24+
25+
src = ./.;
26+
27+
# No tests included
28+
doCheck = false;
29+
30+
nativeBuildInputs = [
31+
git
32+
];
33+
34+
propagatedBuildInputs = [
35+
jinja2
36+
coloredlogs
37+
boto3
38+
pyyaml
39+
click
40+
simple_tools
41+
];
42+
43+
meta = with lib; {
44+
homepage = "https://github.com/clarksource/k8t";
45+
license = licenses.isc;
46+
};
47+
};
48+
in with python3.pkgs; pkgs.mkShell {
449
buildInputs = [
50+
k8t
51+
setuptools
552
pre-commit
53+
tox
654
];
7-
8-
shellHook = ''
9-
export PATH="$PATH:$HOME/.yarn/bin"
10-
'';
1155
}

k8t/cli.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -111,18 +111,23 @@ def cli_validate(method, value_files, cli_values, cname, ename, directory):
111111
@click.option("--value", "cli_values", type=(str, str), multiple=True, metavar="<KEY VALUE>", help="Additional value(s) to include.")
112112
@click.option("--cluster", "-c", "cname", help="Cluster context to use.")
113113
@click.option("--environment", "-e", "ename", help="Deployment environment to use.")
114+
@click.option("--secret-provider", help="Secret provider override.")
114115
@click.argument("directory", type=click.Path(dir_okay=True, file_okay=False, exists=True), default=os.getcwd())
115116
@requires_project_directory
116-
def cli_gen(method, value_files, cli_values, cname, ename, directory): # pylint: disable=redefined-outer-name,too-many-arguments
117+
def cli_gen(method, value_files, cli_values, cname, ename, secret_provider, directory): # pylint: disable=redefined-outer-name,too-many-arguments
117118
vals = deep_merge( # pylint: disable=redefined-outer-name
118119
values.load_all(directory, cname, ename, method),
119120
*(load_yaml(p) for p in value_files),
120121
dict(cli_values),
121122
envvalues(),
122123
method=method,
123124
)
125+
124126
config.CONFIG = config.load_all(directory, cname, ename, method)
125127

128+
if secret_provider is not None:
129+
config.CONFIG['secrets']['provider'] = secret_provider
130+
126131
eng = build(directory, cname, ename)
127132

128133
templates = eng.list_templates() # pylint: disable=redefined-outer-name

k8t/filters.py

+1
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ def hashf(value, method="sha256"):
8383

8484
def get_secret(key: str, length: int = None) -> str:
8585
provider_name = config.CONFIG.get("secrets", {}).get("provider")
86+
8687
if not provider_name:
8788
raise RuntimeError("Secrets provider not configured.")
8889

0 commit comments

Comments
 (0)