##// END OF EJS Templates
feat(stack): added new cli cmd option to run a custom command on top of image...
super-admin -
Show More
@@ -875,6 +875,7 b' rcstack_cli_usage() {'
875 echo
875 echo
876 # :command.usage_commands
876 # :command.usage_commands
877 printf "%s\n" "Commands:"
877 printf "%s\n" "Commands:"
878 printf " %s run a custom command on top of docker image from RhodeCode\n" "cmd "
878 printf " %s print out stored docker image version\n" "image-info "
879 printf " %s print out stored docker image version\n" "image-info "
879 printf " %s set version to .runtime.env file\n" "set-runtime-image "
880 printf " %s set version to .runtime.env file\n" "set-runtime-image "
880 printf " %s get current docker info\n" "docker-info "
881 printf " %s get current docker info\n" "docker-info "
@@ -903,6 +904,49 b' rcstack_cli_usage() {'
903 }
904 }
904
905
905 # :command.usage
906 # :command.usage
907 rcstack_cli_cmd_usage() {
908 if [[ -n $long_usage ]]; then
909 printf "rcstack cli cmd - run a custom command on top of docker image from RhodeCode\n"
910 echo
911
912 else
913 printf "rcstack cli cmd - run a custom command on top of docker image from RhodeCode\n"
914 echo
915
916 fi
917
918 printf "%s\n" "Usage:"
919 printf " rcstack cli cmd [OPTIONS] [CALL ARGUMENTS...]\n"
920 printf " rcstack cli cmd --help | -h\n"
921 echo
922
923 # :command.long_usage
924 if [[ -n $long_usage ]]; then
925 printf "%s\n" "Options:"
926
927 # :command.usage_flags
928 # :flag.usage
929 printf " %s\n" "--env-file-path ENV_FILE_PATH"
930 printf " Set custom env file\n"
931 printf " Default: $PWD/.custom/.runtime.env\n"
932 echo
933
934 # :command.usage_fixed_flags
935 printf " %s\n" "--help, -h"
936 printf " Show this help\n"
937 echo
938
939 # :command.usage_args
940 printf "%s\n" "Arguments:"
941
942 echo " CALL ARGUMENTS..."
943 printf " call arguments\n"
944 echo
945
946 fi
947 }
948
949 # :command.usage
906 rcstack_cli_image_info_usage() {
950 rcstack_cli_image_info_usage() {
907 if [[ -n $long_usage ]]; then
951 if [[ -n $long_usage ]]; then
908 printf "rcstack cli image-info - print out stored docker image version\n"
952 printf "rcstack cli image-info - print out stored docker image version\n"
@@ -3517,6 +3561,45 b' rcstack_stack_monitor_restart_unhealthy_command() {'
3517 }
3561 }
3518
3562
3519 # :command.function
3563 # :command.function
3564 rcstack_cli_cmd_command() {
3565 # src/cli_cmd_command.sh
3566 check_bootstrap
3567
3568 DEBUG=${args[--debug]}
3569 ENV_FILE=${args[--env-file-path]}
3570
3571 printf "attaching $PWD/config/_shared \t\tunder: /vol/confvolume\n"
3572
3573 #printf "attaching rc_reposvolume \t\tunder: /vol/repovolume\n"
3574 #printf "attaching \$PWD/.custom/storage \t\tunder: /vol/backupvolume\n"
3575
3576 if [ ${#other_args[@]} -eq 0 ]; then
3577 other_args[${#other_args[@]}]="echo 'please provide a valid cmd arg...'"
3578 fi
3579
3580 CMD_RHODECODE="\
3581 RC_ENV_FILE=$ENV_FILE docker compose \
3582 --env-file $ENV_FILE \
3583 $ENV_EXPAND \
3584 -p cmd-run \
3585 -f docker-compose-base.yaml \
3586 -f docker-compose-apps.yaml \
3587 run \
3588 --volume=$PWD/config/_shared:/vol/confvolume \
3589 --workdir=/vol/confvolume \
3590 -it \
3591 vcsserver"
3592
3593 if [[ $DEBUG ]]; then
3594 echo $CMD_RHODECODE
3595 echo ${other_args[*]}
3596 fi
3597
3598 eval "${CMD_RHODECODE} ${other_args[*]}"
3599
3600 }
3601
3602 # :command.function
3520 rcstack_cli_image_info_command() {
3603 rcstack_cli_image_info_command() {
3521 # src/cli_image_info_command.sh
3604 # src/cli_image_info_command.sh
3522
3605
@@ -5687,6 +5770,13 b' rcstack_cli_parse_requirements() {'
5687 case $action in
5770 case $action in
5688 -*) ;;
5771 -*) ;;
5689
5772
5773 cmd)
5774 action="cmd"
5775 shift
5776 rcstack_cli_cmd_parse_requirements "$@"
5777 shift $#
5778 ;;
5779
5690 image-info)
5780 image-info)
5691 action="image-info"
5781 action="image-info"
5692 shift
5782 shift
@@ -5815,6 +5905,75 b' rcstack_cli_parse_requirements() {'
5815 }
5905 }
5816
5906
5817 # :command.parse_requirements
5907 # :command.parse_requirements
5908 rcstack_cli_cmd_parse_requirements() {
5909 # :command.fixed_flags_filter
5910 while [[ $# -gt 0 ]]; do
5911 case "${1:-}" in
5912 --help | -h)
5913 long_usage=yes
5914 rcstack_cli_cmd_usage
5915 exit
5916 ;;
5917
5918 *)
5919 break
5920 ;;
5921
5922 esac
5923 done
5924
5925 # :command.command_filter
5926 action="cli cmd"
5927
5928 # :command.parse_requirements_while
5929 while [[ $# -gt 0 ]]; do
5930 key="$1"
5931 case "$key" in
5932 # :flag.case
5933 --env-file-path)
5934
5935 # :flag.case_arg
5936 if [[ -n ${2+x} ]]; then
5937 # :flag.validations
5938 if [[ -n $(validate_file_exists "$2") ]]; then
5939 printf "validation error in %s:\n%s\n" "--env-file-path ENV_FILE_PATH" "$(validate_file_exists "$2")" >&2
5940 exit 1
5941 fi
5942
5943 args['--env-file-path']="$2"
5944 shift
5945 shift
5946 else
5947 printf "%s\n" "--env-file-path requires an argument: --env-file-path ENV_FILE_PATH" >&2
5948 exit 1
5949 fi
5950 ;;
5951
5952 --)
5953 shift
5954 other_args+=("$@")
5955 break
5956 ;;
5957
5958 -?*)
5959 other_args+=("$1")
5960 shift
5961 ;;
5962
5963 *)
5964 # :command.parse_requirements_case
5965 # :command.parse_requirements_case_catch_all
5966 other_args+=("$1")
5967 shift
5968
5969 ;;
5970
5971 esac
5972 done
5973
5974 }
5975
5976 # :command.parse_requirements
5818 rcstack_cli_image_info_parse_requirements() {
5977 rcstack_cli_image_info_parse_requirements() {
5819 # :command.fixed_flags_filter
5978 # :command.fixed_flags_filter
5820 while [[ $# -gt 0 ]]; do
5979 while [[ $# -gt 0 ]]; do
@@ -7230,6 +7389,7 b' run() {'
7230 "stack-monitor") rcstack_stack_monitor_command ;;
7389 "stack-monitor") rcstack_stack_monitor_command ;;
7231 "stack-monitor restart-unhealthy") rcstack_stack_monitor_restart_unhealthy_command ;;
7390 "stack-monitor restart-unhealthy") rcstack_stack_monitor_restart_unhealthy_command ;;
7232 "cli") rcstack_cli_command ;;
7391 "cli") rcstack_cli_command ;;
7392 "cli cmd") rcstack_cli_cmd_command ;;
7233 "cli image-info") rcstack_cli_image_info_command ;;
7393 "cli image-info") rcstack_cli_image_info_command ;;
7234 "cli set-runtime-image") rcstack_cli_set_runtime_image_command ;;
7394 "cli set-runtime-image") rcstack_cli_set_runtime_image_command ;;
7235 "cli docker-info") rcstack_cli_docker_info_command ;;
7395 "cli docker-info") rcstack_cli_docker_info_command ;;
General Comments 0
You need to be logged in to leave comments. Login now