labctl: dépôt autonome — module git.g3e.fr/syonad/labctl, exemple evpn-2hv, LABCTL_BIN, licence, README, CI
Some checks failed
Tests / test (push) Successful in 4m12s
Release Pipeline / set-release-target (push) Successful in 2s
Release Pipeline / upload-assets (lab-host.sh, scripts/lab-host.sh) (push) Successful in 7s
Release Pipeline / build (push) Successful in 1m31s
Release Pipeline / build (amd64, linux) (push) Successful in 0s
Release Pipeline / build (arm64, darwin) (push) Successful in 0s
Release Pipeline / checksums (push) Successful in 6s
Release Pipeline / release (push) Failing after 22s
Release Pipeline / publish (push) Failing after 0s

Signed-off-by: GnomeZworc <nicolas.boufidjeline@g3e.fr>
This commit is contained in:
GnomeZworc 2026-10-12 16:33:02 +02:00
commit ef7392f09b
Signed by: nicolas.boufideline
GPG key ID: 4406BBBF8845D632
31 changed files with 766 additions and 36 deletions

View file

@ -46,7 +46,8 @@ usage: ${0##*/} <commande> [arguments]
environnement : SCW_SECRET_KEY et SCW_DEFAULT_PROJECT_ID (requis, à défaut lus dans ${CREDENTIALS_FILE},
fichier en 0600, lignes CLÉ=valeur), LAB_ZONES (zones candidates, dans l'ordre :
${ZONES} ; SCW_DEFAULT_ZONE passe en tête), LAB_OFFER (${OFFER_NAME}), LAB_OS_NAME (${OS_NAME}), LAB_OS_VERSION (${OS_VERSION}),
LAB_SSH_KEY (${SSH_KEY} ; à défaut, l'agent SSH)
LAB_SSH_KEY (${SSH_KEY} ; à défaut, l'agent SSH), LABCTL_BIN (binaire labctl linux/amd64
envoyé par push au lieu de le compiler depuis le dépôt)
ne jamais lancer sous 'bash -x' : la trace afficherait SCW_SECRET_KEY.
EOF
@ -388,9 +389,15 @@ cmd_push () {
[[ -f "${TOPOLOGY}" ]] || die "topologie introuvable : ${TOPOLOGY}"
[[ "${NAME}" =~ ^[A-Za-z0-9._-]+$ ]] || die "nom de topologie refusé : ${NAME} (lettres, chiffres, '.', '_', '-')"
require_known_server
info "compilation de labctl (linux/amd64)"
(cd "${REPO_DIR}" && CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o "${BINARY}" ./cmd/labctl) \
|| die "compilation de labctl échouée"
if [[ -n "${LABCTL_BIN:-}" ]]; then
[[ -f "${LABCTL_BIN}" && -x "${LABCTL_BIN}" ]] || die "LABCTL_BIN n'est pas un exécutable : ${LABCTL_BIN}"
BINARY="${LABCTL_BIN}"
info "labctl fourni : ${BINARY}"
else
info "compilation de labctl (linux/amd64)"
(cd "${REPO_DIR}" && CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o "${BINARY}" ./cmd/labctl) \
|| die "compilation de labctl échouée"
fi
push_file "${BINARY}" labctl 755 || die "envoi de labctl échoué"
push_dir "$(dirname "${TOPOLOGY}")" || die "envoi du répertoire de ${NAME} échoué"
info "déposés sur le serveur : ~/labctl, ~/topology/ — ensuite : ${0##*/} ssh './labctl up topology/${NAME}'"

View file

@ -227,7 +227,7 @@ lab_env () {
SCW_DEFAULT_PROJECT_ID="${PROJECT}" LAB_POLL_INTERVAL="${LAB_POLL_INTERVAL:-0}" \
LAB_INSTALL_TIMEOUT="${LAB_INSTALL_TIMEOUT:-60}" LAB_DELETE_TIMEOUT="${LAB_DELETE_TIMEOUT:-60}" \
LAB_SSH_TIMEOUT="${LAB_SSH_TIMEOUT:-60}" LAB_ZONES="${LAB_ZONES:-fr-par-1}" \
LAB_OFFER="${LAB_OFFER:-EM-B212X-SSD}" ${SCW_DEFAULT_ZONE:+SCW_DEFAULT_ZONE="${SCW_DEFAULT_ZONE}"} \
LAB_OFFER="${LAB_OFFER:-EM-B212X-SSD}" ${SCW_DEFAULT_ZONE:+SCW_DEFAULT_ZONE="${SCW_DEFAULT_ZONE}"} ${LABCTL_BIN:+LABCTL_BIN="${LABCTL_BIN}"} \
"$@"
}
@ -725,6 +725,31 @@ test_push_stops_when_the_build_fails () {
teardown
}
test_push_sends_a_provided_binary_without_building () {
setup "push : LABCTL_BIN est envoyé tel quel, sans compilation"
known_server
printf 'name: x\n' > "${WORK}/x.yml"
printf 'binaire-de-release' > "${WORK}/labctl-release"
chmod 755 "${WORK}/labctl-release"
LABCTL_BIN="${WORK}/labctl-release" run_lab push "${WORK}/x.yml" || fail "code de sortie $?"
[[ -s "${WORK}/go.log" ]] && fail "compilation lancée : $(cat "${WORK}/go.log")"
[[ $(cat "${WORK}/pushed.1") == "binaire-de-release" ]] || fail "contenu envoyé : $(cat "${WORK}/pushed.1")"
teardown
}
test_push_refuses_a_provided_binary_that_is_not_executable () {
setup "push : LABCTL_BIN absent ou non exécutable refusé avant tout envoi"
known_server
printf 'name: x\n' > "${WORK}/x.yml"
printf 'x' > "${WORK}/labctl-release"
for BIN in "${WORK}/absent" "${WORK}/labctl-release"; do
LABCTL_BIN="${BIN}" run_lab push "${WORK}/x.yml" && fail "push a réussi avec ${BIN}"
grep -q "LABCTL_BIN n'est pas un exécutable" "${WORK}/out.log" || fail "message absent pour ${BIN}"
done
[[ -s "${WORK}/ssh.log" ]] && fail "ssh lancé"
teardown
}
test_push_fails_when_a_transfer_fails () {
setup "push : un envoi échoué fait échouer push"
known_server