adapt to nu 0.90

master
Kinch 2024-03-04 16:06:35 +01:00
parent afaf55b0f1
commit 55b79af44b
11 changed files with 74 additions and 29 deletions

15
aws-dev-env.nu Normal file
View File

@ -0,0 +1,15 @@
export-env {
load-env {
MS_OCR_AUTHORITY: "https://otc-dev.aws.de.insiders.cloud/ocr/microsoft",
FLAIR_AUTHORITY: "http://localhost:8082",
XS_SF_URL: "https://api.test.de.insiders.cloud",
XS_URL: "https://xs-backend.test.de.insiders.cloud",
XS_SF_ACCOUNT: "xs.aws.test.tessi-admin",
KUBE_CONTEXT: "aws-dev"
HELM_KUBECONTEXT: "aws-dev"
XS_ENV_NAME: "AWS_DEV"
AWS_INFASTRUCTURE_ACCOUNT: "047349208615.dkr.ecr.eu-central-1.amazonaws.com"
XS_KAFKA_BOOSTRAP_SERVER: "localhost:9092"
AWS_PROFILE: "default"
}
}

View File

@ -9,5 +9,6 @@ export-env {
HELM_KUBECONTEXT: "aws-prod"
XS_ENV_NAME: "AWS_PROD"
AWS_INFASTRUCTURE_ACCOUNT: "047349208615.dkr.ecr.eu-central-1.amazonaws.com"
AWS_PROFILE: "prod"
}
}

14
aws-staging-env.nu Normal file
View File

@ -0,0 +1,14 @@
export-env {
load-env {
MS_OCR_AUTHORITY: "https://otc-dev.aws.de.insiders.cloud/ocr/microsoft",
FLAIR_AUTHORITY: "http://localhost:8082",
XS_SF_URL: "https://api.production.de.insiders.cloud",
XS_URL: "https://xs-backend.production.de.insiders.cloud",
XS_SF_ACCOUNT: "xs.prod.paul",
KUBE_CONTEXT: "aws-staging"
HELM_KUBECONTEXT: "aws-staging"
XS_ENV_NAME: "AWS_STAGING"
AWS_INFASTRUCTURE_ACCOUNT: "047349208615.dkr.ecr.eu-central-1.amazonaws.com"
AWS_PROFILE: "prod"
}
}

View File

@ -5,10 +5,11 @@ export-env {
XS_SF_URL: "https://api.test.de.insiders.cloud",
XS_URL: "https://xs-backend.test.de.insiders.cloud",
XS_SF_ACCOUNT: "xs.aws.test.tessi-admin",
KUBE_CONTEXT: "dev-test"
HELM_KUBECONTEXT: "dev-test"
KUBE_CONTEXT: "aws-test"
HELM_KUBECONTEXT: "aws-test"
XS_ENV_NAME: "AWS_TEST"
AWS_INFASTRUCTURE_ACCOUNT: "047349208615.dkr.ecr.eu-central-1.amazonaws.com"
XS_KAFKA_BOOSTRAP_SERVER: "localhost:9092"
AWS_PROFILE: "default"
}
}

6
aws.nu
View File

