From 4eee2c2cb6c49f2d43a541a7e004bf308e8a0d3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arild=20H=C3=A5kon=20Olsen?= Date: Wed, 7 Feb 2024 09:01:04 +0100 Subject: [PATCH] Added presentation of dependecies --- CHANGELOG.md | 3 + smud-cli/functions-list.sh | 389 ++++++++++++++++++++++++++++--------- smud-cli/functions.sh | 6 +- smud-cli/include.sh | 2 +- smud-cli/smud.sh | 1 - 5 files changed, 306 insertions(+), 95 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 45bc2af..7b5fd65 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +## Version 1.0.11 +- Added presentation of dependecies + ## Version 1.0.10 - Improved list for SMUD-GitOps repository diff --git a/smud-cli/functions-list.sh b/smud-cli/functions-list.sh index 6101781..a0d590b 100644 --- a/smud-cli/functions-list.sh +++ b/smud-cli/functions-list.sh @@ -121,7 +121,6 @@ product_infos__find_latest_products_with_version() option="$1" product_name="" - commit_filter="$to_commit" pos_colon=2 progress_title="latest products with version" if [ "$option" = "installed" ]; then @@ -129,13 +128,14 @@ product_infos__find_latest_products_with_version() commit_filter="" pos_colon=1 else + commit_filter="$to_commit" if [ ! "$commit_filter" ]; then return fi fi - files_command="git --no-pager grep chartVersion $commit_filter -- :$app_files_filter" + app_files_command="git --no-pager grep 'chartVersion: $version' $commit_filter -- :$app_files_filter|uniq" { - run_command --files --command-var=files_command --return-var=changed_files --debug-title='Find all changed files' + run_command --files --command-var=app_files_command --return-var=changed_files --debug-title='Find all changed app files' } || { return } @@ -151,8 +151,25 @@ product_infos__find_latest_products_with_version() product_names=() fi - progressbar__init $line_numbers 100 + app_files_command="git --no-pager grep -B 0 -A 500 'dependencies:' $commit_filter -- :$app_files_filter|sed -e 's/.*:dependencies://g'|uniq" + run_command --files --command-var=app_files_command --return-var=dependencies_files --skip-error --debug-title='Find all dependencies app files' + if [ "$dependencies_files" ]; then + IFS=$'\n';read -rd '' -a dependencies_files <<< "$dependencies_files" + fi + if [ "$debug" ]; then + if [ "$changed_files" ]; then + print_gray "changed_files:" + print_gray "${changed_files[@]}" + fi + if [ "$dependencies_files" ]; then + print_gray "dependencies_files:" + echo "dependencies_files:\n "${dependencies_files[@]}"" + fi + fi + + progressbar__init $line_numbers 100 + product_info_dependencies="" i=0 for line in "${changed_files[@]}" do @@ -208,6 +225,31 @@ product_infos__find_latest_products_with_version() append_product "$file" "A" "$add_product" complete_version done + if [ "$dependencies_files" ]; then + product_info_dependencies="" + for line in "${dependencies_files[@]}" + do + c=$(expr match $line '.*/app\.yaml') + if [ $c -gt 0 ]; then + file="${line:0:$c}" + local dependency="${line:$((c+1))}" + local dependency=$(echo "$dependency"|sed -e 's/\r//g'|xargs) + + if [ "$dependency" ] && [ "${dependency:0:1}" = "-" ]; then + local dependency="$( echo "${dependency:1}"|sed -e 's/\r//g'|xargs)" + product_name="$(echo "$file" | cut -d '/' -f 2)" + product_stage="$(echo "$file" | cut -d '/' -f 3)" + local stage_product_name="$product_name/$product_stage" + # echo "stage_product_name: $stage_product_name, dependency: $dependency" + append_product_depenencies "$dependency" "$stage_product_name" + # echo "depedencies_return: $depedencies_return" + product_info=${product_infos[$stage_product_name]} + complete_version + # echo "xxx: ${product_infos[$stage_product_name]}" + fi + fi + done + fi progressbar__end "" "Time to resolve $progress_title took" @@ -323,10 +365,12 @@ product_infos__print_debug() product_infos__print() { + max_cols=$(echo $(/usr/bin/tput cols)) n_products_len=40 n_current_ver_len=14 n_latest_ver_len=14 n_tags_len=10 + n_dependencies_len=$((max_len_of_depenencies+2)) printed_product="" iMajorTot=0 iMinorTot=0 @@ -347,7 +391,7 @@ product_infos__print() if [ "$product_stage" = "internal-test" ]; then has_internal_test="true"; fi if [ "$product_stage" = "external-test" ]; then has_external_test="true"; fi if [ "$product_stage" = "production" ]; then has_production="true"; fi - + if [ "$prev" = "external-test" ] && [ "$product_stage" = "internal-test" ]; then ordered_product_stages[$iPrev]="$product_stage" ordered_product_stages[$i]="$prev" @@ -389,9 +433,10 @@ product_infos__print() product_latest_version="" product_latest_commit="" current_version="" - local latest_version="" + latest_version="" commit="" files="" + local product_dependencies="" product_info=${product_infos[${stage_product_name}]} if [ ! "$product_info" ]; then # echo "Not found : $stage_product_name" @@ -401,7 +446,7 @@ product_infos__print() # echo "Found : $stage_product_name" product_info__get_current_version product_info current_version if [ ! "$current_version" ]; then - current_version="$(get_current_version)" + get_current_version product_info stage_product_name current_version fi if [ "$show_latest_version_in_list" = "true" ]; then @@ -413,13 +458,12 @@ product_infos__print() else latest_version="" if [ "$product_stage" = "development" ] && [ "$has_internal_test" ]; then - latest_version="$(get_next_stage_version "$product_name/internal-test")" + get_next_stage_version "$product_name/internal-test" latest_version latest_version_header_text="INT-TEST VER." show_latest_version_in_list="show" show_tags_in_list="show" - fi - if ([ "$product_stage" = "internal-test" ] || [ "$product_stage" = "production" ]) && [ "$has_external_test" ]; then - latest_version="$(get_next_stage_version "$product_name/external-test")" + elif ([ "$product_stage" = "internal-test" ] || [ "$product_stage" = "production" ]) && [ "$has_external_test" ]; then + get_next_stage_version "$product_name/external-test" latest_version show_latest_version_in_list="show" show_tags_in_list="show" latest_version_header_text="EXT-TEST VER." @@ -427,19 +471,24 @@ product_infos__print() show_tags_in_list="reverse" fi - fi - if [ "$product_stage" = "external-test" ] && [ "$has_production" ]; then - latest_version="$(get_next_stage_version "$product_name/production")" + elif [ "$product_stage" = "external-test" ] && [ "$has_production" ]; then + get_next_stage_version "$product_name/production" latest_version show_latest_version_in_list="show" show_tags_in_list="show" latest_version_header_text="PROD VER." fi fi + product_info__get_dependencies product_info product_dependencies + # if [ "$product_dependencies" ]; then + # product_dependencies="[$product_dependencies]" + # # echo "product_dependencies($stage_product_name): $product_info" + # # exit + # fi if [ "$show_files" ]; then product_info__get_latest_files product_info files fi - + if [ "$new" ] && [ "$current_version" ];then continue @@ -506,8 +555,12 @@ product_infos__print() if [ "$show_tags_in_list" ]; then tags_header="`printf %-${n_tags_len}s "TAGS"`" fi + dependencies_header="" + if [ $max_len_of_depenencies -gt 0 ]; then + dependencies_header="`printf %-${n_dependencies_len}s "DEPENDENCIES"`" + fi - printf "`printf %-${n_products_len}s "PRODUCTS"` $tags_header `printf %-${n_current_ver_len}s "CURRENT VER."` $latest_version_header $files_header\n" + printf "`printf %-${n_products_len}s "PRODUCTS"` $tags_header `printf %-${n_current_ver_len}s "CURRENT VER."` $latest_version_header $dependencies_header$files_header\n" printed_product_header="true" fi @@ -531,13 +584,27 @@ product_infos__print() print_tags=`printf %-${n_tags_len}s "$tags"` fi + print_dependencies="" + if [ "$dependencies_header" ]; then + print_dependencies=`printf %-${n_dependencies_len}s "$product_dependencies"` + fi + print_files=""; if [ "$files_header" ]; then print_files="$(echo "$files" | sed -e $replace_regex)" fi - printf "$print_product_name $print_tags $print_current_version $print_latest_version $print_files\n" + line="$print_product_name $print_tags $print_current_version $print_latest_version $print_dependencies" + line_full="$line$print_files" + # echo "${#line_full} $max_cols" + if [ ! ${#line_full} -gt $max_cols ]; then + printf "$line_full\n" + else + w=$(expr $max_cols - 5) + # echo "w: $w -- $max_cols" + printf "${line_full:0:$w}...\n" + fi done summarize="" if [ $iProducts -gt 0 ];then summarize="${summarize} Products:$iProducts |"; fi @@ -580,15 +647,11 @@ product_infos__print() } get_next_stage_version() { - local next_stage_product_name=$1 - - local next_product_info=${product_infos[${next_stage_product_name}]} - local next_latest_version="" - if [ "$next_product_info" ]; then - local next_latest_version="$(get_current_version next_product_info next_stage_product_name)" - fi - echo "$next_latest_version" - + local getnextstageversion__stage_product_name="$1" + local -n getnextstageversion__next_version="$2" + local next_product_info=${product_infos[${getnextstageversion__stage_product_name}]} + get_current_version next_product_info getnextstageversion__stage_product_name getnextstageversion__next_version + # echo "get_next_stage_version($getnextstageversion__next_version) - [$1,$2]" } get_tags() @@ -625,26 +688,42 @@ get_tags() } get_product_info() { - local -n get_product_info__local_product_info=$1 - if [ ! "$get_product_info__local_product_info" ] && [ "$stage_product_name" ]; then - get_product_info__local_product_info="${product_infos[${stage_product_name}]}" + local -n getproductinfo__product_info=$1 + if [ "$2" ]; then + local -n getproductinfo__stage_product_name=$2 + else + local getproductinfo__stage_product_name="$stage_product_name" + fi + if [ ! "$getproductinfo__product_info" ] && [ "$getproductinfo__stage_product_name" ]; then + getproductinfo__product_info="${product_infos[${getproductinfo__stage_product_name}]}" fi } create_product_info() { - local -n create_product_info__local_product_info=$1 - create_product_info__local_product_info="$product_latest_date|$current_version|$product_latest_version|$product_latest_commit|$product_info_files" + local -n createproductinfo__local_product_info=$1 + createproductinfo__local_product_info="$product_latest_date|$current_version|$product_latest_version|$product_latest_commit|$product_info_files|$product_info_dependencies" + # echo "create_product_info()...[$product_info_dependencies]" } set_product_info() -{ - if [ ! "$product_info" ] && [ "$stage_product_name" ]; then - get_product_info product_info - if [ ! "$product_info" ]; then - product_info=${product_infos[${stage_product_name}]} +{ if [ "$1" ]; then + local -n setproductinfo__product_info=$1 + else + local setproductinfo__product_info=$product_info + fi + if [ "$2" ]; then + local -n setproductinfo__stage_product_name=$2 + else + local setproductinfo__stage_product_name=$stage_product_name + fi + + if [ ! "$setproductinfo__product_info" ] && [ "$setproductinfo__stage_product_name" ]; then + get_product_info setproductinfo__product_info setproductinfo__stage_product_name + if [ ! "$setproductinfo__product_info" ]; then + setproductinfo__product_info=${product_infos[${setproductinfo__stage_product_name}]} fi fi @@ -655,35 +734,90 @@ set_product_info() get_current_version() { - product_info_var=$1 + getcurrentversion__product_info=$1 if [ "$1" ]; then - local -n product_info_var=$1 - local current_version="" + local -n getcurrentversion__product_info="$1" else - local product_info_var="$product_info" + local getcurrentversion__product_info="$product_info" fi if [ "$2" ]; then - local -n stage_product_name_var=$2 + local -n getcurrentversion__stage_product_name="$2" + else + local getcurrentversion__stage_product_name="$stage_product_name" + fi + + if [ "$3" ]; then + local -n getcurrentversion__current_version="$3" else - local stage_product_name_var="$stage_product_name" + local getcurrentversion__current_version="$current_version" fi - if [ ! "$current_version" ] && [ "$stage_product_name_var" ]; then - get_product_info product_info_var - if [ "$product_info_var" ]; then - product_info__get_current_version product_info_var current_version + if [ "$4" ]; then + local -n getcurrentversion__depedencies="$4" + else + local getcurrentversion__depedencies="$product_info_dependencies" + fi + + + if [ ! "$getcurrentversion__current_version" ] && [ "$getcurrentversion__stage_product_name" ]; then + get_product_info getcurrentversion__product_info getcurrentversion__stage_product_name + if [ "$getcurrentversion__product_info" ]; then + product_info__get_current_version getcurrentversion__product_info getcurrentversion__current_version fi - if [ ! "$current_version" ] ; then - app_file="products/$stage_product_name_var/app.yaml" + if [ ! "$getcurrentversion__current_version" ] ; then + local app_file="products/$getcurrentversion__stage_product_name/app.yaml" if [ -f $app_file ]; then - current_version=`cat $app_file | grep chartVersion: | cut -d ':' -f 2 |xargs|sed -e 's/"//g'|xargs|tr -d ['\n','\r'] |cut -d '#' -f 1 |xargs` - if [ "$current_version" ] && [ ! "$1$2" ]; then - set_product_info + local app_yaml_content="`cat $app_file`" + getcurrentversion__current_version="`echo "$app_yaml_content" | grep 'chartVersion:' | cut -d ':' -f 2 |xargs|sed -e 's/"//g' -e 's/\r//g' |xargs|tr -d ['\n','\r'] |cut -d '#' -f 1 |xargs`" + # echo "HIT: [$getcurrentversion__current_version]" + if [ "$4" ]; then + get_depedencies app_yaml_content getcurrentversion__depedencies + fi + if [ "$getcurrentversion__current_version" ]; then + current_version="$getcurrentversion__current_version" + set_product_info getcurrentversion__product_info getcurrentversion__stage_product_name fi fi fi fi - echo "$current_version" + + if [ ! "$3" ]; then + echo "$getcurrentversion__current_version" + fi +} + +get_depedencies() +{ + local -n getdepedencies__app_yaml_content=$1 + local -n getdepedencies__depedencies=$2 + local getdepedencies__depedencies_arr=() + local getdepedencies__depedencies="$(echo "$getdepedencies__app_yaml_content" | grep 'dependencies:' -A 500| sed -e 's/dependencies://g')" + + if [ ! "$getdepedencies__depedencies" ]; then + return + fi + IFS=$'\n';read -rd '' -a getdepedencies__depedencies_arr <<< "$getdepedencies__depedencies" + array=() + for e in "${getdepedencies__depedencies_arr[@]}"; + do + e="$(echo "$e"|sed -e 's/\r//g'|xargs)" + + local c=$(echo "$e" | grep '-' -c) + if [ $c -gt 0 ]; then + e="$( echo "${e:1}" | xargs)" + array+=("$e") + # echo "$e -- new product" + # else + # echo "$e" + fi + done + getdepedencies__depedencies="${array[@]}" + # echo "XXX: $getdepedencies__depedencies" + l=${#getdepedencies__depedencies} + if [ $l -gt $max_len_of_depenencies ]; then + max_len_of_depenencies=$l + fi + } get_latest_version() @@ -691,15 +825,15 @@ get_latest_version() if [ ! "$product_latest_version" ] && [ "$stage_product_name" ] && [ ! "$is_smud_dev_repo" ]; then # echo "stage_product_name: $stage_product_name , file: $file" if [ "$1" ]; then - local -n product_latest_version_local=$1 + local -n getlatestversion__latest_version=$1 else - product_latest_version_local="" + getlatestversion__latest_version="" fi - get_product_info product_info + get_product_info product_info stage_product_name if [ "$product_info" ]; then - product_info__get_latest_version product_info product_latest_version_local + product_info__get_latest_version product_info getlatestversion__latest_version local product_latest_commit_local=$product_latest_commit - if [ ! "$product_latest_version_local" ]; then + if [ ! "$getlatestversion__latest_version" ]; then if [ ! "$file" ]; then file="products/$stage_product_name/app.yaml" c=1 @@ -728,11 +862,11 @@ get_latest_version() latest_version_command="git --no-pager grep "chartVersion:" $product_latest_commit_local:$file" { - run_command --latest_version --command-var=latest_version_command --return-var=product_latest_version_local --debug-title='Find latest versions from conent' - # echo "product_latest_version_local(0): '$product_latest_version_local'" - product_latest_version_local="$(echo "$product_latest_version_local" | cut -d ':' -f 4 | sed -e 's/"//g'|xargs)" - product_latest_version=$product_latest_version_local - # echo "product_latest_version_local(1): '$product_latest_version_local'" + run_command --latest_version --command-var=latest_version_command --return-var=getlatestversion__latest_version --debug-title='Find latest versions from conent' + # echo "getlatestversion__latest_version(0): '$getlatestversion__latest_version'" + getlatestversion__latest_version="$(echo "$getlatestversion__latest_version" | cut -d ':' -f 4 | sed -e 's/"//g'|xargs)" + product_latest_version=$getlatestversion__latest_version + # echo "getlatestversion__latest_version(1): '$getlatestversion__latest_version'" set_product_info } || { return @@ -742,7 +876,7 @@ get_latest_version() fi fi fi - product_latest_version=$product_latest_version_local + product_latest_version=$getlatestversion__latest_version if [ ! "$1" ]; then echo "$product_latest_version" fi @@ -751,9 +885,9 @@ get_latest_version() append_product_files() { if [ "$3" ];then - local -n append_product_files_return_value=$3 + local -n appendproductfiles__return_value=$3 fi - append_product_files_return_value="false" + appendproductfiles__return_value="false" file_to_append="$1" if [ ! "$file_to_append" ]; then file_to_append=$file @@ -768,48 +902,110 @@ append_product_files() fi # echo "file_to_append: $file_to_append ($file_state_to_append) => [$stage_product_name]: '$product_info'" - if [ "$product_info" ]; then - product_info__get_latest_files product_info product_info_files - old=$product_info_files + local files__product_info="${product_infos[$stage_product_name]}" + local files__product_info_files="" + if [ "$files__product_info" ]; then + product_info__get_latest_files files__product_info files__product_info_files + old=$files__product_info_files - if [ "$product_info_files" ]; then - c=$(echo "$product_info_files" | grep $file_to_append -c) + if [ "$files__product_info_files" ]; then + c=$(echo "$files__product_info_files" | grep $file_to_append -c) # echo "c:$c, old:$old, file_to_append:$file_to_append" if [ $c -eq 0 ]; then if [ ! "$file_state_to_append" = "D" ]; then - product_info_files="$(echo "$product_info_files $file_to_append" | xargs)" + files__product_info_files="$(echo "$files__product_info_files $file_to_append" | xargs)" fi elif [ "$file_state_to_append" = "D" ]; then replace_regex="s/$(echo "$file_to_append"|sed -e 's/\//\\\//g'|sed -e 's/\./\\\./g' )//g" # echo "replace_regex: $replace_regex" - changed_product_info_files="$(echo "$product_info_files" | sed -e $replace_regex | xargs)" - # echo "product_info_files: [$product_info_files], changed_product_info_files=[$changed_product_info_files]" - product_info_files=$changed_product_info_files + changed_product_info_files="$(echo "$files__product_info_files" | sed -e $replace_regex | xargs)" + # echo "files__product_info_files: [$files__product_info_files], changed_product_info_files=[$changed_product_info_files]" + files__product_info_files=$changed_product_info_files fi elif [ ! "$file_state_to_append" = "D" ]; then - product_info_files="$file_to_append" + files__product_info_files="$file_to_append" fi - if [ ! "$old" = "$product_info_files" ]; then - product_info_files="$(echo "$product_info_files"|xargs)" - create_product_info product_info - product_infos[$stage_product_name]=$product_info - append_product_files_return_value="true" + if [ ! "$old" = "$files__product_info_files" ]; then + # echo "¤¤¤ files-pre($stage_product_name): $files__product_info" + product_info_files="$(echo "$files__product_info_files"|xargs)" + product_info__get_current_version files__product_info current_version + product_info__get_latest_version files__product_info product_latest_version + product_info__get_dependencies files__product_info product_info_dependencies + + create_product_info files__product_info + # echo "¤¤¤ files-post($stage_product_name): $files__product_info" + product_infos[$stage_product_name]=$files__product_info + appendproductfiles__return_value="true" fi else - product_info_files="" + files__product_info_files="" fi } +max_len_of_depenencies=0 +append_product_depenencies() +{ + if [ ! "$1" ]; then + return + fi + if [ ! "$2" ]; then + return + fi + local dependency_to_append="$1" + local depenency_stage_product_name="$2" + if [ "$3" ];then + local -n appendproductdepenencies__return_value=$3 + fi + appendproductdepenencies__return_value="false" + local depenency__product_info="${product_infos[$depenency_stage_product_name]}" + local depenency__product_info_dependencies="" + if [ "$depenency__product_info" ]; then + product_info__get_dependencies depenency__product_info depenency__product_info_dependencies + old=$depenency__product_info_dependencies + + # echo "*** depenency__product_info($depenency_stage_product_name): $depenency__product_info -- depenencies: $depenency__product_info_dependencies" + + if [ "$depenency__product_info_dependencies" ]; then + c=$(echo "$depenency__product_info_dependencies" | grep $dependency_to_append -c) + + # echo "c:$c, old:$old, dependency_to_append:$dependency_to_append" + if [ $c -eq 0 ]; then + depenency__product_info_dependencies="$(echo "$depenency__product_info_dependencies $dependency_to_append" | xargs)" + fi + else + depenency__product_info_dependencies="$dependency_to_append" + fi + + if [ ! "$old" = "$depenency__product_info_dependencies" ]; then + product_info_dependencies="$(echo "$depenency__product_info_dependencies"|xargs)" + l=${#product_info_dependencies} + if [ $l -gt $max_len_of_depenencies ]; then + max_len_of_depenencies=$l + fi + product_info__get_current_version depenency__product_info current_version + product_info__get_latest_version depenency__product_info product_latest_version + product_info__get_latest_files depenency__product_info product_info_files + create_product_info depenency__product_info + # echo "### HIT: $product_info_dependencies" + # echo "¤¤¤ depenencies($depenency_stage_product_name): $depenency__product_info" + product_infos[$depenency_stage_product_name]=$depenency__product_info + appendproductdepenencies__return_value="true" + fi + else + depenency__product_info_dependencies="" + fi +} + append_product() { if [ "$4" ];then - local -n append_product_return_value=$4 + local -n appendproduct__return_value=$4 fi - append_product_return_value="false" + appendproduct__return_value="false" local product_info_created=0 if [ ! "$product_info" ] && [ "$stage_product_name" ]; then product_info=${product_infos[${stage_product_name}]} @@ -820,11 +1016,12 @@ append_product() product_info_created=1 create_product_info product_info product_infos[$stage_product_name]=$product_info - append_product_return_value="true" + appendproduct__return_value="true" fi fi if [ $product_info_created -eq 0 ]; then product_info__get_latest_version product_info product_latest_version + product_info__get_dependencies product_info product_info_dependencies fi file_to_append="$1" @@ -842,10 +1039,10 @@ append_product() file_state_to_append="A" fi - append_product_files "$file_to_append" "$file_status_to_append" append_product_append_product_files_return_value + append_product_files "$file_to_append" "$file_status_to_append" append_product_appendproductfiles__return_value - if [ "$append_product_return_value" = "false" ]; then - append_product_return_value=$append_product_append_product_files_return_value + if [ "$appendproduct__return_value" = "false" ]; then + appendproduct__return_value=$append_product_appendproductfiles__return_value fi } @@ -855,7 +1052,7 @@ complete_version() { if [ "$stage_product_name" ]; then if [ ! "$product_info" ];then - get_product_info product_info + get_product_info product_info stage_product_name fi if [ ! "$product_info" ];then @@ -864,9 +1061,11 @@ complete_version() product_info__get_latest_files product_info product_info_files product_info__get_latest_version product_info product_latest_version product_info__get_current_version product_info current_version + product_info__get_dependencies product_info product_info_dependencies create_product_info product_info fi - + # echo "complete_version:" + # echo "current_version: $current_version" product_infos[$stage_product_name]=$product_info if [ "$1" ]; then echo "complete_version(): product_name: '$product_name', current_version: '$current_version' , product_info_files:$product_info_files, product_info: '$product_info' }" @@ -884,6 +1083,7 @@ complete_version() product_latest_version="" product_latest_date="" stage_product_name="" + product_info_dependencies="" } @@ -912,7 +1112,7 @@ product_info__get_latest_commit_date() product_info__get_field local_product_info local_value 1 } -# create_product_info__local_product_info="$product_latest_date|$current_version|$product_latest_version|$product_latest_commit|$product_info_files" +# createproductinfo__local_product_info="$product_latest_date|$current_version|$product_latest_version|$product_latest_commit|$product_info_files" product_info__get_current_version() { # [|$current_version|||] @@ -949,5 +1149,14 @@ product_info__get_latest_files() product_info__get_field local_product_info local_value 5 } +product_info__get_dependencies() +{ + # [||||$product_info_files] + local -n local_product_info=$1 + local -n local_value=$2 + + product_info__get_field local_product_info local_value 6 +} + diff --git a/smud-cli/functions.sh b/smud-cli/functions.sh index 977db9b..b6507ce 100644 --- a/smud-cli/functions.sh +++ b/smud-cli/functions.sh @@ -50,7 +50,7 @@ get_changelog_file() help() { - version="$(changelog_get_current_version)" + version="$(changelog_get_version)" # Print information echo "${bold}smud${normal}: Help dealing with products in the GitOps repository." @@ -76,7 +76,7 @@ show_invalid_command() show_valid_commands } -changelog_get_current_version() +changelog_get_version() { file=$1 if [ ! "$file" ]; then @@ -97,7 +97,7 @@ version() if [ $file ]; then changes=(`cat $file |sed -e 's/## Version /\n/g'`) printf "${bold}smud version${normal}: Show the version of smud CLI\n" - echo "Current Version "$(changelog_get_current_version)"" + echo "Current Version "$(changelog_get_version)"" echo "" echo "Changelog:" cat $file| sed -e 's/## //g' diff --git a/smud-cli/include.sh b/smud-cli/include.sh index fd9292e..20268c3 100644 --- a/smud-cli/include.sh +++ b/smud-cli/include.sh @@ -481,7 +481,7 @@ if [ $has_args ] && [ ! $help ] && [ "$is_repo" ]; then fi if [ "$version" ]; then git_grep_version=-GchartVersion:.$version - git_grep="$git_grep $git_grep_version" + git_grep="$(echo "$git_grep $git_grep_version" | xargs)" fi fi diff --git a/smud-cli/smud.sh b/smud-cli/smud.sh index 8451294..693b9d6 100644 --- a/smud-cli/smud.sh +++ b/smud-cli/smud.sh @@ -11,7 +11,6 @@ command=$1 print_verbose "\n${bold}command: $command\n" - if [ ! $command ] ; then help else