diff options
author | Jake Champlin <jake@gnu.space> | 2017-06-09 17:54:32 +0000 |
---|---|---|
committer | Jake Champlin <jake@gnu.space> | 2017-06-09 17:54:32 +0000 |
commit | 9b12e4fe6f3c95986f1f3ec791636c58ca7e7583 (patch) | |
tree | 38f5f12bec0e488a12f0459a7356e6b7de7d8f84 /vendor/github.com/fsouza/go-dockerclient/misc.go | |
parent | cec3de8a3bcaffd21dedd1bf42da4b490cae7e16 (diff) | |
download | terraform-provider-statuscake-9b12e4fe6f3c95986f1f3ec791636c58ca7e7583.tar.gz terraform-provider-statuscake-9b12e4fe6f3c95986f1f3ec791636c58ca7e7583.tar.zst terraform-provider-statuscake-9b12e4fe6f3c95986f1f3ec791636c58ca7e7583.zip |
Transfer of provider code
Diffstat (limited to 'vendor/github.com/fsouza/go-dockerclient/misc.go')
-rw-r--r-- | vendor/github.com/fsouza/go-dockerclient/misc.go | 124 |
1 files changed, 124 insertions, 0 deletions
diff --git a/vendor/github.com/fsouza/go-dockerclient/misc.go b/vendor/github.com/fsouza/go-dockerclient/misc.go new file mode 100644 index 0000000..ce9e975 --- /dev/null +++ b/vendor/github.com/fsouza/go-dockerclient/misc.go | |||
@@ -0,0 +1,124 @@ | |||
1 | // Copyright 2015 go-dockerclient authors. All rights reserved. | ||
2 | // Use of this source code is governed by a BSD-style | ||
3 | // license that can be found in the LICENSE file. | ||
4 | |||
5 | package docker | ||
6 | |||
7 | import ( | ||
8 | "encoding/json" | ||
9 | "strings" | ||
10 | ) | ||
11 | |||
12 | // Version returns version information about the docker server. | ||
13 | // | ||
14 | // See https://goo.gl/ND9R8L for more details. | ||
15 | func (c *Client) Version() (*Env, error) { | ||
16 | resp, err := c.do("GET", "/version", doOptions{}) | ||
17 | if err != nil { | ||
18 | return nil, err | ||
19 | } | ||
20 | defer resp.Body.Close() | ||
21 | var env Env | ||
22 | if err := env.Decode(resp.Body); err != nil { | ||
23 | return nil, err | ||
24 | } | ||
25 | return &env, nil | ||
26 | } | ||
27 | |||
28 | // DockerInfo contains information about the Docker server | ||
29 | // | ||
30 | // See https://goo.gl/bHUoz9 for more details. | ||
31 | type DockerInfo struct { | ||
32 | ID string | ||
33 | Containers int | ||
34 | ContainersRunning int | ||
35 | ContainersPaused int | ||
36 | ContainersStopped int | ||
37 | Images int | ||
38 | Driver string | ||
39 | DriverStatus [][2]string | ||
40 | SystemStatus [][2]string | ||
41 | Plugins PluginsInfo | ||
42 | MemoryLimit bool | ||
43 | SwapLimit bool | ||
44 | KernelMemory bool | ||
45 | CPUCfsPeriod bool `json:"CpuCfsPeriod"` | ||
46 | CPUCfsQuota bool `json:"CpuCfsQuota"` | ||
47 | CPUShares bool | ||
48 | CPUSet bool | ||
49 | IPv4Forwarding bool | ||
50 | BridgeNfIptables bool | ||
51 | BridgeNfIP6tables bool `json:"BridgeNfIp6tables"` | ||
52 | Debug bool | ||
53 | NFd int | ||
54 | OomKillDisable bool | ||
55 | NGoroutines int | ||
56 | SystemTime string | ||
57 | ExecutionDriver string | ||
58 | LoggingDriver string | ||
59 | CgroupDriver string | ||
60 | NEventsListener int | ||
61 | KernelVersion string | ||
62 | OperatingSystem string | ||
63 | OSType string | ||
64 | Architecture string | ||
65 | IndexServerAddress string | ||
66 | NCPU int | ||
67 | MemTotal int64 | ||
68 | DockerRootDir string | ||
69 | HTTPProxy string `json:"HttpProxy"` | ||
70 | HTTPSProxy string `json:"HttpsProxy"` | ||
71 | NoProxy string | ||
72 | Name string | ||
73 | Labels []string | ||
74 | ExperimentalBuild bool | ||
75 | ServerVersion string | ||
76 | ClusterStore string | ||
77 | ClusterAdvertise string | ||
78 | } | ||
79 | |||
80 | // PluginsInfo is a struct with the plugins registered with the docker daemon | ||
81 | // | ||
82 | // for more information, see: https://goo.gl/bHUoz9 | ||
83 | type PluginsInfo struct { | ||
84 | // List of Volume plugins registered | ||
85 | Volume []string | ||
86 | // List of Network plugins registered | ||
87 | Network []string | ||
88 | // List of Authorization plugins registered | ||
89 | Authorization []string | ||
90 | } | ||
91 | |||
92 | // Info returns system-wide information about the Docker server. | ||
93 | // | ||
94 | // See https://goo.gl/ElTHi2 for more details. | ||
95 | func (c *Client) Info() (*DockerInfo, error) { | ||
96 | resp, err := c.do("GET", "/info", doOptions{}) | ||
97 | if err != nil { | ||
98 | return nil, err | ||
99 | } | ||
100 | defer resp.Body.Close() | ||
101 | var info DockerInfo | ||
102 | if err := json.NewDecoder(resp.Body).Decode(&info); err != nil { | ||
103 | return nil, err | ||
104 | } | ||
105 | return &info, nil | ||
106 | } | ||
107 | |||
108 | // ParseRepositoryTag gets the name of the repository and returns it splitted | ||
109 | // in two parts: the repository and the tag. | ||
110 | // | ||
111 | // Some examples: | ||
112 | // | ||
113 | // localhost.localdomain:5000/samalba/hipache:latest -> localhost.localdomain:5000/samalba/hipache, latest | ||
114 | // localhost.localdomain:5000/samalba/hipache -> localhost.localdomain:5000/samalba/hipache, "" | ||
115 | func ParseRepositoryTag(repoTag string) (repository string, tag string) { | ||
116 | n := strings.LastIndex(repoTag, ":") | ||
117 | if n < 0 { | ||
118 | return repoTag, "" | ||
119 | } | ||
120 | if tag := repoTag[n+1:]; !strings.Contains(tag, "/") { | ||
121 | return repoTag[:n], tag | ||
122 | } | ||
123 | return repoTag, "" | ||
124 | } | ||