@@ -8,11 +8,9 @@ source scripts/funcs/checks
88source scripts/funcs/printing
99source scripts/funcs/kubernetes
1010
11- # Parse command line arguments
1211CONTAINER_RUNTIME=" ${CONTAINER_RUNTIME-" docker" } "
1312
14- # Validate and set up container runtime configuration
15- setup_container_runtime () {
13+ setup_validate_container_runtime () {
1614 case " ${CONTAINER_RUNTIME} " in
1715 " podman" )
1816 if ! command -v podman & > /dev/null; then
@@ -38,7 +36,6 @@ setup_container_runtime() {
3836 ;;
3937 esac
4038
41- # Create config directory
4239 if [[ " $USE_SUDO " == " true" ]]; then
4340 sudo mkdir -p " $( dirname " ${CONFIG_PATH} " ) "
4441 else
@@ -76,51 +73,20 @@ write_file() {
7673 fi
7774}
7875
79- check_docker_daemon_is_running () {
80- if [[ " ${CONTAINER_RUNTIME} " == " podman" ]]; then
81- # Podman doesn't require a daemon
82- echo " Using Podman (no daemon required)"
83- return 0
84- fi
85-
86- if [[ " $( uname -s) " != " Linux" ]]; then
87- echo " Skipping docker daemon check when not running in Linux"
88- return 0
89- fi
90-
91- if systemctl is-active --quiet docker; then
92- echo " Docker is already running."
93- else
94- echo " Docker is not running. Starting Docker..."
95- # Start the Docker daemon
96- sudo systemctl start docker
97- for _ in {1..15}; do
98- if systemctl is-active --quiet docker; then
99- echo " Docker started successfully."
100- return 0
101- fi
102- echo " Waiting for Docker to start..."
103- sleep 3
104- done
105- fi
106- }
107-
10876remove_element () {
10977 local config_option=" $1 "
110- local tmpfile=$( mktemp)
78+ local tmpfile
79+ tmpfile=$( mktemp)
11180
112- # Initialize config file if it doesn't exist
11381 if [[ ! -f " ${CONFIG_PATH} " ]]; then
11482 write_file ' {}' " ${CONFIG_PATH} "
11583 fi
11684
117- # Remove the specified element using jq
11885 exec_cmd jq ' del(.' " ${config_option} " ' )' " ${CONFIG_PATH} " > " ${tmpfile} "
11986 exec_cmd cp " ${tmpfile} " " ${CONFIG_PATH} "
12087 rm " ${tmpfile} "
12188}
12289
123- # Container runtime login wrapper
12490container_login () {
12591 local username=" $1 "
12692 local registry=" $2 "
@@ -132,21 +98,14 @@ container_login() {
13298 fi
13399}
134100
135- # This is the script which performs container authentication to different registries that we use (so far ECR and RedHat)
136- # As the result of this login the config file will have all the 'auth' information necessary to work with container registries
137-
138- setup_container_runtime
139-
140- check_docker_daemon_is_running
101+ setup_validate_container_runtime
141102
142- # Initialize config file if it doesn't exist
143103if [[ ! -f " ${CONFIG_PATH} " ]]; then
144104 write_file ' {}' " ${CONFIG_PATH} "
145105fi
146106
147107if [[ -f " ${CONFIG_PATH} " ]]; then
148108 if [[ " ${RUNNING_IN_EVG:- " false" } " != " true" ]]; then
149- # Check if login is actually required by making a HEAD request to ECR using existing credentials
150109 echo " Checking if container registry credentials are valid..."
151110 ecr_auth=$( exec_cmd jq -r ' .auths."268558157000.dkr.ecr.us-east-1.amazonaws.com".auth // empty' " ${CONFIG_PATH} " )
152111
0 commit comments