blob: 0190310cc04570235f83d7bae2c8619d95c80448 [file] [log] [blame]
gioc9161872024-04-21 10:46:35 +04001#!/bin/bash
2
3# Outputs the generated helm configurations after templating.
4
5yaml_output=/tmp/op-hc-yaml-output.txt
6error_output=/tmp/op-hc-error-output.txt
7section_output=/tmp/op-hc-section-output.yml
8vimrc=/tmp/op-hc-vim-rc
9
10rm $yaml_output $error_output $section_output $vimrc &>/dev/null
11
12helm template --debug "$@" . 1> $yaml_output 2> $error_output
13
14if [ $? -gt 0 ]; then
15 section=`cat $error_output | grep 'Error: YAML parse error on' | cut -d: -f2 | cut -d' ' -f6-`
16
17 if [ -n "$section" ]; then
18 cat $yaml_output | sed -e "0,/\# Source: ${section//\//\\/}/d" | tail -n+2 | sed -e '/---/,$d' > $section_output
19
20 line=`cat $error_output | grep line | head -n1 | perl -nle 'm/line (\d+)/; print $1'`
21
22 if [ -n "$line" ]; then
23 echo "autocmd VimEnter * echo '`cat $error_output | grep line | head -n1`'" > $vimrc
24 vim +$line -u $vimrc $section_output
25 else
26 echo
27 echo "Template error: "
28 echo
29 echo ---
30 cat $section_output
31 cat $error_output
32 fi
33 else
34 echo
35 echo "Template error: "
36 echo
37 echo ---
38 cat $yaml_output
39 cat $error_output
40 fi
41else
42 cat $yaml_output
43
44 echo
45 echo "Syntax ok"
46fi