forked from argoproj/argo-cd
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add wildcard support in OCI Helm Repositories targetRevision (a…
…rgoproj#6686) (argoproj#10641) * Add wildcard support in OCI Helm Repositories A naive approach, adapting existing code for fetching the index. Signed-off-by: Alex Eftimie <alex.eftimie@getyourguide.com> * Fix unittest missing mock Signed-off-by: Alex Eftimie <alex.eftimie@getyourguide.com> * Fix release resolution also in Manual Sync dialog Signed-off-by: Alex Eftimie <alex.eftimie@getyourguide.com> * Show target revision in application list. Tiles and Table updated Signed-off-by: Alex Eftimie <alex.eftimie@getyourguide.com> * Follow Link rel=next in tags response for tag list completion (signed) Signed-off-by: Alex Eftimie <alex.eftimie@getyourguide.com> * Wrap errors into fmt.Errorf according to PR review Signed-off-by: Alex Eftimie <alex.eftimie@getyourguide.com> * Address PR comments, add test for tags MaxVersion and pagination Signed-off-by: Alex Eftimie <alex.eftimie@getyourguide.com> * Apply suggestions from code review Co-authored-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com> Signed-off-by: Alex Eftimie <alex.eftimie@getyourguide.com> * more feedback from pr Signed-off-by: Alex Eftimie <alex.eftimie@getyourguide.com> * Revert url.JoinPath change - only available in 1.19 Signed-off-by: Alex Eftimie <alex.eftimie@getyourguide.com> * use strings.Join. add unittest Signed-off-by: Alex Eftimie <alex.eftimie@getyourguide.com> * Safe access to app.status.sync object Signed-off-by: Alex Eftimie <alex.eftimie@getyourguide.com> * Remove status.revision from UI. It doesn't bring much value and it does clutter the ui a bit Signed-off-by: Alex Eftimie <alex.eftimie@getyourguide.com> * Update util/helm/client.go Signed-off-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com> * Update util/helm/client.go Signed-off-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com> Signed-off-by: Alex Eftimie <alex.eftimie@getyourguide.com> Signed-off-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com> Co-authored-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com> Signed-off-by: emirot <emirot.nolan@gmail.com>
- Loading branch information
Showing
8 changed files
with
330 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package helm | ||
|
||
import ( | ||
"fmt" | ||
|
||
log "github.com/sirupsen/logrus" | ||
|
||
"github.com/Masterminds/semver/v3" | ||
) | ||
|
||
type TagsList struct { | ||
Tags []string | ||
} | ||
|
||
func (t TagsList) MaxVersion(constraints *semver.Constraints) (*semver.Version, error) { | ||
versions := semver.Collection{} | ||
for _, tag := range t.Tags { | ||
v, err := semver.NewVersion(tag) | ||
|
||
//Invalid semantic version ignored | ||
if err == semver.ErrInvalidSemVer { | ||
log.Debugf("Invalid semantic version: %s", tag) | ||
continue | ||
} | ||
if err != nil { | ||
return nil, fmt.Errorf("invalid constraint in tags: %v", err) | ||
} | ||
if constraints.Check(v) { | ||
versions = append(versions, v) | ||
} | ||
} | ||
if len(versions) == 0 { | ||
return nil, fmt.Errorf("constraint not found in %v tags", len(t.Tags)) | ||
} | ||
maxVersion := versions[0] | ||
for _, v := range versions { | ||
if v.GreaterThan(maxVersion) { | ||
maxVersion = v | ||
} | ||
} | ||
return maxVersion, nil | ||
} |
Oops, something went wrong.