73 lines
2.0 KiB
Plaintext
73 lines
2.0 KiB
Plaintext
|
|
# Made for prepare and postrun
|
|
use ../config/accessor.nu *
|
|
use ../utils/ui.nu *
|
|
use ../sops *
|
|
|
|
export def log_debug [
|
|
msg: string
|
|
]: nothing -> nothing {
|
|
use std
|
|
std log debug $msg
|
|
# std assert (1 == 1)
|
|
}
|
|
export def check_env [
|
|
]: nothing -> nothing {
|
|
let vars_path = (get-provisioning-vars)
|
|
if ($vars_path | is-empty) {
|
|
_print $"🛑 Error no values found for (_ansi red_bold)PROVISIONING_VARS(_ansi reset)"
|
|
exit 1
|
|
}
|
|
if not ($vars_path | path exists) {
|
|
_print $"🛑 Error file (_ansi red_bold)($vars_path)(_ansi reset) not found"
|
|
exit 1
|
|
}
|
|
let workspace_path = (get-workspace-path)
|
|
if ($workspace_path | is-empty) {
|
|
_print $"🛑 Error no values found for (_ansi red_bold)PROVISIONING_WORKSPACE_PATH(_ansi reset)"
|
|
exit 1
|
|
}
|
|
if not ($workspace_path | path exists) {
|
|
_print $"🛑 Error file (_ansi red_bold)($workspace_path)(_ansi reset) not found"
|
|
exit 1
|
|
}
|
|
let wk_env_path = (get-provisioning-wk-env-path)
|
|
if ($wk_env_path | is-empty) {
|
|
_print $"🛑 Error no values found for (_ansi red_bold)PROVISIONING_WK_ENV_PATH(_ansi reset)"
|
|
exit 1
|
|
}
|
|
if not ($wk_env_path | path exists) {
|
|
_print $"🛑 Error file (_ansi red_bold)($wk_env_path)(_ansi reset) not found"
|
|
exit 1
|
|
}
|
|
}
|
|
|
|
export def sops_cmd [
|
|
task: string
|
|
source: string
|
|
target?: string
|
|
--error_exit # error on exit
|
|
]: nothing -> nothing {
|
|
let sops_key = (find-sops-key)
|
|
if ($sops_key | is-empty) {
|
|
$env.CURRENT_INFRA_PATH = ((get-provisioning-infra-path) | path join (get-workspace-path | path basename))
|
|
use ../../../sops_env.nu
|
|
}
|
|
#use sops/lib.nu on_sops
|
|
if $error_exit {
|
|
on_sops $task $source $target --error_exit
|
|
} else {
|
|
on_sops $task $source $target
|
|
}
|
|
}
|
|
|
|
export def load_defs [
|
|
]: nothing -> record {
|
|
let vars_path = (get-provisioning-vars)
|
|
if not ($vars_path | path exists) {
|
|
_print $"🛑 Error file (_ansi red_bold)($vars_path)(_ansi reset) not found"
|
|
exit 1
|
|
}
|
|
(open $vars_path)
|
|
}
|