mirror of
https://github.com/linuxkit/linuxkit.git
synced 2026-04-04 15:36:15 +00:00
Update notary vendor to 0.6.0
Signed-off-by: Justin Cormack <justin.cormack@docker.com>
This commit is contained in:
86
vendor/github.com/theupdateframework/notary/client/client.go
generated
vendored
86
vendor/github.com/theupdateframework/notary/client/client.go
generated
vendored
@@ -1,88 +1,4 @@
|
||||
/*
|
||||
Package client implements everything required for interacting with a Notary repository.
|
||||
|
||||
Usage
|
||||
|
||||
Use this package by creating a new repository object and calling methods on it.
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"os"
|
||||
"time"
|
||||
|
||||
"github.com/docker/distribution/registry/client/auth"
|
||||
"github.com/docker/distribution/registry/client/auth/challenge"
|
||||
"github.com/docker/distribution/registry/client/transport"
|
||||
notary "github.com/theupdateframework/notary/client"
|
||||
"github.com/theupdateframework/notary/trustpinning"
|
||||
"github.com/theupdateframework/notary/tuf/data"
|
||||
)
|
||||
|
||||
func main() {
|
||||
rootDir := ".trust"
|
||||
if err := os.MkdirAll(rootDir, 0700); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
server := "https://notary.docker.io"
|
||||
image := "docker.io/library/alpine"
|
||||
repo, err := notary.NewFileCachedNotaryRepository(
|
||||
rootDir,
|
||||
data.GUN(image),
|
||||
server,
|
||||
makeHubTransport(server, image),
|
||||
nil,
|
||||
trustpinning.TrustPinConfig{},
|
||||
)
|
||||
|
||||
targets, err := repo.ListTargets()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
for _, tgt := range targets {
|
||||
fmt.Printf("%s\t%s\n", tgt.Name, hex.EncodeToString(tgt.Hashes["sha256"]))
|
||||
}
|
||||
}
|
||||
|
||||
func makeHubTransport(server, image string) http.RoundTripper {
|
||||
base := http.DefaultTransport
|
||||
modifiers := []transport.RequestModifier{
|
||||
transport.NewHeaderRequestModifier(http.Header{
|
||||
"User-Agent": []string{"my-client"},
|
||||
}),
|
||||
}
|
||||
|
||||
authTransport := transport.NewTransport(base, modifiers...)
|
||||
pingClient := &http.Client{
|
||||
Transport: authTransport,
|
||||
Timeout: 5 * time.Second,
|
||||
}
|
||||
req, err := http.NewRequest("GET", server+"/v2/", nil)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
challengeManager := challenge.NewSimpleManager()
|
||||
resp, err := pingClient.Do(req)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
if err := challengeManager.AddResponse(resp); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
tokenHandler := auth.NewTokenHandler(base, nil, image, "pull")
|
||||
modifiers = append(modifiers, auth.NewAuthorizer(challengeManager, tokenHandler, auth.NewBasicHandler(nil)))
|
||||
|
||||
return transport.NewTransport(base, modifiers...)
|
||||
}
|
||||
|
||||
*/
|
||||
//Package client implements everything required for interacting with a Notary repository.
|
||||
package client
|
||||
|
||||
import (
|
||||
|
||||
Reference in New Issue
Block a user