Skip to content

Commit fd0aace

Browse files
committed
feat(sync): default sidecar tag to okdev binary version
1 parent 5a2646e commit fd0aace

5 files changed

Lines changed: 51 additions & 19 deletions

File tree

.github/workflows/syncthing-image.yml

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,7 @@ on:
1010
push:
1111
branches: [main]
1212
tags:
13-
- 'syncthing-v*'
14-
paths:
15-
- 'infra/syncthing/**'
16-
- '.github/workflows/syncthing-image.yml'
13+
- "v*"
1714

1815
jobs:
1916
build-and-push:
@@ -28,14 +25,12 @@ jobs:
2825
id: vars
2926
shell: bash
3027
run: |
31-
if [[ "${GITHUB_REF}" == refs/tags/syncthing-v* ]]; then
32-
version="${GITHUB_REF_NAME#syncthing-}"
33-
elif [[ -n "${{ github.event.inputs.syncthing_version }}" ]]; then
34-
version="${{ github.event.inputs.syncthing_version }}"
28+
if [[ -n "${{ github.event.inputs.syncthing_version }}" ]]; then
29+
syncthing_version="${{ github.event.inputs.syncthing_version }}"
3530
else
36-
version="v1.29.7"
31+
syncthing_version="v1.29.7"
3732
fi
38-
echo "version=${version}" >> "$GITHUB_OUTPUT"
33+
echo "syncthing_version=${syncthing_version}" >> "$GITHUB_OUTPUT"
3934
4035
- uses: docker/setup-qemu-action@v3
4136
- uses: docker/setup-buildx-action@v3
@@ -55,8 +50,8 @@ jobs:
5550
tags: |
5651
type=raw,value=edge,enable={{is_default_branch}}
5752
type=sha,prefix=edge-
58-
type=match,pattern=syncthing-(v.*),group=1
59-
type=raw,value=latest,enable=${{ startsWith(github.ref, 'refs/tags/syncthing-v') }}
53+
type=ref,event=tag
54+
type=raw,value=latest,enable=${{ startsWith(github.ref, 'refs/tags/v') }}
6055
6156
- name: Build and push
6257
uses: docker/build-push-action@v6
@@ -66,6 +61,6 @@ jobs:
6661
platforms: linux/amd64,linux/arm64
6762
push: true
6863
build-args: |
69-
SYNCTHING_VERSION=${{ steps.vars.outputs.version }}
64+
SYNCTHING_VERSION=${{ steps.vars.outputs.syncthing_version }}
7065
tags: ${{ steps.meta.outputs.tags }}
7166
labels: ${{ steps.meta.outputs.labels }}

docs/quickstart.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ For a named session:
6363
```
6464

6565
`okdev` auto-installs local Syncthing and auto-injects a pod sidecar when `sync.engine=syncthing`.
66-
Default sidecar image is `ghcr.io/<repo-owner>/okdev:<version>`; update `spec.sync.syncthing.image` if you publish under a different registry.
66+
Default sidecar image tag follows the running `okdev` binary version (`ghcr.io/<repo-owner>/okdev:<okdev-version>`). For dev builds, fallback is `ghcr.io/<repo-owner>/okdev:edge`. Update `spec.sync.syncthing.image` only if you publish to a different registry/repository.
6767

6868
Preview-only mode (no cluster changes):
6969

docs/release.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,15 @@ git push origin v0.1.0
3131
- `okdev_<os>_<arch>.tar.gz`
3232
- `checksums.txt`
3333

34+
## Sidecar image tags
35+
36+
The sidecar image tag is aligned with the `okdev` release tag:
37+
38+
- release `vX.Y.Z` publishes `ghcr.io/acmore/okdev:vX.Y.Z`
39+
- dev/main pushes publish `ghcr.io/acmore/okdev:edge`
40+
41+
`okdev` resolves default sidecar image from its own binary version, with `edge` fallback for dev builds.
42+
3443
## Install from release
3544

3645
```bash

