mirror of
https://github.com/weaveworks/scope.git
synced 2026-07-18 04:49:55 +00:00
``` gvt delete github.com/fsouza/go-dockerclient gvt delete github.com/docker/docker/opts gvt delete github.com/docker/docker/pkg/archive gvt delete github.com/docker/docker/pkg/fileutils gvt delete github.com/docker/docker/pkg/homedir gvt delete github.com/docker/docker/pkg/idtools gvt delete github.com/docker/docker/pkg/ioutils gvt delete github.com/docker/docker/pkg/longpath gvt delete github.com/docker/docker/pkg/mflag gvt delete github.com/docker/docker/pkg/mount gvt delete github.com/docker/docker/pkg/parsers gvt delete github.com/docker/docker/pkg/pools gvt delete github.com/docker/docker/pkg/promise gvt delete github.com/docker/docker/pkg/stdcopy gvt delete github.com/docker/docker/pkg/system gvt delete github.com/docker/docker/pkg/term gvt delete github.com/docker/docker/pkg/units gvt delete github.com/docker/libcontainer/cgroups gvt delete github.com/docker/distribution/digest gvt delete github.com/docker/distribution/reference gvt delete github.com/docker/distribution/vendor/github.com/stevvooe/resumable gvt fetch --tag 1.2.0 github.com/fsouza/go-dockerclient 2018/07/23 17:03:36 Fetching: github.com/fsouza/go-dockerclient 2018/07/23 17:03:39 · Skipping (existing): github.com/docker/go-units 2018/07/23 17:03:39 · Fetching recursive dependency: github.com/docker/docker/pkg/jsonmessage 2018/07/23 17:03:51 ·· Fetching recursive dependency: github.com/docker/docker/vendor/github.com/Nvveen/Gotty 2018/07/23 17:03:51 ·· Fetching recursive dependency: github.com/docker/docker/vendor/github.com/docker/go-units 2018/07/23 17:03:51 ·· Fetching recursive dependency: github.com/docker/docker/pkg/term 2018/07/23 17:03:51 ··· Fetching recursive dependency: github.com/docker/docker/vendor/github.com/Azure/go-ansiterm 2018/07/23 17:03:51 ··· Fetching recursive dependency: github.com/docker/docker/vendor/github.com/sirupsen/logrus 2018/07/23 17:03:51 ···· Fetching recursive dependency: github.com/docker/docker/vendor/golang.org/x/sys/unix 2018/07/23 17:03:51 ···· Fetching recursive dependency: github.com/docker/docker/vendor/golang.org/x/crypto/ssh/terminal 2018/07/23 17:03:51 ····· Fetching recursive dependency: github.com/docker/docker/vendor/golang.org/x/sys/windows 2018/07/23 17:03:51 · Skipping (existing): github.com/gorilla/mux 2018/07/23 17:03:51 · Fetching recursive dependency: github.com/docker/docker/api/types/swarm 2018/07/23 17:03:51 ·· Fetching recursive dependency: github.com/docker/docker/api/types/network 2018/07/23 17:03:51 ··· Fetching recursive dependency: github.com/docker/docker/api/types/filters 2018/07/23 17:03:51 ···· Fetching recursive dependency: github.com/docker/docker/api/types/versions 2018/07/23 17:03:51 ····· Fetching recursive dependency: github.com/docker/docker/vendor/github.com/docker/go-connections/nat 2018/07/23 17:03:51 ····· Fetching recursive dependency: github.com/docker/docker/api/types 2018/07/23 17:03:51 ······ Fetching recursive dependency: github.com/docker/docker/errdefs 2018/07/23 17:03:51 ······ Fetching recursive dependency: github.com/docker/docker/pkg/streamformatter 2018/07/23 17:03:51 ······· Fetching recursive dependency: github.com/docker/docker/pkg/progress 2018/07/23 17:03:51 ········ Fetching recursive dependency: github.com/docker/docker/vendor/golang.org/x/time/rate 2018/07/23 17:03:51 ········· Fetching recursive dependency: github.com/docker/docker/vendor/golang.org/x/net/context 2018/07/23 17:03:52 ······ Fetching recursive dependency: github.com/docker/docker/vendor/github.com/gogo/protobuf/proto 2018/07/23 17:03:52 ······ Fetching recursive dependency: github.com/docker/docker/vendor/github.com/opencontainers/image-spec/specs-go/v1 2018/07/23 17:03:52 ······· Fetching recursive dependency: github.com/docker/docker/vendor/github.com/opencontainers/go-digest 2018/07/23 17:03:52 ······· Fetching recursive dependency: github.com/docker/docker/vendor/github.com/opencontainers/image-spec/specs-go 2018/07/23 17:03:52 · Fetching recursive dependency: github.com/docker/docker/pkg/homedir 2018/07/23 17:03:52 ·· Fetching recursive dependency: github.com/docker/docker/pkg/idtools 2018/07/23 17:03:52 ··· Fetching recursive dependency: github.com/docker/docker/pkg/system 2018/07/23 17:03:52 ···· Fetching recursive dependency: github.com/docker/docker/vendor/github.com/pkg/errors 2018/07/23 17:03:52 ···· Fetching recursive dependency: github.com/docker/docker/vendor/github.com/Microsoft/go-winio 2018/07/23 17:03:52 ···· Fetching recursive dependency: github.com/docker/docker/vendor/github.com/containerd/continuity/pathdriver 2018/07/23 17:03:52 ···· Fetching recursive dependency: github.com/docker/docker/pkg/mount 2018/07/23 17:03:52 ··· Fetching recursive dependency: github.com/docker/docker/vendor/github.com/opencontainers/runc/libcontainer/user 2018/07/23 17:03:52 · Fetching recursive dependency: github.com/docker/docker/pkg/stdcopy 2018/07/23 17:03:52 · Fetching recursive dependency: github.com/docker/docker/pkg/archive 2018/07/23 17:03:52 ·· Fetching recursive dependency: github.com/docker/docker/pkg/pools 2018/07/23 17:03:52 ··· Fetching recursive dependency: github.com/docker/docker/pkg/ioutils 2018/07/23 17:03:52 ···· Fetching recursive dependency: github.com/docker/docker/pkg/longpath 2018/07/23 17:03:52 ·· Fetching recursive dependency: github.com/docker/docker/vendor/github.com/opencontainers/runc/libcontainer/system 2018/07/23 17:03:52 ·· Fetching recursive dependency: github.com/docker/docker/pkg/fileutils 2018/07/23 17:03:52 ·· Fetching recursive dependency: github.com/docker/docker/vendor/archive/tar 2018/07/23 17:03:52 · Skipping (existing): golang.org/x/net/context 2018/07/23 17:03:52 · Fetching recursive dependency: github.com/docker/docker/opts 2018/07/23 17:03:53 ·· Fetching recursive dependency: github.com/docker/docker/vendor/github.com/docker/libnetwork/ipamutils 2018/07/23 17:03:53 · Skipping (existing): golang.org/x/net/context/ctxhttp 2018/07/23 17:03:53 · Fetching recursive dependency: github.com/Microsoft/go-winio 2018/07/23 17:03:55 ·· Fetching recursive dependency: golang.org/x/sys/windows ```
172 lines
4.4 KiB
Go
172 lines
4.4 KiB
Go
// Copyright 2016 go-dockerclient authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
package docker
|
|
|
|
import (
|
|
"encoding/json"
|
|
"net/http"
|
|
"net/url"
|
|
"strconv"
|
|
|
|
"github.com/docker/docker/api/types/swarm"
|
|
"golang.org/x/net/context"
|
|
)
|
|
|
|
// NoSuchSecret is the error returned when a given secret does not exist.
|
|
type NoSuchSecret struct {
|
|
ID string
|
|
Err error
|
|
}
|
|
|
|
func (err *NoSuchSecret) Error() string {
|
|
if err.Err != nil {
|
|
return err.Err.Error()
|
|
}
|
|
return "No such secret: " + err.ID
|
|
}
|
|
|
|
// CreateSecretOptions specify parameters to the CreateSecret function.
|
|
//
|
|
// See https://goo.gl/KrVjHz for more details.
|
|
type CreateSecretOptions struct {
|
|
Auth AuthConfiguration `qs:"-"`
|
|
swarm.SecretSpec
|
|
Context context.Context
|
|
}
|
|
|
|
// CreateSecret creates a new secret, returning the secret instance
|
|
// or an error in case of failure.
|
|
//
|
|
// See https://goo.gl/KrVjHz for more details.
|
|
func (c *Client) CreateSecret(opts CreateSecretOptions) (*swarm.Secret, error) {
|
|
headers, err := headersWithAuth(opts.Auth)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
path := "/secrets/create?" + queryString(opts)
|
|
resp, err := c.do("POST", path, doOptions{
|
|
headers: headers,
|
|
data: opts.SecretSpec,
|
|
forceJSON: true,
|
|
context: opts.Context,
|
|
})
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer resp.Body.Close()
|
|
var secret swarm.Secret
|
|
if err := json.NewDecoder(resp.Body).Decode(&secret); err != nil {
|
|
return nil, err
|
|
}
|
|
return &secret, nil
|
|
}
|
|
|
|
// RemoveSecretOptions encapsulates options to remove a secret.
|
|
//
|
|
// See https://goo.gl/Tqrtya for more details.
|
|
type RemoveSecretOptions struct {
|
|
ID string `qs:"-"`
|
|
Context context.Context
|
|
}
|
|
|
|
// RemoveSecret removes a secret, returning an error in case of failure.
|
|
//
|
|
// See https://goo.gl/Tqrtya for more details.
|
|
func (c *Client) RemoveSecret(opts RemoveSecretOptions) error {
|
|
path := "/secrets/" + opts.ID
|
|
resp, err := c.do("DELETE", path, doOptions{context: opts.Context})
|
|
if err != nil {
|
|
if e, ok := err.(*Error); ok && e.Status == http.StatusNotFound {
|
|
return &NoSuchSecret{ID: opts.ID}
|
|
}
|
|
return err
|
|
}
|
|
resp.Body.Close()
|
|
return nil
|
|
}
|
|
|
|
// UpdateSecretOptions specify parameters to the UpdateSecret function.
|
|
//
|
|
// Only label can be updated
|
|
// See https://docs.docker.com/engine/api/v1.33/#operation/SecretUpdate
|
|
// See https://goo.gl/wu3MmS for more details.
|
|
type UpdateSecretOptions struct {
|
|
Auth AuthConfiguration `qs:"-"`
|
|
swarm.SecretSpec
|
|
Context context.Context
|
|
Version uint64
|
|
}
|
|
|
|
// UpdateSecret updates the secret at ID with the options
|
|
//
|
|
// See https://goo.gl/wu3MmS for more details.
|
|
func (c *Client) UpdateSecret(id string, opts UpdateSecretOptions) error {
|
|
headers, err := headersWithAuth(opts.Auth)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
params := make(url.Values)
|
|
params.Set("version", strconv.FormatUint(opts.Version, 10))
|
|
resp, err := c.do("POST", "/secrets/"+id+"/update?"+params.Encode(), doOptions{
|
|
headers: headers,
|
|
data: opts.SecretSpec,
|
|
forceJSON: true,
|
|
context: opts.Context,
|
|
})
|
|
if err != nil {
|
|
if e, ok := err.(*Error); ok && e.Status == http.StatusNotFound {
|
|
return &NoSuchSecret{ID: id}
|
|
}
|
|
return err
|
|
}
|
|
defer resp.Body.Close()
|
|
return nil
|
|
}
|
|
|
|
// InspectSecret returns information about a secret by its ID.
|
|
//
|
|
// See https://goo.gl/dHmr75 for more details.
|
|
func (c *Client) InspectSecret(id string) (*swarm.Secret, error) {
|
|
path := "/secrets/" + id
|
|
resp, err := c.do("GET", path, doOptions{})
|
|
if err != nil {
|
|
if e, ok := err.(*Error); ok && e.Status == http.StatusNotFound {
|
|
return nil, &NoSuchSecret{ID: id}
|
|
}
|
|
return nil, err
|
|
}
|
|
defer resp.Body.Close()
|
|
var secret swarm.Secret
|
|
if err := json.NewDecoder(resp.Body).Decode(&secret); err != nil {
|
|
return nil, err
|
|
}
|
|
return &secret, nil
|
|
}
|
|
|
|
// ListSecretsOptions specify parameters to the ListSecrets function.
|
|
//
|
|
// See https://goo.gl/DwvNMd for more details.
|
|
type ListSecretsOptions struct {
|
|
Filters map[string][]string
|
|
Context context.Context
|
|
}
|
|
|
|
// ListSecrets returns a slice of secrets matching the given criteria.
|
|
//
|
|
// See https://goo.gl/DwvNMd for more details.
|
|
func (c *Client) ListSecrets(opts ListSecretsOptions) ([]swarm.Secret, error) {
|
|
path := "/secrets?" + queryString(opts)
|
|
resp, err := c.do("GET", path, doOptions{context: opts.Context})
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer resp.Body.Close()
|
|
var secrets []swarm.Secret
|
|
if err := json.NewDecoder(resp.Body).Decode(&secrets); err != nil {
|
|
return nil, err
|
|
}
|
|
return secrets, nil
|
|
}
|