@ -1,5 +1,5 @@
def call_aws [args:list<string>] {
run-external --redirect-stdout "aws" $args
run-external --redirect-stdout "aws" "--profile" $env.AWS_PROFILE ...$args
}
def comp-instanceId [] {
@ -17,7 +17,7 @@ export def login-into-docker [] {
export def login [] {
call_aws ["sso", "login"]
login-into-docker
# login-into-docker
}
export def "restart instance" [instanceId:string@comp-instanceId] {
@ -51,7 +51,7 @@ export def alarm [alarm:string@comp-alarm-name] {
| update Timestamp { |r| $r.Timestamp | into datetime }
| select AlarmName Timestamp HistorySummary oldState newState
| rename name age summary old new
| insert date {|r| $r.age | date to-timezone "Europe/Berlin" | date format }
| insert date {|r| $r.age | date to-timezone "Europe/Berlin" | format date }
| where new == ALARM
| reverse
}

View File

@ -24,5 +24,5 @@ export def init [] {
export def main [] {
let items = (list includes)
^restic backup $items
^restic backup ...$items
}

15
br.nu
View File

@ -7,7 +7,7 @@ def read-settings [] {
}
def comp-name [] {
read-settings | query db "SELECT * FROM formula" | select name desc | rename value description
read-settings | query db "SELECT * FROM main" | select name desc | rename value description
}
# update the info about the formulars
@ -15,16 +15,21 @@ export def update-cache [] {
let formulars = (http get https://formulae.brew.sh/api/formula.json)
let casks = (http get https://formulae.brew.sh/api/cask.json)
rm -f (settings-db)
$formulars | select name full_name desc | insert type "formula" | into sqlite --table_name "formula" (settings-db)
$casks | select token full_token desc | rename name full_name desc | insert type "cask" | into sqlite --table_name "formula" (settings-db)
$formulars | select name full_name desc | insert type "formula" | into sqlite --table-name "formula" (settings-db)
$casks
| select token full_token desc
| rename name full_name desc
| insert type "cask"
| default "" "desc"
| into sqlite --table-name "formula" (settings-db)
}
export def search [pattern:string,--exact] {
let settings = (read-settings)
if $exact {
$settings | query db $"SELECT * FROM formula WHERE name = '($pattern)'"
$settings | query db $"SELECT * FROM main WHERE name = '($pattern)'"
} else {
$settings | query db $"SELECT * FROM formula WHERE name LIKE '%($pattern)%'"
$settings | query db $"SELECT * FROM main WHERE name LIKE '%($pattern)%'"
}
}

2
cluster.nu Normal file
View File

@ -0,0 +1,2 @@
# drops all tables for current environment. You should restart the backend to execute the migration
export def "drop database" [] {}

14
hl.nu
View File

@ -1,23 +1,27 @@
export def helm-projects [] {
[{
value: "xs-backend",
description: "/Volumes/extreme/projects/xtraction-factory/XtractionStudioBackend/src/main/helm/xs-backend"
# description: "/Volumes/extreme/projects/xtraction-factory/XtractionStudioBackend/src/main/helm/xs-backend"
description: "/Volumes/extreme/projects/xtraction-factory/XtractionStudioBackend/products/xs-backend/src/main/helm"
}]
}
export def hist [project:string@helm-projects] {
export def hist [project:string@helm-projects, --max:int=10] {
let helm_project_path = (helm-projects | where value == $project | first | get description | parse-helm-path)
cd $helm_project_path.directory
helm history ($helm_project_path.name) -o json | from json | update updated { |row| $row.updated | into datetime }
helm history $project --max $max -o json
| from json
| update updated { |row| $row.updated | into datetime }
# helm history $project -o json | from json
}
export def rollback [project:string@helm-projects, revision?:int] {
let helm_project_path = (helm-projects | where value == $project | first | get description | parse-helm-path)
cd $helm_project_path.directory
if $revision == null {
helm rollback ($helm_project_path.name)
helm rollback $project
} else {
helm rollback ($helm_project_path.name) $revision
helm rollback $project $revision
}
}

26
sc.nu
View File

@ -41,19 +41,19 @@ def sc-delete [path:string] {
^xh delete -A bearer -a $"(provide-access-token)" (ht with-path $env.XS_SF_URL $path) | from json
}
export def-env update-access-token [] {
print -e $"Login as (ansi pb)($env.XS_SF_ACCOUNT)(ansi reset)"
let token_response = (request-token)
if "ErrorCode" in $token_response {
print "ERROR"
let error_msg = $"Could not login into smart cloud as user ($env.XS_SF_ACCOUNT): ($token_response | get Message)"
error make {
msg: $error_msg
}
}
$token_response | credm update-token-response (token-name)
$token_response.token
}
# export def-env update-access-token [] {
# print -e $"Login as (ansi pb)($env.XS_SF_ACCOUNT)(ansi reset)"
# let token_response = (request-token)
# if "ErrorCode" in $token_response {
# print "ERROR"
# let error_msg = $"Could not login into smart cloud as user ($env.XS_SF_ACCOUNT): ($token_response | get Message)"
# error make {
# msg: $error_msg
# }
# }
# $token_response | credm update-token-response (token-name)
# $token_response.token
# }
export def provide-access-token [] {
let token = (credm get (token-name))

3
xs-tools.nu Normal file
View File

@ -0,0 +1,3 @@
export def "view log" [] {
lines | filter { |line| $line | str starts-with '{' } | each { |line| try { $line | from json } catch {{}} } | flatten
}