-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathclient_example_test.go
50 lines (40 loc) · 1013 Bytes
/
client_example_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package containers_test
import (
"bytes"
"context"
"fmt"
containers "github.com/taubyte/go-simple-container"
)
var client *containers.Client
var err error
var image *containers.Image
func ExampleNew() {
// create new docker client
client, err = containers.New()
if err != nil {
return
}
fmt.Println("success")
// Output: success
}
func ExampleClient_Image() {
// create new docker client
client, err := containers.New()
if err != nil {
return
}
// declare new docker image `node` from docker hub public image `node`
image, err = client.Image(context.Background(), "node")
if err != nil {
return
}
dockerFileTarBall := bytes.NewBuffer(nil)
// Build a custom image using a Dockerfile tarball.
// This will error because we are sending nil bytes. Refer to README for how to build this tarball.
image, err = client.Image(context.Background(), "custom/test:version1", containers.Build(dockerFileTarBall))
if err == nil {
return
}
fmt.Println("success")
// Output: success
}