()
| 10 | ) |
| 11 | |
| 12 | func ExampleNew() { |
| 13 | ctx := context.Background() |
| 14 | // use config.Host to provide registry logins, TLS, and other registry settings |
| 15 | exHostLocal := config.Host{ |
| 16 | Name: "registry.example.org:5000", |
| 17 | TLS: config.TLSDisabled, |
| 18 | User: "exUser", |
| 19 | Pass: "exPass", |
| 20 | } |
| 21 | exHostDH := config.Host{ |
| 22 | Name: "docker.io", |
| 23 | User: "dhUser", |
| 24 | Pass: "dhPass", |
| 25 | } |
| 26 | // define a regclient with desired options |
| 27 | rc := regclient.New( |
| 28 | regclient.WithConfigHost([]config.Host{exHostLocal, exHostDH}...), |
| 29 | regclient.WithDockerCerts(), |
| 30 | regclient.WithDockerCreds(), |
| 31 | regclient.WithUserAgent("regclient/example"), |
| 32 | ) |
| 33 | // create a reference for an image |
| 34 | r, err := ref.New("ghcr.io/regclient/regctl:latest") |
| 35 | if err != nil { |
| 36 | fmt.Printf("failed to create ref: %v\n", err) |
| 37 | return |
| 38 | } |
| 39 | defer rc.Close(ctx, r) |
| 40 | // get a manifest (or call other regclient methods) |
| 41 | m, err := rc.ManifestGet(ctx, r) |
| 42 | if err != nil { |
| 43 | fmt.Printf("failed to get manifest: %v\n", err) |
| 44 | return |
| 45 | } |
| 46 | fmt.Println(m.GetDescriptor().MediaType) |
| 47 | // Output: application/vnd.oci.image.index.v1+json |
| 48 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…