Commit 4d2716b6 authored by Pierre Smeyers's avatar Pierre Smeyers
Browse files

feat: support CA certs provided as file

parent aae92d34
Loading
Loading
Loading
Loading
+11 −11
Original line number Diff line number Diff line
@@ -210,6 +210,15 @@ stages:
    fi
  }

  function as_content() {
    file_or_content=$1
    if [[ -f "${file_or_content}" ]]; then
      cat "${file_or_content}"
    else
      echo "${file_or_content}"
    fi
  }

  function install_ca_certs() {
    certs=$1
    if [[ -z "$certs" ]]
@@ -218,25 +227,16 @@ stages:
    fi

    # import in system
    if echo "$certs" >> /etc/ssl/certs/ca-certificates.crt
    if as_content "$certs" >> /etc/ssl/certs/ca-certificates.crt
    then
      log_info "CA certificates imported in \\e[33;1m/etc/ssl/certs/ca-certificates.crt\\e[0m"
    fi
    if echo "$certs" >> /etc/ssl/cert.pem
    if as_content "$certs" >> /etc/ssl/cert.pem
    then
      log_info "CA certificates imported in \\e[33;1m/etc/ssl/cert.pem\\e[0m"
    fi
  }

  function as_content() {
    file_or_content=$1
    if [[ -f ${file_or_content} ]]; then
      cat "${file_or_content}"
    else
      echo "${file_or_content}"
    fi
  }

  function unscope_variables() {
    _scoped_vars=$(env | awk -F '=' "/^scoped__[a-zA-Z0-9_]+=/ {print \$1}" | sort)
    if [[ -z "$_scoped_vars" ]]; then return; fi