@@ -11,11 +11,13 @@ import (
1111 "strings"
1212 "testing"
1313
14+ "github.com/blang/semver/v4"
1415 "github.com/siderolabs/gen/xslices"
1516 "github.com/stretchr/testify/assert"
1617
1718 "github.com/siderolabs/talos/internal/integration/base"
1819 "github.com/siderolabs/talos/pkg/machinery/config/machine"
20+ "github.com/siderolabs/talos/pkg/machinery/version"
1921)
2022
2123// ImageSuite verifies the image command.
@@ -35,10 +37,20 @@ func (suite *ImageSuite) TestDefault() {
3537 )
3638}
3739
40+ var versionRe = regexp .MustCompile (`^[v]?(\d+\.\d+\.\d+(?:-(?:alpha|beta|rc)\.\d+)?)` )
41+
42+ func normalizeTag (tag string ) string {
43+ m := versionRe .FindStringSubmatch (tag )
44+ if len (m ) == 0 {
45+ return tag
46+ }
47+
48+ return m [1 ]
49+ }
50+
3851// TestSourceBundle verifies talos-bundle Talos list of images.
3952func (suite * ImageSuite ) TestSourceBundle () {
40- suite .RunCLI ([]string {"image" , "talos-bundle" , "v1.11.2" },
41- base .StdoutShouldMatch (regexp .MustCompile (regexp .QuoteMeta (`ghcr.io/siderolabs/installer:v1.11.2
53+ out := `ghcr.io/siderolabs/installer:v1.11.2
4254ghcr.io/siderolabs/installer-base:v1.11.2
4355ghcr.io/siderolabs/imager:v1.11.2
4456ghcr.io/siderolabs/talos:v1.11.2
@@ -115,7 +127,32 @@ ghcr.io/siderolabs/xdma-driver:aefa9a1-v1.11.2@sha256:b65cb2033d46a7c88d317cb29a
115127ghcr.io/siderolabs/xen-guest-agent:0.4.0-g5c274e6@sha256:91e08d9ae45e325bf20da77f251e265d0e72cb38751a6dcee930bf21c9adacc1
116128ghcr.io/siderolabs/youki:0.5.5@sha256:562ceabb69570203024dbb9b8673ba485af1ffdd082210656573e22557235372
117129ghcr.io/siderolabs/zerotier:1.16.0@sha256:9444baa3acdc665dba56ed16c8a983c81c3f37fc73877be8fd882f9cf8c9fa5a
118- ghcr.io/siderolabs/zfs:2.3.3-v1.11.2@sha256:73782571f334b18995ddf324d24b86ea9a11aa37661a468b4e077da63e0d9714` ))),
130+ ghcr.io/siderolabs/zfs:2.3.3-v1.11.2@sha256:73782571f334b18995ddf324d24b86ea9a11aa37661a468b4e077da63e0d9714`
131+
132+ suite .RunCLI ([]string {"image" , "talos-bundle" , "v1.11.2" },
133+ base .StdoutShouldMatch (regexp .MustCompile (regexp .QuoteMeta (out ))),
134+ )
135+
136+ tag , err := semver .ParseTolerant (normalizeTag (version .Tag ))
137+ assert .NoError (suite .T (), err )
138+
139+ suite .T ().Log (normalizeTag (version .Tag ))
140+ suite .T ().Log (version .Tag )
141+
142+ suite .RunCLI ([]string {"image" , "talos-bundle" , "v" + tag .String ()},
143+ base .StdoutShouldMatch (regexp .MustCompile (regexp .QuoteMeta ("ghcr.io/siderolabs/talos:v" + tag .String ()))),
144+ )
145+
146+ suite .RunCLI ([]string {"image" , "talos-bundle" , tag .String ()},
147+ base .StdoutEmpty (),
148+ base .ShouldFail (),
149+ )
150+
151+ tag .Patch = 0
152+ assert .NoError (suite .T (), tag .IncrementMinor ())
153+ suite .RunCLI ([]string {"image" , "talos-bundle" , "v" + tag .FinalizeVersion ()},
154+ base .StdoutEmpty (),
155+ base .ShouldFail (),
119156 )
120157}
121158
0 commit comments