diff --git a/pkg/parser/dockerImageParser.go b/pkg/parser/dockerImageParser.go index fced439a..bf5ab414 100644 --- a/pkg/parser/dockerImageParser.go +++ b/pkg/parser/dockerImageParser.go @@ -2,6 +2,7 @@ package parser import ( "regexp" + "strings" "github.com/CircleCI-Public/circleci-yaml-language-server/pkg/ast" ) @@ -36,6 +37,10 @@ func ParseDockerImageValue(value string) ast.DockerImageInfo { if tag != "" { // The regex includes the leading ":", just snip it tag = tag[1:] + // Split at "@" and take only the version part before it + if strings.Contains(tag, "@") { + tag = strings.Split(tag, "@")[0] + } } return ast.DockerImageInfo{ diff --git a/pkg/parser/dockerImageParser_test.go b/pkg/parser/dockerImageParser_test.go index 49afd0bc..8e3cfd4c 100644 --- a/pkg/parser/dockerImageParser_test.go +++ b/pkg/parser/dockerImageParser_test.go @@ -120,6 +120,19 @@ func Test_parseDockerImageValue(t *testing.T) { FullPath: "cimg/go:<>", }, }, + + { + name: "", + args: args{ + value: "cimg/node:22.11.0@sha256:76aae59c6259672ab68819b8960de5ef571394681089eab2b576f85f080c73ba", + }, + want: ast.DockerImageInfo{ + Namespace: "cimg", + Tag: "22.11.0", + Name: "node", + FullPath: "cimg/node:22.11.0@sha256:76aae59c6259672ab68819b8960de5ef571394681089eab2b576f85f080c73ba", + }, + }, } for _, tt := range tests {