Skip to content

Commit efa9a9c

Browse files
committed
feat: tag in config
1 parent d284514 commit efa9a9c

6 files changed

Lines changed: 17 additions & 13 deletions

File tree

justfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ CONFIG_PATH := canonicalize(env("BRIDGEHEAD_CONFIG_PATH", "./bridgehead"))
55
export TAG := env("TAG", "localbuild")
66

77
run: build ensure_bootstrap
8-
sudo TAG=$TAG {{ CONFIG_PATH }}/bridgehead install
8+
sudo {{ CONFIG_PATH }}/bridgehead install
99

1010
up: down_bg run
1111
{{ CONFIG_PATH }}/bridgehead compose up

src/config.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ pub struct Config {
2424
pub hostname: Host,
2525
#[serde(default)]
2626
pub environment: Environment,
27+
#[serde(default = "latest")]
28+
pub version_tag: String,
2729
pub https_proxy_url: Option<Url>,
2830
pub ccp: Option<CcpConfig>,
2931
pub bbmri: Option<BbmriConfig>,
@@ -34,6 +36,10 @@ pub struct Config {
3436
pub local_conf: RefCell<LocalConf>,
3537
}
3638

39+
fn latest() -> String {
40+
"latest".to_string()
41+
}
42+
3743
#[derive(Debug, Deserialize, Default)]
3844
#[serde(rename_all = "lowercase")]
3945
pub enum Environment {

static/bootstrap.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ EOF
2828
read -p "Proxy [${HTTPS_PROXY:-None}]: " proxy
2929
proxy="${proxy:-$HTTPS_PROXY}"
3030
[ -n "$proxy" ] && echo "proxy = \"$proxy\"" >> "${config_dir}/config.toml"
31+
[ -n "$TAG" ] && echo "version_tag = \"$TAG\"" >> "${config_dir}/config.toml"
3132

3233
echo "Configuration file created at ${config_dir}/config.toml"
3334
else

templates/bridgehead

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ main() {
2929
{%- endif %}
3030
if ! systemctl list-units &> /dev/null; then
3131
echo "Systemd is not active. Skipping systemd setup."
32-
sudo -u bridgehead TAG=$TAG ./bridgehead update
32+
sudo -u bridgehead ./bridgehead update
3333
else
3434
install_systemd
3535
fi
@@ -69,14 +69,13 @@ main() {
6969
update)
7070
docker image prune -f
7171
# TODO: Check if the bridgehead script changed and if so rerun
72-
# TODO: Read tag from config
73-
docker pull samply/rusthead:${TAG:-latest} &>/dev/null || echo "Failed to pull latest rusthead image. Using latest local image."
72+
docker pull samply/rusthead:{{ conf.version_tag }} &>/dev/null || echo "Failed to pull latest rusthead image. Using latest local image."
7473
docker run --rm \
7574
-v {{ config_dir }}:{{ config_dir }} \
7675
-v /var/run/docker.sock:/var/run/docker.sock \
7776
-e BRIDGEHEAD_CONFIG_PATH={{ config_dir }} \
7877
-u "$(id -u bridgehead):$(id -g bridgehead)" \
79-
samply/rusthead:${TAG:-latest} update
78+
samply/rusthead:{{ conf.version_tag }} update
8079
;;
8180
*)
8281
echo "Unknown bridgehead command '$@'"

tests/snapshots/example.config/configs@bridgehead.snap

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ main() {
3030
git config --local user.name "Bridgehead"
3131
if ! systemctl list-units &> /dev/null; then
3232
echo "Systemd is not active. Skipping systemd setup."
33-
sudo -u bridgehead TAG=$TAG ./bridgehead update
33+
sudo -u bridgehead ./bridgehead update
3434
else
3535
install_systemd
3636
fi
@@ -61,14 +61,13 @@ main() {
6161
update)
6262
docker image prune -f
6363
# TODO: Check if the bridgehead script changed and if so rerun
64-
# TODO: Read tag from config
65-
docker pull samply/rusthead:${TAG:-latest} &>/dev/null || echo "Failed to pull latest rusthead image. Using latest local image."
64+
docker pull samply/rusthead:latest &>/dev/null || echo "Failed to pull latest rusthead image. Using latest local image."
6665
docker run --rm \
6766
-v [TMP_DIR]:[TMP_DIR] \
6867
-v /var/run/docker.sock:/var/run/docker.sock \
6968
-e BRIDGEHEAD_CONFIG_PATH=[TMP_DIR] \
7069
-u "$(id -u bridgehead):$(id -g bridgehead)" \
71-
samply/rusthead:${TAG:-latest} update
70+
samply/rusthead:latest update
7271
;;
7372
*)
7473
echo "Unknown bridgehead command '$@'"

tests/snapshots/minimal/configs@bridgehead.snap

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ main() {
3030
git config --local user.name "Bridgehead"
3131
if ! systemctl list-units &> /dev/null; then
3232
echo "Systemd is not active. Skipping systemd setup."
33-
sudo -u bridgehead TAG=$TAG ./bridgehead update
33+
sudo -u bridgehead ./bridgehead update
3434
else
3535
install_systemd
3636
fi
@@ -48,14 +48,13 @@ main() {
4848
update)
4949
docker image prune -f
5050
# TODO: Check if the bridgehead script changed and if so rerun
51-
# TODO: Read tag from config
52-
docker pull samply/rusthead:${TAG:-latest} &>/dev/null || echo "Failed to pull latest rusthead image. Using latest local image."
51+
docker pull samply/rusthead:latest &>/dev/null || echo "Failed to pull latest rusthead image. Using latest local image."
5352
docker run --rm \
5453
-v [TMP_DIR]:[TMP_DIR] \
5554
-v /var/run/docker.sock:/var/run/docker.sock \
5655
-e BRIDGEHEAD_CONFIG_PATH=[TMP_DIR] \
5756
-u "$(id -u bridgehead):$(id -g bridgehead)" \
58-
samply/rusthead:${TAG:-latest} update
57+
samply/rusthead:latest update
5958
;;
6059
*)
6160
echo "Unknown bridgehead command '$@'"

0 commit comments

Comments
 (0)