Skip to content

Commit

Permalink
Time bugfix (#10)
Browse files Browse the repository at this point in the history
* update grouped created at

* fill with space
  • Loading branch information
tomoyamachi authored Dec 26, 2019
1 parent eba21c0 commit 824059c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
16 changes: 15 additions & 1 deletion internal/report/table.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ func (w TableWriter) Write(tags types.ImageTags) (err error) {
targets := utils.StrByLen(tag.Tags)
sort.Sort(targets)

// filled with whitespace
table.Append([]string{
strings.Join(targets, tablewriter.NEWLINE),
strings.Join(fillWithSpaces(targets), tablewriter.NEWLINE),
getBytesize(tag.Byte),
ttos(tag.CreatedAt),
ttos(tag.UploadedAt),
Expand All @@ -39,6 +40,19 @@ func (w TableWriter) Write(tags types.ImageTags) (err error) {
return nil
}

func fillWithSpaces(tagNames []string) []string {
fillWithSpaces := []string{}
for _, tag := range tagNames {
tagStr := tag
whitespaceCnt := tablewriter.MAX_ROW_WIDTH - len(tag)
if whitespaceCnt > 0 {
tagStr = tag + strings.Repeat(tablewriter.SPACE, whitespaceCnt)
}
fillWithSpaces = append(fillWithSpaces, tagStr)
}
return fillWithSpaces
}

func getBytesize(b int) string {
if b == 0 {
return "-"
Expand Down
5 changes: 5 additions & 0 deletions pkg/provider/dockerhub/dockerhub.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,11 @@ func (p *DockerHub) convertResultToTag(summaries []ImageSummary) types.ImageTags
}
// update exist ImageTag
target.Tags = append(target.Tags, imageSummary.Name)
// TODO : write test codes
createdAt, _ := time.Parse(time.RFC3339Nano, imageSummary.LastUpdated)
if createdAt.After(target.CreatedAt) {
target.CreatedAt = createdAt
}
pools[firstHash] = target
}

Expand Down

0 comments on commit 824059c

Please sign in to comment.