From 9712f139f6234918c42e76b12b1459afafecf488 Mon Sep 17 00:00:00 2001
From: Burak Ok <burakok@microsoft.com>
Date: Tue, 2 Sep 2025 17:53:24 +0200
Subject: [PATCH] IG: Change default tag to the current version

---
 pkg/oci/oci.go | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/pkg/oci/oci.go b/pkg/oci/oci.go
index dacf0c441..557b5eb43 100644
--- a/pkg/oci/oci.go
+++ b/pkg/oci/oci.go
@@ -43,6 +43,7 @@ import (
 	"oras.land/oras-go/v2/registry/remote"
 	oras_auth "oras.land/oras-go/v2/registry/remote/auth"
 
+	"github.com/inspektor-gadget/inspektor-gadget/internal/version"
 	"github.com/inspektor-gadget/inspektor-gadget/pkg/logger"
 	signatureverifier "github.com/inspektor-gadget/inspektor-gadget/pkg/signature-verifier"
 )
@@ -481,7 +482,7 @@ func getGadgetImageDescriptor(ctx context.Context, store *oci.Store, fullTag str
 		repository = named.Name()
 	}
 
-	tag := "latest"
+	tag := "v"+version.Version().String()
 	if tagged, ok := parsed.(reference.Tagged); ok {
 		tag = tagged.Tag()
 	}
@@ -656,7 +657,10 @@ func normalizeImageName(image string) (reference.Named, error) {
 	if err != nil {
 		return nil, fmt.Errorf("parsing normalized image %q: %w", image, err)
 	}
-	return reference.TagNameOnly(name), nil
+	if reference.IsNameOnly(name) {
+		return reference.WithTag(name, "v"+version.Version().String())
+	}
+	return name, nil
 }
 
 func getHostString(repository string) (string, error) {
-- 
2.34.1

