Skip to content

Commit

Permalink
nix stdlib: use github token from vault via template
Browse files Browse the repository at this point in the history
  • Loading branch information
dermetfan committed Jan 18, 2022
1 parent cce0f88 commit e00e428
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions pkgs/cicero/evaluators/nix/lib.nix
Expand Up @@ -321,11 +321,6 @@ rec {
(inner: ''
export SSL_CERT_FILE=/current-profile/etc/ssl/certs/ca-bundle.crt
# TODO Only get from vault. Env var is just for development.
if [[ -z "''${GITHUB_TOKEN:-}" ]]; then
GITHUB_TOKEN=$(vault kv get -field=token kv/data/cicero/github)
fi
function cleanup {
rm -f "$secret_headers"
}
Expand All @@ -334,7 +329,7 @@ rec {
secret_headers="$(mktemp)"
cat >> "$secret_headers" <<EOF
Authorization: token $GITHUB_TOKEN
Authorization: token $(< "$NOMAD_SECRETS_DIR"/github/token)
EOF
function report {
Expand Down Expand Up @@ -376,9 +371,13 @@ rec {
config.packages = data-merge.append [
"github:NixOS/nixpkgs/${self.inputs.nixpkgs.rev}#curl"
"github:NixOS/nixpkgs/${self.inputs.nixpkgs.rev}#jq"
"github:NixOS/nixpkgs/${self.inputs.nixpkgs.rev}#vault"
"github:NixOS/nixpkgs/${self.inputs.nixpkgs.rev}#cacert"
];

template = data-merge.append [{
destination = "secrets/cicero/github/token";
data = ''{{with secret "kv/data/cicero/github"}}{{.Data.data.token}}{{end}}'';
}];
};
};
};
Expand Down

0 comments on commit e00e428

Please sign in to comment.