76 lines
2.7 KiB
Plaintext
76 lines
2.7 KiB
Plaintext
export def helm-projects [] {
|
|
[{
|
|
value: "xs-backend",
|
|
description: "/Volumes/extreme/projects/xtraction-factory/XtractionStudioBackend/src/main/helm/xs-backend"
|
|
}]
|
|
}
|
|
|
|
export def hist [project:string@helm-projects] {
|
|
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 }
|
|
}
|
|
|
|
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)
|
|
} else {
|
|
helm rollback ($helm_project_path.name) $revision
|
|
}
|
|
}
|
|
|
|
# render a file from a helm chart.
|
|
export def render [
|
|
project:string@helm-projects, # the project name
|
|
path:string@comp-template-files, # the template file relative to the templates folder
|
|
values:string@comp-values-files, # the value file in addition to the values.yaml which will always be used
|
|
] {
|
|
let helm_project_path = ($project | helm-project-directory)
|
|
^helm template ($helm_project_path) -s ("templates" | path join $path) -f ($helm_project_path | path join $values) --debug
|
|
}
|
|
|
|
# == completition
|
|
|
|
export def comp-template-files [context: string] {
|
|
let project_path = ($context | split shell words | filter project-names | first | helm-project-directory)
|
|
let template_path = ([$project_path, "templates"] | path join)
|
|
glob $"($project_path)/templates/*.{yaml,yml}" | each { |template_file|
|
|
$template_file | path relative-to $template_path
|
|
}
|
|
}
|
|
|
|
def comp-values-files [context: string] {
|
|
let project_path = ($context | split shell words | filter project-names | first | helm-project-directory)
|
|
glob $"($project_path)/values-*.{yaml,yml}" | each { |template_file|
|
|
$template_file | path relative-to $project_path
|
|
}
|
|
}
|
|
|
|
# == implementation
|
|
|
|
# like split words but split only on spaces (ignoring multiple spaces)
|
|
def "split shell words" [] {
|
|
split row " " | filter { |x| ($x | is-empty) == false }
|
|
}
|
|
|
|
# filter words for valide project names
|
|
def "filter project-names" [] {
|
|
let words = $in
|
|
let project_names = (helm-projects | each {|x| $x.value})
|
|
$words | filter {|word| $word in $project_names}
|
|
}
|
|
|
|
def parse-helm-path [] {
|
|
let helm_path = $in
|
|
{
|
|
name: ($helm_path | path basename),
|
|
directory: ($helm_path | path dirname)
|
|
}
|
|
}
|
|
|
|
def helm-project-directory [] {
|
|
let project_name = $in
|
|
helm-projects | where value == $project_name | first | get description
|
|
} |