internal/config/config.go

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,19 @@ import (
55
"fmt"
66
"strings"
77

8+
"github.com/acmore/okdev/internal/version"
89
corev1 "k8s.io/api/core/v1"
910
)
1011

1112
const (
12-
DefaultSyncthingVersion = "v1.29.7"
13-
DefaultSyncthingImage = "ghcr.io/acmore/okdev:" + DefaultSyncthingVersion
14-
DefaultWorkspacePVCSize = "50Gi"
13+
DefaultSyncthingVersion = "v1.29.7"
14+
DefaultSyncthingImageRepository = "ghcr.io/acmore/okdev"
15+
DefaultSyncthingImageFallback = "edge"
16+
DefaultWorkspacePVCSize = "50Gi"
1517
)
1618

19+
var DefaultSyncthingImage = DefaultSyncthingImageForBinaryVersion(version.Version)
20+
1721
// DevEnvironment is the top-level config structure for .okdev.yaml.
1822
type DevEnvironment struct {
1923
APIVersion string `yaml:"apiVersion"`
@@ -107,7 +111,7 @@ func (d *DevEnvironment) SetDefaults() {
107111
d.Spec.Sync.Syncthing.AutoInstall = &v
108112
}
109113
if d.Spec.Sync.Syncthing.Image == "" {
110-
d.Spec.Sync.Syncthing.Image = DefaultSyncthingImage
114+
d.Spec.Sync.Syncthing.Image = DefaultSyncthingImageForBinaryVersion(version.Version)
111115
}
112116
if d.Spec.SSH.User == "" {
113117
d.Spec.SSH.User = "root"
@@ -217,3 +221,11 @@ func validatePortRange(field string, port int) error {
217221
}
218222
return nil
219223
}
224+
225+
func DefaultSyncthingImageForBinaryVersion(binaryVersion string) string {
226+
tag := strings.TrimSpace(binaryVersion)
227+
if tag == "" || tag == "unknown" || strings.Contains(tag, "dev") {
228+
tag = DefaultSyncthingImageFallback
229+
}
230+
return DefaultSyncthingImageRepository + ":" + tag
231+
}

internal/config/config_test.go

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
package config
22

3-
import "testing"
3+
import (
4+
"testing"
5+
6+
"github.com/acmore/okdev/internal/version"
7+
)
48

59
func validConfig() *DevEnvironment {
610
return &DevEnvironment{
@@ -32,6 +36,9 @@ func TestSetDefaults(t *testing.T) {
3236
if cfg.Spec.Sync.Engine != "syncthing" {
3337
t.Fatalf("sync engine default not set: %q", cfg.Spec.Sync.Engine)
3438
}
39+
if cfg.Spec.Sync.Syncthing.Image != DefaultSyncthingImageForBinaryVersion(version.Version) {
40+
t.Fatalf("sync image default not set: %q", cfg.Spec.Sync.Syncthing.Image)
41+
}
3542
if !cfg.Spec.Sync.Syncthing.AutoInstallEnabled() {
3643
t.Fatal("expected syncthing autoinstall default true")
3744
}
@@ -90,3 +97,12 @@ func TestValidateRejectsInvalidSSHPort(t *testing.T) {
9097
t.Fatal("expected validation error")
9198
}
9299
}
100+
101+
func TestDefaultSyncthingImageForBinaryVersion(t *testing.T) {
102+
if got := DefaultSyncthingImageForBinaryVersion("v0.2.1"); got != "ghcr.io/acmore/okdev:v0.2.1" {
103+
t.Fatalf("unexpected image for release version: %s", got)
104+
}
105+
if got := DefaultSyncthingImageForBinaryVersion("0.0.0-dev"); got != "ghcr.io/acmore/okdev:edge" {
106+
t.Fatalf("unexpected image for dev version: %s", got)
107+
}
108+
}

0 commit comments

Comments
 (0)