From f0c4addbaf314b138ae68a4b205b80cad1ea75fc Mon Sep 17 00:00:00 2001 From: Charlie Drage Date: Tue, 9 May 2017 08:55:55 -0400 Subject: [PATCH 01/12] Use old git command Some versions of git don't have git-url (case in point on Debian 8, no get-url on packaged git). Use old command in getting URL. --- script/test/cmd/tests.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/script/test/cmd/tests.sh b/script/test/cmd/tests.sh index 07aed44c..fca5999d 100755 --- a/script/test/cmd/tests.sh +++ b/script/test/cmd/tests.sh @@ -20,7 +20,7 @@ source $KOMPOSE_ROOT/script/test/cmd/lib.sh # Get current branch and remote url of git repository branch=$(git branch | grep \* | cut -d ' ' -f2-) -uri=$(git remote get-url origin) +uri=$(git config --get remote.origin.url) if [[ $uri != *".git"* ]]; then uri="${uri}.git" fi From 4e051c2cb6d1e83659314124a13f60528e918605 Mon Sep 17 00:00:00 2001 From: Charlie Drage Date: Wed, 10 May 2017 11:05:47 -0400 Subject: [PATCH 02/12] Update version number Updates version number within setup installation instructions for docs --- docs/setup.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/setup.md b/docs/setup.md index 39b8ed28..11bbe2ea 100644 --- a/docs/setup.md +++ b/docs/setup.md @@ -8,13 +8,13 @@ Kompose is released via GitHub on a three-week cycle, you can see all current re ```sh # Linux -curl -L https://github.com/kubernetes-incubator/kompose/releases/download/v0.5.0/kompose-linux-amd64 -o kompose +curl -L https://github.com/kubernetes-incubator/kompose/releases/download/v0.6.0/kompose-linux-amd64 -o kompose # macOS -curl -L https://github.com/kubernetes-incubator/kompose/releases/download/v0.5.0/kompose-darwin-amd64 -o kompose +curl -L https://github.com/kubernetes-incubator/kompose/releases/download/v0.6.0/kompose-darwin-amd64 -o kompose # Windows -curl -L https://github.com/kubernetes-incubator/kompose/releases/download/v0.5.0/kompose-windows-amd64.exe -o kompose.exe +curl -L https://github.com/kubernetes-incubator/kompose/releases/download/v0.6.0/kompose-windows-amd64.exe -o kompose.exe chmod +x kompose sudo mv ./kompose /usr/local/bin/kompose From 7f00fec328290ea0efb55007dfe97cc98f0ba53b Mon Sep 17 00:00:00 2001 From: Suraj Narwade Date: Mon, 15 May 2017 18:28:03 +0530 Subject: [PATCH 03/12] Updated Vendoring It resolves issues #474 and #589 which were coming from libcompose, as well as resolves #440 and #437 partially as `group_add` & `stop_grace_period` are supported by libcompose now. --- glide.lock | 24 +- glide.yaml | 2 +- .../docker/libcompose/config/schema.go | 2 + .../docker/libcompose/config/types.go | 115 +++--- .../docker/libcompose/project/project.go | 9 +- .../docker/libcompose/utils/util.go | 16 + vendor/github.com/hashicorp/hcl/decoder.go | 4 +- .../hashicorp/hcl/hcl/parser/parser.go | 6 + .../mitchellh/mapstructure/decode_hooks.go | 8 +- .../mitchellh/mapstructure/mapstructure.go | 11 +- vendor/github.com/pelletier/go-toml/doc.go | 184 +-------- .../github.com/pelletier/go-toml/marshal.go | 63 +-- vendor/github.com/pelletier/go-toml/match.go | 234 ----------- vendor/github.com/pelletier/go-toml/parser.go | 38 +- vendor/github.com/pelletier/go-toml/query.go | 153 -------- .../pelletier/go-toml/querylexer.go | 356 ----------------- .../pelletier/go-toml/queryparser.go | 275 ------------- vendor/github.com/pelletier/go-toml/toml.go | 106 +++-- .../pelletier/go-toml/tomltree_create.go | 10 +- .../pelletier/go-toml/tomltree_write.go | 24 +- vendor/github.com/pkg/errors/stack.go | 8 + vendor/github.com/spf13/cobra/cobra.go | 19 +- vendor/github.com/spf13/cobra/command.go | 367 ++++++++++-------- .../spf13/jwalterweatherman/notepad.go | 23 +- vendor/github.com/spf13/pflag/count.go | 4 +- vendor/github.com/spf13/pflag/flag.go | 162 ++++---- .../github.com/xeipuuv/gojsonschema/errors.go | 9 + .../github.com/xeipuuv/gojsonschema/schema.go | 4 + .../golang.org/x/sys/unix/asm_solaris_amd64.s | 4 +- vendor/golang.org/x/sys/unix/sockcmsg_unix.go | 9 +- .../x/sys/unix/syscall_dragonfly.go | 33 +- vendor/golang.org/x/sys/unix/syscall_linux.go | 1 + .../x/sys/unix/syscall_linux_mips64x.go | 5 +- .../x/sys/unix/syscall_linux_mipsx.go | 4 +- .../golang.org/x/sys/unix/syscall_solaris.go | 24 +- vendor/golang.org/x/sys/unix/syscall_unix.go | 1 + vendor/golang.org/x/sys/unix/types_solaris.go | 7 + .../x/sys/unix/zerrors_dragonfly_amd64.go | 56 ++- .../x/sys/unix/zerrors_linux_386.go | 23 ++ .../x/sys/unix/zerrors_linux_amd64.go | 23 ++ .../x/sys/unix/zerrors_linux_arm.go | 23 ++ .../x/sys/unix/zerrors_linux_arm64.go | 23 ++ .../x/sys/unix/zerrors_linux_mips.go | 23 ++ .../x/sys/unix/zerrors_linux_mips64.go | 23 ++ .../x/sys/unix/zerrors_linux_mips64le.go | 23 ++ .../x/sys/unix/zerrors_linux_mipsle.go | 23 ++ .../x/sys/unix/zerrors_linux_ppc64.go | 23 ++ .../x/sys/unix/zerrors_linux_ppc64le.go | 23 ++ .../x/sys/unix/zerrors_linux_s390x.go | 23 ++ .../x/sys/unix/zerrors_solaris_amd64.go | 49 ++- .../x/sys/unix/zsyscall_dragonfly_amd64.go | 13 +- .../x/sys/unix/zsyscall_linux_386.go | 11 + .../x/sys/unix/zsyscall_linux_amd64.go | 11 + .../x/sys/unix/zsyscall_linux_arm.go | 11 + .../x/sys/unix/zsyscall_linux_arm64.go | 11 + .../x/sys/unix/zsyscall_linux_mips.go | 11 + .../x/sys/unix/zsyscall_linux_mips64.go | 21 + .../x/sys/unix/zsyscall_linux_mips64le.go | 21 + .../x/sys/unix/zsyscall_linux_mipsle.go | 11 + .../x/sys/unix/zsyscall_linux_ppc64.go | 11 + .../x/sys/unix/zsyscall_linux_ppc64le.go | 11 + .../x/sys/unix/zsyscall_linux_s390x.go | 11 + .../x/sys/unix/zsyscall_linux_sparc64.go | 13 +- .../x/sys/unix/zsyscall_solaris_amd64.go | 101 +++-- .../x/sys/unix/zsysnum_dragonfly_amd64.go | 21 +- .../x/sys/unix/ztypes_dragonfly_amd64.go | 6 +- .../golang.org/x/sys/unix/ztypes_linux_386.go | 14 + .../x/sys/unix/ztypes_linux_amd64.go | 14 + .../golang.org/x/sys/unix/ztypes_linux_arm.go | 14 + .../x/sys/unix/ztypes_linux_arm64.go | 14 + .../x/sys/unix/ztypes_linux_mips.go | 32 +- .../x/sys/unix/ztypes_linux_mips64.go | 32 +- .../x/sys/unix/ztypes_linux_mips64le.go | 32 +- .../x/sys/unix/ztypes_linux_mipsle.go | 32 +- .../x/sys/unix/ztypes_linux_ppc64.go | 14 + .../x/sys/unix/ztypes_linux_ppc64le.go | 14 + .../x/sys/unix/ztypes_linux_s390x.go | 14 + .../x/sys/unix/ztypes_solaris_amd64.go | 23 +- 78 files changed, 1454 insertions(+), 1772 deletions(-) delete mode 100644 vendor/github.com/pelletier/go-toml/match.go delete mode 100644 vendor/github.com/pelletier/go-toml/query.go delete mode 100644 vendor/github.com/pelletier/go-toml/querylexer.go delete mode 100644 vendor/github.com/pelletier/go-toml/queryparser.go diff --git a/glide.lock b/glide.lock index 7fc2af69..948f0622 100644 --- a/glide.lock +++ b/glide.lock @@ -1,5 +1,5 @@ -hash: 12a90ec6d0d5c29da6e19bfe5b4db322154c9d13777ef2c0c2174190ff1c1e79 -updated: 2017-04-21T16:45:28.958337712+05:30 +hash: 3036ae90e1ce5e101dedcf0270bae7f148557cbb7f94e537784bb28650d088bb +updated: 2017-05-15T18:20:57.195406298+05:30 imports: - name: cloud.google.com/go version: 3b1ae45394a234c385be014e9a488f2bb6eef821 @@ -190,7 +190,7 @@ imports: - name: github.com/docker/go-units version: 0bbddae09c5a5419a8c6dcdd7ff90da3d450393b - name: github.com/docker/libcompose - version: c6a7d4679d065a4f50e08d4d1fe13776062cf1ec + version: 01ff8920a57835fda41607e0f27252408e99cf08 subpackages: - config - logger @@ -332,7 +332,7 @@ imports: - runtime/internal - utilities - name: github.com/hashicorp/hcl - version: 7fa7fff964d035e8a162cce3a164b3ad02ad651b + version: 392dba7d905ed5d04a5794ba89f558b27e2ba1ca subpackages: - hcl/ast - hcl/parser @@ -357,7 +357,7 @@ imports: subpackages: - pbutil - name: github.com/mitchellh/mapstructure - version: 53818660ed4955e899c0bcafa97299a388bd7c8e + version: cc8532a8e9a55ea36402aa21efdf403a60d34096 - name: github.com/openshift/origin version: b4e0954faa4a0d11d9c1a536b76ad4a8c0206b7c subpackages: @@ -405,9 +405,9 @@ imports: - name: github.com/pelletier/go-buffruneio version: c37440a7cf42ac63b919c752ca73a85067e05992 - name: github.com/pelletier/go-toml - version: fe206efb84b2bc8e8cfafe6b4c1826622be969e3 + version: 685a1f1cb7a66b9cadbe8f1ac49d9f8f567d6a9d - name: github.com/pkg/errors - version: ff09b135c25aae272398c51a07235b90a75aa4f0 + version: c605e284fe17294bda444b34710735b29d1a9d90 - name: github.com/prometheus/client_golang version: e51041b3fa41cece0dca035740ba6411905be473 subpackages: @@ -433,11 +433,11 @@ imports: - name: github.com/spf13/cast version: acbeb36b902d72a7a4c18e8f3241075e7ab763e4 - name: github.com/spf13/cobra - version: 10f6b9d7e1631a54ad07c5c0fb71c28a1abfd3c2 + version: 4cdb38c072b86bf795d2c81de50784d9fdd6eb77 - name: github.com/spf13/jwalterweatherman - version: fa7ca7e836cf3a8bb4ebf799f472c12d7e903d66 + version: 8f07c835e5cc1450c082fe3a439cf87b0cbb2d99 - name: github.com/spf13/pflag - version: 2300d0f8576fe575f71aaa5b9bbe4e1b0dc2eb51 + version: e57e3eeb33f795204c1ca35f56c44f83227c6e66 - name: github.com/spf13/viper version: 0967fc9aceab2ce9da34061253ac10fb99bba5b2 - name: github.com/ugorji/go @@ -449,7 +449,7 @@ imports: - name: github.com/xeipuuv/gojsonreference version: e02fc20de94c78484cd5ffb007f8af96be030a45 - name: github.com/xeipuuv/gojsonschema - version: 702b404897d4364af44dc8dcabc9815947942325 + version: a55c211c418162597a32c74c7230f81adb5ad616 - name: golang.org/x/net version: e90d6d0afc4c315a0d87a568ae68577cc15149a0 subpackages: @@ -473,7 +473,7 @@ imports: - jws - jwt - name: golang.org/x/sys - version: ea9bcade75cb975a0b9738936568ab388b845617 + version: 1e99a4f9d247b28c670884b9a8d6801f39a47b77 subpackages: - unix - name: golang.org/x/text diff --git a/glide.yaml b/glide.yaml index 6d2e3607..14b3c47b 100644 --- a/glide.yaml +++ b/glide.yaml @@ -14,7 +14,7 @@ import: - package: github.com/pkg/errors - package: github.com/docker/libcompose - version: c6a7d4679d065a4f50e08d4d1fe13776062cf1ec + version: 01ff8920a57835fda41607e0f27252408e99cf08 subpackages: - config - lookup diff --git a/vendor/github.com/docker/libcompose/config/schema.go b/vendor/github.com/docker/libcompose/config/schema.go index 48bd6a5e..672a77f5 100644 --- a/vendor/github.com/docker/libcompose/config/schema.go +++ b/vendor/github.com/docker/libcompose/config/schema.go @@ -281,6 +281,7 @@ var servicesSchemaDataV2 = `{ "external_links": {"type": "array", "items": {"type": "string"}, "uniqueItems": true}, "extra_hosts": {"$ref": "#/definitions/list_or_dict"}, + "group_add": {"type": "array", "items": {"type": "string"}, "uniqueItems": true}, "hostname": {"type": "string"}, "image": {"type": "string"}, "ipc": {"type": "string"}, @@ -347,6 +348,7 @@ var servicesSchemaDataV2 = `{ "security_opt": {"type": "array", "items": {"type": "string"}, "uniqueItems": true}, "shm_size": {"type": ["number", "string"]}, "stdin_open": {"type": "boolean"}, + "stop_grace_period": {"type": "string"}, "stop_signal": {"type": "string"}, "tmpfs": {"$ref": "#/definitions/string_or_list"}, "tty": {"type": "boolean"}, diff --git a/vendor/github.com/docker/libcompose/config/types.go b/vendor/github.com/docker/libcompose/config/types.go index 7a370058..9e4c9dfc 100644 --- a/vendor/github.com/docker/libcompose/config/types.go +++ b/vendor/github.com/docker/libcompose/config/types.go @@ -85,63 +85,64 @@ type Log struct { // ServiceConfig holds version 2 of libcompose service configuration type ServiceConfig struct { - Build yaml.Build `yaml:"build,omitempty"` - CapAdd []string `yaml:"cap_add,omitempty"` - CapDrop []string `yaml:"cap_drop,omitempty"` - CPUSet string `yaml:"cpuset,omitempty"` - CPUShares yaml.StringorInt `yaml:"cpu_shares,omitempty"` - CPUQuota yaml.StringorInt `yaml:"cpu_quota,omitempty"` - Command yaml.Command `yaml:"command,flow,omitempty"` - CgroupParent string `yaml:"cgroup_parent,omitempty"` - ContainerName string `yaml:"container_name,omitempty"` - Devices []string `yaml:"devices,omitempty"` - DependsOn []string `yaml:"depends_on,omitempty"` - DNS yaml.Stringorslice `yaml:"dns,omitempty"` - DNSOpts []string `yaml:"dns_opt,omitempty"` - DNSSearch yaml.Stringorslice `yaml:"dns_search,omitempty"` - DomainName string `yaml:"domainname,omitempty"` - Entrypoint yaml.Command `yaml:"entrypoint,flow,omitempty"` - EnvFile yaml.Stringorslice `yaml:"env_file,omitempty"` - Environment yaml.MaporEqualSlice `yaml:"environment,omitempty"` - Expose []string `yaml:"expose,omitempty"` - Extends yaml.MaporEqualSlice `yaml:"extends,omitempty"` - ExternalLinks []string `yaml:"external_links,omitempty"` - ExtraHosts []string `yaml:"extra_hosts,omitempty"` - GroupAdd []string `yaml:"group_add,omitempty"` - Image string `yaml:"image,omitempty"` - Isolation string `yaml:"isolation,omitempty"` - Hostname string `yaml:"hostname,omitempty"` - Ipc string `yaml:"ipc,omitempty"` - Labels yaml.SliceorMap `yaml:"labels,omitempty"` - Links yaml.MaporColonSlice `yaml:"links,omitempty"` - Logging Log `yaml:"logging,omitempty"` - MacAddress string `yaml:"mac_address,omitempty"` - MemLimit yaml.MemStringorInt `yaml:"mem_limit,omitempty"` - MemReservation yaml.MemStringorInt `yaml:"mem_reservation,omitempty"` - MemSwapLimit yaml.MemStringorInt `yaml:"memswap_limit,omitempty"` - MemSwappiness yaml.MemStringorInt `yaml:"mem_swappiness,omitempty"` - NetworkMode string `yaml:"network_mode,omitempty"` - Networks *yaml.Networks `yaml:"networks,omitempty"` - OomKillDisable bool `yaml:"oom_kill_disable,omitempty"` - OomScoreAdj yaml.StringorInt `yaml:"oom_score_adj,omitempty"` - Pid string `yaml:"pid,omitempty"` - Ports []string `yaml:"ports,omitempty"` - Privileged bool `yaml:"privileged,omitempty"` - SecurityOpt []string `yaml:"security_opt,omitempty"` - ShmSize yaml.MemStringorInt `yaml:"shm_size,omitempty"` - StopSignal string `yaml:"stop_signal,omitempty"` - Tmpfs yaml.Stringorslice `yaml:"tmpfs,omitempty"` - VolumeDriver string `yaml:"volume_driver,omitempty"` - Volumes *yaml.Volumes `yaml:"volumes,omitempty"` - VolumesFrom []string `yaml:"volumes_from,omitempty"` - Uts string `yaml:"uts,omitempty"` - Restart string `yaml:"restart,omitempty"` - ReadOnly bool `yaml:"read_only,omitempty"` - StdinOpen bool `yaml:"stdin_open,omitempty"` - Tty bool `yaml:"tty,omitempty"` - User string `yaml:"user,omitempty"` - WorkingDir string `yaml:"working_dir,omitempty"` - Ulimits yaml.Ulimits `yaml:"ulimits,omitempty"` + Build yaml.Build `yaml:"build,omitempty"` + CapAdd []string `yaml:"cap_add,omitempty"` + CapDrop []string `yaml:"cap_drop,omitempty"` + CPUSet string `yaml:"cpuset,omitempty"` + CPUShares yaml.StringorInt `yaml:"cpu_shares,omitempty"` + CPUQuota yaml.StringorInt `yaml:"cpu_quota,omitempty"` + Command yaml.Command `yaml:"command,flow,omitempty"` + CgroupParent string `yaml:"cgroup_parent,omitempty"` + ContainerName string `yaml:"container_name,omitempty"` + Devices []string `yaml:"devices,omitempty"` + DependsOn []string `yaml:"depends_on,omitempty"` + DNS yaml.Stringorslice `yaml:"dns,omitempty"` + DNSOpts []string `yaml:"dns_opt,omitempty"` + DNSSearch yaml.Stringorslice `yaml:"dns_search,omitempty"` + DomainName string `yaml:"domainname,omitempty"` + Entrypoint yaml.Command `yaml:"entrypoint,flow,omitempty"` + EnvFile yaml.Stringorslice `yaml:"env_file,omitempty"` + Environment yaml.MaporEqualSlice `yaml:"environment,omitempty"` + Expose []string `yaml:"expose,omitempty"` + Extends yaml.MaporEqualSlice `yaml:"extends,omitempty"` + ExternalLinks []string `yaml:"external_links,omitempty"` + ExtraHosts []string `yaml:"extra_hosts,omitempty"` + GroupAdd []string `yaml:"group_add,omitempty"` + Image string `yaml:"image,omitempty"` + Isolation string `yaml:"isolation,omitempty"` + Hostname string `yaml:"hostname,omitempty"` + Ipc string `yaml:"ipc,omitempty"` + Labels yaml.SliceorMap `yaml:"labels,omitempty"` + Links yaml.MaporColonSlice `yaml:"links,omitempty"` + Logging Log `yaml:"logging,omitempty"` + MacAddress string `yaml:"mac_address,omitempty"` + MemLimit yaml.MemStringorInt `yaml:"mem_limit,omitempty"` + MemReservation yaml.MemStringorInt `yaml:"mem_reservation,omitempty"` + MemSwapLimit yaml.MemStringorInt `yaml:"memswap_limit,omitempty"` + MemSwappiness yaml.MemStringorInt `yaml:"mem_swappiness,omitempty"` + NetworkMode string `yaml:"network_mode,omitempty"` + Networks *yaml.Networks `yaml:"networks,omitempty"` + OomKillDisable bool `yaml:"oom_kill_disable,omitempty"` + OomScoreAdj yaml.StringorInt `yaml:"oom_score_adj,omitempty"` + Pid string `yaml:"pid,omitempty"` + Ports []string `yaml:"ports,omitempty"` + Privileged bool `yaml:"privileged,omitempty"` + SecurityOpt []string `yaml:"security_opt,omitempty"` + ShmSize yaml.MemStringorInt `yaml:"shm_size,omitempty"` + StopGracePeriod string `yaml:"stop_grace_period,omitempty"` + StopSignal string `yaml:"stop_signal,omitempty"` + Tmpfs yaml.Stringorslice `yaml:"tmpfs,omitempty"` + VolumeDriver string `yaml:"volume_driver,omitempty"` + Volumes *yaml.Volumes `yaml:"volumes,omitempty"` + VolumesFrom []string `yaml:"volumes_from,omitempty"` + Uts string `yaml:"uts,omitempty"` + Restart string `yaml:"restart,omitempty"` + ReadOnly bool `yaml:"read_only,omitempty"` + StdinOpen bool `yaml:"stdin_open,omitempty"` + Tty bool `yaml:"tty,omitempty"` + User string `yaml:"user,omitempty"` + WorkingDir string `yaml:"working_dir,omitempty"` + Ulimits yaml.Ulimits `yaml:"ulimits,omitempty"` } // VolumeConfig holds v2 volume configuration diff --git a/vendor/github.com/docker/libcompose/project/project.go b/vendor/github.com/docker/libcompose/project/project.go index ef783120..df828929 100644 --- a/vendor/github.com/docker/libcompose/project/project.go +++ b/vendor/github.com/docker/libcompose/project/project.go @@ -288,7 +288,8 @@ func (p *Project) handleNetworkConfig() { // Consolidate the name of the network // FIXME(vdemeester) probably shouldn't be there, maybe move that to interface/factory for _, network := range serviceConfig.Networks.Networks { - if net, ok := p.NetworkConfigs[network.Name]; ok { + net, ok := p.NetworkConfigs[network.Name] + if ok && net != nil { if net.External.External { network.RealName = network.Name if net.External.Name != "" { @@ -297,6 +298,12 @@ func (p *Project) handleNetworkConfig() { } else { network.RealName = p.Name + "_" + network.Name } + } else { + network.RealName = p.Name + "_" + network.Name + + p.NetworkConfigs[network.Name] = &config.NetworkConfig{ + External: yaml.External{External: false}, + } } // Ignoring if we don't find the network, it will be catched later } diff --git a/vendor/github.com/docker/libcompose/utils/util.go b/vendor/github.com/docker/libcompose/utils/util.go index 971f9433..daad7317 100644 --- a/vendor/github.com/docker/libcompose/utils/util.go +++ b/vendor/github.com/docker/libcompose/utils/util.go @@ -3,6 +3,7 @@ package utils import ( "encoding/json" "sync" + "time" "github.com/Sirupsen/logrus" @@ -160,3 +161,18 @@ func ConvertKeysToStrings(item interface{}) interface{} { return item } } + +// DurationStrToSecondsInt converts duration string to *int in seconds +func DurationStrToSecondsInt(s string) *int { + if s == "" { + return nil + } + duration, err := time.ParseDuration(s) + if err != nil { + logrus.Errorf("Failed to parse duration:%v", s) + return nil + } + r := (int)(duration.Seconds()) + return &r + +} diff --git a/vendor/github.com/hashicorp/hcl/decoder.go b/vendor/github.com/hashicorp/hcl/decoder.go index 0b39c1b9..6e75ece8 100644 --- a/vendor/github.com/hashicorp/hcl/decoder.go +++ b/vendor/github.com/hashicorp/hcl/decoder.go @@ -89,7 +89,7 @@ func (d *decoder) decode(name string, node ast.Node, result reflect.Value) error switch k.Kind() { case reflect.Bool: return d.decodeBool(name, node, result) - case reflect.Float64: + case reflect.Float32, reflect.Float64: return d.decodeFloat(name, node, result) case reflect.Int, reflect.Int32, reflect.Int64: return d.decodeInt(name, node, result) @@ -143,7 +143,7 @@ func (d *decoder) decodeFloat(name string, node ast.Node, result reflect.Value) return err } - result.Set(reflect.ValueOf(v)) + result.Set(reflect.ValueOf(v).Convert(result.Type())) return nil } } diff --git a/vendor/github.com/hashicorp/hcl/hcl/parser/parser.go b/vendor/github.com/hashicorp/hcl/hcl/parser/parser.go index 6e54bed9..b4881806 100644 --- a/vendor/github.com/hashicorp/hcl/hcl/parser/parser.go +++ b/vendor/github.com/hashicorp/hcl/hcl/parser/parser.go @@ -3,6 +3,7 @@ package parser import ( + "bytes" "errors" "fmt" "strings" @@ -36,6 +37,11 @@ func newParser(src []byte) *Parser { // Parse returns the fully parsed source and returns the abstract syntax tree. func Parse(src []byte) (*ast.File, error) { + // normalize all line endings + // since the scanner and output only work with "\n" line endings, we may + // end up with dangling "\r" characters in the parsed data. + src = bytes.Replace(src, []byte("\r\n"), []byte("\n"), -1) + p := newParser(src) return p.Parse() } diff --git a/vendor/github.com/mitchellh/mapstructure/decode_hooks.go b/vendor/github.com/mitchellh/mapstructure/decode_hooks.go index 115ae67c..acdaadef 100644 --- a/vendor/github.com/mitchellh/mapstructure/decode_hooks.go +++ b/vendor/github.com/mitchellh/mapstructure/decode_hooks.go @@ -121,6 +121,11 @@ func StringToTimeDurationHookFunc() DecodeHookFunc { } } +// WeaklyTypedHook is a DecodeHookFunc which adds support for weak typing to +// the decoder. +// +// Note that this is significantly different from the WeaklyTypedInput option +// of the DecoderConfig. func WeaklyTypedHook( f reflect.Kind, t reflect.Kind, @@ -132,9 +137,8 @@ func WeaklyTypedHook( case reflect.Bool: if dataVal.Bool() { return "1", nil - } else { - return "0", nil } + return "0", nil case reflect.Float32: return strconv.FormatFloat(dataVal.Float(), 'f', -1, 64), nil case reflect.Int: diff --git a/vendor/github.com/mitchellh/mapstructure/mapstructure.go b/vendor/github.com/mitchellh/mapstructure/mapstructure.go index 6dee0ef0..6ec5c333 100644 --- a/vendor/github.com/mitchellh/mapstructure/mapstructure.go +++ b/vendor/github.com/mitchellh/mapstructure/mapstructure.go @@ -1,5 +1,5 @@ -// The mapstructure package exposes functionality to convert an -// arbitrary map[string]interface{} into a native Go structure. +// Package mapstructure exposes functionality to convert an arbitrary +// map[string]interface{} into a native Go structure. // // The Go structure can be arbitrarily complex, containing slices, // other structs, etc. and the decoder will properly decode nested @@ -32,7 +32,12 @@ import ( // both. type DecodeHookFunc interface{} +// DecodeHookFuncType is a DecodeHookFunc which has complete information about +// the source and target types. type DecodeHookFuncType func(reflect.Type, reflect.Type, interface{}) (interface{}, error) + +// DecodeHookFuncKind is a DecodeHookFunc which knows only the Kinds of the +// source and target types. type DecodeHookFuncKind func(reflect.Kind, reflect.Kind, interface{}) (interface{}, error) // DecoderConfig is the configuration that is used to create a new decoder @@ -436,7 +441,7 @@ func (d *Decoder) decodeFloat(name string, data interface{}, val reflect.Value) case dataKind == reflect.Uint: val.SetFloat(float64(dataVal.Uint())) case dataKind == reflect.Float32: - val.SetFloat(float64(dataVal.Float())) + val.SetFloat(dataVal.Float()) case dataKind == reflect.Bool && d.config.WeaklyTypedInput: if dataVal.Bool() { val.SetFloat(1) diff --git a/vendor/github.com/pelletier/go-toml/doc.go b/vendor/github.com/pelletier/go-toml/doc.go index 9156b736..cfa5e4ab 100644 --- a/vendor/github.com/pelletier/go-toml/doc.go +++ b/vendor/github.com/pelletier/go-toml/doc.go @@ -13,14 +13,14 @@ // // load TOML data stored in a string // tree, err := toml.Load(stringContainingTomlData) // -// Either way, the result is a TomlTree object that can be used to navigate the +// Either way, the result is a Tree object that can be used to navigate the // structure and data within the original document. // // -// Getting data from the TomlTree +// Getting data from the Tree // // After parsing TOML data with Load() or LoadFile(), use the Has() and Get() -// methods on the returned TomlTree, to find your way through the document data. +// methods on the returned Tree, to find your way through the document data. // // if tree.Has("foo") { // fmt.Println("foo is:", tree.Get("foo")) @@ -50,11 +50,11 @@ // tree.GetPath([]string{"foo","bar","baz"}) // // Note that this is distinct from the heavyweight query syntax supported by -// TomlTree.Query() and the Query() struct (see below). +// Tree.Query() and the Query() struct (see below). // // Position Support // -// Each element within the TomlTree is stored with position metadata, which is +// Each element within the Tree is stored with position metadata, which is // invaluable for providing semantic feedback to a user. This helps in // situations where the TOML file parses correctly, but contains data that is // not correct for the application. In such cases, an error message can be @@ -75,176 +75,10 @@ // return fmt.Errorf("%v: Expected 'bar' element", tree.GetPosition("")) // } // -// Query Support +// JSONPath-like queries // -// The TOML query path implementation is based loosely on the JSONPath specification: -// http://goessner.net/articles/JsonPath/ -// -// The idea behind a query path is to allow quick access to any element, or set -// of elements within TOML document, with a single expression. -// -// result, err := tree.Query("$.foo.bar.baz") -// -// This is roughly equivalent to: -// -// next := tree.Get("foo") -// if next != nil { -// next = next.Get("bar") -// if next != nil { -// next = next.Get("baz") -// } -// } -// result := next -// -// err is nil if any parsing exception occurs. -// -// If no node in the tree matches the query, result will simply contain an empty list of -// items. -// -// As illustrated above, the query path is much more efficient, especially since -// the structure of the TOML file can vary. Rather than making assumptions about -// a document's structure, a query allows the programmer to make structured -// requests into the document, and get zero or more values as a result. -// -// The syntax of a query begins with a root token, followed by any number -// sub-expressions: -// -// $ -// Root of the TOML tree. This must always come first. -// .name -// Selects child of this node, where 'name' is a TOML key -// name. -// ['name'] -// Selects child of this node, where 'name' is a string -// containing a TOML key name. -// [index] -// Selcts child array element at 'index'. -// ..expr -// Recursively selects all children, filtered by an a union, -// index, or slice expression. -// ..* -// Recursive selection of all nodes at this point in the -// tree. -// .* -// Selects all children of the current node. -// [expr,expr] -// Union operator - a logical 'or' grouping of two or more -// sub-expressions: index, key name, or filter. -// [start:end:step] -// Slice operator - selects array elements from start to -// end-1, at the given step. All three arguments are -// optional. -// [?(filter)] -// Named filter expression - the function 'filter' is -// used to filter children at this node. -// -// Query Indexes And Slices -// -// Index expressions perform no bounds checking, and will contribute no -// values to the result set if the provided index or index range is invalid. -// Negative indexes represent values from the end of the array, counting backwards. -// -// // select the last index of the array named 'foo' -// tree.Query("$.foo[-1]") -// -// Slice expressions are supported, by using ':' to separate a start/end index pair. -// -// // select up to the first five elements in the array -// tree.Query("$.foo[0:5]") -// -// Slice expressions also allow negative indexes for the start and stop -// arguments. -// -// // select all array elements. -// tree.Query("$.foo[0:-1]") -// -// Slice expressions may have an optional stride/step parameter: -// -// // select every other element -// tree.Query("$.foo[0:-1:2]") -// -// Slice start and end parameters are also optional: -// -// // these are all equivalent and select all the values in the array -// tree.Query("$.foo[:]") -// tree.Query("$.foo[0:]") -// tree.Query("$.foo[:-1]") -// tree.Query("$.foo[0:-1:]") -// tree.Query("$.foo[::1]") -// tree.Query("$.foo[0::1]") -// tree.Query("$.foo[:-1:1]") -// tree.Query("$.foo[0:-1:1]") -// -// Query Filters -// -// Query filters are used within a Union [,] or single Filter [] expression. -// A filter only allows nodes that qualify through to the next expression, -// and/or into the result set. -// -// // returns children of foo that are permitted by the 'bar' filter. -// tree.Query("$.foo[?(bar)]") -// -// There are several filters provided with the library: -// -// tree -// Allows nodes of type TomlTree. -// int -// Allows nodes of type int64. -// float -// Allows nodes of type float64. -// string -// Allows nodes of type string. -// time -// Allows nodes of type time.Time. -// bool -// Allows nodes of type bool. -// -// Query Results -// -// An executed query returns a QueryResult object. This contains the nodes -// in the TOML tree that qualify the query expression. Position information -// is also available for each value in the set. -// -// // display the results of a query -// results := tree.Query("$.foo.bar.baz") -// for idx, value := results.Values() { -// fmt.Println("%v: %v", results.Positions()[idx], value) -// } -// -// Compiled Queries -// -// Queries may be executed directly on a TomlTree object, or compiled ahead -// of time and executed discretely. The former is more convienent, but has the -// penalty of having to recompile the query expression each time. -// -// // basic query -// results := tree.Query("$.foo.bar.baz") -// -// // compiled query -// query := toml.CompileQuery("$.foo.bar.baz") -// results := query.Execute(tree) -// -// // run the compiled query again on a different tree -// moreResults := query.Execute(anotherTree) -// -// User Defined Query Filters -// -// Filter expressions may also be user defined by using the SetFilter() -// function on the Query object. The function must return true/false, which -// signifies if the passed node is kept or discarded, respectively. -// -// // create a query that references a user-defined filter -// query, _ := CompileQuery("$[?(bazOnly)]") -// -// // define the filter, and assign it to the query -// query.SetFilter("bazOnly", func(node interface{}) bool{ -// if tree, ok := node.(*TomlTree); ok { -// return tree.Has("baz") -// } -// return false // reject all other node types -// }) -// -// // run the query -// query.Execute(tree) +// The package github.com/pelletier/go-toml/query implements a system +// similar to JSONPath to quickly retrive elements of a TOML document using a +// single expression. See the package documentation for more information. // package toml diff --git a/vendor/github.com/pelletier/go-toml/marshal.go b/vendor/github.com/pelletier/go-toml/marshal.go index a1d70104..358425ae 100644 --- a/vendor/github.com/pelletier/go-toml/marshal.go +++ b/vendor/github.com/pelletier/go-toml/marshal.go @@ -1,6 +1,7 @@ package toml import ( + "bytes" "errors" "fmt" "reflect" @@ -9,14 +10,14 @@ import ( ) /* -TomlTree structural types and corresponding marshal types +Tree structural types and corresponding marshal types ------------------------------------------------------------------------------- -*TomlTree (*)struct, (*)map[string]interface{} -[]*TomlTree (*)[](*)struct, (*)[](*)map[string]interface{} +*Tree (*)struct, (*)map[string]interface{} +[]*Tree (*)[](*)struct, (*)[](*)map[string]interface{} []interface{} (as interface{}) (*)[]primitive, (*)[]([]interface{}) interface{} (*)primitive -TomlTree primitive types and corresponding marshal types +Tree primitive types and corresponding marshal types ----------------------------------------------------------- uint64 uint, uint8-uint64, pointers to same int64 int, int8-uint64, pointers to same @@ -35,7 +36,7 @@ type tomlOpts struct { var timeType = reflect.TypeOf(time.Time{}) var marshalerType = reflect.TypeOf(new(Marshaler)).Elem() -// Check if the given marshall type maps to a TomlTree primitive +// Check if the given marshall type maps to a Tree primitive func isPrimitive(mtype reflect.Type) bool { switch mtype.Kind() { case reflect.Ptr: @@ -57,7 +58,7 @@ func isPrimitive(mtype reflect.Type) bool { } } -// Check if the given marshall type maps to a TomlTree slice +// Check if the given marshall type maps to a Tree slice func isTreeSlice(mtype reflect.Type) bool { switch mtype.Kind() { case reflect.Slice: @@ -67,7 +68,7 @@ func isTreeSlice(mtype reflect.Type) bool { } } -// Check if the given marshall type maps to a non-TomlTree slice +// Check if the given marshall type maps to a non-Tree slice func isOtherSlice(mtype reflect.Type) bool { switch mtype.Kind() { case reflect.Ptr: @@ -79,7 +80,7 @@ func isOtherSlice(mtype reflect.Type) bool { } } -// Check if the given marshall type maps to a TomlTree +// Check if the given marshall type maps to a Tree func isTree(mtype reflect.Type) bool { switch mtype.Kind() { case reflect.Map: @@ -133,11 +134,11 @@ func Marshal(v interface{}) ([]byte, error) { } // Convert given marshal struct or map value to toml tree -func valueToTree(mtype reflect.Type, mval reflect.Value) (*TomlTree, error) { +func valueToTree(mtype reflect.Type, mval reflect.Value) (*Tree, error) { if mtype.Kind() == reflect.Ptr { return valueToTree(mtype.Elem(), mval.Elem()) } - tval := newTomlTree() + tval := newTree() switch mtype.Kind() { case reflect.Struct: for i := 0; i < mtype.NumField(); i++ { @@ -165,8 +166,8 @@ func valueToTree(mtype reflect.Type, mval reflect.Value) (*TomlTree, error) { } // Convert given marshal slice to slice of Toml trees -func valueToTreeSlice(mtype reflect.Type, mval reflect.Value) ([]*TomlTree, error) { - tval := make([]*TomlTree, mval.Len(), mval.Len()) +func valueToTreeSlice(mtype reflect.Type, mval reflect.Value) ([]*Tree, error) { + tval := make([]*Tree, mval.Len(), mval.Len()) for i := 0; i < mval.Len(); i++ { val, err := valueToTree(mtype.Elem(), mval.Index(i)) if err != nil { @@ -224,24 +225,15 @@ func valueToToml(mtype reflect.Type, mval reflect.Value) (interface{}, error) { } } -/* -Unmarshal parses the TOML-encoded data and stores the result in the value -pointed to by v. Behavior is similar to the Go json encoder, except that there -is no concept of an Unmarshaler interface or UnmarshalTOML function for -sub-structs, and currently only definite types can be unmarshaled to (i.e. no -`interface{}`). -*/ -func Unmarshal(data []byte, v interface{}) error { +// Unmarshal attempts to unmarshal the Tree into a Go struct pointed by v. +// Neither Unmarshaler interfaces nor UnmarshalTOML functions are supported for +// sub-structs, and only definite types can be unmarshaled. +func (t *Tree) Unmarshal(v interface{}) error { mtype := reflect.TypeOf(v) if mtype.Kind() != reflect.Ptr || mtype.Elem().Kind() != reflect.Struct { return errors.New("Only a pointer to struct can be unmarshaled from TOML") } - t, err := Load(string(data)) - if err != nil { - return err - } - sval, err := valueFromTree(mtype.Elem(), t) if err != nil { return err @@ -250,8 +242,21 @@ func Unmarshal(data []byte, v interface{}) error { return nil } +// Unmarshal parses the TOML-encoded data and stores the result in the value +// pointed to by v. Behavior is similar to the Go json encoder, except that there +// is no concept of an Unmarshaler interface or UnmarshalTOML function for +// sub-structs, and currently only definite types can be unmarshaled to (i.e. no +// `interface{}`). +func Unmarshal(data []byte, v interface{}) error { + t, err := LoadReader(bytes.NewReader(data)) + if err != nil { + return err + } + return t.Unmarshal(v) +} + // Convert toml tree to marshal struct or map, using marshal type -func valueFromTree(mtype reflect.Type, tval *TomlTree) (reflect.Value, error) { +func valueFromTree(mtype reflect.Type, tval *Tree) (reflect.Value, error) { if mtype.Kind() == reflect.Ptr { return unwrapPointer(mtype, tval) } @@ -290,7 +295,7 @@ func valueFromTree(mtype reflect.Type, tval *TomlTree) (reflect.Value, error) { } // Convert toml value to marshal struct/map slice, using marshal type -func valueFromTreeSlice(mtype reflect.Type, tval []*TomlTree) (reflect.Value, error) { +func valueFromTreeSlice(mtype reflect.Type, tval []*Tree) (reflect.Value, error) { mval := reflect.MakeSlice(mtype, len(tval), len(tval)) for i := 0; i < len(tval); i++ { val, err := valueFromTree(mtype.Elem(), tval[i]) @@ -322,9 +327,9 @@ func valueFromToml(mtype reflect.Type, tval interface{}) (reflect.Value, error) } switch { case isTree(mtype): - return valueFromTree(mtype, tval.(*TomlTree)) + return valueFromTree(mtype, tval.(*Tree)) case isTreeSlice(mtype): - return valueFromTreeSlice(mtype, tval.([]*TomlTree)) + return valueFromTreeSlice(mtype, tval.([]*Tree)) case isOtherSlice(mtype): return valueFromOtherSlice(mtype, tval.([]interface{})) default: diff --git a/vendor/github.com/pelletier/go-toml/match.go b/vendor/github.com/pelletier/go-toml/match.go deleted file mode 100644 index 48b0f2a1..00000000 --- a/vendor/github.com/pelletier/go-toml/match.go +++ /dev/null @@ -1,234 +0,0 @@ -package toml - -import ( - "fmt" -) - -// support function to set positions for tomlValues -// NOTE: this is done to allow ctx.lastPosition to indicate the start of any -// values returned by the query engines -func tomlValueCheck(node interface{}, ctx *queryContext) interface{} { - switch castNode := node.(type) { - case *tomlValue: - ctx.lastPosition = castNode.position - return castNode.value - case []*TomlTree: - if len(castNode) > 0 { - ctx.lastPosition = castNode[0].position - } - return node - default: - return node - } -} - -// base match -type matchBase struct { - next pathFn -} - -func (f *matchBase) setNext(next pathFn) { - f.next = next -} - -// terminating functor - gathers results -type terminatingFn struct { - // empty -} - -func newTerminatingFn() *terminatingFn { - return &terminatingFn{} -} - -func (f *terminatingFn) setNext(next pathFn) { - // do nothing -} - -func (f *terminatingFn) call(node interface{}, ctx *queryContext) { - switch castNode := node.(type) { - case *TomlTree: - ctx.result.appendResult(node, castNode.position) - case *tomlValue: - ctx.result.appendResult(node, castNode.position) - default: - // use last position for scalars - ctx.result.appendResult(node, ctx.lastPosition) - } -} - -// match single key -type matchKeyFn struct { - matchBase - Name string -} - -func newMatchKeyFn(name string) *matchKeyFn { - return &matchKeyFn{Name: name} -} - -func (f *matchKeyFn) call(node interface{}, ctx *queryContext) { - if array, ok := node.([]*TomlTree); ok { - for _, tree := range array { - item := tree.values[f.Name] - if item != nil { - f.next.call(item, ctx) - } - } - } else if tree, ok := node.(*TomlTree); ok { - item := tree.values[f.Name] - if item != nil { - f.next.call(item, ctx) - } - } -} - -// match single index -type matchIndexFn struct { - matchBase - Idx int -} - -func newMatchIndexFn(idx int) *matchIndexFn { - return &matchIndexFn{Idx: idx} -} - -func (f *matchIndexFn) call(node interface{}, ctx *queryContext) { - if arr, ok := tomlValueCheck(node, ctx).([]interface{}); ok { - if f.Idx < len(arr) && f.Idx >= 0 { - f.next.call(arr[f.Idx], ctx) - } - } -} - -// filter by slicing -type matchSliceFn struct { - matchBase - Start, End, Step int -} - -func newMatchSliceFn(start, end, step int) *matchSliceFn { - return &matchSliceFn{Start: start, End: end, Step: step} -} - -func (f *matchSliceFn) call(node interface{}, ctx *queryContext) { - if arr, ok := tomlValueCheck(node, ctx).([]interface{}); ok { - // adjust indexes for negative values, reverse ordering - realStart, realEnd := f.Start, f.End - if realStart < 0 { - realStart = len(arr) + realStart - } - if realEnd < 0 { - realEnd = len(arr) + realEnd - } - if realEnd < realStart { - realEnd, realStart = realStart, realEnd // swap - } - // loop and gather - for idx := realStart; idx < realEnd; idx += f.Step { - f.next.call(arr[idx], ctx) - } - } -} - -// match anything -type matchAnyFn struct { - matchBase -} - -func newMatchAnyFn() *matchAnyFn { - return &matchAnyFn{} -} - -func (f *matchAnyFn) call(node interface{}, ctx *queryContext) { - if tree, ok := node.(*TomlTree); ok { - for _, v := range tree.values { - f.next.call(v, ctx) - } - } -} - -// filter through union -type matchUnionFn struct { - Union []pathFn -} - -func (f *matchUnionFn) setNext(next pathFn) { - for _, fn := range f.Union { - fn.setNext(next) - } -} - -func (f *matchUnionFn) call(node interface{}, ctx *queryContext) { - for _, fn := range f.Union { - fn.call(node, ctx) - } -} - -// match every single last node in the tree -type matchRecursiveFn struct { - matchBase -} - -func newMatchRecursiveFn() *matchRecursiveFn { - return &matchRecursiveFn{} -} - -func (f *matchRecursiveFn) call(node interface{}, ctx *queryContext) { - if tree, ok := node.(*TomlTree); ok { - var visit func(tree *TomlTree) - visit = func(tree *TomlTree) { - for _, v := range tree.values { - f.next.call(v, ctx) - switch node := v.(type) { - case *TomlTree: - visit(node) - case []*TomlTree: - for _, subtree := range node { - visit(subtree) - } - } - } - } - f.next.call(tree, ctx) - visit(tree) - } -} - -// match based on an externally provided functional filter -type matchFilterFn struct { - matchBase - Pos Position - Name string -} - -func newMatchFilterFn(name string, pos Position) *matchFilterFn { - return &matchFilterFn{Name: name, Pos: pos} -} - -func (f *matchFilterFn) call(node interface{}, ctx *queryContext) { - fn, ok := (*ctx.filters)[f.Name] - if !ok { - panic(fmt.Sprintf("%s: query context does not have filter '%s'", - f.Pos.String(), f.Name)) - } - switch castNode := tomlValueCheck(node, ctx).(type) { - case *TomlTree: - for _, v := range castNode.values { - if tv, ok := v.(*tomlValue); ok { - if fn(tv.value) { - f.next.call(v, ctx) - } - } else { - if fn(v) { - f.next.call(v, ctx) - } - } - } - case []interface{}: - for _, v := range castNode { - if fn(v) { - f.next.call(v, ctx) - } - } - } -} diff --git a/vendor/github.com/pelletier/go-toml/parser.go b/vendor/github.com/pelletier/go-toml/parser.go index 20e90a3e..64eb0e58 100644 --- a/vendor/github.com/pelletier/go-toml/parser.go +++ b/vendor/github.com/pelletier/go-toml/parser.go @@ -14,7 +14,7 @@ import ( type tomlParser struct { flow chan token - tree *TomlTree + tree *Tree tokensBuffer []token currentTable []string seenTableKeys []string @@ -106,18 +106,18 @@ func (p *tomlParser) parseGroupArray() tomlParserStateFn { } p.tree.createSubTree(keys[:len(keys)-1], startToken.Position) // create parent entries destTree := p.tree.GetPath(keys) - var array []*TomlTree + var array []*Tree if destTree == nil { - array = make([]*TomlTree, 0) - } else if target, ok := destTree.([]*TomlTree); ok && target != nil { - array = destTree.([]*TomlTree) + array = make([]*Tree, 0) + } else if target, ok := destTree.([]*Tree); ok && target != nil { + array = destTree.([]*Tree) } else { p.raiseError(key, "key %s is already assigned and not of type table array", key) } p.currentTable = keys // add a new tree to the end of the table array - newTree := newTomlTree() + newTree := newTree() newTree.position = startToken.Position array = append(array, newTree) p.tree.SetPath(p.currentTable, array) @@ -183,11 +183,11 @@ func (p *tomlParser) parseAssign() tomlParserStateFn { } // find the table to assign, looking out for arrays of tables - var targetNode *TomlTree + var targetNode *Tree switch node := p.tree.GetPath(tableKey).(type) { - case []*TomlTree: + case []*Tree: targetNode = node[len(node)-1] - case *TomlTree: + case *Tree: targetNode = node default: p.raiseError(key, "Unknown table type for path: %s", @@ -212,7 +212,7 @@ func (p *tomlParser) parseAssign() tomlParserStateFn { var toInsert interface{} switch value.(type) { - case *TomlTree, []*TomlTree: + case *Tree, []*Tree: toInsert = value default: toInsert = &tomlValue{value, key.Position} @@ -289,8 +289,8 @@ func tokenIsComma(t *token) bool { return t != nil && t.typ == tokenComma } -func (p *tomlParser) parseInlineTable() *TomlTree { - tree := newTomlTree() +func (p *tomlParser) parseInlineTable() *Tree { + tree := newTree() var previous *token Loop: for { @@ -360,22 +360,22 @@ func (p *tomlParser) parseArray() interface{} { p.getToken() } } - // An array of TomlTrees is actually an array of inline + // An array of Trees is actually an array of inline // tables, which is a shorthand for a table array. If the - // array was not converted from []interface{} to []*TomlTree, + // array was not converted from []interface{} to []*Tree, // the two notations would not be equivalent. - if arrayType == reflect.TypeOf(newTomlTree()) { - tomlArray := make([]*TomlTree, len(array)) + if arrayType == reflect.TypeOf(newTree()) { + tomlArray := make([]*Tree, len(array)) for i, v := range array { - tomlArray[i] = v.(*TomlTree) + tomlArray[i] = v.(*Tree) } return tomlArray } return array } -func parseToml(flow chan token) *TomlTree { - result := newTomlTree() +func parseToml(flow chan token) *Tree { + result := newTree() result.position = Position{1, 1} parser := &tomlParser{ flow: flow, diff --git a/vendor/github.com/pelletier/go-toml/query.go b/vendor/github.com/pelletier/go-toml/query.go deleted file mode 100644 index 307a1eca..00000000 --- a/vendor/github.com/pelletier/go-toml/query.go +++ /dev/null @@ -1,153 +0,0 @@ -package toml - -import ( - "time" -) - -// NodeFilterFn represents a user-defined filter function, for use with -// Query.SetFilter(). -// -// The return value of the function must indicate if 'node' is to be included -// at this stage of the TOML path. Returning true will include the node, and -// returning false will exclude it. -// -// NOTE: Care should be taken to write script callbacks such that they are safe -// to use from multiple goroutines. -type NodeFilterFn func(node interface{}) bool - -// QueryResult is the result of Executing a Query. -type QueryResult struct { - items []interface{} - positions []Position -} - -// appends a value/position pair to the result set. -func (r *QueryResult) appendResult(node interface{}, pos Position) { - r.items = append(r.items, node) - r.positions = append(r.positions, pos) -} - -// Values is a set of values within a QueryResult. The order of values is not -// guaranteed to be in document order, and may be different each time a query is -// executed. -func (r QueryResult) Values() []interface{} { - values := make([]interface{}, len(r.items)) - for i, v := range r.items { - o, ok := v.(*tomlValue) - if ok { - values[i] = o.value - } else { - values[i] = v - } - } - return values -} - -// Positions is a set of positions for values within a QueryResult. Each index -// in Positions() corresponds to the entry in Value() of the same index. -func (r QueryResult) Positions() []Position { - return r.positions -} - -// runtime context for executing query paths -type queryContext struct { - result *QueryResult - filters *map[string]NodeFilterFn - lastPosition Position -} - -// generic path functor interface -type pathFn interface { - setNext(next pathFn) - call(node interface{}, ctx *queryContext) -} - -// A Query is the representation of a compiled TOML path. A Query is safe -// for concurrent use by multiple goroutines. -type Query struct { - root pathFn - tail pathFn - filters *map[string]NodeFilterFn -} - -func newQuery() *Query { - return &Query{ - root: nil, - tail: nil, - filters: &defaultFilterFunctions, - } -} - -func (q *Query) appendPath(next pathFn) { - if q.root == nil { - q.root = next - } else { - q.tail.setNext(next) - } - q.tail = next - next.setNext(newTerminatingFn()) // init the next functor -} - -// CompileQuery compiles a TOML path expression. The returned Query can be used -// to match elements within a TomlTree and its descendants. -func CompileQuery(path string) (*Query, error) { - return parseQuery(lexQuery(path)) -} - -// Execute executes a query against a TomlTree, and returns the result of the query. -func (q *Query) Execute(tree *TomlTree) *QueryResult { - result := &QueryResult{ - items: []interface{}{}, - positions: []Position{}, - } - if q.root == nil { - result.appendResult(tree, tree.GetPosition("")) - } else { - ctx := &queryContext{ - result: result, - filters: q.filters, - } - q.root.call(tree, ctx) - } - return result -} - -// SetFilter sets a user-defined filter function. These may be used inside -// "?(..)" query expressions to filter TOML document elements within a query. -func (q *Query) SetFilter(name string, fn NodeFilterFn) { - if q.filters == &defaultFilterFunctions { - // clone the static table - q.filters = &map[string]NodeFilterFn{} - for k, v := range defaultFilterFunctions { - (*q.filters)[k] = v - } - } - (*q.filters)[name] = fn -} - -var defaultFilterFunctions = map[string]NodeFilterFn{ - "tree": func(node interface{}) bool { - _, ok := node.(*TomlTree) - return ok - }, - "int": func(node interface{}) bool { - _, ok := node.(int64) - return ok - }, - "float": func(node interface{}) bool { - _, ok := node.(float64) - return ok - }, - "string": func(node interface{}) bool { - _, ok := node.(string) - return ok - }, - "time": func(node interface{}) bool { - _, ok := node.(time.Time) - return ok - }, - "bool": func(node interface{}) bool { - _, ok := node.(bool) - return ok - }, -} diff --git a/vendor/github.com/pelletier/go-toml/querylexer.go b/vendor/github.com/pelletier/go-toml/querylexer.go deleted file mode 100644 index 960681d0..00000000 --- a/vendor/github.com/pelletier/go-toml/querylexer.go +++ /dev/null @@ -1,356 +0,0 @@ -// TOML JSONPath lexer. -// -// Written using the principles developed by Rob Pike in -// http://www.youtube.com/watch?v=HxaD_trXwRE - -package toml - -import ( - "fmt" - "strconv" - "strings" - "unicode/utf8" -) - -// Lexer state function -type queryLexStateFn func() queryLexStateFn - -// Lexer definition -type queryLexer struct { - input string - start int - pos int - width int - tokens chan token - depth int - line int - col int - stringTerm string -} - -func (l *queryLexer) run() { - for state := l.lexVoid; state != nil; { - state = state() - } - close(l.tokens) -} - -func (l *queryLexer) nextStart() { - // iterate by runes (utf8 characters) - // search for newlines and advance line/col counts - for i := l.start; i < l.pos; { - r, width := utf8.DecodeRuneInString(l.input[i:]) - if r == '\n' { - l.line++ - l.col = 1 - } else { - l.col++ - } - i += width - } - // advance start position to next token - l.start = l.pos -} - -func (l *queryLexer) emit(t tokenType) { - l.tokens <- token{ - Position: Position{l.line, l.col}, - typ: t, - val: l.input[l.start:l.pos], - } - l.nextStart() -} - -func (l *queryLexer) emitWithValue(t tokenType, value string) { - l.tokens <- token{ - Position: Position{l.line, l.col}, - typ: t, - val: value, - } - l.nextStart() -} - -func (l *queryLexer) next() rune { - if l.pos >= len(l.input) { - l.width = 0 - return eof - } - var r rune - r, l.width = utf8.DecodeRuneInString(l.input[l.pos:]) - l.pos += l.width - return r -} - -func (l *queryLexer) ignore() { - l.nextStart() -} - -func (l *queryLexer) backup() { - l.pos -= l.width -} - -func (l *queryLexer) errorf(format string, args ...interface{}) queryLexStateFn { - l.tokens <- token{ - Position: Position{l.line, l.col}, - typ: tokenError, - val: fmt.Sprintf(format, args...), - } - return nil -} - -func (l *queryLexer) peek() rune { - r := l.next() - l.backup() - return r -} - -func (l *queryLexer) accept(valid string) bool { - if strings.ContainsRune(valid, l.next()) { - return true - } - l.backup() - return false -} - -func (l *queryLexer) follow(next string) bool { - return strings.HasPrefix(l.input[l.pos:], next) -} - -func (l *queryLexer) lexVoid() queryLexStateFn { - for { - next := l.peek() - switch next { - case '$': - l.pos++ - l.emit(tokenDollar) - continue - case '.': - if l.follow("..") { - l.pos += 2 - l.emit(tokenDotDot) - } else { - l.pos++ - l.emit(tokenDot) - } - continue - case '[': - l.pos++ - l.emit(tokenLeftBracket) - continue - case ']': - l.pos++ - l.emit(tokenRightBracket) - continue - case ',': - l.pos++ - l.emit(tokenComma) - continue - case '*': - l.pos++ - l.emit(tokenStar) - continue - case '(': - l.pos++ - l.emit(tokenLeftParen) - continue - case ')': - l.pos++ - l.emit(tokenRightParen) - continue - case '?': - l.pos++ - l.emit(tokenQuestion) - continue - case ':': - l.pos++ - l.emit(tokenColon) - continue - case '\'': - l.ignore() - l.stringTerm = string(next) - return l.lexString - case '"': - l.ignore() - l.stringTerm = string(next) - return l.lexString - } - - if isSpace(next) { - l.next() - l.ignore() - continue - } - - if isAlphanumeric(next) { - return l.lexKey - } - - if next == '+' || next == '-' || isDigit(next) { - return l.lexNumber - } - - if l.next() == eof { - break - } - - return l.errorf("unexpected char: '%v'", next) - } - l.emit(tokenEOF) - return nil -} - -func (l *queryLexer) lexKey() queryLexStateFn { - for { - next := l.peek() - if !isAlphanumeric(next) { - l.emit(tokenKey) - return l.lexVoid - } - - if l.next() == eof { - break - } - } - l.emit(tokenEOF) - return nil -} - -func (l *queryLexer) lexString() queryLexStateFn { - l.pos++ - l.ignore() - growingString := "" - - for { - if l.follow(l.stringTerm) { - l.emitWithValue(tokenString, growingString) - l.pos++ - l.ignore() - return l.lexVoid - } - - if l.follow("\\\"") { - l.pos++ - growingString += "\"" - } else if l.follow("\\'") { - l.pos++ - growingString += "'" - } else if l.follow("\\n") { - l.pos++ - growingString += "\n" - } else if l.follow("\\b") { - l.pos++ - growingString += "\b" - } else if l.follow("\\f") { - l.pos++ - growingString += "\f" - } else if l.follow("\\/") { - l.pos++ - growingString += "/" - } else if l.follow("\\t") { - l.pos++ - growingString += "\t" - } else if l.follow("\\r") { - l.pos++ - growingString += "\r" - } else if l.follow("\\\\") { - l.pos++ - growingString += "\\" - } else if l.follow("\\u") { - l.pos += 2 - code := "" - for i := 0; i < 4; i++ { - c := l.peek() - l.pos++ - if !isHexDigit(c) { - return l.errorf("unfinished unicode escape") - } - code = code + string(c) - } - l.pos-- - intcode, err := strconv.ParseInt(code, 16, 32) - if err != nil { - return l.errorf("invalid unicode escape: \\u" + code) - } - growingString += string(rune(intcode)) - } else if l.follow("\\U") { - l.pos += 2 - code := "" - for i := 0; i < 8; i++ { - c := l.peek() - l.pos++ - if !isHexDigit(c) { - return l.errorf("unfinished unicode escape") - } - code = code + string(c) - } - l.pos-- - intcode, err := strconv.ParseInt(code, 16, 32) - if err != nil { - return l.errorf("invalid unicode escape: \\u" + code) - } - growingString += string(rune(intcode)) - } else if l.follow("\\") { - l.pos++ - return l.errorf("invalid escape sequence: \\" + string(l.peek())) - } else { - growingString += string(l.peek()) - } - - if l.next() == eof { - break - } - } - - return l.errorf("unclosed string") -} - -func (l *queryLexer) lexNumber() queryLexStateFn { - l.ignore() - if !l.accept("+") { - l.accept("-") - } - pointSeen := false - digitSeen := false - for { - next := l.next() - if next == '.' { - if pointSeen { - return l.errorf("cannot have two dots in one float") - } - if !isDigit(l.peek()) { - return l.errorf("float cannot end with a dot") - } - pointSeen = true - } else if isDigit(next) { - digitSeen = true - } else { - l.backup() - break - } - if pointSeen && !digitSeen { - return l.errorf("cannot start float with a dot") - } - } - - if !digitSeen { - return l.errorf("no digit in that number") - } - if pointSeen { - l.emit(tokenFloat) - } else { - l.emit(tokenInteger) - } - return l.lexVoid -} - -// Entry point -func lexQuery(input string) chan token { - l := &queryLexer{ - input: input, - tokens: make(chan token), - line: 1, - col: 1, - } - go l.run() - return l.tokens -} diff --git a/vendor/github.com/pelletier/go-toml/queryparser.go b/vendor/github.com/pelletier/go-toml/queryparser.go deleted file mode 100644 index 1cbfc83b..00000000 --- a/vendor/github.com/pelletier/go-toml/queryparser.go +++ /dev/null @@ -1,275 +0,0 @@ -/* - Based on the "jsonpath" spec/concept. - - http://goessner.net/articles/JsonPath/ - https://code.google.com/p/json-path/ -*/ - -package toml - -import ( - "fmt" -) - -const maxInt = int(^uint(0) >> 1) - -type queryParser struct { - flow chan token - tokensBuffer []token - query *Query - union []pathFn - err error -} - -type queryParserStateFn func() queryParserStateFn - -// Formats and panics an error message based on a token -func (p *queryParser) parseError(tok *token, msg string, args ...interface{}) queryParserStateFn { - p.err = fmt.Errorf(tok.Position.String()+": "+msg, args...) - return nil // trigger parse to end -} - -func (p *queryParser) run() { - for state := p.parseStart; state != nil; { - state = state() - } -} - -func (p *queryParser) backup(tok *token) { - p.tokensBuffer = append(p.tokensBuffer, *tok) -} - -func (p *queryParser) peek() *token { - if len(p.tokensBuffer) != 0 { - return &(p.tokensBuffer[0]) - } - - tok, ok := <-p.flow - if !ok { - return nil - } - p.backup(&tok) - return &tok -} - -func (p *queryParser) lookahead(types ...tokenType) bool { - result := true - buffer := []token{} - - for _, typ := range types { - tok := p.getToken() - if tok == nil { - result = false - break - } - buffer = append(buffer, *tok) - if tok.typ != typ { - result = false - break - } - } - // add the tokens back to the buffer, and return - p.tokensBuffer = append(p.tokensBuffer, buffer...) - return result -} - -func (p *queryParser) getToken() *token { - if len(p.tokensBuffer) != 0 { - tok := p.tokensBuffer[0] - p.tokensBuffer = p.tokensBuffer[1:] - return &tok - } - tok, ok := <-p.flow - if !ok { - return nil - } - return &tok -} - -func (p *queryParser) parseStart() queryParserStateFn { - tok := p.getToken() - - if tok == nil || tok.typ == tokenEOF { - return nil - } - - if tok.typ != tokenDollar { - return p.parseError(tok, "Expected '$' at start of expression") - } - - return p.parseMatchExpr -} - -// handle '.' prefix, '[]', and '..' -func (p *queryParser) parseMatchExpr() queryParserStateFn { - tok := p.getToken() - switch tok.typ { - case tokenDotDot: - p.query.appendPath(&matchRecursiveFn{}) - // nested parse for '..' - tok := p.getToken() - switch tok.typ { - case tokenKey: - p.query.appendPath(newMatchKeyFn(tok.val)) - return p.parseMatchExpr - case tokenLeftBracket: - return p.parseBracketExpr - case tokenStar: - // do nothing - the recursive predicate is enough - return p.parseMatchExpr - } - - case tokenDot: - // nested parse for '.' - tok := p.getToken() - switch tok.typ { - case tokenKey: - p.query.appendPath(newMatchKeyFn(tok.val)) - return p.parseMatchExpr - case tokenStar: - p.query.appendPath(&matchAnyFn{}) - return p.parseMatchExpr - } - - case tokenLeftBracket: - return p.parseBracketExpr - - case tokenEOF: - return nil // allow EOF at this stage - } - return p.parseError(tok, "expected match expression") -} - -func (p *queryParser) parseBracketExpr() queryParserStateFn { - if p.lookahead(tokenInteger, tokenColon) { - return p.parseSliceExpr - } - if p.peek().typ == tokenColon { - return p.parseSliceExpr - } - return p.parseUnionExpr -} - -func (p *queryParser) parseUnionExpr() queryParserStateFn { - var tok *token - - // this state can be traversed after some sub-expressions - // so be careful when setting up state in the parser - if p.union == nil { - p.union = []pathFn{} - } - -loop: // labeled loop for easy breaking - for { - if len(p.union) > 0 { - // parse delimiter or terminator - tok = p.getToken() - switch tok.typ { - case tokenComma: - // do nothing - case tokenRightBracket: - break loop - default: - return p.parseError(tok, "expected ',' or ']', not '%s'", tok.val) - } - } - - // parse sub expression - tok = p.getToken() - switch tok.typ { - case tokenInteger: - p.union = append(p.union, newMatchIndexFn(tok.Int())) - case tokenKey: - p.union = append(p.union, newMatchKeyFn(tok.val)) - case tokenString: - p.union = append(p.union, newMatchKeyFn(tok.val)) - case tokenQuestion: - return p.parseFilterExpr - default: - return p.parseError(tok, "expected union sub expression, not '%s', %d", tok.val, len(p.union)) - } - } - - // if there is only one sub-expression, use that instead - if len(p.union) == 1 { - p.query.appendPath(p.union[0]) - } else { - p.query.appendPath(&matchUnionFn{p.union}) - } - - p.union = nil // clear out state - return p.parseMatchExpr -} - -func (p *queryParser) parseSliceExpr() queryParserStateFn { - // init slice to grab all elements - start, end, step := 0, maxInt, 1 - - // parse optional start - tok := p.getToken() - if tok.typ == tokenInteger { - start = tok.Int() - tok = p.getToken() - } - if tok.typ != tokenColon { - return p.parseError(tok, "expected ':'") - } - - // parse optional end - tok = p.getToken() - if tok.typ == tokenInteger { - end = tok.Int() - tok = p.getToken() - } - if tok.typ == tokenRightBracket { - p.query.appendPath(newMatchSliceFn(start, end, step)) - return p.parseMatchExpr - } - if tok.typ != tokenColon { - return p.parseError(tok, "expected ']' or ':'") - } - - // parse optional step - tok = p.getToken() - if tok.typ == tokenInteger { - step = tok.Int() - if step < 0 { - return p.parseError(tok, "step must be a positive value") - } - tok = p.getToken() - } - if tok.typ != tokenRightBracket { - return p.parseError(tok, "expected ']'") - } - - p.query.appendPath(newMatchSliceFn(start, end, step)) - return p.parseMatchExpr -} - -func (p *queryParser) parseFilterExpr() queryParserStateFn { - tok := p.getToken() - if tok.typ != tokenLeftParen { - return p.parseError(tok, "expected left-parenthesis for filter expression") - } - tok = p.getToken() - if tok.typ != tokenKey && tok.typ != tokenString { - return p.parseError(tok, "expected key or string for filter funciton name") - } - name := tok.val - tok = p.getToken() - if tok.typ != tokenRightParen { - return p.parseError(tok, "expected right-parenthesis for filter expression") - } - p.union = append(p.union, newMatchFilterFn(name, tok.Position)) - return p.parseUnionExpr -} - -func parseQuery(flow chan token) (*Query, error) { - parser := &queryParser{ - flow: flow, - tokensBuffer: []token{}, - query: newQuery(), - } - parser.run() - return parser.query, parser.err -} diff --git a/vendor/github.com/pelletier/go-toml/toml.go b/vendor/github.com/pelletier/go-toml/toml.go index 1ba56a1c..99663217 100644 --- a/vendor/github.com/pelletier/go-toml/toml.go +++ b/vendor/github.com/pelletier/go-toml/toml.go @@ -14,30 +14,35 @@ type tomlValue struct { position Position } -// TomlTree is the result of the parsing of a TOML file. -type TomlTree struct { - values map[string]interface{} // string -> *tomlValue, *TomlTree, []*TomlTree +// Tree is the result of the parsing of a TOML file. +type Tree struct { + values map[string]interface{} // string -> *tomlValue, *Tree, []*Tree position Position } -func newTomlTree() *TomlTree { - return &TomlTree{ +func newTree() *Tree { + return &Tree{ values: make(map[string]interface{}), position: Position{}, } } -// TreeFromMap initializes a new TomlTree object using the given map. -func TreeFromMap(m map[string]interface{}) (*TomlTree, error) { +// TreeFromMap initializes a new Tree object using the given map. +func TreeFromMap(m map[string]interface{}) (*Tree, error) { result, err := toTree(m) if err != nil { return nil, err } - return result.(*TomlTree), nil + return result.(*Tree), nil +} + +// Position returns the position of the tree. +func (t *Tree) Position() Position { + return t.position } // Has returns a boolean indicating if the given key exists. -func (t *TomlTree) Has(key string) bool { +func (t *Tree) Has(key string) bool { if key == "" { return false } @@ -45,25 +50,27 @@ func (t *TomlTree) Has(key string) bool { } // HasPath returns true if the given path of keys exists, false otherwise. -func (t *TomlTree) HasPath(keys []string) bool { +func (t *Tree) HasPath(keys []string) bool { return t.GetPath(keys) != nil } // Keys returns the keys of the toplevel tree. // Warning: this is a costly operation. -func (t *TomlTree) Keys() []string { - var keys []string +func (t *Tree) Keys() []string { + keys := make([]string, len(t.values)) + i := 0 for k := range t.values { - keys = append(keys, k) + keys[i] = k + i++ } return keys } -// Get the value at key in the TomlTree. +// Get the value at key in the Tree. // Key is a dot-separated path (e.g. a.b.c). // Returns nil if the path does not exist in the tree. // If keys is of length zero, the current tree is returned. -func (t *TomlTree) Get(key string) interface{} { +func (t *Tree) Get(key string) interface{} { if key == "" { return t } @@ -76,7 +83,7 @@ func (t *TomlTree) Get(key string) interface{} { // GetPath returns the element in the tree indicated by 'keys'. // If keys is of length zero, the current tree is returned. -func (t *TomlTree) GetPath(keys []string) interface{} { +func (t *Tree) GetPath(keys []string) interface{} { if len(keys) == 0 { return t } @@ -87,9 +94,9 @@ func (t *TomlTree) GetPath(keys []string) interface{} { return nil } switch node := value.(type) { - case *TomlTree: + case *Tree: subtree = node - case []*TomlTree: + case []*Tree: // go to most recent element if len(node) == 0 { return nil @@ -109,7 +116,7 @@ func (t *TomlTree) GetPath(keys []string) interface{} { } // GetPosition returns the position of the given key. -func (t *TomlTree) GetPosition(key string) Position { +func (t *Tree) GetPosition(key string) Position { if key == "" { return t.position } @@ -118,7 +125,7 @@ func (t *TomlTree) GetPosition(key string) Position { // GetPositionPath returns the element in the tree indicated by 'keys'. // If keys is of length zero, the current tree is returned. -func (t *TomlTree) GetPositionPath(keys []string) Position { +func (t *Tree) GetPositionPath(keys []string) Position { if len(keys) == 0 { return t.position } @@ -129,9 +136,9 @@ func (t *TomlTree) GetPositionPath(keys []string) Position { return Position{0, 0} } switch node := value.(type) { - case *TomlTree: + case *Tree: subtree = node - case []*TomlTree: + case []*Tree: // go to most recent element if len(node) == 0 { return Position{0, 0} @@ -145,9 +152,9 @@ func (t *TomlTree) GetPositionPath(keys []string) Position { switch node := subtree.values[keys[len(keys)-1]].(type) { case *tomlValue: return node.position - case *TomlTree: + case *Tree: return node.position - case []*TomlTree: + case []*Tree: // go to most recent element if len(node) == 0 { return Position{0, 0} @@ -159,7 +166,7 @@ func (t *TomlTree) GetPositionPath(keys []string) Position { } // GetDefault works like Get but with a default value -func (t *TomlTree) GetDefault(key string, def interface{}) interface{} { +func (t *Tree) GetDefault(key string, def interface{}) interface{} { val := t.Get(key) if val == nil { return def @@ -169,30 +176,30 @@ func (t *TomlTree) GetDefault(key string, def interface{}) interface{} { // Set an element in the tree. // Key is a dot-separated path (e.g. a.b.c). -// Creates all necessary intermediates trees, if needed. -func (t *TomlTree) Set(key string, value interface{}) { +// Creates all necessary intermediate trees, if needed. +func (t *Tree) Set(key string, value interface{}) { t.SetPath(strings.Split(key, "."), value) } // SetPath sets an element in the tree. // Keys is an array of path elements (e.g. {"a","b","c"}). -// Creates all necessary intermediates trees, if needed. -func (t *TomlTree) SetPath(keys []string, value interface{}) { +// Creates all necessary intermediate trees, if needed. +func (t *Tree) SetPath(keys []string, value interface{}) { subtree := t for _, intermediateKey := range keys[:len(keys)-1] { nextTree, exists := subtree.values[intermediateKey] if !exists { - nextTree = newTomlTree() + nextTree = newTree() subtree.values[intermediateKey] = nextTree // add new element here } switch node := nextTree.(type) { - case *TomlTree: + case *Tree: subtree = node - case []*TomlTree: + case []*Tree: // go to most recent element if len(node) == 0 { // create element if it does not exist - subtree.values[intermediateKey] = append(node, newTomlTree()) + subtree.values[intermediateKey] = append(node, newTree()) } subtree = node[len(node)-1] } @@ -201,9 +208,9 @@ func (t *TomlTree) SetPath(keys []string, value interface{}) { var toInsert interface{} switch value.(type) { - case *TomlTree: + case *Tree: toInsert = value - case []*TomlTree: + case []*Tree: toInsert = value case *tomlValue: toInsert = value @@ -221,21 +228,21 @@ func (t *TomlTree) SetPath(keys []string, value interface{}) { // and tree[a][b][c] // // Returns nil on success, error object on failure -func (t *TomlTree) createSubTree(keys []string, pos Position) error { +func (t *Tree) createSubTree(keys []string, pos Position) error { subtree := t for _, intermediateKey := range keys { nextTree, exists := subtree.values[intermediateKey] if !exists { - tree := newTomlTree() + tree := newTree() tree.position = pos subtree.values[intermediateKey] = tree nextTree = tree } switch node := nextTree.(type) { - case []*TomlTree: + case []*Tree: subtree = node[len(node)-1] - case *TomlTree: + case *Tree: subtree = node default: return fmt.Errorf("unknown type for path %s (%s): %T (%#v)", @@ -245,17 +252,8 @@ func (t *TomlTree) createSubTree(keys []string, pos Position) error { return nil } -// Query compiles and executes a query on a tree and returns the query result. -func (t *TomlTree) Query(query string) (*QueryResult, error) { - q, err := CompileQuery(query) - if err != nil { - return nil, err - } - return q.Execute(t), nil -} - -// LoadReader creates a TomlTree from any io.Reader. -func LoadReader(reader io.Reader) (tree *TomlTree, err error) { +// LoadReader creates a Tree from any io.Reader. +func LoadReader(reader io.Reader) (tree *Tree, err error) { defer func() { if r := recover(); r != nil { if _, ok := r.(runtime.Error); ok { @@ -268,13 +266,13 @@ func LoadReader(reader io.Reader) (tree *TomlTree, err error) { return } -// Load creates a TomlTree from a string. -func Load(content string) (tree *TomlTree, err error) { +// Load creates a Tree from a string. +func Load(content string) (tree *Tree, err error) { return LoadReader(strings.NewReader(content)) } -// LoadFile creates a TomlTree from a file. -func LoadFile(path string) (tree *TomlTree, err error) { +// LoadFile creates a Tree from a file. +func LoadFile(path string) (tree *Tree, err error) { file, err := os.Open(path) if err != nil { return nil, err diff --git a/vendor/github.com/pelletier/go-toml/tomltree_create.go b/vendor/github.com/pelletier/go-toml/tomltree_create.go index c6054f35..ee7114ed 100644 --- a/vendor/github.com/pelletier/go-toml/tomltree_create.go +++ b/vendor/github.com/pelletier/go-toml/tomltree_create.go @@ -51,7 +51,7 @@ func simpleValueCoercion(object interface{}) (interface{}, error) { case fmt.Stringer: return original.String(), nil default: - return nil, fmt.Errorf("cannot convert type %T to TomlTree", object) + return nil, fmt.Errorf("cannot convert type %T to Tree", object) } } @@ -59,7 +59,7 @@ func sliceToTree(object interface{}) (interface{}, error) { // arrays are a bit tricky, since they can represent either a // collection of simple values, which is represented by one // *tomlValue, or an array of tables, which is represented by an - // array of *TomlTree. + // array of *Tree. // holding the assumption that this function is called from toTree only when value.Kind() is Array or Slice value := reflect.ValueOf(object) @@ -70,14 +70,14 @@ func sliceToTree(object interface{}) (interface{}, error) { } if insideType.Kind() == reflect.Map { // this is considered as an array of tables - tablesArray := make([]*TomlTree, 0, length) + tablesArray := make([]*Tree, 0, length) for i := 0; i < length; i++ { table := value.Index(i) tree, err := toTree(table.Interface()) if err != nil { return nil, err } - tablesArray = append(tablesArray, tree.(*TomlTree)) + tablesArray = append(tablesArray, tree.(*Tree)) } return tablesArray, nil } @@ -120,7 +120,7 @@ func toTree(object interface{}) (interface{}, error) { } values[key.String()] = newValue } - return &TomlTree{values, Position{}}, nil + return &Tree{values, Position{}}, nil } if value.Kind() == reflect.Array || value.Kind() == reflect.Slice { diff --git a/vendor/github.com/pelletier/go-toml/tomltree_write.go b/vendor/github.com/pelletier/go-toml/tomltree_write.go index 6a7fa174..73581441 100644 --- a/vendor/github.com/pelletier/go-toml/tomltree_write.go +++ b/vendor/github.com/pelletier/go-toml/tomltree_write.go @@ -4,11 +4,11 @@ import ( "bytes" "fmt" "io" + "reflect" "sort" "strconv" "strings" "time" - "reflect" ) // encodes a string to a TOML-compliant string value @@ -83,14 +83,14 @@ func tomlValueStringRepresentation(v interface{}) (string, error) { return "", fmt.Errorf("unsupported value type %T: %v", v, v) } -func (t *TomlTree) writeTo(w io.Writer, indent, keyspace string, bytesCount int64) (int64, error) { +func (t *Tree) writeTo(w io.Writer, indent, keyspace string, bytesCount int64) (int64, error) { simpleValuesKeys := make([]string, 0) complexValuesKeys := make([]string, 0) for k := range t.values { v := t.values[k] switch v.(type) { - case *TomlTree, []*TomlTree: + case *Tree, []*Tree: complexValuesKeys = append(complexValuesKeys, k) default: simpleValuesKeys = append(simpleValuesKeys, k) @@ -129,7 +129,7 @@ func (t *TomlTree) writeTo(w io.Writer, indent, keyspace string, bytesCount int6 switch node := v.(type) { // node has to be of those two types given how keys are sorted above - case *TomlTree: + case *Tree: tableName := fmt.Sprintf("\n%s[%s]\n", indent, combinedKey) writtenBytesCount, err := w.Write([]byte(tableName)) bytesCount += int64(writtenBytesCount) @@ -140,7 +140,7 @@ func (t *TomlTree) writeTo(w io.Writer, indent, keyspace string, bytesCount int6 if err != nil { return bytesCount, err } - case []*TomlTree: + case []*Tree: for _, subTree := range node { if len(subTree.values) > 0 { tableArrayName := fmt.Sprintf("\n%s[[%s]]\n", indent, combinedKey) @@ -162,16 +162,16 @@ func (t *TomlTree) writeTo(w io.Writer, indent, keyspace string, bytesCount int6 return bytesCount, nil } -// WriteTo encode the TomlTree as Toml and writes it to the writer w. +// WriteTo encode the Tree as Toml and writes it to the writer w. // Returns the number of bytes written in case of success, or an error if anything happened. -func (t *TomlTree) WriteTo(w io.Writer) (int64, error) { +func (t *Tree) WriteTo(w io.Writer) (int64, error) { return t.writeTo(w, "", "", 0) } // ToTomlString generates a human-readable representation of the current tree. // Output spans multiple lines, and is suitable for ingest by a TOML parser. // If the conversion cannot be performed, ToString returns a non-nil error. -func (t *TomlTree) ToTomlString() (string, error) { +func (t *Tree) ToTomlString() (string, error) { var buf bytes.Buffer _, err := t.WriteTo(&buf) if err != nil { @@ -182,7 +182,7 @@ func (t *TomlTree) ToTomlString() (string, error) { // String generates a human-readable representation of the current tree. // Alias of ToString. Present to implement the fmt.Stringer interface. -func (t *TomlTree) String() string { +func (t *Tree) String() string { result, _ := t.ToTomlString() return result } @@ -196,18 +196,18 @@ func (t *TomlTree) String() string { // * time.Time // * map[string]interface{} (where interface{} is any of this list) // * []interface{} (where interface{} is any of this list) -func (t *TomlTree) ToMap() map[string]interface{} { +func (t *Tree) ToMap() map[string]interface{} { result := map[string]interface{}{} for k, v := range t.values { switch node := v.(type) { - case []*TomlTree: + case []*Tree: var array []interface{} for _, item := range node { array = append(array, item.ToMap()) } result[k] = array - case *TomlTree: + case *Tree: result[k] = node.ToMap() case *tomlValue: result[k] = node.value diff --git a/vendor/github.com/pkg/errors/stack.go b/vendor/github.com/pkg/errors/stack.go index 6b1f2891..cbe3f3e3 100644 --- a/vendor/github.com/pkg/errors/stack.go +++ b/vendor/github.com/pkg/errors/stack.go @@ -79,6 +79,14 @@ func (f Frame) Format(s fmt.State, verb rune) { // StackTrace is stack of Frames from innermost (newest) to outermost (oldest). type StackTrace []Frame +// Format formats the stack of Frames according to the fmt.Formatter interface. +// +// %s lists source files for each Frame in the stack +// %v lists the source file and line number for each Frame in the stack +// +// Format accepts flags that alter the printing of some verbs, as follows: +// +// %+v Prints filename, function, and line number for each Frame in the stack. func (st StackTrace) Format(s fmt.State, verb rune) { switch verb { case 'v': diff --git a/vendor/github.com/spf13/cobra/cobra.go b/vendor/github.com/spf13/cobra/cobra.go index 25473a70..2726d19e 100644 --- a/vendor/github.com/spf13/cobra/cobra.go +++ b/vendor/github.com/spf13/cobra/cobra.go @@ -27,12 +27,13 @@ import ( ) var templateFuncs = template.FuncMap{ - "trim": strings.TrimSpace, - "trimRightSpace": trimRightSpace, - "appendIfNotPresent": appendIfNotPresent, - "rpad": rpad, - "gt": Gt, - "eq": Eq, + "trim": strings.TrimSpace, + "trimRightSpace": trimRightSpace, + "trimTrailingWhitespaces": trimRightSpace, + "appendIfNotPresent": appendIfNotPresent, + "rpad": rpad, + "gt": Gt, + "eq": Eq, } var initializers []func() @@ -65,6 +66,8 @@ func OnInitialize(y ...func()) { initializers = append(initializers, y...) } +// FIXME Gt is unused by cobra and should be removed in a version 2. It exists only for compatibility with users of cobra. + // Gt takes two types and checks whether the first type is greater than the second. In case of types Arrays, Chans, // Maps and Slices, Gt will compare their lengths. Ints are compared directly while strings are first parsed as // ints and then compared. @@ -95,6 +98,8 @@ func Gt(a interface{}, b interface{}) bool { return left > right } +// FIXME Eq is unused by cobra and should be removed in a version 2. It exists only for compatibility with users of cobra. + // Eq takes two types and checks whether they are equal. Supported types are int and string. Unsupported types will panic. func Eq(a interface{}, b interface{}) bool { av := reflect.ValueOf(a) @@ -115,6 +120,8 @@ func trimRightSpace(s string) string { return strings.TrimRightFunc(s, unicode.IsSpace) } +// FIXME appendIfNotPresent is unused by cobra and should be removed in a version 2. It exists only for compatibility with users of cobra. + // appendIfNotPresent will append stringToAppend to the end of s, but only if it's not yet present in s. func appendIfNotPresent(s, stringToAppend string) string { if strings.Contains(s, stringToAppend) { diff --git a/vendor/github.com/spf13/cobra/command.go b/vendor/github.com/spf13/cobra/command.go index 329bbeae..01d9683e 100644 --- a/vendor/github.com/spf13/cobra/command.go +++ b/vendor/github.com/spf13/cobra/command.go @@ -11,8 +11,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -//Package cobra is a commander providing a simple interface to create powerful modern CLI interfaces. -//In addition to providing an interface, Cobra simultaneously provides a controller to organize your application code. +// Package cobra is a commander providing a simple interface to create powerful modern CLI interfaces. +// In addition to providing an interface, Cobra simultaneously provides a controller to organize your application code. package cobra import ( @@ -28,110 +28,147 @@ import ( ) // Command is just that, a command for your application. -// eg. 'go run' ... 'run' is the command. Cobra requires +// E.g. 'go run ...' - 'run' is the command. Cobra requires // you to define the usage and description as part of your command // definition to ensure usability. type Command struct { - // Name is the command name, usually the executable's name. - name string - // The one-line usage message. + // Use is the one-line usage message. Use string - // An array of aliases that can be used instead of the first word in Use. + + // Aliases is an array of aliases that can be used instead of the first word in Use. Aliases []string - // An array of command names for which this command will be suggested - similar to aliases but only suggests. + + // SuggestFor is an array of command names for which this command will be suggested - + // similar to aliases but only suggests. SuggestFor []string - // The short description shown in the 'help' output. + + // Short is the short description shown in the 'help' output. Short string - // The long message shown in the 'help ' output. + + // Long is the long message shown in the 'help ' output. Long string - // Examples of how to use the command + + // Example is examples of how to use the command. Example string - // List of all valid non-flag arguments that are accepted in bash completions + + // ValidArgs is list of all valid non-flag arguments that are accepted in bash completions ValidArgs []string - // List of aliases for ValidArgs. These are not suggested to the user in the bash - // completion, but accepted if entered manually. + + // ArgAliases is List of aliases for ValidArgs. + // These are not suggested to the user in the bash completion, + // but accepted if entered manually. ArgAliases []string - // Custom functions used by the bash autocompletion generator + + // BashCompletionFunction is custom functions used by the bash autocompletion generator. BashCompletionFunction string - // Is this command deprecated and should print this string when used? + + // Deprecated defines, if this command is deprecated and should print this string when used. Deprecated string - // Is this command hidden and should NOT show up in the list of available commands? + + // Hidden defines, if this command is hidden and should NOT show up in the list of available commands. Hidden bool + // Annotations are key/value pairs that can be used by applications to identify or - // group commands + // group commands. Annotations map[string]string - // Full set of flags - flags *flag.FlagSet - // Set of flags childrens of this command will inherit - pflags *flag.FlagSet - // Flags that are declared specifically by this command (not inherited). - lflags *flag.FlagSet - // Inherited flags. - iflags *flag.FlagSet - // All persistent flags of cmd's parents. - parentsPflags *flag.FlagSet - // SilenceErrors is an option to quiet errors down stream - SilenceErrors bool - // Silence Usage is an option to silence usage when an error occurs. - SilenceUsage bool + // The *Run functions are executed in the following order: // * PersistentPreRun() // * PreRun() // * Run() // * PostRun() // * PersistentPostRun() - // All functions get the same args, the arguments after the command name - // PersistentPreRun: children of this command will inherit and execute + // All functions get the same args, the arguments after the command name. + // + // PersistentPreRun: children of this command will inherit and execute. PersistentPreRun func(cmd *Command, args []string) - // PersistentPreRunE: PersistentPreRun but returns an error + // PersistentPreRunE: PersistentPreRun but returns an error. PersistentPreRunE func(cmd *Command, args []string) error // PreRun: children of this command will not inherit. PreRun func(cmd *Command, args []string) - // PreRunE: PreRun but returns an error + // PreRunE: PreRun but returns an error. PreRunE func(cmd *Command, args []string) error - // Run: Typically the actual work function. Most commands will only implement this + // Run: Typically the actual work function. Most commands will only implement this. Run func(cmd *Command, args []string) - // RunE: Run but returns an error + // RunE: Run but returns an error. RunE func(cmd *Command, args []string) error // PostRun: run after the Run command. PostRun func(cmd *Command, args []string) - // PostRunE: PostRun but returns an error + // PostRunE: PostRun but returns an error. PostRunE func(cmd *Command, args []string) error - // PersistentPostRun: children of this command will inherit and execute after PostRun + // PersistentPostRun: children of this command will inherit and execute after PostRun. PersistentPostRun func(cmd *Command, args []string) - // PersistentPostRunE: PersistentPostRun but returns an error + // PersistentPostRunE: PersistentPostRun but returns an error. PersistentPostRunE func(cmd *Command, args []string) error - // DisableAutoGenTag remove + + // SilenceErrors is an option to quiet errors down stream. + SilenceErrors bool + + // SilenceUsage is an option to silence usage when an error occurs. + SilenceUsage bool + + // DisableFlagParsing disables the flag parsing. + // If this is true all flags will be passed to the command as arguments. + DisableFlagParsing bool + + // DisableAutoGenTag defines, if gen tag ("Auto generated by spf13/cobra...") + // will be printed by generating docs for this command. DisableAutoGenTag bool - // Commands is the list of commands supported by this program. + + // DisableSuggestions disables the suggestions based on Levenshtein distance + // that go along with 'unknown command' messages. + DisableSuggestions bool + // SuggestionsMinimumDistance defines minimum levenshtein distance to display suggestions. + // Must be > 0. + SuggestionsMinimumDistance int + + // name is the command name, usually the executable's name. + name string + // commands is the list of commands supported by this program. commands []*Command - // Parent Command for this command + // parent is a parent command for this command. parent *Command - // max lengths of commands' string lengths for use in padding + // Max lengths of commands' string lengths for use in padding. commandsMaxUseLen int commandsMaxCommandPathLen int commandsMaxNameLen int - // is commands slice are sorted or not + // commandsAreSorted defines, if command slice are sorted or not. commandsAreSorted bool - args []string // actual args parsed from flags - output io.Writer // out writer if set in SetOutput(w) - usageFunc func(*Command) error // Usage can be defined by application - usageTemplate string // Can be defined by Application - flagErrorFunc func(*Command, error) error - helpTemplate string // Can be defined by Application - helpFunc func(*Command, []string) // Help can be defined by application - helpCommand *Command // The help command - // The global normalization function that we can use on every pFlag set and children commands + // args is actual args parsed from flags. + args []string + // flagErrorBuf contains all error messages from pflag. + flagErrorBuf *bytes.Buffer + // flags is full set of flags. + flags *flag.FlagSet + // pflags contains persistent flags. + pflags *flag.FlagSet + // lflags contains local flags. + lflags *flag.FlagSet + // iflags contains inherited flags. + iflags *flag.FlagSet + // parentsPflags is all persistent flags of cmd's parents. + parentsPflags *flag.FlagSet + // globNormFunc is the global normalization function + // that we can use on every pflag set and children commands globNormFunc func(f *flag.FlagSet, name string) flag.NormalizedName - // Disable the suggestions based on Levenshtein distance that go along with 'unknown command' messages - DisableSuggestions bool - // If displaying suggestions, allows to set the minimum levenshtein distance to display, must be > 0 - SuggestionsMinimumDistance int - - // Disable the flag parsing. If this is true all flags will be passed to the command as arguments. - DisableFlagParsing bool + // output is an output writer defined by user. + output io.Writer + // usageFunc is usage func defined by user. + usageFunc func(*Command) error + // usageTemplate is usage template defined by user. + usageTemplate string + // flagErrorFunc is func defined by user and it's called when the parsing of + // flags returns an error. + flagErrorFunc func(*Command, error) error + // helpTemplate is help template defined by user. + helpTemplate string + // helpFunc is help func defined by user. + helpFunc func(*Command, []string) + // helpCommand is command with usage 'help'. If it's not defined by user, + // cobra uses default help command. + helpCommand *Command } // SetArgs sets arguments for the command. It is set to os.Args[1:] by default, if desired, can be overridden @@ -215,9 +252,8 @@ func (c *Command) UsageFunc() (f func(*Command) error) { if c.usageFunc != nil { return c.usageFunc } - if c.HasParent() { - return c.parent.UsageFunc() + return c.Parent().UsageFunc() } return func(c *Command) error { c.mergePersistentFlags() @@ -239,10 +275,13 @@ func (c *Command) Usage() error { // HelpFunc returns either the function set by SetHelpFunc for this command // or a parent, or it returns a function with default help behavior. func (c *Command) HelpFunc() func(*Command, []string) { - if helpFunc := c.checkHelpFunc(); helpFunc != nil { - return helpFunc + if c.helpFunc != nil { + return c.helpFunc } - return func(*Command, []string) { + if c.HasParent() { + return c.Parent().HelpFunc() + } + return func(c *Command, a []string) { c.mergePersistentFlags() err := tmpl(c.OutOrStdout(), c.HelpTemplate(), c) if err != nil { @@ -251,20 +290,6 @@ func (c *Command) HelpFunc() func(*Command, []string) { } } -// checkHelpFunc checks if there is helpFunc in ancestors of c. -func (c *Command) checkHelpFunc() func(*Command, []string) { - if c == nil { - return nil - } - if c.helpFunc != nil { - return c.helpFunc - } - if c.HasParent() { - return c.parent.checkHelpFunc() - } - return nil -} - // Help puts out the help for the command. // Used when a user calls help [command]. // Can be defined by user by overriding HelpFunc. @@ -339,23 +364,23 @@ func (c *Command) UsageTemplate() string { return c.parent.UsageTemplate() } return `Usage:{{if .Runnable}} - {{if .HasAvailableFlags}}{{appendIfNotPresent .UseLine "[flags]"}}{{else}}{{.UseLine}}{{end}}{{end}}{{if .HasAvailableSubCommands}} - {{ .CommandPath}} [command]{{end}}{{if gt .Aliases 0}} + {{.UseLine}}{{end}}{{if .HasAvailableSubCommands}} + {{.CommandPath}} [command]{{end}}{{if gt (len .Aliases) 0}} Aliases: {{.NameAndAliases}}{{end}}{{if .HasExample}} Examples: -{{ .Example }}{{end}}{{if .HasAvailableSubCommands}} +{{.Example}}{{end}}{{if .HasAvailableSubCommands}} Available Commands:{{range .Commands}}{{if (or .IsAvailableCommand (eq .Name "help"))}} {{rpad .Name .NamePadding }} {{.Short}}{{end}}{{end}}{{end}}{{if .HasAvailableLocalFlags}} Flags: -{{.LocalFlags.FlagUsages | trimRightSpace}}{{end}}{{if .HasAvailableInheritedFlags}} +{{.LocalFlags.FlagUsages | trimTrailingWhitespaces}}{{end}}{{if .HasAvailableInheritedFlags}} Global Flags: -{{.InheritedFlags.FlagUsages | trimRightSpace}}{{end}}{{if .HasHelpSubCommands}} +{{.InheritedFlags.FlagUsages | trimTrailingWhitespaces}}{{end}}{{if .HasHelpSubCommands}} Additional help topics:{{range .Commands}}{{if .IsAdditionalHelpTopicCommand}} {{rpad .CommandPath .CommandPathPadding}} {{.Short}}{{end}}{{end}}{{end}}{{if .HasAvailableSubCommands}} @@ -373,70 +398,60 @@ func (c *Command) HelpTemplate() string { if c.HasParent() { return c.parent.HelpTemplate() } - return `{{with or .Long .Short }}{{. | trim}} + return `{{with (or .Long .Short)}}{{. | trimTrailingWhitespaces}} {{end}}{{if or .Runnable .HasSubCommands}}{{.UsageString}}{{end}}` } -// Really only used when casting a command to a commander. -func (c *Command) resetChildrensParents() { - for _, x := range c.commands { - x.parent = c - } -} - -func hasNoOptDefVal(name string, f *flag.FlagSet) bool { - flag := f.Lookup(name) +func hasNoOptDefVal(name string, fs *flag.FlagSet) bool { + flag := fs.Lookup(name) if flag == nil { return false } - return len(flag.NoOptDefVal) > 0 + return flag.NoOptDefVal != "" } func shortHasNoOptDefVal(name string, fs *flag.FlagSet) bool { - result := false - fs.VisitAll(func(flag *flag.Flag) { - if flag.Shorthand == name && len(flag.NoOptDefVal) > 0 { - result = true - } - }) - return result + if len(name) == 0 { + return false + } + + flag := fs.ShorthandLookup(name[:1]) + if flag == nil { + return false + } + return flag.NoOptDefVal != "" } func stripFlags(args []string, c *Command) []string { - if len(args) < 1 { + if len(args) == 0 { return args } c.mergePersistentFlags() commands := []string{} + flags := c.Flags() - inQuote := false - inFlag := false - for _, y := range args { - if !inQuote { - switch { - case strings.HasPrefix(y, "\""): - inQuote = true - case strings.Contains(y, "=\""): - inQuote = true - case strings.HasPrefix(y, "--") && !strings.Contains(y, "="): - // TODO: this isn't quite right, we should really check ahead for 'true' or 'false' - inFlag = !hasNoOptDefVal(y[2:], c.Flags()) - case strings.HasPrefix(y, "-") && !strings.Contains(y, "=") && len(y) == 2 && !shortHasNoOptDefVal(y[1:], c.Flags()): - inFlag = true - case inFlag: - inFlag = false - case y == "": - // strip empty commands, as the go tests expect this to be ok.... - case !strings.HasPrefix(y, "-"): - commands = append(commands, y) - inFlag = false +Loop: + for len(args) > 0 { + s := args[0] + args = args[1:] + switch { + case strings.HasPrefix(s, "--") && !strings.Contains(s, "=") && !hasNoOptDefVal(s[2:], flags): + // If '--flag arg' then + // delete arg from args. + fallthrough // (do the same as below) + case strings.HasPrefix(s, "-") && !strings.Contains(s, "=") && len(s) == 2 && !shortHasNoOptDefVal(s[1:], flags): + // If '-f arg' then + // delete 'arg' from args or break the loop if len(args) <= 1. + if len(args) <= 1 { + break Loop + } else { + args = args[1:] + continue } - } - - if strings.HasSuffix(y, "\"") && !strings.HasSuffix(y, "\\\"") { - inQuote = false + case s != "" && !strings.HasPrefix(s, "-"): + commands = append(commands, s) } } @@ -581,18 +596,19 @@ func (c *Command) execute(a []string) (err error) { // initialize help flag as the last point possible to allow for user // overriding - c.initHelpFlag() + c.InitDefaultHelpFlag() err = c.ParseFlags(a) if err != nil { return c.FlagErrorFunc()(c, err) } - // If help is called, regardless of other flags, return we want help + + // If help is called, regardless of other flags, return we want help. // Also say we need help if the command isn't runnable. helpVal, err := c.Flags().GetBool("help") if err != nil { // should be impossible to get here as we always declare a help - // flag in initHelpFlag() + // flag in InitDefaultHelpFlag() c.Println("\"help\" flag declared as non-bool. Please correct your code") return err } @@ -732,10 +748,19 @@ func (c *Command) ExecuteC() (cmd *Command, err error) { return cmd, nil } -func (c *Command) initHelpFlag() { +// InitDefaultHelpFlag adds default help flag to c. +// It is called automatically by executing the c or by calling help and usage. +// If c already has help flag, it will do nothing. +func (c *Command) InitDefaultHelpFlag() { c.mergePersistentFlags() if c.Flags().Lookup("help") == nil { - c.Flags().BoolP("help", "h", false, "help for "+c.Name()) + usage := "help for " + if c.Name() == "" { + usage += "this command" + } else { + usage += c.Name() + } + c.Flags().BoolP("help", "h", false, usage) } } @@ -759,6 +784,7 @@ func (c *Command) initHelpCmd() { c.Printf("Unknown help topic %#q\n", args) c.Root().Usage() } else { + cmd.InitDefaultHelpFlag() // make possible 'help' flag to be shown cmd.Help() } }, @@ -862,34 +888,34 @@ func (c *Command) Print(i ...interface{}) { // Println is a convenience method to Println to the defined output, fallback to Stderr if not set. func (c *Command) Println(i ...interface{}) { - str := fmt.Sprintln(i...) - c.Print(str) + c.Print(fmt.Sprintln(i...)) } // Printf is a convenience method to Printf to the defined output, fallback to Stderr if not set. func (c *Command) Printf(format string, i ...interface{}) { - str := fmt.Sprintf(format, i...) - c.Print(str) + c.Print(fmt.Sprintf(format, i...)) } // CommandPath returns the full path to this command. func (c *Command) CommandPath() string { - str := c.Name() - x := c - for x.HasParent() { - str = x.parent.Name() + " " + str - x = x.parent + if c.HasParent() { + return c.Parent().CommandPath() + " " + c.Name() } - return str + return c.Name() } // UseLine puts out the full usage for a given command (including parents). func (c *Command) UseLine() string { - str := "" + var useline string if c.HasParent() { - str = c.parent.CommandPath() + " " + useline = c.parent.CommandPath() + " " + c.Use + } else { + useline = c.Use } - return str + c.Use + if c.HasAvailableFlags() && !strings.Contains(useline, "[flags]") { + useline += " [flags]" + } + return useline } // DebugFlags used to determine which flags have been assigned to which commands @@ -922,6 +948,7 @@ func (c *Command) DebugFlags() { } }) } + c.Println(x.flagErrorBuf) if x.HasSubCommands() { for _, y := range x.commands { debugflags(y) @@ -934,15 +961,14 @@ func (c *Command) DebugFlags() { // Name returns the command's name: the first word in the use line. func (c *Command) Name() string { - if c.name != "" { - return c.name + if c.name == "" { + name := c.Use + i := strings.Index(name, " ") + if i >= 0 { + name = name[:i] + } + c.name = name } - name := c.Use - i := strings.Index(name, " ") - if i >= 0 { - name = name[:i] - } - c.name = name return c.name } @@ -1062,7 +1088,10 @@ func (c *Command) GlobalNormalizationFunc() func(f *flag.FlagSet, name string) f func (c *Command) Flags() *flag.FlagSet { if c.flags == nil { c.flags = flag.NewFlagSet(c.Name(), flag.ContinueOnError) - c.flags.SetOutput(c.OutOrStderr()) + if c.flagErrorBuf == nil { + c.flagErrorBuf = new(bytes.Buffer) + } + c.flags.SetOutput(c.flagErrorBuf) } return c.flags @@ -1087,7 +1116,10 @@ func (c *Command) LocalFlags() *flag.FlagSet { if c.lflags == nil { c.lflags = flag.NewFlagSet(c.Name(), flag.ContinueOnError) - c.lflags.SetOutput(c.OutOrStderr()) + if c.flagErrorBuf == nil { + c.flagErrorBuf = new(bytes.Buffer) + } + c.lflags.SetOutput(c.flagErrorBuf) } c.lflags.SortFlags = c.Flags().SortFlags @@ -1107,6 +1139,10 @@ func (c *Command) InheritedFlags() *flag.FlagSet { if c.iflags == nil { c.iflags = flag.NewFlagSet(c.Name(), flag.ContinueOnError) + if c.flagErrorBuf == nil { + c.flagErrorBuf = new(bytes.Buffer) + } + c.iflags.SetOutput(c.flagErrorBuf) } local := c.LocalFlags() @@ -1127,17 +1163,22 @@ func (c *Command) NonInheritedFlags() *flag.FlagSet { func (c *Command) PersistentFlags() *flag.FlagSet { if c.pflags == nil { c.pflags = flag.NewFlagSet(c.Name(), flag.ContinueOnError) - c.pflags.SetOutput(c.OutOrStderr()) + if c.flagErrorBuf == nil { + c.flagErrorBuf = new(bytes.Buffer) + } + c.pflags.SetOutput(c.flagErrorBuf) } return c.pflags } // ResetFlags is used in testing. func (c *Command) ResetFlags() { + c.flagErrorBuf = new(bytes.Buffer) + c.flagErrorBuf.Reset() c.flags = flag.NewFlagSet(c.Name(), flag.ContinueOnError) - c.flags.SetOutput(c.OutOrStderr()) + c.flags.SetOutput(c.flagErrorBuf) c.pflags = flag.NewFlagSet(c.Name(), flag.ContinueOnError) - c.pflags.SetOutput(c.OutOrStderr()) + c.pflags.SetOutput(c.flagErrorBuf) } // HasFlags checks if the command contains any flags (local plus persistent from the entire structure). @@ -1225,8 +1266,8 @@ func (c *Command) Parent() *Command { // mergePersistentFlags merges c.PersistentFlags() to c.Flags() // and adds missing persistent flags of all parents. func (c *Command) mergePersistentFlags() { - c.Flags().AddFlagSet(c.PersistentFlags()) c.updateParentsPflags() + c.Flags().AddFlagSet(c.PersistentFlags()) c.Flags().AddFlagSet(c.parentsPflags) } @@ -1236,7 +1277,7 @@ func (c *Command) mergePersistentFlags() { func (c *Command) updateParentsPflags() { if c.parentsPflags == nil { c.parentsPflags = flag.NewFlagSet(c.Name(), flag.ContinueOnError) - c.parentsPflags.SetOutput(c.OutOrStderr()) + c.parentsPflags.SetOutput(c.flagErrorBuf) c.parentsPflags.SortFlags = false } diff --git a/vendor/github.com/spf13/jwalterweatherman/notepad.go b/vendor/github.com/spf13/jwalterweatherman/notepad.go index 5a623f48..28259034 100644 --- a/vendor/github.com/spf13/jwalterweatherman/notepad.go +++ b/vendor/github.com/spf13/jwalterweatherman/notepad.go @@ -96,13 +96,6 @@ func NewNotepad(outThreshold Threshold, logThreshold Threshold, outHandle, logHa return n } -// Feedback is special. It writes plainly to the output while -// logging with the standard extra information (date, file, etc) -// Only Println and Printf are currently provided for this -type Feedback struct { - *Notepad -} - // init create the loggers for each level depending on the notepad thresholds func (n *Notepad) init() { bothHandle := io.MultiWriter(n.outHandle, n.logHandle) @@ -177,19 +170,25 @@ func (n *Notepad) SetFlags(flags int) { } // Feedback is special. It writes plainly to the output while -// logging with the standard extra information (date, file, etc) -// Only Println and Printf are currently provided for this +// logging with the standard extra information (date, file, etc). +type Feedback struct { + *Notepad +} + func (fb *Feedback) Println(v ...interface{}) { s := fmt.Sprintln(v...) fmt.Print(s) fb.LOG.Output(2, s) } -// Feedback is special. It writes plainly to the output while -// logging with the standard extra information (date, file, etc) -// Only Println and Printf are currently provided for this func (fb *Feedback) Printf(format string, v ...interface{}) { s := fmt.Sprintf(format, v...) fmt.Print(s) fb.LOG.Output(2, s) } + +func (fb *Feedback) Print(v ...interface{}) { + s := fmt.Sprint(v...) + fmt.Print(s) + fb.LOG.Output(2, s) +} diff --git a/vendor/github.com/spf13/pflag/count.go b/vendor/github.com/spf13/pflag/count.go index d22be41f..250a4381 100644 --- a/vendor/github.com/spf13/pflag/count.go +++ b/vendor/github.com/spf13/pflag/count.go @@ -83,7 +83,9 @@ func (f *FlagSet) CountP(name, shorthand string, usage string) *int { return p } -// Count like Count only the flag is placed on the CommandLine isntead of a given flag set +// Count defines a count flag with specified name, default value, and usage string. +// The return value is the address of an int variable that stores the value of the flag. +// A count flag will add 1 to its value evey time it is found on the command line func Count(name string, usage string) *int { return CommandLine.CountP(name, "", usage) } diff --git a/vendor/github.com/spf13/pflag/flag.go b/vendor/github.com/spf13/pflag/flag.go index 0730bd63..6f1fc300 100644 --- a/vendor/github.com/spf13/pflag/flag.go +++ b/vendor/github.com/spf13/pflag/flag.go @@ -319,6 +319,22 @@ func (f *FlagSet) Lookup(name string) *Flag { return f.lookup(f.normalizeFlagName(name)) } +// ShorthandLookup returns the Flag structure of the short handed flag, +// returning nil if none exists. +// It panics, if len(name) > 1. +func (f *FlagSet) ShorthandLookup(name string) *Flag { + if name == "" { + return nil + } + if len(name) > 1 { + msg := fmt.Sprintf("can not look up shorthand which is more than one ASCII character: %q", name) + fmt.Fprintf(f.out(), msg) + panic(msg) + } + c := name[0] + return f.shorthands[c] +} + // lookup returns the Flag structure of the named flag, returning nil if none exists. func (f *FlagSet) lookup(name NormalizedName) *Flag { return f.formal[name] @@ -360,7 +376,7 @@ func (f *FlagSet) MarkDeprecated(name string, usageMessage string) error { if flag == nil { return fmt.Errorf("flag %q does not exist", name) } - if len(usageMessage) == 0 { + if usageMessage == "" { return fmt.Errorf("deprecated message for flag %q must be set", name) } flag.Deprecated = usageMessage @@ -375,7 +391,7 @@ func (f *FlagSet) MarkShorthandDeprecated(name string, usageMessage string) erro if flag == nil { return fmt.Errorf("flag %q does not exist", name) } - if len(usageMessage) == 0 { + if usageMessage == "" { return fmt.Errorf("deprecated message for flag %q must be set", name) } flag.ShorthandDeprecated = usageMessage @@ -399,6 +415,12 @@ func Lookup(name string) *Flag { return CommandLine.Lookup(name) } +// ShorthandLookup returns the Flag structure of the short handed flag, +// returning nil if none exists. +func ShorthandLookup(name string) *Flag { + return CommandLine.ShorthandLookup(name) +} + // Set sets the value of the named flag. func (f *FlagSet) Set(name, value string) error { normalName := f.normalizeFlagName(name) @@ -406,18 +428,28 @@ func (f *FlagSet) Set(name, value string) error { if !ok { return fmt.Errorf("no such flag -%v", name) } + err := flag.Value.Set(value) if err != nil { - return err + var flagName string + if flag.Shorthand != "" && flag.ShorthandDeprecated == "" { + flagName = fmt.Sprintf("-%s, --%s", flag.Shorthand, flag.Name) + } else { + flagName = fmt.Sprintf("--%s", flag.Name) + } + return fmt.Errorf("invalid argument %q for %q flag: %v", value, flagName, err) } + if f.actual == nil { f.actual = make(map[NormalizedName]*Flag) } f.actual[normalName] = flag f.orderedActual = append(f.orderedActual, flag) + flag.Changed = true - if len(flag.Deprecated) > 0 { - fmt.Fprintf(os.Stderr, "Flag --%s has been deprecated, %s\n", flag.Name, flag.Deprecated) + + if flag.Deprecated != "" { + fmt.Fprintf(f.out(), "Flag --%s has been deprecated, %s\n", flag.Name, flag.Deprecated) } return nil } @@ -599,28 +631,28 @@ func wrap(i, w int, s string) string { // for all flags in the FlagSet. Wrapped to `cols` columns (0 for no // wrapping) func (f *FlagSet) FlagUsagesWrapped(cols int) string { - x := new(bytes.Buffer) + buf := new(bytes.Buffer) lines := make([]string, 0, len(f.formal)) maxlen := 0 f.VisitAll(func(flag *Flag) { - if len(flag.Deprecated) > 0 || flag.Hidden { + if flag.Deprecated != "" || flag.Hidden { return } line := "" - if len(flag.Shorthand) > 0 && len(flag.ShorthandDeprecated) == 0 { + if flag.Shorthand != "" && flag.ShorthandDeprecated == "" { line = fmt.Sprintf(" -%s, --%s", flag.Shorthand, flag.Name) } else { line = fmt.Sprintf(" --%s", flag.Name) } varname, usage := UnquoteUsage(flag) - if len(varname) > 0 { + if varname != "" { line += " " + varname } - if len(flag.NoOptDefVal) > 0 { + if flag.NoOptDefVal != "" { switch flag.Value.Type() { case "string": line += fmt.Sprintf("[=\"%s\"]", flag.NoOptDefVal) @@ -656,10 +688,10 @@ func (f *FlagSet) FlagUsagesWrapped(cols int) string { sidx := strings.Index(line, "\x00") spacing := strings.Repeat(" ", maxlen-sidx) // maxlen + 2 comes from + 1 for the \x00 and + 1 for the (deliberate) off-by-one in maxlen-sidx - fmt.Fprintln(x, line[:sidx], spacing, wrap(maxlen+2, cols, line[sidx+1:])) + fmt.Fprintln(buf, line[:sidx], spacing, wrap(maxlen+2, cols, line[sidx+1:])) } - return x.String() + return buf.String() } // FlagUsages returns a string containing the usage information for all flags in @@ -756,11 +788,10 @@ func (f *FlagSet) VarP(value Value, name, shorthand, usage string) { // AddFlag will add the flag to the FlagSet func (f *FlagSet) AddFlag(flag *Flag) { - // Call normalizeFlagName function only once normalizedFlagName := f.normalizeFlagName(flag.Name) - _, alreadythere := f.formal[normalizedFlagName] - if alreadythere { + _, alreadyThere := f.formal[normalizedFlagName] + if alreadyThere { msg := fmt.Sprintf("%s flag redefined: %s", f.name, flag.Name) fmt.Fprintln(f.out(), msg) panic(msg) // Happens only if flags are declared with identical names @@ -773,27 +804,29 @@ func (f *FlagSet) AddFlag(flag *Flag) { f.formal[normalizedFlagName] = flag f.orderedFormal = append(f.orderedFormal, flag) - if len(flag.Shorthand) == 0 { + if flag.Shorthand == "" { return } if len(flag.Shorthand) > 1 { - fmt.Fprintf(f.out(), "%s shorthand more than ASCII character: %s\n", f.name, flag.Shorthand) - panic("shorthand is more than one character") + msg := fmt.Sprintf("%q shorthand is more than one ASCII character", flag.Shorthand) + fmt.Fprintf(f.out(), msg) + panic(msg) } if f.shorthands == nil { f.shorthands = make(map[byte]*Flag) } c := flag.Shorthand[0] - old, alreadythere := f.shorthands[c] - if alreadythere { - fmt.Fprintf(f.out(), "%s shorthand reused: %q for %s already used for %s\n", f.name, c, flag.Name, old.Name) - panic("shorthand redefinition") + used, alreadyThere := f.shorthands[c] + if alreadyThere { + msg := fmt.Sprintf("unable to redefine %q shorthand in %q flagset: it's already used for %q flag", c, f.name, used.Name) + fmt.Fprintf(f.out(), msg) + panic(msg) } f.shorthands[c] = flag } // AddFlagSet adds one FlagSet to another. If a flag is already present in f -// the flag from newSet will be ignored +// the flag from newSet will be ignored. func (f *FlagSet) AddFlagSet(newSet *FlagSet) { if newSet == nil { return @@ -841,35 +874,6 @@ func (f *FlagSet) usage() { } } -func (f *FlagSet) setFlag(flag *Flag, value string, origArg string) error { - if err := flag.Value.Set(value); err != nil { - return f.failf("invalid argument %q for %s: %v", value, origArg, err) - } - // mark as visited for Visit() - if f.actual == nil { - f.actual = make(map[NormalizedName]*Flag) - } - f.actual[f.normalizeFlagName(flag.Name)] = flag - f.orderedActual = append(f.orderedActual, flag) - flag.Changed = true - if len(flag.Deprecated) > 0 { - fmt.Fprintf(os.Stderr, "Flag --%s has been deprecated, %s\n", flag.Name, flag.Deprecated) - } - if len(flag.ShorthandDeprecated) > 0 && containsShorthand(origArg, flag.Shorthand) { - fmt.Fprintf(os.Stderr, "Flag shorthand -%s has been deprecated, %s\n", flag.Shorthand, flag.ShorthandDeprecated) - } - return nil -} - -func containsShorthand(arg, shorthand string) bool { - // filter out flags -- - if strings.HasPrefix(arg, "-") { - return false - } - arg = strings.SplitN(arg, "=", 2)[0] - return strings.Contains(arg, shorthand) -} - func (f *FlagSet) parseLongArg(s string, args []string, fn parseFunc) (a []string, err error) { a = args name := s[2:] @@ -877,10 +881,11 @@ func (f *FlagSet) parseLongArg(s string, args []string, fn parseFunc) (a []strin err = f.failf("bad flag syntax: %s", s) return } + split := strings.SplitN(name, "=", 2) name = split[0] - flag, alreadythere := f.formal[f.normalizeFlagName(name)] - if !alreadythere { + flag, exists := f.formal[f.normalizeFlagName(name)] + if !exists { if name == "help" { // special case for nice help message. f.usage() return a, ErrHelp @@ -888,11 +893,12 @@ func (f *FlagSet) parseLongArg(s string, args []string, fn parseFunc) (a []strin err = f.failf("unknown flag: --%s", name) return } + var value string if len(split) == 2 { // '--flag=arg' value = split[1] - } else if len(flag.NoOptDefVal) > 0 { + } else if flag.NoOptDefVal != "" { // '--flag' (arg was optional) value = flag.NoOptDefVal } else if len(a) > 0 { @@ -904,7 +910,8 @@ func (f *FlagSet) parseLongArg(s string, args []string, fn parseFunc) (a []strin err = f.failf("flag needs an argument: %s", s) return } - err = fn(flag, value, s) + + err = fn(flag, value) return } @@ -912,38 +919,49 @@ func (f *FlagSet) parseSingleShortArg(shorthands string, args []string, fn parse if strings.HasPrefix(shorthands, "test.") { return } + outArgs = args outShorts = shorthands[1:] c := shorthands[0] - flag, alreadythere := f.shorthands[c] - if !alreadythere { + flag, exists := f.shorthands[c] + if !exists { if c == 'h' { // special case for nice help message. f.usage() err = ErrHelp return } - //TODO continue on error err = f.failf("unknown shorthand flag: %q in -%s", c, shorthands) return } + var value string if len(shorthands) > 2 && shorthands[1] == '=' { + // '-f=arg' value = shorthands[2:] outShorts = "" - } else if len(flag.NoOptDefVal) > 0 { + } else if flag.NoOptDefVal != "" { + // '-f' (arg was optional) value = flag.NoOptDefVal } else if len(shorthands) > 1 { + // '-farg' value = shorthands[1:] outShorts = "" } else if len(args) > 0 { + // '-f arg' value = args[0] outArgs = args[1:] } else { + // '-f' (arg was required) err = f.failf("flag needs an argument: %q in -%s", c, shorthands) return } - err = fn(flag, value, shorthands) + + if flag.ShorthandDeprecated != "" { + fmt.Fprintf(f.out(), "Flag shorthand -%s has been deprecated, %s\n", flag.Shorthand, flag.ShorthandDeprecated) + } + + err = fn(flag, value) return } @@ -951,6 +969,7 @@ func (f *FlagSet) parseShortArg(s string, args []string, fn parseFunc) (a []stri a = args shorthands := s[1:] + // "shorthands" can be a series of shorthand letters of flags (e.g. "-vvv"). for len(shorthands) > 0 { shorthands, a, err = f.parseSingleShortArg(shorthands, args, fn) if err != nil { @@ -998,13 +1017,18 @@ func (f *FlagSet) parseArgs(args []string, fn parseFunc) (err error) { // The return value will be ErrHelp if -help was set but not defined. func (f *FlagSet) Parse(arguments []string) error { f.parsed = true - f.args = make([]string, 0, len(arguments)) - assign := func(flag *Flag, value, origArg string) error { - return f.setFlag(flag, value, origArg) + if len(arguments) < 0 { + return nil } - err := f.parseArgs(arguments, assign) + f.args = make([]string, 0, len(arguments)) + + set := func(flag *Flag, value string) error { + return f.Set(flag.Name, value) + } + + err := f.parseArgs(arguments, set) if err != nil { switch f.errorHandling { case ContinueOnError: @@ -1018,7 +1042,7 @@ func (f *FlagSet) Parse(arguments []string) error { return nil } -type parseFunc func(flag *Flag, value, origArg string) error +type parseFunc func(flag *Flag, value string) error // ParseAll parses flag definitions from the argument list, which should not // include the command name. The arguments for fn are flag and value. Must be @@ -1029,11 +1053,7 @@ func (f *FlagSet) ParseAll(arguments []string, fn func(flag *Flag, value string) f.parsed = true f.args = make([]string, 0, len(arguments)) - assign := func(flag *Flag, value, origArg string) error { - return fn(flag, value) - } - - err := f.parseArgs(arguments, assign) + err := f.parseArgs(arguments, fn) if err != nil { switch f.errorHandling { case ContinueOnError: diff --git a/vendor/github.com/xeipuuv/gojsonschema/errors.go b/vendor/github.com/xeipuuv/gojsonschema/errors.go index a541a737..d39f0195 100644 --- a/vendor/github.com/xeipuuv/gojsonschema/errors.go +++ b/vendor/github.com/xeipuuv/gojsonschema/errors.go @@ -237,6 +237,11 @@ func newError(err ResultError, context *jsonContext, value interface{}, locale l err.SetValue(value) err.SetDetails(details) details["field"] = err.Field() + + if _, exists := details["context"]; !exists && context != nil { + details["context"] = context.String() + } + err.SetDescription(formatErrorDescription(d, details)) } @@ -257,6 +262,10 @@ func formatErrorDescription(s string, details ErrorDetails) string { errorTemplates.Lock() tpl = errorTemplates.New(s) + if ErrorTemplateFuncs != nil { + tpl.Funcs(ErrorTemplateFuncs) + } + tpl, err = tpl.Parse(s) errorTemplates.Unlock() diff --git a/vendor/github.com/xeipuuv/gojsonschema/schema.go b/vendor/github.com/xeipuuv/gojsonschema/schema.go index cf3cbc7d..eeb5f31b 100644 --- a/vendor/github.com/xeipuuv/gojsonschema/schema.go +++ b/vendor/github.com/xeipuuv/gojsonschema/schema.go @@ -31,6 +31,7 @@ import ( "errors" "reflect" "regexp" + "text/template" "github.com/xeipuuv/gojsonreference" ) @@ -39,6 +40,9 @@ var ( // Locale is the default locale to use // Library users can overwrite with their own implementation Locale locale = DefaultLocale{} + + // ErrorTemplateFuncs allows you to define custom template funcs for use in localization. + ErrorTemplateFuncs template.FuncMap ) func NewSchema(l JSONLoader) (*Schema, error) { diff --git a/vendor/golang.org/x/sys/unix/asm_solaris_amd64.s b/vendor/golang.org/x/sys/unix/asm_solaris_amd64.s index 43ed17a0..ded8260f 100644 --- a/vendor/golang.org/x/sys/unix/asm_solaris_amd64.s +++ b/vendor/golang.org/x/sys/unix/asm_solaris_amd64.s @@ -10,8 +10,8 @@ // System calls for amd64, Solaris are implemented in runtime/syscall_solaris.go // -TEXT ·sysvicall6(SB),NOSPLIT,$0-64 +TEXT ·sysvicall6(SB),NOSPLIT,$0-88 JMP syscall·sysvicall6(SB) -TEXT ·rawSysvicall6(SB),NOSPLIT,$0-64 +TEXT ·rawSysvicall6(SB),NOSPLIT,$0-88 JMP syscall·rawSysvicall6(SB) diff --git a/vendor/golang.org/x/sys/unix/sockcmsg_unix.go b/vendor/golang.org/x/sys/unix/sockcmsg_unix.go index f1493a3e..bb756ece 100644 --- a/vendor/golang.org/x/sys/unix/sockcmsg_unix.go +++ b/vendor/golang.org/x/sys/unix/sockcmsg_unix.go @@ -1,4 +1,4 @@ -// Copyright 2011 The Go Authors. All rights reserved. +// Copyright 2011 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. @@ -13,9 +13,10 @@ import "unsafe" // Round the length of a raw sockaddr up to align it properly. func cmsgAlignOf(salen int) int { salign := sizeofPtr - // NOTE: It seems like 64-bit Darwin and DragonFly BSD kernels - // still require 32-bit aligned access to network subsystem. - if darwin64Bit || dragonfly64Bit { + // NOTE: It seems like 64-bit Darwin, DragonFly BSD and + // Solaris kernels still require 32-bit aligned access to + // network subsystem. + if darwin64Bit || dragonfly64Bit || solaris64Bit { salign = 4 } return (salen + salign - 1) & ^(salign - 1) diff --git a/vendor/golang.org/x/sys/unix/syscall_dragonfly.go b/vendor/golang.org/x/sys/unix/syscall_dragonfly.go index 3363456f..7e0210fc 100644 --- a/vendor/golang.org/x/sys/unix/syscall_dragonfly.go +++ b/vendor/golang.org/x/sys/unix/syscall_dragonfly.go @@ -1,8 +1,8 @@ -// Copyright 2009,2010 The Go Authors. All rights reserved. +// Copyright 2009 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// FreeBSD system calls. +// DragonFly BSD system calls. // This file is compiled as ordinary Go code, // but it is also input to mksyscall, // which parses the //sys lines and generates system call stubs. @@ -34,7 +34,7 @@ func nametomib(name string) (mib []_C_int, err error) { // NOTE(rsc): It seems strange to set the buffer to have // size CTL_MAXNAME+2 but use only CTL_MAXNAME - // as the size. I don't know why the +2 is here, but the + // as the size. I don't know why the +2 is here, but the // kernel uses +2 for its own implementation of this function. // I am scared that if we don't include the +2 here, the kernel // will silently write 2 words farther than we specify @@ -57,7 +57,7 @@ func nametomib(name string) (mib []_C_int, err error) { } func direntIno(buf []byte) (uint64, bool) { - return readInt(buf, unsafe.Offsetof(Dirent{}.Ino), unsafe.Sizeof(Dirent{}.Ino)) + return readInt(buf, unsafe.Offsetof(Dirent{}.Fileno), unsafe.Sizeof(Dirent{}.Fileno)) } func direntReclen(buf []byte) (uint64, bool) { @@ -65,7 +65,7 @@ func direntReclen(buf []byte) (uint64, bool) { if !ok { return 0, false } - return (16 + namlen + 1 + 7) & ^7, true + return (16 + namlen + 1 + 7) &^ 7, true } func direntNamlen(buf []byte) (uint64, bool) { @@ -92,6 +92,24 @@ func Pwrite(fd int, p []byte, offset int64) (n int, err error) { return extpwrite(fd, p, 0, offset) } +func Accept4(fd, flags int) (nfd int, sa Sockaddr, err error) { + var rsa RawSockaddrAny + var len _Socklen = SizeofSockaddrAny + nfd, err = accept4(fd, &rsa, &len, flags) + if err != nil { + return + } + if len > SizeofSockaddrAny { + panic("RawSockaddrAny too small") + } + sa, err = anyToSockaddr(&rsa) + if err != nil { + Close(nfd) + nfd = 0 + } + return +} + func Getfsstat(buf []Statfs_t, flags int) (n int, err error) { var _p0 unsafe.Pointer var bufsize uintptr @@ -199,6 +217,7 @@ func Getfsstat(buf []Statfs_t, flags int) (n int, err error) { //sys munmap(addr uintptr, length uintptr) (err error) //sys readlen(fd int, buf *byte, nbuf int) (n int, err error) = SYS_READ //sys writelen(fd int, buf *byte, nbuf int) (n int, err error) = SYS_WRITE +//sys accept4(fd int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (nfd int, err error) /* * Unimplemented @@ -234,6 +253,8 @@ func Getfsstat(buf []Statfs_t, flags int) (n int, err error) { // Kdebug_trace // Sigreturn // Mmap +// Mlock +// Munlock // Atsocket // Kqueue_from_portset_np // Kqueue_portset @@ -326,6 +347,8 @@ func Getfsstat(buf []Statfs_t, flags int) (n int, err error) { // Lio_listio // __pthread_cond_wait // Iopolicysys +// Mlockall +// Munlockall // __pthread_kill // __pthread_sigmask // __sigwait diff --git a/vendor/golang.org/x/sys/unix/syscall_linux.go b/vendor/golang.org/x/sys/unix/syscall_linux.go index 9737e08b..8c102bc7 100644 --- a/vendor/golang.org/x/sys/unix/syscall_linux.go +++ b/vendor/golang.org/x/sys/unix/syscall_linux.go @@ -1038,6 +1038,7 @@ func Mount(source string, target string, fstype string, flags uintptr, data stri //sys Chroot(path string) (err error) //sys ClockGettime(clockid int32, time *Timespec) (err error) //sys Close(fd int) (err error) +//sys CopyFileRange(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int, err error) //sys Dup(oldfd int) (fd int, err error) //sys Dup3(oldfd int, newfd int, flags int) (err error) //sysnb EpollCreate(size int) (fd int, err error) diff --git a/vendor/golang.org/x/sys/unix/syscall_linux_mips64x.go b/vendor/golang.org/x/sys/unix/syscall_linux_mips64x.go index 8119fde3..73318e5c 100644 --- a/vendor/golang.org/x/sys/unix/syscall_linux_mips64x.go +++ b/vendor/golang.org/x/sys/unix/syscall_linux_mips64x.go @@ -7,6 +7,7 @@ package unix +//sys Dup2(oldfd int, newfd int) (err error) //sys EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) //sys Fchown(fd int, uid int, gid int) (err error) //sys Fstatfs(fd int, buf *Statfs_t) (err error) @@ -182,9 +183,9 @@ func fillStat_t(s *Stat_t, st *stat_t) { s.Blocks = st.Blocks } -func (r *PtraceRegs) PC() uint64 { return r.Regs[64] } +func (r *PtraceRegs) PC() uint64 { return r.Epc } -func (r *PtraceRegs) SetPC(pc uint64) { r.Regs[64] = pc } +func (r *PtraceRegs) SetPC(pc uint64) { r.Epc = pc } func (iov *Iovec) SetLen(length int) { iov.Len = uint64(length) diff --git a/vendor/golang.org/x/sys/unix/syscall_linux_mipsx.go b/vendor/golang.org/x/sys/unix/syscall_linux_mipsx.go index be77d24a..b83d93fd 100644 --- a/vendor/golang.org/x/sys/unix/syscall_linux_mipsx.go +++ b/vendor/golang.org/x/sys/unix/syscall_linux_mipsx.go @@ -211,9 +211,9 @@ func Setrlimit(resource int, rlim *Rlimit) (err error) { return setrlimit(resource, &rl) } -func (r *PtraceRegs) PC() uint64 { return uint64(r.Regs[64]) } +func (r *PtraceRegs) PC() uint64 { return r.Epc } -func (r *PtraceRegs) SetPC(pc uint64) { r.Regs[64] = uint32(pc) } +func (r *PtraceRegs) SetPC(pc uint64) { r.Epc = pc } func (iov *Iovec) SetLen(length int) { iov.Len = uint32(length) diff --git a/vendor/golang.org/x/sys/unix/syscall_solaris.go b/vendor/golang.org/x/sys/unix/syscall_solaris.go index 3cb1d0bf..cab9b4fb 100644 --- a/vendor/golang.org/x/sys/unix/syscall_solaris.go +++ b/vendor/golang.org/x/sys/unix/syscall_solaris.go @@ -422,7 +422,7 @@ func Accept(fd int) (nfd int, sa Sockaddr, err error) { return } -//sys recvmsg(s int, msg *Msghdr, flags int) (n int, err error) = libsocket.recvmsg +//sys recvmsg(s int, msg *Msghdr, flags int) (n int, err error) = libsocket.__xnet_recvmsg func Recvmsg(fd int, p, oob []byte, flags int) (n, oobn int, recvflags int, from Sockaddr, err error) { var msg Msghdr @@ -441,7 +441,7 @@ func Recvmsg(fd int, p, oob []byte, flags int) (n, oobn int, recvflags int, from iov.Base = &dummy iov.SetLen(1) } - msg.Accrights = (*int8)(unsafe.Pointer(&oob[0])) + msg.Accrightslen = int32(len(oob)) } msg.Iov = &iov msg.Iovlen = 1 @@ -461,7 +461,7 @@ func Sendmsg(fd int, p, oob []byte, to Sockaddr, flags int) (err error) { return } -//sys sendmsg(s int, msg *Msghdr, flags int) (n int, err error) = libsocket.sendmsg +//sys sendmsg(s int, msg *Msghdr, flags int) (n int, err error) = libsocket.__xnet_sendmsg func SendmsgN(fd int, p, oob []byte, to Sockaddr, flags int) (n int, err error) { var ptr unsafe.Pointer @@ -487,7 +487,7 @@ func SendmsgN(fd int, p, oob []byte, to Sockaddr, flags int) (n int, err error) iov.Base = &dummy iov.SetLen(1) } - msg.Accrights = (*int8)(unsafe.Pointer(&oob[0])) + msg.Accrightslen = int32(len(oob)) } msg.Iov = &iov msg.Iovlen = 1 @@ -583,6 +583,7 @@ func IoctlGetTermio(fd int, req int) (*Termio, error) { //sys Fdatasync(fd int) (err error) //sys Fpathconf(fd int, name int) (val int, err error) //sys Fstat(fd int, stat *Stat_t) (err error) +//sys Fstatvfs(fd int, vfsstat *Statvfs_t) (err error) //sys Getdents(fd int, buf []byte, basep *uintptr) (n int, err error) //sysnb Getgid() (gid int) //sysnb Getpid() (pid int) @@ -599,7 +600,7 @@ func IoctlGetTermio(fd int, req int) (*Termio, error) { //sys Kill(pid int, signum syscall.Signal) (err error) //sys Lchown(path string, uid int, gid int) (err error) //sys Link(path string, link string) (err error) -//sys Listen(s int, backlog int) (err error) = libsocket.listen +//sys Listen(s int, backlog int) (err error) = libsocket.__xnet_llisten //sys Lstat(path string, stat *Stat_t) (err error) //sys Madvise(b []byte, advice int) (err error) //sys Mkdir(path string, mode uint32) (err error) @@ -639,6 +640,7 @@ func IoctlGetTermio(fd int, req int) (*Termio, error) { //sysnb Setuid(uid int) (err error) //sys Shutdown(s int, how int) (err error) = libsocket.shutdown //sys Stat(path string, stat *Stat_t) (err error) +//sys Statvfs(path string, vfsstat *Statvfs_t) (err error) //sys Symlink(path string, link string) (err error) //sys Sync() (err error) //sysnb Times(tms *Tms) (ticks uintptr, err error) @@ -652,15 +654,15 @@ func IoctlGetTermio(fd int, req int) (*Termio, error) { //sys Unlinkat(dirfd int, path string, flags int) (err error) //sys Ustat(dev int, ubuf *Ustat_t) (err error) //sys Utime(path string, buf *Utimbuf) (err error) -//sys bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) = libsocket.bind -//sys connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) = libsocket.connect +//sys bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) = libsocket.__xnet_bind +//sys connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) = libsocket.__xnet_connect //sys mmap(addr uintptr, length uintptr, prot int, flag int, fd int, pos int64) (ret uintptr, err error) //sys munmap(addr uintptr, length uintptr) (err error) -//sys sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error) = libsocket.sendto -//sys socket(domain int, typ int, proto int) (fd int, err error) = libsocket.socket -//sysnb socketpair(domain int, typ int, proto int, fd *[2]int32) (err error) = libsocket.socketpair +//sys sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error) = libsocket.__xnet_sendto +//sys socket(domain int, typ int, proto int) (fd int, err error) = libsocket.__xnet_socket +//sysnb socketpair(domain int, typ int, proto int, fd *[2]int32) (err error) = libsocket.__xnet_socketpair //sys write(fd int, p []byte) (n int, err error) -//sys getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error) = libsocket.getsockopt +//sys getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error) = libsocket.__xnet_getsockopt //sysnb getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) = libsocket.getpeername //sys setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error) = libsocket.setsockopt //sys recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error) = libsocket.recvfrom diff --git a/vendor/golang.org/x/sys/unix/syscall_unix.go b/vendor/golang.org/x/sys/unix/syscall_unix.go index 8a5237de..3ed8a91f 100644 --- a/vendor/golang.org/x/sys/unix/syscall_unix.go +++ b/vendor/golang.org/x/sys/unix/syscall_unix.go @@ -23,6 +23,7 @@ const ( darwin64Bit = runtime.GOOS == "darwin" && sizeofPtr == 8 dragonfly64Bit = runtime.GOOS == "dragonfly" && sizeofPtr == 8 netbsd32Bit = runtime.GOOS == "netbsd" && sizeofPtr == 4 + solaris64Bit = runtime.GOOS == "solaris" && sizeofPtr == 8 ) // Do the interface allocations only once for common diff --git a/vendor/golang.org/x/sys/unix/types_solaris.go b/vendor/golang.org/x/sys/unix/types_solaris.go index 69bf1bc4..393c7f04 100644 --- a/vendor/golang.org/x/sys/unix/types_solaris.go +++ b/vendor/golang.org/x/sys/unix/types_solaris.go @@ -37,6 +37,7 @@ package unix #include #include #include +#include #include #include #include @@ -139,6 +140,12 @@ type Flock_t C.struct_flock type Dirent C.struct_dirent +// Filesystems + +type _Fsblkcnt_t C.fsblkcnt_t + +type Statvfs_t C.struct_statvfs + // Sockets type RawSockaddrInet4 C.struct_sockaddr_in diff --git a/vendor/golang.org/x/sys/unix/zerrors_dragonfly_amd64.go b/vendor/golang.org/x/sys/unix/zerrors_dragonfly_amd64.go index 0feceee1..8f40598b 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_dragonfly_amd64.go +++ b/vendor/golang.org/x/sys/unix/zerrors_dragonfly_amd64.go @@ -1,5 +1,5 @@ // mkerrors.sh -m64 -// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT +// Code generated by the command above; see README.md. DO NOT EDIT. // +build amd64,dragonfly @@ -37,8 +37,8 @@ const ( AF_MAX = 0x24 AF_MPLS = 0x22 AF_NATM = 0x1d + AF_NETBIOS = 0x6 AF_NETGRAPH = 0x20 - AF_NS = 0x6 AF_OSI = 0x7 AF_PUP = 0x4 AF_ROUTE = 0x11 @@ -46,6 +46,7 @@ const ( AF_SNA = 0xb AF_UNIX = 0x1 AF_UNSPEC = 0x0 + ALTWERASE = 0x200 B0 = 0x0 B110 = 0x6e B115200 = 0x1c200 @@ -141,7 +142,22 @@ const ( BRKINT = 0x2 CFLUSH = 0xf CLOCAL = 0x8000 + CLOCK_MONOTONIC = 0x4 + CLOCK_MONOTONIC_FAST = 0xc + CLOCK_MONOTONIC_PRECISE = 0xb + CLOCK_PROCESS_CPUTIME_ID = 0xf + CLOCK_PROF = 0x2 + CLOCK_REALTIME = 0x0 + CLOCK_REALTIME_FAST = 0xa + CLOCK_REALTIME_PRECISE = 0x9 + CLOCK_SECOND = 0xd + CLOCK_THREAD_CPUTIME_ID = 0xe + CLOCK_UPTIME = 0x5 + CLOCK_UPTIME_FAST = 0x8 + CLOCK_UPTIME_PRECISE = 0x7 + CLOCK_VIRTUAL = 0x1 CREAD = 0x800 + CRTSCTS = 0x30000 CS5 = 0x0 CS6 = 0x100 CS7 = 0x200 @@ -286,24 +302,28 @@ const ( ECHOPRT = 0x20 EVFILT_AIO = -0x3 EVFILT_EXCEPT = -0x8 + EVFILT_FS = -0xa EVFILT_MARKER = 0xf EVFILT_PROC = -0x5 EVFILT_READ = -0x1 EVFILT_SIGNAL = -0x6 - EVFILT_SYSCOUNT = 0x8 + EVFILT_SYSCOUNT = 0xa EVFILT_TIMER = -0x7 + EVFILT_USER = -0x9 EVFILT_VNODE = -0x4 EVFILT_WRITE = -0x2 EV_ADD = 0x1 EV_CLEAR = 0x20 EV_DELETE = 0x2 EV_DISABLE = 0x8 + EV_DISPATCH = 0x80 EV_ENABLE = 0x4 EV_EOF = 0x8000 EV_ERROR = 0x4000 EV_FLAG1 = 0x2000 EV_NODATA = 0x1000 EV_ONESHOT = 0x10 + EV_RECEIPT = 0x40 EV_SYSFLAGS = 0xf000 EXTA = 0x4b00 EXTB = 0x9600 @@ -679,7 +699,6 @@ const ( IPPROTO_SATEXPAK = 0x40 IPPROTO_SATMON = 0x45 IPPROTO_SCCSP = 0x60 - IPPROTO_SCTP = 0x84 IPPROTO_SDRP = 0x2a IPPROTO_SEP = 0x21 IPPROTO_SKIP = 0x39 @@ -730,6 +749,7 @@ const ( IPV6_LEAVE_GROUP = 0xd IPV6_MAXHLIM = 0xff IPV6_MAXPACKET = 0xffff + IPV6_MINHLIM = 0x28 IPV6_MMTU = 0x500 IPV6_MSFILTER = 0x4a IPV6_MULTICAST_HOPS = 0xa @@ -778,6 +798,7 @@ const ( IP_FW_FLUSH = 0x34 IP_FW_GET = 0x36 IP_FW_RESETLOG = 0x37 + IP_FW_X = 0x31 IP_FW_ZERO = 0x35 IP_HDRINCL = 0x2 IP_IPSEC_POLICY = 0x15 @@ -833,6 +854,7 @@ const ( MADV_SETMAP = 0xb MADV_WILLNEED = 0x3 MAP_ANON = 0x1000 + MAP_ANONYMOUS = 0x1000 MAP_COPY = 0x2 MAP_FILE = 0x0 MAP_FIXED = 0x10 @@ -851,6 +873,7 @@ const ( MAP_VPAGETABLE = 0x2000 MCL_CURRENT = 0x1 MCL_FUTURE = 0x2 + MSG_CMSG_CLOEXEC = 0x1000 MSG_CTRUNC = 0x20 MSG_DONTROUTE = 0x4 MSG_DONTWAIT = 0x80 @@ -860,11 +883,11 @@ const ( MSG_FMASK = 0xffff0000 MSG_FNONBLOCKING = 0x20000 MSG_NOSIGNAL = 0x400 - MSG_NOTIFICATION = 0x200 MSG_OOB = 0x1 MSG_PEEK = 0x2 MSG_SYNC = 0x800 MSG_TRUNC = 0x10 + MSG_UNUSED09 = 0x200 MSG_WAITALL = 0x40 MS_ASYNC = 0x1 MS_INVALIDATE = 0x2 @@ -875,12 +898,19 @@ const ( NET_RT_IFLIST = 0x3 NET_RT_MAXID = 0x4 NOFLSH = 0x80000000 + NOKERNINFO = 0x2000000 NOTE_ATTRIB = 0x8 NOTE_CHILD = 0x4 NOTE_DELETE = 0x1 NOTE_EXEC = 0x20000000 NOTE_EXIT = 0x80000000 NOTE_EXTEND = 0x4 + NOTE_FFAND = 0x40000000 + NOTE_FFCOPY = 0xc0000000 + NOTE_FFCTRLMASK = 0xc0000000 + NOTE_FFLAGSMASK = 0xffffff + NOTE_FFNOP = 0x0 + NOTE_FFOR = 0x80000000 NOTE_FORK = 0x40000000 NOTE_LINK = 0x10 NOTE_LOWAT = 0x1 @@ -891,6 +921,7 @@ const ( NOTE_REVOKE = 0x40 NOTE_TRACK = 0x1 NOTE_TRACKERR = 0x2 + NOTE_TRIGGER = 0x1000000 NOTE_WRITE = 0x2 OCRNL = 0x10 ONLCR = 0x2 @@ -898,6 +929,7 @@ const ( ONOCR = 0x20 ONOEOT = 0x8 OPOST = 0x1 + OXTABS = 0x4 O_ACCMODE = 0x3 O_APPEND = 0x8 O_ASYNC = 0x40 @@ -910,14 +942,11 @@ const ( O_FAPPEND = 0x100000 O_FASYNCWRITE = 0x800000 O_FBLOCKING = 0x40000 - O_FBUFFERED = 0x2000000 - O_FMASK = 0x7fc0000 + O_FMASK = 0xfc0000 O_FNONBLOCKING = 0x80000 O_FOFFSET = 0x200000 O_FSYNC = 0x80 O_FSYNCWRITE = 0x400000 - O_FUNBUFFERED = 0x1000000 - O_MAPONREAD = 0x4000000 O_NDELAY = 0x4 O_NOCTTY = 0x8000 O_NOFOLLOW = 0x100 @@ -1096,8 +1125,10 @@ const ( SIOCSLIFPHYADDR = 0x8118694a SIOCSLOWAT = 0x80047302 SIOCSPGRP = 0x80047308 + SOCK_CLOEXEC = 0x10000000 SOCK_DGRAM = 0x2 SOCK_MAXADDRLEN = 0xff + SOCK_NONBLOCK = 0x20000000 SOCK_RAW = 0x3 SOCK_RDM = 0x4 SOCK_SEQPACKET = 0x5 @@ -1107,6 +1138,7 @@ const ( SO_ACCEPTCONN = 0x2 SO_ACCEPTFILTER = 0x1000 SO_BROADCAST = 0x20 + SO_CPUHINT = 0x1030 SO_DEBUG = 0x1 SO_DONTROUTE = 0x10 SO_ERROR = 0x1007 @@ -1127,8 +1159,12 @@ const ( SO_TYPE = 0x1008 SO_USELOOPBACK = 0x40 TCIFLUSH = 0x1 + TCIOFF = 0x3 TCIOFLUSH = 0x3 + TCION = 0x4 TCOFLUSH = 0x2 + TCOOFF = 0x1 + TCOON = 0x2 TCP_FASTKEEP = 0x80 TCP_KEEPCNT = 0x400 TCP_KEEPIDLE = 0x100 @@ -1227,6 +1263,8 @@ const ( VKILL = 0x5 VLNEXT = 0xe VMIN = 0x10 + VM_BCACHE_SIZE_MAX = 0x0 + VM_SWZONE_SIZE_MAX = 0x4000000000 VQUIT = 0x9 VREPRINT = 0x6 VSTART = 0xc diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_386.go b/vendor/golang.org/x/sys/unix/zerrors_linux_386.go index 14a56e03..341bdfc9 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_386.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_386.go @@ -168,6 +168,7 @@ const ( BLKFRASET = 0x1264 BLKGETSIZE = 0x1260 BLKGETSIZE64 = 0x80041272 + BLKPBSZGET = 0x127b BLKRAGET = 0x1263 BLKRASET = 0x1262 BLKROGET = 0x125e @@ -449,6 +450,24 @@ const ( FF1 = 0x8000 FFDLY = 0x8000 FLUSHO = 0x1000 + FS_ENCRYPTION_MODE_AES_256_CBC = 0x3 + FS_ENCRYPTION_MODE_AES_256_CTS = 0x4 + FS_ENCRYPTION_MODE_AES_256_GCM = 0x2 + FS_ENCRYPTION_MODE_AES_256_XTS = 0x1 + FS_ENCRYPTION_MODE_INVALID = 0x0 + FS_IOC_GET_ENCRYPTION_POLICY = 0x400c6615 + FS_IOC_GET_ENCRYPTION_PWSALT = 0x40106614 + FS_IOC_SET_ENCRYPTION_POLICY = 0x800c6613 + FS_KEY_DESCRIPTOR_SIZE = 0x8 + FS_KEY_DESC_PREFIX = "fscrypt:" + FS_KEY_DESC_PREFIX_SIZE = 0x8 + FS_MAX_KEY_SIZE = 0x40 + FS_POLICY_FLAGS_PAD_16 = 0x2 + FS_POLICY_FLAGS_PAD_32 = 0x3 + FS_POLICY_FLAGS_PAD_4 = 0x0 + FS_POLICY_FLAGS_PAD_8 = 0x1 + FS_POLICY_FLAGS_PAD_MASK = 0x3 + FS_POLICY_FLAGS_VALID = 0x3 F_DUPFD = 0x0 F_DUPFD_CLOEXEC = 0x406 F_EXLCK = 0x4 @@ -810,6 +829,7 @@ const ( MS_ACTIVE = 0x40000000 MS_ASYNC = 0x1 MS_BIND = 0x1000 + MS_BORN = 0x20000000 MS_DIRSYNC = 0x80 MS_INVALIDATE = 0x2 MS_I_VERSION = 0x800000 @@ -823,6 +843,8 @@ const ( MS_NODEV = 0x4 MS_NODIRATIME = 0x800 MS_NOEXEC = 0x8 + MS_NOREMOTELOCK = 0x8000000 + MS_NOSEC = 0x10000000 MS_NOSUID = 0x2 MS_NOUSER = -0x80000000 MS_POSIXACL = 0x10000 @@ -839,6 +861,7 @@ const ( MS_SYNC = 0x4 MS_SYNCHRONOUS = 0x10 MS_UNBINDABLE = 0x20000 + MS_VERBOSE = 0x8000 NAME_MAX = 0xff NETLINK_ADD_MEMBERSHIP = 0x1 NETLINK_AUDIT = 0x9 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_amd64.go b/vendor/golang.org/x/sys/unix/zerrors_linux_amd64.go index bc7ecee8..f636a396 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_amd64.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_amd64.go @@ -168,6 +168,7 @@ const ( BLKFRASET = 0x1264 BLKGETSIZE = 0x1260 BLKGETSIZE64 = 0x80081272 + BLKPBSZGET = 0x127b BLKRAGET = 0x1263 BLKRASET = 0x1262 BLKROGET = 0x125e @@ -449,6 +450,24 @@ const ( FF1 = 0x8000 FFDLY = 0x8000 FLUSHO = 0x1000 + FS_ENCRYPTION_MODE_AES_256_CBC = 0x3 + FS_ENCRYPTION_MODE_AES_256_CTS = 0x4 + FS_ENCRYPTION_MODE_AES_256_GCM = 0x2 + FS_ENCRYPTION_MODE_AES_256_XTS = 0x1 + FS_ENCRYPTION_MODE_INVALID = 0x0 + FS_IOC_GET_ENCRYPTION_POLICY = 0x400c6615 + FS_IOC_GET_ENCRYPTION_PWSALT = 0x40106614 + FS_IOC_SET_ENCRYPTION_POLICY = 0x800c6613 + FS_KEY_DESCRIPTOR_SIZE = 0x8 + FS_KEY_DESC_PREFIX = "fscrypt:" + FS_KEY_DESC_PREFIX_SIZE = 0x8 + FS_MAX_KEY_SIZE = 0x40 + FS_POLICY_FLAGS_PAD_16 = 0x2 + FS_POLICY_FLAGS_PAD_32 = 0x3 + FS_POLICY_FLAGS_PAD_4 = 0x0 + FS_POLICY_FLAGS_PAD_8 = 0x1 + FS_POLICY_FLAGS_PAD_MASK = 0x3 + FS_POLICY_FLAGS_VALID = 0x3 F_DUPFD = 0x0 F_DUPFD_CLOEXEC = 0x406 F_EXLCK = 0x4 @@ -810,6 +829,7 @@ const ( MS_ACTIVE = 0x40000000 MS_ASYNC = 0x1 MS_BIND = 0x1000 + MS_BORN = 0x20000000 MS_DIRSYNC = 0x80 MS_INVALIDATE = 0x2 MS_I_VERSION = 0x800000 @@ -823,6 +843,8 @@ const ( MS_NODEV = 0x4 MS_NODIRATIME = 0x800 MS_NOEXEC = 0x8 + MS_NOREMOTELOCK = 0x8000000 + MS_NOSEC = 0x10000000 MS_NOSUID = 0x2 MS_NOUSER = -0x80000000 MS_POSIXACL = 0x10000 @@ -839,6 +861,7 @@ const ( MS_SYNC = 0x4 MS_SYNCHRONOUS = 0x10 MS_UNBINDABLE = 0x20000 + MS_VERBOSE = 0x8000 NAME_MAX = 0xff NETLINK_ADD_MEMBERSHIP = 0x1 NETLINK_AUDIT = 0x9 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_arm.go b/vendor/golang.org/x/sys/unix/zerrors_linux_arm.go index 189e1e91..986a9473 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_arm.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_arm.go @@ -168,6 +168,7 @@ const ( BLKFRASET = 0x1264 BLKGETSIZE = 0x1260 BLKGETSIZE64 = 0x80041272 + BLKPBSZGET = 0x127b BLKRAGET = 0x1263 BLKRASET = 0x1262 BLKROGET = 0x125e @@ -449,6 +450,24 @@ const ( FF1 = 0x8000 FFDLY = 0x8000 FLUSHO = 0x1000 + FS_ENCRYPTION_MODE_AES_256_CBC = 0x3 + FS_ENCRYPTION_MODE_AES_256_CTS = 0x4 + FS_ENCRYPTION_MODE_AES_256_GCM = 0x2 + FS_ENCRYPTION_MODE_AES_256_XTS = 0x1 + FS_ENCRYPTION_MODE_INVALID = 0x0 + FS_IOC_GET_ENCRYPTION_POLICY = 0x400c6615 + FS_IOC_GET_ENCRYPTION_PWSALT = 0x40106614 + FS_IOC_SET_ENCRYPTION_POLICY = 0x800c6613 + FS_KEY_DESCRIPTOR_SIZE = 0x8 + FS_KEY_DESC_PREFIX = "fscrypt:" + FS_KEY_DESC_PREFIX_SIZE = 0x8 + FS_MAX_KEY_SIZE = 0x40 + FS_POLICY_FLAGS_PAD_16 = 0x2 + FS_POLICY_FLAGS_PAD_32 = 0x3 + FS_POLICY_FLAGS_PAD_4 = 0x0 + FS_POLICY_FLAGS_PAD_8 = 0x1 + FS_POLICY_FLAGS_PAD_MASK = 0x3 + FS_POLICY_FLAGS_VALID = 0x3 F_DUPFD = 0x0 F_DUPFD_CLOEXEC = 0x406 F_EXLCK = 0x4 @@ -809,6 +828,7 @@ const ( MS_ACTIVE = 0x40000000 MS_ASYNC = 0x1 MS_BIND = 0x1000 + MS_BORN = 0x20000000 MS_DIRSYNC = 0x80 MS_INVALIDATE = 0x2 MS_I_VERSION = 0x800000 @@ -822,6 +842,8 @@ const ( MS_NODEV = 0x4 MS_NODIRATIME = 0x800 MS_NOEXEC = 0x8 + MS_NOREMOTELOCK = 0x8000000 + MS_NOSEC = 0x10000000 MS_NOSUID = 0x2 MS_NOUSER = -0x80000000 MS_POSIXACL = 0x10000 @@ -838,6 +860,7 @@ const ( MS_SYNC = 0x4 MS_SYNCHRONOUS = 0x10 MS_UNBINDABLE = 0x20000 + MS_VERBOSE = 0x8000 NAME_MAX = 0xff NETLINK_ADD_MEMBERSHIP = 0x1 NETLINK_AUDIT = 0x9 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_arm64.go b/vendor/golang.org/x/sys/unix/zerrors_linux_arm64.go index ed41e120..b72a6453 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_arm64.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_arm64.go @@ -168,6 +168,7 @@ const ( BLKFRASET = 0x1264 BLKGETSIZE = 0x1260 BLKGETSIZE64 = 0x80081272 + BLKPBSZGET = 0x127b BLKRAGET = 0x1263 BLKRASET = 0x1262 BLKROGET = 0x125e @@ -450,6 +451,24 @@ const ( FF1 = 0x8000 FFDLY = 0x8000 FLUSHO = 0x1000 + FS_ENCRYPTION_MODE_AES_256_CBC = 0x3 + FS_ENCRYPTION_MODE_AES_256_CTS = 0x4 + FS_ENCRYPTION_MODE_AES_256_GCM = 0x2 + FS_ENCRYPTION_MODE_AES_256_XTS = 0x1 + FS_ENCRYPTION_MODE_INVALID = 0x0 + FS_IOC_GET_ENCRYPTION_POLICY = 0x400c6615 + FS_IOC_GET_ENCRYPTION_PWSALT = 0x40106614 + FS_IOC_SET_ENCRYPTION_POLICY = 0x800c6613 + FS_KEY_DESCRIPTOR_SIZE = 0x8 + FS_KEY_DESC_PREFIX = "fscrypt:" + FS_KEY_DESC_PREFIX_SIZE = 0x8 + FS_MAX_KEY_SIZE = 0x40 + FS_POLICY_FLAGS_PAD_16 = 0x2 + FS_POLICY_FLAGS_PAD_32 = 0x3 + FS_POLICY_FLAGS_PAD_4 = 0x0 + FS_POLICY_FLAGS_PAD_8 = 0x1 + FS_POLICY_FLAGS_PAD_MASK = 0x3 + FS_POLICY_FLAGS_VALID = 0x3 F_DUPFD = 0x0 F_DUPFD_CLOEXEC = 0x406 F_EXLCK = 0x4 @@ -810,6 +829,7 @@ const ( MS_ACTIVE = 0x40000000 MS_ASYNC = 0x1 MS_BIND = 0x1000 + MS_BORN = 0x20000000 MS_DIRSYNC = 0x80 MS_INVALIDATE = 0x2 MS_I_VERSION = 0x800000 @@ -823,6 +843,8 @@ const ( MS_NODEV = 0x4 MS_NODIRATIME = 0x800 MS_NOEXEC = 0x8 + MS_NOREMOTELOCK = 0x8000000 + MS_NOSEC = 0x10000000 MS_NOSUID = 0x2 MS_NOUSER = -0x80000000 MS_POSIXACL = 0x10000 @@ -839,6 +861,7 @@ const ( MS_SYNC = 0x4 MS_SYNCHRONOUS = 0x10 MS_UNBINDABLE = 0x20000 + MS_VERBOSE = 0x8000 NAME_MAX = 0xff NETLINK_ADD_MEMBERSHIP = 0x1 NETLINK_AUDIT = 0x9 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_mips.go b/vendor/golang.org/x/sys/unix/zerrors_linux_mips.go index e1af3af4..198a3054 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_mips.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_mips.go @@ -168,6 +168,7 @@ const ( BLKFRASET = 0x20001264 BLKGETSIZE = 0x20001260 BLKGETSIZE64 = 0x40041272 + BLKPBSZGET = 0x2000127b BLKRAGET = 0x20001263 BLKRASET = 0x20001262 BLKROGET = 0x2000125e @@ -449,6 +450,24 @@ const ( FF1 = 0x8000 FFDLY = 0x8000 FLUSHO = 0x2000 + FS_ENCRYPTION_MODE_AES_256_CBC = 0x3 + FS_ENCRYPTION_MODE_AES_256_CTS = 0x4 + FS_ENCRYPTION_MODE_AES_256_GCM = 0x2 + FS_ENCRYPTION_MODE_AES_256_XTS = 0x1 + FS_ENCRYPTION_MODE_INVALID = 0x0 + FS_IOC_GET_ENCRYPTION_POLICY = 0x800c6615 + FS_IOC_GET_ENCRYPTION_PWSALT = 0x80106614 + FS_IOC_SET_ENCRYPTION_POLICY = 0x400c6613 + FS_KEY_DESCRIPTOR_SIZE = 0x8 + FS_KEY_DESC_PREFIX = "fscrypt:" + FS_KEY_DESC_PREFIX_SIZE = 0x8 + FS_MAX_KEY_SIZE = 0x40 + FS_POLICY_FLAGS_PAD_16 = 0x2 + FS_POLICY_FLAGS_PAD_32 = 0x3 + FS_POLICY_FLAGS_PAD_4 = 0x0 + FS_POLICY_FLAGS_PAD_8 = 0x1 + FS_POLICY_FLAGS_PAD_MASK = 0x3 + FS_POLICY_FLAGS_VALID = 0x3 F_DUPFD = 0x0 F_DUPFD_CLOEXEC = 0x406 F_EXLCK = 0x4 @@ -810,6 +829,7 @@ const ( MS_ACTIVE = 0x40000000 MS_ASYNC = 0x1 MS_BIND = 0x1000 + MS_BORN = 0x20000000 MS_DIRSYNC = 0x80 MS_INVALIDATE = 0x2 MS_I_VERSION = 0x800000 @@ -823,6 +843,8 @@ const ( MS_NODEV = 0x4 MS_NODIRATIME = 0x800 MS_NOEXEC = 0x8 + MS_NOREMOTELOCK = 0x8000000 + MS_NOSEC = 0x10000000 MS_NOSUID = 0x2 MS_NOUSER = -0x80000000 MS_POSIXACL = 0x10000 @@ -839,6 +861,7 @@ const ( MS_SYNC = 0x4 MS_SYNCHRONOUS = 0x10 MS_UNBINDABLE = 0x20000 + MS_VERBOSE = 0x8000 NAME_MAX = 0xff NETLINK_ADD_MEMBERSHIP = 0x1 NETLINK_AUDIT = 0x9 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_mips64.go b/vendor/golang.org/x/sys/unix/zerrors_linux_mips64.go index 35c7280b..37d66f31 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_mips64.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_mips64.go @@ -168,6 +168,7 @@ const ( BLKFRASET = 0x20001264 BLKGETSIZE = 0x20001260 BLKGETSIZE64 = 0x40081272 + BLKPBSZGET = 0x2000127b BLKRAGET = 0x20001263 BLKRASET = 0x20001262 BLKROGET = 0x2000125e @@ -449,6 +450,24 @@ const ( FF1 = 0x8000 FFDLY = 0x8000 FLUSHO = 0x2000 + FS_ENCRYPTION_MODE_AES_256_CBC = 0x3 + FS_ENCRYPTION_MODE_AES_256_CTS = 0x4 + FS_ENCRYPTION_MODE_AES_256_GCM = 0x2 + FS_ENCRYPTION_MODE_AES_256_XTS = 0x1 + FS_ENCRYPTION_MODE_INVALID = 0x0 + FS_IOC_GET_ENCRYPTION_POLICY = 0x800c6615 + FS_IOC_GET_ENCRYPTION_PWSALT = 0x80106614 + FS_IOC_SET_ENCRYPTION_POLICY = 0x400c6613 + FS_KEY_DESCRIPTOR_SIZE = 0x8 + FS_KEY_DESC_PREFIX = "fscrypt:" + FS_KEY_DESC_PREFIX_SIZE = 0x8 + FS_MAX_KEY_SIZE = 0x40 + FS_POLICY_FLAGS_PAD_16 = 0x2 + FS_POLICY_FLAGS_PAD_32 = 0x3 + FS_POLICY_FLAGS_PAD_4 = 0x0 + FS_POLICY_FLAGS_PAD_8 = 0x1 + FS_POLICY_FLAGS_PAD_MASK = 0x3 + FS_POLICY_FLAGS_VALID = 0x3 F_DUPFD = 0x0 F_DUPFD_CLOEXEC = 0x406 F_EXLCK = 0x4 @@ -810,6 +829,7 @@ const ( MS_ACTIVE = 0x40000000 MS_ASYNC = 0x1 MS_BIND = 0x1000 + MS_BORN = 0x20000000 MS_DIRSYNC = 0x80 MS_INVALIDATE = 0x2 MS_I_VERSION = 0x800000 @@ -823,6 +843,8 @@ const ( MS_NODEV = 0x4 MS_NODIRATIME = 0x800 MS_NOEXEC = 0x8 + MS_NOREMOTELOCK = 0x8000000 + MS_NOSEC = 0x10000000 MS_NOSUID = 0x2 MS_NOUSER = -0x80000000 MS_POSIXACL = 0x10000 @@ -839,6 +861,7 @@ const ( MS_SYNC = 0x4 MS_SYNCHRONOUS = 0x10 MS_UNBINDABLE = 0x20000 + MS_VERBOSE = 0x8000 NAME_MAX = 0xff NETLINK_ADD_MEMBERSHIP = 0x1 NETLINK_AUDIT = 0x9 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_mips64le.go b/vendor/golang.org/x/sys/unix/zerrors_linux_mips64le.go index 768e9a75..0f33f0fa 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_mips64le.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_mips64le.go @@ -168,6 +168,7 @@ const ( BLKFRASET = 0x20001264 BLKGETSIZE = 0x20001260 BLKGETSIZE64 = 0x40081272 + BLKPBSZGET = 0x2000127b BLKRAGET = 0x20001263 BLKRASET = 0x20001262 BLKROGET = 0x2000125e @@ -449,6 +450,24 @@ const ( FF1 = 0x8000 FFDLY = 0x8000 FLUSHO = 0x2000 + FS_ENCRYPTION_MODE_AES_256_CBC = 0x3 + FS_ENCRYPTION_MODE_AES_256_CTS = 0x4 + FS_ENCRYPTION_MODE_AES_256_GCM = 0x2 + FS_ENCRYPTION_MODE_AES_256_XTS = 0x1 + FS_ENCRYPTION_MODE_INVALID = 0x0 + FS_IOC_GET_ENCRYPTION_POLICY = 0x800c6615 + FS_IOC_GET_ENCRYPTION_PWSALT = 0x80106614 + FS_IOC_SET_ENCRYPTION_POLICY = 0x400c6613 + FS_KEY_DESCRIPTOR_SIZE = 0x8 + FS_KEY_DESC_PREFIX = "fscrypt:" + FS_KEY_DESC_PREFIX_SIZE = 0x8 + FS_MAX_KEY_SIZE = 0x40 + FS_POLICY_FLAGS_PAD_16 = 0x2 + FS_POLICY_FLAGS_PAD_32 = 0x3 + FS_POLICY_FLAGS_PAD_4 = 0x0 + FS_POLICY_FLAGS_PAD_8 = 0x1 + FS_POLICY_FLAGS_PAD_MASK = 0x3 + FS_POLICY_FLAGS_VALID = 0x3 F_DUPFD = 0x0 F_DUPFD_CLOEXEC = 0x406 F_EXLCK = 0x4 @@ -810,6 +829,7 @@ const ( MS_ACTIVE = 0x40000000 MS_ASYNC = 0x1 MS_BIND = 0x1000 + MS_BORN = 0x20000000 MS_DIRSYNC = 0x80 MS_INVALIDATE = 0x2 MS_I_VERSION = 0x800000 @@ -823,6 +843,8 @@ const ( MS_NODEV = 0x4 MS_NODIRATIME = 0x800 MS_NOEXEC = 0x8 + MS_NOREMOTELOCK = 0x8000000 + MS_NOSEC = 0x10000000 MS_NOSUID = 0x2 MS_NOUSER = -0x80000000 MS_POSIXACL = 0x10000 @@ -839,6 +861,7 @@ const ( MS_SYNC = 0x4 MS_SYNCHRONOUS = 0x10 MS_UNBINDABLE = 0x20000 + MS_VERBOSE = 0x8000 NAME_MAX = 0xff NETLINK_ADD_MEMBERSHIP = 0x1 NETLINK_AUDIT = 0x9 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_mipsle.go b/vendor/golang.org/x/sys/unix/zerrors_linux_mipsle.go index b6ea4b7c..3fa39fa7 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_mipsle.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_mipsle.go @@ -168,6 +168,7 @@ const ( BLKFRASET = 0x20001264 BLKGETSIZE = 0x20001260 BLKGETSIZE64 = 0x40041272 + BLKPBSZGET = 0x2000127b BLKRAGET = 0x20001263 BLKRASET = 0x20001262 BLKROGET = 0x2000125e @@ -449,6 +450,24 @@ const ( FF1 = 0x8000 FFDLY = 0x8000 FLUSHO = 0x2000 + FS_ENCRYPTION_MODE_AES_256_CBC = 0x3 + FS_ENCRYPTION_MODE_AES_256_CTS = 0x4 + FS_ENCRYPTION_MODE_AES_256_GCM = 0x2 + FS_ENCRYPTION_MODE_AES_256_XTS = 0x1 + FS_ENCRYPTION_MODE_INVALID = 0x0 + FS_IOC_GET_ENCRYPTION_POLICY = 0x800c6615 + FS_IOC_GET_ENCRYPTION_PWSALT = 0x80106614 + FS_IOC_SET_ENCRYPTION_POLICY = 0x400c6613 + FS_KEY_DESCRIPTOR_SIZE = 0x8 + FS_KEY_DESC_PREFIX = "fscrypt:" + FS_KEY_DESC_PREFIX_SIZE = 0x8 + FS_MAX_KEY_SIZE = 0x40 + FS_POLICY_FLAGS_PAD_16 = 0x2 + FS_POLICY_FLAGS_PAD_32 = 0x3 + FS_POLICY_FLAGS_PAD_4 = 0x0 + FS_POLICY_FLAGS_PAD_8 = 0x1 + FS_POLICY_FLAGS_PAD_MASK = 0x3 + FS_POLICY_FLAGS_VALID = 0x3 F_DUPFD = 0x0 F_DUPFD_CLOEXEC = 0x406 F_EXLCK = 0x4 @@ -810,6 +829,7 @@ const ( MS_ACTIVE = 0x40000000 MS_ASYNC = 0x1 MS_BIND = 0x1000 + MS_BORN = 0x20000000 MS_DIRSYNC = 0x80 MS_INVALIDATE = 0x2 MS_I_VERSION = 0x800000 @@ -823,6 +843,8 @@ const ( MS_NODEV = 0x4 MS_NODIRATIME = 0x800 MS_NOEXEC = 0x8 + MS_NOREMOTELOCK = 0x8000000 + MS_NOSEC = 0x10000000 MS_NOSUID = 0x2 MS_NOUSER = -0x80000000 MS_POSIXACL = 0x10000 @@ -839,6 +861,7 @@ const ( MS_SYNC = 0x4 MS_SYNCHRONOUS = 0x10 MS_UNBINDABLE = 0x20000 + MS_VERBOSE = 0x8000 NAME_MAX = 0xff NETLINK_ADD_MEMBERSHIP = 0x1 NETLINK_AUDIT = 0x9 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64.go b/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64.go index cf2546c7..4585ef77 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64.go @@ -168,6 +168,7 @@ const ( BLKFRASET = 0x20001264 BLKGETSIZE = 0x20001260 BLKGETSIZE64 = 0x40081272 + BLKPBSZGET = 0x2000127b BLKRAGET = 0x20001263 BLKRASET = 0x20001262 BLKROGET = 0x2000125e @@ -449,6 +450,24 @@ const ( FF1 = 0x4000 FFDLY = 0x4000 FLUSHO = 0x800000 + FS_ENCRYPTION_MODE_AES_256_CBC = 0x3 + FS_ENCRYPTION_MODE_AES_256_CTS = 0x4 + FS_ENCRYPTION_MODE_AES_256_GCM = 0x2 + FS_ENCRYPTION_MODE_AES_256_XTS = 0x1 + FS_ENCRYPTION_MODE_INVALID = 0x0 + FS_IOC_GET_ENCRYPTION_POLICY = 0x800c6615 + FS_IOC_GET_ENCRYPTION_PWSALT = 0x80106614 + FS_IOC_SET_ENCRYPTION_POLICY = 0x400c6613 + FS_KEY_DESCRIPTOR_SIZE = 0x8 + FS_KEY_DESC_PREFIX = "fscrypt:" + FS_KEY_DESC_PREFIX_SIZE = 0x8 + FS_MAX_KEY_SIZE = 0x40 + FS_POLICY_FLAGS_PAD_16 = 0x2 + FS_POLICY_FLAGS_PAD_32 = 0x3 + FS_POLICY_FLAGS_PAD_4 = 0x0 + FS_POLICY_FLAGS_PAD_8 = 0x1 + FS_POLICY_FLAGS_PAD_MASK = 0x3 + FS_POLICY_FLAGS_VALID = 0x3 F_DUPFD = 0x0 F_DUPFD_CLOEXEC = 0x406 F_EXLCK = 0x4 @@ -809,6 +828,7 @@ const ( MS_ACTIVE = 0x40000000 MS_ASYNC = 0x1 MS_BIND = 0x1000 + MS_BORN = 0x20000000 MS_DIRSYNC = 0x80 MS_INVALIDATE = 0x2 MS_I_VERSION = 0x800000 @@ -822,6 +842,8 @@ const ( MS_NODEV = 0x4 MS_NODIRATIME = 0x800 MS_NOEXEC = 0x8 + MS_NOREMOTELOCK = 0x8000000 + MS_NOSEC = 0x10000000 MS_NOSUID = 0x2 MS_NOUSER = -0x80000000 MS_POSIXACL = 0x10000 @@ -838,6 +860,7 @@ const ( MS_SYNC = 0x4 MS_SYNCHRONOUS = 0x10 MS_UNBINDABLE = 0x20000 + MS_VERBOSE = 0x8000 NAME_MAX = 0xff NETLINK_ADD_MEMBERSHIP = 0x1 NETLINK_AUDIT = 0x9 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64le.go b/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64le.go index 0609cc13..b2a9128c 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64le.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64le.go @@ -168,6 +168,7 @@ const ( BLKFRASET = 0x20001264 BLKGETSIZE = 0x20001260 BLKGETSIZE64 = 0x40081272 + BLKPBSZGET = 0x2000127b BLKRAGET = 0x20001263 BLKRASET = 0x20001262 BLKROGET = 0x2000125e @@ -449,6 +450,24 @@ const ( FF1 = 0x4000 FFDLY = 0x4000 FLUSHO = 0x800000 + FS_ENCRYPTION_MODE_AES_256_CBC = 0x3 + FS_ENCRYPTION_MODE_AES_256_CTS = 0x4 + FS_ENCRYPTION_MODE_AES_256_GCM = 0x2 + FS_ENCRYPTION_MODE_AES_256_XTS = 0x1 + FS_ENCRYPTION_MODE_INVALID = 0x0 + FS_IOC_GET_ENCRYPTION_POLICY = 0x800c6615 + FS_IOC_GET_ENCRYPTION_PWSALT = 0x80106614 + FS_IOC_SET_ENCRYPTION_POLICY = 0x400c6613 + FS_KEY_DESCRIPTOR_SIZE = 0x8 + FS_KEY_DESC_PREFIX = "fscrypt:" + FS_KEY_DESC_PREFIX_SIZE = 0x8 + FS_MAX_KEY_SIZE = 0x40 + FS_POLICY_FLAGS_PAD_16 = 0x2 + FS_POLICY_FLAGS_PAD_32 = 0x3 + FS_POLICY_FLAGS_PAD_4 = 0x0 + FS_POLICY_FLAGS_PAD_8 = 0x1 + FS_POLICY_FLAGS_PAD_MASK = 0x3 + FS_POLICY_FLAGS_VALID = 0x3 F_DUPFD = 0x0 F_DUPFD_CLOEXEC = 0x406 F_EXLCK = 0x4 @@ -809,6 +828,7 @@ const ( MS_ACTIVE = 0x40000000 MS_ASYNC = 0x1 MS_BIND = 0x1000 + MS_BORN = 0x20000000 MS_DIRSYNC = 0x80 MS_INVALIDATE = 0x2 MS_I_VERSION = 0x800000 @@ -822,6 +842,8 @@ const ( MS_NODEV = 0x4 MS_NODIRATIME = 0x800 MS_NOEXEC = 0x8 + MS_NOREMOTELOCK = 0x8000000 + MS_NOSEC = 0x10000000 MS_NOSUID = 0x2 MS_NOUSER = -0x80000000 MS_POSIXACL = 0x10000 @@ -838,6 +860,7 @@ const ( MS_SYNC = 0x4 MS_SYNCHRONOUS = 0x10 MS_UNBINDABLE = 0x20000 + MS_VERBOSE = 0x8000 NAME_MAX = 0xff NETLINK_ADD_MEMBERSHIP = 0x1 NETLINK_AUDIT = 0x9 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_s390x.go b/vendor/golang.org/x/sys/unix/zerrors_linux_s390x.go index f9556ed1..f8b0eb7b 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_s390x.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_s390x.go @@ -168,6 +168,7 @@ const ( BLKFRASET = 0x1264 BLKGETSIZE = 0x1260 BLKGETSIZE64 = 0x80081272 + BLKPBSZGET = 0x127b BLKRAGET = 0x1263 BLKRASET = 0x1262 BLKROGET = 0x125e @@ -449,6 +450,24 @@ const ( FF1 = 0x8000 FFDLY = 0x8000 FLUSHO = 0x1000 + FS_ENCRYPTION_MODE_AES_256_CBC = 0x3 + FS_ENCRYPTION_MODE_AES_256_CTS = 0x4 + FS_ENCRYPTION_MODE_AES_256_GCM = 0x2 + FS_ENCRYPTION_MODE_AES_256_XTS = 0x1 + FS_ENCRYPTION_MODE_INVALID = 0x0 + FS_IOC_GET_ENCRYPTION_POLICY = 0x400c6615 + FS_IOC_GET_ENCRYPTION_PWSALT = 0x40106614 + FS_IOC_SET_ENCRYPTION_POLICY = 0x800c6613 + FS_KEY_DESCRIPTOR_SIZE = 0x8 + FS_KEY_DESC_PREFIX = "fscrypt:" + FS_KEY_DESC_PREFIX_SIZE = 0x8 + FS_MAX_KEY_SIZE = 0x40 + FS_POLICY_FLAGS_PAD_16 = 0x2 + FS_POLICY_FLAGS_PAD_32 = 0x3 + FS_POLICY_FLAGS_PAD_4 = 0x0 + FS_POLICY_FLAGS_PAD_8 = 0x1 + FS_POLICY_FLAGS_PAD_MASK = 0x3 + FS_POLICY_FLAGS_VALID = 0x3 F_DUPFD = 0x0 F_DUPFD_CLOEXEC = 0x406 F_EXLCK = 0x4 @@ -809,6 +828,7 @@ const ( MS_ACTIVE = 0x40000000 MS_ASYNC = 0x1 MS_BIND = 0x1000 + MS_BORN = 0x20000000 MS_DIRSYNC = 0x80 MS_INVALIDATE = 0x2 MS_I_VERSION = 0x800000 @@ -822,6 +842,8 @@ const ( MS_NODEV = 0x4 MS_NODIRATIME = 0x800 MS_NOEXEC = 0x8 + MS_NOREMOTELOCK = 0x8000000 + MS_NOSEC = 0x10000000 MS_NOSUID = 0x2 MS_NOUSER = -0x80000000 MS_POSIXACL = 0x10000 @@ -838,6 +860,7 @@ const ( MS_SYNC = 0x4 MS_SYNCHRONOUS = 0x10 MS_UNBINDABLE = 0x20000 + MS_VERBOSE = 0x8000 NAME_MAX = 0xff NETLINK_ADD_MEMBERSHIP = 0x1 NETLINK_AUDIT = 0x9 diff --git a/vendor/golang.org/x/sys/unix/zerrors_solaris_amd64.go b/vendor/golang.org/x/sys/unix/zerrors_solaris_amd64.go index a08922b9..81e83d78 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_solaris_amd64.go +++ b/vendor/golang.org/x/sys/unix/zerrors_solaris_amd64.go @@ -1,5 +1,5 @@ // mkerrors.sh -m64 -// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT +// Code generated by the command above; see README.md. DO NOT EDIT. // +build amd64,solaris @@ -159,7 +159,12 @@ const ( BPF_W = 0x0 BPF_X = 0x8 BRKINT = 0x2 + BS0 = 0x0 + BS1 = 0x2000 + BSDLY = 0x2000 + CBAUD = 0xf CFLUSH = 0xf + CIBAUD = 0xf0000 CLOCAL = 0x800 CLOCK_HIGHRES = 0x4 CLOCK_LEVEL = 0xa @@ -169,7 +174,13 @@ const ( CLOCK_REALTIME = 0x3 CLOCK_THREAD_CPUTIME_ID = 0x2 CLOCK_VIRTUAL = 0x1 + CR0 = 0x0 + CR1 = 0x200 + CR2 = 0x400 + CR3 = 0x600 + CRDLY = 0x600 CREAD = 0x80 + CRTSCTS = 0x80000000 CS5 = 0x0 CS6 = 0x10 CS7 = 0x20 @@ -276,6 +287,9 @@ const ( FD_CLOEXEC = 0x1 FD_NFDBITS = 0x40 FD_SETSIZE = 0x10000 + FF0 = 0x0 + FF1 = 0x8000 + FFDLY = 0x8000 FLUSHALL = 0x1 FLUSHDATA = 0x0 FLUSHO = 0x2000 @@ -290,6 +304,10 @@ const ( F_DUP2FD_CLOEXEC = 0x24 F_DUPFD = 0x0 F_DUPFD_CLOEXEC = 0x25 + F_FLOCK = 0x35 + F_FLOCK64 = 0x35 + F_FLOCKW = 0x36 + F_FLOCKW64 = 0x36 F_FREESP = 0xb F_FREESP64 = 0xb F_GETFD = 0x1 @@ -304,6 +322,12 @@ const ( F_MDACC = 0x20 F_NODNY = 0x0 F_NPRIV = 0x10 + F_OFD_GETLK = 0x2f + F_OFD_GETLK64 = 0x2f + F_OFD_SETLK = 0x30 + F_OFD_SETLK64 = 0x30 + F_OFD_SETLKW = 0x31 + F_OFD_SETLKW64 = 0x31 F_PRIV = 0xf F_QUOTACTL = 0x11 F_RDACC = 0x1 @@ -332,6 +356,7 @@ const ( F_WRDNY = 0x2 F_WRLCK = 0x2 HUPCL = 0x400 + IBSHIFT = 0x10 ICANON = 0x2 ICRNL = 0x100 IEXTEN = 0x8000 @@ -589,15 +614,21 @@ const ( IP_UNSPEC_SRC = 0x42 ISIG = 0x1 ISTRIP = 0x20 + IUCLC = 0x200 IXANY = 0x800 IXOFF = 0x1000 IXON = 0x400 + LOCK_EX = 0x2 + LOCK_NB = 0x4 + LOCK_SH = 0x1 + LOCK_UN = 0x8 MADV_ACCESS_DEFAULT = 0x6 MADV_ACCESS_LWP = 0x7 MADV_ACCESS_MANY = 0x8 MADV_DONTNEED = 0x4 MADV_FREE = 0x5 MADV_NORMAL = 0x0 + MADV_PURGE = 0x9 MADV_RANDOM = 0x1 MADV_SEQUENTIAL = 0x2 MADV_WILLNEED = 0x3 @@ -605,6 +636,7 @@ const ( MAP_ALIGN = 0x200 MAP_ANON = 0x100 MAP_ANONYMOUS = 0x100 + MAP_FILE = 0x0 MAP_FIXED = 0x10 MAP_INITDATA = 0x800 MAP_NORESERVE = 0x40 @@ -632,10 +664,14 @@ const ( MS_OLDSYNC = 0x0 MS_SYNC = 0x4 M_FLUSH = 0x86 + NL0 = 0x0 + NL1 = 0x100 + NLDLY = 0x100 NOFLSH = 0x80 OCRNL = 0x8 OFDEL = 0x80 OFILL = 0x40 + OLCUC = 0x2 ONLCR = 0x4 ONLRET = 0x20 ONOCR = 0x10 @@ -955,12 +991,21 @@ const ( SO_USELOOPBACK = 0x40 SO_VRRP = 0x1017 SO_WROFF = 0x2 + TAB0 = 0x0 + TAB1 = 0x800 + TAB2 = 0x1000 + TAB3 = 0x1800 + TABDLY = 0x1800 TCFLSH = 0x5407 TCGETA = 0x5401 TCGETS = 0x540d TCIFLUSH = 0x0 + TCIOFF = 0x2 TCIOFLUSH = 0x2 + TCION = 0x3 TCOFLUSH = 0x1 + TCOOFF = 0x0 + TCOON = 0x1 TCP_ABORT_THRESHOLD = 0x11 TCP_ANONPRIVBIND = 0x20 TCP_CONN_ABORT_THRESHOLD = 0x13 @@ -1089,6 +1134,8 @@ const ( WSTOPPED = 0x4 WTRAPPED = 0x2 WUNTRACED = 0x4 + XCASE = 0x4 + XTABS = 0x1800 ) // Errors diff --git a/vendor/golang.org/x/sys/unix/zsyscall_dragonfly_amd64.go b/vendor/golang.org/x/sys/unix/zsyscall_dragonfly_amd64.go index 3e9d82a2..eafceb8e 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_dragonfly_amd64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_dragonfly_amd64.go @@ -1,5 +1,5 @@ // mksyscall.pl -dragonfly -tags dragonfly,amd64 syscall_bsd.go syscall_dragonfly.go syscall_dragonfly_amd64.go -// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT +// Code generated by the command above; see README.md. DO NOT EDIT. // +build dragonfly,amd64 @@ -1380,3 +1380,14 @@ func writelen(fd int, buf *byte, nbuf int) (n int, err error) { } return } + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func accept4(fd int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (nfd int, err error) { + r0, _, e1 := Syscall6(SYS_ACCEPT4, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)), uintptr(flags), 0, 0) + nfd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} diff --git a/vendor/golang.org/x/sys/unix/zsyscall_linux_386.go b/vendor/golang.org/x/sys/unix/zsyscall_linux_386.go index 41693a96..b4e9d8b3 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_linux_386.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_linux_386.go @@ -312,6 +312,17 @@ func Close(fd int) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func CopyFileRange(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int, err error) { + r0, _, e1 := Syscall6(SYS_COPY_FILE_RANGE, uintptr(rfd), uintptr(unsafe.Pointer(roff)), uintptr(wfd), uintptr(unsafe.Pointer(woff)), uintptr(len), uintptr(flags)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Dup(oldfd int) (fd int, err error) { r0, _, e1 := Syscall(SYS_DUP, uintptr(oldfd), 0, 0) fd = int(r0) diff --git a/vendor/golang.org/x/sys/unix/zsyscall_linux_amd64.go b/vendor/golang.org/x/sys/unix/zsyscall_linux_amd64.go index f10621d9..3de166a5 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_linux_amd64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_linux_amd64.go @@ -312,6 +312,17 @@ func Close(fd int) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func CopyFileRange(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int, err error) { + r0, _, e1 := Syscall6(SYS_COPY_FILE_RANGE, uintptr(rfd), uintptr(unsafe.Pointer(roff)), uintptr(wfd), uintptr(unsafe.Pointer(woff)), uintptr(len), uintptr(flags)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Dup(oldfd int) (fd int, err error) { r0, _, e1 := Syscall(SYS_DUP, uintptr(oldfd), 0, 0) fd = int(r0) diff --git a/vendor/golang.org/x/sys/unix/zsyscall_linux_arm.go b/vendor/golang.org/x/sys/unix/zsyscall_linux_arm.go index fae666f6..03463aec 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_linux_arm.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_linux_arm.go @@ -312,6 +312,17 @@ func Close(fd int) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func CopyFileRange(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int, err error) { + r0, _, e1 := Syscall6(SYS_COPY_FILE_RANGE, uintptr(rfd), uintptr(unsafe.Pointer(roff)), uintptr(wfd), uintptr(unsafe.Pointer(woff)), uintptr(len), uintptr(flags)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Dup(oldfd int) (fd int, err error) { r0, _, e1 := Syscall(SYS_DUP, uintptr(oldfd), 0, 0) fd = int(r0) diff --git a/vendor/golang.org/x/sys/unix/zsyscall_linux_arm64.go b/vendor/golang.org/x/sys/unix/zsyscall_linux_arm64.go index a4dca395..4f68f392 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_linux_arm64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_linux_arm64.go @@ -312,6 +312,17 @@ func Close(fd int) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func CopyFileRange(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int, err error) { + r0, _, e1 := Syscall6(SYS_COPY_FILE_RANGE, uintptr(rfd), uintptr(unsafe.Pointer(roff)), uintptr(wfd), uintptr(unsafe.Pointer(woff)), uintptr(len), uintptr(flags)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Dup(oldfd int) (fd int, err error) { r0, _, e1 := Syscall(SYS_DUP, uintptr(oldfd), 0, 0) fd = int(r0) diff --git a/vendor/golang.org/x/sys/unix/zsyscall_linux_mips.go b/vendor/golang.org/x/sys/unix/zsyscall_linux_mips.go index b56db729..73d68896 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_linux_mips.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_linux_mips.go @@ -312,6 +312,17 @@ func Close(fd int) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func CopyFileRange(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int, err error) { + r0, _, e1 := Syscall6(SYS_COPY_FILE_RANGE, uintptr(rfd), uintptr(unsafe.Pointer(roff)), uintptr(wfd), uintptr(unsafe.Pointer(woff)), uintptr(len), uintptr(flags)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Dup(oldfd int) (fd int, err error) { r0, _, e1 := Syscall(SYS_DUP, uintptr(oldfd), 0, 0) fd = int(r0) diff --git a/vendor/golang.org/x/sys/unix/zsyscall_linux_mips64.go b/vendor/golang.org/x/sys/unix/zsyscall_linux_mips64.go index ca2359de..60c9629d 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_linux_mips64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_linux_mips64.go @@ -312,6 +312,17 @@ func Close(fd int) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func CopyFileRange(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int, err error) { + r0, _, e1 := Syscall6(SYS_COPY_FILE_RANGE, uintptr(rfd), uintptr(unsafe.Pointer(roff)), uintptr(wfd), uintptr(unsafe.Pointer(woff)), uintptr(len), uintptr(flags)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Dup(oldfd int) (fd int, err error) { r0, _, e1 := Syscall(SYS_DUP, uintptr(oldfd), 0, 0) fd = int(r0) @@ -1194,6 +1205,16 @@ func Munlockall() (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Dup2(oldfd int, newfd int) (err error) { + _, _, e1 := Syscall(SYS_DUP2, uintptr(oldfd), uintptr(newfd), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) { var _p0 unsafe.Pointer if len(events) > 0 { diff --git a/vendor/golang.org/x/sys/unix/zsyscall_linux_mips64le.go b/vendor/golang.org/x/sys/unix/zsyscall_linux_mips64le.go index e574940f..1fc8c659 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_linux_mips64le.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_linux_mips64le.go @@ -312,6 +312,17 @@ func Close(fd int) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func CopyFileRange(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int, err error) { + r0, _, e1 := Syscall6(SYS_COPY_FILE_RANGE, uintptr(rfd), uintptr(unsafe.Pointer(roff)), uintptr(wfd), uintptr(unsafe.Pointer(woff)), uintptr(len), uintptr(flags)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Dup(oldfd int) (fd int, err error) { r0, _, e1 := Syscall(SYS_DUP, uintptr(oldfd), 0, 0) fd = int(r0) @@ -1194,6 +1205,16 @@ func Munlockall() (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Dup2(oldfd int, newfd int) (err error) { + _, _, e1 := Syscall(SYS_DUP2, uintptr(oldfd), uintptr(newfd), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) { var _p0 unsafe.Pointer if len(events) > 0 { diff --git a/vendor/golang.org/x/sys/unix/zsyscall_linux_mipsle.go b/vendor/golang.org/x/sys/unix/zsyscall_linux_mipsle.go index 31836d45..c5f87e63 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_linux_mipsle.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_linux_mipsle.go @@ -312,6 +312,17 @@ func Close(fd int) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func CopyFileRange(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int, err error) { + r0, _, e1 := Syscall6(SYS_COPY_FILE_RANGE, uintptr(rfd), uintptr(unsafe.Pointer(roff)), uintptr(wfd), uintptr(unsafe.Pointer(woff)), uintptr(len), uintptr(flags)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Dup(oldfd int) (fd int, err error) { r0, _, e1 := Syscall(SYS_DUP, uintptr(oldfd), 0, 0) fd = int(r0) diff --git a/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc64.go b/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc64.go index 4a767558..cee6ec35 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc64.go @@ -312,6 +312,17 @@ func Close(fd int) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func CopyFileRange(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int, err error) { + r0, _, e1 := Syscall6(SYS_COPY_FILE_RANGE, uintptr(rfd), uintptr(unsafe.Pointer(roff)), uintptr(wfd), uintptr(unsafe.Pointer(woff)), uintptr(len), uintptr(flags)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Dup(oldfd int) (fd int, err error) { r0, _, e1 := Syscall(SYS_DUP, uintptr(oldfd), 0, 0) fd = int(r0) diff --git a/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc64le.go b/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc64le.go index 5fb34282..f031e10a 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc64le.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc64le.go @@ -312,6 +312,17 @@ func Close(fd int) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func CopyFileRange(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int, err error) { + r0, _, e1 := Syscall6(SYS_COPY_FILE_RANGE, uintptr(rfd), uintptr(unsafe.Pointer(roff)), uintptr(wfd), uintptr(unsafe.Pointer(woff)), uintptr(len), uintptr(flags)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Dup(oldfd int) (fd int, err error) { r0, _, e1 := Syscall(SYS_DUP, uintptr(oldfd), 0, 0) fd = int(r0) diff --git a/vendor/golang.org/x/sys/unix/zsyscall_linux_s390x.go b/vendor/golang.org/x/sys/unix/zsyscall_linux_s390x.go index 79d285ca..4e4728ab 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_linux_s390x.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_linux_s390x.go @@ -312,6 +312,17 @@ func Close(fd int) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func CopyFileRange(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int, err error) { + r0, _, e1 := Syscall6(SYS_COPY_FILE_RANGE, uintptr(rfd), uintptr(unsafe.Pointer(roff)), uintptr(wfd), uintptr(unsafe.Pointer(woff)), uintptr(len), uintptr(flags)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Dup(oldfd int) (fd int, err error) { r0, _, e1 := Syscall(SYS_DUP, uintptr(oldfd), 0, 0) fd = int(r0) diff --git a/vendor/golang.org/x/sys/unix/zsyscall_linux_sparc64.go b/vendor/golang.org/x/sys/unix/zsyscall_linux_sparc64.go index ce3ec585..2dd98434 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_linux_sparc64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_linux_sparc64.go @@ -1,5 +1,5 @@ // mksyscall.pl -tags linux,sparc64 syscall_linux.go syscall_linux_sparc64.go -// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT +// Code generated by the command above; see README.md. DO NOT EDIT. // +build linux,sparc64 @@ -312,6 +312,17 @@ func Close(fd int) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func CopyFileRange(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int, err error) { + r0, _, e1 := Syscall6(SYS_COPY_FILE_RANGE, uintptr(rfd), uintptr(unsafe.Pointer(roff)), uintptr(wfd), uintptr(unsafe.Pointer(woff)), uintptr(len), uintptr(flags)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Dup(oldfd int) (fd int, err error) { r0, _, e1 := Syscall(SYS_DUP, uintptr(oldfd), 0, 0) fd = int(r0) diff --git a/vendor/golang.org/x/sys/unix/zsyscall_solaris_amd64.go b/vendor/golang.org/x/sys/unix/zsyscall_solaris_amd64.go index bdf140b1..cbc6f6e3 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_solaris_amd64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_solaris_amd64.go @@ -1,5 +1,5 @@ // mksyscall_solaris.pl -tags solaris,amd64 syscall_solaris.go syscall_solaris_amd64.go -// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT +// Code generated by the command above; see README.md. DO NOT EDIT. // +build solaris,amd64 @@ -22,8 +22,8 @@ import ( //go:cgo_import_dynamic libc_fcntl fcntl "libc.so" //go:cgo_import_dynamic libc_futimesat futimesat "libc.so" //go:cgo_import_dynamic libc_accept accept "libsocket.so" -//go:cgo_import_dynamic libc_recvmsg recvmsg "libsocket.so" -//go:cgo_import_dynamic libc_sendmsg sendmsg "libsocket.so" +//go:cgo_import_dynamic libc___xnet_recvmsg __xnet_recvmsg "libsocket.so" +//go:cgo_import_dynamic libc___xnet_sendmsg __xnet_sendmsg "libsocket.so" //go:cgo_import_dynamic libc_acct acct "libc.so" //go:cgo_import_dynamic libc_ioctl ioctl "libc.so" //go:cgo_import_dynamic libc_access access "libc.so" @@ -45,6 +45,7 @@ import ( //go:cgo_import_dynamic libc_fdatasync fdatasync "libc.so" //go:cgo_import_dynamic libc_fpathconf fpathconf "libc.so" //go:cgo_import_dynamic libc_fstat fstat "libc.so" +//go:cgo_import_dynamic libc_fstatvfs fstatvfs "libc.so" //go:cgo_import_dynamic libc_getdents getdents "libc.so" //go:cgo_import_dynamic libc_getgid getgid "libc.so" //go:cgo_import_dynamic libc_getpid getpid "libc.so" @@ -61,7 +62,7 @@ import ( //go:cgo_import_dynamic libc_kill kill "libc.so" //go:cgo_import_dynamic libc_lchown lchown "libc.so" //go:cgo_import_dynamic libc_link link "libc.so" -//go:cgo_import_dynamic libc_listen listen "libsocket.so" +//go:cgo_import_dynamic libc___xnet_llisten __xnet_llisten "libsocket.so" //go:cgo_import_dynamic libc_lstat lstat "libc.so" //go:cgo_import_dynamic libc_madvise madvise "libc.so" //go:cgo_import_dynamic libc_mkdir mkdir "libc.so" @@ -101,6 +102,7 @@ import ( //go:cgo_import_dynamic libc_setuid setuid "libc.so" //go:cgo_import_dynamic libc_shutdown shutdown "libsocket.so" //go:cgo_import_dynamic libc_stat stat "libc.so" +//go:cgo_import_dynamic libc_statvfs statvfs "libc.so" //go:cgo_import_dynamic libc_symlink symlink "libc.so" //go:cgo_import_dynamic libc_sync sync "libc.so" //go:cgo_import_dynamic libc_times times "libc.so" @@ -114,15 +116,15 @@ import ( //go:cgo_import_dynamic libc_unlinkat unlinkat "libc.so" //go:cgo_import_dynamic libc_ustat ustat "libc.so" //go:cgo_import_dynamic libc_utime utime "libc.so" -//go:cgo_import_dynamic libc_bind bind "libsocket.so" -//go:cgo_import_dynamic libc_connect connect "libsocket.so" +//go:cgo_import_dynamic libc___xnet_bind __xnet_bind "libsocket.so" +//go:cgo_import_dynamic libc___xnet_connect __xnet_connect "libsocket.so" //go:cgo_import_dynamic libc_mmap mmap "libc.so" //go:cgo_import_dynamic libc_munmap munmap "libc.so" -//go:cgo_import_dynamic libc_sendto sendto "libsocket.so" -//go:cgo_import_dynamic libc_socket socket "libsocket.so" -//go:cgo_import_dynamic libc_socketpair socketpair "libsocket.so" +//go:cgo_import_dynamic libc___xnet_sendto __xnet_sendto "libsocket.so" +//go:cgo_import_dynamic libc___xnet_socket __xnet_socket "libsocket.so" +//go:cgo_import_dynamic libc___xnet_socketpair __xnet_socketpair "libsocket.so" //go:cgo_import_dynamic libc_write write "libc.so" -//go:cgo_import_dynamic libc_getsockopt getsockopt "libsocket.so" +//go:cgo_import_dynamic libc___xnet_getsockopt __xnet_getsockopt "libsocket.so" //go:cgo_import_dynamic libc_getpeername getpeername "libsocket.so" //go:cgo_import_dynamic libc_setsockopt setsockopt "libsocket.so" //go:cgo_import_dynamic libc_recvfrom recvfrom "libsocket.so" @@ -140,8 +142,8 @@ import ( //go:linkname procfcntl libc_fcntl //go:linkname procfutimesat libc_futimesat //go:linkname procaccept libc_accept -//go:linkname procrecvmsg libc_recvmsg -//go:linkname procsendmsg libc_sendmsg +//go:linkname proc__xnet_recvmsg libc___xnet_recvmsg +//go:linkname proc__xnet_sendmsg libc___xnet_sendmsg //go:linkname procacct libc_acct //go:linkname procioctl libc_ioctl //go:linkname procAccess libc_access @@ -163,6 +165,7 @@ import ( //go:linkname procFdatasync libc_fdatasync //go:linkname procFpathconf libc_fpathconf //go:linkname procFstat libc_fstat +//go:linkname procFstatvfs libc_fstatvfs //go:linkname procGetdents libc_getdents //go:linkname procGetgid libc_getgid //go:linkname procGetpid libc_getpid @@ -179,7 +182,7 @@ import ( //go:linkname procKill libc_kill //go:linkname procLchown libc_lchown //go:linkname procLink libc_link -//go:linkname proclisten libc_listen +//go:linkname proc__xnet_llisten libc___xnet_llisten //go:linkname procLstat libc_lstat //go:linkname procMadvise libc_madvise //go:linkname procMkdir libc_mkdir @@ -219,6 +222,7 @@ import ( //go:linkname procSetuid libc_setuid //go:linkname procshutdown libc_shutdown //go:linkname procStat libc_stat +//go:linkname procStatvfs libc_statvfs //go:linkname procSymlink libc_symlink //go:linkname procSync libc_sync //go:linkname procTimes libc_times @@ -232,15 +236,15 @@ import ( //go:linkname procUnlinkat libc_unlinkat //go:linkname procUstat libc_ustat //go:linkname procUtime libc_utime -//go:linkname procbind libc_bind -//go:linkname procconnect libc_connect +//go:linkname proc__xnet_bind libc___xnet_bind +//go:linkname proc__xnet_connect libc___xnet_connect //go:linkname procmmap libc_mmap //go:linkname procmunmap libc_munmap -//go:linkname procsendto libc_sendto -//go:linkname procsocket libc_socket -//go:linkname procsocketpair libc_socketpair +//go:linkname proc__xnet_sendto libc___xnet_sendto +//go:linkname proc__xnet_socket libc___xnet_socket +//go:linkname proc__xnet_socketpair libc___xnet_socketpair //go:linkname procwrite libc_write -//go:linkname procgetsockopt libc_getsockopt +//go:linkname proc__xnet_getsockopt libc___xnet_getsockopt //go:linkname procgetpeername libc_getpeername //go:linkname procsetsockopt libc_setsockopt //go:linkname procrecvfrom libc_recvfrom @@ -259,8 +263,8 @@ var ( procfcntl, procfutimesat, procaccept, - procrecvmsg, - procsendmsg, + proc__xnet_recvmsg, + proc__xnet_sendmsg, procacct, procioctl, procAccess, @@ -282,6 +286,7 @@ var ( procFdatasync, procFpathconf, procFstat, + procFstatvfs, procGetdents, procGetgid, procGetpid, @@ -298,7 +303,7 @@ var ( procKill, procLchown, procLink, - proclisten, + proc__xnet_llisten, procLstat, procMadvise, procMkdir, @@ -338,6 +343,7 @@ var ( procSetuid, procshutdown, procStat, + procStatvfs, procSymlink, procSync, procTimes, @@ -351,15 +357,15 @@ var ( procUnlinkat, procUstat, procUtime, - procbind, - procconnect, + proc__xnet_bind, + proc__xnet_connect, procmmap, procmunmap, - procsendto, - procsocket, - procsocketpair, + proc__xnet_sendto, + proc__xnet_socket, + proc__xnet_socketpair, procwrite, - procgetsockopt, + proc__xnet_getsockopt, procgetpeername, procsetsockopt, procrecvfrom, @@ -488,7 +494,7 @@ func accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) { } func recvmsg(s int, msg *Msghdr, flags int) (n int, err error) { - r0, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procrecvmsg)), 3, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags), 0, 0, 0) + r0, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&proc__xnet_recvmsg)), 3, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags), 0, 0, 0) n = int(r0) if e1 != 0 { err = e1 @@ -497,7 +503,7 @@ func recvmsg(s int, msg *Msghdr, flags int) (n int, err error) { } func sendmsg(s int, msg *Msghdr, flags int) (n int, err error) { - r0, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procsendmsg)), 3, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags), 0, 0, 0) + r0, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&proc__xnet_sendmsg)), 3, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags), 0, 0, 0) n = int(r0) if e1 != 0 { err = e1 @@ -713,6 +719,14 @@ func Fstat(fd int, stat *Stat_t) (err error) { return } +func Fstatvfs(fd int, vfsstat *Statvfs_t) (err error) { + _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procFstatvfs)), 2, uintptr(fd), uintptr(unsafe.Pointer(vfsstat)), 0, 0, 0, 0) + if e1 != 0 { + err = e1 + } + return +} + func Getdents(fd int, buf []byte, basep *uintptr) (n int, err error) { var _p0 *byte if len(buf) > 0 { @@ -853,7 +867,7 @@ func Link(path string, link string) (err error) { } func Listen(s int, backlog int) (err error) { - _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&proclisten)), 2, uintptr(s), uintptr(backlog), 0, 0, 0, 0) + _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&proc__xnet_llisten)), 2, uintptr(s), uintptr(backlog), 0, 0, 0, 0) if e1 != 0 { err = e1 } @@ -1302,6 +1316,19 @@ func Stat(path string, stat *Stat_t) (err error) { return } +func Statvfs(path string, vfsstat *Statvfs_t) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procStatvfs)), 2, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(vfsstat)), 0, 0, 0, 0) + if e1 != 0 { + err = e1 + } + return +} + func Symlink(path string, link string) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) @@ -1441,7 +1468,7 @@ func Utime(path string, buf *Utimbuf) (err error) { } func bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) { - _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procbind)), 3, uintptr(s), uintptr(addr), uintptr(addrlen), 0, 0, 0) + _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&proc__xnet_bind)), 3, uintptr(s), uintptr(addr), uintptr(addrlen), 0, 0, 0) if e1 != 0 { err = e1 } @@ -1449,7 +1476,7 @@ func bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) { } func connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) { - _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procconnect)), 3, uintptr(s), uintptr(addr), uintptr(addrlen), 0, 0, 0) + _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&proc__xnet_connect)), 3, uintptr(s), uintptr(addr), uintptr(addrlen), 0, 0, 0) if e1 != 0 { err = e1 } @@ -1478,7 +1505,7 @@ func sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) ( if len(buf) > 0 { _p0 = &buf[0] } - _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procsendto)), 6, uintptr(s), uintptr(unsafe.Pointer(_p0)), uintptr(len(buf)), uintptr(flags), uintptr(to), uintptr(addrlen)) + _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&proc__xnet_sendto)), 6, uintptr(s), uintptr(unsafe.Pointer(_p0)), uintptr(len(buf)), uintptr(flags), uintptr(to), uintptr(addrlen)) if e1 != 0 { err = e1 } @@ -1486,7 +1513,7 @@ func sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) ( } func socket(domain int, typ int, proto int) (fd int, err error) { - r0, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procsocket)), 3, uintptr(domain), uintptr(typ), uintptr(proto), 0, 0, 0) + r0, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&proc__xnet_socket)), 3, uintptr(domain), uintptr(typ), uintptr(proto), 0, 0, 0) fd = int(r0) if e1 != 0 { err = e1 @@ -1495,7 +1522,7 @@ func socket(domain int, typ int, proto int) (fd int, err error) { } func socketpair(domain int, typ int, proto int, fd *[2]int32) (err error) { - _, _, e1 := rawSysvicall6(uintptr(unsafe.Pointer(&procsocketpair)), 4, uintptr(domain), uintptr(typ), uintptr(proto), uintptr(unsafe.Pointer(fd)), 0, 0) + _, _, e1 := rawSysvicall6(uintptr(unsafe.Pointer(&proc__xnet_socketpair)), 4, uintptr(domain), uintptr(typ), uintptr(proto), uintptr(unsafe.Pointer(fd)), 0, 0) if e1 != 0 { err = e1 } @@ -1516,7 +1543,7 @@ func write(fd int, p []byte) (n int, err error) { } func getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error) { - _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procgetsockopt)), 5, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(unsafe.Pointer(vallen)), 0) + _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&proc__xnet_getsockopt)), 5, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(unsafe.Pointer(vallen)), 0) if e1 != 0 { err = e1 } diff --git a/vendor/golang.org/x/sys/unix/zsysnum_dragonfly_amd64.go b/vendor/golang.org/x/sys/unix/zsysnum_dragonfly_amd64.go index d6038fa9..b2c9ef81 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_dragonfly_amd64.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_dragonfly_amd64.go @@ -1,5 +1,5 @@ // mksysnum_dragonfly.pl -// MACHINE GENERATED BY THE ABOVE COMMAND; DO NOT EDIT +// Code generated by the command above; see README.md. DO NOT EDIT. // +build amd64,dragonfly @@ -42,7 +42,7 @@ const ( SYS_SYNC = 36 // { int sync(void); } SYS_KILL = 37 // { int kill(int pid, int signum); } SYS_GETPPID = 39 // { pid_t getppid(void); } - SYS_DUP = 41 // { int dup(u_int fd); } + SYS_DUP = 41 // { int dup(int fd); } SYS_PIPE = 42 // { int pipe(void); } SYS_GETEGID = 43 // { gid_t getegid(void); } SYS_PROFIL = 44 // { int profil(caddr_t samples, size_t size, \ @@ -76,7 +76,7 @@ const ( SYS_SWAPON = 85 // { int swapon(char *name); } SYS_GETITIMER = 86 // { int getitimer(u_int which, struct itimerval *itv); } SYS_GETDTABLESIZE = 89 // { int getdtablesize(void); } - SYS_DUP2 = 90 // { int dup2(u_int from, u_int to); } + SYS_DUP2 = 90 // { int dup2(int from, int to); } SYS_FCNTL = 92 // { int fcntl(int fd, int cmd, long arg); } SYS_SELECT = 93 // { int select(int nd, fd_set *in, fd_set *ou, \ SYS_FSYNC = 95 // { int fsync(int fd); } @@ -144,7 +144,7 @@ const ( SYS_SEMOP = 222 // { int semop(int semid, struct sembuf *sops, \ SYS_MSGCTL = 224 // { int msgctl(int msqid, int cmd, \ SYS_MSGGET = 225 // { int msgget(key_t key, int msgflg); } - SYS_MSGSND = 226 // { int msgsnd(int msqid, void *msgp, size_t msgsz, \ + SYS_MSGSND = 226 // { int msgsnd(int msqid, const void *msgp, size_t msgsz, \ SYS_MSGRCV = 227 // { int msgrcv(int msqid, void *msgp, size_t msgsz, \ SYS_SHMAT = 228 // { caddr_t shmat(int shmid, const void *shmaddr, \ SYS_SHMCTL = 229 // { int shmctl(int shmid, int cmd, \ @@ -224,7 +224,7 @@ const ( SYS_GETRESGID = 361 // { int getresgid(gid_t *rgid, gid_t *egid, gid_t *sgid); } SYS_KQUEUE = 362 // { int kqueue(void); } SYS_KEVENT = 363 // { int kevent(int fd, \ - SYS_SCTP_PEELOFF = 364 // { int sctp_peeloff(int sd, caddr_t name ); } + SYS_KENV = 390 // { int kenv(int what, const char *name, char *value, int len); } SYS_LCHFLAGS = 391 // { int lchflags(char *path, int flags); } SYS_UUIDGEN = 392 // { int uuidgen(struct uuid *store, int count); } SYS_SENDFILE = 393 // { int sendfile(int fd, int s, off_t offset, size_t nbytes, \ @@ -301,4 +301,15 @@ const ( SYS_LPATHCONF = 533 // { int lpathconf(char *path, int name); } SYS_VMM_GUEST_CTL = 534 // { int vmm_guest_ctl(int op, struct vmm_guest_options *options); } SYS_VMM_GUEST_SYNC_ADDR = 535 // { int vmm_guest_sync_addr(long *dstaddr, long *srcaddr); } + SYS_PROCCTL = 536 // { int procctl(idtype_t idtype, id_t id, int cmd, void *data); } + SYS_CHFLAGSAT = 537 // { int chflagsat(int fd, const char *path, int flags, int atflags);} + SYS_PIPE2 = 538 // { int pipe2(int *fildes, int flags); } + SYS_UTIMENSAT = 539 // { int utimensat(int fd, const char *path, const struct timespec *ts, int flags); } + SYS_FUTIMENS = 540 // { int futimens(int fd, const struct timespec *ts); } + SYS_ACCEPT4 = 541 // { int accept4(int s, caddr_t name, int *anamelen, int flags); } + SYS_LWP_SETNAME = 542 // { int lwp_setname(lwpid_t tid, const char *name); } + SYS_PPOLL = 543 // { int ppoll(struct pollfd *fds, u_int nfds, \ + SYS_LWP_SETAFFINITY = 544 // { int lwp_setaffinity(pid_t pid, lwpid_t tid, const cpumask_t *mask); } + SYS_LWP_GETAFFINITY = 545 // { int lwp_getaffinity(pid_t pid, lwpid_t tid, cpumask_t *mask); } + SYS_LWP_CREATE2 = 546 // { int lwp_create2(struct lwp_params *params, const cpumask_t *mask); } ) diff --git a/vendor/golang.org/x/sys/unix/ztypes_dragonfly_amd64.go b/vendor/golang.org/x/sys/unix/ztypes_dragonfly_amd64.go index 8a6f4e1c..e585c893 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_dragonfly_amd64.go +++ b/vendor/golang.org/x/sys/unix/ztypes_dragonfly_amd64.go @@ -1,5 +1,5 @@ -// Created by cgo -godefs - DO NOT EDIT -// cgo -godefs types_dragonfly.go +// cgo -godefs types_dragonfly.go | go run mkpost.go +// Code generated by the command above; see README.md. DO NOT EDIT. // +build amd64,dragonfly @@ -324,7 +324,7 @@ type IfData struct { Iqdrops uint64 Noproto uint64 Hwassist uint64 - Unused uint64 + Oqdrops uint64 Lastchange Timeval } diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_386.go b/vendor/golang.org/x/sys/unix/ztypes_linux_386.go index 8fc7b822..7333755b 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux_386.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_386.go @@ -152,6 +152,20 @@ type Flock_t struct { Pid int32 } +type FscryptPolicy struct { + Version uint8 + Contents_encryption_mode uint8 + Filenames_encryption_mode uint8 + Flags uint8 + Master_key_descriptor [8]uint8 +} + +type FscryptKey struct { + Mode uint32 + Raw [64]uint8 + Size uint32 +} + const ( FADV_NORMAL = 0x0 FADV_RANDOM = 0x1 diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_amd64.go b/vendor/golang.org/x/sys/unix/ztypes_linux_amd64.go index 6eb6c960..5807e174 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux_amd64.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_amd64.go @@ -154,6 +154,20 @@ type Flock_t struct { Pad_cgo_1 [4]byte } +type FscryptPolicy struct { + Version uint8 + Contents_encryption_mode uint8 + Filenames_encryption_mode uint8 + Flags uint8 + Master_key_descriptor [8]uint8 +} + +type FscryptKey struct { + Mode uint32 + Raw [64]uint8 + Size uint32 +} + const ( FADV_NORMAL = 0x0 FADV_RANDOM = 0x1 diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_arm.go b/vendor/golang.org/x/sys/unix/ztypes_linux_arm.go index bb103b02..db7c8bfa 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux_arm.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_arm.go @@ -156,6 +156,20 @@ type Flock_t struct { Pad_cgo_1 [4]byte } +type FscryptPolicy struct { + Version uint8 + Contents_encryption_mode uint8 + Filenames_encryption_mode uint8 + Flags uint8 + Master_key_descriptor [8]uint8 +} + +type FscryptKey struct { + Mode uint32 + Raw [64]uint8 + Size uint32 +} + const ( FADV_NORMAL = 0x0 FADV_RANDOM = 0x1 diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_arm64.go b/vendor/golang.org/x/sys/unix/ztypes_linux_arm64.go index 36ba9082..19cca4f0 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux_arm64.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_arm64.go @@ -155,6 +155,20 @@ type Flock_t struct { Pad_cgo_1 [4]byte } +type FscryptPolicy struct { + Version uint8 + Contents_encryption_mode uint8 + Filenames_encryption_mode uint8 + Flags uint8 + Master_key_descriptor [8]uint8 +} + +type FscryptKey struct { + Mode uint32 + Raw [64]uint8 + Size uint32 +} + const ( FADV_NORMAL = 0x0 FADV_RANDOM = 0x1 diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_mips.go b/vendor/golang.org/x/sys/unix/ztypes_linux_mips.go index ac79d82b..f97268cc 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux_mips.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_mips.go @@ -155,6 +155,20 @@ type Flock_t struct { Pad_cgo_1 [4]byte } +type FscryptPolicy struct { + Version uint8 + Contents_encryption_mode uint8 + Filenames_encryption_mode uint8 + Flags uint8 + Master_key_descriptor [8]uint8 +} + +type FscryptKey struct { + Mode uint32 + Raw [64]uint8 + Size uint32 +} + const ( FADV_NORMAL = 0x0 FADV_RANDOM = 0x1 @@ -554,17 +568,13 @@ type InotifyEvent struct { const SizeofInotifyEvent = 0x10 type PtraceRegs struct { - Regs [109]uint32 - U_tsize uint32 - U_dsize uint32 - U_ssize uint32 - Start_code uint32 - Start_data uint32 - Start_stack uint32 - Signal int32 - U_ar0 *byte - Magic uint32 - U_comm [32]int8 + Regs [32]uint64 + Lo uint64 + Hi uint64 + Epc uint64 + Badvaddr uint64 + Status uint64 + Cause uint64 } type FdSet struct { diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_mips64.go b/vendor/golang.org/x/sys/unix/ztypes_linux_mips64.go index 98c53a8f..8d062087 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux_mips64.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_mips64.go @@ -155,6 +155,20 @@ type Flock_t struct { Pad_cgo_1 [4]byte } +type FscryptPolicy struct { + Version uint8 + Contents_encryption_mode uint8 + Filenames_encryption_mode uint8 + Flags uint8 + Master_key_descriptor [8]uint8 +} + +type FscryptKey struct { + Mode uint32 + Raw [64]uint8 + Size uint32 +} + const ( FADV_NORMAL = 0x0 FADV_RANDOM = 0x1 @@ -556,17 +570,13 @@ type InotifyEvent struct { const SizeofInotifyEvent = 0x10 type PtraceRegs struct { - Regs [102]uint64 - U_tsize uint64 - U_dsize uint64 - U_ssize uint64 - Start_code uint64 - Start_data uint64 - Start_stack uint64 - Signal int64 - U_ar0 uint64 - Magic uint64 - U_comm [32]int8 + Regs [32]uint64 + Lo uint64 + Hi uint64 + Epc uint64 + Badvaddr uint64 + Status uint64 + Cause uint64 } type FdSet struct { diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_mips64le.go b/vendor/golang.org/x/sys/unix/ztypes_linux_mips64le.go index 99638abe..b1fbe717 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux_mips64le.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_mips64le.go @@ -155,6 +155,20 @@ type Flock_t struct { Pad_cgo_1 [4]byte } +type FscryptPolicy struct { + Version uint8 + Contents_encryption_mode uint8 + Filenames_encryption_mode uint8 + Flags uint8 + Master_key_descriptor [8]uint8 +} + +type FscryptKey struct { + Mode uint32 + Raw [64]uint8 + Size uint32 +} + const ( FADV_NORMAL = 0x0 FADV_RANDOM = 0x1 @@ -556,17 +570,13 @@ type InotifyEvent struct { const SizeofInotifyEvent = 0x10 type PtraceRegs struct { - Regs [102]uint64 - U_tsize uint64 - U_dsize uint64 - U_ssize uint64 - Start_code uint64 - Start_data uint64 - Start_stack uint64 - Signal int64 - U_ar0 uint64 - Magic uint64 - U_comm [32]int8 + Regs [32]uint64 + Lo uint64 + Hi uint64 + Epc uint64 + Badvaddr uint64 + Status uint64 + Cause uint64 } type FdSet struct { diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_mipsle.go b/vendor/golang.org/x/sys/unix/ztypes_linux_mipsle.go index b7131a43..b634e3c2 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux_mipsle.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_mipsle.go @@ -155,6 +155,20 @@ type Flock_t struct { Pad_cgo_1 [4]byte } +type FscryptPolicy struct { + Version uint8 + Contents_encryption_mode uint8 + Filenames_encryption_mode uint8 + Flags uint8 + Master_key_descriptor [8]uint8 +} + +type FscryptKey struct { + Mode uint32 + Raw [64]uint8 + Size uint32 +} + const ( FADV_NORMAL = 0x0 FADV_RANDOM = 0x1 @@ -554,17 +568,13 @@ type InotifyEvent struct { const SizeofInotifyEvent = 0x10 type PtraceRegs struct { - Regs [109]uint32 - U_tsize uint32 - U_dsize uint32 - U_ssize uint32 - Start_code uint32 - Start_data uint32 - Start_stack uint32 - Signal int32 - U_ar0 *byte - Magic uint32 - U_comm [32]int8 + Regs [32]uint64 + Lo uint64 + Hi uint64 + Epc uint64 + Badvaddr uint64 + Status uint64 + Cause uint64 } type FdSet struct { diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_ppc64.go b/vendor/golang.org/x/sys/unix/ztypes_linux_ppc64.go index a78282b1..4410abb8 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux_ppc64.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_ppc64.go @@ -156,6 +156,20 @@ type Flock_t struct { Pad_cgo_1 [4]byte } +type FscryptPolicy struct { + Version uint8 + Contents_encryption_mode uint8 + Filenames_encryption_mode uint8 + Flags uint8 + Master_key_descriptor [8]uint8 +} + +type FscryptKey struct { + Mode uint32 + Raw [64]uint8 + Size uint32 +} + const ( FADV_NORMAL = 0x0 FADV_RANDOM = 0x1 diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_ppc64le.go b/vendor/golang.org/x/sys/unix/ztypes_linux_ppc64le.go index 564092e2..10947c3e 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux_ppc64le.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_ppc64le.go @@ -156,6 +156,20 @@ type Flock_t struct { Pad_cgo_1 [4]byte } +type FscryptPolicy struct { + Version uint8 + Contents_encryption_mode uint8 + Filenames_encryption_mode uint8 + Flags uint8 + Master_key_descriptor [8]uint8 +} + +type FscryptKey struct { + Mode uint32 + Raw [64]uint8 + Size uint32 +} + const ( FADV_NORMAL = 0x0 FADV_RANDOM = 0x1 diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_s390x.go b/vendor/golang.org/x/sys/unix/ztypes_linux_s390x.go index 03452c6d..57dbb36b 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux_s390x.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_s390x.go @@ -155,6 +155,20 @@ type Flock_t struct { _ [4]byte } +type FscryptPolicy struct { + Version uint8 + Contents_encryption_mode uint8 + Filenames_encryption_mode uint8 + Flags uint8 + Master_key_descriptor [8]uint8 +} + +type FscryptKey struct { + Mode uint32 + Raw [64]uint8 + Size uint32 +} + const ( FADV_NORMAL = 0x0 FADV_RANDOM = 0x1 diff --git a/vendor/golang.org/x/sys/unix/ztypes_solaris_amd64.go b/vendor/golang.org/x/sys/unix/ztypes_solaris_amd64.go index 02777e4d..92336f9f 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_solaris_amd64.go +++ b/vendor/golang.org/x/sys/unix/ztypes_solaris_amd64.go @@ -1,6 +1,7 @@ -// +build amd64,solaris -// Created by cgo -godefs - DO NOT EDIT // cgo -godefs types_solaris.go | go run mkpost.go +// Code generated by the command above; see README.md. DO NOT EDIT. + +// +build amd64,solaris package unix @@ -128,6 +129,24 @@ type Dirent struct { Pad_cgo_0 [5]byte } +type _Fsblkcnt_t uint64 + +type Statvfs_t struct { + Bsize uint64 + Frsize uint64 + Blocks uint64 + Bfree uint64 + Bavail uint64 + Files uint64 + Ffree uint64 + Favail uint64 + Fsid uint64 + Basetype [16]int8 + Flag uint64 + Namemax uint64 + Fstr [32]int8 +} + type RawSockaddrInet4 struct { Family uint16 Port uint16 From f7a78edeaeb5fa5965beca1831e407080154e538 Mon Sep 17 00:00:00 2001 From: Suraj Deshmukh Date: Mon, 15 May 2017 21:11:52 +0530 Subject: [PATCH 04/12] remove duplicate import with different name `k8s.io/kubernetes/pkg/api` is imported directly and once with the alias import name `kapi` so remove the original import and keep the aliased with `kapi` one and also replace the code bits which call it with `api` name. --- pkg/transformer/openshift/openshift.go | 39 +++++++++++++------------- 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/pkg/transformer/openshift/openshift.go b/pkg/transformer/openshift/openshift.go index 1d5e3a69..25436b48 100644 --- a/pkg/transformer/openshift/openshift.go +++ b/pkg/transformer/openshift/openshift.go @@ -28,7 +28,6 @@ import ( log "github.com/Sirupsen/logrus" - "k8s.io/kubernetes/pkg/api" kapi "k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/api/unversioned" "k8s.io/kubernetes/pkg/client/unversioned/clientcmd" @@ -39,6 +38,8 @@ import ( "time" + "reflect" + "github.com/kubernetes-incubator/kompose/pkg/transformer" buildapi "github.com/openshift/origin/pkg/build/api" deployapi "github.com/openshift/origin/pkg/deploy/api" @@ -50,7 +51,6 @@ import ( "k8s.io/kubernetes/pkg/kubectl" "k8s.io/kubernetes/pkg/labels" "k8s.io/kubernetes/pkg/util/intstr" - "reflect" ) // OpenShift implements Transformer interface and represents OpenShift transformer @@ -172,7 +172,7 @@ func (o *OpenShift) initImageStream(name string, service kobject.ServiceConfig, if service.Build == "" { tags = map[string]imageapi.TagReference{ tag: imageapi.TagReference{ - From: &api.ObjectReference{ + From: &kapi.ObjectReference{ Kind: "DockerImage", Name: service.Image, }, @@ -186,7 +186,7 @@ func (o *OpenShift) initImageStream(name string, service kobject.ServiceConfig, Kind: "ImageStream", APIVersion: "v1", }, - ObjectMeta: api.ObjectMeta{ + ObjectMeta: kapi.ObjectMeta{ Name: name, Labels: transformer.ConfigLabels(name), }, @@ -209,7 +209,7 @@ func initBuildConfig(name string, service kobject.ServiceConfig, repo string, br Kind: "BuildConfig", APIVersion: "v1", }, - ObjectMeta: api.ObjectMeta{ + ObjectMeta: kapi.ObjectMeta{ Name: name, }, Spec: buildapi.BuildConfigSpec{ @@ -258,7 +258,7 @@ func (o *OpenShift) initDeploymentConfig(name string, service kobject.ServiceCon Kind: "DeploymentConfig", APIVersion: "v1", }, - ObjectMeta: api.ObjectMeta{ + ObjectMeta: kapi.ObjectMeta{ Name: name, Labels: transformer.ConfigLabels(name), }, @@ -266,8 +266,8 @@ func (o *OpenShift) initDeploymentConfig(name string, service kobject.ServiceCon Replicas: int32(replicas), Selector: transformer.ConfigLabels(name), //UniqueLabelKey: p.Name, - Template: &api.PodTemplateSpec{ - ObjectMeta: api.ObjectMeta{ + Template: &kapi.PodTemplateSpec{ + ObjectMeta: kapi.ObjectMeta{ Labels: transformer.ConfigLabels(name), }, Spec: o.InitPodSpec(name, " "), @@ -283,7 +283,7 @@ func (o *OpenShift) initDeploymentConfig(name string, service kobject.ServiceCon //Automatic - if new tag is detected - update image update inside the pod template Automatic: true, ContainerNames: containerName, - From: api.ObjectReference{ + From: kapi.ObjectReference{ Name: name + ":" + tag, Kind: "ImageStreamTag", }, @@ -301,7 +301,7 @@ func (o *OpenShift) initRoute(name string, service kobject.ServiceConfig, port i Kind: "Route", APIVersion: "v1", }, - ObjectMeta: api.ObjectMeta{ + ObjectMeta: kapi.ObjectMeta{ Name: name, Labels: transformer.ConfigLabels(name), }, @@ -488,13 +488,13 @@ func (o *OpenShift) Deploy(komposeObject kobject.KomposeObject, opt kobject.Conv return err } log.Infof("Successfully created DeploymentConfig: %s", t.Name) - case *api.Service: + case *kapi.Service: _, err := kclient.Services(namespace).Create(t) if err != nil { return err } log.Infof("Successfully created Service: %s", t.Name) - case *api.PersistentVolumeClaim: + case *kapi.PersistentVolumeClaim: _, err := kclient.PersistentVolumeClaims(namespace).Create(t) if err != nil { return err @@ -506,7 +506,7 @@ func (o *OpenShift) Deploy(komposeObject kobject.KomposeObject, opt kobject.Conv return err } log.Infof("Successfully created Route: %s", t.Name) - case *api.Pod: + case *kapi.Pod: _, err := kclient.Pods(namespace).Create(t) if err != nil { return err @@ -554,7 +554,7 @@ func (o *OpenShift) Undeploy(komposeObject kobject.KomposeObject, opt kobject.Co for _, v := range objects { label := labels.SelectorFromSet(labels.Set(map[string]string{transformer.Selector: v.(meta.Object).GetName()})) - options := api.ListOptions{LabelSelector: label} + options := kapi.ListOptions{LabelSelector: label} komposeLabel := map[string]string{transformer.Selector: v.(meta.Object).GetName()} switch t := v.(type) { case *imageapi.ImageStream: @@ -576,7 +576,6 @@ func (o *OpenShift) Undeploy(komposeObject kobject.KomposeObject, opt kobject.Co } case *buildapi.BuildConfig: - //options := api.ListOptions{LabelSelector: label} buildConfig, err := oclient.BuildConfigs(namespace).List(options) if err != nil { errorList = append(errorList, err) @@ -612,7 +611,7 @@ func (o *OpenShift) Undeploy(komposeObject kobject.KomposeObject, opt kobject.Co } } - case *api.Service: + case *kapi.Service: //delete svc svc, err := kclient.Services(namespace).List(options) if err != nil { @@ -621,7 +620,7 @@ func (o *OpenShift) Undeploy(komposeObject kobject.KomposeObject, opt kobject.Co } for _, l := range svc.Items { if reflect.DeepEqual(l.Labels, komposeLabel) { - rpService, err := kubectl.ReaperFor(api.Kind("Service"), kclient) + rpService, err := kubectl.ReaperFor(kapi.Kind("Service"), kclient) if err != nil { errorList = append(errorList, err) break @@ -636,7 +635,7 @@ func (o *OpenShift) Undeploy(komposeObject kobject.KomposeObject, opt kobject.Co } } - case *api.PersistentVolumeClaim: + case *kapi.PersistentVolumeClaim: // delete pvc pvc, err := kclient.PersistentVolumeClaims(namespace).List(options) if err != nil { @@ -672,7 +671,7 @@ func (o *OpenShift) Undeploy(komposeObject kobject.KomposeObject, opt kobject.Co } } - case *api.Pod: + case *kapi.Pod: //delete pods pod, err := kclient.Pods(namespace).List(options) if err != nil { @@ -681,7 +680,7 @@ func (o *OpenShift) Undeploy(komposeObject kobject.KomposeObject, opt kobject.Co } for _, l := range pod.Items { if reflect.DeepEqual(l.Labels, komposeLabel) { - rpPod, err := kubectl.ReaperFor(api.Kind("Pod"), kclient) + rpPod, err := kubectl.ReaperFor(kapi.Kind("Pod"), kclient) if err != nil { errorList = append(errorList, err) break From 8fc262bd99b9c1f8e5e2821702e49b8ee9453f44 Mon Sep 17 00:00:00 2001 From: Suraj Narwade Date: Mon, 13 Feb 2017 12:15:21 +0530 Subject: [PATCH 05/12] Add build_args support in buildconfig now args provided under build in docker-compose file can be available in buildconfig. it solves #406 Added unit test and functional test solves #445 Separated key:"value" pairs by spaces --- pkg/kobject/kobject.go | 1 + pkg/loader/compose/compose.go | 1 + pkg/transformer/openshift/openshift.go | 8 + pkg/transformer/openshift/openshift_test.go | 15 +- script/test/cmd/tests.sh | 22 +- script/test/fixtures/buildargs/README.md | 11 + .../test/fixtures/buildargs/build/Dockerfile | 2 + .../fixtures/buildargs/docker-compose.yml | 16 + script/test/fixtures/buildargs/envs | 1 + .../buildargs/output-os-template.json | 319 ++++++++++++++++++ 10 files changed, 385 insertions(+), 11 deletions(-) create mode 100644 script/test/fixtures/buildargs/README.md create mode 100644 script/test/fixtures/buildargs/build/Dockerfile create mode 100644 script/test/fixtures/buildargs/docker-compose.yml create mode 100644 script/test/fixtures/buildargs/envs create mode 100644 script/test/fixtures/buildargs/output-os-template.json diff --git a/pkg/kobject/kobject.go b/pkg/kobject/kobject.go index 8c95ba2f..594ee085 100644 --- a/pkg/kobject/kobject.go +++ b/pkg/kobject/kobject.go @@ -82,6 +82,7 @@ type ServiceConfig struct { VolumesFrom []string `compose:"volumes_from" bundle:""` ServiceType string `compose:"kompose.service.type" bundle:""` Build string `compose:"build" bundle:""` + BuildArgs map[string]*string `compose:"build-args" bundle:""` ExposeService string `compose:"kompose.service.expose" bundle:""` Stdin bool `compose:"stdin_open" bundle:""` Tty bool `compose:"tty" bundle:""` diff --git a/pkg/loader/compose/compose.go b/pkg/loader/compose/compose.go index 542f5c31..e8c093c6 100644 --- a/pkg/loader/compose/compose.go +++ b/pkg/loader/compose/compose.go @@ -321,6 +321,7 @@ func (c *Compose) LoadFile(files []string) (kobject.KomposeObject, error) { serviceConfig.Command = composeServiceConfig.Entrypoint serviceConfig.Args = composeServiceConfig.Command serviceConfig.Dockerfile = composeServiceConfig.Build.Dockerfile + serviceConfig.BuildArgs = composeServiceConfig.Build.Args envs := loadEnvVars(composeServiceConfig.Environment) serviceConfig.Environment = envs diff --git a/pkg/transformer/openshift/openshift.go b/pkg/transformer/openshift/openshift.go index 25436b48..975fe8c4 100644 --- a/pkg/transformer/openshift/openshift.go +++ b/pkg/transformer/openshift/openshift.go @@ -200,6 +200,13 @@ func (o *OpenShift) initImageStream(name string, service kobject.ServiceConfig, // initBuildConfig initialize Openshifts BuildConfig Object func initBuildConfig(name string, service kobject.ServiceConfig, repo string, branch string) (*buildapi.BuildConfig, error) { contextDir, err := getAbsBuildContext(service.Build) + envList := []kapi.EnvVar{} + for envName, envValue := range service.BuildArgs { + if *envValue == "\x00" { + *envValue = os.Getenv(envName) + } + envList = append(envList, kapi.EnvVar{Name: envName, Value: *envValue}) + } if err != nil { return nil, errors.Wrap(err, name+"buildconfig cannot be created due to error in creating build context, getAbsBuildContext failed") } @@ -229,6 +236,7 @@ func initBuildConfig(name string, service kobject.ServiceConfig, repo string, br Strategy: buildapi.BuildStrategy{ DockerStrategy: &buildapi.DockerBuildStrategy{ DockerfilePath: service.Dockerfile, + Env: envList, }, }, Output: buildapi.BuildOutput{ diff --git a/pkg/transformer/openshift/openshift_test.go b/pkg/transformer/openshift/openshift_test.go index c1d74fe5..f88f3844 100644 --- a/pkg/transformer/openshift/openshift_test.go +++ b/pkg/transformer/openshift/openshift_test.go @@ -17,13 +17,13 @@ limitations under the License. package openshift import ( + kapi "k8s.io/kubernetes/pkg/api" + "k8s.io/kubernetes/pkg/runtime" "os" "path/filepath" + "reflect" "testing" - "k8s.io/kubernetes/pkg/api" - "k8s.io/kubernetes/pkg/runtime" - deployapi "github.com/openshift/origin/pkg/deploy/api" "github.com/kubernetes-incubator/kompose/pkg/kobject" @@ -37,7 +37,7 @@ func newServiceConfig() kobject.ServiceConfig { ContainerName: "myfoobarname", Image: "image", Environment: []kobject.EnvVar{kobject.EnvVar{Name: "env", Value: "value"}}, - Port: []kobject.Ports{kobject.Ports{HostPort: 123, ContainerPort: 456, Protocol: api.ProtocolTCP}}, + Port: []kobject.Ports{kobject.Ports{HostPort: 123, ContainerPort: 456, Protocol: kapi.ProtocolTCP}}, Command: []string{"cmd"}, WorkingDir: "dir", Args: []string{"arg1", "arg2"}, @@ -288,9 +288,12 @@ func TestInitBuildConfig(t *testing.T) { serviceName := "serviceA" repo := "https://git.test.com/org/repo" branch := "somebranch" + buildArgs := []kapi.EnvVar{{Name: "name", Value: "value"}} + value := "value" sc := kobject.ServiceConfig{ Build: filepath.Join(dir, "a/build"), Dockerfile: "Dockerfile-alternate", + BuildArgs: map[string]*string{"name": &value}, } bc, err := initBuildConfig(serviceName, sc, repo, branch) if err != nil { @@ -307,13 +310,15 @@ func TestInitBuildConfig(t *testing.T) { "Assert buildconfig output name": {bc.Spec.CommonSpec.Output.To.Name, serviceName + ":latest"}, "Assert buildconfig dockerfilepath": {bc.Spec.CommonSpec.Strategy.DockerStrategy.DockerfilePath, "Dockerfile-alternate"}, } - for name, test := range testCases { t.Log("Test case: ", name) if test.field != test.value { t.Errorf("Expected: %#v, got: %#v", test.value, test.field) } } + if !reflect.DeepEqual(bc.Spec.CommonSpec.Strategy.DockerStrategy.Env, buildArgs) { + t.Errorf("Expected: %#v, got: %#v", bc.Spec.CommonSpec.Strategy.DockerStrategy.Env, buildArgs) + } } // TestServiceWithoutPort this tests if Headless Service is created for services without Port. diff --git a/script/test/cmd/tests.sh b/script/test/cmd/tests.sh index 07aed44c..618ffda3 100755 --- a/script/test/cmd/tests.sh +++ b/script/test/cmd/tests.sh @@ -27,8 +27,6 @@ fi # Warning Template warning="Buildconfig using $uri::$branch as source." -# Replacing variables with current branch and uri -sed -e "s;%URI%;$uri;g" -e "s;%REF%;$branch;g" $KOMPOSE_ROOT/script/test/fixtures/nginx-node-redis/output-os-template.json > /tmp/output-os.json ####### # Tests related to docker-compose file in /script/test/fixtures/etherpad @@ -58,11 +56,15 @@ unset $(cat $KOMPOSE_ROOT/script/test/fixtures/gitlab/envs | cut -d'=' -f1) # kubernetes test convert::expect_success_and_warning "kompose -f $KOMPOSE_ROOT/script/test/fixtures/nginx-node-redis/docker-compose.yml convert --stdout -j" "$KOMPOSE_ROOT/script/test/fixtures/nginx-node-redis/output-k8s.json" "Kubernetes provider doesn't support build key - ignoring" # openshift test +# Replacing variables with current branch and uri +sed -e "s;%URI%;$uri;g" -e "s;%REF%;$branch;g" $KOMPOSE_ROOT/script/test/fixtures/nginx-node-redis/output-os-template.json > /tmp/output-os.json convert::expect_success_and_warning "kompose --provider=openshift -f $KOMPOSE_ROOT/script/test/fixtures/nginx-node-redis/docker-compose.yml convert --stdout -j" "/tmp/output-os.json" "$warning" +rm /tmp/output-os.json + ###### # Tests related to docker-compose file in /script/test/fixtures/entrypoint-command # kubernetes test -convert::expect_success "kompose -f $KOMPOSE_ROOT/script/test/fixtures/entrypoint-command/docker-compose.yml convert --stdout -j" "$KOMPOSE_ROOT/script/test/fixtures/entrypoint-command/output-k8s.json" +convert::expect_success "kompose -f $KOMPOSE_ROOT/script/test/fixtures/entrypoint-command/docker-compose.yml convert --stdout -j" "$KOMPOSE_ROOT/script/test/fixtures/entrypoint-command/output-k8s.json" # openshift test convert::expect_success "kompose --provider=openshift -f $KOMPOSE_ROOT/script/test/fixtures/entrypoint-command/docker-compose.yml convert --stdout -j" "$KOMPOSE_ROOT/script/test/fixtures/entrypoint-command/output-os.json" @@ -209,6 +211,8 @@ convert::check_artifacts_generated "kompose -f $KOMPOSE_ROOT/script/test/fixture #### # Test regarding build context (running kompose from various directories) +# Replacing variables with current branch and uri +sed -e "s;%URI%;$uri;g" -e "s;%REF%;$branch;g" $KOMPOSE_ROOT/script/test/fixtures/nginx-node-redis/output-os-template.json > /tmp/output-os.json CURRENT_DIR=$(pwd) cd "$KOMPOSE_ROOT/script/test/fixtures/nginx-node-redis/" convert::expect_success_and_warning "kompose convert --provider openshift --stdout -j" "/tmp/output-os.json" "$warning" @@ -217,6 +221,15 @@ convert::expect_success_and_warning "kompose convert --provider openshift --stdo cd "$KOMPOSE_ROOT/script/test/fixtures/nginx-node-redis/node" convert::expect_success_and_warning "kompose convert --provider openshift --stdout -j -f ../docker-compose.yml" "/tmp/output-os.json" "$warning" cd $CURRENT_DIR +rm /tmp/output-os.json + + +# Test the presence of build args in buildconfig +# Replacing variables with current branch and uri +sed -e "s;%URI%;$uri;g" -e "s;%REF%;$branch;g" $KOMPOSE_ROOT/script/test/fixtures/buildargs/output-os-template.json > /tmp/output-buildarg-os.json +export $(cat $KOMPOSE_ROOT/script/test/fixtures/buildargs/envs) +convert::expect_success_and_warning "kompose --provider openshift -f $KOMPOSE_ROOT/script/test/fixtures/buildargs/docker-compose.yml convert --stdout -j" "/tmp/output-buildarg-os.json" "$warning" +rm /tmp/output-buildarg-os.json # Test related to support docker-compose.yaml beside docker-compose.yml # Store the original path @@ -234,7 +247,4 @@ convert::expect_success "kompose --provider=openshift convert --stdout -j" "$KOM # Return back to the original path cd $CURRENT_DIR -# Removes generated output -rm -rf /tmp/output-os.json - exit $EXIT_STATUS diff --git a/script/test/fixtures/buildargs/README.md b/script/test/fixtures/buildargs/README.md new file mode 100644 index 00000000..bf97166a --- /dev/null +++ b/script/test/fixtures/buildargs/README.md @@ -0,0 +1,11 @@ +## Docker Compose Buildargs + +### Usage + +The simplest thing to do: + +```bash +export $(cat envs) +``` + +To customize the values edit `envs` file. diff --git a/script/test/fixtures/buildargs/build/Dockerfile b/script/test/fixtures/buildargs/build/Dockerfile new file mode 100644 index 00000000..f094e685 --- /dev/null +++ b/script/test/fixtures/buildargs/build/Dockerfile @@ -0,0 +1,2 @@ +FROM busybox +RUN touch /test \ No newline at end of file diff --git a/script/test/fixtures/buildargs/docker-compose.yml b/script/test/fixtures/buildargs/docker-compose.yml new file mode 100644 index 00000000..ff319374 --- /dev/null +++ b/script/test/fixtures/buildargs/docker-compose.yml @@ -0,0 +1,16 @@ +version: "2" + +services: + foo: + build: + context: "./build" + args: + NAME: web + command: "sleep 3600" + foo1: + build: + context: "./build" + args: + - NAME=web + - foo + command: "sleep 3600" diff --git a/script/test/fixtures/buildargs/envs b/script/test/fixtures/buildargs/envs new file mode 100644 index 00000000..74d0a43f --- /dev/null +++ b/script/test/fixtures/buildargs/envs @@ -0,0 +1 @@ +foo=bar diff --git a/script/test/fixtures/buildargs/output-os-template.json b/script/test/fixtures/buildargs/output-os-template.json new file mode 100644 index 00000000..04ce1e9c --- /dev/null +++ b/script/test/fixtures/buildargs/output-os-template.json @@ -0,0 +1,319 @@ +{ + "kind": "List", + "apiVersion": "v1", + "metadata": {}, + "items": [ + { + "kind": "Service", + "apiVersion": "v1", + "metadata": { + "name": "foo1", + "creationTimestamp": null, + "labels": { + "io.kompose.service": "foo1" + } + }, + "spec": { + "ports": [ + { + "name": "headless", + "port": 55555, + "targetPort": 0 + } + ], + "selector": { + "io.kompose.service": "foo1" + }, + "clusterIP": "None" + }, + "status": { + "loadBalancer": {} + } + }, + { + "kind": "Service", + "apiVersion": "v1", + "metadata": { + "name": "foo", + "creationTimestamp": null, + "labels": { + "io.kompose.service": "foo" + } + }, + "spec": { + "ports": [ + { + "name": "headless", + "port": 55555, + "targetPort": 0 + } + ], + "selector": { + "io.kompose.service": "foo" + }, + "clusterIP": "None" + }, + "status": { + "loadBalancer": {} + } + }, + { + "kind": "DeploymentConfig", + "apiVersion": "v1", + "metadata": { + "name": "foo1", + "creationTimestamp": null, + "labels": { + "io.kompose.service": "foo1" + } + }, + "spec": { + "strategy": { + "resources": {} + }, + "triggers": [ + { + "type": "ConfigChange" + }, + { + "type": "ImageChange", + "imageChangeParams": { + "automatic": true, + "containerNames": [ + "foo1" + ], + "from": { + "kind": "ImageStreamTag", + "name": "foo1:latest" + } + } + } + ], + "replicas": 1, + "test": false, + "selector": { + "io.kompose.service": "foo1" + }, + "template": { + "metadata": { + "creationTimestamp": null, + "labels": { + "io.kompose.service": "foo1" + } + }, + "spec": { + "containers": [ + { + "name": "foo1", + "image": " ", + "args": [ + "sleep", + "3600" + ], + "resources": {} + } + ], + "restartPolicy": "Always" + } + } + }, + "status": {} + }, + { + "kind": "ImageStream", + "apiVersion": "v1", + "metadata": { + "name": "foo1", + "creationTimestamp": null, + "labels": { + "io.kompose.service": "foo1" + } + }, + "spec": {}, + "status": { + "dockerImageRepository": "" + } + }, + { + "kind": "BuildConfig", + "apiVersion": "v1", + "metadata": { + "name": "foo1", + "creationTimestamp": null + }, + "spec": { + "triggers": [ + { + "type": "ConfigChange" + }, + { + "type": "ImageChange" + } + ], + "runPolicy": "Serial", + "source": { + "type": "Git", + "git": { + "uri": "%URI%", + "ref": "%REF%" + }, + "contextDir": "script/test/fixtures/buildargs/build/" + }, + "strategy": { + "type": "Docker", + "dockerStrategy": { + "env": [ + { + "name": "NAME", + "value": "web" + }, + { + "name": "foo", + "value": "bar" + } + ] + } + }, + "output": { + "to": { + "kind": "ImageStreamTag", + "name": "foo1:latest" + } + }, + "resources": {}, + "postCommit": {}, + "nodeSelector": null + }, + "status": { + "lastVersion": 0 + } + }, + { + "kind": "DeploymentConfig", + "apiVersion": "v1", + "metadata": { + "name": "foo", + "creationTimestamp": null, + "labels": { + "io.kompose.service": "foo" + } + }, + "spec": { + "strategy": { + "resources": {} + }, + "triggers": [ + { + "type": "ConfigChange" + }, + { + "type": "ImageChange", + "imageChangeParams": { + "automatic": true, + "containerNames": [ + "foo" + ], + "from": { + "kind": "ImageStreamTag", + "name": "foo:latest" + } + } + } + ], + "replicas": 1, + "test": false, + "selector": { + "io.kompose.service": "foo" + }, + "template": { + "metadata": { + "creationTimestamp": null, + "labels": { + "io.kompose.service": "foo" + } + }, + "spec": { + "containers": [ + { + "name": "foo", + "image": " ", + "args": [ + "sleep", + "3600" + ], + "resources": {} + } + ], + "restartPolicy": "Always" + } + } + }, + "status": {} + }, + { + "kind": "ImageStream", + "apiVersion": "v1", + "metadata": { + "name": "foo", + "creationTimestamp": null, + "labels": { + "io.kompose.service": "foo" + } + }, + "spec": {}, + "status": { + "dockerImageRepository": "" + } + }, + { + "kind": "BuildConfig", + "apiVersion": "v1", + "metadata": { + "name": "foo", + "creationTimestamp": null + }, + "spec": { + "triggers": [ + { + "type": "ConfigChange" + }, + { + "type": "ImageChange" + } + ], + "runPolicy": "Serial", + "source": { + "type": "Git", + "git": { + "uri": "%URI%", + "ref": "%REF%" + }, + "contextDir": "script/test/fixtures/buildargs/build/" + }, + "strategy": { + "type": "Docker", + "dockerStrategy": { + "env": [ + { + "name": "NAME", + "value": "web" + } + ] + } + }, + "output": { + "to": { + "kind": "ImageStreamTag", + "name": "foo:latest" + } + }, + "resources": {}, + "postCommit": {}, + "nodeSelector": null + }, + "status": { + "lastVersion": 0 + } + } + ] +} From 792976da1f61db3972d6b701e80da7368aa3c4a0 Mon Sep 17 00:00:00 2001 From: Tomas Kral Date: Thu, 27 Apr 2017 13:27:49 +0200 Subject: [PATCH 06/12] some of created objects were missing io.kompose.service label label added to BuildConfig, DaemonSet, ReplicationController, Deployment and Pod --- pkg/transformer/kubernetes/kubernetes.go | 12 ++-- pkg/transformer/kubernetes/kubernetes_test.go | 8 +-- pkg/transformer/openshift/openshift.go | 4 +- .../buildargs/output-os-template.json | 10 ++- .../test/fixtures/bundles/dab/output-k8s.json | 10 ++- .../test/fixtures/bundles/dsb/output-k8s.json | 21 +++++- .../entrypoint-command/output-k8s.json | 5 +- .../envvars-separators/output-k8s.json | 65 +++++++++++++++---- script/test/fixtures/etherpad/output-k8s.json | 10 ++- ...rnetes-expose-hostname-multiple-ports.json | 8 ++- .../kubernetes-expose-hostname.json | 8 ++- ...kubernetes-expose-true-multiple-ports.json | 8 ++- .../kubernetes-expose-true.json | 8 ++- script/test/fixtures/gitlab/output-k8s.json | 15 ++++- .../fixtures/keyonly-envs/output-k8s.json | 15 ++++- .../test/fixtures/mem-limit/output-k8s.json | 5 +- .../fixtures/mem-limit/output-mb-k8s.json | 5 +- .../multiple-compose-files/output-k8s.json | 10 ++- .../fixtures/nginx-node-redis/output-k8s.json | 25 +++++-- .../nginx-node-redis/output-os-template.json | 22 +++++-- .../fixtures/ports-with-ip/output-k8s.json | 10 ++- .../fixtures/ports-with-proto/output-k8s.json | 10 ++- .../service-name-change/output-k8s.json | 10 ++- .../test/fixtures/stdin-true/output-k8s.json | 5 +- script/test/fixtures/tty-true/output-k8s.json | 5 +- .../simple-vol-mounts/output-k8s.json | 5 +- .../volumes-from/output-k8s.json | 10 ++- .../fixtures/yaml-and-yml/output-k8s.json | 10 ++- .../fixtures/yaml-and-yml/yml/output-k8s.json | 10 ++- 29 files changed, 278 insertions(+), 71 deletions(-) diff --git a/pkg/transformer/kubernetes/kubernetes.go b/pkg/transformer/kubernetes/kubernetes.go index e1b55ae6..15c6a9cc 100644 --- a/pkg/transformer/kubernetes/kubernetes.go +++ b/pkg/transformer/kubernetes/kubernetes.go @@ -130,7 +130,8 @@ func (k *Kubernetes) InitRC(name string, service kobject.ServiceConfig, replicas APIVersion: "v1", }, ObjectMeta: api.ObjectMeta{ - Name: name, + Name: name, + Labels: transformer.ConfigLabels(name), }, Spec: api.ReplicationControllerSpec{ Replicas: int32(replicas), @@ -171,7 +172,8 @@ func (k *Kubernetes) InitD(name string, service kobject.ServiceConfig, replicas APIVersion: "extensions/v1beta1", }, ObjectMeta: api.ObjectMeta{ - Name: name, + Name: name, + Labels: transformer.ConfigLabels(name), }, Spec: extensions.DeploymentSpec{ Replicas: int32(replicas), @@ -191,7 +193,8 @@ func (k *Kubernetes) InitDS(name string, service kobject.ServiceConfig) *extensi APIVersion: "extensions/v1beta1", }, ObjectMeta: api.ObjectMeta{ - Name: name, + Name: name, + Labels: transformer.ConfigLabels(name), }, Spec: extensions.DaemonSetSpec{ Template: api.PodTemplateSpec{ @@ -513,7 +516,8 @@ func (k *Kubernetes) InitPod(name string, service kobject.ServiceConfig) *api.Po APIVersion: "v1", }, ObjectMeta: api.ObjectMeta{ - Name: name, + Name: name, + Labels: transformer.ConfigLabels(name), }, Spec: k.InitPodSpec(name, service.Image), } diff --git a/pkg/transformer/kubernetes/kubernetes_test.go b/pkg/transformer/kubernetes/kubernetes_test.go index 19e8fc77..9489c033 100644 --- a/pkg/transformer/kubernetes/kubernetes_test.go +++ b/pkg/transformer/kubernetes/kubernetes_test.go @@ -311,7 +311,7 @@ func TestKomposeConvert(t *testing.T) { if err := checkPodTemplate(config, d.Spec.Template, labels); err != nil { t.Errorf("%v", err) } - if err := checkMeta(config, d.ObjectMeta, name, false); err != nil { + if err := checkMeta(config, d.ObjectMeta, name, true); err != nil { t.Errorf("%v", err) } if (int)(d.Spec.Replicas) != replicas { @@ -328,7 +328,7 @@ func TestKomposeConvert(t *testing.T) { if err := checkPodTemplate(config, ds.Spec.Template, labels); err != nil { t.Errorf("%v", err) } - if err := checkMeta(config, ds.ObjectMeta, name, false); err != nil { + if err := checkMeta(config, ds.ObjectMeta, name, true); err != nil { t.Errorf("%v", err) } if ds.Spec.Selector != nil && len(ds.Spec.Selector.MatchLabels) > 0 { @@ -342,7 +342,7 @@ func TestKomposeConvert(t *testing.T) { if err := checkPodTemplate(config, *rc.Spec.Template, labels); err != nil { t.Errorf("%v", err) } - if err := checkMeta(config, rc.ObjectMeta, name, false); err != nil { + if err := checkMeta(config, rc.ObjectMeta, name, true); err != nil { t.Errorf("%v", err) } if (int)(rc.Spec.Replicas) != replicas { @@ -360,7 +360,7 @@ func TestKomposeConvert(t *testing.T) { if err := checkPodTemplate(config, *dc.Spec.Template, labels); err != nil { t.Errorf("%v", err) } - if err := checkMeta(config, dc.ObjectMeta, name, false); err != nil { + if err := checkMeta(config, dc.ObjectMeta, name, true); err != nil { t.Errorf("%v", err) } if (int)(dc.Spec.Replicas) != replicas { diff --git a/pkg/transformer/openshift/openshift.go b/pkg/transformer/openshift/openshift.go index 975fe8c4..93709bc7 100644 --- a/pkg/transformer/openshift/openshift.go +++ b/pkg/transformer/openshift/openshift.go @@ -216,8 +216,10 @@ func initBuildConfig(name string, service kobject.ServiceConfig, repo string, br Kind: "BuildConfig", APIVersion: "v1", }, + ObjectMeta: kapi.ObjectMeta{ - Name: name, + Name: name, + Labels: transformer.ConfigLabels(name), }, Spec: buildapi.BuildConfigSpec{ Triggers: []buildapi.BuildTriggerPolicy{ diff --git a/script/test/fixtures/buildargs/output-os-template.json b/script/test/fixtures/buildargs/output-os-template.json index 04ce1e9c..4150b830 100644 --- a/script/test/fixtures/buildargs/output-os-template.json +++ b/script/test/fixtures/buildargs/output-os-template.json @@ -139,7 +139,10 @@ "apiVersion": "v1", "metadata": { "name": "foo1", - "creationTimestamp": null + "creationTimestamp": null, + "labels": { + "io.kompose.service": "foo1" + } }, "spec": { "triggers": [ @@ -270,7 +273,10 @@ "apiVersion": "v1", "metadata": { "name": "foo", - "creationTimestamp": null + "creationTimestamp": null, + "labels": { + "io.kompose.service": "foo" + } }, "spec": { "triggers": [ diff --git a/script/test/fixtures/bundles/dab/output-k8s.json b/script/test/fixtures/bundles/dab/output-k8s.json index bccaf809..f0a75e36 100644 --- a/script/test/fixtures/bundles/dab/output-k8s.json +++ b/script/test/fixtures/bundles/dab/output-k8s.json @@ -60,7 +60,10 @@ "apiVersion": "extensions/v1beta1", "metadata": { "name": "redis", - "creationTimestamp": null + "creationTimestamp": null, + "labels": { + "io.kompose.service": "redis" + } }, "spec": { "replicas": 1, @@ -96,7 +99,10 @@ "apiVersion": "extensions/v1beta1", "metadata": { "name": "web", - "creationTimestamp": null + "creationTimestamp": null, + "labels": { + "io.kompose.service": "web" + } }, "spec": { "replicas": 1, diff --git a/script/test/fixtures/bundles/dsb/output-k8s.json b/script/test/fixtures/bundles/dsb/output-k8s.json index 32a20ce8..499b1659 100644 --- a/script/test/fixtures/bundles/dsb/output-k8s.json +++ b/script/test/fixtures/bundles/dsb/output-k8s.json @@ -146,6 +146,9 @@ "metadata": { "name": "db", "creationTimestamp": null, + "labels": { + "io.kompose.service": "db" + }, "annotations": { "com.example.description": "Postgres Database" } @@ -184,7 +187,10 @@ "apiVersion": "extensions/v1beta1", "metadata": { "name": "redis", - "creationTimestamp": null + "creationTimestamp": null, + "labels": { + "io.kompose.service": "redis" + } }, "spec": { "replicas": 1, @@ -220,7 +226,10 @@ "apiVersion": "extensions/v1beta1", "metadata": { "name": "result", - "creationTimestamp": null + "creationTimestamp": null, + "labels": { + "io.kompose.service": "result" + } }, "spec": { "replicas": 1, @@ -257,6 +266,9 @@ "metadata": { "name": "vote", "creationTimestamp": null, + "labels": { + "io.kompose.service": "vote" + }, "annotations": { "com.example.description": "Vote" } @@ -295,7 +307,10 @@ "apiVersion": "extensions/v1beta1", "metadata": { "name": "worker", - "creationTimestamp": null + "creationTimestamp": null, + "labels": { + "io.kompose.service": "worker" + } }, "spec": { "replicas": 1, diff --git a/script/test/fixtures/entrypoint-command/output-k8s.json b/script/test/fixtures/entrypoint-command/output-k8s.json index 0faa005d..d26d5707 100644 --- a/script/test/fixtures/entrypoint-command/output-k8s.json +++ b/script/test/fixtures/entrypoint-command/output-k8s.json @@ -35,7 +35,10 @@ "apiVersion": "extensions/v1beta1", "metadata": { "name": "base", - "creationTimestamp": null + "creationTimestamp": null, + "labels": { + "io.kompose.service": "base" + } }, "spec": { "replicas": 1, diff --git a/script/test/fixtures/envvars-separators/output-k8s.json b/script/test/fixtures/envvars-separators/output-k8s.json index 1b02cbaa..727b6dd8 100644 --- a/script/test/fixtures/envvars-separators/output-k8s.json +++ b/script/test/fixtures/envvars-separators/output-k8s.json @@ -356,7 +356,10 @@ "apiVersion": "extensions/v1beta1", "metadata": { "name": "hygieia-api", - "creationTimestamp": null + "creationTimestamp": null, + "labels": { + "io.kompose.service": "hygieia-api" + } }, "spec": { "replicas": 1, @@ -430,7 +433,10 @@ "apiVersion": "extensions/v1beta1", "metadata": { "name": "hygieia-bitbucket-scm-collector", - "creationTimestamp": null + "creationTimestamp": null, + "labels": { + "io.kompose.service": "hygieia-bitbucket-scm-collector" + } }, "spec": { "replicas": 1, @@ -499,7 +505,10 @@ "apiVersion": "extensions/v1beta1", "metadata": { "name": "hygieia-chat-ops-collector", - "creationTimestamp": null + "creationTimestamp": null, + "labels": { + "io.kompose.service": "hygieia-chat-ops-collector" + } }, "spec": { "replicas": 1, @@ -568,7 +577,10 @@ "apiVersion": "extensions/v1beta1", "metadata": { "name": "hygieia-github-scm-collector", - "creationTimestamp": null + "creationTimestamp": null, + "labels": { + "io.kompose.service": "hygieia-github-scm-collector" + } }, "spec": { "replicas": 1, @@ -637,7 +649,10 @@ "apiVersion": "extensions/v1beta1", "metadata": { "name": "hygieia-jenkins-build-collector", - "creationTimestamp": null + "creationTimestamp": null, + "labels": { + "io.kompose.service": "hygieia-jenkins-build-collector" + } }, "spec": { "replicas": 1, @@ -706,7 +721,10 @@ "apiVersion": "extensions/v1beta1", "metadata": { "name": "hygieia-jenkins-cucumber-test-collector", - "creationTimestamp": null + "creationTimestamp": null, + "labels": { + "io.kompose.service": "hygieia-jenkins-cucumber-test-collector" + } }, "spec": { "replicas": 1, @@ -775,7 +793,10 @@ "apiVersion": "extensions/v1beta1", "metadata": { "name": "hygieia-jira-feature-collector", - "creationTimestamp": null + "creationTimestamp": null, + "labels": { + "io.kompose.service": "hygieia-jira-feature-collector" + } }, "spec": { "replicas": 1, @@ -854,7 +875,10 @@ "apiVersion": "extensions/v1beta1", "metadata": { "name": "hygieia-sonar-codequality-collector", - "creationTimestamp": null + "creationTimestamp": null, + "labels": { + "io.kompose.service": "hygieia-sonar-codequality-collector" + } }, "spec": { "replicas": 1, @@ -923,7 +947,10 @@ "apiVersion": "extensions/v1beta1", "metadata": { "name": "hygieia-subversion-scm-collector", - "creationTimestamp": null + "creationTimestamp": null, + "labels": { + "io.kompose.service": "hygieia-subversion-scm-collector" + } }, "spec": { "replicas": 1, @@ -992,7 +1019,10 @@ "apiVersion": "extensions/v1beta1", "metadata": { "name": "hygieia-udeploy-collector", - "creationTimestamp": null + "creationTimestamp": null, + "labels": { + "io.kompose.service": "hygieia-udeploy-collector" + } }, "spec": { "replicas": 1, @@ -1075,7 +1105,10 @@ "apiVersion": "extensions/v1beta1", "metadata": { "name": "hygieia-ui", - "creationTimestamp": null + "creationTimestamp": null, + "labels": { + "io.kompose.service": "hygieia-ui" + } }, "spec": { "replicas": 1, @@ -1111,7 +1144,10 @@ "apiVersion": "extensions/v1beta1", "metadata": { "name": "hygieia-versionone-collector", - "creationTimestamp": null + "creationTimestamp": null, + "labels": { + "io.kompose.service": "hygieia-versionone-collector" + } }, "spec": { "replicas": 1, @@ -1180,7 +1216,10 @@ "apiVersion": "extensions/v1beta1", "metadata": { "name": "mongodb", - "creationTimestamp": null + "creationTimestamp": null, + "labels": { + "io.kompose.service": "mongodb" + } }, "spec": { "replicas": 1, diff --git a/script/test/fixtures/etherpad/output-k8s.json b/script/test/fixtures/etherpad/output-k8s.json index 20fdd6e7..8af68c9a 100644 --- a/script/test/fixtures/etherpad/output-k8s.json +++ b/script/test/fixtures/etherpad/output-k8s.json @@ -60,7 +60,10 @@ "apiVersion": "extensions/v1beta1", "metadata": { "name": "etherpad", - "creationTimestamp": null + "creationTimestamp": null, + "labels": { + "io.kompose.service": "etherpad" + } }, "spec": { "replicas": 1, @@ -118,7 +121,10 @@ "apiVersion": "extensions/v1beta1", "metadata": { "name": "mariadb", - "creationTimestamp": null + "creationTimestamp": null, + "labels": { + "io.kompose.service": "mariadb" + } }, "spec": { "replicas": 1, diff --git a/script/test/fixtures/expose-service/provider-files/kubernetes-expose-hostname-multiple-ports.json b/script/test/fixtures/expose-service/provider-files/kubernetes-expose-hostname-multiple-ports.json index d2dc9ce4..9e0bbc0e 100644 --- a/script/test/fixtures/expose-service/provider-files/kubernetes-expose-hostname-multiple-ports.json +++ b/script/test/fixtures/expose-service/provider-files/kubernetes-expose-hostname-multiple-ports.json @@ -68,7 +68,10 @@ "apiVersion": "extensions/v1beta1", "metadata": { "name": "redis", - "creationTimestamp": null + "creationTimestamp": null, + "labels": { + "io.kompose.service": "redis" + } }, "spec": { "replicas": 1, @@ -105,6 +108,9 @@ "metadata": { "name": "web", "creationTimestamp": null, + "labels": { + "io.kompose.service": "web" + }, "annotations": { "kompose.service.expose": "batman.example.com" } diff --git a/script/test/fixtures/expose-service/provider-files/kubernetes-expose-hostname.json b/script/test/fixtures/expose-service/provider-files/kubernetes-expose-hostname.json index 902be11a..98d604e3 100644 --- a/script/test/fixtures/expose-service/provider-files/kubernetes-expose-hostname.json +++ b/script/test/fixtures/expose-service/provider-files/kubernetes-expose-hostname.json @@ -63,7 +63,10 @@ "apiVersion": "extensions/v1beta1", "metadata": { "name": "redis", - "creationTimestamp": null + "creationTimestamp": null, + "labels": { + "io.kompose.service": "redis" + } }, "spec": { "replicas": 1, @@ -100,6 +103,9 @@ "metadata": { "name": "web", "creationTimestamp": null, + "labels": { + "io.kompose.service": "web" + }, "annotations": { "kompose.service.expose": "batman.example.com" } diff --git a/script/test/fixtures/expose-service/provider-files/kubernetes-expose-true-multiple-ports.json b/script/test/fixtures/expose-service/provider-files/kubernetes-expose-true-multiple-ports.json index b6842d7b..e378ef9c 100644 --- a/script/test/fixtures/expose-service/provider-files/kubernetes-expose-true-multiple-ports.json +++ b/script/test/fixtures/expose-service/provider-files/kubernetes-expose-true-multiple-ports.json @@ -68,7 +68,10 @@ "apiVersion": "extensions/v1beta1", "metadata": { "name": "redis", - "creationTimestamp": null + "creationTimestamp": null, + "labels": { + "io.kompose.service": "redis" + } }, "spec": { "replicas": 1, @@ -105,6 +108,9 @@ "metadata": { "name": "web", "creationTimestamp": null, + "labels": { + "io.kompose.service": "web" + }, "annotations": { "kompose.service.expose": "True" } diff --git a/script/test/fixtures/expose-service/provider-files/kubernetes-expose-true.json b/script/test/fixtures/expose-service/provider-files/kubernetes-expose-true.json index ab77b2a4..4a96c0bd 100644 --- a/script/test/fixtures/expose-service/provider-files/kubernetes-expose-true.json +++ b/script/test/fixtures/expose-service/provider-files/kubernetes-expose-true.json @@ -63,7 +63,10 @@ "apiVersion": "extensions/v1beta1", "metadata": { "name": "redis", - "creationTimestamp": null + "creationTimestamp": null, + "labels": { + "io.kompose.service": "redis" + } }, "spec": { "replicas": 1, @@ -100,6 +103,9 @@ "metadata": { "name": "web", "creationTimestamp": null, + "labels": { + "io.kompose.service": "web" + }, "annotations": { "kompose.service.expose": "True" } diff --git a/script/test/fixtures/gitlab/output-k8s.json b/script/test/fixtures/gitlab/output-k8s.json index d09e8015..386875c0 100644 --- a/script/test/fixtures/gitlab/output-k8s.json +++ b/script/test/fixtures/gitlab/output-k8s.json @@ -96,7 +96,10 @@ "apiVersion": "extensions/v1beta1", "metadata": { "name": "gitlab", - "creationTimestamp": null + "creationTimestamp": null, + "labels": { + "io.kompose.service": "gitlab" + } }, "spec": { "replicas": 1, @@ -172,7 +175,10 @@ "apiVersion": "extensions/v1beta1", "metadata": { "name": "postgresql", - "creationTimestamp": null + "creationTimestamp": null, + "labels": { + "io.kompose.service": "postgresql" + } }, "spec": { "replicas": 1, @@ -222,7 +228,10 @@ "apiVersion": "extensions/v1beta1", "metadata": { "name": "redis", - "creationTimestamp": null + "creationTimestamp": null, + "labels": { + "io.kompose.service": "redis" + } }, "spec": { "replicas": 1, diff --git a/script/test/fixtures/keyonly-envs/output-k8s.json b/script/test/fixtures/keyonly-envs/output-k8s.json index 5605984a..9b60c84e 100644 --- a/script/test/fixtures/keyonly-envs/output-k8s.json +++ b/script/test/fixtures/keyonly-envs/output-k8s.json @@ -86,7 +86,10 @@ "apiVersion": "extensions/v1beta1", "metadata": { "name": "frontend", - "creationTimestamp": null + "creationTimestamp": null, + "labels": { + "io.kompose.service": "frontend" + } }, "spec": { "replicas": 1, @@ -140,7 +143,10 @@ "apiVersion": "extensions/v1beta1", "metadata": { "name": "redis-master", - "creationTimestamp": null + "creationTimestamp": null, + "labels": { + "io.kompose.service": "redis-master" + } }, "spec": { "replicas": 1, @@ -176,7 +182,10 @@ "apiVersion": "extensions/v1beta1", "metadata": { "name": "redis-slave", - "creationTimestamp": null + "creationTimestamp": null, + "labels": { + "io.kompose.service": "redis-slave" + } }, "spec": { "replicas": 1, diff --git a/script/test/fixtures/mem-limit/output-k8s.json b/script/test/fixtures/mem-limit/output-k8s.json index dd7828d3..02ba1b5b 100644 --- a/script/test/fixtures/mem-limit/output-k8s.json +++ b/script/test/fixtures/mem-limit/output-k8s.json @@ -40,7 +40,10 @@ "apiVersion": "extensions/v1beta1", "metadata": { "name": "redis", - "creationTimestamp": null + "creationTimestamp": null, + "labels": { + "io.kompose.service": "redis" + } }, "spec": { "replicas": 1, diff --git a/script/test/fixtures/mem-limit/output-mb-k8s.json b/script/test/fixtures/mem-limit/output-mb-k8s.json index 868a3681..466de9c5 100644 --- a/script/test/fixtures/mem-limit/output-mb-k8s.json +++ b/script/test/fixtures/mem-limit/output-mb-k8s.json @@ -40,7 +40,10 @@ "apiVersion": "extensions/v1beta1", "metadata": { "name": "redis", - "creationTimestamp": null + "creationTimestamp": null, + "labels": { + "io.kompose.service": "redis" + } }, "spec": { "replicas": 1, diff --git a/script/test/fixtures/multiple-compose-files/output-k8s.json b/script/test/fixtures/multiple-compose-files/output-k8s.json index 18c834d3..af03e694 100644 --- a/script/test/fixtures/multiple-compose-files/output-k8s.json +++ b/script/test/fixtures/multiple-compose-files/output-k8s.json @@ -70,7 +70,10 @@ "apiVersion": "extensions/v1beta1", "metadata": { "name": "etherpad", - "creationTimestamp": null + "creationTimestamp": null, + "labels": { + "io.kompose.service": "etherpad" + } }, "spec": { "replicas": 1, @@ -131,7 +134,10 @@ "apiVersion": "extensions/v1beta1", "metadata": { "name": "mariadb", - "creationTimestamp": null + "creationTimestamp": null, + "labels": { + "io.kompose.service": "mariadb" + } }, "spec": { "replicas": 1, diff --git a/script/test/fixtures/nginx-node-redis/output-k8s.json b/script/test/fixtures/nginx-node-redis/output-k8s.json index 707ab180..2e7fb750 100644 --- a/script/test/fixtures/nginx-node-redis/output-k8s.json +++ b/script/test/fixtures/nginx-node-redis/output-k8s.json @@ -138,7 +138,10 @@ "apiVersion": "extensions/v1beta1", "metadata": { "name": "nginx", - "creationTimestamp": null + "creationTimestamp": null, + "labels": { + "io.kompose.service": "nginx" + } }, "spec": { "replicas": 1, @@ -173,7 +176,10 @@ "apiVersion": "extensions/v1beta1", "metadata": { "name": "node1", - "creationTimestamp": null + "creationTimestamp": null, + "labels": { + "io.kompose.service": "node1" + } }, "spec": { "replicas": 1, @@ -208,7 +214,10 @@ "apiVersion": "extensions/v1beta1", "metadata": { "name": "node2", - "creationTimestamp": null + "creationTimestamp": null, + "labels": { + "io.kompose.service": "node2" + } }, "spec": { "replicas": 1, @@ -243,7 +252,10 @@ "apiVersion": "extensions/v1beta1", "metadata": { "name": "node3", - "creationTimestamp": null + "creationTimestamp": null, + "labels": { + "io.kompose.service": "node3" + } }, "spec": { "replicas": 1, @@ -278,7 +290,10 @@ "apiVersion": "extensions/v1beta1", "metadata": { "name": "redis", - "creationTimestamp": null + "creationTimestamp": null, + "labels": { + "io.kompose.service": "redis" + } }, "spec": { "replicas": 1, diff --git a/script/test/fixtures/nginx-node-redis/output-os-template.json b/script/test/fixtures/nginx-node-redis/output-os-template.json index 202cbb81..384e0a0a 100644 --- a/script/test/fixtures/nginx-node-redis/output-os-template.json +++ b/script/test/fixtures/nginx-node-redis/output-os-template.json @@ -216,7 +216,10 @@ "apiVersion": "v1", "metadata": { "name": "nginx", - "creationTimestamp": null + "creationTimestamp": null, + "labels": { + "io.kompose.service": "nginx" + } }, "spec": { "triggers": [ @@ -337,7 +340,10 @@ "apiVersion": "v1", "metadata": { "name": "node1", - "creationTimestamp": null + "creationTimestamp": null, + "labels": { + "io.kompose.service": "node1" + } }, "spec": { "triggers": [ @@ -458,7 +464,10 @@ "apiVersion": "v1", "metadata": { "name": "node2", - "creationTimestamp": null + "creationTimestamp": null, + "labels": { + "io.kompose.service": "node2" + } }, "spec": { "triggers": [ @@ -579,7 +588,10 @@ "apiVersion": "v1", "metadata": { "name": "node3", - "creationTimestamp": null + "creationTimestamp": null, + "labels": { + "io.kompose.service": "node3" + } }, "spec": { "triggers": [ @@ -709,4 +721,4 @@ } } ] -} +} \ No newline at end of file diff --git a/script/test/fixtures/ports-with-ip/output-k8s.json b/script/test/fixtures/ports-with-ip/output-k8s.json index 07de3f8b..0a24eef9 100644 --- a/script/test/fixtures/ports-with-ip/output-k8s.json +++ b/script/test/fixtures/ports-with-ip/output-k8s.json @@ -66,7 +66,10 @@ "apiVersion": "extensions/v1beta1", "metadata": { "name": "redis", - "creationTimestamp": null + "creationTimestamp": null, + "labels": { + "io.kompose.service": "redis" + } }, "spec": { "replicas": 1, @@ -106,7 +109,10 @@ "apiVersion": "extensions/v1beta1", "metadata": { "name": "web", - "creationTimestamp": null + "creationTimestamp": null, + "labels": { + "io.kompose.service": "web" + } }, "spec": { "replicas": 1, diff --git a/script/test/fixtures/ports-with-proto/output-k8s.json b/script/test/fixtures/ports-with-proto/output-k8s.json index c62891b8..41aeb491 100644 --- a/script/test/fixtures/ports-with-proto/output-k8s.json +++ b/script/test/fixtures/ports-with-proto/output-k8s.json @@ -66,7 +66,10 @@ "apiVersion": "extensions/v1beta1", "metadata": { "name": "redis", - "creationTimestamp": null + "creationTimestamp": null, + "labels": { + "io.kompose.service": "redis" + } }, "spec": { "replicas": 1, @@ -106,7 +109,10 @@ "apiVersion": "extensions/v1beta1", "metadata": { "name": "web", - "creationTimestamp": null + "creationTimestamp": null, + "labels": { + "io.kompose.service": "web" + } }, "spec": { "replicas": 1, diff --git a/script/test/fixtures/service-name-change/output-k8s.json b/script/test/fixtures/service-name-change/output-k8s.json index 04443310..bd4699b1 100644 --- a/script/test/fixtures/service-name-change/output-k8s.json +++ b/script/test/fixtures/service-name-change/output-k8s.json @@ -66,7 +66,10 @@ "apiVersion": "extensions/v1beta1", "metadata": { "name": "mariadb", - "creationTimestamp": null + "creationTimestamp": null, + "labels": { + "io.kompose.service": "mariadb" + } }, "spec": { "replicas": 1, @@ -149,7 +152,10 @@ "apiVersion": "extensions/v1beta1", "metadata": { "name": "wordpress", - "creationTimestamp": null + "creationTimestamp": null, + "labels": { + "io.kompose.service": "wordpress" + } }, "spec": { "replicas": 1, diff --git a/script/test/fixtures/stdin-true/output-k8s.json b/script/test/fixtures/stdin-true/output-k8s.json index d200cdcf..9173c74b 100644 --- a/script/test/fixtures/stdin-true/output-k8s.json +++ b/script/test/fixtures/stdin-true/output-k8s.json @@ -34,7 +34,10 @@ "apiVersion": "extensions/v1beta1", "metadata": { "name": "client", - "creationTimestamp": null + "creationTimestamp": null, + "labels": { + "io.kompose.service": "client" + } }, "spec": { "replicas": 1, diff --git a/script/test/fixtures/tty-true/output-k8s.json b/script/test/fixtures/tty-true/output-k8s.json index 07bef7f2..7d363af8 100644 --- a/script/test/fixtures/tty-true/output-k8s.json +++ b/script/test/fixtures/tty-true/output-k8s.json @@ -34,7 +34,10 @@ "apiVersion": "extensions/v1beta1", "metadata": { "name": "client", - "creationTimestamp": null + "creationTimestamp": null, + "labels": { + "io.kompose.service": "client" + } }, "spec": { "replicas": 1, diff --git a/script/test/fixtures/volume-mounts/simple-vol-mounts/output-k8s.json b/script/test/fixtures/volume-mounts/simple-vol-mounts/output-k8s.json index 9d4bd7cc..4968cf09 100644 --- a/script/test/fixtures/volume-mounts/simple-vol-mounts/output-k8s.json +++ b/script/test/fixtures/volume-mounts/simple-vol-mounts/output-k8s.json @@ -34,7 +34,10 @@ "apiVersion": "extensions/v1beta1", "metadata": { "name": "httpd", - "creationTimestamp": null + "creationTimestamp": null, + "labels": { + "io.kompose.service": "httpd" + } }, "spec": { "replicas": 1, diff --git a/script/test/fixtures/volume-mounts/volumes-from/output-k8s.json b/script/test/fixtures/volume-mounts/volumes-from/output-k8s.json index cd1fd90c..3fa7a774 100644 --- a/script/test/fixtures/volume-mounts/volumes-from/output-k8s.json +++ b/script/test/fixtures/volume-mounts/volumes-from/output-k8s.json @@ -60,7 +60,10 @@ "apiVersion": "extensions/v1beta1", "metadata": { "name": "nginx", - "creationTimestamp": null + "creationTimestamp": null, + "labels": { + "io.kompose.service": "nginx" + } }, "spec": { "replicas": 1, @@ -144,7 +147,10 @@ "apiVersion": "extensions/v1beta1", "metadata": { "name": "web", - "creationTimestamp": null + "creationTimestamp": null, + "labels": { + "io.kompose.service": "web" + } }, "spec": { "replicas": 1, diff --git a/script/test/fixtures/yaml-and-yml/output-k8s.json b/script/test/fixtures/yaml-and-yml/output-k8s.json index 167b0c19..fce4a9f3 100644 --- a/script/test/fixtures/yaml-and-yml/output-k8s.json +++ b/script/test/fixtures/yaml-and-yml/output-k8s.json @@ -60,7 +60,10 @@ "apiVersion": "extensions/v1beta1", "metadata": { "name": "redis", - "creationTimestamp": null + "creationTimestamp": null, + "labels": { + "io.kompose.service": "redis" + } }, "spec": { "replicas": 1, @@ -96,7 +99,10 @@ "apiVersion": "extensions/v1beta1", "metadata": { "name": "web", - "creationTimestamp": null + "creationTimestamp": null, + "labels": { + "io.kompose.service": "web" + } }, "spec": { "replicas": 1, diff --git a/script/test/fixtures/yaml-and-yml/yml/output-k8s.json b/script/test/fixtures/yaml-and-yml/yml/output-k8s.json index 167b0c19..fce4a9f3 100644 --- a/script/test/fixtures/yaml-and-yml/yml/output-k8s.json +++ b/script/test/fixtures/yaml-and-yml/yml/output-k8s.json @@ -60,7 +60,10 @@ "apiVersion": "extensions/v1beta1", "metadata": { "name": "redis", - "creationTimestamp": null + "creationTimestamp": null, + "labels": { + "io.kompose.service": "redis" + } }, "spec": { "replicas": 1, @@ -96,7 +99,10 @@ "apiVersion": "extensions/v1beta1", "metadata": { "name": "web", - "creationTimestamp": null + "creationTimestamp": null, + "labels": { + "io.kompose.service": "web" + } }, "spec": { "replicas": 1, From bee784faf6052f753ad078be7392798475ca51f9 Mon Sep 17 00:00:00 2001 From: Tomas Kral Date: Thu, 27 Apr 2017 15:36:20 +0200 Subject: [PATCH 07/12] Use BuildConfig reaper to delete BuildConfig with all related pods --- pkg/transformer/openshift/openshift.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pkg/transformer/openshift/openshift.go b/pkg/transformer/openshift/openshift.go index 93709bc7..d5a2326c 100644 --- a/pkg/transformer/openshift/openshift.go +++ b/pkg/transformer/openshift/openshift.go @@ -42,6 +42,7 @@ import ( "github.com/kubernetes-incubator/kompose/pkg/transformer" buildapi "github.com/openshift/origin/pkg/build/api" + buildconfigreaper "github.com/openshift/origin/pkg/build/cmd" deployapi "github.com/openshift/origin/pkg/deploy/api" deploymentconfigreaper "github.com/openshift/origin/pkg/deploy/cmd" imageapi "github.com/openshift/origin/pkg/image/api" @@ -593,7 +594,8 @@ func (o *OpenShift) Undeploy(komposeObject kobject.KomposeObject, opt kobject.Co } for _, l := range buildConfig.Items { if reflect.DeepEqual(l.Labels, komposeLabel) { - err := oclient.BuildConfigs(namespace).Delete(t.Name) + bcreaper := buildconfigreaper.NewBuildConfigReaper(oclient) + err := bcreaper.Stop(namespace, t.Name, TIMEOUT*time.Second, nil) if err != nil { errorList = append(errorList, err) break From 166eedfc1c309e663d4e2d98e4da8e07d56a3bd8 Mon Sep 17 00:00:00 2001 From: Tomas Kral Date: Thu, 27 Apr 2017 15:40:39 +0200 Subject: [PATCH 08/12] update vendor added files required by BuildConfig reaper --- .../openshift/origin/pkg/build/cmd/doc.go | 2 + .../openshift/origin/pkg/build/cmd/reaper.go | 150 +++++++++ .../openshift/origin/pkg/util/doc.go | 4 + .../openshift/origin/pkg/util/etcd.go | 21 ++ .../openshift/origin/pkg/util/labels.go | 286 ++++++++++++++++++ .../openshift/origin/pkg/util/strings.go | 21 ++ 6 files changed, 484 insertions(+) create mode 100644 vendor/github.com/openshift/origin/pkg/build/cmd/doc.go create mode 100644 vendor/github.com/openshift/origin/pkg/build/cmd/reaper.go create mode 100644 vendor/github.com/openshift/origin/pkg/util/doc.go create mode 100644 vendor/github.com/openshift/origin/pkg/util/etcd.go create mode 100644 vendor/github.com/openshift/origin/pkg/util/labels.go create mode 100644 vendor/github.com/openshift/origin/pkg/util/strings.go diff --git a/vendor/github.com/openshift/origin/pkg/build/cmd/doc.go b/vendor/github.com/openshift/origin/pkg/build/cmd/doc.go new file mode 100644 index 00000000..e9cc603a --- /dev/null +++ b/vendor/github.com/openshift/origin/pkg/build/cmd/doc.go @@ -0,0 +1,2 @@ +// Package cmd provides command helpers for builds +package cmd diff --git a/vendor/github.com/openshift/origin/pkg/build/cmd/reaper.go b/vendor/github.com/openshift/origin/pkg/build/cmd/reaper.go new file mode 100644 index 00000000..11fb11a5 --- /dev/null +++ b/vendor/github.com/openshift/origin/pkg/build/cmd/reaper.go @@ -0,0 +1,150 @@ +package cmd + +import ( + "sort" + "strings" + "time" + + "github.com/golang/glog" + kapi "k8s.io/kubernetes/pkg/api" + kerrors "k8s.io/kubernetes/pkg/api/errors" + "k8s.io/kubernetes/pkg/client/unversioned" + "k8s.io/kubernetes/pkg/kubectl" + ktypes "k8s.io/kubernetes/pkg/types" + kutilerrors "k8s.io/kubernetes/pkg/util/errors" + + buildapi "github.com/openshift/origin/pkg/build/api" + buildutil "github.com/openshift/origin/pkg/build/util" + "github.com/openshift/origin/pkg/client" + "github.com/openshift/origin/pkg/util" +) + +// NewBuildConfigReaper returns a new reaper for buildConfigs +func NewBuildConfigReaper(oc *client.Client) kubectl.Reaper { + return &BuildConfigReaper{oc: oc, pollInterval: kubectl.Interval, timeout: kubectl.Timeout} +} + +// BuildConfigReaper implements the Reaper interface for buildConfigs +type BuildConfigReaper struct { + oc client.Interface + pollInterval, timeout time.Duration +} + +// Stop deletes the build configuration and all of the associated builds. +func (reaper *BuildConfigReaper) Stop(namespace, name string, timeout time.Duration, gracePeriod *kapi.DeleteOptions) error { + _, err := reaper.oc.BuildConfigs(namespace).Get(name) + + if err != nil { + return err + } + + var bcPotentialBuilds []buildapi.Build + + // Collect builds related to the config. + builds, err := reaper.oc.Builds(namespace).List(kapi.ListOptions{LabelSelector: buildutil.BuildConfigSelector(name)}) + if err != nil { + return err + } + + bcPotentialBuilds = append(bcPotentialBuilds, builds.Items...) + + // Collect deprecated builds related to the config. + // TODO: Delete this block after BuildConfigLabelDeprecated is removed. + builds, err = reaper.oc.Builds(namespace).List(kapi.ListOptions{LabelSelector: buildutil.BuildConfigSelectorDeprecated(name)}) + if err != nil { + return err + } + + bcPotentialBuilds = append(bcPotentialBuilds, builds.Items...) + + // A map of builds associated with this build configuration + bcBuilds := make(map[ktypes.UID]buildapi.Build) + + // Because of name length limits in the BuildConfigSelector, annotations are used to ensure + // reliable selection of associated builds. + for _, build := range bcPotentialBuilds { + if build.Annotations != nil { + if bcName, ok := build.Annotations[buildapi.BuildConfigAnnotation]; ok { + // The annotation, if present, has the full build config name. + if bcName != name { + // If the name does not match exactly, the build is not truly associated with the build configuration + continue + } + } + } + // Note that if there is no annotation, this is a deprecated build spec + // and we choose to include it in the deletion having matched only the BuildConfigSelectorDeprecated + + // Use a map to union the lists returned by the contemporary & deprecated build queries + // (there will be overlap between the lists, and we only want to try to delete each build once) + bcBuilds[build.UID] = build + } + + // If there are builds associated with this build configuration, pause it before attempting the deletion + if len(bcBuilds) > 0 { + + // Add paused annotation to the build config pending the deletion + err = unversioned.RetryOnConflict(unversioned.DefaultRetry, func() error { + + bc, err := reaper.oc.BuildConfigs(namespace).Get(name) + if err != nil { + return err + } + + // Ignore if the annotation already exists + if strings.ToLower(bc.Annotations[buildapi.BuildConfigPausedAnnotation]) == "true" { + return nil + } + + // Set the annotation and update + if err := util.AddObjectAnnotations(bc, map[string]string{buildapi.BuildConfigPausedAnnotation: "true"}); err != nil { + return err + } + _, err = reaper.oc.BuildConfigs(namespace).Update(bc) + return err + }) + + if err != nil { + return err + } + + } + + // Warn the user if the BuildConfig won't get deleted after this point. + bcDeleted := false + defer func() { + if !bcDeleted { + glog.Warningf("BuildConfig %s/%s will not be deleted because not all associated builds could be deleted. You can try re-running the command or removing them manually", namespace, name) + } + }() + + // For the benefit of test cases, sort the UIDs so that the deletion order is deterministic + buildUIDs := make([]string, 0, len(bcBuilds)) + for buildUID := range bcBuilds { + buildUIDs = append(buildUIDs, string(buildUID)) + } + sort.Strings(buildUIDs) + + errList := []error{} + for _, buildUID := range buildUIDs { + build := bcBuilds[ktypes.UID(buildUID)] + if err := reaper.oc.Builds(namespace).Delete(build.Name); err != nil { + glog.Warningf("Cannot delete Build %s/%s: %v", build.Namespace, build.Name, err) + if !kerrors.IsNotFound(err) { + errList = append(errList, err) + } + } + } + + // Aggregate all errors + if len(errList) > 0 { + return kutilerrors.NewAggregate(errList) + } + + if err := reaper.oc.BuildConfigs(namespace).Delete(name); err != nil { + return err + } + + bcDeleted = true + return nil +} diff --git a/vendor/github.com/openshift/origin/pkg/util/doc.go b/vendor/github.com/openshift/origin/pkg/util/doc.go new file mode 100644 index 00000000..3ce2be72 --- /dev/null +++ b/vendor/github.com/openshift/origin/pkg/util/doc.go @@ -0,0 +1,4 @@ +// Package util implements various utility functions used in both testing and +// implementation of OpenShift. Package util may not depend on any other +// package in the OpenShift package tree. +package util diff --git a/vendor/github.com/openshift/origin/pkg/util/etcd.go b/vendor/github.com/openshift/origin/pkg/util/etcd.go new file mode 100644 index 00000000..754f49d9 --- /dev/null +++ b/vendor/github.com/openshift/origin/pkg/util/etcd.go @@ -0,0 +1,21 @@ +package util + +import ( + "path" + + kapi "k8s.io/kubernetes/pkg/api" + kerrors "k8s.io/kubernetes/pkg/api/errors" +) + +// NoNamespaceKeyFunc is the default function for constructing etcd paths to a resource relative to prefix enforcing +// If a namespace is on context, it errors. +func NoNamespaceKeyFunc(ctx kapi.Context, prefix string, name string) (string, error) { + ns, ok := kapi.NamespaceFrom(ctx) + if ok && len(ns) > 0 { + return "", kerrors.NewBadRequest("Namespace parameter is not allowed.") + } + if len(name) == 0 { + return "", kerrors.NewBadRequest("Name parameter required.") + } + return path.Join(prefix, name), nil +} diff --git a/vendor/github.com/openshift/origin/pkg/util/labels.go b/vendor/github.com/openshift/origin/pkg/util/labels.go new file mode 100644 index 00000000..eba90666 --- /dev/null +++ b/vendor/github.com/openshift/origin/pkg/util/labels.go @@ -0,0 +1,286 @@ +package util + +import ( + "fmt" + "reflect" + + kmeta "k8s.io/kubernetes/pkg/api/meta" + "k8s.io/kubernetes/pkg/labels" + "k8s.io/kubernetes/pkg/runtime" + + deployapi "github.com/openshift/origin/pkg/deploy/api" +) + +// MergeInto flags +const ( + OverwriteExistingDstKey = 1 << iota + ErrorOnExistingDstKey + ErrorOnDifferentDstKeyValue +) + +// AddObjectLabelsWithFlags will set labels on the target object. Label overwrite behavior +// is controlled by the flags argument. +func AddObjectLabelsWithFlags(obj runtime.Object, labels labels.Set, flags int) error { + if labels == nil { + return nil + } + + accessor, err := kmeta.Accessor(obj) + + if err != nil { + if _, ok := obj.(*runtime.Unstructured); !ok { + // error out if it's not possible to get an accessor and it's also not an unstructured object + return err + } + } else { + metaLabels := accessor.GetLabels() + if metaLabels == nil { + metaLabels = make(map[string]string) + } + + switch objType := obj.(type) { + case *deployapi.DeploymentConfig: + if err := addDeploymentConfigNestedLabels(objType, labels, flags); err != nil { + return fmt.Errorf("unable to add nested labels to %s/%s: %v", obj.GetObjectKind().GroupVersionKind(), accessor.GetName(), err) + } + } + + if err := MergeInto(metaLabels, labels, flags); err != nil { + return fmt.Errorf("unable to add labels to %s/%s: %v", obj.GetObjectKind().GroupVersionKind(), accessor.GetName(), err) + } + + accessor.SetLabels(metaLabels) + + return nil + } + + // handle unstructured object + // TODO: allow meta.Accessor to handle runtime.Unstructured + if unstruct, ok := obj.(*runtime.Unstructured); ok && unstruct.Object != nil { + // the presence of "metadata" is sufficient for us to apply the rules for Kube-like + // objects. + // TODO: add swagger detection to allow this to happen more effectively + if obj, ok := unstruct.Object["metadata"]; ok { + if m, ok := obj.(map[string]interface{}); ok { + + existing := make(map[string]string) + if l, ok := m["labels"]; ok { + if found, ok := interfaceToStringMap(l); ok { + existing = found + } + } + if err := MergeInto(existing, labels, flags); err != nil { + return err + } + m["labels"] = mapToGeneric(existing) + } + return nil + } + + // only attempt to set root labels if a root object called labels exists + // TODO: add swagger detection to allow this to happen more effectively + if obj, ok := unstruct.Object["labels"]; ok { + existing := make(map[string]string) + if found, ok := interfaceToStringMap(obj); ok { + existing = found + } + if err := MergeInto(existing, labels, flags); err != nil { + return err + } + unstruct.Object["labels"] = mapToGeneric(existing) + return nil + } + } + + return nil + +} + +// AddObjectLabels adds new label(s) to a single runtime.Object, overwriting +// existing labels that have the same key. +func AddObjectLabels(obj runtime.Object, labels labels.Set) error { + return AddObjectLabelsWithFlags(obj, labels, OverwriteExistingDstKey) +} + +// AddObjectAnnotations adds new annotation(s) to a single runtime.Object +func AddObjectAnnotations(obj runtime.Object, annotations map[string]string) error { + if len(annotations) == 0 { + return nil + } + + accessor, err := kmeta.Accessor(obj) + + if err != nil { + if _, ok := obj.(*runtime.Unstructured); !ok { + // error out if it's not possible to get an accessor and it's also not an unstructured object + return err + } + } else { + metaAnnotations := accessor.GetAnnotations() + if metaAnnotations == nil { + metaAnnotations = make(map[string]string) + } + + switch objType := obj.(type) { + case *deployapi.DeploymentConfig: + if err := addDeploymentConfigNestedAnnotations(objType, annotations); err != nil { + return fmt.Errorf("unable to add nested annotations to %s/%s: %v", obj.GetObjectKind().GroupVersionKind(), accessor.GetName(), err) + } + } + + MergeInto(metaAnnotations, annotations, OverwriteExistingDstKey) + accessor.SetAnnotations(metaAnnotations) + + return nil + } + + // handle unstructured object + // TODO: allow meta.Accessor to handle runtime.Unstructured + if unstruct, ok := obj.(*runtime.Unstructured); ok && unstruct.Object != nil { + // the presence of "metadata" is sufficient for us to apply the rules for Kube-like + // objects. + // TODO: add swagger detection to allow this to happen more effectively + if obj, ok := unstruct.Object["metadata"]; ok { + if m, ok := obj.(map[string]interface{}); ok { + + existing := make(map[string]string) + if l, ok := m["annotations"]; ok { + if found, ok := interfaceToStringMap(l); ok { + existing = found + } + } + if err := MergeInto(existing, annotations, OverwriteExistingDstKey); err != nil { + return err + } + m["annotations"] = mapToGeneric(existing) + } + return nil + } + + // only attempt to set root annotations if a root object called annotations exists + // TODO: add swagger detection to allow this to happen more effectively + if obj, ok := unstruct.Object["annotations"]; ok { + existing := make(map[string]string) + if found, ok := interfaceToStringMap(obj); ok { + existing = found + } + if err := MergeInto(existing, annotations, OverwriteExistingDstKey); err != nil { + return err + } + unstruct.Object["annotations"] = mapToGeneric(existing) + return nil + } + } + + return nil +} + +// addDeploymentConfigNestedLabels adds new label(s) to a nested labels of a single DeploymentConfig object +func addDeploymentConfigNestedLabels(obj *deployapi.DeploymentConfig, labels labels.Set, flags int) error { + if obj.Spec.Template.Labels == nil { + obj.Spec.Template.Labels = make(map[string]string) + } + if err := MergeInto(obj.Spec.Template.Labels, labels, flags); err != nil { + return fmt.Errorf("unable to add labels to Template.DeploymentConfig.Template.ControllerTemplate.Template: %v", err) + } + return nil +} + +func addDeploymentConfigNestedAnnotations(obj *deployapi.DeploymentConfig, annotations map[string]string) error { + if obj.Spec.Template == nil { + return nil + } + + if obj.Spec.Template.Annotations == nil { + obj.Spec.Template.Annotations = make(map[string]string) + } + + if err := MergeInto(obj.Spec.Template.Annotations, annotations, OverwriteExistingDstKey); err != nil { + return fmt.Errorf("unable to add annotations to Template.DeploymentConfig.Template.ControllerTemplate.Template: %v", err) + } + return nil +} + +// interfaceToStringMap extracts a map[string]string from a map[string]interface{} +func interfaceToStringMap(obj interface{}) (map[string]string, bool) { + if obj == nil { + return nil, false + } + lm, ok := obj.(map[string]interface{}) + if !ok { + return nil, false + } + existing := make(map[string]string) + for k, v := range lm { + switch t := v.(type) { + case string: + existing[k] = t + } + } + return existing, true +} + +// mapToGeneric converts a map[string]string into a map[string]interface{} +func mapToGeneric(obj map[string]string) map[string]interface{} { + if obj == nil { + return nil + } + res := make(map[string]interface{}) + for k, v := range obj { + res[k] = v + } + return res +} + +// MergeInto merges items from a src map into a dst map. +// Returns an error when the maps are not of the same type. +// Flags: +// - ErrorOnExistingDstKey +// When set: Return an error if any of the dst keys is already set. +// - ErrorOnDifferentDstKeyValue +// When set: Return an error if any of the dst keys is already set +// to a different value than src key. +// - OverwriteDstKey +// When set: Overwrite existing dst key value with src key value. +func MergeInto(dst, src interface{}, flags int) error { + dstVal := reflect.ValueOf(dst) + srcVal := reflect.ValueOf(src) + + if dstVal.Kind() != reflect.Map { + return fmt.Errorf("dst is not a valid map: %v", dstVal.Kind()) + } + if srcVal.Kind() != reflect.Map { + return fmt.Errorf("src is not a valid map: %v", srcVal.Kind()) + } + if dstTyp, srcTyp := dstVal.Type(), srcVal.Type(); !dstTyp.AssignableTo(srcTyp) { + return fmt.Errorf("type mismatch, can't assign '%v' to '%v'", srcTyp, dstTyp) + } + + if dstVal.IsNil() { + return fmt.Errorf("dst value is nil") + } + if srcVal.IsNil() { + // Nothing to merge + return nil + } + + for _, k := range srcVal.MapKeys() { + if dstVal.MapIndex(k).IsValid() { + if flags&ErrorOnExistingDstKey != 0 { + return fmt.Errorf("dst key already set (ErrorOnExistingDstKey=1), '%v'='%v'", k, dstVal.MapIndex(k)) + } + if dstVal.MapIndex(k).String() != srcVal.MapIndex(k).String() { + if flags&ErrorOnDifferentDstKeyValue != 0 { + return fmt.Errorf("dst key already set to a different value (ErrorOnDifferentDstKeyValue=1), '%v'='%v'", k, dstVal.MapIndex(k)) + } + if flags&OverwriteExistingDstKey != 0 { + dstVal.SetMapIndex(k, srcVal.MapIndex(k)) + } + } + } else { + dstVal.SetMapIndex(k, srcVal.MapIndex(k)) + } + } + + return nil +} diff --git a/vendor/github.com/openshift/origin/pkg/util/strings.go b/vendor/github.com/openshift/origin/pkg/util/strings.go new file mode 100644 index 00000000..cf1b4804 --- /dev/null +++ b/vendor/github.com/openshift/origin/pkg/util/strings.go @@ -0,0 +1,21 @@ +package util + +import "sort" + +// UniqueStrings returns a sorted, uniquified slice of the specified strings +func UniqueStrings(strings []string) []string { + m := make(map[string]bool, len(strings)) + for _, s := range strings { + m[s] = true + } + + i := 0 + strings = make([]string, len(m), len(m)) + for s := range m { + strings[i] = s + i++ + } + + sort.Strings(strings) + return strings +} From 9ebfa9e2937bfdbb0d7597e7367b3eb0fa7d84df Mon Sep 17 00:00:00 2001 From: Abhishek Chanda Date: Tue, 16 May 2017 17:34:26 +0000 Subject: [PATCH 09/12] Replace underscores with dashes while rendering container names Kubernetes container names must match the regex [a-z0-9]([-a-z0-9]*[a-z0-9])? This excludes underscores, which is common in container names in compose. --- pkg/loader/compose/compose.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pkg/loader/compose/compose.go b/pkg/loader/compose/compose.go index e8c093c6..77ce6297 100644 --- a/pkg/loader/compose/compose.go +++ b/pkg/loader/compose/compose.go @@ -317,7 +317,11 @@ func (c *Compose) LoadFile(files []string) (kobject.KomposeObject, error) { serviceConfig := kobject.ServiceConfig{} serviceConfig.Image = composeServiceConfig.Image serviceConfig.Build = composeServiceConfig.Build.Context - serviceConfig.ContainerName = composeServiceConfig.ContainerName + newName := normalizeServiceNames(composeServiceConfig.ContainerName) + serviceConfig.ContainerName = newName + if newName != composeServiceConfig.ContainerName { + log.Infof("Container name in service %q has been changed from %q to %q", name, composeServiceConfig.ContainerName, newName) + } serviceConfig.Command = composeServiceConfig.Entrypoint serviceConfig.Args = composeServiceConfig.Command serviceConfig.Dockerfile = composeServiceConfig.Build.Dockerfile From 1cacfddf1a7174ad2ad8a57e32647b4db1a11940 Mon Sep 17 00:00:00 2001 From: Charlie Drage Date: Fri, 19 May 2017 10:27:11 -0400 Subject: [PATCH 10/12] Update `kompose completion` Updates Kompose completion with neutral language (using shell instead of bash). Fixes the indentation issues when outputting `kompose completion --help` --- cmd/completion.go | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/cmd/completion.go b/cmd/completion.go index 59d9613c..2a6565b2 100644 --- a/cmd/completion.go +++ b/cmd/completion.go @@ -12,18 +12,15 @@ import ( var completion = &cobra.Command{ Use: "completion SHELL", - Short: "Generate a bash auto completion file", - Long: `Generate a bash auto completion script. + Short: "Output shell completion code", + Long: `Generates shell completion code. - Auto completion supports both bash and zsh. +Auto completion supports both bash and zsh. Output is to STDOUT. - The output is to stdout. +source <(kompose completion bash) +source <(kompose completion zsh) - Examples: - $ source <(kompose completion bash) - $ source <(kompose completion zsh) - - Will load the bash completion code. +Will load the shell completion code. `, RunE: func(cmd *cobra.Command, args []string) error { From c01f6f1763c2d40aa049463741b04751c4495143 Mon Sep 17 00:00:00 2001 From: gitlawr Date: Thu, 18 May 2017 13:58:26 +0800 Subject: [PATCH 11/12] To solve #440 This commit Add support for stop_grace_period which maps to Pod.Spec.TerminationGracePeriodSeconds Updated conversion.md on support for the key --- docs/conversion.md | 2 +- pkg/kobject/kobject.go | 61 +++++++++++---------- pkg/loader/compose/compose.go | 1 + pkg/transformer/kubernetes/k8sutils.go | 24 +++++++- pkg/transformer/kubernetes/k8sutils_test.go | 30 +++++++++- 5 files changed, 85 insertions(+), 33 deletions(-) diff --git a/docs/conversion.md b/docs/conversion.md index e22a4cb6..c077a5df 100644 --- a/docs/conversion.md +++ b/docs/conversion.md @@ -35,7 +35,7 @@ This document outlines all the conversion details regarding `docker-compose.yaml | pid | | N | | | | ports | | Y | [Service.Spec.Ports](https://kubernetes.io/docs/api-reference/v1/definitions/#_v1_containerport) | | | security_opt | | N | | | -| stop_grace_period | | N | | | +| stop_grace_period | | Y | [Pod.Spec.TerminationGracePeriodSeconds](https://kubernetes.io/docs/resources-reference/v1.6/#podspec-v1-core) | | | stop_signal | | N | | | | sysctls | | N | | | | ulimits | | N | | See this [issue](https://github.com/kubernetes/kubernetes/issues/3595) on the k8s repo | diff --git a/pkg/kobject/kobject.go b/pkg/kobject/kobject.go index 594ee085..3572423d 100644 --- a/pkg/kobject/kobject.go +++ b/pkg/kobject/kobject.go @@ -59,36 +59,37 @@ type ConvertOptions struct { // ServiceConfig holds the basic struct of a container type ServiceConfig struct { // use tags to mark from what element this value comes - ContainerName string - Image string `compose:"image" bundle:"Image"` - Environment []EnvVar `compose:"environment" bundle:"Env"` - Port []Ports `compose:"ports" bundle:"Ports"` - Command []string `compose:"command" bundle:"Command"` - WorkingDir string `compose:"" bundle:"WorkingDir"` - Args []string `compose:"args" bundle:"Args"` - Volumes []string `compose:"volumes" bundle:"Volumes"` - Network []string `compose:"network" bundle:"Networks"` - Labels map[string]string `compose:"labels" bundle:"Labels"` - Annotations map[string]string `compose:"" bundle:""` - CPUSet string `compose:"cpuset" bundle:""` - CPUShares int64 `compose:"cpu_shares" bundle:""` - CPUQuota int64 `compose:"cpu_quota" bundle:""` - CapAdd []string `compose:"cap_add" bundle:""` - CapDrop []string `compose:"cap_drop" bundle:""` - Expose []string `compose:"expose" bundle:""` - Privileged bool `compose:"privileged" bundle:""` - Restart string `compose:"restart" bundle:""` - User string `compose:"user" bundle:"User"` - VolumesFrom []string `compose:"volumes_from" bundle:""` - ServiceType string `compose:"kompose.service.type" bundle:""` - Build string `compose:"build" bundle:""` - BuildArgs map[string]*string `compose:"build-args" bundle:""` - ExposeService string `compose:"kompose.service.expose" bundle:""` - Stdin bool `compose:"stdin_open" bundle:""` - Tty bool `compose:"tty" bundle:""` - MemLimit yaml.MemStringorInt `compose:"mem_limit" bundle:""` - TmpFs []string `compose:"tmpfs" bundle:""` - Dockerfile string `compose:"dockerfile" bundle:""` + ContainerName string + Image string `compose:"image" bundle:"Image"` + Environment []EnvVar `compose:"environment" bundle:"Env"` + Port []Ports `compose:"ports" bundle:"Ports"` + Command []string `compose:"command" bundle:"Command"` + WorkingDir string `compose:"" bundle:"WorkingDir"` + Args []string `compose:"args" bundle:"Args"` + Volumes []string `compose:"volumes" bundle:"Volumes"` + Network []string `compose:"network" bundle:"Networks"` + Labels map[string]string `compose:"labels" bundle:"Labels"` + Annotations map[string]string `compose:"" bundle:""` + CPUSet string `compose:"cpuset" bundle:""` + CPUShares int64 `compose:"cpu_shares" bundle:""` + CPUQuota int64 `compose:"cpu_quota" bundle:""` + CapAdd []string `compose:"cap_add" bundle:""` + CapDrop []string `compose:"cap_drop" bundle:""` + Expose []string `compose:"expose" bundle:""` + Privileged bool `compose:"privileged" bundle:""` + Restart string `compose:"restart" bundle:""` + User string `compose:"user" bundle:"User"` + VolumesFrom []string `compose:"volumes_from" bundle:""` + ServiceType string `compose:"kompose.service.type" bundle:""` + StopGracePeriod string `compose:"stop_grace_period" bundle:""` + Build string `compose:"build" bundle:""` + BuildArgs map[string]*string `compose:"build-args" bundle:""` + ExposeService string `compose:"kompose.service.expose" bundle:""` + Stdin bool `compose:"stdin_open" bundle:""` + Tty bool `compose:"tty" bundle:""` + MemLimit yaml.MemStringorInt `compose:"mem_limit" bundle:""` + TmpFs []string `compose:"tmpfs" bundle:""` + Dockerfile string `compose:"dockerfile" bundle:""` } // EnvVar holds the environment variable struct of a container diff --git a/pkg/loader/compose/compose.go b/pkg/loader/compose/compose.go index e8c093c6..61b97d92 100644 --- a/pkg/loader/compose/compose.go +++ b/pkg/loader/compose/compose.go @@ -373,6 +373,7 @@ func (c *Compose) LoadFile(files []string) (kobject.KomposeObject, error) { serviceConfig.Tty = composeServiceConfig.Tty serviceConfig.MemLimit = composeServiceConfig.MemLimit serviceConfig.TmpFs = composeServiceConfig.Tmpfs + serviceConfig.StopGracePeriod = composeServiceConfig.StopGracePeriod komposeObject.ServiceConfigs[normalizeServiceNames(name)] = serviceConfig if normalizeServiceNames(name) != name { log.Infof("Service name in docker-compose has been changed from %q to %q", name, normalizeServiceNames(name)) diff --git a/pkg/transformer/kubernetes/k8sutils.go b/pkg/transformer/kubernetes/k8sutils.go index 01a67b47..f40100a3 100644 --- a/pkg/transformer/kubernetes/k8sutils.go +++ b/pkg/transformer/kubernetes/k8sutils.go @@ -27,6 +27,7 @@ import ( "strconv" "strings" "text/template" + "time" log "github.com/Sirupsen/logrus" "github.com/ghodss/yaml" @@ -38,10 +39,11 @@ import ( "k8s.io/kubernetes/pkg/apis/extensions" "k8s.io/kubernetes/pkg/runtime" + "sort" + deployapi "github.com/openshift/origin/pkg/deploy/api" "github.com/pkg/errors" "k8s.io/kubernetes/pkg/api/resource" - "sort" ) /** @@ -382,6 +384,13 @@ func (k *Kubernetes) UpdateKubernetesObjects(name string, service kobject.Servic template.Spec.Containers[0].TTY = service.Tty template.Spec.Volumes = volumes + if service.StopGracePeriod != "" { + template.Spec.TerminationGracePeriodSeconds, err = DurationStrToSecondsInt(service.StopGracePeriod) + if err != nil { + log.Warningf("Failed to parse duration \"%v\" for service \"%v\"", service.StopGracePeriod, name) + } + } + // Configure the resource limits if service.MemLimit != 0 { memoryResourceList := api.ResourceList{ @@ -553,3 +562,16 @@ func SortedKeys(komposeObject kobject.KomposeObject) []string { sort.Strings(sortedKeys) return sortedKeys } + +//converts duration string to *int64 in seconds +func DurationStrToSecondsInt(s string) (*int64, error) { + if s == "" { + return nil, nil + } + duration, err := time.ParseDuration(s) + if err != nil { + return nil, err + } + r := (int64)(duration.Seconds()) + return &r, nil +} diff --git a/pkg/transformer/kubernetes/k8sutils_test.go b/pkg/transformer/kubernetes/k8sutils_test.go index 34d6aa45..7c2ed342 100644 --- a/pkg/transformer/kubernetes/k8sutils_test.go +++ b/pkg/transformer/kubernetes/k8sutils_test.go @@ -26,10 +26,11 @@ import ( "github.com/kubernetes-incubator/kompose/pkg/kobject" "github.com/kubernetes-incubator/kompose/pkg/testutils" + "reflect" + "github.com/pkg/errors" "k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/apis/extensions" - "reflect" ) /* @@ -296,3 +297,30 @@ func TestSortedKeys(t *testing.T) { t.Logf("Test Fail output should be %s", c) } } + +//test conversion from duration string to seconds *int64 +func TestDurationStrToSecondsInt(t *testing.T) { + testCases := map[string]struct { + in string + out *int64 + }{ + "5s": {in: "5s", out: &[]int64{5}[0]}, + "1m30s": {in: "1m30s", out: &[]int64{90}[0]}, + "empty": {in: "", out: nil}, + "onlynumber": {in: "2", out: nil}, + "illegal": {in: "abc", out: nil}, + } + + for name, test := range testCases { + result, _ := DurationStrToSecondsInt(test.in) + if test.out == nil && result != nil { + t.Errorf("Case '%v' for TestDurationStrToSecondsInt fail, Expected 'nil' , got '%v'", name, *result) + } + if test.out != nil && result == nil { + t.Errorf("Case '%v' for TestDurationStrToSecondsInt fail, Expected '%v' , got 'nil'", name, *test.out) + } + if test.out != nil && result != nil && *test.out != *result { + t.Errorf("Case '%v' for TestDurationStrToSecondsInt fail, Expected '%v' , got '%v'", name, *test.out, *result) + } + } +} From c5fa9f7f2ad1fcfa7bfe64deb806ff0b4b4b18aa Mon Sep 17 00:00:00 2001 From: Tomas Kral Date: Tue, 23 May 2017 13:53:14 +0200 Subject: [PATCH 12/12] Fix incorrect tag in BuildConfig. For services with build and image keys DeploymentConfig respects tag from docker-compose image key. But BuildConfig image tag was always set to 'latest'. Result of this was that deployment wasn't trigired after successful build. This fixes it by setting BuildConfig output image tag to the same tag that is used for DeploymentConfig (tag from docker-compose image key) --- pkg/transformer/openshift/openshift.go | 2 +- pkg/transformer/openshift/openshift_test.go | 84 +++++++++++++-------- 2 files changed, 55 insertions(+), 31 deletions(-) diff --git a/pkg/transformer/openshift/openshift.go b/pkg/transformer/openshift/openshift.go index d5a2326c..e76f54f3 100644 --- a/pkg/transformer/openshift/openshift.go +++ b/pkg/transformer/openshift/openshift.go @@ -245,7 +245,7 @@ func initBuildConfig(name string, service kobject.ServiceConfig, repo string, br Output: buildapi.BuildOutput{ To: &kapi.ObjectReference{ Kind: "ImageStreamTag", - Name: name + ":latest", + Name: name + ":" + getImageTag(service.Image), }, }, }, diff --git a/pkg/transformer/openshift/openshift_test.go b/pkg/transformer/openshift/openshift_test.go index f88f3844..ded80e65 100644 --- a/pkg/transformer/openshift/openshift_test.go +++ b/pkg/transformer/openshift/openshift_test.go @@ -281,43 +281,67 @@ func TestGetAbsBuildContext(t *testing.T) { // Test initializing buildconfig for a service func TestInitBuildConfig(t *testing.T) { - dir := testutils.CreateLocalGitDirectory(t) - testutils.CreateSubdir(t, dir, "a/build") - defer os.RemoveAll(dir) - serviceName := "serviceA" - repo := "https://git.test.com/org/repo" + repo := "https://git.test.com/org/repo1" branch := "somebranch" buildArgs := []kapi.EnvVar{{Name: "name", Value: "value"}} value := "value" - sc := kobject.ServiceConfig{ - Build: filepath.Join(dir, "a/build"), - Dockerfile: "Dockerfile-alternate", - BuildArgs: map[string]*string{"name": &value}, - } - bc, err := initBuildConfig(serviceName, sc, repo, branch) - if err != nil { - t.Error(errors.Wrap(err, "initBuildConfig failed")) + testDir := "a/build" + + dir := testutils.CreateLocalGitDirectory(t) + testutils.CreateSubdir(t, dir, testDir) + defer os.RemoveAll(dir) + + testCases := []struct { + Name string + ServiceConfig kobject.ServiceConfig + }{ + { + Name: "Service config without image key", + ServiceConfig: kobject.ServiceConfig{ + Build: filepath.Join(dir, testDir), + Dockerfile: "Dockerfile-alternate", + BuildArgs: map[string]*string{"name": &value}, + }, + }, + { + Name: "Service config with image key", + ServiceConfig: kobject.ServiceConfig{ + Build: filepath.Join(dir, testDir), + Dockerfile: "Dockerfile-alternate", + BuildArgs: map[string]*string{"name": &value}, + Image: "foo:bar", + }, + }, } - testCases := map[string]struct { - field string - value string - }{ - "Assert buildconfig source git URI": {bc.Spec.CommonSpec.Source.Git.URI, repo}, - "Assert buildconfig source git Ref": {bc.Spec.CommonSpec.Source.Git.Ref, branch}, - "Assert buildconfig source context dir": {bc.Spec.CommonSpec.Source.ContextDir, "a/build/"}, - "Assert buildconfig output name": {bc.Spec.CommonSpec.Output.To.Name, serviceName + ":latest"}, - "Assert buildconfig dockerfilepath": {bc.Spec.CommonSpec.Strategy.DockerStrategy.DockerfilePath, "Dockerfile-alternate"}, - } - for name, test := range testCases { - t.Log("Test case: ", name) - if test.field != test.value { - t.Errorf("Expected: %#v, got: %#v", test.value, test.field) + for _, test := range testCases { + + bc, err := initBuildConfig(serviceName, test.ServiceConfig, repo, branch) + if err != nil { + t.Error(errors.Wrap(err, "initBuildConfig failed")) + } + + assertions := map[string]struct { + field string + value string + }{ + "Assert buildconfig source git URI": {bc.Spec.CommonSpec.Source.Git.URI, repo}, + "Assert buildconfig source git Ref": {bc.Spec.CommonSpec.Source.Git.Ref, branch}, + "Assert buildconfig source context dir": {bc.Spec.CommonSpec.Source.ContextDir, testDir + "/"}, + // BuildConfig output image is named after service name. If image key is set than tag from that is used. + "Assert buildconfig output name": {bc.Spec.CommonSpec.Output.To.Name, serviceName + ":" + getImageTag(test.ServiceConfig.Image)}, + "Assert buildconfig dockerfilepath": {bc.Spec.CommonSpec.Strategy.DockerStrategy.DockerfilePath, test.ServiceConfig.Dockerfile}, + } + + for name, assertionTest := range assertions { + if assertionTest.field != assertionTest.value { + t.Errorf("%s Expected: %#v, got: %#v", name, assertionTest.value, assertionTest.field) + } + } + if !reflect.DeepEqual(bc.Spec.CommonSpec.Strategy.DockerStrategy.Env, buildArgs) { + t.Errorf("Expected: %#v, got: %#v", bc.Spec.CommonSpec.Strategy.DockerStrategy.Env, buildArgs) } - } - if !reflect.DeepEqual(bc.Spec.CommonSpec.Strategy.DockerStrategy.Env, buildArgs) { - t.Errorf("Expected: %#v, got: %#v", bc.Spec.CommonSpec.Strategy.DockerStrategy.Env, buildArgs) } }