Remove tritonshell, use it as git submodule instead

This commit is contained in:
teutat3s 2022-10-05 16:24:45 +02:00
parent 7546e1a25d
commit f28bff0af4
Signed by: teutat3s
GPG key ID: 4FA1D3FA524F22C1
9 changed files with 0 additions and 3670 deletions

View file

@ -1,111 +0,0 @@
{
"nodes": {
"devshell": {
"inputs": {
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs"
},
"locked": {
"lastModified": 1653917170,
"narHash": "sha256-FyxOnEE/V4PNEcMU62ikY4FfYPo349MOhMM97HS0XEo=",
"owner": "numtide",
"repo": "devshell",
"rev": "fc7a3e3adde9bbcab68af6d1e3c6eb738e296a92",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "devshell",
"type": "github"
}
},
"flake-utils": {
"locked": {
"lastModified": 1642700792,
"narHash": "sha256-XqHrk7hFb+zBvRg6Ghl+AZDq03ov6OshJLiSWOoX5es=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "846b2ae0fc4cc943637d3d1def4454213e203cba",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"flake-utils_2": {
"locked": {
"lastModified": 1653893745,
"narHash": "sha256-0jntwV3Z8//YwuOjzhV2sgJJPt+HY6KhU7VZUL0fKZQ=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "1ed9fb1935d260de5fe1c2f7ee0ebaae17ed2fa1",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1643381941,
"narHash": "sha256-pHTwvnN4tTsEKkWlXQ8JMY423epos8wUOhthpwJjtpc=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "5efc8ca954272c4376ac929f4c5ffefcc20551d5",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs20-09": {
"locked": {
"lastModified": 1651477912,
"narHash": "sha256-YDFgJElf0ZL977+fo6ueQAmpb6lwrw1lzDlxLEINVXE=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "66b0db71f463164486a36dded50bedee185e45c2",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "release-20.09",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs_2": {
"locked": {
"lastModified": 1653931853,
"narHash": "sha256-O3wncIouj9x7gBPntzHeK/Hkmm9M1SGlYq7JI7saTAE=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "f1c167688a6f81f4a51ab542e5f476c8c595e457",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"devshell": "devshell",
"flake-utils": "flake-utils_2",
"nixpkgs": "nixpkgs_2",
"nixpkgs20-09": "nixpkgs20-09"
}
}
},
"root": "root",
"version": 7
}

View file

@ -1,56 +0,0 @@
{
description = "devs & ops environment for nix'ing with triton";
inputs.devshell.url = "github:numtide/devshell";
inputs.flake-utils.url = "github:numtide/flake-utils";
inputs.nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
inputs.nixpkgs20-09.url = "github:nixos/nixpkgs/release-20.09";
outputs = { self, flake-utils, devshell, nixpkgs, nixpkgs20-09 }:
flake-utils.lib.eachDefaultSystem (system: {
# Internal utility package with shell function and env vars helper.
# These get source'd in devshell.bash.extra when starting tritonshell
packages = {
triton-utils = import ./pkgs/triton-utils.nix { inherit nixpkgs system; };
triton-docker-env =
let
# CUSTOMIZE:
# variables used to set triton env vars in tritonshell
# adjust to suit your Triton Data Center setup
# take a look at ./pkgs/triton-docker-env-shell.nix to see how these get used
cnsBaseDomain = "greenbaum.zone";
dataCenters = [ "cgn-1" "lev-1" ];
mantaDomain = "eu-central.manta.greenbaum.cloud";
tritonApiDomain = "api.greenbaum.cloud";
in
import ./pkgs/triton-docker-env.nix {
inherit nixpkgs system cnsBaseDomain dataCenters mantaDomain
tritonApiDomain;
};
};
devShell =
let
pkgs = import nixpkgs {
inherit system;
overlays = [ devshell.overlay ];
};
pkgs20-09 = import nixpkgs20-09 {
inherit system;
overlays = [ devshell.overlay ];
};
# HINT: add your extra pkgs here,
# they'll get appended to devshell.packages in ./tritonshell.nix
extraDevshellPkgs = with pkgs; [
# used by triton-ansible-inventory
nodejs
];
in
import ./tritonshell.nix { inherit extraDevshellPkgs devshell pkgs pkgs20-09 self system; };
});
}

View file

@ -1,31 +0,0 @@
{ pkgs, cnsBaseDomain, dataCenters, mantaDomain, tritonApiDomain, ... }:
with pkgs.nodePackages;
''
export PATH="${triton}/bin:${json}/bin:$PATH"
# script to set the docker, triton, manta and CNS env vars for the current
# triton profile
# set triton and docker host environment variables
eval "$(triton env)"
# get the user's UUID
triton_account_uuid="$(triton account get --json | json id)"
# set the CNS (container name service) base for auto-generated DNS records
# in public and private networks
# note, this makes assumptions that only work if you configured the nix
# variables in flake.nix "CUSTOMIZE" section according to your Triton Data
# Center setup
for dc in ${pkgs.lib.concatStringsSep " " dataCenters}; do
if env | grep -q -E "SDC_URL=https://''${dc}.${tritonApiDomain}"; then
export \
TRITON_CNS_SEARCH_DOMAIN_PUBLIC="''${triton_account_uuid}.''${dc}.${cnsBaseDomain}" \
TRITON_CNS_SEARCH_DOMAIN_PRIVATE="''${triton_account_uuid}.''${dc}.int.${cnsBaseDomain}" \
TRITON_DC=''$dc
fi
done
export MANTA_URL=https://${mantaDomain}
export MANTA_USER=$SDC_ACCOUNT
export MANTA_KEY_ID=$SDC_KEY_ID
''

View file

@ -1,7 +0,0 @@
{ nixpkgs, system, cnsBaseDomain, dataCenters, mantaDomain, tritonApiDomain, ... }:
let
pkgs = import nixpkgs {
inherit system;
};
in
(pkgs.writeShellScriptBin "triton-docker-env.sh" (import ./triton-docker-env-shell.nix { inherit pkgs cnsBaseDomain dataCenters mantaDomain tritonApiDomain; }))

View file

@ -1,19 +0,0 @@
{ nixpkgs, system, ... }:
let
pkgs = import nixpkgs {
inherit system;
};
in
pkgs.stdenv.mkDerivation {
pname = "triton-utils";
version = "0.0.3";
src = pkgs.lib.cleanSource ./.;
installPhase = ''
mkdir -p $out/bin $out/share/certs
cd ./utils
cp ./cacert-2022-02-01.pem $out/share/certs
cp ./ttp.sh $out/bin
cp ./unset-env.sh $out/bin
'';
}

File diff suppressed because it is too large Load diff

View file

@ -1,30 +0,0 @@
#!/usr/bin/env bash
# helper function to set the docker, triton, manta and CNS env vars for the current triton profile
ttp() {
if [[ "$1" == "set" ]]; then
if [[ -n "$2" ]]; then
source unset-env.sh
triton profile set "$2"
fi
source triton-docker-env.sh
elif [[ "$1" == "unset" ]]; then
source unset-env.sh
elif [[ "$1" == "env" ]]; then
env | grep "DOCKER\|MANTA\|SDC\|TRITON" | sort
else
echo "this is a helper function to quickly switch triton profiles"
echo "and setup the required environment variables"
echo "for triton, manta and the remote docker host (API)"
echo
echo 'use "ttp set your-profile" to switch to a profile'
echo
echo 'use "ttp unset" to clear all environment variables used by these CLIs'
echo "useful if you'd like to run a docker command against the"
echo "local docker host"
echo
echo 'use "ttp env" to view the currently set environment variables'
echo "used by the triton & manta CLIs"
echo
echo 'use "ttp help" to view this help'
fi
}

View file

@ -1,9 +0,0 @@
#!/usr/bin/env bash
# script to unset the docker, triton, manta and CNS env vars for the current triton profile
# make sure we're starting in a "clean" environment
unset TRITON_PROFILE
unset DOCKER_CERT_PATH DOCKER_HOST DOCKER_TLS_VERIFY COMPOSE_HTTP_TIMEOUT
unset SDC_URL SDC_ACCOUNT SDC_KEY_ID
unset TRITON_CNS_SEARCH_DOMAIN_PUBLIC TRITON_CNS_SEARCH_DOMAIN_PRIVATE
unset MANTA_URL MANTA_USER MANTA_KEY_ID

View file

@ -1,96 +0,0 @@
{ extraDevshellPkgs, devshell, pkgs, pkgs20-09, self, system, ... }:
pkgs.devshell.mkShell {
# devshell docs: https://numtide.github.io/devshell/modules_schema.html
name = "tritonshell";
devshell.interactive = {
PS1_util = pkgs.lib.noDepEntry ''
if [[ -n "''${PRJ_ROOT:-}" ]]; then
# Print the path relative to $PRJ_ROOT
rel_root() {
local path
path=$(${pkgs.coreutils}/bin/realpath --relative-to "$PRJ_ROOT" "$PWD")
if [[ $path != . ]]; then
echo " $path "
fi
}
else
# If PRJ_ROOT is unset, print only the current directory name
rel_root() {
echo " \W "
}
fi
'';
PS1.text = ''
PS1='\[\033[38;5;202m\][$SDC_ACCOUNT@$TRITON_DC]$(rel_root)\$ \[\033[0m\]'
'';
};
commands = [
{
package = pkgs.devshell.cli;
help = "Per project developer environments";
}
{
package = pkgs.nodePackages.triton;
category = "triton & manta tools";
name = "triton";
help = "Triton DC CLI (https://docs.greenbaum.cloud/en/devops/triton-cli.html)";
}
{
package = pkgs.nodePackages.manta;
category = "triton & manta tools";
name = "manta";
help = "Manta CLIs (https://apidocs.joyent.com/manta/index.html#cli)";
}
{
package = self.packages.${system}.triton-utils;
category = "triton & manta tools";
name = "ttp";
help = "Quickly switch triton profiles (shell function)";
}
];
devshell.packages = [
pkgs.bash-completion
# use docker-compose version 1.26.2 for best triton API compatibility
pkgs20-09.docker-compose
# shell scripts and utilities to set and unset triton environment variables
self.packages.${system}.triton-utils
self.packages.${system}.triton-docker-env
# useful for working with JSON data
pkgs.jq
pkgs.bunyan-rs
] ++ extraDevshellPkgs;
env = [
# workaround for TLS certs bug in docker-compose, CERTIFICATE_VERIFY_FAILED
# see: https://github.com/joyent/triton-docker-cli/issues/17
{
name = "CURL_CA_BUNDLE";
value = "${self.packages.${system}.triton-utils}/share/certs/cacert-2022-02-01.pem";
}
{
name = "CONSUL_HTTP_ADDR";
value = "http://consul.service.consul:8500";
}
{
name = "NOMAD_ADDR";
value = "https://nomad.service.consul:4646";
}
{
name = "VAULT_ADDR";
value = "https://vault.service.consul:8200";
}
];
bash = {
extra = ''
source ${self.packages.${system}.triton-docker-env}/bin/triton-docker-env.sh
source ${self.packages.${system}.triton-utils}/bin/ttp.sh
if [ "$(uname)" == "Darwin" ]; then
source $DEVSHELL_DIR/share/bash-completion/bash_completion
fi
'';
};
}