Skip to content

Commit

Permalink
fix(ketchup): Computing release URL with new version
Browse files Browse the repository at this point in the history
Signed-off-by: Vincent Boutour <bob@vibioh.fr>
  • Loading branch information
ViBiOh committed Jun 3, 2021
1 parent f70b68e commit be299e2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
2 changes: 1 addition & 1 deletion pkg/model/ketchup.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ func NewRelease(repository Repository, pattern string, version semver.Version) R
Repository: repository,
Pattern: pattern,
Version: version,
URL: repository.URL(pattern),
URL: repository.VersionURL(version.Name),
}
}

Expand Down
17 changes: 11 additions & 6 deletions pkg/model/repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,16 @@ func (r Repository) String() string {
}
}

// URL format the URL of given repository with current version
// URL format the URL of given repository with pattern version
func (r Repository) URL(pattern string) string {
return r.VersionURL(r.Versions[pattern])
}

// VersionURL format the URL of given repository with given version
func (r Repository) VersionURL(version string) string {
switch r.Kind {
case Github:
return fmt.Sprintf("%s/%s/releases/tag/%s", githubURL, r.Name, r.Versions[pattern])
return fmt.Sprintf("%s/%s/releases/tag/%s", githubURL, r.Name, version)
case Helm:
parts := strings.SplitN(r.Name, "@", 2)
if len(parts) > 1 {
Expand All @@ -122,16 +127,16 @@ func (r Repository) URL(pattern string) string {
case Docker:
switch strings.Count(r.Name, "/") {
case 0:
return fmt.Sprintf("https://hub.docker.com/_/%s?tab=tags&page=1&ordering=last_updated&name=%s", r.Name, r.Versions[pattern])
return fmt.Sprintf("https://hub.docker.com/_/%s?tab=tags&page=1&ordering=last_updated&name=%s", r.Name, version)
case 1:
return fmt.Sprintf("https://hub.docker.com/r/%s/tags?page=1&ordering=last_updated&name=%s", r.Name, r.Versions[pattern])
return fmt.Sprintf("https://hub.docker.com/r/%s/tags?page=1&ordering=last_updated&name=%s", r.Name, version)
default:
return fmt.Sprintf("https://%s", r.Name)
}
case NPM:
return fmt.Sprintf("https://www.npmjs.com/package/%s/v/%s", r.Name, r.Versions[pattern])
return fmt.Sprintf("https://www.npmjs.com/package/%s/v/%s", r.Name, version)
case Pypi:
return fmt.Sprintf("https://pypi.org/project/%s/%s/", r.Name, r.Versions[pattern])
return fmt.Sprintf("https://pypi.org/project/%s/%s/", r.Name, version)
default:
return "#"
}
Expand Down

0 comments on commit be299e2

Please sign in to comment.