Skip to content

Commit

Permalink
Ignore: style change for pride and glory
Browse files Browse the repository at this point in the history
  • Loading branch information
ivanilves committed Oct 19, 2017
1 parent 85a18b8 commit 4c5b065
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
6 changes: 1 addition & 5 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,7 @@ func main() {
suicide(err, true)
}

imageSummaries, err := dc.ListImagesForRepo(repoName)
if err != nil {
suicide(err, true)
}
localTags, err := local.FetchTags(repoName, imageSummaries)
localTags, err := local.FetchTags(repoName, dc)
if err != nil {
suicide(err, true)
}
Expand Down
16 changes: 10 additions & 6 deletions tag/local/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,22 @@ package local
import (
"strings"

"github.com/docker/docker/api/types"

dockerclient "github.com/ivanilves/lstags/docker/client"
"github.com/ivanilves/lstags/tag"
)

// FetchTags looks up Docker repo tags and IDs present on local Docker daemon
func FetchTags(repo string, imageSummaries []types.ImageSummary) (map[string]*tag.Tag, error) {
func FetchTags(repoName string, dc *dockerclient.DockerClient) (map[string]*tag.Tag, error) {
imageSummaries, err := dc.ListImagesForRepo(repoName)
if err != nil {
return nil, err
}

tags := make(map[string]*tag.Tag)

for _, imageSummary := range imageSummaries {
repoDigest := extractRepoDigest(imageSummary.RepoDigests)
tagNames := extractTagNames(imageSummary.RepoTags, repo)
tagNames := extractTagNames(imageSummary.RepoTags, repoName)

if repoDigest == "" {
repoDigest = "this.image.is.bad.it.has.no.digest.fuuu!"
Expand Down Expand Up @@ -48,11 +52,11 @@ func extractRepoDigest(repoDigests []string) string {
return digestFields[1]
}

func extractTagNames(repoTags []string, repo string) []string {
func extractTagNames(repoTags []string, repoName string) []string {
tagNames := make([]string, 0)

for _, tag := range repoTags {
if strings.HasPrefix(tag, repo+":") {
if strings.HasPrefix(tag, repoName+":") {
fields := strings.Split(tag, ":")
tagNames = append(tagNames, fields[len(fields)-1])
}
Expand Down

0 comments on commit 4c5b065

Please sign in to comment.