Skip to content

Commit

Permalink
fix: add missing v prefix when looking up version in the image factory
Browse files Browse the repository at this point in the history
Otherwise it can never find the version in the image factory versions
response and always skips it.

Signed-off-by: Artem Chernyshev <[email protected]>
  • Loading branch information
Unix4ever committed Mar 7, 2024
1 parent 0eed757 commit 22ec251
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func NewTalosExtensionsController() *TalosExtensionsController {
return fmt.Errorf("failed to get existing image factory Talos versions %w", err)
}

hasVersion := slices.Index(versions, version.Metadata().ID()) != -1
hasVersion := slices.Index(versions, "v"+version.Metadata().ID()) != -1

// skip fetching Talos extensions for a version which isn't registered in the image factory
if !hasVersion {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (

"github.com/cosi-project/runtime/pkg/resource/rtestutils"
"github.com/julienschmidt/httprouter"
"github.com/siderolabs/gen/xslices"
"github.com/siderolabs/image-factory/pkg/client"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/suite"
Expand Down Expand Up @@ -126,7 +127,7 @@ func (suite *TalosExtensionsSuite) TestReconcile() {

factory := imageFactoryMock{
extensionsVersions: map[string][]client.ExtensionInfo{
"v1.6.0": {
"1.6.0": {
{
Name: "siderolabs/hello-world-service",
Ref: "github.com/siderolabs/hello-world-service:v1.6.0",
Expand All @@ -135,7 +136,7 @@ func (suite *TalosExtensionsSuite) TestReconcile() {
Description: "This system extension provides an example Talos extension service.",
},
},
"v200.0.0": {
"200.0.0": {
{
Name: "siderolabs/hello-future",
Ref: "github.com/siderolabs/hello-future:v200.0.0",
Expand All @@ -161,10 +162,10 @@ func (suite *TalosExtensionsSuite) TestReconcile() {
suite.Require().NoError(suite.runtime.RegisterQController(omnictrl.NewTalosExtensionsController()))

versions := []string{
"v0.14.0", "v1.6.0", "v200.0.0",
"0.14.0", "1.6.0", "200.0.0",
}

factory.talosVersions = versions[1:]
factory.talosVersions = xslices.Map(versions[1:], func(v string) string { return "v" + v })

for _, v := range versions {
version := omni.NewTalosVersion(resources.DefaultNamespace, v)
Expand All @@ -180,15 +181,15 @@ func (suite *TalosExtensionsSuite) TestReconcile() {
manifest := res.TypedSpec().Value.Items[0]

switch res.Metadata().ID() {
case "v1.6.0":
case "1.6.0":
assert.EqualValues("Sidero Labs", manifest.Author)
assert.EqualValues("This system extension provides an example Talos extension service.", manifest.Description)
assert.EqualValues("aaaa", manifest.Digest)
assert.EqualValues("v1.6.0", manifest.Version)
assert.EqualValues("siderolabs/hello-world-service", manifest.Name)
assert.EqualValues("github.com/siderolabs/hello-world-service:v1.6.0", manifest.Ref)
// no info in the manifests, should still be in the list but without additional info
case "v200.0.0":
case "200.0.0":
assert.EqualValues("v200.0.0", manifest.Version)
assert.EqualValues("siderolabs/hello-future", manifest.Name)
assert.EqualValues("aaaa", manifest.Digest)
Expand Down

0 comments on commit 22ec251

Please sign in to comment.