Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Install from the specified release channel #9

Merged
merged 2 commits into from
Nov 8, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 14 additions & 8 deletions hab/hab.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,16 @@ type PackagesInfo struct {

// PackageInfo is package info in pkgs response
type PackageInfo struct {
Origin string `json:"origin"`
Name string `json:"name"`
Version string `json:"version"`
Release string `json:"release"`
Origin string `json:"origin"`
Name string `json:"name"`
Version string `json:"version"`
Release string `json:"release"`
Channels []string `json:"channels"`
}

// Depot for hab
type Depot interface {
PackageVersionsFromName(pkgName string) ([]string, error)
PackageVersionsFromName(pkgName string, habChannel string) ([]string, error)
}

type depot struct {
Expand Down Expand Up @@ -67,7 +68,7 @@ func (depo *depot) packagesInfo(pkgName string, from int) (PackagesInfo, error)
}

// PackageVersionsFromName fetch all versions from depot
func (depo *depot) PackageVersionsFromName(pkgName string) ([]string, error) {
func (depo *depot) PackageVersionsFromName(pkgName string, habChannel string) ([]string, error) {
var packages []PackageInfo

offset := 0
Expand All @@ -93,8 +94,13 @@ func (depo *depot) PackageVersionsFromName(pkgName string) ([]string, error) {
if foundVersions[pkg.Version] {
continue
}
versions = append(versions, pkg.Version)
foundVersions[pkg.Version] = true
for _, channel := range pkg.Channels {
if channel == habChannel {
versions = append(versions, pkg.Version)
foundVersions[pkg.Version] = true
break
}
}
}

return versions, nil
Expand Down
Loading