This repository has been archived by the owner on Aug 20, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 24
/
client.go
77 lines (64 loc) · 2.66 KB
/
client.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
package client
import (
"context"
"github.com/pkg/errors"
"github.com/rancher/k3c/pkg/log"
pb "github.com/rancher/k3c/pkg/remote/apis/k3c/v1alpha1"
"github.com/rancher/k3c/pkg/status"
v1 "k8s.io/api/core/v1"
)
var (
ErrContainerNotFound = errors.New("container not found")
ErrImageNotFound = errors.New("image not found")
)
type Client interface {
ListPods(ctx context.Context) ([]v1.Pod, error)
CreatePod(ctx context.Context, name string, opts *pb.PodOptions) (string, error)
CreateContainer(ctx context.Context, podID, image string, opts *pb.ContainerOptions) (string, error)
StartContainer(ctx context.Context, containerID string) error
StopContainer(ctx context.Context, containerID string, timeout int64) error
RemoveContainer(ctx context.Context, containerID string) error
LogContainer(ctx context.Context, containerID string, opts *v1.PodLogOptions) (<-chan log.Entry, error)
GetContainer(ctx context.Context, name string) (*v1.Pod, *v1.Container, string, error)
Attach(ctx context.Context, name string, opts *pb.AttachOptions) (*StreamResponse, error)
Exec(ctx context.Context, containerName string, cmd []string, opts *pb.ExecOptions) (*StreamResponse, error)
ListImages(ctx context.Context) (images []Image, err error)
RemoveImage(ctx context.Context, image string) error
PullImage(ctx context.Context, image string, authConfig *AuthConfig) (string, error)
PullProgress(ctx context.Context, image string) (<-chan []status.Info, error)
PushImage(ctx context.Context, image string, authConfig *AuthConfig) error
PushProgress(ctx context.Context, image string) (<-chan []status.Info, error)
GetImage(ctx context.Context, image string) (*Image, error)
TagImage(ctx context.Context, image string, tags ...string) error
CreateVolume(ctx context.Context, name string) (*Volume, error)
ListVolumes(ctx context.Context) ([]Volume, error)
RemoveVolume(ctx context.Context, name string, force bool) error
Events(ctx context.Context) (<-chan status.Event, error)
Close() error
}
type Volume struct {
ID string
}
type StreamResponse struct {
URL string
TTY bool
Stdin bool
}
type Image struct {
ID string
// Other names by which this image is known.
Tags []string
// Digests by which this image is known.
Digests []string
// Size of the image in bytes. Must be > 0.
Size uint64
}
type AuthConfig struct {
Username string `json:"username,omitempty"`
Password string `json:"password,omitempty"`
Auth string `json:"auth,omitempty"`
Email string `json:"email,omitempty"`
ServerAddress string `json:"serveraddress,omitempty"`
IdentityToken string `json:"identitytoken,omitempty"`
RegistryToken string `json:"registrytoken,omitempty"`
}