-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Ravi Chamarthy <[email protected]>
- Loading branch information
1 parent
2fe93ce
commit f40de93
Showing
9 changed files
with
1,023 additions
and
747 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,7 @@ | |
|
||
# Dependency directories (remove the comment below to include it) | ||
tools/ | ||
bin/ | ||
.gofmt | ||
.lint | ||
.build | ||
|
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,101 @@ | ||
package main | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"strings" | ||
|
||
"github.com/k0kubun/go-ansi" | ||
"github.com/schollz/progressbar/v3" | ||
"github.com/urfave/cli/v2" | ||
) | ||
|
||
func doFetchTags(c *cli.Context) error { | ||
if c.NArg() < 1 { | ||
return fmt.Errorf("regsistry URL must be specified") | ||
} | ||
|
||
registry := c.Args().Get(0) | ||
prefixes := []string{} | ||
out := getKnowLayersFilename() | ||
if c.NArg() >= 1 { | ||
p := c.Args().Get(1) | ||
prefixes = strings.Split(p, ",") | ||
} | ||
|
||
if c.NArg() >= 2 { | ||
out = c.Args().Get(2) | ||
} | ||
|
||
reg := NewReg(registry, prefixes) | ||
ctx := context.Background() | ||
l, e := reg.GetRepoList(ctx, prefixes) | ||
if e != nil { | ||
return e | ||
} | ||
|
||
entries := LayerNameHashEntries{} | ||
repos := []*Repo{} | ||
bar := progressbar.NewOptions(len(l.Repositories), | ||
progressbar.OptionSetWriter(ansi.NewAnsiStdout()), | ||
progressbar.OptionEnableColorCodes(true), | ||
progressbar.OptionShowBytes(true), | ||
progressbar.OptionSetWidth(15), | ||
progressbar.OptionSetDescription("[cyan][1/2][reset] Fetching Repositories"), | ||
progressbar.OptionSetTheme(progressbar.Theme{ | ||
Saucer: "[green]=[reset]", | ||
SaucerHead: "[green]>[reset]", | ||
SaucerPadding: " ", | ||
BarStart: "[", | ||
BarEnd: "]", | ||
})) | ||
|
||
repoChan := make(chan RepoError, 16) | ||
go reg.FetchRepoInfos(l, repoChan) | ||
|
||
for repo := range repoChan { | ||
r, e := repo.Repo, repo.Err | ||
if e != nil { | ||
return e | ||
} | ||
if e := bar.Add(1); e != nil { | ||
return e | ||
} | ||
repos = append(repos, r) | ||
} | ||
|
||
totalTags := 0 | ||
for _, r := range repos { | ||
totalTags += len(r.Tags) | ||
} | ||
|
||
bar = progressbar.NewOptions(totalTags, | ||
progressbar.OptionSetWriter(ansi.NewAnsiStdout()), | ||
progressbar.OptionEnableColorCodes(true), | ||
progressbar.OptionShowBytes(true), | ||
progressbar.OptionSetWidth(15), | ||
progressbar.OptionSetDescription("[cyan][2/2][reset] Fetching Image Tags"), | ||
progressbar.OptionSetTheme(progressbar.Theme{ | ||
Saucer: "[green]=[reset]", | ||
SaucerHead: "[green]>[reset]", | ||
SaucerPadding: " ", | ||
BarStart: "[", | ||
BarEnd: "]", | ||
})) | ||
|
||
tagChan := make(chan LayerEntryError, 64) | ||
go reg.FetchLayerEntries(repos, tagChan) | ||
|
||
for entryErr := range tagChan { | ||
entry, err := entryErr.Entry, entryErr.Err | ||
if err != nil { | ||
return err | ||
} | ||
if e := bar.Add(1); e != nil { | ||
return e | ||
} | ||
entries = append(entries, entry) | ||
} | ||
|
||
return entries.Save(out) | ||
} |
This file was deleted.
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
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
Oops, something went wrong.