Skip to content

Commit

Permalink
Merge pull request #622 from gpontejos/fix-iar-image-sorting
Browse files Browse the repository at this point in the history
fix: ensure latest IAR image is used as default
  • Loading branch information
gpontejos authored Jan 30, 2025
2 parents d911244 + 461fe88 commit 8814218
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ require (
github.com/gorilla/mux v1.8.1 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-multierror v1.1.1 // indirect
github.com/hashicorp/go-version v1.7.0
github.com/huandu/xstrings v1.3.3 // indirect
github.com/imdario/mergo v0.3.15 // indirect
github.com/jmespath/go-jmespath v0.4.1-0.20220621161143-b0104c826a24 // indirect
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,8 @@ github.com/hashicorp/errwrap v1.1.0 h1:OxrOeh75EUXMY8TBjag2fzXGZ40LB6IKw45YeGUDY
github.com/hashicorp/errwrap v1.1.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+lD48awMYo=
github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM=
github.com/hashicorp/go-version v1.7.0 h1:5tqGy27NaOTB8yJKUZELlFAS/LTKJkrmONwQKeRZfjY=
github.com/hashicorp/go-version v1.7.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA=
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
github.com/huandu/xstrings v1.3.3 h1:/Gcsuc1x8JVbJ9/rlye4xZnVAbEkGauT8lbebqcQws4=
github.com/huandu/xstrings v1.3.3/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE=
Expand Down
14 changes: 14 additions & 0 deletions pkg/registry/falcon_registry/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"errors"
"fmt"
"sort"
"strings"

"github.com/containers/image/v5/docker"
Expand All @@ -13,6 +14,7 @@ import (
"github.com/crowdstrike/falcon-operator/pkg/falcon_api"
"github.com/crowdstrike/falcon-operator/pkg/registry/auth"
"github.com/crowdstrike/gofalcon/falcon"
version "github.com/hashicorp/go-version"
)

type FalconRegistry struct {
Expand Down Expand Up @@ -97,6 +99,18 @@ func lastTag(ctx context.Context, systemContext *types.SystemContext, imageUri s
if err != nil {
return "", err
}

if strings.Contains(imageUri, "imageanalyzer") {
sort.Slice(tags, func(i, j int) bool {
v1, err1 := version.NewVersion(tags[i])
v2, err2 := version.NewVersion(tags[j])
if err1 != nil || err2 != nil {
return tags[i] < tags[j]
}
return v1.LessThan(v2)
})
}

return guessLastTag(tags, filter)
}

Expand Down

0 comments on commit 8814218

Please sign in to comment.