Skip to content

Commit

Permalink
Inherit DOMAIN from parent container for /ssh-command/get.sh (#153)
Browse files Browse the repository at this point in the history
  • Loading branch information
felipecrs authored May 3, 2024
1 parent 7746f33 commit 4209251
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
3 changes: 3 additions & 0 deletions devcontainer/rootfs/etc/s6-overlay/s6-rc.d/sshd/condition.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,8 @@ fi
# Needed for situations like:
# docker run --rm -v /ssh-command:/ssh-command ubuntu /ssh-command/get.sh
echo "${USER}" >/ssh-command/user
if [[ -n "${DOMAIN:-}" ]]; then
echo "${DOMAIN}" >/ssh-command/domain
fi

exit 0
13 changes: 10 additions & 3 deletions devcontainer/rootfs/ssh-command/get.sh
Original file line number Diff line number Diff line change
Expand Up @@ -112,14 +112,21 @@ else
readonly node_host
fi

if [[ -f "${script_dir}/domain" ]]; then
domain="$(cat "${script_dir}/domain")"
else
domain=""
fi
readonly domain

# Check if node_host is a fully qualified domain name (have a dot)
if [[ "${node_host}" == *.* ]]; then
readonly node_fqdn="${node_host}"
if [[ -n "${DOMAIN:-}" ]]; then
if [[ -n "${domain}" ]]; then
log_info "Ignoring the DOMAIN env var because the inferred node hostname seems to be a fully qualified domain name."
fi
elif [[ -n "${DOMAIN:-}" ]]; then
readonly node_fqdn="${node_host}.${DOMAIN}"
elif [[ -n "${domain}" ]]; then
readonly node_fqdn="${node_host}.${domain}"
log_info "Using the DOMAIN env var to build the node's fully qualified domain name."
else
readonly node_fqdn="${node_host}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ pipeline {
sh 'printenv | sort | tee /dev/stderr | grep -q ^USER='
sh 'docker version'
sh 'IGNORE_FAILURE=false /ssh-command/get.sh'
sh 'IGNORE_FAILURE=false DOMAIN=localdev /ssh-command/get.sh'
}
}
stage ('nested dond') {
Expand All @@ -49,7 +48,7 @@ pipeline {
docker {
reuseNode true
image 'localhost:15432/jenkins-agent-dind:latest'
args "--privileged --group-add=docker --env=SSHD_ENABLED=true --publish=^${env.SSHD_PORT}:22"
args "--privileged --group-add=docker --env=SSHD_ENABLED=true --publish=^${env.SSHD_PORT}:22 --env=DOMAIN=example.com"
}
}
steps {
Expand Down

0 comments on commit 4209251

Please sign in to comment.