MCPcopy Index your code
hub / github.com/regclient/regclient / ExampleNew

Function ExampleNew

example_test.go:12–48  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

10)
11
12func 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}

Callers

nothing calls this directly

Calls 9

NewFunction · 0.92
WithConfigHostFunction · 0.92
WithDockerCertsFunction · 0.92
WithDockerCredsFunction · 0.92
WithUserAgentFunction · 0.92
NewFunction · 0.92
CloseMethod · 0.65
ManifestGetMethod · 0.65
GetDescriptorMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…