mirror of
https://github.com/genuinetools/reg.git
synced 2024-09-28 11:46:20 -04:00
domain fixes
This commit is contained in:
parent
1d42ff4384
commit
4a8d8107ef
5 changed files with 47 additions and 5 deletions
25
main.go
25
main.go
|
@ -171,6 +171,31 @@ func main() {
|
|||
// print the tags
|
||||
fmt.Println(strings.Join(tags, "\n"))
|
||||
|
||||
return nil
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: "timestamp",
|
||||
Usage: "get the notary timestamp for the specific reference of a repository",
|
||||
Action: func(c *cli.Context) error {
|
||||
repo, ref, err := getRepoAndRef(c)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
timestamp, err := r.NotaryTimestamp(repo, ref)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
b, err := json.MarshalIndent(timestamp, " ", " ")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// print the tags
|
||||
fmt.Println(string(b))
|
||||
|
||||
return nil
|
||||
},
|
||||
},
|
||||
|
|
15
registry/notary.go
Normal file
15
registry/notary.go
Normal file
|
@ -0,0 +1,15 @@
|
|||
package registry
|
||||
|
||||
// NotaryTimestamp returns a notary timestamp for a specific repository:tag.
|
||||
func (r *Registry) NotaryTimestamp(repository, ref string) (interface{}, error) {
|
||||
url := r.url("/v2/%s/%s/_trust/tuf/timestamp.json", r.Domain, repository)
|
||||
r.Logf("registry.manifests url=%s repository=%s ref=%s", url, repository, ref)
|
||||
|
||||
var ts interface{}
|
||||
_, err := r.getJSON(url, &ts)
|
||||
if err != nil {
|
||||
return ts, err
|
||||
}
|
||||
|
||||
return ts, nil
|
||||
}
|
|
@ -14,6 +14,7 @@ import (
|
|||
// Registry defines the client for retriving information from the registry API.
|
||||
type Registry struct {
|
||||
URL string
|
||||
Domain string
|
||||
Client *http.Client
|
||||
Logf LogfCallback
|
||||
}
|
||||
|
@ -73,6 +74,7 @@ func newFromTransport(auth types.AuthConfig, transport http.RoundTripper, debug
|
|||
|
||||
registry := &Registry{
|
||||
URL: url,
|
||||
Domain: strings.TrimPrefix(url, "https://"),
|
||||
Client: &http.Client{
|
||||
Transport: errorTransport,
|
||||
},
|
||||
|
|
|
@ -247,7 +247,7 @@ func createStaticIndex(r *registry.Registry, staticDir string) error {
|
|||
repos = append(repos, repository{
|
||||
Name: repo,
|
||||
Tags: strings.Join(tags, "<br/>"),
|
||||
RegistryURL: r.URL,
|
||||
RegistryURL: r.Domain,
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -266,9 +266,9 @@ func createStaticIndex(r *registry.Registry, staticDir string) error {
|
|||
lp := filepath.Join(templateDir, "layout.html")
|
||||
|
||||
d := data{
|
||||
RegistryURL: r.URL,
|
||||
RegistryURL: r.Domain,
|
||||
Repos: repos,
|
||||
LastUpdated: time.Now().String(),
|
||||
LastUpdated: time.Now().Format(time.RFC1123),
|
||||
}
|
||||
tmpl := template.Must(template.New("").ParseFiles(lp))
|
||||
if err := tmpl.ExecuteTemplate(f, "layout", d); err != nil {
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
<link rel="stylesheet" href="/css/styles.css" />
|
||||
</head>
|
||||
<body>
|
||||
<h1>{{ .RegistryURL }}<</h1>
|
||||
<h1>{{ .RegistryURL }}</h1>
|
||||
<form>
|
||||
<input name="filter" type="search"><a class="clear">clear</a>
|
||||
</form>
|
||||
|
|
Loading…
Reference in a new issue