summaryrefslogtreecommitdiff
path: root/vendor
diff options
context:
space:
mode:
Diffstat (limited to 'vendor')
-rw-r--r--vendor/github.com/containers/buildah/buildah.go2
-rw-r--r--vendor/github.com/containers/buildah/go.mod7
-rw-r--r--vendor/github.com/containers/buildah/go.sum20
-rw-r--r--vendor/github.com/containers/buildah/image.go5
-rw-r--r--vendor/github.com/containers/buildah/imagebuildah/build.go2
-rw-r--r--vendor/github.com/containers/buildah/imagebuildah/executor.go9
-rw-r--r--vendor/github.com/containers/buildah/imagebuildah/stage_executor.go7
-rw-r--r--vendor/github.com/containers/buildah/install.md63
-rw-r--r--vendor/github.com/containers/buildah/pkg/cli/common.go3
-rw-r--r--vendor/github.com/containers/buildah/pkg/umask/umask_unsupported.go7
-rw-r--r--vendor/github.com/containers/buildah/run_linux.go28
-rw-r--r--vendor/github.com/containers/common/pkg/subscriptions/mounts.conf1
-rw-r--r--vendor/github.com/containers/common/pkg/subscriptions/subscriptions.go (renamed from vendor/github.com/containers/buildah/pkg/secrets/secrets.go)111
-rw-r--r--vendor/github.com/containers/common/pkg/umask/umask_unix.go (renamed from vendor/github.com/containers/buildah/pkg/umask/umask_unix.go)6
-rw-r--r--vendor/github.com/containers/common/pkg/umask/umask_unsupported.go7
-rw-r--r--vendor/github.com/spf13/cobra/bash_completions.go752
-rw-r--r--vendor/github.com/spf13/cobra/custom_completions.go101
-rw-r--r--vendor/github.com/spf13/cobra/fish_completions.go115
-rw-r--r--vendor/github.com/spf13/cobra/zsh_completions.go55
-rw-r--r--vendor/github.com/varlink/go/LICENSE201
-rw-r--r--vendor/github.com/varlink/go/cmd/varlink-go-interface-generator/main.go445
-rw-r--r--vendor/github.com/varlink/go/varlink/bridge.go65
-rw-r--r--vendor/github.com/varlink/go/varlink/bridge_windows.go63
-rw-r--r--vendor/github.com/varlink/go/varlink/call.go104
-rw-r--r--vendor/github.com/varlink/go/varlink/connection.go291
-rw-r--r--vendor/github.com/varlink/go/varlink/doc.go63
-rw-r--r--vendor/github.com/varlink/go/varlink/idl/idl.go497
-rw-r--r--vendor/github.com/varlink/go/varlink/orgvarlinkservice.go162
-rw-r--r--vendor/github.com/varlink/go/varlink/resolver.go92
-rw-r--r--vendor/github.com/varlink/go/varlink/service.go375
-rw-r--r--vendor/github.com/varlink/go/varlink/socketactivation.go63
-rw-r--r--vendor/github.com/varlink/go/varlink/socketactivation_windows.go7
-rw-r--r--vendor/modules.txt12
33 files changed, 773 insertions, 2968 deletions
diff --git a/vendor/github.com/containers/buildah/buildah.go b/vendor/github.com/containers/buildah/buildah.go
index 9ab47e60c..10e3f17ed 100644
--- a/vendor/github.com/containers/buildah/buildah.go
+++ b/vendor/github.com/containers/buildah/buildah.go
@@ -28,7 +28,7 @@ const (
Package = "buildah"
// Version for the Package. Bump version in contrib/rpm/buildah.spec
// too.
- Version = "1.18.0"
+ Version = "1.19.0-dev"
// The value we use to identify what type of information, currently a
// serialized Builder structure, we are using as per-container state.
// This should only be changed when we make incompatible changes to
diff --git a/vendor/github.com/containers/buildah/go.mod b/vendor/github.com/containers/buildah/go.mod
index b1f3ad67a..0d795f6b6 100644
--- a/vendor/github.com/containers/buildah/go.mod
+++ b/vendor/github.com/containers/buildah/go.mod
@@ -5,12 +5,11 @@ go 1.12
require (
github.com/containerd/containerd v1.4.1 // indirect
github.com/containernetworking/cni v0.7.2-0.20190904153231-83439463f784
- github.com/containers/common v0.26.3
- github.com/containers/image/v5 v5.8.0
+ github.com/containers/common v0.29.0
+ github.com/containers/image/v5 v5.8.1
github.com/containers/ocicrypt v1.0.3
- github.com/containers/storage v1.24.0
+ github.com/containers/storage v1.24.1
github.com/docker/distribution v2.7.1+incompatible
- github.com/docker/docker v17.12.0-ce-rc1.0.20201020191947-73dc6a680cdd+incompatible // indirect
github.com/docker/go-units v0.4.0
github.com/docker/libnetwork v0.8.0-dev.2.0.20190625141545-5a177b73e316
github.com/fsouza/go-dockerclient v1.6.6
diff --git a/vendor/github.com/containers/buildah/go.sum b/vendor/github.com/containers/buildah/go.sum
index 069328c38..e3413bc68 100644
--- a/vendor/github.com/containers/buildah/go.sum
+++ b/vendor/github.com/containers/buildah/go.sum
@@ -73,20 +73,17 @@ github.com/containerd/ttrpc v0.0.0-20190828154514-0e0f228740de/go.mod h1:PvCDdDG
github.com/containerd/typeurl v0.0.0-20180627222232-a93fcdb778cd/go.mod h1:Cm3kwCdlkCfMSHURc+r6fwoGH6/F1hH3S4sg0rLFWPc=
github.com/containernetworking/cni v0.7.2-0.20190904153231-83439463f784 h1:rqUVLD8I859xRgUx/WMC3v7QAFqbLKZbs+0kqYboRJc=
github.com/containernetworking/cni v0.7.2-0.20190904153231-83439463f784/go.mod h1:LGwApLUm2FpoOfxTDEeq8T9ipbpZ61X79hmU3w8FmsY=
-github.com/containers/common v0.26.3 h1:5Kb5fMmJ7/xMiJ+iEbPA+5pQpl/FGxCgJex4nml4Slo=
-github.com/containers/common v0.26.3/go.mod h1:hJWZIlrl5MsE2ELNRa+MPp6I1kPbXHauuj0Ym4BsLG4=
-github.com/containers/image/v5 v5.7.0 h1:fiTC8/Xbr+zEP6njGTZtPW/3UD7MC93nC9DbUoWdxkA=
-github.com/containers/image/v5 v5.7.0/go.mod h1:8aOy+YaItukxghRORkvhq5ibWttHErzDLy6egrKfKos=
-github.com/containers/image/v5 v5.8.0 h1:B3FGHi0bdGXgg698kBIGOlHCXN5n+scJr6/5354GOPU=
-github.com/containers/image/v5 v5.8.0/go.mod h1:jKxdRtyIDumVa56hdsZvV+gwx4zB50hRou6pIuCWLkg=
+github.com/containers/common v0.29.0 h1:hTMC+urdkk5bKfhL/OgCixIX5xjJgQ2l2jPG745ECFQ=
+github.com/containers/common v0.29.0/go.mod h1:yT4GTUHsKRmpaDb+mecXRnIMre7W3ZgwXqaYMywXlaA=
+github.com/containers/image/v5 v5.8.1 h1:aHW8a/Kd0dTJ7PTL/fc6y12sJqHxWgqilu+XyHfjD8Q=
+github.com/containers/image/v5 v5.8.1/go.mod h1:blOEFd/iFdeyh891ByhCVUc+xAcaI3gBegXECwz9UbQ=
github.com/containers/libtrust v0.0.0-20190913040956-14b96171aa3b h1:Q8ePgVfHDplZ7U33NwHZkrVELsZP5fYj9pM5WBZB2GE=
github.com/containers/libtrust v0.0.0-20190913040956-14b96171aa3b/go.mod h1:9rfv8iPl1ZP7aqh9YA68wnZv2NUDbXdcdPHVz0pFbPY=
github.com/containers/ocicrypt v1.0.3 h1:vYgl+RZ9Q3DPMuTfxmN+qp0X2Bj52uuY2vnt6GzVe1c=
github.com/containers/ocicrypt v1.0.3/go.mod h1:CUBa+8MRNL/VkpxYIpaMtgn1WgXGyvPQj8jcy0EVG6g=
-github.com/containers/storage v1.23.6/go.mod h1:haFs0HRowKwyzvWEx9EgI3WsL8XCSnBDb5f8P5CAxJY=
github.com/containers/storage v1.23.7/go.mod h1:cUT2zHjtx+WlVri30obWmM2gpqpi8jfPsmIzP1TVpEI=
-github.com/containers/storage v1.24.0 h1:Fo2LkF7tkMLmo38sTZ/G8wHjcn8JfUFPfyTxM4WwMfk=
-github.com/containers/storage v1.24.0/go.mod h1:A4d3BzuZK9b3oLVEsiSRhZLPIx3z7utgiPyXLK/YMhY=
+github.com/containers/storage v1.24.1 h1:1+f8fy6ly35c8SLet5jzZ8t0WJJs5+xSpfMAYw0R3kc=
+github.com/containers/storage v1.24.1/go.mod h1:0xJL06Dmd+ZYXIUdnBUPN0JnhHGgwMkLvnnAonJfWJU=
github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk=
github.com/coreos/etcd v3.3.13+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE=
github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
@@ -232,8 +229,8 @@ github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvW
github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00=
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
github.com/klauspost/compress v1.11.1/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs=
-github.com/klauspost/compress v1.11.2 h1:MiK62aErc3gIiVEtyzKfeOHgW7atJb5g/KNX5m3c2nQ=
-github.com/klauspost/compress v1.11.2/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs=
+github.com/klauspost/compress v1.11.3 h1:dB4Bn0tN3wdCzQxnS8r06kV74qN/TAfaIS0bVE8h3jc=
+github.com/klauspost/compress v1.11.3/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs=
github.com/klauspost/pgzip v1.2.5 h1:qnWYvvKqedOF2ulHpMG72XQol4ILEJ8k2wwRl/Km8oE=
github.com/klauspost/pgzip v1.2.5/go.mod h1:Ch1tH69qFZu15pkjo5kYi6mth2Zzwzt50oCQKQE9RUs=
github.com/konsorten/go-windows-terminal-sequences v1.0.1 h1:mweAR1A6xJ3oS2pRaGiHgQ4OO8tzTaLawm8vnODuwDk=
@@ -278,7 +275,6 @@ github.com/moby/sys/mount v0.1.1 h1:mdhBytJ1SMmMat0gtzWWjFX/87K5j6E/7Q5z7rR0cZY=
github.com/moby/sys/mount v0.1.1/go.mod h1:FVQFLDRWwyBjDTBNQXDlWnSFREqOo3OKX9aqhmeoo74=
github.com/moby/sys/mountinfo v0.1.0/go.mod h1:w2t2Avltqx8vE7gX5l+QiBKxODu2TX0+Syr3h52Tw4o=
github.com/moby/sys/mountinfo v0.1.3/go.mod h1:w2t2Avltqx8vE7gX5l+QiBKxODu2TX0+Syr3h52Tw4o=
-github.com/moby/sys/mountinfo v0.3.1/go.mod h1:rEr8tzG/lsIZHBtN/JjGG+LMYx9eXgW2JI+6q0qou+A=
github.com/moby/sys/mountinfo v0.4.0 h1:1KInV3Huv18akCu58V7lzNlt+jFmqlu1EaErnEHE/VM=
github.com/moby/sys/mountinfo v0.4.0/go.mod h1:rEr8tzG/lsIZHBtN/JjGG+LMYx9eXgW2JI+6q0qou+A=
github.com/moby/term v0.0.0-20200429084858-129dac9f73f6/go.mod h1:or9wGItza1sRcM4Wd3dIv8DsFHYQuFsMHEdxUIlUxms=
diff --git a/vendor/github.com/containers/buildah/image.go b/vendor/github.com/containers/buildah/image.go
index 154bc503f..7c55020ab 100644
--- a/vendor/github.com/containers/buildah/image.go
+++ b/vendor/github.com/containers/buildah/image.go
@@ -321,10 +321,7 @@ func (i *containerImageRef) NewImageSource(ctx context.Context, sc *types.System
}
// If we're not re-exporting the data, and we're reusing layers individually, reuse
// the blobsum and diff IDs.
- if !i.exporting && !i.squash && layerID != i.layerID {
- if layer.UncompressedDigest == "" {
- return nil, errors.Errorf("unable to look up size of layer %q", layerID)
- }
+ if !i.exporting && !i.squash && layerID != i.layerID && layer.UncompressedDigest != "" {
layerBlobSum := layer.UncompressedDigest
layerBlobSize := layer.UncompressedSize
diffID := layer.UncompressedDigest
diff --git a/vendor/github.com/containers/buildah/imagebuildah/build.go b/vendor/github.com/containers/buildah/imagebuildah/build.go
index a97a403b3..1ec21e786 100644
--- a/vendor/github.com/containers/buildah/imagebuildah/build.go
+++ b/vendor/github.com/containers/buildah/imagebuildah/build.go
@@ -185,6 +185,8 @@ type BuildOptions struct {
Jobs *int
// LogRusage logs resource usage for each step.
LogRusage bool
+ // Excludes is a list of excludes to be used instead of the .dockerignore file.
+ Excludes []string
}
// BuildDockerfiles parses a set of one or more Dockerfiles (which may be
diff --git a/vendor/github.com/containers/buildah/imagebuildah/executor.go b/vendor/github.com/containers/buildah/imagebuildah/executor.go
index 8c96b4e67..3c41ec1d2 100644
--- a/vendor/github.com/containers/buildah/imagebuildah/executor.go
+++ b/vendor/github.com/containers/buildah/imagebuildah/executor.go
@@ -130,9 +130,12 @@ func NewExecutor(store storage.Store, options BuildOptions, mainNode *parser.Nod
return nil, errors.Wrapf(err, "failed to get container config")
}
- excludes, err := imagebuilder.ParseDockerignore(options.ContextDirectory)
- if err != nil {
- return nil, err
+ excludes := options.Excludes
+ if len(excludes) == 0 {
+ excludes, err = imagebuilder.ParseDockerignore(options.ContextDirectory)
+ if err != nil {
+ return nil, err
+ }
}
capabilities, err := defaultContainerConfig.Capabilities("", options.AddCapabilities, options.DropCapabilities)
if err != nil {
diff --git a/vendor/github.com/containers/buildah/imagebuildah/stage_executor.go b/vendor/github.com/containers/buildah/imagebuildah/stage_executor.go
index 6c058e226..191645b89 100644
--- a/vendor/github.com/containers/buildah/imagebuildah/stage_executor.go
+++ b/vendor/github.com/containers/buildah/imagebuildah/stage_executor.go
@@ -368,6 +368,7 @@ func (s *StageExecutor) Run(run imagebuilder.Run, config docker.Config) error {
Stderr: s.executor.err,
Quiet: s.executor.quiet,
NamespaceOptions: s.executor.namespaceOptions,
+ Terminal: buildah.WithoutTerminal,
}
if config.NetworkDisabled {
options.ConfigureNetwork = buildah.NetworkDisabled
@@ -1144,7 +1145,11 @@ func (s *StageExecutor) intermediateImageExists(ctx context.Context, currNode *p
// lines in the Dockerfile up till the point we are at in the build.
manifestType, history, diffIDs, err := s.executor.getImageTypeAndHistoryAndDiffIDs(ctx, image.ID)
if err != nil {
- return "", errors.Wrapf(err, "error getting history of %q", image.ID)
+ // It's possible that this image is for another architecture, which results
+ // in a custom-crafted error message that we'd have to use substring matching
+ // to recognize. Instead, ignore the image.
+ logrus.Debugf("error getting history of %q (%v), ignoring it", image.ID, err)
+ continue
}
// If this candidate isn't of the type that we're building, then it may have lost
// some format-specific information that a building-without-cache run wouldn't lose.
diff --git a/vendor/github.com/containers/buildah/install.md b/vendor/github.com/containers/buildah/install.md
index 00381e16a..119315d1f 100644
--- a/vendor/github.com/containers/buildah/install.md
+++ b/vendor/github.com/containers/buildah/install.md
@@ -59,35 +59,31 @@ sudo dnf -y install buildah
#### [Debian](https://debian.org)
-The buildah package is [being worked on](https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=928083)
-for inclusion in the default Debian repos.
-
-Alternatively, the [Kubic project](https://build.opensuse.org/project/show/devel:kubic:libcontainers:stable)
-provides packages for Debian 10, testing and unstable.
+The buildah package is available in
+the [Bullseye (testing) branch](https://packages.debian.org/bullseye/buildah), which
+will be the next stable release (Debian 11) as well as Debian Unstable/Sid.
```bash
-# Debian Unstable/Sid
-echo 'deb http://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/Debian_Unstable/ /' > /etc/apt/sources.list.d/devel:kubic:libcontainers:stable.list
-wget -nv https://download.opensuse.org/repositories/devel:kubic:libcontainers:stable/Debian_Unstable/Release.key -O Release.key
+# Debian Testing/Bullseye or Unstable/Sid
+sudo apt-get update
+sudo apt-get -y install buildah
+```
-# Debian Testing
-echo 'deb http://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/Debian_Testing/ /' > /etc/apt/sources.list.d/devel:kubic:libcontainers:stable.list
-wget -nv https://download.opensuse.org/repositories/devel:kubic:libcontainers:stable/Debian_Testing/Release.key -O Release.key
+The [Kubic project](https://build.opensuse.org/project/show/devel:kubic:libcontainers:stable)
+provides packages for Debian 10. The Kubic packages for Debian Testing/Bullseye and Debian Unstable/Sid
+have been discontinued to avoid
+[conflicts](https://github.com/containers/buildah/issues/2797) with the official packages.
-# Debian 10
-echo 'deb http://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/Debian_10/ /' > /etc/apt/sources.list.d/devel:kubic:libcontainers:stable.list
-wget -nv https://download.opensuse.org/repositories/devel:kubic:libcontainers:stable/Debian_10/Release.key -O Release.key
+Caution: If you upgrade from Debian 10 to Testing/Bullseye or
+Unstable/Sid you would likely end up downgrading Buildah because the version in
+OBS is more frequently updated than the one in Debian's official repositories,
+due to how Debian works.
-sudo apt-key add - < Release.key
-sudo apt-get update -qq
-sudo apt-get -qq -y install buildah
-```
-
-### [Fedora](https://www.fedoraproject.org), [CentOS](https://www.centos.org)
+### [Fedora](https://www.fedoraproject.org)
```bash
-sudo yum -y install buildah
+sudo dnf -y install buildah
```
### [Fedora SilverBlue](https://silverblue.fedoraproject.org)
@@ -127,19 +123,25 @@ sudo subscription-manager repos --enable=rhel-7-server-extras-rpms
sudo yum -y install buildah
```
-#### [Raspbian](https://raspbian.org)
+#### [Raspberry Pi OS armhf (ex Raspbian)](https://www.raspberrypi.org/downloads/raspberry-pi-os/)
The Kubic project provides packages for Raspbian 10.
```bash
# Raspbian 10
-echo 'deb http://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/Raspbian_10/ /' > /etc/apt/sources.list.d/devel:kubic:libcontainers:stable.list
-wget -nv https://download.opensuse.org/repositories/devel:kubic:libcontainers:stable/Raspbian_10/Release.key -O Release.key
-sudo apt-key add - < Release.key
+echo 'deb https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/Raspbian_10/ /' | sudo tee /etc/apt/sources.list.d/devel:kubic:libcontainers:stable.list
+curl -L https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/Raspbian_10/Release.key | sudo apt-key add -
sudo apt-get update -qq
sudo apt-get -qq -y install buildah
```
+#### [Raspberry Pi OS arm64 (beta)](https://downloads.raspberrypi.org/raspios_arm64/images/)
+
+Raspberry Pi OS use the standard Debian's repositories,
+so it is fully compatible with Debian's arm64 repository.
+You can simply follow the [steps for Debian](#debian) to install podman.
+
+
### [RHEL8 Beta](https://www.redhat.com/en/blog/powering-its-future-while-preserving-present-introducing-red-hat-enterprise-linux-8-beta?intcmp=701f2000001Cz6OAAS)
```bash
@@ -149,7 +151,16 @@ sudo yum module install -y buildah
### [Ubuntu](https://www.ubuntu.com)
-The Kubic project provides packages for Ubuntu 18.04, 19.04 and 19.10 (it should also work with direct derivatives like Pop!\_OS).
+The buildah package is available in the official repositories for Ubuntu 20.10
+and newer.
+
+```bash
+# Ubuntu 20.10 and newer
+sudo apt-get -y update
+sudo apt-get -y install buildah
+```
+
+The [Kubic project](https://build.opensuse.org/package/show/devel:kubic:libcontainers:stable/buildah) provides packages for some older but supported Ubuntu versions (it should also work with direct derivatives like Pop!\_OS).
```bash
. /etc/os-release
diff --git a/vendor/github.com/containers/buildah/pkg/cli/common.go b/vendor/github.com/containers/buildah/pkg/cli/common.go
index 62a328de0..123548d97 100644
--- a/vendor/github.com/containers/buildah/pkg/cli/common.go
+++ b/vendor/github.com/containers/buildah/pkg/cli/common.go
@@ -59,6 +59,7 @@ type BudResults struct {
Creds string
DisableCompression bool
DisableContentTrust bool
+ IgnoreFile string
File []string
Format string
Iidfile string
@@ -185,6 +186,7 @@ func GetBudFlags(flags *BudResults) pflag.FlagSet {
fs.StringVar(&flags.Creds, "creds", "", "use `[username[:password]]` for accessing the registry")
fs.BoolVarP(&flags.DisableCompression, "disable-compression", "D", true, "don't compress layers by default")
fs.BoolVar(&flags.DisableContentTrust, "disable-content-trust", false, "This is a Docker specific option and is a NOOP")
+ fs.StringVar(&flags.IgnoreFile, "ignorefile", "", "path to an alternate .dockerignore file")
fs.StringSliceVarP(&flags.File, "file", "f", []string{}, "`pathname or URL` of a Dockerfile")
fs.StringVar(&flags.Format, "format", DefaultFormat(), "`format` of the built image's manifest and metadata. Use BUILDAH_FORMAT environment variable to override.")
fs.StringVar(&flags.Iidfile, "iidfile", "", "`file` to write the image ID to")
@@ -231,6 +233,7 @@ func GetBudFlagsCompletions() commonComp.FlagCompletions {
flagCompletion["creds"] = commonComp.AutocompleteNone
flagCompletion["file"] = commonComp.AutocompleteDefault
flagCompletion["format"] = commonComp.AutocompleteNone
+ flagCompletion["ignorefile"] = commonComp.AutocompleteDefault
flagCompletion["iidfile"] = commonComp.AutocompleteDefault
flagCompletion["jobs"] = commonComp.AutocompleteNone
flagCompletion["label"] = commonComp.AutocompleteNone
diff --git a/vendor/github.com/containers/buildah/pkg/umask/umask_unsupported.go b/vendor/github.com/containers/buildah/pkg/umask/umask_unsupported.go
deleted file mode 100644
index 20913a718..000000000
--- a/vendor/github.com/containers/buildah/pkg/umask/umask_unsupported.go
+++ /dev/null
@@ -1,7 +0,0 @@
-// +build !linux,!darwin
-
-package umask
-
-func CheckUmask() {}
-
-func SetUmask(int) int { return 0 }
diff --git a/vendor/github.com/containers/buildah/run_linux.go b/vendor/github.com/containers/buildah/run_linux.go
index d907941ed..d20d39423 100644
--- a/vendor/github.com/containers/buildah/run_linux.go
+++ b/vendor/github.com/containers/buildah/run_linux.go
@@ -25,10 +25,10 @@ import (
"github.com/containers/buildah/chroot"
"github.com/containers/buildah/copier"
"github.com/containers/buildah/pkg/overlay"
- "github.com/containers/buildah/pkg/secrets"
"github.com/containers/buildah/util"
"github.com/containers/common/pkg/capabilities"
"github.com/containers/common/pkg/config"
+ "github.com/containers/common/pkg/subscriptions"
"github.com/containers/storage/pkg/idtools"
"github.com/containers/storage/pkg/ioutils"
"github.com/containers/storage/pkg/reexec"
@@ -216,16 +216,28 @@ func (b *Builder) Run(command []string, options RunOptions) error {
}
// Empty file, so no need to recreate if it exists
if _, ok := bindFiles["/run/.containerenv"]; !ok {
- // Empty string for now, but we may consider populating this later
containerenvPath := filepath.Join(path, "/run/.containerenv")
if err = os.MkdirAll(filepath.Dir(containerenvPath), 0755); err != nil {
return err
}
- emptyFile, err := os.Create(containerenvPath)
- if err != nil {
+
+ rootless := 0
+ if unshare.IsRootless() {
+ rootless = 1
+ }
+ // Populate the .containerenv with container information
+ containerenv := fmt.Sprintf(`\
+engine="buildah-%s"
+name=%q
+id=%q
+image=%q
+imageid=%q
+rootless=%d
+`, Version, b.Container, b.ContainerID, b.FromImage, b.FromImageID, rootless)
+
+ if err = ioutils.AtomicWriteFile(containerenvPath, []byte(containerenv), 0755); err != nil {
return err
}
- emptyFile.Close()
if err := label.Relabel(containerenvPath, b.MountLabel, false); err != nil {
return err
}
@@ -477,15 +489,15 @@ func (b *Builder) setupMounts(mountPoint string, spec *specs.Spec, bundlePath st
return errors.Wrapf(err, "error determining work directory for container %q", b.ContainerID)
}
- // Figure out which UID and GID to tell the secrets package to use
+ // Figure out which UID and GID to tell the subscritions package to use
// for files that it creates.
rootUID, rootGID, err := util.GetHostRootIDs(spec)
if err != nil {
return err
}
- // Get the list of secrets mounts.
- secretMounts := secrets.SecretMountsWithUIDGID(b.MountLabel, cdir, b.DefaultMountsFilePath, mountPoint, int(rootUID), int(rootGID), unshare.IsRootless(), false)
+ // Get the list of subscriptionss mounts.
+ secretMounts := subscriptions.MountsWithUIDGID(b.MountLabel, cdir, b.DefaultMountsFilePath, mountPoint, int(rootUID), int(rootGID), unshare.IsRootless(), false)
// Add temporary copies of the contents of volume locations at the
// volume locations, unless we already have something there.
diff --git a/vendor/github.com/containers/common/pkg/subscriptions/mounts.conf b/vendor/github.com/containers/common/pkg/subscriptions/mounts.conf
new file mode 100644
index 000000000..b7cde9d8a
--- /dev/null
+++ b/vendor/github.com/containers/common/pkg/subscriptions/mounts.conf
@@ -0,0 +1 @@
+/usr/share/rhel/secrets:/run/secrets
diff --git a/vendor/github.com/containers/buildah/pkg/secrets/secrets.go b/vendor/github.com/containers/common/pkg/subscriptions/subscriptions.go
index 32f888fa8..6aa66b0c8 100644
--- a/vendor/github.com/containers/buildah/pkg/secrets/secrets.go
+++ b/vendor/github.com/containers/common/pkg/subscriptions/subscriptions.go
@@ -1,4 +1,4 @@
-package secrets
+package subscriptions
import (
"bufio"
@@ -7,7 +7,7 @@ import (
"path/filepath"
"strings"
- "github.com/containers/buildah/pkg/umask"
+ "github.com/containers/common/pkg/umask"
"github.com/containers/storage/pkg/idtools"
rspec "github.com/opencontainers/runtime-spec/specs-go"
"github.com/opencontainers/selinux/go-selinux/label"
@@ -27,16 +27,16 @@ var (
UserOverrideMountsFile = filepath.Join(os.Getenv("HOME"), ".config/containers/mounts.conf")
)
-// secretData stores the name of the file and the content read from it
-type secretData struct {
+// subscriptionData stores the name of the file and the content read from it
+type subscriptionData struct {
name string
data []byte
mode os.FileMode
dirMode os.FileMode
}
-// saveTo saves secret data to given directory
-func (s secretData) saveTo(dir string) error {
+// saveTo saves subscription data to given directory
+func (s subscriptionData) saveTo(dir string) error {
path := filepath.Join(dir, s.name)
if err := os.MkdirAll(filepath.Dir(path), s.dirMode); err != nil {
return err
@@ -44,10 +44,10 @@ func (s secretData) saveTo(dir string) error {
return ioutil.WriteFile(path, s.data, s.mode)
}
-func readAll(root, prefix string, parentMode os.FileMode) ([]secretData, error) {
+func readAll(root, prefix string, parentMode os.FileMode) ([]subscriptionData, error) {
path := filepath.Join(root, prefix)
- data := []secretData{}
+ data := []subscriptionData{}
files, err := ioutil.ReadDir(path)
if err != nil {
@@ -74,7 +74,7 @@ func readAll(root, prefix string, parentMode os.FileMode) ([]secretData, error)
return data, nil
}
-func readFileOrDir(root, name string, parentMode os.FileMode) ([]secretData, error) {
+func readFileOrDir(root, name string, parentMode os.FileMode) ([]subscriptionData, error) {
path := filepath.Join(root, name)
s, err := os.Stat(path)
@@ -93,7 +93,7 @@ func readFileOrDir(root, name string, parentMode os.FileMode) ([]secretData, err
if err != nil {
return nil, err
}
- return []secretData{{
+ return []subscriptionData{{
name: name,
data: bytes,
mode: s.Mode(),
@@ -101,13 +101,13 @@ func readFileOrDir(root, name string, parentMode os.FileMode) ([]secretData, err
}}, nil
}
-func getHostSecretData(hostDir string, mode os.FileMode) ([]secretData, error) {
- var allSecrets []secretData
- hostSecrets, err := readAll(hostDir, "", mode)
+func getHostSubscriptionData(hostDir string, mode os.FileMode) ([]subscriptionData, error) {
+ var allSubscriptions []subscriptionData
+ hostSubscriptions, err := readAll(hostDir, "", mode)
if err != nil {
- return nil, errors.Wrapf(err, "failed to read secrets from %q", hostDir)
+ return nil, errors.Wrapf(err, "failed to read subscriptions from %q", hostDir)
}
- return append(allSecrets, hostSecrets...), nil
+ return append(allSubscriptions, hostSubscriptions...), nil
}
func getMounts(filePath string) []string {
@@ -136,7 +136,7 @@ func getMounts(filePath string) []string {
}
// getHostAndCtrDir separates the host:container paths
-func getMountsMap(path string) (string, string, error) {
+func getMountsMap(path string) (string, string, error) { //nolint
arr := strings.SplitN(path, ":", 2)
switch len(arr) {
case 1:
@@ -147,27 +147,21 @@ func getMountsMap(path string) (string, string, error) {
return "", "", errors.Errorf("unable to get host and container dir from path: %s", path)
}
-// SecretMounts copies, adds, and mounts the secrets to the container root filesystem
-// Deprecated, Please use SecretMountWithUIDGID
-func SecretMounts(mountLabel, containerWorkingDir, mountFile string, rootless, disableFips bool) []rspec.Mount {
- return SecretMountsWithUIDGID(mountLabel, containerWorkingDir, mountFile, containerWorkingDir, 0, 0, rootless, disableFips)
-}
-
-// SecretMountsWithUIDGID copies, adds, and mounts the secrets to the container root filesystem
+// MountsWithUIDGID copies, adds, and mounts the subscriptions to the container root filesystem
// mountLabel: MAC/SELinux label for container content
-// containerWorkingDir: Private data for storing secrets on the host mounted in container.
+// containerWorkingDir: Private data for storing subscriptions on the host mounted in container.
// mountFile: Additional mount points required for the container.
// mountPoint: Container image mountpoint
-// uid: to assign to content created for secrets
-// gid: to assign to content created for secrets
+// uid: to assign to content created for subscriptions
+// gid: to assign to content created for subscriptions
// rootless: indicates whether container is running in rootless mode
// disableFips: indicates whether system should ignore fips mode
-func SecretMountsWithUIDGID(mountLabel, containerWorkingDir, mountFile, mountPoint string, uid, gid int, rootless, disableFips bool) []rspec.Mount {
+func MountsWithUIDGID(mountLabel, containerWorkingDir, mountFile, mountPoint string, uid, gid int, rootless, disableFips bool) []rspec.Mount {
var (
- secretMounts []rspec.Mount
- mountFiles []string
+ subscriptionMounts []rspec.Mount
+ mountFiles []string
)
- // Add secrets from paths given in the mounts.conf files
+ // Add subscriptions from paths given in the mounts.conf files
// mountFile will have a value if the hidden --default-mounts-file flag is set
// Note for testing purposes only
if mountFile == "" {
@@ -180,31 +174,32 @@ func SecretMountsWithUIDGID(mountLabel, containerWorkingDir, mountFile, mountPoi
}
for _, file := range mountFiles {
if _, err := os.Stat(file); err == nil {
- mounts, err := addSecretsFromMountsFile(file, mountLabel, containerWorkingDir, uid, gid)
+ mounts, err := addSubscriptionsFromMountsFile(file, mountLabel, containerWorkingDir, uid, gid)
if err != nil {
- logrus.Warnf("error mounting secrets, skipping entry in %s: %v", file, err)
+ logrus.Warnf("error mounting subscriptions, skipping entry in %s: %v", file, err)
}
- secretMounts = mounts
+ subscriptionMounts = mounts
break
}
}
- // Only add FIPS secret mount if disableFips=false
+ // Only add FIPS subscription mount if disableFips=false
if disableFips {
- return secretMounts
+ return subscriptionMounts
}
- // Add FIPS mode secret if /etc/system-fips exists on the host
+ // Add FIPS mode subscription if /etc/system-fips exists on the host
_, err := os.Stat("/etc/system-fips")
- if err == nil {
- if err := addFIPSModeSecret(&secretMounts, containerWorkingDir, mountPoint, mountLabel, uid, gid); err != nil {
- logrus.Errorf("error adding FIPS mode secret to container: %v", err)
+ switch {
+ case err == nil:
+ if err := addFIPSModeSubscription(&subscriptionMounts, containerWorkingDir, mountPoint, mountLabel, uid, gid); err != nil {
+ logrus.Errorf("error adding FIPS mode subscription to container: %v", err)
}
- } else if os.IsNotExist(err) {
- logrus.Debug("/etc/system-fips does not exist on host, not mounting FIPS mode secret")
- } else {
- logrus.Errorf("stat /etc/system-fips failed for FIPS mode secret: %v", err)
+ case os.IsNotExist(err):
+ logrus.Debug("/etc/system-fips does not exist on host, not mounting FIPS mode subscription")
+ default:
+ logrus.Errorf("stat /etc/system-fips failed for FIPS mode subscription: %v", err)
}
- return secretMounts
+ return subscriptionMounts
}
func rchown(chowndir string, uid, gid int) error {
@@ -213,9 +208,9 @@ func rchown(chowndir string, uid, gid int) error {
})
}
-// addSecretsFromMountsFile copies the contents of host directory to container directory
+// addSubscriptionsFromMountsFile copies the contents of host directory to container directory
// and returns a list of mounts
-func addSecretsFromMountsFile(filePath, mountLabel, containerWorkingDir string, uid, gid int) ([]rspec.Mount, error) {
+func addSubscriptionsFromMountsFile(filePath, mountLabel, containerWorkingDir string, uid, gid int) ([]rspec.Mount, error) {
var mounts []rspec.Mount
defaultMountsPaths := getMounts(filePath)
for _, path := range defaultMountsPaths {
@@ -235,7 +230,7 @@ func addSecretsFromMountsFile(filePath, mountLabel, containerWorkingDir string,
ctrDirOrFileOnHost := filepath.Join(containerWorkingDir, ctrDirOrFile)
- // In the event of a restart, don't want to copy secrets over again as they already would exist in ctrDirOrFileOnHost
+ // In the event of a restart, don't want to copy subscriptions over again as they already would exist in ctrDirOrFileOnHost
_, err = os.Stat(ctrDirOrFileOnHost)
if os.IsNotExist(err) {
@@ -245,17 +240,17 @@ func addSecretsFromMountsFile(filePath, mountLabel, containerWorkingDir string,
}
// Don't let the umask have any influence on the file and directory creation
- oldUmask := umask.SetUmask(0)
- defer umask.SetUmask(oldUmask)
+ oldUmask := umask.Set(0)
+ defer umask.Set(oldUmask)
switch mode := fileInfo.Mode(); {
case mode.IsDir():
if err = os.MkdirAll(ctrDirOrFileOnHost, mode.Perm()); err != nil {
return nil, errors.Wrapf(err, "making container directory %q failed", ctrDirOrFileOnHost)
}
- data, err := getHostSecretData(hostDirOrFile, mode.Perm())
+ data, err := getHostSubscriptionData(hostDirOrFile, mode.Perm())
if err != nil {
- return nil, errors.Wrapf(err, "getting host secret data failed")
+ return nil, errors.Wrapf(err, "getting host subscription data failed")
}
for _, s := range data {
if err := s.saveTo(ctrDirOrFileOnHost); err != nil {
@@ -305,15 +300,15 @@ func addSecretsFromMountsFile(filePath, mountLabel, containerWorkingDir string,
return mounts, nil
}
-// addFIPSModeSecret creates /run/secrets/system-fips in the container
+// addFIPSModeSubscription creates /run/secrets/system-fips in the container
// root filesystem if /etc/system-fips exists on hosts.
// This enables the container to be FIPS compliant and run openssl in
// FIPS mode as the host is also in FIPS mode.
-func addFIPSModeSecret(mounts *[]rspec.Mount, containerWorkingDir, mountPoint, mountLabel string, uid, gid int) error {
- secretsDir := "/run/secrets"
- ctrDirOnHost := filepath.Join(containerWorkingDir, secretsDir)
+func addFIPSModeSubscription(mounts *[]rspec.Mount, containerWorkingDir, mountPoint, mountLabel string, uid, gid int) error {
+ subscriptionsDir := "/run/secrets"
+ ctrDirOnHost := filepath.Join(containerWorkingDir, subscriptionsDir)
if _, err := os.Stat(ctrDirOnHost); os.IsNotExist(err) {
- if err = idtools.MkdirAllAs(ctrDirOnHost, 0755, uid, gid); err != nil {
+ if err = idtools.MkdirAllAs(ctrDirOnHost, 0755, uid, gid); err != nil { //nolint
return errors.Wrapf(err, "making container directory %q on host failed", ctrDirOnHost)
}
if err = label.Relabel(ctrDirOnHost, mountLabel, false); err != nil {
@@ -330,10 +325,10 @@ func addFIPSModeSecret(mounts *[]rspec.Mount, containerWorkingDir, mountPoint, m
defer file.Close()
}
- if !mountExists(*mounts, secretsDir) {
+ if !mountExists(*mounts, subscriptionsDir) {
m := rspec.Mount{
Source: ctrDirOnHost,
- Destination: secretsDir,
+ Destination: subscriptionsDir,
Type: "bind",
Options: []string{"bind", "rprivate"},
}
diff --git a/vendor/github.com/containers/buildah/pkg/umask/umask_unix.go b/vendor/github.com/containers/common/pkg/umask/umask_unix.go
index 02e10945b..bb589f7ac 100644
--- a/vendor/github.com/containers/buildah/pkg/umask/umask_unix.go
+++ b/vendor/github.com/containers/common/pkg/umask/umask_unix.go
@@ -8,13 +8,13 @@ import (
"github.com/sirupsen/logrus"
)
-func CheckUmask() {
- oldUmask := syscall.Umask(0022)
+func Check() {
+ oldUmask := syscall.Umask(0022) //nolint
if (oldUmask & ^0022) != 0 {
logrus.Debugf("umask value too restrictive. Forcing it to 022")
}
}
-func SetUmask(value int) int {
+func Set(value int) int {
return syscall.Umask(value)
}
diff --git a/vendor/github.com/containers/common/pkg/umask/umask_unsupported.go b/vendor/github.com/containers/common/pkg/umask/umask_unsupported.go
new file mode 100644
index 000000000..9041d5f20
--- /dev/null
+++ b/vendor/github.com/containers/common/pkg/umask/umask_unsupported.go
@@ -0,0 +1,7 @@
+// +build !linux,!darwin
+
+package umask
+
+func Check() {}
+
+func Set(int) int { return 0 }
diff --git a/vendor/github.com/spf13/cobra/bash_completions.go b/vendor/github.com/spf13/cobra/bash_completions.go
index 2ceebc552..846636d75 100644
--- a/vendor/github.com/spf13/cobra/bash_completions.go
+++ b/vendor/github.com/spf13/cobra/bash_completions.go
@@ -5,95 +5,70 @@ import (
"fmt"
"io"
"os"
+ "sort"
+ "strings"
+
+ "github.com/spf13/pflag"
)
// Annotations for Bash completion.
const (
- BashCompFilenameExt = "cobra_annotation_bash_completion_filename_extensions"
- // BashCompCustom should be avoided as it only works for bash.
- // Function RegisterFlagCompletionFunc() should be used instead.
+ BashCompFilenameExt = "cobra_annotation_bash_completion_filename_extensions"
BashCompCustom = "cobra_annotation_bash_completion_custom"
BashCompOneRequiredFlag = "cobra_annotation_bash_completion_one_required_flag"
BashCompSubdirsInDir = "cobra_annotation_bash_completion_subdirs_in_dir"
)
-// GenBashCompletion generates bash completion file and writes to the passed writer.
-func (c *Command) GenBashCompletion(w io.Writer) error {
- return c.genBashCompletion(w, false)
-}
-
-// GenBashCompletionWithDesc generates bash completion file with descriptions and writes to the passed writer.
-func (c *Command) GenBashCompletionWithDesc(w io.Writer) error {
- return c.genBashCompletion(w, true)
-}
-
-// GenBashCompletionFile generates bash completion file.
-func (c *Command) GenBashCompletionFile(filename string) error {
- return c.genBashCompletionFile(filename, false)
-}
-
-// GenBashCompletionFileWithDesc generates bash completion file with descriptions.
-func (c *Command) GenBashCompletionFileWithDesc(filename string) error {
- return c.genBashCompletionFile(filename, true)
+func writePreamble(buf *bytes.Buffer, name string) {
+ buf.WriteString(fmt.Sprintf("# bash completion for %-36s -*- shell-script -*-\n", name))
+ buf.WriteString(fmt.Sprintf(`
+__%[1]s_debug()
+{
+ if [[ -n ${BASH_COMP_DEBUG_FILE} ]]; then
+ echo "$*" >> "${BASH_COMP_DEBUG_FILE}"
+ fi
}
-func (c *Command) genBashCompletionFile(filename string, includeDesc bool) error {
- outFile, err := os.Create(filename)
- if err != nil {
- return err
- }
- defer outFile.Close()
-
- return c.genBashCompletion(outFile, includeDesc)
+# Homebrew on Macs have version 1.3 of bash-completion which doesn't include
+# _init_completion. This is a very minimal version of that function.
+__%[1]s_init_completion()
+{
+ COMPREPLY=()
+ _get_comp_words_by_ref "$@" cur prev words cword
}
-func (c *Command) genBashCompletion(w io.Writer, includeDesc bool) error {
- buf := new(bytes.Buffer)
- if len(c.BashCompletionFunction) > 0 {
- buf.WriteString(c.BashCompletionFunction + "\n")
- }
- genBashComp(buf, c.Name(), includeDesc)
-
- _, err := buf.WriteTo(w)
- return err
+__%[1]s_index_of_word()
+{
+ local w word=$1
+ shift
+ index=0
+ for w in "$@"; do
+ [[ $w = "$word" ]] && return
+ index=$((index+1))
+ done
+ index=-1
}
-func genBashComp(buf *bytes.Buffer, name string, includeDesc bool) {
- compCmd := ShellCompRequestCmd
- if !includeDesc {
- compCmd = ShellCompNoDescRequestCmd
- }
-
- buf.WriteString(fmt.Sprintf(`# bash completion for %-36[1]s -*- shell-script -*-
-
-__%[1]s_debug()
+__%[1]s_contains_word()
{
- if [[ -n ${BASH_COMP_DEBUG_FILE} ]]; then
- echo "$*" >> "${BASH_COMP_DEBUG_FILE}"
- fi
+ local w word=$1; shift
+ for w in "$@"; do
+ [[ $w = "$word" ]] && return
+ done
+ return 1
}
-__%[1]s_perform_completion()
+__%[1]s_handle_go_custom_completion()
{
- __%[1]s_debug
- __%[1]s_debug "========= starting completion logic =========="
- __%[1]s_debug "cur is ${cur}, words[*] is ${words[*]}, #words[@] is ${#words[@]}, cword is $cword"
-
- # The user could have moved the cursor backwards on the command-line.
- # We need to trigger completion from the $cword location, so we need
- # to truncate the command-line ($words) up to the $cword location.
- words=("${words[@]:0:$cword+1}")
- __%[1]s_debug "Truncated words[*]: ${words[*]},"
+ __%[1]s_debug "${FUNCNAME[0]}: cur is ${cur}, words[*] is ${words[*]}, #words[@] is ${#words[@]}"
local shellCompDirectiveError=%[3]d
local shellCompDirectiveNoSpace=%[4]d
local shellCompDirectiveNoFileComp=%[5]d
local shellCompDirectiveFilterFileExt=%[6]d
local shellCompDirectiveFilterDirs=%[7]d
- local shellCompDirectiveLegacyCustomComp=%[8]d
- local shellCompDirectiveLegacyCustomArgsComp=%[9]d
- local out requestComp lastParam lastChar comp directive args flagPrefix
+ local out requestComp lastParam lastChar comp directive args
# Prepare the command to request completions for the program.
# Calling ${words[0]} instead of directly %[1]s allows to handle aliases
@@ -102,24 +77,16 @@ __%[1]s_perform_completion()
lastParam=${words[$((${#words[@]}-1))]}
lastChar=${lastParam:$((${#lastParam}-1)):1}
- __%[1]s_debug "lastParam ${lastParam}, lastChar ${lastChar}"
+ __%[1]s_debug "${FUNCNAME[0]}: lastParam ${lastParam}, lastChar ${lastChar}"
if [ -z "${cur}" ] && [ "${lastChar}" != "=" ]; then
# If the last parameter is complete (there is a space following it)
# We add an extra empty parameter so we can indicate this to the go method.
- __%[1]s_debug "Adding extra empty parameter"
+ __%[1]s_debug "${FUNCNAME[0]}: Adding extra empty parameter"
requestComp="${requestComp} \"\""
fi
- # When completing a flag with an = (e.g., %[1]s -n=<TAB>)
- # bash focuses on the part after the =, so we need to remove
- # the flag part from $cur
- if [[ "${cur}" == -*=* ]]; then
- flagPrefix="${cur%%%%=*}="
- cur="${cur#*=}"
- fi
-
- __%[1]s_debug "Calling ${requestComp}"
+ __%[1]s_debug "${FUNCNAME[0]}: calling ${requestComp}"
# Use eval to handle any environment variables and such
out=$(eval "${requestComp}" 2>/dev/null)
@@ -131,23 +98,23 @@ __%[1]s_perform_completion()
# There is not directive specified
directive=0
fi
- __%[1]s_debug "The completion directive is: ${directive}"
- __%[1]s_debug "The completions are: ${out[*]}"
+ __%[1]s_debug "${FUNCNAME[0]}: the completion directive is: ${directive}"
+ __%[1]s_debug "${FUNCNAME[0]}: the completions are: ${out[*]}"
if [ $((directive & shellCompDirectiveError)) -ne 0 ]; then
# Error code. No completion.
- __%[1]s_debug "Received error from custom completion go code"
+ __%[1]s_debug "${FUNCNAME[0]}: received error from custom completion go code"
return
else
if [ $((directive & shellCompDirectiveNoSpace)) -ne 0 ]; then
if [[ $(type -t compopt) = "builtin" ]]; then
- __%[1]s_debug "Activating no space"
+ __%[1]s_debug "${FUNCNAME[0]}: activating no space"
compopt -o nospace
fi
fi
if [ $((directive & shellCompDirectiveNoFileComp)) -ne 0 ]; then
if [[ $(type -t compopt) = "builtin" ]]; then
- __%[1]s_debug "Activating no file completion"
+ __%[1]s_debug "${FUNCNAME[0]}: activating no file completion"
compopt +o default
fi
fi
@@ -156,7 +123,6 @@ __%[1]s_perform_completion()
if [ $((directive & shellCompDirectiveFilterFileExt)) -ne 0 ]; then
# File extension filtering
local fullFilter filter filteringCmd
-
# Do not use quotes around the $out variable or else newline
# characters will be kept.
for filter in ${out[*]}; do
@@ -168,173 +134,545 @@ __%[1]s_perform_completion()
$filteringCmd
elif [ $((directive & shellCompDirectiveFilterDirs)) -ne 0 ]; then
# File completion for directories only
-
+ local subDir
# Use printf to strip any trailing newline
- local subdir
subdir=$(printf "%%s" "${out[0]}")
if [ -n "$subdir" ]; then
__%[1]s_debug "Listing directories in $subdir"
- pushd "$subdir" >/dev/null 2>&1 && _filedir -d && popd >/dev/null 2>&1 || return
+ __%[1]s_handle_subdirs_in_dir_flag "$subdir"
else
__%[1]s_debug "Listing directories in ."
_filedir -d
fi
- elif [ $((directive & shellCompDirectiveLegacyCustomComp)) -ne 0 ]; then
- local cmd
- __%[1]s_debug "Legacy custom completion. Directive: $directive, cmds: ${out[*]}"
-
- # The following variables should get their value through the commands
- # we have received as completions and are parsing below.
- local last_command
- local nouns
-
- # Execute every command received
- while IFS='' read -r cmd; do
- __%[1]s_debug "About to execute: $cmd"
- eval "$cmd"
- done < <(printf "%%s\n" "${out[@]}")
-
- __%[1]s_debug "last_command: $last_command"
- __%[1]s_debug "nouns[0]: ${nouns[0]}, nouns[1]: ${nouns[1]}"
-
- if [ $((directive & shellCompDirectiveLegacyCustomArgsComp)) -ne 0 ]; then
- # We should call the global legacy custom completion function, if it is defined
- if declare -F __%[1]s_custom_func >/dev/null; then
- # Use command name qualified legacy custom func
- __%[1]s_debug "About to call: __%[1]s_custom_func"
- __%[1]s_custom_func
- elif declare -F __custom_func >/dev/null; then
- # Otherwise fall back to unqualified legacy custom func for compatibility
- __%[1]s_debug "About to call: __custom_func"
- __custom_func
- fi
- fi
else
- local tab
- tab=$(printf '\t')
- local longest=0
- # Look for the longest completion so that we can format things nicely
while IFS='' read -r comp; do
- comp=${comp%%%%$tab*}
- if ((${#comp}>longest)); then
- longest=${#comp}
+ COMPREPLY+=("$comp")
+ done < <(compgen -W "${out[*]}" -- "$cur")
+ fi
+}
+
+__%[1]s_handle_reply()
+{
+ __%[1]s_debug "${FUNCNAME[0]}"
+ local comp
+ case $cur in
+ -*)
+ if [[ $(type -t compopt) = "builtin" ]]; then
+ compopt -o nospace
+ fi
+ local allflags
+ if [ ${#must_have_one_flag[@]} -ne 0 ]; then
+ allflags=("${must_have_one_flag[@]}")
+ else
+ allflags=("${flags[*]} ${two_word_flags[*]}")
+ fi
+ while IFS='' read -r comp; do
+ COMPREPLY+=("$comp")
+ done < <(compgen -W "${allflags[*]}" -- "$cur")
+ if [[ $(type -t compopt) = "builtin" ]]; then
+ [[ "${COMPREPLY[0]}" == *= ]] || compopt +o nospace
fi
- done < <(printf "%%s\n" "${out[@]}")
- local completions=()
- while IFS='' read -r comp; do
- if [ -z "$comp" ]; then
- continue
+ # complete after --flag=abc
+ if [[ $cur == *=* ]]; then
+ if [[ $(type -t compopt) = "builtin" ]]; then
+ compopt +o nospace
+ fi
+
+ local index flag
+ flag="${cur%%=*}"
+ __%[1]s_index_of_word "${flag}" "${flags_with_completion[@]}"
+ COMPREPLY=()
+ if [[ ${index} -ge 0 ]]; then
+ PREFIX=""
+ cur="${cur#*=}"
+ ${flags_completion[${index}]}
+ if [ -n "${ZSH_VERSION}" ]; then
+ # zsh completion needs --flag= prefix
+ eval "COMPREPLY=( \"\${COMPREPLY[@]/#/${flag}=}\" )"
+ fi
+ fi
fi
+ return 0;
+ ;;
+ esac
+
+ # check if we are handling a flag with special work handling
+ local index
+ __%[1]s_index_of_word "${prev}" "${flags_with_completion[@]}"
+ if [[ ${index} -ge 0 ]]; then
+ ${flags_completion[${index}]}
+ return
+ fi
- __%[1]s_debug "Original comp: $comp"
- comp="$(__%[1]s_format_comp_descriptions "$comp" "$longest")"
- __%[1]s_debug "Final comp: $comp"
- completions+=("$comp")
- done < <(printf "%%s\n" "${out[@]}")
+ # we are parsing a flag and don't have a special handler, no completion
+ if [[ ${cur} != "${words[cword]}" ]]; then
+ return
+ fi
+ local completions
+ completions=("${commands[@]}")
+ if [[ ${#must_have_one_noun[@]} -ne 0 ]]; then
+ completions+=("${must_have_one_noun[@]}")
+ elif [[ -n "${has_completion_function}" ]]; then
+ # if a go completion function is provided, defer to that function
+ __%[1]s_handle_go_custom_completion
+ fi
+ if [[ ${#must_have_one_flag[@]} -ne 0 ]]; then
+ completions+=("${must_have_one_flag[@]}")
+ fi
+ while IFS='' read -r comp; do
+ COMPREPLY+=("$comp")
+ done < <(compgen -W "${completions[*]}" -- "$cur")
+
+ if [[ ${#COMPREPLY[@]} -eq 0 && ${#noun_aliases[@]} -gt 0 && ${#must_have_one_noun[@]} -ne 0 ]]; then
while IFS='' read -r comp; do
- # Although this script should only be used for bash
- # there may be programs that still convert the bash
- # script into a zsh one. To continue supporting those
- # programs, we do this single adaptation for zsh
- if [ -n "${ZSH_VERSION}" ]; then
- # zsh completion needs --flag= prefix
- COMPREPLY+=("$flagPrefix$comp")
- else
- COMPREPLY+=("$comp")
- fi
- done < <(compgen -W "${completions[*]}" -- "$cur")
-
- # If there is a single completion left, remove the description text
- if [ ${#COMPREPLY[*]} -eq 1 ]; then
- __%[1]s_debug "COMPREPLY[0]: ${COMPREPLY[0]}"
- comp="${COMPREPLY[0]%%%% *}"
- __%[1]s_debug "Removed description from single completion, which is now: ${comp}"
- COMPREPLY=()
COMPREPLY+=("$comp")
+ done < <(compgen -W "${noun_aliases[*]}" -- "$cur")
+ fi
+
+ if [[ ${#COMPREPLY[@]} -eq 0 ]]; then
+ if declare -F __%[1]s_custom_func >/dev/null; then
+ # try command name qualified custom func
+ __%[1]s_custom_func
+ else
+ # otherwise fall back to unqualified for compatibility
+ declare -F __custom_func >/dev/null && __custom_func
+ fi
+ fi
+
+ # available in bash-completion >= 2, not always present on macOS
+ if declare -F __ltrim_colon_completions >/dev/null; then
+ __ltrim_colon_completions "$cur"
+ fi
+
+ # If there is only 1 completion and it is a flag with an = it will be completed
+ # but we don't want a space after the =
+ if [[ "${#COMPREPLY[@]}" -eq "1" ]] && [[ $(type -t compopt) = "builtin" ]] && [[ "${COMPREPLY[0]}" == --*= ]]; then
+ compopt -o nospace
+ fi
+}
+
+# The arguments should be in the form "ext1|ext2|extn"
+__%[1]s_handle_filename_extension_flag()
+{
+ local ext="$1"
+ _filedir "@(${ext})"
+}
+
+__%[1]s_handle_subdirs_in_dir_flag()
+{
+ local dir="$1"
+ pushd "${dir}" >/dev/null 2>&1 && _filedir -d && popd >/dev/null 2>&1 || return
+}
+
+__%[1]s_handle_flag()
+{
+ __%[1]s_debug "${FUNCNAME[0]}: c is $c words[c] is ${words[c]}"
+
+ # if a command required a flag, and we found it, unset must_have_one_flag()
+ local flagname=${words[c]}
+ local flagvalue
+ # if the word contained an =
+ if [[ ${words[c]} == *"="* ]]; then
+ flagvalue=${flagname#*=} # take in as flagvalue after the =
+ flagname=${flagname%%=*} # strip everything after the =
+ flagname="${flagname}=" # but put the = back
+ fi
+ __%[1]s_debug "${FUNCNAME[0]}: looking for ${flagname}"
+ if __%[1]s_contains_word "${flagname}" "${must_have_one_flag[@]}"; then
+ must_have_one_flag=()
+ fi
+
+ # if you set a flag which only applies to this command, don't show subcommands
+ if __%[1]s_contains_word "${flagname}" "${local_nonpersistent_flags[@]}"; then
+ commands=()
+ fi
+
+ # keep flag value with flagname as flaghash
+ # flaghash variable is an associative array which is only supported in bash > 3.
+ if [[ -z "${BASH_VERSION}" || "${BASH_VERSINFO[0]}" -gt 3 ]]; then
+ if [ -n "${flagvalue}" ] ; then
+ flaghash[${flagname}]=${flagvalue}
+ elif [ -n "${words[ $((c+1)) ]}" ] ; then
+ flaghash[${flagname}]=${words[ $((c+1)) ]}
+ else
+ flaghash[${flagname}]="true" # pad "true" for bool flag
+ fi
+ fi
+
+ # skip the argument to a two word flag
+ if [[ ${words[c]} != *"="* ]] && __%[1]s_contains_word "${words[c]}" "${two_word_flags[@]}"; then
+ __%[1]s_debug "${FUNCNAME[0]}: found a flag ${words[c]}, skip the next argument"
+ c=$((c+1))
+ # if we are looking for a flags value, don't show commands
+ if [[ $c -eq $cword ]]; then
+ commands=()
fi
fi
- __%[1]s_handle_special_char "$cur" :
- __%[1]s_handle_special_char "$cur" =
+ c=$((c+1))
+
}
-__%[1]s_handle_special_char()
+__%[1]s_handle_noun()
{
- local comp="$1"
- local char=$2
- if [[ "$comp" == *${char}* && "$COMP_WORDBREAKS" == *${char}* ]]; then
- local word=${comp%%"${comp##*${char}}"}
- local idx=${#COMPREPLY[*]}
- while [[ $((--idx)) -ge 0 ]]; do
- COMPREPLY[$idx]=${COMPREPLY[$idx]#"$word"}
- done
+ __%[1]s_debug "${FUNCNAME[0]}: c is $c words[c] is ${words[c]}"
+
+ if __%[1]s_contains_word "${words[c]}" "${must_have_one_noun[@]}"; then
+ must_have_one_noun=()
+ elif __%[1]s_contains_word "${words[c]}" "${noun_aliases[@]}"; then
+ must_have_one_noun=()
fi
+
+ nouns+=("${words[c]}")
+ c=$((c+1))
}
-__%[1]s_format_comp_descriptions()
+__%[1]s_handle_command()
{
- local tab
- tab=$(printf '\t')
- local comp="$1"
- local longest=$2
-
- # Properly format the description string which follows a tab character if there is one
- if [[ "$comp" == *$tab* ]]; then
- desc=${comp#*$tab}
- comp=${comp%%%%$tab*}
-
- # $COLUMNS stores the current shell width.
- # Remove an extra 4 because we add 2 spaces and 2 parentheses.
- maxdesclength=$(( COLUMNS - longest - 4 ))
-
- # Make sure we can fit a description of at least 8 characters
- # if we are to align the descriptions.
- if [[ $maxdesclength -gt 8 ]]; then
- # Add the proper number of spaces to align the descriptions
- for ((i = ${#comp} ; i < longest ; i++)); do
- comp+=" "
- done
+ __%[1]s_debug "${FUNCNAME[0]}: c is $c words[c] is ${words[c]}"
+
+ local next_command
+ if [[ -n ${last_command} ]]; then
+ next_command="_${last_command}_${words[c]//:/__}"
+ else
+ if [[ $c -eq 0 ]]; then
+ next_command="_%[1]s_root_command"
else
- # Don't pad the descriptions so we can fit more text after the completion
- maxdesclength=$(( COLUMNS - ${#comp} - 4 ))
+ next_command="_${words[c]//:/__}"
fi
+ fi
+ c=$((c+1))
+ __%[1]s_debug "${FUNCNAME[0]}: looking for ${next_command}"
+ declare -F "$next_command" >/dev/null && $next_command
+}
- # If there is enough space for any description text,
- # truncate the descriptions that are too long for the shell width
- if [ $maxdesclength -gt 0 ]; then
- if [ ${#desc} -gt $maxdesclength ]; then
- desc=${desc:0:$(( maxdesclength - 1 ))}
- desc+="…"
- fi
- comp+=" ($desc)"
+__%[1]s_handle_word()
+{
+ if [[ $c -ge $cword ]]; then
+ __%[1]s_handle_reply
+ return
+ fi
+ __%[1]s_debug "${FUNCNAME[0]}: c is $c words[c] is ${words[c]}"
+ if [[ "${words[c]}" == -* ]]; then
+ __%[1]s_handle_flag
+ elif __%[1]s_contains_word "${words[c]}" "${commands[@]}"; then
+ __%[1]s_handle_command
+ elif [[ $c -eq 0 ]]; then
+ __%[1]s_handle_command
+ elif __%[1]s_contains_word "${words[c]}" "${command_aliases[@]}"; then
+ # aliashash variable is an associative array which is only supported in bash > 3.
+ if [[ -z "${BASH_VERSION}" || "${BASH_VERSINFO[0]}" -gt 3 ]]; then
+ words[c]=${aliashash[${words[c]}]}
+ __%[1]s_handle_command
+ else
+ __%[1]s_handle_noun
fi
+ else
+ __%[1]s_handle_noun
fi
+ __%[1]s_handle_word
+}
- # Must use printf to escape all special characters
- printf "%%q" "${comp}"
+`, name, ShellCompNoDescRequestCmd,
+ ShellCompDirectiveError, ShellCompDirectiveNoSpace, ShellCompDirectiveNoFileComp,
+ ShellCompDirectiveFilterFileExt, ShellCompDirectiveFilterDirs))
}
-__start_%[1]s()
-{
+func writePostscript(buf *bytes.Buffer, name string) {
+ name = strings.Replace(name, ":", "__", -1)
+ buf.WriteString(fmt.Sprintf("__start_%s()\n", name))
+ buf.WriteString(fmt.Sprintf(`{
local cur prev words cword
+ declare -A flaghash 2>/dev/null || :
+ declare -A aliashash 2>/dev/null || :
+ if declare -F _init_completion >/dev/null 2>&1; then
+ _init_completion -s || return
+ else
+ __%[1]s_init_completion -n "=" || return
+ fi
- COMPREPLY=()
- _get_comp_words_by_ref -n "=:" cur prev words cword
-
- __%[1]s_perform_completion
+ local c=0
+ local flags=()
+ local two_word_flags=()
+ local local_nonpersistent_flags=()
+ local flags_with_completion=()
+ local flags_completion=()
+ local commands=("%[1]s")
+ local must_have_one_flag=()
+ local must_have_one_noun=()
+ local has_completion_function
+ local last_command
+ local nouns=()
+
+ __%[1]s_handle_word
}
-if [[ $(type -t compopt) = "builtin" ]]; then
- complete -o default -F __start_%[1]s %[1]s
+`, name))
+ buf.WriteString(fmt.Sprintf(`if [[ $(type -t compopt) = "builtin" ]]; then
+ complete -o default -F __start_%s %s
else
- complete -o default -o nospace -F __start_%[1]s %[1]s
+ complete -o default -o nospace -F __start_%s %s
fi
-# ex: ts=4 sw=4 et filetype=sh
-`, name, compCmd,
- ShellCompDirectiveError, ShellCompDirectiveNoSpace, ShellCompDirectiveNoFileComp,
- ShellCompDirectiveFilterFileExt, ShellCompDirectiveFilterDirs,
- shellCompDirectiveLegacyCustomComp, shellCompDirectiveLegacyCustomArgsComp))
+`, name, name, name, name))
+ buf.WriteString("# ex: ts=4 sw=4 et filetype=sh\n")
+}
+
+func writeCommands(buf *bytes.Buffer, cmd *Command) {
+ buf.WriteString(" commands=()\n")
+ for _, c := range cmd.Commands() {
+ if !c.IsAvailableCommand() && c != cmd.helpCommand {
+ continue
+ }
+ buf.WriteString(fmt.Sprintf(" commands+=(%q)\n", c.Name()))
+ writeCmdAliases(buf, c)
+ }
+ buf.WriteString("\n")
+}
+
+func writeFlagHandler(buf *bytes.Buffer, name string, annotations map[string][]string, cmd *Command) {
+ for key, value := range annotations {
+ switch key {
+ case BashCompFilenameExt:
+ buf.WriteString(fmt.Sprintf(" flags_with_completion+=(%q)\n", name))
+
+ var ext string
+ if len(value) > 0 {
+ ext = fmt.Sprintf("__%s_handle_filename_extension_flag ", cmd.Root().Name()) + strings.Join(value, "|")
+ } else {
+ ext = "_filedir"
+ }
+ buf.WriteString(fmt.Sprintf(" flags_completion+=(%q)\n", ext))
+ case BashCompCustom:
+ buf.WriteString(fmt.Sprintf(" flags_with_completion+=(%q)\n", name))
+ if len(value) > 0 {
+ handlers := strings.Join(value, "; ")
+ buf.WriteString(fmt.Sprintf(" flags_completion+=(%q)\n", handlers))
+ } else {
+ buf.WriteString(" flags_completion+=(:)\n")
+ }
+ case BashCompSubdirsInDir:
+ buf.WriteString(fmt.Sprintf(" flags_with_completion+=(%q)\n", name))
+
+ var ext string
+ if len(value) == 1 {
+ ext = fmt.Sprintf("__%s_handle_subdirs_in_dir_flag ", cmd.Root().Name()) + value[0]
+ } else {
+ ext = "_filedir -d"
+ }
+ buf.WriteString(fmt.Sprintf(" flags_completion+=(%q)\n", ext))
+ }
+ }
+}
+
+func writeShortFlag(buf *bytes.Buffer, flag *pflag.Flag, cmd *Command) {
+ name := flag.Shorthand
+ format := " "
+ if len(flag.NoOptDefVal) == 0 {
+ format += "two_word_"
+ }
+ format += "flags+=(\"-%s\")\n"
+ buf.WriteString(fmt.Sprintf(format, name))
+ writeFlagHandler(buf, "-"+name, flag.Annotations, cmd)
+}
+
+func writeFlag(buf *bytes.Buffer, flag *pflag.Flag, cmd *Command) {
+ name := flag.Name
+ format := " flags+=(\"--%s"
+ if len(flag.NoOptDefVal) == 0 {
+ format += "="
+ }
+ format += "\")\n"
+ buf.WriteString(fmt.Sprintf(format, name))
+ if len(flag.NoOptDefVal) == 0 {
+ format = " two_word_flags+=(\"--%s\")\n"
+ buf.WriteString(fmt.Sprintf(format, name))
+ }
+ writeFlagHandler(buf, "--"+name, flag.Annotations, cmd)
+}
+
+func writeLocalNonPersistentFlag(buf *bytes.Buffer, flag *pflag.Flag) {
+ name := flag.Name
+ format := " local_nonpersistent_flags+=(\"--%[1]s\")\n"
+ if len(flag.NoOptDefVal) == 0 {
+ format += " local_nonpersistent_flags+=(\"--%[1]s=\")\n"
+ }
+ buf.WriteString(fmt.Sprintf(format, name))
+ if len(flag.Shorthand) > 0 {
+ buf.WriteString(fmt.Sprintf(" local_nonpersistent_flags+=(\"-%s\")\n", flag.Shorthand))
+ }
+}
+
+// Setup annotations for go completions for registered flags
+func prepareCustomAnnotationsForFlags(cmd *Command) {
+ for flag := range flagCompletionFunctions {
+ // Make sure the completion script calls the __*_go_custom_completion function for
+ // every registered flag. We need to do this here (and not when the flag was registered
+ // for completion) so that we can know the root command name for the prefix
+ // of __<prefix>_go_custom_completion
+ if flag.Annotations == nil {
+ flag.Annotations = map[string][]string{}
+ }
+ flag.Annotations[BashCompCustom] = []string{fmt.Sprintf("__%[1]s_handle_go_custom_completion", cmd.Root().Name())}
+ }
+}
+
+func writeFlags(buf *bytes.Buffer, cmd *Command) {
+ prepareCustomAnnotationsForFlags(cmd)
+ buf.WriteString(` flags=()
+ two_word_flags=()
+ local_nonpersistent_flags=()
+ flags_with_completion=()
+ flags_completion=()
+
+`)
+ localNonPersistentFlags := cmd.LocalNonPersistentFlags()
+ cmd.NonInheritedFlags().VisitAll(func(flag *pflag.Flag) {
+ if nonCompletableFlag(flag) {
+ return
+ }
+ writeFlag(buf, flag, cmd)
+ if len(flag.Shorthand) > 0 {
+ writeShortFlag(buf, flag, cmd)
+ }
+ // localNonPersistentFlags are used to stop the completion of subcommands when one is set
+ // if TraverseChildren is true we should allow to complete subcommands
+ if localNonPersistentFlags.Lookup(flag.Name) != nil && !cmd.Root().TraverseChildren {
+ writeLocalNonPersistentFlag(buf, flag)
+ }
+ })
+ cmd.InheritedFlags().VisitAll(func(flag *pflag.Flag) {
+ if nonCompletableFlag(flag) {
+ return
+ }
+ writeFlag(buf, flag, cmd)
+ if len(flag.Shorthand) > 0 {
+ writeShortFlag(buf, flag, cmd)
+ }
+ })
+
+ buf.WriteString("\n")
+}
+
+func writeRequiredFlag(buf *bytes.Buffer, cmd *Command) {
+ buf.WriteString(" must_have_one_flag=()\n")
+ flags := cmd.NonInheritedFlags()
+ flags.VisitAll(func(flag *pflag.Flag) {
+ if nonCompletableFlag(flag) {
+ return
+ }
+ for key := range flag.Annotations {
+ switch key {
+ case BashCompOneRequiredFlag:
+ format := " must_have_one_flag+=(\"--%s"
+ if flag.Value.Type() != "bool" {
+ format += "="
+ }
+ format += "\")\n"
+ buf.WriteString(fmt.Sprintf(format, flag.Name))
+
+ if len(flag.Shorthand) > 0 {
+ buf.WriteString(fmt.Sprintf(" must_have_one_flag+=(\"-%s\")\n", flag.Shorthand))
+ }
+ }
+ }
+ })
+}
+
+func writeRequiredNouns(buf *bytes.Buffer, cmd *Command) {
+ buf.WriteString(" must_have_one_noun=()\n")
+ sort.Sort(sort.StringSlice(cmd.ValidArgs))
+ for _, value := range cmd.ValidArgs {
+ // Remove any description that may be included following a tab character.
+ // Descriptions are not supported by bash completion.
+ value = strings.Split(value, "\t")[0]
+ buf.WriteString(fmt.Sprintf(" must_have_one_noun+=(%q)\n", value))
+ }
+ if cmd.ValidArgsFunction != nil {
+ buf.WriteString(" has_completion_function=1\n")
+ }
+}
+
+func writeCmdAliases(buf *bytes.Buffer, cmd *Command) {
+ if len(cmd.Aliases) == 0 {
+ return
+ }
+
+ sort.Sort(sort.StringSlice(cmd.Aliases))
+
+ buf.WriteString(fmt.Sprint(` if [[ -z "${BASH_VERSION}" || "${BASH_VERSINFO[0]}" -gt 3 ]]; then`, "\n"))
+ for _, value := range cmd.Aliases {
+ buf.WriteString(fmt.Sprintf(" command_aliases+=(%q)\n", value))
+ buf.WriteString(fmt.Sprintf(" aliashash[%q]=%q\n", value, cmd.Name()))
+ }
+ buf.WriteString(` fi`)
+ buf.WriteString("\n")
+}
+func writeArgAliases(buf *bytes.Buffer, cmd *Command) {
+ buf.WriteString(" noun_aliases=()\n")
+ sort.Sort(sort.StringSlice(cmd.ArgAliases))
+ for _, value := range cmd.ArgAliases {
+ buf.WriteString(fmt.Sprintf(" noun_aliases+=(%q)\n", value))
+ }
+}
+
+func gen(buf *bytes.Buffer, cmd *Command) {
+ for _, c := range cmd.Commands() {
+ if !c.IsAvailableCommand() && c != cmd.helpCommand {
+ continue
+ }
+ gen(buf, c)
+ }
+ commandName := cmd.CommandPath()
+ commandName = strings.Replace(commandName, " ", "_", -1)
+ commandName = strings.Replace(commandName, ":", "__", -1)
+
+ if cmd.Root() == cmd {
+ buf.WriteString(fmt.Sprintf("_%s_root_command()\n{\n", commandName))
+ } else {
+ buf.WriteString(fmt.Sprintf("_%s()\n{\n", commandName))
+ }
+
+ buf.WriteString(fmt.Sprintf(" last_command=%q\n", commandName))
+ buf.WriteString("\n")
+ buf.WriteString(" command_aliases=()\n")
+ buf.WriteString("\n")
+
+ writeCommands(buf, cmd)
+ writeFlags(buf, cmd)
+ writeRequiredFlag(buf, cmd)
+ writeRequiredNouns(buf, cmd)
+ writeArgAliases(buf, cmd)
+ buf.WriteString("}\n\n")
+}
+
+// GenBashCompletion generates bash completion file and writes to the passed writer.
+func (c *Command) GenBashCompletion(w io.Writer) error {
+ buf := new(bytes.Buffer)
+ writePreamble(buf, c.Name())
+ if len(c.BashCompletionFunction) > 0 {
+ buf.WriteString(c.BashCompletionFunction + "\n")
+ }
+ gen(buf, c)
+ writePostscript(buf, c.Name())
+
+ _, err := buf.WriteTo(w)
+ return err
+}
+
+func nonCompletableFlag(flag *pflag.Flag) bool {
+ return flag.Hidden || len(flag.Deprecated) > 0
+}
+
+// GenBashCompletionFile generates bash completion file.
+func (c *Command) GenBashCompletionFile(filename string) error {
+ outFile, err := os.Create(filename)
+ if err != nil {
+ return err
+ }
+ defer outFile.Close()
+
+ return c.GenBashCompletion(outFile)
}
diff --git a/vendor/github.com/spf13/cobra/custom_completions.go b/vendor/github.com/spf13/cobra/custom_completions.go
index e2c68ae1e..f9e88e081 100644
--- a/vendor/github.com/spf13/cobra/custom_completions.go
+++ b/vendor/github.com/spf13/cobra/custom_completions.go
@@ -51,11 +51,6 @@ const (
// obtain the same behavior but only for flags.
ShellCompDirectiveFilterDirs
- // For internal use only.
- // Used to maintain backwards-compatibility with the legacy bash custom completions.
- shellCompDirectiveLegacyCustomComp
- shellCompDirectiveLegacyCustomArgsComp
-
// ===========================================================================
// All directives using iota should be above this one.
@@ -99,12 +94,6 @@ func (d ShellCompDirective) string() string {
if d&ShellCompDirectiveFilterDirs != 0 {
directives = append(directives, "ShellCompDirectiveFilterDirs")
}
- if d&shellCompDirectiveLegacyCustomComp != 0 {
- directives = append(directives, "shellCompDirectiveLegacyCustomComp")
- }
- if d&shellCompDirectiveLegacyCustomArgsComp != 0 {
- directives = append(directives, "shellCompDirectiveLegacyCustomArgsComp")
- }
if len(directives) == 0 {
directives = append(directives, "ShellCompDirectiveDefault")
}
@@ -160,6 +149,10 @@ func (c *Command) initCompleteCmd(args []string) {
fmt.Fprintln(finalCmd.OutOrStdout(), comp)
}
+ if directive >= shellCompDirectiveMaxValue {
+ directive = ShellCompDirectiveDefault
+ }
+
// As the last printout, print the completion directive for the completion script to parse.
// The directive integer must be that last character following a single colon (:).
// The completion script expects :<directive>
@@ -369,10 +362,6 @@ func (c *Command) getCompletions(args []string) (*Command, []string, ShellCompDi
var comps []string
comps, directive = completionFn(finalCmd, finalArgs, toComplete)
completions = append(completions, comps...)
- } else {
- // If there is no Go custom completion defined, check for legacy bash
- // custom completion to preserve backwards-compatibility
- completions, directive = checkLegacyCustomCompletion(finalCmd, finalArgs, flag, completions, directive)
}
return finalCmd, completions, directive, nil
@@ -453,16 +442,7 @@ func checkIfFlagCompletion(finalCmd *Command, args []string, lastArg string) (*p
if len(lastArg) > 0 && lastArg[0] == '-' {
if index := strings.Index(lastArg, "="); index >= 0 {
// Flag with an =
- if strings.HasPrefix(lastArg[:index], "--") {
- // Flag has full name
- flagName = lastArg[2:index]
- } else {
- // Flag is shorthand
- // We have to get the last shorthand flag name
- // e.g. `-asd` => d to provide the correct completion
- // https://github.com/spf13/cobra/issues/1257
- flagName = lastArg[index-1 : index]
- }
+ flagName = strings.TrimLeft(lastArg[:index], "-")
lastArg = lastArg[index+1:]
flagWithEqual = true
} else {
@@ -479,16 +459,8 @@ func checkIfFlagCompletion(finalCmd *Command, args []string, lastArg string) (*p
// If the flag contains an = it means it has already been fully processed,
// so we don't need to deal with it here.
if index := strings.Index(prevArg, "="); index < 0 {
- if strings.HasPrefix(prevArg, "--") {
- // Flag has full name
- flagName = prevArg[2:]
- } else {
- // Flag is shorthand
- // We have to get the last shorthand flag name
- // e.g. `-asd` => d to provide the correct completion
- // https://github.com/spf13/cobra/issues/1257
- flagName = prevArg[len(prevArg)-1:]
- }
+ flagName = strings.TrimLeft(prevArg, "-")
+
// Remove the uncompleted flag or else there could be an error created
// for an invalid value for that flag
trimmedArgs = args[:len(args)-1]
@@ -541,65 +513,6 @@ func findFlag(cmd *Command, name string) *pflag.Flag {
return cmd.Flag(name)
}
-func nonCompletableFlag(flag *pflag.Flag) bool {
- return flag.Hidden || len(flag.Deprecated) > 0
-}
-
-// This function checks if legacy bash custom completion should be performed and if so,
-// it provides the shell script with the necessary information.
-func checkLegacyCustomCompletion(cmd *Command, args []string, flag *pflag.Flag, completions []string, directive ShellCompDirective) ([]string, ShellCompDirective) {
- // Check if any legacy custom completion is defined for the program
- if len(cmd.Root().BashCompletionFunction) > 0 {
- // Legacy custom completion is only triggered if no other completions were found.
- if len(completions) == 0 {
- if flag != nil {
- // For legacy custom flag completion, we must let the script know the bash
- // functions it should call based on the content of the annotation BashCompCustom.
- if values, present := flag.Annotations[BashCompCustom]; present {
- if len(values) > 0 {
- handlers := strings.Join(values, "; ")
- // We send the commands to set the shell variables that are needed
- // for legacy custom completions followed by the functions to call
- // to perform the actual flag completion
- completions = append(prepareLegacyCustomCompletionVars(cmd, args), handlers)
- directive = directive | shellCompDirectiveLegacyCustomComp
- }
- }
- } else {
- // Check if the legacy custom_func is defined.
- // This check will work for both "__custom_func" and "__<program>_custom_func".
- // This could happen if the program defined some functions for legacy flag completion
- // but not the legacy custom_func.
- if strings.Contains(cmd.Root().BashCompletionFunction, "_custom_func") {
- // For legacy args completion, the script already knows what to call
- // so we only need to tell it the commands to set the shell variables needed
- completions = prepareLegacyCustomCompletionVars(cmd, args)
- directive = directive | shellCompDirectiveLegacyCustomComp | shellCompDirectiveLegacyCustomArgsComp
- }
- }
- }
- }
- return completions, directive
-}
-
-// The original bash completion script had some shell variables that are used by legacy bash
-// custom completions. Let's set those variables to allow those legacy custom completions
-// to continue working.
-func prepareLegacyCustomCompletionVars(cmd *Command, args []string) []string {
- var compVarCmds []string
-
- // "last_command" variable
- commandName := cmd.CommandPath()
- commandName = strings.Replace(commandName, " ", "_", -1)
- commandName = strings.Replace(commandName, ":", "__", -1)
- compVarCmds = append(compVarCmds, fmt.Sprintf("last_command=%s", commandName))
-
- // "nouns" array variable
- compVarCmds = append(compVarCmds, fmt.Sprintf("nouns=(%s)", strings.Join(args, " ")))
-
- return compVarCmds
-}
-
// CompDebug prints the specified string to the same file as where the
// completion script prints its logs.
// Note that completion printouts should never be on stdout as they would
diff --git a/vendor/github.com/spf13/cobra/fish_completions.go b/vendor/github.com/spf13/cobra/fish_completions.go
index aeaef0087..eaae9bca8 100644
--- a/vendor/github.com/spf13/cobra/fish_completions.go
+++ b/vendor/github.com/spf13/cobra/fish_completions.go
@@ -28,9 +28,9 @@ function __%[1]s_debug
end
function __%[1]s_perform_completion
- __%[1]s_debug "Starting __%[1]s_perform_completion"
+ __%[1]s_debug "Starting __%[1]s_perform_completion with: $argv"
- set args (string split -- " " (commandline -c))
+ set args (string split -- " " "$argv")
set lastArg "$args[-1]"
__%[1]s_debug "args: $args"
@@ -71,22 +71,31 @@ function __%[1]s_perform_completion
printf "%%s\n" "$directiveLine"
end
-# This function does two things:
-# - Obtain the completions and store them in the global __%[1]s_comp_results
-# - Return false if file completion should be performed
+# This function does three things:
+# 1- Obtain the completions and store them in the global __%[1]s_comp_results
+# 2- Set the __%[1]s_comp_do_file_comp flag if file completion should be performed
+# and unset it otherwise
+# 3- Return true if the completion results are not empty
function __%[1]s_prepare_completions
- __%[1]s_debug ""
- __%[1]s_debug "========= starting completion logic =========="
-
# Start fresh
+ set --erase __%[1]s_comp_do_file_comp
set --erase __%[1]s_comp_results
- set results (__%[1]s_perform_completion)
+ # Check if the command-line is already provided. This is useful for testing.
+ if not set --query __%[1]s_comp_commandLine
+ # Use the -c flag to allow for completion in the middle of the line
+ set __%[1]s_comp_commandLine (commandline -c)
+ end
+ __%[1]s_debug "commandLine is: $__%[1]s_comp_commandLine"
+
+ set results (__%[1]s_perform_completion "$__%[1]s_comp_commandLine")
+ set --erase __%[1]s_comp_commandLine
__%[1]s_debug "Completion results: $results"
if test -z "$results"
__%[1]s_debug "No completion, probably due to a failure"
# Might as well do file completion, in case it helps
+ set --global __%[1]s_comp_do_file_comp 1
return 1
end
@@ -101,8 +110,6 @@ function __%[1]s_prepare_completions
set shellCompDirectiveNoFileComp %[6]d
set shellCompDirectiveFilterFileExt %[7]d
set shellCompDirectiveFilterDirs %[8]d
- set shellCompDirectiveLegacyCustomComp %[9]d
- set shellCompDirectiveLegacyCustomArgsComp %[10]d
if test -z "$directive"
set directive 0
@@ -112,14 +119,6 @@ function __%[1]s_prepare_completions
if test $compErr -eq 1
__%[1]s_debug "Received error directive: aborting."
# Might as well do file completion, in case it helps
- return 1
- end
-
- set legacyCustom (math (math --scale 0 $directive / $shellCompDirectiveLegacyCustomComp) %% 2)
- set legacyCustomArgs (math (math --scale 0 $directive / $shellCompDirectiveLegacyCustomArgsComp) %% 2)
- if test $legacyCustom -eq 1; or test $legacyCustomArgs -eq 1
- __%[1]s_debug "Legacy bash custom completion not applicable to fish"
- # Do full file completion instead
set --global __%[1]s_comp_do_file_comp 1
return 1
end
@@ -129,6 +128,7 @@ function __%[1]s_prepare_completions
if test $filefilter -eq 1; or test $dirfilter -eq 1
__%[1]s_debug "File extension filtering or directory filtering not supported"
# Do full file completion instead
+ set --global __%[1]s_comp_do_file_comp 1
return 1
end
@@ -137,51 +137,27 @@ function __%[1]s_prepare_completions
__%[1]s_debug "nospace: $nospace, nofiles: $nofiles"
- # If we want to prevent a space, or if file completion is NOT disabled,
- # we need to count the number of valid completions.
- # To do so, we will filter on prefix as the completions we have received
- # may not already be filtered so as to allow fish to match on different
- # criteria than prefix.
- if test $nospace -ne 0; or test $nofiles -eq 0
- set prefix (commandline -t)
- __%[1]s_debug "prefix: $prefix"
-
- set completions
- for comp in $__%[1]s_comp_results
- if test (string match -e -r "^$prefix" "$comp")
- set -a completions $comp
- end
- end
- set --global __%[1]s_comp_results $completions
- __%[1]s_debug "Filtered completions are: $__%[1]s_comp_results"
-
- # Important not to quote the variable for count to work
- set numComps (count $__%[1]s_comp_results)
- __%[1]s_debug "numComps: $numComps"
-
- if test $numComps -eq 1; and test $nospace -ne 0
- # To support the "nospace" directive we trick the shell
- # by outputting an extra, longer completion.
- # We must first split on \t to get rid of the descriptions because
- # the extra character we add to the fake second completion must be
- # before the description. We don't need descriptions anyway since
- # there is only a single real completion which the shell will expand
- # immediately.
- __%[1]s_debug "Adding second completion to perform nospace directive"
- set split (string split --max 1 \t $__%[1]s_comp_results[1])
- set --global __%[1]s_comp_results $split[1] $split[1].
- __%[1]s_debug "Completions are now: $__%[1]s_comp_results"
- end
-
- if test $numComps -eq 0; and test $nofiles -eq 0
- # To be consistent with bash and zsh, we only trigger file
- # completion when there are no other completions
- __%[1]s_debug "Requesting file completion"
- return 1
- end
+ # Important not to quote the variable for count to work
+ set numComps (count $__%[1]s_comp_results)
+ __%[1]s_debug "numComps: $numComps"
+
+ if test $numComps -eq 1; and test $nospace -ne 0
+ # To support the "nospace" directive we trick the shell
+ # by outputting an extra, longer completion.
+ __%[1]s_debug "Adding second completion to perform nospace directive"
+ set --append __%[1]s_comp_results $__%[1]s_comp_results[1].
end
- return 0
+ if test $numComps -eq 0; and test $nofiles -eq 0
+ __%[1]s_debug "Requesting file completion"
+ set --global __%[1]s_comp_do_file_comp 1
+ end
+
+ # If we don't want file completion, we must return true even if there
+ # are no completions found. This is because fish will perform the last
+ # completion command, even if its condition is false, if no other
+ # completion command was triggered
+ return (not set --query __%[1]s_comp_do_file_comp)
end
# Since Fish completions are only loaded once the user triggers them, we trigger them ourselves
@@ -194,14 +170,21 @@ complete --do-complete "%[2]s " > /dev/null 2>&1
# Remove any pre-existing completions for the program since we will be handling all of them.
complete -c %[2]s -e
-# The call to __%[1]s_prepare_completions will setup __%[1]s_comp_results
-# which provides the program's completion choices.
+# The order in which the below two lines are defined is very important so that __%[1]s_prepare_completions
+# is called first. It is __%[1]s_prepare_completions that sets up the __%[1]s_comp_do_file_comp variable.
+#
+# This completion will be run second as complete commands are added FILO.
+# It triggers file completion choices when __%[1]s_comp_do_file_comp is set.
+complete -c %[2]s -n 'set --query __%[1]s_comp_do_file_comp'
+
+# This completion will be run first as complete commands are added FILO.
+# The call to __%[1]s_prepare_completions will setup both __%[1]s_comp_results and __%[1]s_comp_do_file_comp.
+# It provides the program's completion choices.
complete -c %[2]s -n '__%[1]s_prepare_completions' -f -a '$__%[1]s_comp_results'
`, nameForVar, name, compCmd,
ShellCompDirectiveError, ShellCompDirectiveNoSpace, ShellCompDirectiveNoFileComp,
- ShellCompDirectiveFilterFileExt, ShellCompDirectiveFilterDirs,
- shellCompDirectiveLegacyCustomComp, shellCompDirectiveLegacyCustomArgsComp))
+ ShellCompDirectiveFilterFileExt, ShellCompDirectiveFilterDirs))
}
// GenFishCompletion generates fish completion file and writes to the passed writer.
diff --git a/vendor/github.com/spf13/cobra/zsh_completions.go b/vendor/github.com/spf13/cobra/zsh_completions.go
index ef290e2eb..92a70394a 100644
--- a/vendor/github.com/spf13/cobra/zsh_completions.go
+++ b/vendor/github.com/spf13/cobra/zsh_completions.go
@@ -94,10 +94,8 @@ _%[1]s()
local shellCompDirectiveNoFileComp=%[5]d
local shellCompDirectiveFilterFileExt=%[6]d
local shellCompDirectiveFilterDirs=%[7]d
- local shellCompDirectiveLegacyCustomComp=%[8]d
- local shellCompDirectiveLegacyCustomArgsComp=%[9]d
- local lastParam lastChar flagPrefix requestComp out directive comp lastComp noSpace
+ local lastParam lastChar flagPrefix requestComp out directive compCount comp lastComp
local -a completions
__%[1]s_debug "\n========= starting completion logic =========="
@@ -165,6 +163,7 @@ _%[1]s()
return
fi
+ compCount=0
while IFS='\n' read -r comp; do
if [ -n "$comp" ]; then
# If requested, completions are returned with a description.
@@ -176,17 +175,13 @@ _%[1]s()
local tab=$(printf '\t')
comp=${comp//$tab/:}
+ ((compCount++))
__%[1]s_debug "Adding completion: ${comp}"
completions+=${comp}
lastComp=$comp
fi
done < <(printf "%%s\n" "${out[@]}")
- if [ $((directive & shellCompDirectiveNoSpace)) -ne 0 ]; then
- __%[1]s_debug "Activating nospace."
- noSpace="-S ''"
- fi
-
if [ $((directive & shellCompDirectiveFilterFileExt)) -ne 0 ]; then
# File extension filtering
local filteringCmd
@@ -213,40 +208,25 @@ _%[1]s()
__%[1]s_debug "Listing directories in ."
fi
- local result
_arguments '*:dirname:_files -/'" ${flagPrefix}"
- result=$?
if [ -n "$subdir" ]; then
popd >/dev/null 2>&1
fi
- return $result
- else
- __%[1]s_debug "Calling _describe"
- if eval _describe "completions" completions $flagPrefix $noSpace; then
- __%[1]s_debug "_describe found some completions"
-
- # Return the success of having called _describe
- return 0
+ elif [ $((directive & shellCompDirectiveNoSpace)) -ne 0 ] && [ ${compCount} -eq 1 ]; then
+ __%[1]s_debug "Activating nospace."
+ # We can use compadd here as there is no description when
+ # there is only one completion.
+ compadd -S '' "${lastComp}"
+ elif [ ${compCount} -eq 0 ]; then
+ if [ $((directive & shellCompDirectiveNoFileComp)) -ne 0 ]; then
+ __%[1]s_debug "deactivating file completion"
else
- __%[1]s_debug "_describe did not find completions."
- __%[1]s_debug "Checking if we should do file completion."
- if [ $((directive & shellCompDirectiveNoFileComp)) -ne 0 ]; then
- __%[1]s_debug "deactivating file completion"
-
- # We must return an error code here to let zsh know that there were no
- # completions found by _describe; this is what will trigger other
- # matching algorithms to attempt to find completions.
- # For example zsh can match letters in the middle of words.
- return 1
- else
- # Perform file completion
- __%[1]s_debug "Activating file completion"
-
- # We must return the result of this command, so it must be the
- # last command, or else we must store its result to return it.
- _arguments '*:filename:_files'" ${flagPrefix}"
- fi
+ # Perform file completion
+ __%[1]s_debug "activating file completion"
+ _arguments '*:filename:_files'" ${flagPrefix}"
fi
+ else
+ _describe "completions" completions $(echo $flagPrefix)
fi
}
@@ -256,6 +236,5 @@ if [ "$funcstack[1]" = "_%[1]s" ]; then
fi
`, name, compCmd,
ShellCompDirectiveError, ShellCompDirectiveNoSpace, ShellCompDirectiveNoFileComp,
- ShellCompDirectiveFilterFileExt, ShellCompDirectiveFilterDirs,
- shellCompDirectiveLegacyCustomComp, shellCompDirectiveLegacyCustomArgsComp))
+ ShellCompDirectiveFilterFileExt, ShellCompDirectiveFilterDirs))
}
diff --git a/vendor/github.com/varlink/go/LICENSE b/vendor/github.com/varlink/go/LICENSE
deleted file mode 100644
index 261eeb9e9..000000000
--- a/vendor/github.com/varlink/go/LICENSE
+++ /dev/null
@@ -1,201 +0,0 @@
- Apache License
- Version 2.0, January 2004
- http://www.apache.org/licenses/
-
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
- 1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
- 2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
- 3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
- 4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
- 5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
- 6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
- 7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
- 8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
- 9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
- END OF TERMS AND CONDITIONS
-
- APPENDIX: How to apply the Apache License to your work.
-
- To apply the Apache License to your work, attach the following
- boilerplate notice, with the fields enclosed by brackets "[]"
- replaced with your own identifying information. (Don't include
- the brackets!) The text should be enclosed in the appropriate
- comment syntax for the file format. We also recommend that a
- file or class name and description of purpose be included on the
- same "printed page" as the copyright notice for easier
- identification within third-party archives.
-
- Copyright [yyyy] [name of copyright owner]
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
diff --git a/vendor/github.com/varlink/go/cmd/varlink-go-interface-generator/main.go b/vendor/github.com/varlink/go/cmd/varlink-go-interface-generator/main.go
deleted file mode 100644
index 98a983c5e..000000000
--- a/vendor/github.com/varlink/go/cmd/varlink-go-interface-generator/main.go
+++ /dev/null
@@ -1,445 +0,0 @@
-package main
-
-import (
- "bytes"
- "fmt"
- "go/format"
- "io/ioutil"
- "os"
- "path"
- "strings"
-
- "github.com/varlink/go/varlink/idl"
-)
-
-func writeType(b *bytes.Buffer, t *idl.Type, json bool, ident int) {
- switch t.Kind {
- case idl.TypeBool:
- b.WriteString("bool")
-
- case idl.TypeInt:
- b.WriteString("int64")
-
- case idl.TypeFloat:
- b.WriteString("float64")
-
- case idl.TypeString, idl.TypeEnum:
- b.WriteString("string")
-
- case idl.TypeObject:
- b.WriteString("json.RawMessage")
-
- case idl.TypeArray:
- b.WriteString("[]")
- writeType(b, t.ElementType, json, ident)
-
- case idl.TypeMap:
- b.WriteString("map[string]")
- writeType(b, t.ElementType, json, ident)
-
- case idl.TypeMaybe:
- b.WriteString("*")
- writeType(b, t.ElementType, json, ident)
-
- case idl.TypeAlias:
- b.WriteString(t.Alias)
-
- case idl.TypeStruct:
- if len(t.Fields) == 0 {
- b.WriteString("struct{}")
- } else {
- b.WriteString("struct {\n")
- for _, field := range t.Fields {
- for i := 0; i < ident+1; i++ {
- b.WriteString("\t")
- }
-
- b.WriteString(strings.Title(field.Name) + " ")
- writeType(b, field.Type, json, ident+1)
- if json {
- b.WriteString(" `json:\"" + field.Name)
- if field.Type.Kind == idl.TypeMaybe {
- b.WriteString(",omitempty")
- }
- b.WriteString("\"`")
- }
- b.WriteString("\n")
- }
- for i := 0; i < ident; i++ {
- b.WriteString("\t")
- }
- b.WriteString("}")
- }
- }
-}
-
-func writeDocString(b *bytes.Buffer, s string) {
- if s == "" {
- return
- }
-
- // Quote multi-line docstrings
- b.WriteString("// " + strings.Replace(s, "\n", "\n// ", -1))
- b.WriteString("\n")
-}
-
-func generateTemplate(description string) (string, []byte, error) {
- description = strings.TrimRight(description, "\n")
-
- midl, err := idl.New(description)
- if err != nil {
- return "", nil, err
- }
-
- pkgname := strings.Replace(midl.Name, ".", "", -1)
-
- var b bytes.Buffer
- b.WriteString("// Generated with github.com/varlink/go/cmd/varlink-go-interface-generator\n\n")
-
- writeDocString(&b, midl.Doc)
- b.WriteString("package " + pkgname + "\n\n")
- b.WriteString("@IMPORTS@\n\n")
-
- b.WriteString("// Generated type declarations\n\n")
-
- for _, a := range midl.Aliases {
- writeDocString(&b, a.Doc)
- b.WriteString("type " + a.Name + " ")
- writeType(&b, a.Type, true, 0)
- b.WriteString("\n\n")
- }
-
- for _, a := range midl.Errors {
- writeDocString(&b, a.Doc)
- b.WriteString("type " + a.Name + " ")
- writeType(&b, a.Type, true, 0)
- b.WriteString("\nfunc (e " + a.Name + ") Error() string {\n")
- b.WriteString("\treturn \"" + midl.Name + "." + a.Name + "\"\n")
- b.WriteString("}\n\n")
- }
-
- b.WriteString("func Dispatch_Error(err error) error {\n")
- b.WriteString("\tif e, ok := err.(*varlink.Error); ok {\n")
- b.WriteString("\t\tswitch e.Name {\n")
- for _, a := range midl.Errors {
- b.WriteString("\t\tcase \"" + midl.Name + "." + a.Name + "\":\n")
- b.WriteString("\t\t\terrorRawParameters := e.Parameters.(*json.RawMessage)\n")
- b.WriteString("\t\t\tif errorRawParameters == nil {\n")
- b.WriteString("\t\t\t\treturn e\n")
- b.WriteString("\t\t\t}\n")
- b.WriteString("\t\t\tvar param " + a.Name + "\n")
- b.WriteString("\t\t\terr := json.Unmarshal(*errorRawParameters, &param)\n")
- b.WriteString("\t\t\tif err != nil {\n")
- b.WriteString("\t\t\t\treturn e\n")
- b.WriteString("\t\t\t}\n")
- b.WriteString("\t\t\treturn &param\n")
- }
- b.WriteString("\t\t}\n")
- b.WriteString("\t}\n")
- b.WriteString("\treturn err\n")
- b.WriteString("}\n\n")
-
- b.WriteString("// Generated client method calls\n\n")
-
- for _, m := range midl.Methods {
- writeDocString(&b, m.Doc)
- b.WriteString("type " + m.Name + "_methods struct{}\n")
- b.WriteString("func " + m.Name + "() " + m.Name + "_methods { return " + m.Name + "_methods{} }\n\n")
-
- b.WriteString("func (m " + m.Name + "_methods) Call(c *varlink.Connection")
- for _, field := range m.In.Fields {
- b.WriteString(", " + field.Name + "_in_ ")
- writeType(&b, field.Type, false, 1)
- }
- b.WriteString(") (")
- for _, field := range m.Out.Fields {
- b.WriteString(field.Name + "_out_ ")
- writeType(&b, field.Type, false, 1)
- b.WriteString(", ")
- }
- b.WriteString("err_ error) {\n")
- b.WriteString("receive, err_ := m.Send(c, 0")
- for _, field := range m.In.Fields {
- b.WriteString(", " + field.Name + "_in_ ")
- }
- b.WriteString(")\n")
- b.WriteString("if err_ != nil {\n" +
- "\treturn\n" +
- "}\n")
- b.WriteString("\t")
- for _, field := range m.Out.Fields {
- b.WriteString(field.Name + "_out_ ")
- b.WriteString(", ")
- }
- b.WriteString("_, err_ = receive()\n")
- b.WriteString("\treturn\n" +
- "}\n\n")
-
- b.WriteString("func (m " + m.Name + "_methods) Send(c *varlink.Connection, flags uint64")
- for _, field := range m.In.Fields {
- b.WriteString(", " + field.Name + "_in_ ")
- writeType(&b, field.Type, false, 1)
- }
- b.WriteString(") (func() (")
- for _, field := range m.Out.Fields {
- writeType(&b, field.Type, false, 1)
- b.WriteString(", ")
- }
- b.WriteString("uint64, error), error) {\n")
- if len(m.In.Fields) > 0 {
- b.WriteString("\tvar in ")
- writeType(&b, m.In, true, 1)
- b.WriteString("\n")
- for _, field := range m.In.Fields {
- switch field.Type.Kind {
- case idl.TypeStruct, idl.TypeArray, idl.TypeMap:
- b.WriteString("\tin." + strings.Title(field.Name) + " = ")
- writeType(&b, field.Type, true, 1)
- b.WriteString("(" + field.Name + "_in_)\n")
-
- default:
- b.WriteString("\tin." + strings.Title(field.Name) + " = " + field.Name + "_in_\n")
- }
- }
- b.WriteString("\treceive, err := c.Send(\"" + midl.Name + "." + m.Name + "\", in, flags)\n")
- } else {
- b.WriteString("\treceive, err := c.Send(\"" + midl.Name + "." + m.Name + "\", nil, flags)\n")
- }
- b.WriteString("\tif err != nil {\n" +
- "\t\treturn nil, err\n" +
- "\t}\n")
- b.WriteString("\treturn func() (")
- for _, field := range m.Out.Fields {
- b.WriteString(field.Name + "_out_ ")
- writeType(&b, field.Type, false, 3)
- b.WriteString(", ")
- }
- b.WriteString("flags uint64, err error) {\n")
- if len(m.Out.Fields) > 0 {
- b.WriteString("\t\tvar out ")
- writeType(&b, m.Out, true, 2)
- b.WriteString("\n")
- b.WriteString("\t\tflags, err = receive(&out)\n")
- } else {
- b.WriteString("\t\tflags, err = receive(nil)\n")
- }
- b.WriteString("\t\tif err != nil {\n" +
- "\t\t\terr = Dispatch_Error(err)\n" +
- "\t\t\treturn\n" +
- "\t\t}\n")
- for _, field := range m.Out.Fields {
- b.WriteString("\t\t" + field.Name + "_out_ = ")
- switch field.Type.Kind {
- case idl.TypeStruct, idl.TypeArray, idl.TypeMap:
- writeType(&b, field.Type, false, 2)
- b.WriteString("(out." + strings.Title(field.Name) + ")\n")
-
- default:
- b.WriteString("out." + strings.Title(field.Name) + "\n")
- }
- }
- b.WriteString("\t\treturn\n" +
- "\t}, nil\n")
- b.WriteString("}\n\n")
- }
-
- b.WriteString("// Generated service interface with all methods\n\n")
-
- b.WriteString("type " + pkgname + "Interface interface {\n")
- for _, m := range midl.Methods {
- b.WriteString("\t" + m.Name + "(c VarlinkCall")
- for _, field := range m.In.Fields {
- b.WriteString(", " + field.Name + "_ ")
- writeType(&b, field.Type, false, 1)
- }
- b.WriteString(") error\n")
- }
- b.WriteString("}\n\n")
-
- b.WriteString("// Generated service object with all methods\n\n")
-
- b.WriteString("type VarlinkCall struct{ varlink.Call }\n\n")
-
- b.WriteString("// Generated reply methods for all varlink errors\n\n")
-
- for _, e := range midl.Errors {
- writeDocString(&b, e.Doc)
- b.WriteString("func (c *VarlinkCall) Reply" + e.Name + "(")
- for i, field := range e.Type.Fields {
- if i > 0 {
- b.WriteString(", ")
- }
- b.WriteString(field.Name + "_ ")
- writeType(&b, field.Type, false, 1)
- }
- b.WriteString(") error {\n")
- b.WriteString("\tvar out " + e.Name + "\n")
- if len(e.Type.Fields) > 0 {
- for _, field := range e.Type.Fields {
- switch field.Type.Kind {
- case idl.TypeStruct, idl.TypeArray, idl.TypeMap:
- b.WriteString("\tout." + strings.Title(field.Name) + " = ")
- writeType(&b, field.Type, true, 1)
- b.WriteString("(" + field.Name + "_)\n")
-
- default:
- b.WriteString("\tout." + strings.Title(field.Name) + " = " + field.Name + "_\n")
- }
- }
- }
- b.WriteString("\treturn c.ReplyError(\"" + midl.Name + "." + e.Name + "\", &out)\n")
- b.WriteString("}\n\n")
- }
-
- b.WriteString("// Generated reply methods for all varlink methods\n\n")
-
- for _, m := range midl.Methods {
- b.WriteString("func (c *VarlinkCall) Reply" + m.Name + "(")
- for i, field := range m.Out.Fields {
- if i > 0 {
- b.WriteString(", ")
- }
- b.WriteString(field.Name + "_ ")
- writeType(&b, field.Type, false, 1)
- }
- b.WriteString(") error {\n")
- if len(m.Out.Fields) > 0 {
- b.WriteString("\tvar out ")
- writeType(&b, m.Out, true, 1)
- b.WriteString("\n")
- for _, field := range m.Out.Fields {
- switch field.Type.Kind {
- case idl.TypeStruct, idl.TypeArray, idl.TypeMap:
- b.WriteString("\tout." + strings.Title(field.Name) + " = ")
- writeType(&b, field.Type, true, 1)
- b.WriteString("(" + field.Name + "_)\n")
-
- default:
- b.WriteString("\tout." + strings.Title(field.Name) + " = " + field.Name + "_\n")
- }
- }
- b.WriteString("\treturn c.Reply(&out)\n")
- } else {
- b.WriteString("\treturn c.Reply(nil)\n")
- }
- b.WriteString("}\n\n")
- }
-
- b.WriteString("// Generated dummy implementations for all varlink methods\n\n")
-
- for _, m := range midl.Methods {
- writeDocString(&b, m.Doc)
- b.WriteString("func (s *VarlinkInterface) " + m.Name + "(c VarlinkCall")
- for _, field := range m.In.Fields {
- b.WriteString(", " + field.Name + "_ ")
- writeType(&b, field.Type, false, 1)
- }
- b.WriteString(") error {\n" +
- "\treturn c.ReplyMethodNotImplemented(\"" + midl.Name + "." + m.Name + "\")\n" +
- "}\n\n")
- }
-
- b.WriteString("// Generated method call dispatcher\n\n")
-
- b.WriteString("func (s *VarlinkInterface) VarlinkDispatch(call varlink.Call, methodname string) error {\n" +
- "\tswitch methodname {\n")
- for _, m := range midl.Methods {
- b.WriteString("\tcase \"" + m.Name + "\":\n")
- if len(m.In.Fields) > 0 {
- b.WriteString("\t\tvar in ")
- writeType(&b, m.In, true, 2)
- b.WriteString("\n")
- b.WriteString("\t\terr := call.GetParameters(&in)\n" +
- "\t\tif err != nil {\n" +
- "\t\t\treturn call.ReplyInvalidParameter(\"parameters\")\n" +
- "\t\t}\n")
- b.WriteString("\t\treturn s." + pkgname + "Interface." + m.Name + "(VarlinkCall{call}")
- if len(m.In.Fields) > 0 {
- for _, field := range m.In.Fields {
- switch field.Type.Kind {
- case idl.TypeStruct, idl.TypeArray, idl.TypeMap:
- b.WriteString(", ")
- writeType(&b, field.Type, false, 2)
- b.WriteString("(in." + strings.Title(field.Name) + ")")
-
- default:
- b.WriteString(", in." + strings.Title(field.Name))
- }
- }
- }
- b.WriteString(")\n")
- } else {
- b.WriteString("\t\treturn s." + pkgname + "Interface." + m.Name + "(VarlinkCall{call})\n")
- }
- b.WriteString("\n")
- }
- b.WriteString("\tdefault:\n" +
- "\t\treturn call.ReplyMethodNotFound(methodname)\n" +
- "\t}\n" +
- "}\n\n")
-
- b.WriteString("// Generated varlink interface name\n\n")
-
- b.WriteString("func (s *VarlinkInterface) VarlinkGetName() string {\n" +
- "\treturn `" + midl.Name + "`\n" + "}\n\n")
-
- b.WriteString("// Generated varlink interface description\n\n")
-
- // Special-quote backtick, it cannot be part of a backtick-quoted string
- b.WriteString("func (s *VarlinkInterface) VarlinkGetDescription() string {\n" +
- "\treturn `" + strings.Replace(midl.Description, "`", "` + \"`\" + `", -1) + "\n`\n}\n\n")
-
- b.WriteString("// Generated service interface\n\n")
-
- b.WriteString("type VarlinkInterface struct {\n" +
- "\t" + pkgname + "Interface\n" +
- "}\n\n")
-
- b.WriteString("func VarlinkNew(m " + pkgname + "Interface) *VarlinkInterface {\n" +
- "\treturn &VarlinkInterface{m}\n" +
- "}\n")
-
- ret_string := b.String()
-
- if strings.Contains(ret_string, "json.RawMessage") {
- ret_string = strings.Replace(ret_string, "@IMPORTS@", "import (\n\t\"github.com/varlink/go/varlink\"\n\t\"encoding/json\"\n)", 1)
- } else {
- ret_string = strings.Replace(ret_string, "@IMPORTS@", `import "github.com/varlink/go/varlink"`, 1)
- }
-
- pretty, err := format.Source([]byte(ret_string))
- if err != nil {
- return "", nil, err
- }
-
- return pkgname, pretty, nil
-}
-
-func generateFile(varlinkFile string) {
- file, err := ioutil.ReadFile(varlinkFile)
- if err != nil {
- fmt.Fprintf(os.Stderr, "Error reading file '%s': %s\n", varlinkFile, err)
- os.Exit(1)
- }
-
- pkgname, b, err := generateTemplate(string(file))
- if err != nil {
- fmt.Fprintf(os.Stderr, "Error parsing file '%s': %s\n", varlinkFile, err)
- os.Exit(1)
- }
-
- filename := path.Dir(varlinkFile) + "/" + pkgname + ".go"
- err = ioutil.WriteFile(filename, b, 0660)
- if err != nil {
- fmt.Fprintf(os.Stderr, "Error writing file '%s': %s\n", filename, err)
- os.Exit(1)
- }
-}
-
-func main() {
- if len(os.Args) != 2 {
- fmt.Printf("Usage: %s <file>\n", os.Args[0])
- os.Exit(1)
- }
- generateFile(os.Args[1])
-}
diff --git a/vendor/github.com/varlink/go/varlink/bridge.go b/vendor/github.com/varlink/go/varlink/bridge.go
deleted file mode 100644
index c478dcd88..000000000
--- a/vendor/github.com/varlink/go/varlink/bridge.go
+++ /dev/null
@@ -1,65 +0,0 @@
-// +build !windows
-
-package varlink
-
-import (
- "bufio"
- "io"
- "net"
- "os"
- "os/exec"
-)
-
-type PipeCon struct {
- net.Conn
- cmd *exec.Cmd
- reader *io.ReadCloser
- writer *io.WriteCloser
-}
-
-func (p PipeCon) Close() error {
- err1 := (*p.reader).Close()
- err2 := (*p.writer).Close()
- if err1 != nil {
- return err1
- }
- if err2 != nil {
- return err2
- }
- p.cmd.Wait()
-
- return nil
-}
-
-// NewBridgeWithStderr returns a new connection with the given bridge.
-func NewBridgeWithStderr(bridge string, stderr io.Writer) (*Connection, error) {
- //var err error
-
- c := Connection{}
- cmd := exec.Command("sh", "-c", bridge)
- cmd.Stderr = stderr
- r, err := cmd.StdoutPipe()
- if err != nil {
- return nil, err
- }
- w, err := cmd.StdinPipe()
- if err != nil {
- return nil, err
- }
- c.conn = PipeCon{nil, cmd, &r, &w}
- c.address = ""
- c.Reader = bufio.NewReader(r)
- c.Writer = bufio.NewWriter(w)
-
- err = cmd.Start()
- if err != nil {
- return nil, err
- }
-
- return &c, nil
-}
-
-// NewBridge returns a new connection with the given bridge.
-func NewBridge(bridge string) (*Connection, error) {
- return NewBridgeWithStderr(bridge, os.Stderr)
-}
diff --git a/vendor/github.com/varlink/go/varlink/bridge_windows.go b/vendor/github.com/varlink/go/varlink/bridge_windows.go
deleted file mode 100644
index 42953b871..000000000
--- a/vendor/github.com/varlink/go/varlink/bridge_windows.go
+++ /dev/null
@@ -1,63 +0,0 @@
-package varlink
-
-import (
- "bufio"
- "io"
- "net"
- "os"
- "os/exec"
-)
-
-type PipeCon struct {
- net.Conn
- cmd *exec.Cmd
- reader *io.ReadCloser
- writer *io.WriteCloser
-}
-
-func (p PipeCon) Close() error {
- err1 := (*p.reader).Close()
- err2 := (*p.writer).Close()
- if err1 != nil {
- return err1
- }
- if err2 != nil {
- return err2
- }
- p.cmd.Wait()
-
- return nil
-}
-
-// NewBridgeWithStderr returns a new connection with the given bridge.
-func NewBridgeWithStderr(bridge string, stderr io.Writer) (*Connection, error) {
- //var err error
-
- c := Connection{}
- cmd := exec.Command("cmd", "/C", bridge)
- cmd.Stderr = stderr
- r, err := cmd.StdoutPipe()
- if err != nil {
- return nil, err
- }
- w, err := cmd.StdinPipe()
- if err != nil {
- return nil, err
- }
- c.conn = PipeCon{nil, cmd, &r, &w}
- c.address = ""
- c.Reader = bufio.NewReader(r)
- c.Writer = bufio.NewWriter(w)
-
- err = cmd.Start()
- if err != nil {
- return nil, err
- }
-
- return &c, nil
-}
-
-// NewBridge returns a new connection with the given bridge.
-func NewBridge(bridge string) (*Connection, error) {
- return NewBridgeWithStderr(bridge, os.Stderr)
-} \ No newline at end of file
diff --git a/vendor/github.com/varlink/go/varlink/call.go b/vendor/github.com/varlink/go/varlink/call.go
deleted file mode 100644
index 0eaf24aca..000000000
--- a/vendor/github.com/varlink/go/varlink/call.go
+++ /dev/null
@@ -1,104 +0,0 @@
-package varlink
-
-import (
- "bufio"
- "encoding/json"
- "fmt"
- "io"
- "net"
- "strings"
-)
-
-// Call is a method call retrieved by a Service. The connection from the
-// client can be terminated by returning an error from the call instead
-// of sending a reply or error reply.
-type Call struct {
- *bufio.Reader
- *bufio.Writer
- Conn *net.Conn
- Request *[]byte
- In *serviceCall
- Continues bool
- Upgrade bool
-}
-
-// WantsMore indicates if the calling client accepts more than one reply to this method call.
-func (c *Call) WantsMore() bool {
- return c.In.More
-}
-
-// WantsUpgrade indicates that the calling client wants the connection to be upgraded.
-func (c *Call) WantsUpgrade() bool {
- return c.In.Upgrade
-}
-
-// IsOneway indicate that the calling client does not expect a reply.
-func (c *Call) IsOneway() bool {
- return c.In.Oneway
-}
-
-// GetParameters retrieves the method call parameters.
-func (c *Call) GetParameters(p interface{}) error {
- if c.In.Parameters == nil {
- return fmt.Errorf("empty parameters")
- }
- return json.Unmarshal(*c.In.Parameters, p)
-}
-
-func (c *Call) sendMessage(r *serviceReply) error {
- if c.In.Oneway {
- return nil
- }
-
- b, e := json.Marshal(r)
- if e != nil {
- return e
- }
-
- b = append(b, 0)
- _, e = c.Writer.Write(b)
- if e != nil {
- if e == io.EOF {
- return io.ErrUnexpectedEOF
- }
- return e
- }
- e = c.Writer.Flush()
- if e == io.EOF {
- return io.ErrUnexpectedEOF
- }
- return e
-}
-
-// Reply sends a reply to this method call.
-func (c *Call) Reply(parameters interface{}) error {
- if !c.Continues {
- return c.sendMessage(&serviceReply{
- Parameters: parameters,
- })
- }
-
- if !c.In.More {
- return fmt.Errorf("call did not set more, it does not expect continues")
- }
-
- return c.sendMessage(&serviceReply{
- Continues: true,
- Parameters: parameters,
- })
-}
-
-// ReplyError sends an error reply to this method call.
-func (c *Call) ReplyError(name string, parameters interface{}) error {
- r := strings.LastIndex(name, ".")
- if r <= 0 {
- return fmt.Errorf("invalid error name")
- }
- if name[:r] == "org.varlink.service" {
- return fmt.Errorf("refused to send org.varlink.service errors")
- }
- return c.sendMessage(&serviceReply{
- Error: name,
- Parameters: parameters,
- })
-}
diff --git a/vendor/github.com/varlink/go/varlink/connection.go b/vendor/github.com/varlink/go/varlink/connection.go
deleted file mode 100644
index 596caa825..000000000
--- a/vendor/github.com/varlink/go/varlink/connection.go
+++ /dev/null
@@ -1,291 +0,0 @@
-package varlink
-
-import (
- "bufio"
- "encoding/json"
- "fmt"
- "io"
- "net"
- "strings"
-)
-
-// Message flags for Send(). More indicates that the client accepts more than one method
-// reply to this call. Oneway requests, that the service must not send a method reply to
-// this call. Continues indicates that the service will send more than one reply.
-const (
- More = 1 << iota
- Oneway = 1 << iota
- Continues = 1 << iota
- Upgrade = 1 << iota
-)
-
-// Error is a varlink error returned from a method call.
-type Error struct {
- Name string
- Parameters interface{}
-}
-
-func (e *Error) DispatchError() error {
- errorRawParameters := e.Parameters.(*json.RawMessage)
-
- switch e.Name {
- case "org.varlink.service.InterfaceNotFound":
- var param InterfaceNotFound
- if errorRawParameters != nil {
- err := json.Unmarshal(*errorRawParameters, &param)
- if err != nil {
- return e
- }
- }
- return &param
- case "org.varlink.service.MethodNotFound":
- var param MethodNotFound
- if errorRawParameters != nil {
- err := json.Unmarshal(*errorRawParameters, &param)
- if err != nil {
- return e
- }
- }
- return &param
- case "org.varlink.service.MethodNotImplemented":
- var param MethodNotImplemented
- if errorRawParameters != nil {
- err := json.Unmarshal(*errorRawParameters, &param)
- if err != nil {
- return e
- }
- }
- return &param
- case "org.varlink.service.InvalidParameter":
- var param InvalidParameter
- if errorRawParameters != nil {
- err := json.Unmarshal(*errorRawParameters, &param)
- if err != nil {
- return e
- }
- }
- return &param
- }
- return e
-}
-
-// Error returns the fully-qualified varlink error name.
-func (e *Error) Error() string {
- return e.Name
-}
-
-// Connection is a connection from a client to a service.
-type Connection struct {
- io.Closer
- address string
- conn net.Conn
- Reader *bufio.Reader
- Writer *bufio.Writer
-}
-
-// Send sends a method call. It returns a receive() function which is called to retrieve the method reply.
-// If Send() is called with the `More`flag and the receive() function carries the `Continues` flag, receive()
-// can be called multiple times to retrieve multiple replies.
-func (c *Connection) Send(method string, parameters interface{}, flags uint64) (func(interface{}) (uint64, error), error) {
- type call struct {
- Method string `json:"method"`
- Parameters interface{} `json:"parameters,omitempty"`
- More bool `json:"more,omitempty"`
- Oneway bool `json:"oneway,omitempty"`
- Upgrade bool `json:"upgrade,omitempty"`
- }
-
- if (flags&More != 0) && (flags&Oneway != 0) {
- return nil, &Error{
- Name: "org.varlink.InvalidParameter",
- Parameters: "oneway",
- }
- }
-
- if (flags&More != 0) && (flags&Upgrade != 0) {
- return nil, &Error{
- Name: "org.varlink.InvalidParameter",
- Parameters: "more",
- }
- }
-
- m := call{
- Method: method,
- Parameters: parameters,
- More: flags&More != 0,
- Oneway: flags&Oneway != 0,
- Upgrade: flags&Upgrade != 0,
- }
- b, err := json.Marshal(m)
- if err != nil {
- return nil, err
- }
-
- b = append(b, 0)
- _, err = c.Writer.Write(b)
- if err != nil {
- if err == io.EOF {
- return nil, io.ErrUnexpectedEOF
- }
- return nil, err
- }
-
- err = c.Writer.Flush()
- if err != nil {
- if err == io.EOF {
- return nil, io.ErrUnexpectedEOF
- }
- return nil, err
- }
-
- receive := func(out_parameters interface{}) (uint64, error) {
- type reply struct {
- Parameters *json.RawMessage `json:"parameters"`
- Continues bool `json:"continues"`
- Error string `json:"error"`
- }
-
- out, err := c.Reader.ReadBytes('\x00')
- if err != nil {
- if err == io.EOF {
- return 0, io.ErrUnexpectedEOF
- }
- return 0, err
- }
-
- var m reply
- err = json.Unmarshal(out[:len(out)-1], &m)
- if err != nil {
- return 0, err
- }
-
- if m.Error != "" {
- e := &Error{
- Name: m.Error,
- Parameters: m.Parameters,
- }
- return 0, e.DispatchError()
- }
-
- if m.Parameters != nil {
- json.Unmarshal(*m.Parameters, out_parameters)
- }
-
- if m.Continues {
- return Continues, nil
- }
-
- return 0, nil
- }
-
- return receive, nil
-}
-
-// Call sends a method call and returns the method reply.
-func (c *Connection) Call(method string, parameters interface{}, out_parameters interface{}) error {
- receive, err := c.Send(method, &parameters, 0)
- if err != nil {
- return err
- }
-
- _, err = receive(out_parameters)
- return err
-}
-
-// GetInterfaceDescription requests the interface description string from the service.
-func (c *Connection) GetInterfaceDescription(name string) (string, error) {
- type request struct {
- Interface string `json:"interface"`
- }
- type reply struct {
- Description string `json:"description"`
- }
-
- var r reply
- err := c.Call("org.varlink.service.GetInterfaceDescription", request{Interface: name}, &r)
- if err != nil {
- return "", err
- }
-
- return r.Description, nil
-}
-
-// GetInfo requests information about the service.
-func (c *Connection) GetInfo(vendor *string, product *string, version *string, url *string, interfaces *[]string) error {
- type reply struct {
- Vendor string `json:"vendor"`
- Product string `json:"product"`
- Version string `json:"version"`
- URL string `json:"url"`
- Interfaces []string `json:"interfaces"`
- }
-
- var r reply
- err := c.Call("org.varlink.service.GetInfo", nil, &r)
- if err != nil {
- return err
- }
-
- if vendor != nil {
- *vendor = r.Vendor
- }
- if product != nil {
- *product = r.Product
- }
- if version != nil {
- *version = r.Version
- }
- if url != nil {
- *url = r.URL
- }
- if interfaces != nil {
- *interfaces = r.Interfaces
- }
-
- return nil
-}
-
-// Close terminates the connection.
-func (c *Connection) Close() error {
- return c.conn.Close()
-}
-
-// NewConnection returns a new connection to the given address.
-func NewConnection(address string) (*Connection, error) {
- var err error
-
- words := strings.SplitN(address, ":", 2)
-
- if len(words) != 2 {
- return nil, fmt.Errorf("Protocol missing")
- }
-
- protocol := words[0]
- addr := words[1]
-
- // Ignore parameters after ';'
- words = strings.SplitN(addr, ";", 2)
- if words != nil {
- addr = words[0]
- }
-
- switch protocol {
- case "unix":
- break
-
- case "tcp":
- break
- }
-
- c := Connection{}
- c.conn, err = net.Dial(protocol, addr)
- if err != nil {
- return nil, err
- }
-
- c.address = address
- c.Reader = bufio.NewReader(c.conn)
- c.Writer = bufio.NewWriter(c.conn)
-
- return &c, nil
-}
diff --git a/vendor/github.com/varlink/go/varlink/doc.go b/vendor/github.com/varlink/go/varlink/doc.go
deleted file mode 100644
index de1ed2380..000000000
--- a/vendor/github.com/varlink/go/varlink/doc.go
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
-Package varlink provides varlink client and server implementations. See http://varlink.org
-for more information about varlink.
-
-Example varlink interface definition in a org.example.this.varlink file:
- interface org.example.this
-
- method Ping(in: string) -> (out: string)
-
-Generated Go module in a orgexamplethis/orgexamplethis.go file. The generated module
-provides reply methods for all methods specified in the varlink interface description.
-The stub implementations return a MethodNotImplemented error; the service implementation
-using this module will override the methods with its own implementation.
- // Generated with github.com/varlink/go/cmd/varlink-go-interface-generator
- package orgexamplethis
-
- import "github.com/varlink/go/varlink"
-
- type orgexamplethisInterface interface {
- Ping(c VarlinkCall, in string) error
- }
-
- type VarlinkCall struct{ varlink.Call }
-
- func (c *VarlinkCall) ReplyPing(out string) error {
- var out struct {
- Out string `json:"out,omitempty"`
- }
- out.Out = out
- return c.Reply(&out)
- }
-
- func (s *VarlinkInterface) Ping(c VarlinkCall, in string) error {
- return c.ReplyMethodNotImplemented("Ping")
- }
-
- [...]
-
-Service implementing the interface and its method:
- import ("orgexamplethis")
-
- type Data struct {
- orgexamplethis.VarlinkInterface
- data string
- }
-
- data := Data{data: "test"}
-
- func (d *Data) Ping(call orgexamplethis.VarlinkCall, ping string) error {
- return call.ReplyPing(ping)
- }
-
- service, _ = varlink.NewService(
- "Example",
- "This",
- "1",
- "https://example.org/this",
- )
-
- service.RegisterInterface(orgexamplethis.VarlinkNew(&data))
- err := service.Listen("unix:/run/org.example.this", 0)
-*/
-package varlink
diff --git a/vendor/github.com/varlink/go/varlink/idl/idl.go b/vendor/github.com/varlink/go/varlink/idl/idl.go
deleted file mode 100644
index b09b4798b..000000000
--- a/vendor/github.com/varlink/go/varlink/idl/idl.go
+++ /dev/null
@@ -1,497 +0,0 @@
-// Package idl provides a varlink interface description parser.
-package idl
-
-import (
- "bytes"
- "fmt"
- "regexp"
-)
-
-// Valid TypeKind values.
-const (
- TypeBool = iota
- TypeInt
- TypeFloat
- TypeString
- TypeObject
- TypeArray
- TypeMaybe
- TypeMap
- TypeStruct
- TypeEnum
- TypeAlias
-)
-
-// TypeKind specifies the type of an Type.
-type TypeKind uint
-
-// Type represents a varlink type. Types are method input and output parameters,
-// error output parameters, or custom defined types in the interface description.
-type Type struct {
- Kind TypeKind
- ElementType *Type
- Alias string
- Fields []TypeField
-}
-
-// TypeField is a named member of a TypeStruct.
-type TypeField struct {
- Name string
- Type *Type
-}
-
-// Alias represents a named Type in the interface description.
-type Alias struct {
- Name string
- Doc string
- Type *Type
-}
-
-// Method represents a method defined in the interface description.
-type Method struct {
- Name string
- Doc string
- In *Type
- Out *Type
-}
-
-// Error represents an error defined in the interface description.
-type Error struct {
- Name string
- Doc string
- Type *Type
-}
-
-// IDL represents a parsed varlink interface description with types, methods, errors and
-// documentation.
-type IDL struct {
- Name string
- Doc string
- Description string
- Members []interface{}
- Aliases []*Alias
- Methods []*Method
- Errors []*Error
-}
-
-type parser struct {
- input string
- position int
- lineStart int
- lastComment bytes.Buffer
-}
-
-func (p *parser) next() int {
- r := -1
-
- if p.position < len(p.input) {
- r = int(p.input[p.position])
- }
-
- p.position++
- return r
-}
-
-func (p *parser) backup() {
- p.position--
-}
-
-func (p *parser) advance() bool {
- for {
- char := p.next()
-
- if char == '\n' {
- p.lineStart = p.position
- p.lastComment.Reset()
-
- } else if char == ' ' || char == '\t' {
- // ignore
-
- } else if char == '#' {
- p.next()
- start := p.position
- for {
- c := p.next()
- if c < 0 || c == '\n' {
- p.backup()
- break
- }
- }
- if p.lastComment.Len() > 0 {
- p.lastComment.WriteByte('\n')
- }
- p.lastComment.WriteString(p.input[start:p.position])
- p.next()
-
- } else {
- p.backup()
- break
- }
- }
-
- return p.position < len(p.input)
-}
-
-func (p *parser) advanceOnLine() {
- for {
- char := p.next()
- if char != ' ' {
- p.backup()
- return
- }
- }
-}
-
-func (p *parser) readKeyword() string {
- start := p.position
-
- for {
- char := p.next()
- if char < 'a' || char > 'z' {
- p.backup()
- break
- }
- }
-
- return p.input[start:p.position]
-}
-
-func (p *parser) readInterfaceName() string {
- start := p.position
- dnrx := regexp.MustCompile(`^[a-z]+(\.[a-z0-9]+([-][a-z0-9]+)*)+`)
- name := dnrx.FindString(p.input[start:])
- if name != "" {
- if len(name) > 255 {
- return ""
- }
- p.position += len(name)
- return name
- }
- xdnrx := regexp.MustCompile(`^xn--[a-z0-9]+(\.[a-z0-9]+([-][a-z0-9]+)*)+`)
- name = xdnrx.FindString(p.input[start:])
- if name != "" {
- if len(name) > 255 {
- return ""
- }
- p.position += len(name)
- return name
- }
- return ""
-}
-
-func (p *parser) readFieldName() string {
- start := p.position
-
- char := p.next()
- if char < 'a' || char > 'z' {
- p.backup()
- return ""
- }
-
- for {
- char := p.next()
- if (char < 'A' || char > 'Z') && (char < 'a' || char > 'z') && (char < '0' || char > '9') && char != '_' {
- p.backup()
- break
- }
- }
-
- return p.input[start:p.position]
-}
-
-func (p *parser) readTypeName() string {
- start := p.position
-
- for {
- char := p.next()
- if (char < 'A' || char > 'Z') && (char < 'a' || char > 'z') && (char < '0' || char > '9') {
- p.backup()
- break
- }
- }
-
- return p.input[start:p.position]
-}
-
-func (p *parser) readStructType() *Type {
- if p.next() != '(' {
- p.backup()
- return nil
- }
-
- t := &Type{Kind: TypeStruct}
- t.Fields = make([]TypeField, 0)
-
- char := p.next()
- if char != ')' {
- p.backup()
-
- for {
- field := TypeField{}
-
- p.advance()
- field.Name = p.readFieldName()
- if field.Name == "" {
- return nil
- }
-
- p.advance()
-
- // Enums have no types, they are just a list of names
- if p.next() == ':' {
- if t.Kind == TypeEnum {
- return nil
- }
-
- p.advance()
- field.Type = p.readType()
- if field.Type == nil {
- return nil
- }
-
- } else {
- t.Kind = TypeEnum
- p.backup()
- }
-
- t.Fields = append(t.Fields, field)
-
- p.advance()
- char = p.next()
- if char != ',' {
- break
- }
- }
-
- if char != ')' {
- return nil
- }
- }
-
- return t
-}
-
-func (p *parser) readType() *Type {
- var t *Type
-
- switch p.next() {
- case '?':
- e := p.readType()
- if e == nil {
- return nil
- }
- if e.Kind == TypeMaybe {
- return nil
- }
- t = &Type{Kind: TypeMaybe, ElementType: e}
-
- case '[':
- var kind TypeKind
-
- switch p.readKeyword() {
- case "string":
- kind = TypeMap
-
- case "":
- kind = TypeArray
-
- default:
- return nil
- }
-
- if p.next() != ']' {
- return nil
- }
- e := p.readType()
- if e == nil {
- return nil
- }
- t = &Type{Kind: kind, ElementType: e}
-
- default:
- p.backup()
- if keyword := p.readKeyword(); keyword != "" {
- switch keyword {
- case "bool":
- t = &Type{Kind: TypeBool}
-
- case "int":
- t = &Type{Kind: TypeInt}
-
- case "float":
- t = &Type{Kind: TypeFloat}
-
- case "string":
- t = &Type{Kind: TypeString}
-
- case "object":
- t = &Type{Kind: TypeObject}
- }
-
- } else if name := p.readTypeName(); name != "" {
- t = &Type{Kind: TypeAlias, Alias: name}
-
- } else if t = p.readStructType(); t == nil {
- return nil
- }
- }
-
- return t
-}
-
-func (p *parser) readAlias(idl *IDL) (*Alias, error) {
- a := &Alias{}
-
- p.advance()
- a.Doc = p.lastComment.String()
- a.Name = p.readTypeName()
- if a.Name == "" {
- return nil, fmt.Errorf("missing type name")
- }
-
- p.advance()
- a.Type = p.readType()
- if a.Type == nil {
- return nil, fmt.Errorf("missing type declaration")
- }
-
- return a, nil
-}
-
-func (p *parser) readMethod(idl *IDL) (*Method, error) {
- m := &Method{}
-
- p.advance()
- m.Doc = p.lastComment.String()
- m.Name = p.readTypeName()
- if m.Name == "" {
- return nil, fmt.Errorf("missing method type")
- }
-
- p.advance()
- m.In = p.readType()
- if m.In == nil {
- return nil, fmt.Errorf("missing method input")
- }
-
- p.advance()
- one := p.next()
- two := p.next()
- if (one != '-') || two != '>' {
- return nil, fmt.Errorf("missing method '->' operator")
- }
-
- p.advance()
- m.Out = p.readType()
- if m.Out == nil {
- return nil, fmt.Errorf("missing method output")
- }
-
- return m, nil
-}
-
-func (p *parser) readError(idl *IDL) (*Error, error) {
- e := &Error{}
-
- p.advance()
- e.Doc = p.lastComment.String()
- e.Name = p.readTypeName()
- if e.Name == "" {
- return nil, fmt.Errorf("missing error name")
- }
-
- p.advanceOnLine()
- e.Type = p.readType()
-
- return e, nil
-}
-
-func (p *parser) readIDL() (*IDL, error) {
- if keyword := p.readKeyword(); keyword != "interface" {
- return nil, fmt.Errorf("missing interface keyword")
- }
-
- idl := &IDL{
- Members: make([]interface{}, 0),
- Aliases: make([]*Alias, 0),
- Methods: make([]*Method, 0),
- Errors: make([]*Error, 0),
- }
-
- p.advance()
- idl.Doc = p.lastComment.String()
- idl.Name = p.readInterfaceName()
- if idl.Name == "" {
- return nil, fmt.Errorf("interface name")
- }
-
- // Check for duplicates
- members := make(map[string]struct{}, 0)
-
- for {
- if !p.advance() {
- break
- }
-
- switch keyword := p.readKeyword(); keyword {
- case "type":
- a, err := p.readAlias(idl)
- if err != nil {
- return nil, err
- }
- if _, ok := members[a.Name]; ok {
- return nil, fmt.Errorf("type `%s` already defined", a.Name)
- }
- members[a.Name] = struct{}{}
- idl.Aliases = append(idl.Aliases, a)
- idl.Members = append(idl.Members, a)
-
- case "method":
- m, err := p.readMethod(idl)
- if err != nil {
- return nil, err
- }
- if _, ok := members[m.Name]; ok {
- return nil, fmt.Errorf("method `%s` already defined", m.Name)
- }
- members[m.Name] = struct{}{}
- idl.Methods = append(idl.Methods, m)
- idl.Members = append(idl.Members, m)
-
- case "error":
- e, err := p.readError(idl)
- if err != nil {
- return nil, err
- }
- if _, ok := members[e.Name]; ok {
- return nil, fmt.Errorf("error `%s` already defined", e.Name)
- }
- members[e.Name] = struct{}{}
- idl.Errors = append(idl.Errors, e)
- idl.Members = append(idl.Members, e)
-
- default:
- return nil, fmt.Errorf("unknown keyword '%s'", keyword)
- }
- }
-
- return idl, nil
-}
-
-// New parses a varlink interface description.
-func New(description string) (*IDL, error) {
- p := &parser{input: description}
-
- p.advance()
- idl, err := p.readIDL()
- if err != nil {
- return nil, err
- }
-
- if len(idl.Methods) == 0 {
- return nil, fmt.Errorf("no methods defined")
- }
-
- idl.Description = description
- return idl, nil
-}
diff --git a/vendor/github.com/varlink/go/varlink/orgvarlinkservice.go b/vendor/github.com/varlink/go/varlink/orgvarlinkservice.go
deleted file mode 100644
index 600c99d34..000000000
--- a/vendor/github.com/varlink/go/varlink/orgvarlinkservice.go
+++ /dev/null
@@ -1,162 +0,0 @@
-package varlink
-
-// The requested interface was not found.
-type InterfaceNotFound struct {
- Interface string `json:"interface"`
-}
-
-func (e InterfaceNotFound) Error() string {
- return "org.varlink.service.InterfaceNotFound"
-}
-
-// The requested method was not found
-type MethodNotFound struct {
- Method string `json:"method"`
-}
-
-func (e MethodNotFound) Error() string {
- return "org.varlink.service.MethodNotFound"
-}
-
-// The interface defines the requested method, but the service does not
-// implement it.
-type MethodNotImplemented struct {
- Method string `json:"method"`
-}
-
-func (e MethodNotImplemented) Error() string {
- return "org.varlink.service.MethodNotImplemented"
-}
-
-// One of the passed parameters is invalid.
-type InvalidParameter struct {
- Parameter string `json:"parameter"`
-}
-
-func (e InvalidParameter) Error() string {
- return "org.varlink.service.InvalidParameter"
-}
-
-func doReplyError(c *Call, name string, parameters interface{}) error {
- return c.sendMessage(&serviceReply{
- Error: name,
- Parameters: parameters,
- })
-}
-
-// ReplyInterfaceNotFound sends a org.varlink.service errror reply to this method call
-func (c *Call) ReplyInterfaceNotFound(interfaceA string) error {
- var out InterfaceNotFound
- out.Interface = interfaceA
- return doReplyError(c, "org.varlink.service.InterfaceNotFound", &out)
-}
-
-// ReplyMethodNotFound sends a org.varlink.service errror reply to this method call
-func (c *Call) ReplyMethodNotFound(method string) error {
- var out MethodNotFound
- out.Method = method
- return doReplyError(c, "org.varlink.service.MethodNotFound", &out)
-}
-
-// ReplyMethodNotImplemented sends a org.varlink.service errror reply to this method call
-func (c *Call) ReplyMethodNotImplemented(method string) error {
- var out MethodNotImplemented
- out.Method = method
- return doReplyError(c, "org.varlink.service.MethodNotImplemented", &out)
-}
-
-// ReplyInvalidParameter sends a org.varlink.service errror reply to this method call
-func (c *Call) ReplyInvalidParameter(parameter string) error {
- var out InvalidParameter
- out.Parameter = parameter
- return doReplyError(c, "org.varlink.service.InvalidParameter", &out)
-}
-
-func (c *Call) replyGetInfo(vendor string, product string, version string, url string, interfaces []string) error {
- var out struct {
- Vendor string `json:"vendor,omitempty"`
- Product string `json:"product,omitempty"`
- Version string `json:"version,omitempty"`
- URL string `json:"url,omitempty"`
- Interfaces []string `json:"interfaces,omitempty"`
- }
- out.Vendor = vendor
- out.Product = product
- out.Version = version
- out.URL = url
- out.Interfaces = interfaces
- return c.Reply(&out)
-}
-
-func (c *Call) replyGetInterfaceDescription(description string) error {
- var out struct {
- Description string `json:"description,omitempty"`
- }
- out.Description = description
- return c.Reply(&out)
-}
-
-func (s *Service) orgvarlinkserviceDispatch(c Call, methodname string) error {
- switch methodname {
- case "GetInfo":
- return s.getInfo(c)
- case "GetInterfaceDescription":
- var in struct {
- Interface string `json:"interface"`
- }
- err := c.GetParameters(&in)
- if err != nil {
- return c.ReplyInvalidParameter("parameters")
- }
- return s.getInterfaceDescription(c, in.Interface)
-
- default:
- return c.ReplyMethodNotFound(methodname)
- }
-}
-
-func (s *orgvarlinkserviceInterface) VarlinkDispatch(call Call, methodname string) error {
- return nil
-}
-
-func (s *orgvarlinkserviceInterface) VarlinkGetName() string {
- return `org.varlink.service`
-}
-
-func (s *orgvarlinkserviceInterface) VarlinkGetDescription() string {
- return `# The Varlink Service Interface is provided by every varlink service. It
-# describes the service and the interfaces it implements.
-interface org.varlink.service
-
-# Get a list of all the interfaces a service provides and information
-# about the implementation.
-method GetInfo() -> (
- vendor: string,
- product: string,
- version: string,
- url: string,
- interfaces: []string
-)
-
-# Get the description of an interface that is implemented by this service.
-method GetInterfaceDescription(interface: string) -> (description: string)
-
-# The requested interface was not found.
-error InterfaceNotFound (interface: string)
-
-# The requested method was not found
-error MethodNotFound (method: string)
-
-# The interface defines the requested method, but the service does not
-# implement it.
-error MethodNotImplemented (method: string)
-
-# One of the passed parameters is invalid.
-error InvalidParameter (parameter: string)`
-}
-
-type orgvarlinkserviceInterface struct{}
-
-func orgvarlinkserviceNew() *orgvarlinkserviceInterface {
- return &orgvarlinkserviceInterface{}
-}
diff --git a/vendor/github.com/varlink/go/varlink/resolver.go b/vendor/github.com/varlink/go/varlink/resolver.go
deleted file mode 100644
index f0f4487d2..000000000
--- a/vendor/github.com/varlink/go/varlink/resolver.go
+++ /dev/null
@@ -1,92 +0,0 @@
-package varlink
-
-// ResolverAddress is the well-known address of the varlink interface resolver,
-// it translates varlink interface names to varlink service addresses.
-const ResolverAddress = "unix:/run/org.varlink.resolver"
-
-// Resolver resolves varlink interface names to varlink addresses
-type Resolver struct {
- address string
- conn *Connection
-}
-
-// Resolve resolves a varlink interface name to a varlink address.
-func (r *Resolver) Resolve(iface string) (string, error) {
- type request struct {
- Interface string `json:"interface"`
- }
- type reply struct {
- Address string `json:"address"`
- }
-
- /* don't ask the resolver for itself */
- if iface == "org.varlink.resolver" {
- return r.address, nil
- }
-
- var rep reply
- err := r.conn.Call("org.varlink.resolver.Resolve", &request{Interface: iface}, &rep)
- if err != nil {
- return "", err
- }
-
- return rep.Address, nil
-}
-
-// GetInfo requests information about the resolver.
-func (r *Resolver) GetInfo(vendor *string, product *string, version *string, url *string, interfaces *[]string) error {
- type reply struct {
- Vendor string
- Product string
- Version string
- URL string
- Interfaces []string
- }
-
- var rep reply
- err := r.conn.Call("org.varlink.resolver.GetInfo", nil, &rep)
- if err != nil {
- return err
- }
-
- if vendor != nil {
- *vendor = rep.Vendor
- }
- if product != nil {
- *product = rep.Product
- }
- if version != nil {
- *version = rep.Version
- }
- if url != nil {
- *url = rep.URL
- }
- if interfaces != nil {
- *interfaces = rep.Interfaces
- }
-
- return nil
-}
-
-// Close terminates the resolver.
-func (r *Resolver) Close() error {
- return r.conn.Close()
-}
-
-// NewResolver returns a new resolver connected to the given address.
-func NewResolver(address string) (*Resolver, error) {
- if address == "" {
- address = ResolverAddress
- }
-
- c, err := NewConnection(address)
- if err != nil {
- return nil, err
- }
- r := Resolver{
- address: address,
- conn: c,
- }
-
- return &r, nil
-}
diff --git a/vendor/github.com/varlink/go/varlink/service.go b/vendor/github.com/varlink/go/varlink/service.go
deleted file mode 100644
index bf13aa1de..000000000
--- a/vendor/github.com/varlink/go/varlink/service.go
+++ /dev/null
@@ -1,375 +0,0 @@
-package varlink
-
-import (
- "bufio"
- "encoding/json"
- "fmt"
- "net"
- "os"
- "strings"
- "sync"
- "time"
-)
-
-type dispatcher interface {
- VarlinkDispatch(c Call, methodname string) error
- VarlinkGetName() string
- VarlinkGetDescription() string
-}
-
-type serviceCall struct {
- Method string `json:"method"`
- Parameters *json.RawMessage `json:"parameters,omitempty"`
- More bool `json:"more,omitempty"`
- Oneway bool `json:"oneway,omitempty"`
- Upgrade bool `json:"upgrade,omitempty"`
-}
-
-type serviceReply struct {
- Parameters interface{} `json:"parameters,omitempty"`
- Continues bool `json:"continues,omitempty"`
- Error string `json:"error,omitempty"`
-}
-
-// Service represents an active varlink service. In addition to the registered custom varlink Interfaces, every service
-// implements the org.varlink.service interface which allows clients to retrieve information about the
-// running service.
-type Service struct {
- vendor string
- product string
- version string
- url string
- interfaces map[string]dispatcher
- names []string
- descriptions map[string]string
- running bool
- listener net.Listener
- conncounter int64
- mutex sync.Mutex
- protocol string
- address string
-}
-
-// ServiceTimoutError helps API users to special-case timeouts.
-type ServiceTimeoutError struct{}
-
-func (ServiceTimeoutError) Error() string {
- return "service timeout"
-}
-
-func (s *Service) getInfo(c Call) error {
- return c.replyGetInfo(s.vendor, s.product, s.version, s.url, s.names)
-}
-
-func (s *Service) getInterfaceDescription(c Call, name string) error {
- if name == "" {
- return c.ReplyInvalidParameter("interface")
- }
-
- description, ok := s.descriptions[name]
- if !ok {
- return c.ReplyInvalidParameter("interface")
- }
-
- return c.replyGetInterfaceDescription(description)
-}
-
-func (s *Service) HandleMessage(conn *net.Conn, reader *bufio.Reader, writer *bufio.Writer, request []byte) error {
- var in serviceCall
-
- err := json.Unmarshal(request, &in)
-
- if err != nil {
- return err
- }
-
- c := Call{
- Conn: conn,
- Reader: reader,
- Writer: writer,
- In: &in,
- Request: &request,
- }
-
- r := strings.LastIndex(in.Method, ".")
- if r <= 0 {
- return c.ReplyInvalidParameter("method")
- }
-
- interfacename := in.Method[:r]
- methodname := in.Method[r+1:]
-
- if interfacename == "org.varlink.service" {
- return s.orgvarlinkserviceDispatch(c, methodname)
- }
-
- // Find the interface and method in our service
- iface, ok := s.interfaces[interfacename]
- if !ok {
- return c.ReplyInterfaceNotFound(interfacename)
- }
-
- return iface.VarlinkDispatch(c, methodname)
-}
-
-// Shutdown shuts down the listener of a running service.
-func (s *Service) Shutdown() {
- s.running = false
- s.mutex.Lock()
- if s.listener != nil {
- s.listener.Close()
- }
- s.mutex.Unlock()
-}
-
-func (s *Service) handleConnection(conn net.Conn, wg *sync.WaitGroup) {
- defer func() { s.mutex.Lock(); s.conncounter--; s.mutex.Unlock(); wg.Done() }()
- reader := bufio.NewReader(conn)
- writer := bufio.NewWriter(conn)
-
- for {
- request, err := reader.ReadBytes('\x00')
- if err != nil {
- break
- }
-
- err = s.HandleMessage(&conn, reader, writer, request[:len(request)-1])
- if err != nil {
- // FIXME: report error
- //fmt.Fprintf(os.Stderr, "handleMessage: %v", err)
- break
- }
- }
-
- conn.Close()
-}
-
-func (s *Service) teardown() {
- s.mutex.Lock()
- s.listener = nil
- s.running = false
- s.protocol = ""
- s.address = ""
- s.mutex.Unlock()
-}
-
-func (s *Service) parseAddress(address string) error {
- words := strings.SplitN(address, ":", 2)
- if len(words) != 2 {
- return fmt.Errorf("Unknown protocol")
- }
-
- s.protocol = words[0]
- s.address = words[1]
-
- // Ignore parameters after ';'
- words = strings.SplitN(s.address, ";", 2)
- if words != nil {
- s.address = words[0]
- }
-
- switch s.protocol {
- case "unix":
- break
- case "tcp":
- break
-
- default:
- return fmt.Errorf("Unknown protocol")
- }
-
- return nil
-}
-
-func (s *Service) GetListener() (*net.Listener, error) {
- s.mutex.Lock()
- l := s.listener
- s.mutex.Unlock()
- return &l, nil
-}
-
-func (s *Service) setListener() error {
- l := activationListener()
- if l == nil {
- if s.protocol == "unix" && s.address[0] != '@' {
- os.Remove(s.address)
- }
-
- var err error
- l, err = net.Listen(s.protocol, s.address)
- if err != nil {
- return err
- }
-
- if s.protocol == "unix" && s.address[0] != '@' {
- l.(*net.UnixListener).SetUnlinkOnClose(true)
- }
- }
-
- s.mutex.Lock()
- s.listener = l
- s.mutex.Unlock()
-
- return nil
-}
-
-func (s *Service) refreshTimeout(timeout time.Duration) error {
- switch l := s.listener.(type) {
- case *net.UnixListener:
- if err := l.SetDeadline(time.Now().Add(timeout)); err != nil {
- return err
- }
- case *net.TCPListener:
- if err := l.SetDeadline(time.Now().Add(timeout)); err != nil {
- return err
- }
-
- }
- return nil
-}
-
-// Listen starts a Service.
-func (s *Service) Bind(address string) error {
- s.mutex.Lock()
- if s.running {
- s.mutex.Unlock()
- return fmt.Errorf("Init(): already running")
- }
- s.mutex.Unlock()
-
- s.parseAddress(address)
-
- err := s.setListener()
- if err != nil {
- return err
- }
- return nil
-}
-
-// Listen starts a Service.
-func (s *Service) Listen(address string, timeout time.Duration) error {
- var wg sync.WaitGroup
- defer func() { s.teardown(); wg.Wait() }()
-
- err := s.Bind(address)
- if err != nil {
- return err
- }
-
- s.mutex.Lock()
- s.running = true
- l := s.listener
- s.mutex.Unlock()
-
- for s.running {
- if timeout != 0 {
- if err := s.refreshTimeout(timeout); err != nil {
- return err
- }
- }
- conn, err := l.Accept()
- if err != nil {
- if err.(net.Error).Timeout() {
- s.mutex.Lock()
- if s.conncounter == 0 {
- s.mutex.Unlock()
- return ServiceTimeoutError{}
- }
- s.mutex.Unlock()
- continue
- }
- if !s.running {
- return nil
- }
- return err
- }
- s.mutex.Lock()
- s.conncounter++
- s.mutex.Unlock()
- wg.Add(1)
- go s.handleConnection(conn, &wg)
- }
-
- return nil
-}
-
-// Listen starts a Service.
-func (s *Service) DoListen(timeout time.Duration) error {
- var wg sync.WaitGroup
- defer func() { s.teardown(); wg.Wait() }()
-
- s.mutex.Lock()
- l := s.listener
- s.mutex.Unlock()
-
- if l == nil {
- return fmt.Errorf("No listener set")
- }
-
- s.mutex.Lock()
- s.running = true
- s.mutex.Unlock()
-
- for s.running {
- if timeout != 0 {
- if err := s.refreshTimeout(timeout); err != nil {
- return err
- }
- }
- conn, err := l.Accept()
- if err != nil {
- if err.(net.Error).Timeout() {
- s.mutex.Lock()
- if s.conncounter == 0 {
- s.mutex.Unlock()
- return ServiceTimeoutError{}
- }
- s.mutex.Unlock()
- continue
- }
- if !s.running {
- return nil
- }
- return err
- }
- s.mutex.Lock()
- s.conncounter++
- s.mutex.Unlock()
- wg.Add(1)
- go s.handleConnection(conn, &wg)
- }
-
- return nil
-}
-
-// RegisterInterface registers a varlink.Interface containing struct to the Service
-func (s *Service) RegisterInterface(iface dispatcher) error {
- name := iface.VarlinkGetName()
- if _, ok := s.interfaces[name]; ok {
- return fmt.Errorf("interface '%s' already registered", name)
- }
-
- if s.running {
- return fmt.Errorf("service is already running")
- }
- s.interfaces[name] = iface
- s.descriptions[name] = iface.VarlinkGetDescription()
- s.names = append(s.names, name)
-
- return nil
-}
-
-// NewService creates a new Service which implements the list of given varlink interfaces.
-func NewService(vendor string, product string, version string, url string) (*Service, error) {
- s := Service{
- vendor: vendor,
- product: product,
- version: version,
- url: url,
- interfaces: make(map[string]dispatcher),
- descriptions: make(map[string]string),
- }
- err := s.RegisterInterface(orgvarlinkserviceNew())
-
- return &s, err
-}
diff --git a/vendor/github.com/varlink/go/varlink/socketactivation.go b/vendor/github.com/varlink/go/varlink/socketactivation.go
deleted file mode 100644
index a64c0dc8e..000000000
--- a/vendor/github.com/varlink/go/varlink/socketactivation.go
+++ /dev/null
@@ -1,63 +0,0 @@
-// +build !windows
-
-package varlink
-
-import (
- "net"
- "os"
- "strconv"
- "strings"
- "syscall"
-)
-
-func activationListener() net.Listener {
- pid, err := strconv.Atoi(os.Getenv("LISTEN_PID"))
- if err != nil || pid != os.Getpid() {
- return nil
- }
-
- nfds, err := strconv.Atoi(os.Getenv("LISTEN_FDS"))
- if err != nil || nfds < 1 {
- return nil
- }
-
- fd := -1
-
- // If more than one file descriptor is passed, find the
- // "varlink" tag. The first file descriptor is always 3.
- if nfds > 1 {
- fdnames, set := os.LookupEnv("LISTEN_FDNAMES")
- if !set {
- return nil
- }
-
- names := strings.Split(fdnames, ":")
- if len(names) != nfds {
- return nil
- }
-
- for i, name := range names {
- if name == "varlink" {
- fd = 3 + i
- break
- }
- }
-
- if fd < 0 {
- return nil
- }
-
- } else {
- fd = 3
- }
-
- syscall.CloseOnExec(fd)
-
- file := os.NewFile(uintptr(fd), "varlink")
- listener, err := net.FileListener(file)
- if err != nil {
- return nil
- }
-
- return listener
-}
diff --git a/vendor/github.com/varlink/go/varlink/socketactivation_windows.go b/vendor/github.com/varlink/go/varlink/socketactivation_windows.go
deleted file mode 100644
index fb0894531..000000000
--- a/vendor/github.com/varlink/go/varlink/socketactivation_windows.go
+++ /dev/null
@@ -1,7 +0,0 @@
-package varlink
-
-import "net"
-
-func activationListener() net.Listener {
- return nil
-}
diff --git a/vendor/modules.txt b/vendor/modules.txt
index 674b7a4e4..0c6b4de57 100644
--- a/vendor/modules.txt
+++ b/vendor/modules.txt
@@ -67,7 +67,7 @@ github.com/containernetworking/plugins/pkg/utils/hwaddr
github.com/containernetworking/plugins/pkg/utils/sysctl
github.com/containernetworking/plugins/plugins/ipam/host-local/backend
github.com/containernetworking/plugins/plugins/ipam/host-local/backend/allocator
-# github.com/containers/buildah v1.18.0
+# github.com/containers/buildah v1.18.1-0.20201125084616-dd26b137459c
github.com/containers/buildah
github.com/containers/buildah/bind
github.com/containers/buildah/chroot
@@ -84,9 +84,7 @@ github.com/containers/buildah/pkg/manifests
github.com/containers/buildah/pkg/overlay
github.com/containers/buildah/pkg/parse
github.com/containers/buildah/pkg/rusage
-github.com/containers/buildah/pkg/secrets
github.com/containers/buildah/pkg/supplemented
-github.com/containers/buildah/pkg/umask
github.com/containers/buildah/util
# github.com/containers/common v0.29.0
github.com/containers/common/pkg/apparmor
@@ -100,7 +98,9 @@ github.com/containers/common/pkg/report
github.com/containers/common/pkg/report/camelcase
github.com/containers/common/pkg/retry
github.com/containers/common/pkg/seccomp
+github.com/containers/common/pkg/subscriptions
github.com/containers/common/pkg/sysinfo
+github.com/containers/common/pkg/umask
github.com/containers/common/version
# github.com/containers/conmon v2.0.20+incompatible
github.com/containers/conmon/runner/config
@@ -512,7 +512,7 @@ github.com/seccomp/libseccomp-golang
# github.com/sirupsen/logrus v1.7.0
github.com/sirupsen/logrus
github.com/sirupsen/logrus/hooks/syslog
-# github.com/spf13/cobra v1.1.1 => github.com/Luap99/cobra v1.0.1-0.20201110155035-83a59186c706
+# github.com/spf13/cobra v1.1.1
github.com/spf13/cobra
# github.com/spf13/pflag v1.0.5
github.com/spf13/pflag
@@ -549,10 +549,6 @@ github.com/ulikunitz/xz
github.com/ulikunitz/xz/internal/hash
github.com/ulikunitz/xz/internal/xlog
github.com/ulikunitz/xz/lzma
-# github.com/varlink/go v0.0.0-20190502142041-0f1d566d194b
-github.com/varlink/go/cmd/varlink-go-interface-generator
-github.com/varlink/go/varlink
-github.com/varlink/go/varlink/idl
# github.com/vbatts/tar-split v0.11.1
github.com/vbatts/tar-split/archive/tar
github.com/vbatts/tar-split/tar/asm