diff --git a/.go-version b/.go-version index 4dae2985b5..587c5f0c73 100644 --- a/.go-version +++ b/.go-version @@ -1 +1 @@ -1.10.1 +1.10.3 diff --git a/.travis.yml b/.travis.yml index cb40b543f7..0a5ffb3c31 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,7 +6,7 @@ services: language: go go: - - 1.10.1 + - 1.10.3 os: - linux @@ -16,7 +16,7 @@ env: global: # Cross-compile for amd64 only to speed up testing. - GOX_FLAGS="-arch amd64" - - GO_VERSION="1.9.4" + - GO_VERSION="1.10.3" jobs: include: diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc index 3307cc56d0..6cef8233b7 100644 --- a/CHANGELOG.asciidoc +++ b/CHANGELOG.asciidoc @@ -14,7 +14,7 @@ https://github.com/elastic/apm-server/compare/6.3\...master[View commits] === Added - Listen on default port 8200 if unspecified {pull}886[886]. -- Update Go to 1.10.1 {pull}894[894]. +- Update Go to 1.10.3 {pull}1054[1054]. - Combine `apm-server.yml` and `apm-server.reference.yml` into one file {pull}958[958]. - Add optional tracing for the server's API and event publisher {pull}816[816]. - Read sourcemap content and fill context lines {pull}972[972]. diff --git a/Dockerfile b/Dockerfile index 9a7133ecea..da1f80b7a3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.10.1 +FROM golang:1.10.3 MAINTAINER Nicolas Ruflin RUN set -x && \ diff --git a/Makefile b/Makefile index 19657b8932..c57de8eca5 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,4 @@ BEAT_NAME=apm-server -BEAT_DESCRIPTION=Elastic Application Performance Monitoring Server BEAT_INDEX_PREFIX=apm BEAT_PATH=github.com/elastic/apm-server BEAT_GOPATH=$(firstword $(subst :, ,${GOPATH})) @@ -9,14 +8,11 @@ BEAT_REF_YAML=false SYSTEM_TESTS=true TEST_ENVIRONMENT=true ES_BEATS?=./_beats -PREFIX?=. BEATS_VERSION?=master -NOTICE_FILE=NOTICE.txt -LICENSE_FILE=licenses/APACHE-LICENSE-2.0.txt -ELASTIC_LICENSE_FILE=licenses/ELASTIC-LICENSE.txt NOW=$(shell date -u '+%Y-%m-%dT%H:%M:%S') GOBUILD_FLAGS=-i -ldflags "-s -X $(BEAT_PATH)/vendor/github.com/elastic/beats/libbeat/version.buildTime=$(NOW) -X $(BEAT_PATH)/vendor/github.com/elastic/beats/libbeat/version.commit=$(COMMIT_ID)" FIELDS_FILE_PATH=processor +MAGE_IMPORT_PATH=${BEAT_PATH}/vendor/github.com/magefile/mage # Path to the libbeat Makefile -include $(ES_BEATS)/libbeat/scripts/Makefile @@ -34,13 +30,9 @@ update-beats: is-beats-updated: python-env @$(PYTHON_ENV)/bin/python ./script/is_beats_updated.py ${BEATS_VERSION} -# This is called by the beats packer before building starts -.PHONY: before-build -before-build: - # Collects all dependencies and then calls update .PHONY: collect -collect: fields go-generate create-docs notice +collect: fields go-generate add-headers create-docs notice .PHONY: go-generate go-generate: @@ -89,3 +81,15 @@ force-update-docs: clean docs update-beats-docs: @python script/copy-docs.py @$(MAKE) docs + +# Builds a snapshot release. The Go version defined in .go-version will be +# installed and used for the build. +.PHONY: release-manager-release +release-manager-snapshot: + @$(MAKE) SNAPSHOT=true release-manager-release + +# Builds a snapshot release. The Go version defined in .go-version will be +# installed and used for the build. +.PHONY: release-manager-release +release-manager-release: + ./_beats/dev-tools/run_with_go_ver $(MAKE) release diff --git a/NOTICE.txt b/NOTICE.txt index 185c4d9905..68308b57ea 100644 --- a/NOTICE.txt +++ b/NOTICE.txt @@ -291,8 +291,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------- Dependency: github.com/elastic/beats -Version: master -Revision: c941a3d38792137bfc53a3a121f40cebf20b5512 +Revision: af1638c90567274690c8111d47e3c5f12c396558 License type (autodetected): Apache-2.0 ./vendor/github.com/elastic/beats/LICENSE.txt: -------------------------------------------------------------------- @@ -1170,6 +1169,15 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +-------------------------------------------------------------------- +Dependency: github.com/magefile/mage +Revision: 5e51f9ad1ed0886c5d06a8c46a09703cfc4d9034 +License type (autodetected): Apache-2.0 +./vendor/github.com/magefile/mage/LICENSE: +-------------------------------------------------------------------- +Apache License 2.0 + + -------------------------------------------------------------------- Dependency: github.com/mattn/go-colorable Revision: 941b50ebc6efddf4c41c8e4537a5f68a4e686b24 @@ -2331,6 +2339,40 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +-------------------------------------------------------------------- +Dependency: golang.org/x/tools +Revision: 5d2fd3ccab986d52112bf301d47a819783339d0e +License type (autodetected): BSD-3-Clause +./vendor/golang.org/x/tools/LICENSE: +-------------------------------------------------------------------- +Copyright (c) 2009 The Go Authors. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the following disclaimer +in the documentation and/or other materials provided with the +distribution. + * Neither the name of Google Inc. nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + -------------------------------------------------------------------- Dependency: gopkg.in/yaml.v2 Revision: cd8b52f8269e0feb286dfeef29f8fe4d5b397e0b diff --git a/README.md b/README.md index 213d59591b..c121acf1ff 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ To get started with APM please see our [Getting Started Guide](https://www.elast ### Requirements -* [Golang](https://golang.org/dl/) 1.10.1 +* [Golang](https://golang.org/dl/) 1.10.3 ### Install diff --git a/_beats/.go-version b/_beats/.go-version index 5ad2491cf8..587c5f0c73 100644 --- a/_beats/.go-version +++ b/_beats/.go-version @@ -1 +1 @@ -1.10.2 +1.10.3 diff --git a/_beats/dev-tools/.beatconfig b/_beats/dev-tools/.beatconfig deleted file mode 100644 index 6821aff8ce..0000000000 --- a/_beats/dev-tools/.beatconfig +++ /dev/null @@ -1,4 +0,0 @@ -packetbeat-/packetbeat- -filebeat-/filebeat- -winlogonbeat-/winlogonbeat- -logstash-/logstash- diff --git a/_beats/dev-tools/cmd/asset/asset.go b/_beats/dev-tools/cmd/asset/asset.go index 4a08fa6de7..12da770803 100644 --- a/_beats/dev-tools/cmd/asset/asset.go +++ b/_beats/dev-tools/cmd/asset/asset.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + // +build ignore package main @@ -9,7 +26,6 @@ import ( "go/format" "io/ioutil" "os" - "text/template" "github.com/elastic/beats/libbeat/asset" ) @@ -20,34 +36,6 @@ func init() { pkg = flag.String("pkg", "", "Package name") } -var tpl = template.Must(template.New("normalizations").Parse(` -// Code generated by beats/dev-tools/cmd/asset/asset.go - DO NOT EDIT. - -package {{ .Package }} - -import ( - "github.com/elastic/beats/libbeat/asset" -) - -func init() { - if err := asset.SetFields("{{ .Name }}", Asset); err != nil { - panic(err) - } -} - -// Asset returns asset data -func Asset() string { - return "{{ .Data }}" -} - -`)) - -type assetData struct { - Name string - Data string - Package string -} - func main() { flag.Parse() @@ -73,8 +61,9 @@ func main() { } var buf bytes.Buffer - tpl.Execute(&buf, assetData{ - Name: beatName + "/" + file, + asset.Template.Execute(&buf, asset.Data{ + Beat: beatName, + Name: file, Data: encData, Package: *pkg, }) diff --git a/_beats/dev-tools/cmd/dashboards/export_dashboards.go b/_beats/dev-tools/cmd/dashboards/export_dashboards.go index 7d8121fc77..ef5dc2b13f 100644 --- a/_beats/dev-tools/cmd/dashboards/export_dashboards.go +++ b/_beats/dev-tools/cmd/dashboards/export_dashboards.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package main import ( diff --git a/_beats/dev-tools/cmd/kibana_index_pattern/kibana_index_pattern.go b/_beats/dev-tools/cmd/kibana_index_pattern/kibana_index_pattern.go index 373e63bce2..9841a4f69f 100644 --- a/_beats/dev-tools/cmd/kibana_index_pattern/kibana_index_pattern.go +++ b/_beats/dev-tools/cmd/kibana_index_pattern/kibana_index_pattern.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package main import ( diff --git a/_beats/dev-tools/common.bash b/_beats/dev-tools/common.bash index 048c835f2c..cb8a8d5c08 100644 --- a/_beats/dev-tools/common.bash +++ b/_beats/dev-tools/common.bash @@ -91,4 +91,8 @@ jenkins_setup() { # Workaround for Python virtualenv path being too long. export TEMP_PYTHON_ENV=$(mktemp -d) export PYTHON_ENV="${TEMP_PYTHON_ENV}/python-env" + + # Write cached magefile binaries to workspace to ensure + # each run starts from a clean slate. + export MAGEFILE_CACHE="${WORKSPACE}/.magefile" } diff --git a/_beats/dev-tools/deploy b/_beats/dev-tools/deploy index 812a003439..2b0de52e4c 100755 --- a/_beats/dev-tools/deploy +++ b/_beats/dev-tools/deploy @@ -16,9 +16,9 @@ def main(): check_call("make clean", shell=True) print("Done building Docker images.") if args.no_snapshot: - check_call("make SNAPSHOT=no package-all", shell=True) + check_call("make release", shell=True) else: - check_call("make SNAPSHOT=yes package-all", shell=True) + check_call("make snapshot", shell=True) print("All done") if __name__ == "__main__": diff --git a/_beats/dev-tools/jenkins_ci.ps1 b/_beats/dev-tools/jenkins_ci.ps1 index 4db34c03bc..a27381a36e 100755 --- a/_beats/dev-tools/jenkins_ci.ps1 +++ b/_beats/dev-tools/jenkins_ci.ps1 @@ -17,6 +17,10 @@ $env:GOPATH = $env:WORKSPACE $env:PATH = "$env:GOPATH\bin;C:\tools\mingw64\bin;$env:PATH" & gvm --format=powershell $(Get-Content .go-version) | Invoke-Expression +# Write cached magefile binaries to workspace to ensure +# each run starts from a clean slate. +$env:MAGEFILE_CACHE = "$env:WORKSPACE\.magefile" + if (Test-Path "$env:beat") { cd "$env:beat" } else { diff --git a/_beats/dev-tools/jenkins_release.sh b/_beats/dev-tools/jenkins_release.sh new file mode 100755 index 0000000000..a0915a7fe7 --- /dev/null +++ b/_beats/dev-tools/jenkins_release.sh @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +set -euox pipefail + +: "${HOME:?Need to set HOME to a non-empty value.}" +: "${WORKSPACE:?Need to set WORKSPACE to a non-empty value.}" + +source ./dev-tools/common.bash + +jenkins_setup + +cleanup() { + echo "Running cleanup..." + rm -rf $TEMP_PYTHON_ENV + echo "Cleanup complete." +} +trap cleanup EXIT + +make release diff --git a/_beats/dev-tools/mage/.gitignore b/_beats/dev-tools/mage/.gitignore new file mode 100644 index 0000000000..378eac25d3 --- /dev/null +++ b/_beats/dev-tools/mage/.gitignore @@ -0,0 +1 @@ +build diff --git a/_beats/dev-tools/mage/build.go b/_beats/dev-tools/mage/build.go new file mode 100644 index 0000000000..86bd420930 --- /dev/null +++ b/_beats/dev-tools/mage/build.go @@ -0,0 +1,144 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package mage + +import ( + "fmt" + "go/build" + "log" + "os" + "path/filepath" + "strings" + + "github.com/magefile/mage/sh" + "github.com/pkg/errors" +) + +// BuildArgs are the arguments used for the "build" target and they define how +// "go build" is invoked. +type BuildArgs struct { + Name string // Name of binary. (On Windows '.exe' is appended.) + OutputDir string + CGO bool + Static bool + Env map[string]string + LDFlags []string + Vars map[string]string // Vars that are passed as -X key=value with the ldflags. + ExtraFlags []string +} + +// DefaultBuildArgs returns the default BuildArgs for use in builds. +func DefaultBuildArgs() BuildArgs { + args := BuildArgs{ + Name: BeatName, + CGO: build.Default.CgoEnabled, + Vars: map[string]string{ + "github.com/elastic/beats/libbeat/version.buildTime": "{{ date }}", + "github.com/elastic/beats/libbeat/version.commit": "{{ commit }}", + }, + } + + repo, err := GetProjectRepoInfo() + if err != nil { + panic(errors.Wrap(err, "failed to determine project repo info")) + } + + if !repo.IsElasticBeats() { + // Assume libbeat is vendored and prefix the variables. + prefix := repo.RootImportPath + "/vendor/" + prefixedVars := map[string]string{} + for k, v := range args.Vars { + prefixedVars[prefix+k] = v + } + args.Vars = prefixedVars + } + + return args +} + +// DefaultGolangCrossBuildArgs returns the default BuildArgs for use in +// cross-builds. +func DefaultGolangCrossBuildArgs() BuildArgs { + args := DefaultBuildArgs() + args.Name += "-" + Platform.GOOS + "-" + Platform.Arch + args.OutputDir = filepath.Join("build", "golang-crossbuild") + if bp, found := BuildPlatforms.Get(Platform.Name); found { + args.CGO = bp.Flags.SupportsCGO() + } + return args +} + +// GolangCrossBuild invokes "go build" inside of the golang-crossbuild Docker +// environment. +func GolangCrossBuild(params BuildArgs) error { + if os.Getenv("GOLANG_CROSSBUILD") != "1" { + return errors.New("Use the crossBuild target. golangCrossBuild can " + + "only be executed within the golang-crossbuild docker environment.") + } + + defer DockerChown(filepath.Join(params.OutputDir, params.Name+binaryExtension(GOOS))) + return Build(params) +} + +// Build invokes "go build" to produce a binary. +func Build(params BuildArgs) error { + fmt.Println(">> build: Building", params.Name) + + binaryName := params.Name + binaryExtension(GOOS) + + if params.OutputDir != "" { + if err := os.MkdirAll(params.OutputDir, 0755); err != nil { + return err + } + } + + // Environment + env := params.Env + if env == nil { + env = map[string]string{} + } + cgoEnabled := "0" + if params.CGO { + cgoEnabled = "1" + } + env["CGO_ENABLED"] = cgoEnabled + + // Spec + args := []string{ + "build", + "-o", + filepath.Join(params.OutputDir, binaryName), + } + args = append(args, params.ExtraFlags...) + + // ldflags + ldflags := params.LDFlags + if params.Static { + ldflags = append(ldflags, `-extldflags '-static'`) + } + for k, v := range params.Vars { + ldflags = append(ldflags, fmt.Sprintf("-X %v=%v", k, v)) + } + if len(ldflags) > 0 { + args = append(args, "-ldflags") + args = append(args, MustExpand(strings.Join(ldflags, " "))) + } + + log.Println("Adding build environment vars:", env) + return sh.RunWith(env, "go", args...) +} diff --git a/_beats/dev-tools/mage/clean.go b/_beats/dev-tools/mage/clean.go new file mode 100644 index 0000000000..912d372e1d --- /dev/null +++ b/_beats/dev-tools/mage/clean.go @@ -0,0 +1,54 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package mage + +import ( + "github.com/magefile/mage/sh" +) + +// DefaultCleanPaths specifies a list of files or paths to recursively delete. +// The values may contain variables and will be expanded at the time of use. +var DefaultCleanPaths = []string{ + "build", + "docker-compose.yml.lock", + "{{.BeatName}}", + "{{.BeatName}}.exe", + "{{.BeatName}}.test", + "{{.BeatName}}.test.exe", + "fields.yml", + "_meta/fields.generated.yml", + "_meta/kibana.generated", + "_meta/kibana/5/index-pattern/{{.BeatName}}.json", + "_meta/kibana/6/index-pattern/{{.BeatName}}.json", +} + +// Clean clean generated build artifacts. +func Clean(pathLists ...[]string) error { + if len(pathLists) == 0 { + pathLists = [][]string{DefaultCleanPaths} + } + for _, paths := range pathLists { + for _, f := range paths { + f = MustExpand(f) + if err := sh.Rm(f); err != nil { + return err + } + } + } + return nil +} diff --git a/_beats/dev-tools/mage/common.go b/_beats/dev-tools/mage/common.go new file mode 100644 index 0000000000..1ab47d6b5d --- /dev/null +++ b/_beats/dev-tools/mage/common.go @@ -0,0 +1,690 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package mage + +import ( + "archive/tar" + "archive/zip" + "bufio" + "bytes" + "compress/gzip" + "context" + "crypto/sha256" + "crypto/sha512" + "encoding/hex" + "encoding/json" + "fmt" + "io" + "io/ioutil" + "log" + "net/http" + "os" + "path/filepath" + "regexp" + "runtime" + "strconv" + "strings" + "sync" + "text/template" + "time" + "unicode" + + "github.com/magefile/mage/sh" + "github.com/magefile/mage/target" + "github.com/magefile/mage/types" + "github.com/pkg/errors" +) + +// Expand expands the given Go text/template string. +func Expand(in string, args ...map[string]interface{}) (string, error) { + return expandTemplate("inline", in, FuncMap, EnvMap(args...)) +} + +// MustExpand expands the given Go text/template string. It panics if there is +// an error. +func MustExpand(in string, args ...map[string]interface{}) string { + out, err := Expand(in, args...) + if err != nil { + panic(err) + } + return out +} + +// ExpandFile expands the Go text/template read from src and writes the output +// to dst. +func ExpandFile(src, dst string, args ...map[string]interface{}) error { + return expandFile(src, dst, EnvMap(args...)) +} + +// MustExpandFile expands the Go text/template read from src and writes the +// output to dst. It panics if there is an error. +func MustExpandFile(src, dst string, args ...map[string]interface{}) { + if err := ExpandFile(src, dst, args...); err != nil { + panic(err) + } +} + +func expandTemplate(name, tmpl string, funcs template.FuncMap, args ...map[string]interface{}) (string, error) { + t := template.New(name).Option("missingkey=error") + if len(funcs) > 0 { + t = t.Funcs(funcs) + } + + t, err := t.Parse(tmpl) + if err != nil { + if name == "inline" { + return "", errors.Wrapf(err, "failed to parse template '%v'", tmpl) + } + return "", errors.Wrap(err, "failed to parse template") + } + + buf := new(bytes.Buffer) + if err := t.Execute(buf, joinMaps(args...)); err != nil { + if name == "inline" { + return "", errors.Wrapf(err, "failed to expand template '%v'", tmpl) + } + return "", errors.Wrap(err, "failed to expand template") + } + + return buf.String(), nil +} + +func joinMaps(args ...map[string]interface{}) map[string]interface{} { + switch len(args) { + case 0: + return nil + case 1: + return args[0] + } + + var out map[string]interface{} + for _, m := range args { + for k, v := range m { + out[k] = v + } + } + return out +} + +func expandFile(src, dst string, args ...map[string]interface{}) error { + tmplData, err := ioutil.ReadFile(src) + if err != nil { + return errors.Wrapf(err, "failed reading from template %v", src) + } + + output, err := expandTemplate(src, string(tmplData), FuncMap, args...) + if err != nil { + return err + } + + dst, err = expandTemplate("inline", dst, FuncMap, args...) + if err != nil { + return err + } + + if err = ioutil.WriteFile(createDir(dst), []byte(output), 0644); err != nil { + return errors.Wrap(err, "failed to write rendered template") + } + + return nil +} + +// CWD return the current working directory. +func CWD() string { + wd, err := os.Getwd() + if err != nil { + panic(errors.Wrap(err, "failed to get the CWD")) + } + return wd +} + +// EnvOr returns the value of the specified environment variable if it is +// non-empty. Otherwise it return def. +func EnvOr(name, def string) string { + s := os.Getenv(name) + if s == "" { + return def + } + return s +} + +var ( + dockerInfoValue *DockerInfo + dockerInfoErr error + dockerInfoOnce sync.Once +) + +// DockerInfo contains information about the docker daemon. +type DockerInfo struct { + OperatingSystem string `json:"OperatingSystem"` + Labels []string `json:"Labels"` + NCPU int `json:"NCPU"` + MemTotal int `json:"MemTotal"` +} + +// IsBoot2Docker returns true if the Docker OS is boot2docker. +func (info *DockerInfo) IsBoot2Docker() bool { + return strings.Contains(strings.ToLower(info.OperatingSystem), "boot2docker") +} + +// HaveDocker returns an error if docker is unavailable. +func HaveDocker() error { + if _, err := GetDockerInfo(); err != nil { + return errors.Wrap(err, "docker is not available") + } + return nil +} + +// GetDockerInfo returns data from the docker info command. +func GetDockerInfo() (*DockerInfo, error) { + dockerInfoOnce.Do(func() { + dockerInfoValue, dockerInfoErr = dockerInfo() + }) + + return dockerInfoValue, dockerInfoErr +} + +func dockerInfo() (*DockerInfo, error) { + data, err := sh.Output("docker", "info", "-f", "{{ json .}}") + if err != nil { + return nil, err + } + + var info DockerInfo + if err = json.Unmarshal([]byte(data), &info); err != nil { + return nil, err + } + + return &info, nil +} + +// FindReplace reads a file, performs a find/replace operation, then writes the +// output to the same file path. +func FindReplace(file string, re *regexp.Regexp, repl string) error { + info, err := os.Stat(file) + if err != nil { + return err + } + + contents, err := ioutil.ReadFile(file) + if err != nil { + return err + } + + out := re.ReplaceAllString(string(contents), repl) + return ioutil.WriteFile(file, []byte(out), info.Mode().Perm()) +} + +// MustFindReplace invokes FindReplace and panics if an error occurs. +func MustFindReplace(file string, re *regexp.Regexp, repl string) { + if err := FindReplace(file, re, repl); err != nil { + panic(errors.Wrap(err, "failed to find and replace")) + } +} + +// Copy copies a file or a directory (recursively) and preserves the permissions. +func Copy(src, dest string) error { + info, err := os.Stat(src) + if err != nil { + return errors.Wrapf(err, "failed to stat source file %v", src) + } + return recursiveCopy(src, dest, info) +} + +func fileCopy(src, dest string, info os.FileInfo) error { + srcFile, err := os.Open(src) + if err != nil { + return err + } + defer srcFile.Close() + + if !info.Mode().IsRegular() { + return errors.Errorf("failed to copy source file because it is not a regular file") + } + + destFile, err := os.OpenFile(createDir(dest), os.O_CREATE|os.O_TRUNC|os.O_WRONLY, info.Mode()&os.ModePerm) + if err != nil { + return err + } + defer destFile.Close() + + if _, err = io.Copy(destFile, srcFile); err != nil { + return err + } + return destFile.Close() +} + +func dirCopy(src, dest string, info os.FileInfo) error { + if err := os.MkdirAll(dest, info.Mode()); err != nil { + return errors.Wrap(err, "failed creating dirs") + } + + contents, err := ioutil.ReadDir(src) + if err != nil { + return errors.Wrapf(err, "failed to read dir %v", src) + } + + for _, info := range contents { + srcFile := filepath.Join(src, info.Name()) + destFile := filepath.Join(dest, info.Name()) + if err = recursiveCopy(srcFile, destFile, info); err != nil { + return errors.Wrapf(err, "failed to copy %v to %v", srcFile, destFile) + } + } + + return nil +} + +func recursiveCopy(src, dest string, info os.FileInfo) error { + if info.IsDir() { + return dirCopy(src, dest, info) + } + return fileCopy(src, dest, info) +} + +// DownloadFile downloads the given URL and writes the file to destinationDir. +// The path to the file is returned. +func DownloadFile(url, destinationDir string) (string, error) { + log.Println("Downloading", url) + + resp, err := http.Get(url) + if err != nil { + return "", errors.Wrap(err, "http get failed") + } + defer resp.Body.Close() + + if resp.StatusCode != http.StatusOK { + return "", errors.Errorf("download failed with http status: %v", resp.StatusCode) + } + + name := filepath.Join(destinationDir, filepath.Base(url)) + f, err := os.Create(createDir(name)) + if err != nil { + return "", errors.Wrap(err, "failed to create output file") + } + defer f.Close() + + if _, err = io.Copy(f, resp.Body); err != nil { + return "", errors.Wrap(err, "failed to write file") + } + + return name, f.Close() +} + +// Extract extracts .zip, .tar.gz, or .tgz files to destinationDir. +func Extract(sourceFile, destinationDir string) error { + ext := filepath.Ext(sourceFile) + switch { + case strings.HasSuffix(sourceFile, ".tar.gz"), ext == ".tgz": + return untar(sourceFile, destinationDir) + case ext == ".zip": + return unzip(sourceFile, destinationDir) + default: + return errors.Errorf("failed to extract %v, unhandled file extension", sourceFile) + } +} + +func unzip(sourceFile, destinationDir string) error { + r, err := zip.OpenReader(sourceFile) + if err != nil { + return err + } + defer r.Close() + + if err = os.MkdirAll(destinationDir, 0755); err != nil { + return err + } + + extractAndWriteFile := func(f *zip.File) error { + innerFile, err := f.Open() + if err != nil { + return err + } + defer innerFile.Close() + + path := filepath.Join(destinationDir, f.Name) + if !strings.HasPrefix(path, destinationDir) { + return errors.Errorf("illegal file path in zip: %v", f.Name) + } + + if f.FileInfo().IsDir() { + return os.MkdirAll(path, f.Mode()) + } + + if err = os.MkdirAll(filepath.Dir(path), 0755); err != nil { + return err + } + + out, err := os.OpenFile(path, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, f.Mode()) + if err != nil { + return err + } + defer out.Close() + + if _, err = io.Copy(out, innerFile); err != nil { + return err + } + + return out.Close() + } + + for _, f := range r.File { + err := extractAndWriteFile(f) + if err != nil { + return err + } + } + + return nil +} + +func untar(sourceFile, destinationDir string) error { + file, err := os.Open(sourceFile) + if err != nil { + return err + } + defer file.Close() + + var fileReader io.ReadCloser = file + + if strings.HasSuffix(sourceFile, ".gz") { + if fileReader, err = gzip.NewReader(file); err != nil { + return err + } + defer fileReader.Close() + } + + tarReader := tar.NewReader(fileReader) + + for { + header, err := tarReader.Next() + if err != nil { + if err == io.EOF { + break + } + return err + } + + path := filepath.Join(destinationDir, header.Name) + if !strings.HasPrefix(path, destinationDir) { + return errors.Errorf("illegal file path in tar: %v", header.Name) + } + + switch header.Typeflag { + case tar.TypeDir: + if err = os.MkdirAll(path, os.FileMode(header.Mode)); err != nil { + return err + } + case tar.TypeReg: + writer, err := os.Create(path) + if err != nil { + return err + } + + if _, err = io.Copy(writer, tarReader); err != nil { + return err + } + + if err = os.Chmod(path, os.FileMode(header.Mode)); err != nil { + return err + } + + if err = writer.Close(); err != nil { + return err + } + default: + return errors.Errorf("unable to untar type=%c in file=%s", header.Typeflag, path) + } + } + + return nil +} + +func isSeparator(r rune) bool { + return unicode.IsSpace(r) || r == ',' || r == ';' +} + +// RunCmds runs the given commands and stops upon the first error. +func RunCmds(cmds ...[]string) error { + for _, cmd := range cmds { + if err := sh.Run(cmd[0], cmd[1:]...); err != nil { + return err + } + } + return nil +} + +var ( + parallelJobsLock sync.Mutex + parallelJobsSemaphore chan int +) + +func parallelJobs() chan int { + parallelJobsLock.Lock() + defer parallelJobsLock.Unlock() + + if parallelJobsSemaphore == nil { + max := numParallel() + parallelJobsSemaphore = make(chan int, max) + log.Println("Max parallel jobs =", max) + } + + return parallelJobsSemaphore +} + +func numParallel() int { + if maxParallel := os.Getenv("MAX_PARALLEL"); maxParallel != "" { + if num, err := strconv.Atoi(maxParallel); err == nil && num > 0 { + return num + } + } + + // To be conservative use the minimum of the number of CPUs between the host + // and the Docker host. + maxParallel := runtime.NumCPU() + + info, err := GetDockerInfo() + if err == nil && info.NCPU < maxParallel { + maxParallel = info.NCPU + } + + return maxParallel +} + +// ParallelCtx runs the given functions in parallel with an upper limit set +// based on GOMAXPROCS. The provided ctx is passed to the functions (if they +// accept it as a param). +func ParallelCtx(ctx context.Context, fns ...interface{}) { + var fnWrappers []func(context.Context) error + for _, f := range fns { + fnWrapper := types.FuncTypeWrap(f) + if fnWrapper == nil { + panic("attempted to add a dep that did not match required function type") + } + fnWrappers = append(fnWrappers, fnWrapper) + } + + var mu sync.Mutex + var errs []string + var wg sync.WaitGroup + + for _, fw := range fnWrappers { + wg.Add(1) + go func(fw func(context.Context) error) { + defer func() { + if v := recover(); v != nil { + mu.Lock() + errs = append(errs, fmt.Sprint(v)) + mu.Unlock() + } + wg.Done() + <-parallelJobs() + }() + waitStart := time.Now() + parallelJobs() <- 1 + log.Println("Parallel job waited", time.Since(waitStart), "before starting.") + if err := fw(ctx); err != nil { + mu.Lock() + errs = append(errs, fmt.Sprint(err)) + mu.Unlock() + } + }(fw) + } + + wg.Wait() + if len(errs) > 0 { + panic(errors.Errorf(strings.Join(errs, "\n"))) + } +} + +// Parallel runs the given functions in parallel with an upper limit set based +// on GOMAXPROCS. +func Parallel(fns ...interface{}) { + ParallelCtx(context.Background(), fns...) +} + +// FindFiles return a list of file matching the given glob patterns. +func FindFiles(globs ...string) ([]string, error) { + var configFiles []string + for _, glob := range globs { + files, err := filepath.Glob(glob) + if err != nil { + return nil, errors.Wrapf(err, "failed on glob %v", glob) + } + configFiles = append(configFiles, files...) + } + return configFiles, nil +} + +// FileConcat concatenates files and writes the output to out. +func FileConcat(out string, perm os.FileMode, files ...string) error { + f, err := os.OpenFile(createDir(out), os.O_CREATE|os.O_TRUNC|os.O_WRONLY, perm) + if err != nil { + return errors.Wrap(err, "failed to create file") + } + defer f.Close() + + w := bufio.NewWriter(f) + + append := func(file string) error { + in, err := os.Open(file) + if err != nil { + return err + } + defer in.Close() + + if _, err := io.Copy(w, in); err != nil { + return err + } + + return nil + } + + for _, in := range files { + if err := append(in); err != nil { + return err + } + } + + if err = w.Flush(); err != nil { + return err + } + return f.Close() +} + +// MustFileConcat invokes FileConcat and panics if an error occurs. +func MustFileConcat(out string, perm os.FileMode, files ...string) { + if err := FileConcat(out, perm, files...); err != nil { + panic(err) + } +} + +// VerifySHA256 reads a file and verifies that its SHA256 sum matches the +// specified hash. +func VerifySHA256(file string, hash string) error { + f, err := os.Open(file) + if err != nil { + return errors.Wrap(err, "failed to open file for sha256 verification") + } + defer f.Close() + + sum := sha256.New() + if _, err := io.Copy(sum, f); err != nil { + return errors.Wrap(err, "failed reading from input file") + } + + computedHash := hex.EncodeToString(sum.Sum(nil)) + expectedHash := strings.TrimSpace(hash) + + if computedHash != expectedHash { + return errors.Errorf("SHA256 verification of %v failed. Expected=%v, "+ + "but computed=%v", f.Name(), expectedHash, computedHash) + } + log.Println("SHA256 OK:", f.Name()) + + return nil +} + +// CreateSHA512File computes the sha512 sum of the specified file the writes +// a sidecar file containing the hash and filename. +func CreateSHA512File(file string) error { + f, err := os.Open(file) + if err != nil { + return errors.Wrap(err, "failed to open file for sha512 summing") + } + defer f.Close() + + sum := sha512.New() + if _, err := io.Copy(sum, f); err != nil { + return errors.Wrap(err, "failed reading from input file") + } + + computedHash := hex.EncodeToString(sum.Sum(nil)) + out := fmt.Sprintf("%v %v", computedHash, filepath.Base(file)) + + return ioutil.WriteFile(file+".sha512", []byte(out), 0644) +} + +// IsUpToDate returns true iff dst exists and is older based on modtime than all +// of the sources. +func IsUpToDate(dst string, sources ...string) bool { + if len(sources) == 0 { + panic("No sources passed to IsUpToDate") + } + execute, err := target.Path(dst, sources...) + return err == nil && !execute +} + +// createDir creates the parent directory for the given file. +func createDir(file string) string { + // Create the output directory. + if dir := filepath.Dir(file); dir != "." { + if err := os.MkdirAll(dir, 0755); err != nil { + panic(errors.Wrapf(err, "failed to create parent dir for %v", file)) + } + } + return file +} + +// binaryExtension returns the appropriate file extension based on GOOS. +func binaryExtension(goos string) string { + if goos == "windows" { + return ".exe" + } + return "" +} diff --git a/_beats/dev-tools/mage/crossbuild.go b/_beats/dev-tools/mage/crossbuild.go new file mode 100644 index 0000000000..4a41cde080 --- /dev/null +++ b/_beats/dev-tools/mage/crossbuild.go @@ -0,0 +1,239 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package mage + +import ( + "fmt" + "log" + "os" + "path/filepath" + "runtime" + "strconv" + "strings" + + "github.com/magefile/mage/mg" + "github.com/magefile/mage/sh" + "github.com/pkg/errors" +) + +const defaultCrossBuildTarget = "golangCrossBuild" + +// Platforms contains the set of target platforms for cross-builds. It can be +// modified at runtime by setting the PLATFORMS environment variable. +// See NewPlatformList for details about platform filtering expressions. +var Platforms = BuildPlatforms.Defaults() + +func init() { + // Allow overriding via PLATFORMS. + if expression := os.Getenv("PLATFORMS"); len(expression) > 0 { + Platforms = NewPlatformList(expression) + } +} + +// CrossBuildOption defines a option to the CrossBuild target. +type CrossBuildOption func(params *crossBuildParams) + +// ForPlatforms filters the platforms based on the given expression. +func ForPlatforms(expr string) func(params *crossBuildParams) { + return func(params *crossBuildParams) { + params.Platforms = params.Platforms.Filter(expr) + } +} + +// WithTarget specifies the mage target to execute inside the golang-crossbuild +// container. +func WithTarget(target string) func(params *crossBuildParams) { + return func(params *crossBuildParams) { + params.Target = target + } +} + +// Serially causes each cross-build target to be executed serially instead of +// in parallel. +func Serially() func(params *crossBuildParams) { + return func(params *crossBuildParams) { + params.Serial = true + } +} + +type crossBuildParams struct { + Platforms BuildPlatformList + Target string + Serial bool +} + +// CrossBuild executes a given build target once for each target platform. +func CrossBuild(options ...CrossBuildOption) error { + params := crossBuildParams{Platforms: Platforms, Target: defaultCrossBuildTarget} + for _, opt := range options { + opt(¶ms) + } + + // Docker is required for this target. + if err := HaveDocker(); err != nil { + return err + } + + if len(params.Platforms) == 0 { + log.Printf("Skipping cross-build of target=%v because platforms list is empty.", params.Target) + return nil + } + + // Build the magefile for Linux so we can run it inside the container. + mg.Deps(buildMage) + + log.Println("crossBuild: Platform list =", params.Platforms) + var deps []interface{} + for _, buildPlatform := range params.Platforms { + if !buildPlatform.Flags.CanCrossBuild() { + return fmt.Errorf("unsupported cross build platform %v", buildPlatform.Name) + } + + builder := GolangCrossBuilder{buildPlatform.Name, params.Target} + if params.Serial { + if err := builder.Build(); err != nil { + return errors.Wrapf(err, "failed cross-building target=%v for platform=%v", + params.Target, buildPlatform.Name) + } + } else { + deps = append(deps, builder.Build) + } + } + + // Each build runs in parallel. + Parallel(deps...) + return nil +} + +// buildMage pre-compiles the magefile to a binary using the native GOOS/GOARCH +// values for Docker. This is required to so that we can later pass GOOS and +// GOARCH to mage for the cross-build. It has the benefit of speeding up the +// build because the mage -compile is done only once rather than in each Docker +// container. +func buildMage() error { + env := map[string]string{ + "GOOS": "linux", + "GOARCH": "amd64", + } + return sh.RunWith(env, "mage", "-f", "-compile", filepath.Join("build", "mage-linux-amd64")) +} + +func crossBuildImage(platform string) (string, error) { + tagSuffix := "main" + + switch { + case strings.HasPrefix(platform, "darwin"): + tagSuffix = "darwin" + case strings.HasPrefix(platform, "linux/arm"): + tagSuffix = "arm" + case strings.HasPrefix(platform, "linux/mips"): + tagSuffix = "mips" + case strings.HasPrefix(platform, "linux/ppc"): + tagSuffix = "ppc" + case platform == "linux/s390x": + tagSuffix = "s390x" + case strings.HasPrefix(platform, "linux"): + // Use an older version of libc to gain greater OS compatibility. + // Debian 7 uses glibc 2.13. + tagSuffix = "main-debian7" + } + + goVersion, err := GoVersion() + if err != nil { + return "", err + } + + return beatsCrossBuildImage + ":" + goVersion + "-" + tagSuffix, nil +} + +// GolangCrossBuilder executes the specified mage target inside of the +// associated golang-crossbuild container image for the platform. +type GolangCrossBuilder struct { + Platform string + Target string +} + +// Build executes the build inside of Docker. +func (b GolangCrossBuilder) Build() error { + fmt.Printf(">> %v: Building for %v\n", b.Target, b.Platform) + + repoInfo, err := GetProjectRepoInfo() + if err != nil { + return errors.Wrap(err, "failed to determine repo root and package sub dir") + } + + mountPoint := filepath.ToSlash(filepath.Join("/go", "src", repoInfo.RootImportPath)) + workDir := mountPoint + if repoInfo.SubDir != "" { + workDir = filepath.ToSlash(filepath.Join(workDir, repoInfo.SubDir)) + } + + dockerRun := sh.RunCmd("docker", "run") + image, err := crossBuildImage(b.Platform) + if err != nil { + return errors.Wrap(err, "failed to determine golang-crossbuild image tag") + } + verbose := "" + if mg.Verbose() { + verbose = "true" + } + var args []string + if runtime.GOOS != "windows" { + args = append(args, + "--env", "EXEC_UID="+strconv.Itoa(os.Getuid()), + "--env", "EXEC_GID="+strconv.Itoa(os.Getgid()), + ) + } + args = append(args, + "--rm", + "--env", "MAGEFILE_VERBOSE="+verbose, + "--env", "MAGEFILE_TIMEOUT="+EnvOr("MAGEFILE_TIMEOUT", ""), + "-v", repoInfo.RootDir+":"+mountPoint, + "-w", workDir, + image, + "--build-cmd", "build/mage-linux-amd64 "+b.Target, + "-p", b.Platform, + ) + + return dockerRun(args...) +} + +// DockerChown chowns files generated during build. EXEC_UID and EXEC_GID must +// be set in the containers environment otherwise this is a noop. +func DockerChown(file string) { + // Chown files generated during build that are root owned. + uid, _ := strconv.Atoi(EnvOr("EXEC_UID", "-1")) + gid, _ := strconv.Atoi(EnvOr("EXEC_GID", "-1")) + if uid > 0 && gid > 0 { + if err := chownPaths(uid, gid, file); err != nil { + log.Println(err) + } + } +} + +// chownPaths will chown the file and all of the dirs specified in the path. +func chownPaths(uid, gid int, file string) error { + pathParts := strings.Split(file, string(filepath.Separator)) + for i := range pathParts { + chownDir := filepath.Join(pathParts[:i+1]...) + if err := os.Chown(chownDir, uid, gid); err != nil { + return errors.Wrapf(err, "failed to chown path=%v", chownDir) + } + } + return nil +} diff --git a/_beats/dev-tools/mage/files/linux/systemd-daemon-reload.sh b/_beats/dev-tools/mage/files/linux/systemd-daemon-reload.sh new file mode 100644 index 0000000000..65589fb789 --- /dev/null +++ b/_beats/dev-tools/mage/files/linux/systemd-daemon-reload.sh @@ -0,0 +1,4 @@ +#!/usr/bin/env bash + +systemctl daemon-reload 2> /dev/null +exit 0 diff --git a/_beats/dev-tools/mage/files/packages.yml b/_beats/dev-tools/mage/files/packages.yml new file mode 100644 index 0000000000..d57c3c9827 --- /dev/null +++ b/_beats/dev-tools/mage/files/packages.yml @@ -0,0 +1,222 @@ +--- + +# This file contains the package specifications for both Community Beats and +# Official Beats. The shared section contains YAML anchors that are used to +# define common parts of the package in order to not repeat ourselves. + +shared: +- &common + name: '{{.BeatName}}' + service_name: '{{.BeatServiceName}}' + os: '{{.GOOS}}' + arch: '{{.PackageArch}}' + vendor: '{{.BeatVendor}}' + version: '{{ beat_version }}' + license: '{{.BeatLicense}}' + url: '{{.BeatURL}}' + description: '{{.BeatDescription}}' + +- &deb_rpm_spec + <<: *common + post_install_script: '{{ elastic_beats_dir }}/dev-tools/mage/files/linux/systemd-daemon-reload.sh' + files: + /usr/share/{{.BeatName}}/bin/{{.BeatName}}{{.BinaryExt}}: + source: build/golang-crossbuild/{{.BeatName}}-{{.GOOS}}-{{.Platform.Arch}}{{.BinaryExt}} + mode: 0755 + /etc/{{.BeatName}}/fields.yml: + source: fields.yml + mode: 0644 + /usr/share/{{.BeatName}}/LICENSE.txt: + source: '{{ repo.RootDir }}/LICENSE.txt' + mode: 0644 + /usr/share/{{.BeatName}}/NOTICE.txt: + source: '{{ repo.RootDir }}/NOTICE.txt' + mode: 0644 + /usr/share/{{.BeatName}}/README.md: + template: '{{ elastic_beats_dir }}/dev-tools/mage/templates/common/README.md.tmpl' + mode: 0644 + /usr/share/{{.BeatName}}/.build_hash.txt: + content: > + {{ commit }} + mode: 0644 + /etc/{{.BeatName}}/{{.BeatName}}.reference.yml: + source: '{{.BeatName}}.reference.yml' + mode: 0644 + /etc/{{.BeatName}}/{{.BeatName}}.yml: + source: '{{.BeatName}}.yml' + mode: 0600 + config: true + /usr/share/{{.BeatName}}/kibana: + source: _meta/kibana.generated + mode: 0644 + /usr/share/{{.BeatName}}/bin/{{.BeatName}}-god: + source: build/golang-crossbuild/god-{{.GOOS}}-{{.Platform.Arch}} + mode: 0755 + /usr/bin/{{.BeatName}}: + template: '{{ elastic_beats_dir }}/dev-tools/mage/templates/linux/beatname.sh.tmpl' + mode: 0755 + /lib/systemd/system/{{.BeatServiceName}}.service: + template: '{{ elastic_beats_dir }}/dev-tools/mage/templates/linux/systemd.unit.tmpl' + mode: 0755 + /etc/init.d/{{.BeatServiceName}}: + template: '{{ elastic_beats_dir }}/dev-tools/mage/templates/{{.PackageType}}/init.sh.tmpl' + mode: 0755 + +- &binary_files + '{{.BeatName}}{{.BinaryExt}}': + source: build/golang-crossbuild/{{.BeatName}}-{{.GOOS}}-{{.Platform.Arch}}{{.BinaryExt}} + mode: 0755 + fields.yml: + source: fields.yml + mode: 0644 + LICENSE.txt: + source: '{{ repo.RootDir }}/LICENSE.txt' + mode: 0644 + NOTICE.txt: + source: '{{ repo.RootDir }}/NOTICE.txt' + mode: 0644 + README.md: + template: '{{ elastic_beats_dir }}/dev-tools/mage/templates/common/README.md.tmpl' + mode: 0644 + .build_hash.txt: + content: > + {{ commit }} + mode: 0644 + '{{.BeatName}}.reference.yml': + source: '{{.BeatName}}.reference.yml' + mode: 0644 + '{{.BeatName}}.yml': + source: '{{.BeatName}}.yml' + mode: 0600 + config: true + kibana: + source: _meta/kibana.generated + mode: 0644 + +- &binary_spec + <<: *common + files: + <<: *binary_files + +- &windows_binary_spec + <<: *common + files: + <<: *binary_files + install-service-{{.BeatName}}.ps1: + template: '{{ elastic_beats_dir }}/dev-tools/mage/templates/windows/install-service.ps1.tmpl' + mode: 0755 + uninstall-service-{{.BeatName}}.ps1: + template: '{{ elastic_beats_dir }}/dev-tools/mage/templates/windows/uninstall-service.ps1.tmpl' + mode: 0755 + +- &elastic_license_for_binaries + license: "Elastic License" + files: + LICENSE.txt: + source: '{{ repo.RootDir }}/licenses/ELASTIC-LICENSE.txt' + mode: 0644 + +- &elastic_license_for_deb_rpm + license: "Elastic License" + files: + /usr/share/{{.BeatName}}/LICENSE.txt: + source: '{{ repo.RootDir }}/licenses/ELASTIC-LICENSE.txt' + mode: 0644 + +- &apache_license_for_binaries + license: "ASL 2.0" + files: + LICENSE.txt: + source: '{{ repo.RootDir }}/licenses/APACHE-LICENSE-2.0.txt' + mode: 0644 + +- &apache_license_for_deb_rpm + license: "Elastic License" + files: + /usr/share/{{.BeatName}}/LICENSE.txt: + source: '{{ repo.RootDir }}/licenses/APACHE-LICENSE-2.0.txt' + mode: 0644 + +# specs is a list of named packaging "flavors". +specs: + # Community Beats + community_beat: + - os: windows + types: [zip] + spec: + <<: *windows_binary_spec + + - os: darwin + types: [tgz] + spec: + <<: *binary_spec + + - os: linux + types: [tgz] + spec: + <<: *binary_spec + + - os: linux + types: [deb, rpm] + spec: + <<: *deb_rpm_spec + + # Official Beats + elastic_beat: + ### + # OSS Packages + ### + - os: windows + types: [zip] + spec: + <<: *windows_binary_spec + <<: *apache_license_for_binaries + name: '{{.BeatName}}-oss' + + - os: darwin + types: [tgz] + spec: + <<: *binary_spec + <<: *apache_license_for_binaries + name: '{{.BeatName}}-oss' + + - os: linux + types: [tgz] + spec: + <<: *binary_spec + <<: *apache_license_for_binaries + name: '{{.BeatName}}-oss' + + - os: linux + types: [deb, rpm] + spec: + <<: *deb_rpm_spec + <<: *apache_license_for_deb_rpm + name: '{{.BeatName}}-oss' + + ### + # Elastic Licensed Packages + ### + - os: windows + types: [zip] + spec: + <<: *windows_binary_spec + <<: *elastic_license_for_binaries + + - os: darwin + types: [tgz] + spec: + <<: *binary_spec + <<: *elastic_license_for_binaries + + - os: linux + types: [tgz] + spec: + <<: *binary_spec + <<: *elastic_license_for_binaries + + - os: linux + types: [deb, rpm] + spec: + <<: *deb_rpm_spec + <<: *elastic_license_for_deb_rpm diff --git a/_beats/dev-tools/mage/godaemon.go b/_beats/dev-tools/mage/godaemon.go new file mode 100644 index 0000000000..0f4cb2c0ec --- /dev/null +++ b/_beats/dev-tools/mage/godaemon.go @@ -0,0 +1,72 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package mage + +import ( + "errors" + "log" + "os" +) + +// BuildGoDaemon builds the go-deamon binary. +func BuildGoDaemon() error { + if GOOS != "linux" { + return errors.New("go-daemon only builds for linux") + } + + if os.Getenv("GOLANG_CROSSBUILD") != "1" { + return errors.New("Use the crossBuildGoDaemon target. buildGoDaemon can " + + "only be executed within the golang-crossbuild docker environment.") + } + + // Test if binaries are up-to-date. + output := MustExpand("build/golang-crossbuild/god-{{.Platform.GOOS}}-{{.Platform.Arch}}") + input := MustExpand("{{ elastic_beats_dir }}/dev-tools/vendor/github.com/tsg/go-daemon/god.c") + if IsUpToDate(output, input) { + log.Println(">>> buildGoDaemon is up-to-date for", Platform.Name) + return nil + } + + // Determine what compiler to use based on CC that is set by golang-crossbuild. + cc := os.Getenv("CC") + if cc == "" { + cc = "cc" + } + + compileCmd := []string{ + cc, + input, + "-o", createDir(output), + "-lpthread", "-static", + } + switch Platform.Name { + case "linux/amd64": + compileCmd = append(compileCmd, "-m64") + case "linux/386": + compileCmd = append(compileCmd, "-m32") + } + + defer DockerChown(output) + return RunCmds(compileCmd) +} + +// CrossBuildGoDaemon cross-build the go-daemon binary using the +// golang-crossbuild environment. +func CrossBuildGoDaemon() error { + return CrossBuild(ForPlatforms("linux"), WithTarget("buildGoDaemon")) +} diff --git a/_beats/dev-tools/mage/pkg.go b/_beats/dev-tools/mage/pkg.go new file mode 100644 index 0000000000..688e5c2211 --- /dev/null +++ b/_beats/dev-tools/mage/pkg.go @@ -0,0 +1,108 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package mage + +import ( + "fmt" + "log" + + "github.com/magefile/mage/mg" + "github.com/magefile/mage/sh" + "github.com/pkg/errors" +) + +// Package packages the Beat for distribution. It generates packages based on +// the set of target plaforms and registered packaging specifications. +func Package() error { + if len(Platforms) == 0 { + return errors.New("PLATFORMS environment must be set to a list of " + + "GOOS/Arch values, but Platforms is empty") + } + + if len(Packages) == 0 { + return errors.New("no package specs are registered. Call " + + "UseCommunityBeatPackaging or UseElasticBeatPackaging first.") + } + + var tasks []interface{} + for _, target := range Platforms { + for _, pkg := range Packages { + if pkg.OS != target.GOOS() { + continue + } + + for _, pkgType := range pkg.Types { + packageArch, err := getOSArchName(target, pkgType) + if err != nil { + log.Printf("Skipping arch %v for package type %v: %v", target.Arch(), pkgType, err) + continue + } + + spec := pkg.Spec.Clone() + spec.OS = target.GOOS() + spec.Arch = packageArch + spec.Snapshot = Snapshot + spec.evalContext = map[string]interface{}{ + "GOOS": target.GOOS(), + "GOARCH": target.GOARCH(), + "GOARM": target.GOARM(), + "Platform": target, + "PackageType": pkgType.String(), + "BinaryExt": binaryExtension(target.GOOS()), + } + spec.packageDir = packageStagingDir + "/" + pkgType.AddFileExtension(spec.Name+"-"+target.GOOS()+"-"+target.Arch()) + spec = spec.Evaluate() + + tasks = append(tasks, packageBuilder{target, spec, pkgType}.Build) + } + } + } + + Parallel(tasks...) + return nil +} + +type packageBuilder struct { + Platform BuildPlatform + Spec PackageSpec + Type PackageType +} + +func (b packageBuilder) Build() error { + fmt.Printf(">> package: Building %v type=%v for platform=%v\n", b.Spec.Name, b.Type, b.Platform.Name) + log.Printf("Package spec: %+v", b.Spec) + return errors.Wrapf(b.Type.Build(b.Spec), "failed building %v type=%v for platform=%v", + b.Spec.Name, b.Type, b.Platform.Name) +} + +// TestPackages executes the package tests on the produced binaries. These tests +// inspect things like file ownership and mode. +func TestPackages() error { + fmt.Println(">> Testing package contents") + var args []string + if mg.Verbose() { + args = append(args, "-v") + } + args = append(args, + MustExpand("{{ elastic_beats_dir }}/dev-tools/package_test.go"), + "-files", + MustExpand("{{.PWD}}/build/distributions/*"), + ) + goTest := sh.RunCmd("go", "test") + return goTest(args...) +} diff --git a/_beats/dev-tools/mage/pkg_test.go b/_beats/dev-tools/mage/pkg_test.go new file mode 100644 index 0000000000..f9bd3a708e --- /dev/null +++ b/_beats/dev-tools/mage/pkg_test.go @@ -0,0 +1,120 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package mage + +import ( + "path/filepath" + "strings" + "testing" + + "github.com/stretchr/testify/assert" + "gopkg.in/yaml.v2" +) + +func testPackageSpec() PackageSpec { + return PackageSpec{ + Name: "brewbeat", + Version: "7.0.0", + Snapshot: true, + OS: "windows", + Arch: "x86_64", + Files: map[string]PackageFile{ + "brewbeat.yml": PackageFile{ + Source: "./testdata/config.yml", + Mode: 0644, + }, + "README.txt": PackageFile{ + Content: "Hello! {{.Version}}\n", + Mode: 0644, + }, + }, + } +} + +func TestPackageZip(t *testing.T) { + testPackage(t, PackageZip) +} + +func TestPackageTarGz(t *testing.T) { + testPackage(t, PackageTarGz) +} + +func TestPackageRPM(t *testing.T) { + if err := HaveDocker(); err != nil { + t.Skip("docker is required") + } + + testPackage(t, PackageRPM) +} + +func TestPackageDeb(t *testing.T) { + if err := HaveDocker(); err != nil { + t.Skip("docker is required") + } + + testPackage(t, PackageDeb) +} + +func testPackage(t testing.TB, pack func(PackageSpec) error) { + spec := testPackageSpec().Evaluate() + + readme := spec.Files["README.txt"] + readmePath := filepath.ToSlash(filepath.Clean(readme.Source)) + assert.True(t, strings.HasPrefix(readmePath, packageStagingDir)) + + if err := pack(spec); err != nil { + t.Fatal(err) + } +} + +func TestRepoRoot(t *testing.T) { + repo, err := GetProjectRepoInfo() + if err != nil { + t.Error(err) + } + + assert.Equal(t, "github.com/elastic/beats", repo.RootImportPath) + assert.True(t, filepath.IsAbs(repo.RootDir)) + cwd := filepath.Join(repo.RootDir, repo.SubDir) + assert.Equal(t, CWD(), cwd) +} + +func TestDumpVariables(t *testing.T) { + out, err := dumpVariables() + if err != nil { + t.Fatal(err) + } + t.Log(out) +} + +func TestLoadSpecs(t *testing.T) { + pkgs, err := LoadSpecs("files/packages.yml") + if err != nil { + t.Fatal(err) + } + + for flavor, s := range pkgs { + out, err := yaml.Marshal(s) + if err != nil { + t.Fatal(err) + } + if testing.Verbose() { + t.Log("Packaging flavor:", flavor, "\n", string(out)) + } + } +} diff --git a/_beats/dev-tools/mage/pkgspecs.go b/_beats/dev-tools/mage/pkgspecs.go new file mode 100644 index 0000000000..ee6c38a025 --- /dev/null +++ b/_beats/dev-tools/mage/pkgspecs.go @@ -0,0 +1,100 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package mage + +import ( + "io/ioutil" + "log" + "path/filepath" + + "github.com/pkg/errors" + "gopkg.in/yaml.v2" +) + +const packageSpecFile = "dev-tools/mage/files/packages.yml" + +// Packages defines the set of packages to be built when the package target is +// executed. +var Packages []OSPackageArgs + +// UseCommunityBeatPackaging configures the package target to build packages for +// a community Beat. +func UseCommunityBeatPackaging() { + beatsDir, err := ElasticBeatsDir() + if err != nil { + panic(err) + } + + err = LoadNamedSpec("community_beat", filepath.Join(beatsDir, packageSpecFile)) + if err != nil { + panic(err) + } +} + +// UseElasticBeatPackaging configures the package target to build packages for +// an Elastic Beat. This means it will generate two sets of packages -- one +// that is purely OSS under Apache 2.0 and one that is licensed under the +// Elastic License and may contain additional X-Pack features. +func UseElasticBeatPackaging() { + beatsDir, err := ElasticBeatsDir() + if err != nil { + panic(err) + } + + err = LoadNamedSpec("elastic_beat", filepath.Join(beatsDir, packageSpecFile)) + if err != nil { + panic(err) + } +} + +// LoadNamedSpec loads a packaging specification with the given name from the +// specified YAML file. name should be a sub-key of 'specs'. +func LoadNamedSpec(name, file string) error { + specs, err := LoadSpecs(file) + if err != nil { + return errors.Wrap(err, "failed to load spec file") + } + + packages, found := specs[name] + if !found { + return errors.Errorf("%v not found in package specs", name) + } + + log.Printf("%v package spec loaded from %v", name, file) + Packages = packages + return nil +} + +// LoadSpecs loads the packaging specifications from the specified YAML file. +func LoadSpecs(file string) (map[string][]OSPackageArgs, error) { + data, err := ioutil.ReadFile(file) + if err != nil { + return nil, errors.Wrap(err, "failed to read from spec file") + } + + type PackageYAML struct { + Specs map[string][]OSPackageArgs `yaml:"specs"` + } + + var packages PackageYAML + if err = yaml.Unmarshal(data, &packages); err != nil { + return nil, errors.Wrap(err, "failed to unmarshal spec data") + } + + return packages.Specs, nil +} diff --git a/_beats/dev-tools/mage/pkgtypes.go b/_beats/dev-tools/mage/pkgtypes.go new file mode 100644 index 0000000000..4cf1533153 --- /dev/null +++ b/_beats/dev-tools/mage/pkgtypes.go @@ -0,0 +1,764 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package mage + +import ( + "archive/tar" + "archive/zip" + "bytes" + "compress/gzip" + "fmt" + "io" + "io/ioutil" + "log" + "os" + "path/filepath" + "reflect" + "runtime" + "strconv" + "strings" + + "github.com/magefile/mage/mg" + "github.com/magefile/mage/sh" + "github.com/mitchellh/hashstructure" + "github.com/pkg/errors" +) + +const ( + // distributionsDir is the dir where packages are written. + distributionsDir = "build/distributions" + + // packageStagingDir is the staging directory for any temporary files that + // need to be written to disk for inclusion in a package. + packageStagingDir = "build/package" + + // defaultBinaryName specifies the output file for zip and tar.gz. + defaultBinaryName = "{{.Name}}-{{.Version}}{{if .Snapshot}}-SNAPSHOT{{end}}{{if .OS}}-{{.OS}}{{end}}{{if .Arch}}-{{.Arch}}{{end}}" +) + +// PackageType defines the file format of the package (e.g. zip, rpm, etc). +type PackageType int + +// List of possible package types. +const ( + RPM PackageType = iota + 1 + Deb + Zip + TarGz +) + +// OSPackageArgs define a set of package types to build for an operating +// system using the contained PackageSpec. +type OSPackageArgs struct { + OS string `yaml:"os"` + Types []PackageType `yaml:"types"` + Spec PackageSpec `yaml:"spec"` +} + +// PackageSpec specifies package metadata and the contents of the package. +type PackageSpec struct { + Name string `yaml:"name,omitempty"` + ServiceName string `yaml:"service_name,omitempty"` + OS string `yaml:"os,omitempty"` + Arch string `yaml:"arch,omitempty"` + Vendor string `yaml:"vendor,omitempty"` + Snapshot bool `yaml:"snapshot"` + Version string `yaml:"version,omitempty"` + License string `yaml:"license,omitempty"` + URL string `yaml:"url,omitempty"` + Description string `yaml:"description,omitempty"` + PostInstallScript string `yaml:"post_install_script,omitempty"` + Files map[string]PackageFile `yaml:"files"` + OutputFile string `yaml:"output_file,omitempty"` // Optional + + evalContext map[string]interface{} + packageDir string + localPostInstallScript string +} + +// PackageFile represents a file or directory within a package. +type PackageFile struct { + Source string `yaml:"source,omitempty"` // Regular source file or directory. + Content string `yaml:"content,omitempty"` // Inline template string. + Template string `yaml:"template,omitempty"` // Input template file. + Target string `yaml:"target,omitempty"` // Target location in package. Relative paths are added to a package specific directory (e.g. metricbeat-7.0.0-linux-x86_64). + Mode os.FileMode `yaml:"mode,omitempty"` // Target mode for file. Does not apply when source is a directory. + Config bool `yaml:"config"` // Mark file as config in the package (deb and rpm only). + Dep func(PackageSpec) error `yaml:"-" hash:"-" json:"-"` // Dependency to invoke during Evaluate. +} + +// OSArchNames defines the names of architectures for use in packages. +var OSArchNames = map[string]map[PackageType]map[string]string{ + "windows": map[PackageType]map[string]string{ + Zip: map[string]string{ + "386": "x86", + "amd64": "x86_64", + }, + }, + "darwin": map[PackageType]map[string]string{ + TarGz: map[string]string{ + "386": "x86", + "amd64": "x86_64", + }, + }, + "linux": map[PackageType]map[string]string{ + RPM: map[string]string{ + "386": "i686", + "amd64": "x86_64", + "armv7": "armhfp", + "arm64": "aarch64", + "mipsle": "mipsel", + "mips64le": "mips64el", + "ppc64": "ppc64", + "ppc64le": "ppc64le", + "s390x": "s390x", + }, + // https://www.debian.org/ports/ + Deb: map[string]string{ + "386": "i386", + "amd64": "amd64", + "armv5": "armel", + "armv6": "armel", + "armv7": "armhf", + "arm64": "arm64", + "mips": "mips", + "mipsle": "mipsel", + "mips64le": "mips64el", + "ppc64le": "ppc64el", + "s390x": "s390x", + }, + TarGz: map[string]string{ + "386": "x86", + "amd64": "x86_64", + "armv5": "armv5", + "armv6": "armv6", + "armv7": "armv7", + "arm64": "arm64", + "mips": "mips", + "mipsle": "mipsel", + "mips64": "mips64", + "mips64le": "mips64el", + "ppc64": "ppc64", + "ppc64le": "ppc64le", + "s390x": "s390x", + }, + }, +} + +// getOSArchName returns the architecture name to use in a package. +func getOSArchName(platform BuildPlatform, t PackageType) (string, error) { + names, found := OSArchNames[platform.GOOS()] + if !found { + return "", errors.Errorf("arch names for os=%v are not defined", + platform.GOOS()) + } + + archMap, found := names[t] + if !found { + return "", errors.Errorf("arch names for %v on os=%v are not defined", + t, platform.GOOS()) + } + + arch, found := archMap[platform.Arch()] + if !found { + return "", errors.Errorf("arch name associated with %v for %v on "+ + "os=%v is not defined", platform.Arch(), t, platform.GOOS()) + } + + return arch, nil +} + +// String returns the name of the package type. +func (typ PackageType) String() string { + switch typ { + case RPM: + return "rpm" + case Deb: + return "deb" + case Zip: + return "zip" + case TarGz: + return "tar.gz" + default: + return "invalid" + } +} + +// MarshalText returns the text representation of PackageType. +func (typ PackageType) MarshalText() ([]byte, error) { + return []byte(typ.String()), nil +} + +// UnmarshalText returns a PackageType based on the given text. +func (typ *PackageType) UnmarshalText(text []byte) error { + switch strings.ToLower(string(text)) { + case "rpm": + *typ = RPM + case "deb": + *typ = Deb + case "tar.gz", "tgz", "targz": + *typ = TarGz + case "zip": + *typ = Zip + default: + return errors.Errorf("unknown package type: %v", string(text)) + } + return nil +} + +// AddFileExtension returns a filename with the file extension added. If the +// filename already has the extension then it becomes a pass-through. +func (typ PackageType) AddFileExtension(file string) string { + ext := "." + strings.ToLower(typ.String()) + if !strings.HasSuffix(file, ext) { + return file + ext + } + return file +} + +// Build builds a package based on the provided spec. +func (typ PackageType) Build(spec PackageSpec) error { + switch typ { + case RPM: + return PackageRPM(spec) + case Deb: + return PackageDeb(spec) + case Zip: + return PackageZip(spec) + case TarGz: + return PackageTarGz(spec) + default: + return errors.Errorf("unknown package type: %v", typ) + } +} + +// Clone returns a deep clone of the spec. +func (s PackageSpec) Clone() PackageSpec { + clone := s + clone.Files = make(map[string]PackageFile, len(s.Files)) + for k, v := range s.Files { + clone.Files[k] = v + } + return clone +} + +// ReplaceFile replaces an existing file defined in the spec. The target must +// exist other it will panic. +func (s PackageSpec) ReplaceFile(target string, file PackageFile) { + _, found := s.Files[target] + if !found { + panic(errors.Errorf("failed to ReplaceFile because target=%v does not exist", target)) + } + + s.Files[target] = file +} + +// Expand expands a templated string using data from the spec. +func (s PackageSpec) Expand(in string, args ...map[string]interface{}) (string, error) { + return expandTemplate("inline", in, FuncMap, + EnvMap(append([]map[string]interface{}{s.evalContext, s.toMap()}, args...)...)) +} + +// MustExpand expands a templated string using data from the spec. It panics if +// an error occurs. +func (s PackageSpec) MustExpand(in string, args ...map[string]interface{}) string { + v, err := s.Expand(in, args...) + if err != nil { + panic(err) + } + return v +} + +// ExpandFile expands a template file using data from the spec. +func (s PackageSpec) ExpandFile(src, dst string, args ...map[string]interface{}) error { + return expandFile(src, dst, + EnvMap(append([]map[string]interface{}{s.evalContext, s.toMap()}, args...)...)) +} + +// MustExpandFile expands a template file using data from the spec. It panics if +// an error occurs. +func (s PackageSpec) MustExpandFile(src, dst string, args ...map[string]interface{}) error { + return s.ExpandFile(src, dst, args...) +} + +// Evaluate expands all variables used in the spec definition and writes any +// templated files used in the spec to disk. It panics if there is an error. +func (s PackageSpec) Evaluate(args ...map[string]interface{}) PackageSpec { + args = append([]map[string]interface{}{s.toMap(), s.evalContext}, args...) + mustExpand := func(in string) string { + if in == "" { + return "" + } + return MustExpand(in, args...) + } + + s.Name = mustExpand(s.Name) + s.ServiceName = mustExpand(s.ServiceName) + s.OS = mustExpand(s.OS) + s.Arch = mustExpand(s.Arch) + s.Vendor = mustExpand(s.Vendor) + s.Version = mustExpand(s.Version) + s.License = mustExpand(s.License) + s.URL = mustExpand(s.URL) + s.Description = mustExpand(s.Description) + s.PostInstallScript = mustExpand(s.PostInstallScript) + s.OutputFile = mustExpand(s.OutputFile) + + if s.ServiceName == "" { + s.ServiceName = s.Name + } + + if s.packageDir == "" { + outputFileName := filepath.Base(s.OutputFile) + + if outputFileName != "." { + s.packageDir = filepath.Join(packageStagingDir, outputFileName) + } else { + s.packageDir = filepath.Join(packageStagingDir, strings.Join([]string{s.Name, s.OS, s.Arch, s.hash()}, "-")) + } + } else { + s.packageDir = filepath.Clean(mustExpand(s.packageDir)) + } + if s.evalContext == nil { + s.evalContext = map[string]interface{}{} + } + s.evalContext["PackageDir"] = s.packageDir + + evaluatedFiles := make(map[string]PackageFile, len(s.Files)) + for target, f := range s.Files { + // Execute the dependency if it exists. + if f.Dep != nil { + if err := f.Dep(s); err != nil { + panic(errors.Wrapf(err, "failed executing package file dependency for target=%v", target)) + } + } + + f.Source = s.MustExpand(f.Source) + f.Template = s.MustExpand(f.Template) + f.Target = s.MustExpand(target) + target = f.Target + + // Expand templates. + switch { + case f.Source != "": + case f.Content != "": + content, err := s.Expand(f.Content) + if err != nil { + panic(errors.Wrapf(err, "failed to expand content template for target=%v", target)) + } + + f.Source = filepath.Join(s.packageDir, filepath.Base(f.Target)) + if err = ioutil.WriteFile(createDir(f.Source), []byte(content), 0644); err != nil { + panic(errors.Wrapf(err, "failed to write file containing content for target=%v", target)) + } + case f.Template != "": + f.Source = filepath.Join(s.packageDir, filepath.Base(f.Template)) + if err := s.ExpandFile(createDir(f.Template), f.Source); err != nil { + panic(errors.Wrapf(err, "failed to expand template file for target=%v", target)) + } + default: + panic(errors.Errorf("package file with target=%v must have either source, content, or template", target)) + } + + evaluatedFiles[f.Target] = f + } + // Replace the map instead of modifying the source. + s.Files = evaluatedFiles + + if s.PostInstallScript != "" { + // Copy the inside the build dir so that it's available inside of Docker for FPM. + s.localPostInstallScript = filepath.Join(s.packageDir, filepath.Base(s.PostInstallScript)) + if err := Copy(s.PostInstallScript, s.localPostInstallScript); err != nil { + panic(errors.Wrap(err, "failed to copy post install script to build dir")) + } + } + + return s +} + +func (s PackageSpec) hash() string { + h, err := hashstructure.Hash(s, nil) + if err != nil { + panic(errors.Wrap(err, "failed to compute hash of spec")) + } + + hash := strconv.FormatUint(h, 10) + if len(hash) > 10 { + hash = hash[0:10] + } + return hash +} + +// toMap returns a map containing the exported field names and their values. +func (s PackageSpec) toMap() map[string]interface{} { + out := make(map[string]interface{}) + v := reflect.ValueOf(s) + typ := v.Type() + + for i := 0; i < v.NumField(); i++ { + structField := typ.Field(i) + if !structField.Anonymous && structField.PkgPath == "" { + out[structField.Name] = v.Field(i).Interface() + } + } + + return out +} + +// rootDir returns the name of the root directory contained inside of zip and +// tar.gz packages. +func (s PackageSpec) rootDir() string { + if s.OutputFile != "" { + return filepath.Base(s.OutputFile) + } + + // NOTE: This uses .BeatName instead of .Name because we wanted the internal + // directory to not include "-oss". + return s.MustExpand("{{.BeatName}}-{{.Version}}{{if .Snapshot}}-SNAPSHOT{{end}}{{if .OS}}-{{.OS}}{{end}}{{if .Arch}}-{{.Arch}}{{end}}") +} + +// PackageZip packages a zip file. +func PackageZip(spec PackageSpec) error { + // Create a buffer to write our archive to. + buf := new(bytes.Buffer) + + // Create a new zip archive. + w := zip.NewWriter(buf) + baseDir := spec.rootDir() + + // Add files to zip. + for _, pkgFile := range spec.Files { + if err := addFileToZip(w, baseDir, pkgFile); err != nil { + return errors.Wrapf(err, "failed adding file=%+v to zip", pkgFile) + } + } + + if err := w.Close(); err != nil { + return err + } + + // Output the zip file. + if spec.OutputFile == "" { + outputZip, err := spec.Expand(defaultBinaryName + ".zip") + if err != nil { + return err + } + spec.OutputFile = filepath.Join(distributionsDir, outputZip) + } + spec.OutputFile = Zip.AddFileExtension(spec.OutputFile) + + // Write the zip file. + if err := ioutil.WriteFile(createDir(spec.OutputFile), buf.Bytes(), 0644); err != nil { + return errors.Wrap(err, "failed to write zip file") + } + + // Any packages beginning with "tmp-" are temporary by nature so don't have + // them a .sha512 file. + if strings.HasPrefix(filepath.Base(spec.OutputFile), "tmp-") { + return nil + } + + return errors.Wrap(CreateSHA512File(spec.OutputFile), "failed to create .sha512 file") +} + +// PackageTarGz packages a gzipped tar file. +func PackageTarGz(spec PackageSpec) error { + // Create a buffer to write our archive to. + buf := new(bytes.Buffer) + + // Create a new tar archive. + w := tar.NewWriter(buf) + baseDir := spec.rootDir() + + // Add files to tar. + for _, pkgFile := range spec.Files { + if err := addFileToTar(w, baseDir, pkgFile); err != nil { + return errors.Wrapf(err, "failed adding file=%+v to tar", pkgFile) + } + } + + if err := w.Close(); err != nil { + return err + } + + // Output tar.gz to disk. + if spec.OutputFile == "" { + outputTarGz, err := spec.Expand(defaultBinaryName + ".tar.gz") + if err != nil { + return err + } + spec.OutputFile = filepath.Join(distributionsDir, outputTarGz) + } + spec.OutputFile = TarGz.AddFileExtension(spec.OutputFile) + + // Open the output file. + log.Println("Creating output file at", spec.OutputFile) + outFile, err := os.Create(createDir(spec.OutputFile)) + if err != nil { + return err + } + defer outFile.Close() + + // Gzip compress the data. + gzWriter := gzip.NewWriter(outFile) + if _, err = gzWriter.Write(buf.Bytes()); err != nil { + return err + } + + // Close and flush. + if err = gzWriter.Close(); err != nil { + return err + } + + // Any packages beginning with "tmp-" are temporary by nature so don't have + // them a .sha512 file. + if strings.HasPrefix(filepath.Base(spec.OutputFile), "tmp-") { + return nil + } + + return errors.Wrap(CreateSHA512File(spec.OutputFile), "failed to create .sha512 file") +} + +// PackageDeb packages a deb file. This requires Docker to execute FPM. +func PackageDeb(spec PackageSpec) error { + return runFPM(spec, Deb) +} + +// PackageRPM packages a RPM file. This requires Docker to execute FPM. +func PackageRPM(spec PackageSpec) error { + return runFPM(spec, RPM) +} + +func runFPM(spec PackageSpec, packageType PackageType) error { + var fpmPackageType string + switch packageType { + case RPM, Deb: + fpmPackageType = packageType.String() + default: + return errors.Errorf("unsupported package type=%v for runFPM", fpmPackageType) + } + + if err := HaveDocker(); err != nil { + return fmt.Errorf("packaging %v files requires docker: %v", fpmPackageType, err) + } + + // Build a tar file as the input to FPM. + inputTar := filepath.Join(distributionsDir, "tmp-"+fpmPackageType+"-"+spec.rootDir()+"-"+spec.hash()+".tar.gz") + spec.OutputFile = inputTar + if err := PackageTarGz(spec); err != nil { + return err + } + defer os.Remove(inputTar) + + outputFile, err := spec.Expand("{{.Name}}-{{.Version}}{{if .Snapshot}}-SNAPSHOT{{end}}-{{.Arch}}") + if err != nil { + return err + } + spec.OutputFile = packageType.AddFileExtension(filepath.Join(distributionsDir, outputFile)) + + dockerRun := sh.RunCmd("docker", "run") + var args []string + + args, err = addUidGidEnvArgs(args) + if err != nil { + return err + } + + args = append(args, + "--rm", + "-w", "/app", + "-v", CWD()+":/app", + beatsFPMImage+":"+fpmVersion, + "fpm", "--force", + "--input-type", "tar", + "--output-type", fpmPackageType, + "--name", spec.ServiceName, + "--architecture", spec.Arch, + ) + if spec.Version != "" { + args = append(args, "--version", spec.Version) + } + if spec.Vendor != "" { + args = append(args, "--vendor", spec.Vendor) + } + if spec.License != "" { + args = append(args, "--license", strings.Replace(spec.License, " ", "-", -1)) + } + if spec.Description != "" { + args = append(args, "--description", spec.Description) + } + if spec.URL != "" { + args = append(args, "--url", spec.URL) + } + if spec.localPostInstallScript != "" { + args = append(args, "--after-install", spec.localPostInstallScript) + } + args = append(args, + "-p", spec.OutputFile, + inputTar, + ) + + if err = dockerRun(args...); err != nil { + return errors.Wrap(err, "failed while running FPM in docker") + } + + return errors.Wrap(CreateSHA512File(spec.OutputFile), "failed to create .sha512 file") +} + +func addUidGidEnvArgs(args []string) ([]string, error) { + if runtime.GOOS == "windows" { + return args, nil + } + + info, err := GetDockerInfo() + if err != nil { + return args, errors.Wrap(err, "failed to get docker info") + } + + uid, gid := os.Getuid(), os.Getgid() + if info.IsBoot2Docker() { + // Boot2Docker mounts vboxfs using 1000:50. + uid, gid = 1000, 50 + log.Printf("Boot2Docker is in use. Deploying workaround. "+ + "Using UID=%d GID=%d", uid, gid) + } + + return append(args, + "--env", "EXEC_UID="+strconv.Itoa(uid), + "--env", "EXEC_GID="+strconv.Itoa(gid), + ), nil +} + +// addFileToZip adds a file (or directory) to a zip archive. +func addFileToZip(ar *zip.Writer, baseDir string, pkgFile PackageFile) error { + return filepath.Walk(pkgFile.Source, func(path string, info os.FileInfo, err error) error { + if err != nil { + return err + } + + header, err := zip.FileInfoHeader(info) + if err != nil { + return err + } + + if info.Mode().IsRegular() && pkgFile.Mode > 0 { + header.SetMode(pkgFile.Mode & os.ModePerm) + } else if info.IsDir() { + header.SetMode(0755) + } + + if filepath.IsAbs(pkgFile.Target) { + baseDir = "" + } + + relPath, err := filepath.Rel(pkgFile.Source, path) + if err != nil { + return err + } + + header.Name = filepath.Join(baseDir, pkgFile.Target, relPath) + + if info.IsDir() { + header.Name += string(filepath.Separator) + } else { + header.Method = zip.Deflate + } + + if mg.Verbose() { + log.Println("Adding", header.Mode(), header.Name) + } + + w, err := ar.CreateHeader(header) + if err != nil { + return err + } + + if info.IsDir() { + return nil + } + + file, err := os.Open(path) + if err != nil { + return err + } + defer file.Close() + + if _, err = io.Copy(w, file); err != nil { + return err + } + return file.Close() + }) +} + +// addFileToTar adds a file (or directory) to a tar archive. +func addFileToTar(ar *tar.Writer, baseDir string, pkgFile PackageFile) error { + return filepath.Walk(pkgFile.Source, func(path string, info os.FileInfo, err error) error { + if err != nil { + return err + } + + header, err := tar.FileInfoHeader(info, info.Name()) + if err != nil { + return err + } + header.Uname, header.Gname = "root", "root" + header.Uid, header.Gid = 0, 0 + + if info.Mode().IsRegular() && pkgFile.Mode > 0 { + header.Mode = int64(pkgFile.Mode & os.ModePerm) + } else if info.IsDir() { + header.Mode = int64(0755) + } + + if filepath.IsAbs(pkgFile.Target) { + baseDir = "" + } + + relPath, err := filepath.Rel(pkgFile.Source, path) + if err != nil { + return err + } + + header.Name = filepath.Join(baseDir, pkgFile.Target, relPath) + if info.IsDir() { + header.Name += string(filepath.Separator) + } + + if mg.Verbose() { + log.Println("Adding", os.FileMode(header.Mode), header.Name) + } + if err := ar.WriteHeader(header); err != nil { + return err + } + + if info.IsDir() { + return nil + } + + file, err := os.Open(path) + if err != nil { + return err + } + defer file.Close() + + if _, err = io.Copy(ar, file); err != nil { + return err + } + return file.Close() + }) +} diff --git a/_beats/dev-tools/mage/platforms.go b/_beats/dev-tools/mage/platforms.go new file mode 100644 index 0000000000..c6039c55ab --- /dev/null +++ b/_beats/dev-tools/mage/platforms.go @@ -0,0 +1,464 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package mage + +import ( + "sort" + "strings" + + "github.com/pkg/errors" +) + +// BuildPlatforms is a list of GOOS/GOARCH pairs supported by Go. +// The list originated from 'go tool dist list -json'. +var BuildPlatforms = BuildPlatformList{ + {"android/386", CGOSupported}, + {"android/amd64", CGOSupported}, + {"android/arm", CGOSupported}, + {"android/arm64", CGOSupported}, + {"darwin/386", CGOSupported | CrossBuildSupported}, + {"darwin/amd64", CGOSupported | CrossBuildSupported | Default}, + {"darwin/arm", CGOSupported}, + {"darwin/arm64", CGOSupported}, + {"dragonfly/amd64", CGOSupported}, + {"freebsd/386", CGOSupported}, + {"freebsd/amd64", CGOSupported}, + {"freebsd/arm", 0}, + {"linux/386", CGOSupported | CrossBuildSupported | Default}, + {"linux/amd64", CGOSupported | CrossBuildSupported | Default}, + {"linux/armv5", CGOSupported | CrossBuildSupported}, + {"linux/armv6", CGOSupported | CrossBuildSupported}, + {"linux/armv7", CGOSupported | CrossBuildSupported}, + {"linux/arm64", CGOSupported | CrossBuildSupported}, + {"linux/mips", CGOSupported | CrossBuildSupported}, + {"linux/mips64", CGOSupported | CrossBuildSupported}, + {"linux/mips64le", CGOSupported | CrossBuildSupported}, + {"linux/mipsle", CGOSupported | CrossBuildSupported}, + {"linux/ppc64", CrossBuildSupported}, + {"linux/ppc64le", CGOSupported | CrossBuildSupported}, + {"linux/s390x", CGOSupported | CrossBuildSupported}, + {"nacl/386", 0}, + {"nacl/amd64p32", 0}, + {"nacl/arm", 0}, + {"netbsd/386", CGOSupported}, + {"netbsd/amd64", CGOSupported}, + {"netbsd/arm", CGOSupported}, + {"openbsd/386", CGOSupported}, + {"openbsd/amd64", CGOSupported}, + {"openbsd/arm", 0}, + {"plan9/386", 0}, + {"plan9/amd64", 0}, + {"plan9/arm", 0}, + {"solaris/amd64", CGOSupported}, + {"windows/386", CGOSupported | CrossBuildSupported | Default}, + {"windows/amd64", CGOSupported | CrossBuildSupported | Default}, +} + +// PlatformFeature specifies features that are supported for a platform. +type PlatformFeature uint8 + +// List of PlatformFeature types. +const ( + CGOSupported PlatformFeature = 1 << iota // CGO is supported. + CrossBuildSupported // Cross-build supported by golang-crossbuild. + Default // Built by default on crossBuild and package. +) + +var platformFlagNames = map[PlatformFeature]string{ + CGOSupported: "cgo", + CrossBuildSupported: "xbuild", + Default: "default", +} + +// String returns a string representation of the platform features. +func (f PlatformFeature) String() string { + if f == 0 { + return "none" + } + + var names []string + for value, name := range platformFlagNames { + if f&value > 0 { + names = append(names, name) + } + } + + return strings.Join(names, "|") +} + +// CanCrossBuild returns true if cross-building is supported by +// golang-crossbuild. +func (f PlatformFeature) CanCrossBuild() bool { + return f&CrossBuildSupported > 0 +} + +// SupportsCGO returns true if CGO is supported. +func (f PlatformFeature) SupportsCGO() bool { + return f&CGOSupported > 0 +} + +// BuildPlatform represents a target platform for builds. +type BuildPlatform struct { + Name string + Flags PlatformFeature +} + +// GOOS returns the GOOS value contained in the name. +func (p BuildPlatform) GOOS() string { + idx := strings.IndexByte(p.Name, '/') + if idx == -1 { + return p.Name + } + return p.Name[:idx] +} + +// Arch returns the architecture value contained in the name. +func (p BuildPlatform) Arch() string { + idx := strings.IndexByte(p.Name, '/') + if idx == -1 { + return "" + } + return p.Name[strings.IndexByte(p.Name, '/')+1:] +} + +// GOARCH returns the GOARCH value associated with the architecture contained +// in the name. For ARM the Arch and GOARCH can differ because the GOARM value +// is encoded in the Arch value. +func (p BuildPlatform) GOARCH() string { + // Allow armv7 to be interpreted as GOARCH=arm GOARM=7. + arch := p.Arch() + if strings.HasPrefix(arch, "armv") { + return "arm" + } + return arch +} + +// GOARM returns the ARM version. +func (p BuildPlatform) GOARM() string { + arch := p.Arch() + if strings.HasPrefix(arch, "armv") { + return strings.TrimPrefix(arch, "armv") + } + return "" +} + +// Attributes returns a new PlatformAttributes. +func (p BuildPlatform) Attributes() PlatformAttributes { + return MakePlatformAttributes(p.GOOS(), p.GOARCH(), p.GOARM()) +} + +// PlatformAttributes contains all of the data that can be extracted from a +// BuildPlatform name. +type PlatformAttributes struct { + Name string + GOOS string + GOARCH string + GOARM string + Arch string +} + +// MakePlatformAttributes returns a new PlatformAttributes. +func MakePlatformAttributes(goos, goarch, goarm string) PlatformAttributes { + arch := goarch + if goarch == "arm" && goarm != "" { + arch += "v" + goarm + } + + name := goos + if arch != "" { + name += "/" + arch + } + + return PlatformAttributes{ + Name: name, + GOOS: goos, + GOARCH: goarch, + GOARM: goarm, + Arch: arch, + } +} + +// String returns the string representation of the platform which has the format +// of "GOOS/Arch". +func (p PlatformAttributes) String() string { + return p.Name +} + +// BuildPlatformList is a list of BuildPlatforms that supports filtering. +type BuildPlatformList []BuildPlatform + +// Get returns the BuildPlatform matching the given name. +func (list BuildPlatformList) Get(name string) (BuildPlatform, bool) { + for _, bp := range list { + if bp.Name == name { + return bp, true + } + } + return BuildPlatform{}, false +} + +// Defaults returns the default platforms contained in the list. +func (list BuildPlatformList) Defaults() BuildPlatformList { + return list.filter(func(p BuildPlatform) bool { + return p.Flags&Default > 0 + }) +} + +// CrossBuild returns the platforms that support cross-building. +func (list BuildPlatformList) CrossBuild() BuildPlatformList { + return list.filter(func(p BuildPlatform) bool { + return p.Flags&CrossBuildSupported > 0 + }) +} + +// filter returns the platforms that match the given predicate. +func (list BuildPlatformList) filter(pred func(p BuildPlatform) bool) BuildPlatformList { + var out BuildPlatformList + for _, item := range list { + if pred(item) { + out = append(out, item) + } + } + return out +} + +// Remove returns a copy of list without platforms matching name. +func (list BuildPlatformList) Remove(name string) BuildPlatformList { + attrs := BuildPlatform{Name: name}.Attributes() + + if attrs.Arch == "" { + // Filter by GOOS only. + return list.filter(func(bp BuildPlatform) bool { + return bp.GOOS() != attrs.GOOS + }) + } + + return list.filter(func(bp BuildPlatform) bool { + return !(bp.GOOS() == attrs.GOOS && bp.Arch() == attrs.Arch) + }) +} + +// Select returns a new list containing the platforms that match name. +func (list BuildPlatformList) Select(name string) BuildPlatformList { + attrs := BuildPlatform{Name: name}.Attributes() + + if attrs.Arch == "" { + // Filter by GOOS only. + return list.filter(func(bp BuildPlatform) bool { + return bp.GOOS() == attrs.GOOS + }) + } + + return list.filter(func(bp BuildPlatform) bool { + return bp.GOOS() == attrs.GOOS && bp.Arch() == attrs.Arch + }) +} + +type platformExpression struct { + Add []string + Select []string + SelectCrossBuild bool + Remove []string +} + +func newPlatformExpression(expr string) (*platformExpression, error) { + if strings.TrimSpace(expr) == "" { + return nil, nil + } + + pe := &platformExpression{} + + // Parse the expression. + words := strings.FieldsFunc(expr, isSeparator) + for _, w := range words { + if strings.HasPrefix(w, "+") { + pe.Add = append(pe.Add, strings.TrimPrefix(w, "+")) + } else if strings.HasPrefix(w, "!") { + pe.Remove = append(pe.Remove, strings.TrimPrefix(w, "!")) + } else if w == "xbuild" { + pe.SelectCrossBuild = true + } else { + pe.Select = append(pe.Select, w) + } + } + + // Validate the names used. + checks := make([]string, 0, len(pe.Add)+len(pe.Select)+len(pe.Remove)) + checks = append(checks, pe.Add...) + checks = append(checks, pe.Select...) + checks = append(checks, pe.Remove...) + + for _, name := range checks { + if name == "all" || name == "defaults" { + continue + } + + var valid bool + for _, bp := range BuildPlatforms { + if bp.Name == name || bp.GOOS() == name { + valid = true + break + } + } + + if !valid { + return nil, errors.Errorf("invalid platform in expression: %v", name) + } + } + + return pe, nil +} + +// NewPlatformList returns a new BuildPlatformList based on given expression. +// +// By default the initial set include only the platforms designated as defaults. +// To add additional platforms to list use an addition term that is designated +// with a plug sign (e.g. "+netbsd" or "+linux/armv7"). Or you may use "+all" +// to change the initial set to include all possible platforms then filter +// from there (e.g. "+all linux windows"). +// +// The expression can consists of selections (e.g. "linux") and/or +// removals (e.g."!windows"). Each term can be valid GOOS or a valid GOOS/Arch +// pair. +// +// "xbuild" is a special selection term used to select all platforms that are +// cross-build eligible. +// "defaults" is a special selection or removal term that contains all platforms +// designated as a default. +// "all" is a special addition term for adding all valid GOOS/Arch pairs to the +// set. +func NewPlatformList(expr string) BuildPlatformList { + pe, err := newPlatformExpression(expr) + if err != nil { + panic(err) + } + if pe == nil { + return BuildPlatforms.Defaults() + } + + var out BuildPlatformList + if len(pe.Add) == 0 || (len(pe.Select) == 0 && len(pe.Remove) == 0) { + // Bootstrap list with default platforms when the expression is + // exclusively adds OR exclusively selects and removes. + out = BuildPlatforms.Defaults() + } + + all := BuildPlatforms + for _, name := range pe.Add { + if name == "all" { + out = make(BuildPlatformList, len(all)) + copy(out, all) + break + } + out = append(out, all.Select(name)...) + } + + if len(pe.Select) > 0 { + var selected BuildPlatformList + for _, name := range pe.Select { + selected = append(selected, out.Select(name)...) + } + out = selected + } + + for _, name := range pe.Remove { + if name == "defaults" { + for _, defaultBP := range all.Defaults() { + out = out.Remove(defaultBP.Name) + } + continue + } + out = out.Remove(name) + } + + if pe.SelectCrossBuild { + out = out.CrossBuild() + } + return out.deduplicate() +} + +// Filter creates a new list based on the provided expression. +// +// The expression can consists of selections (e.g. "linux") and/or +// removals (e.g."!windows"). Each term can be valid GOOS or a valid GOOS/Arch +// pair. +// +// "xbuild" is a special selection term used to select all platforms that are +// cross-build eligible. +// "defaults" is a special selection or removal term that contains all platforms +// designated as a default. +func (list BuildPlatformList) Filter(expr string) BuildPlatformList { + pe, err := newPlatformExpression(expr) + if err != nil { + panic(err) + } + if pe == nil { + return list + } + if len(pe.Add) > 0 { + panic(errors.Errorf("adds (%v) cannot be used in filter expressions", + strings.Join(pe.Add, ", "))) + } + + var out BuildPlatformList + if len(pe.Select) == 0 && !pe.SelectCrossBuild { + // Filter is only removals so clone the original list. + out = append(out, list...) + } + + if pe.SelectCrossBuild { + out = append(out, list.CrossBuild()...) + } + for _, name := range pe.Select { + if name == "defaults" { + out = append(out, list.Defaults()...) + continue + } + out = append(out, list.Select(name)...) + } + + for _, name := range pe.Remove { + if name == "defaults" { + for _, defaultBP := range BuildPlatforms.Defaults() { + out = out.Remove(defaultBP.Name) + } + continue + } + out = out.Remove(name) + } + + return out.deduplicate() +} + +// deduplicate removes duplicate platforms and sorts the list. +func (list BuildPlatformList) deduplicate() BuildPlatformList { + set := map[string]BuildPlatform{} + for _, item := range list { + set[item.Name] = item + } + + var out BuildPlatformList + for _, v := range set { + out = append(out, v) + } + + sort.Slice(out, func(i, j int) bool { + return out[i].Name < out[j].Name + }) + return out +} diff --git a/_beats/dev-tools/mage/platforms_test.go b/_beats/dev-tools/mage/platforms_test.go new file mode 100644 index 0000000000..76b568a48c --- /dev/null +++ b/_beats/dev-tools/mage/platforms_test.go @@ -0,0 +1,158 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package mage + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +func TestBuildPlatform(t *testing.T) { + bp := BuildPlatform{"windows/amd64", 0} + assert.Equal(t, "windows", bp.GOOS()) + assert.Equal(t, "amd64", bp.GOARCH()) + assert.Equal(t, "", bp.GOARM()) + assert.Equal(t, "amd64", bp.Arch()) + + bp = BuildPlatform{"linux/armv7", 0} + assert.Equal(t, "linux", bp.GOOS()) + assert.Equal(t, "arm", bp.GOARCH()) + assert.Equal(t, "7", bp.GOARM()) + assert.Equal(t, "armv7", bp.Arch()) + attrs := bp.Attributes() + assert.Equal(t, bp.Name, attrs.Name) + assert.Equal(t, "linux", attrs.GOOS) + assert.Equal(t, "arm", attrs.GOARCH) + assert.Equal(t, "7", attrs.GOARM) + assert.Equal(t, "armv7", attrs.Arch) + + bp = BuildPlatform{"linux", 0} + assert.Equal(t, "linux", bp.GOOS()) + assert.Equal(t, "", bp.GOARCH()) + assert.Equal(t, "", bp.GOARM()) + assert.Equal(t, "", bp.Arch()) + attrs = bp.Attributes() + assert.Equal(t, bp.Name, attrs.Name) + assert.Equal(t, "linux", attrs.GOOS) + assert.Equal(t, "", attrs.GOARCH) + assert.Equal(t, "", attrs.GOARM) + assert.Equal(t, "", attrs.Arch) +} + +func TestBuildPlatformsListRemove(t *testing.T) { + list := BuildPlatformList{ + {"linux/amd64", 0}, + {"linux/386", 0}, + } + + assert.ElementsMatch(t, + list.Remove("linux/386"), + BuildPlatformList{{"linux/amd64", 0}}, + ) +} + +func TestBuildPlatformsListRemoveOS(t *testing.T) { + list := BuildPlatformList{ + {"linux/amd64", 0}, + {"linux/386", 0}, + {"windows/amd64", 0}, + } + + assert.ElementsMatch(t, + list.Remove("linux"), + BuildPlatformList{{"windows/amd64", 0}}, + ) +} + +func TestBuildPlatformsListSelect(t *testing.T) { + list := BuildPlatformList{ + {"linux/amd64", 0}, + {"linux/386", 0}, + } + + assert.ElementsMatch(t, + list.Select("linux/386"), + BuildPlatformList{{"linux/386", 0}}, + ) +} + +func TestBuildPlatformsListDefaults(t *testing.T) { + list := BuildPlatformList{ + {"linux/amd64", Default}, + {"linux/386", 0}, + } + + assert.ElementsMatch(t, + list.Defaults(), + BuildPlatformList{{"linux/amd64", Default}}, + ) +} + +func TestBuildPlatformsListFilter(t *testing.T) { + assert.Len(t, BuildPlatforms.Filter("!linux/armv7"), len(BuildPlatforms)-1) + + assert.Len(t, BuildPlatforms.Filter("solaris"), 1) + assert.Len(t, BuildPlatforms.Defaults().Filter("solaris"), 0) + + assert.Len(t, BuildPlatforms.Filter("windows"), 2) + assert.Len(t, BuildPlatforms.Filter("windows/386"), 1) + assert.Len(t, BuildPlatforms.Filter("!defaults"), len(BuildPlatforms)-len(BuildPlatforms.Defaults())) + + defaults := BuildPlatforms.Defaults() + assert.ElementsMatch(t, + defaults.Filter("darwin"), + defaults.Filter("!windows !linux")) + assert.ElementsMatch(t, + defaults, + defaults.Filter("windows linux darwin")) + assert.ElementsMatch(t, + defaults, + append(defaults.Filter("darwin"), defaults.Filter("!darwin")...)) + assert.ElementsMatch(t, + BuildPlatforms, + BuildPlatforms.Filter("")) + assert.ElementsMatch(t, + BuildPlatforms.Filter("defaults"), + BuildPlatforms.Defaults()) +} + +func TestNewPlatformList(t *testing.T) { + assert.Len(t, NewPlatformList("+all !linux/armv7"), len(BuildPlatforms)-1) + assert.Len(t, NewPlatformList("+solaris"), len(BuildPlatforms.Defaults())+1) + assert.Len(t, NewPlatformList("solaris"), 0) + assert.Len(t, NewPlatformList("+all solaris"), 1) + assert.Len(t, NewPlatformList("+windows"), len(BuildPlatforms.Defaults())) + assert.Len(t, NewPlatformList("+linux/ppc64 !defaults"), 1) + + assert.ElementsMatch(t, + NewPlatformList("darwin"), + NewPlatformList("!windows !linux")) + assert.ElementsMatch(t, + BuildPlatforms.Defaults(), + NewPlatformList("windows linux darwin")) + assert.ElementsMatch(t, + BuildPlatforms.Defaults(), + append(NewPlatformList("darwin"), NewPlatformList("!darwin")...)) + assert.ElementsMatch(t, + BuildPlatforms.Defaults(), + NewPlatformList("")) + assert.ElementsMatch(t, + BuildPlatforms, + NewPlatformList("+all")) +} diff --git a/_beats/dev-tools/mage/settings.go b/_beats/dev-tools/mage/settings.go new file mode 100644 index 0000000000..dc66bdd33e --- /dev/null +++ b/_beats/dev-tools/mage/settings.go @@ -0,0 +1,573 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package mage + +import ( + "fmt" + "go/build" + "io/ioutil" + "log" + "os" + "path/filepath" + "regexp" + "strconv" + "strings" + "sync" + "time" + + "github.com/magefile/mage/sh" + "github.com/pkg/errors" + "golang.org/x/tools/go/vcs" +) + +const ( + fpmVersion = "1.10.0" + + // Docker images. See https://github.com/elastic/golang-crossbuild. + beatsFPMImage = "docker.elastic.co/beats-dev/fpm" + beatsCrossBuildImage = "docker.elastic.co/beats-dev/golang-crossbuild" + + elasticBeatsImportPath = "github.com/elastic/beats" +) + +// Common settings with defaults derived from files, CWD, and environment. +var ( + GOOS = build.Default.GOOS + GOARCH = build.Default.GOARCH + GOARM = EnvOr("GOARM", "") + Platform = MakePlatformAttributes(GOOS, GOARCH, GOARM) + BinaryExt = "" + + BeatName = EnvOr("BEAT_NAME", filepath.Base(CWD())) + BeatServiceName = EnvOr("BEAT_SERVICE_NAME", BeatName) + BeatIndexPrefix = EnvOr("BEAT_INDEX_PREFIX", BeatName) + BeatDescription = EnvOr("BEAT_DESCRIPTION", "") + BeatVendor = EnvOr("BEAT_VENDOR", "Elastic") + BeatLicense = EnvOr("BEAT_LICENSE", "ASL 2.0") + BeatURL = EnvOr("BEAT_URL", "https://www.elastic.co/products/beats/"+BeatName) + + Snapshot bool + + FuncMap = map[string]interface{}{ + "beat_doc_branch": BeatDocBranch, + "beat_version": BeatVersion, + "commit": CommitHash, + "date": BuildDate, + "elastic_beats_dir": ElasticBeatsDir, + "go_version": GoVersion, + "repo": GetProjectRepoInfo, + "title": strings.Title, + } +) + +func init() { + if GOOS == "windows" { + BinaryExt = ".exe" + } + + var err error + Snapshot, err = strconv.ParseBool(EnvOr("SNAPSHOT", "false")) + if err != nil { + panic(errors.Errorf("failed to parse SNAPSHOT value", err)) + } +} + +// EnvMap returns map containing the common settings variables and all variables +// from the environment. args are appended to the output prior to adding the +// environment variables (so env vars have the highest precedence). +func EnvMap(args ...map[string]interface{}) map[string]interface{} { + envMap := varMap(args...) + + // Add the environment (highest precedence). + for _, e := range os.Environ() { + env := strings.SplitN(e, "=", 2) + envMap[env[0]] = env[1] + } + + return envMap +} + +func varMap(args ...map[string]interface{}) map[string]interface{} { + data := map[string]interface{}{ + "GOOS": GOOS, + "GOARCH": GOARCH, + "GOARM": GOARM, + "Platform": Platform, + "BinaryExt": BinaryExt, + "BeatName": BeatName, + "BeatServiceName": BeatServiceName, + "BeatIndexPrefix": BeatIndexPrefix, + "BeatDescription": BeatDescription, + "BeatVendor": BeatVendor, + "BeatLicense": BeatLicense, + "BeatURL": BeatURL, + "Snapshot": Snapshot, + } + + // Add the extra args to the map. + for _, m := range args { + for k, v := range m { + data[k] = v + } + } + + return data +} + +func dumpVariables() (string, error) { + var dumpTemplate = `## Variables + +GOOS = {{.GOOS}} +GOARCH = {{.GOARCH}} +GOARM = {{.GOARM}} +Platform = {{.Platform}} +BinaryExt = {{.BinaryExt}} +BeatName = {{.BeatName}} +BeatServiceName = {{.BeatServiceName}} +BeatIndexPrefix = {{.BeatIndexPrefix}} +BeatDescription = {{.BeatDescription}} +BeatVendor = {{.BeatVendor}} +BeatLicense = {{.BeatLicense}} +BeatURL = {{.BeatURL}} + +## Functions + +beat_doc_branch = {{ beat_doc_branch }} +beat_version = {{ beat_version }} +commit = {{ commit }} +date = {{ date }} +elastic_beats_dir = {{ elastic_beats_dir }} +go_version = {{ go_version }} +repo.RootImportPath = {{ repo.RootImportPath }} +repo.RootDir = {{ repo.RootDir }} +repo.ImportPath = {{ repo.ImportPath }} +repo.SubDir = {{ repo.SubDir }} +` + + return Expand(dumpTemplate) +} + +// DumpVariables writes the template variables and values to stdout. +func DumpVariables() error { + out, err := dumpVariables() + if err != nil { + return err + } + + fmt.Println(out) + return nil +} + +var ( + commitHash string + commitHashOnce sync.Once +) + +// CommitHash returns the full length git commit hash. +func CommitHash() (string, error) { + var err error + commitHashOnce.Do(func() { + commitHash, err = sh.Output("git", "rev-parse", "HEAD") + }) + return commitHash, err +} + +var ( + elasticBeatsDirValue string + elasticBeatsDirErr error + elasticBeatsDirLock sync.Mutex +) + +// ElasticBeatsDir returns the path to Elastic beats dir. +func ElasticBeatsDir() (string, error) { + elasticBeatsDirLock.Lock() + defer elasticBeatsDirLock.Unlock() + + if elasticBeatsDirValue != "" || elasticBeatsDirErr != nil { + return elasticBeatsDirValue, elasticBeatsDirErr + } + + elasticBeatsDirValue, elasticBeatsDirErr = findElasticBeatsDir() + if elasticBeatsDirErr == nil { + log.Println("Found Elastic Beats dir at", elasticBeatsDirValue) + } + return elasticBeatsDirValue, elasticBeatsDirErr +} + +// findElasticBeatsDir attempts to find the root of the Elastic Beats directory. +// It checks to see if the current project is elastic/beats, and then if not +// checks the vendor directory. +// +// If your project places the Beats files in a different location (specifically +// the dev-tools/ contents) then you can use SetElasticBeatsDir(). +func findElasticBeatsDir() (string, error) { + repo, err := GetProjectRepoInfo() + if err != nil { + return "", err + } + + if repo.IsElasticBeats() { + return repo.RootDir, nil + } + + const devToolsImportPath = elasticBeatsImportPath + "/dev-tools/mage" + + // Search in project vendor directories. + searchPaths := []string{ + filepath.Join(repo.RootDir, repo.SubDir, "vendor", devToolsImportPath), + filepath.Join(repo.RootDir, "vendor", devToolsImportPath), + } + + for _, path := range searchPaths { + if _, err := os.Stat(path); err == nil { + return filepath.Join(path, "../.."), nil + } + } + + return "", errors.Errorf("failed to find %v in the project's vendor", devToolsImportPath) +} + +// SetElasticBeatsDir explicilty sets the location of the Elastic Beats +// directory. If not set then it will attempt to locate it. +func SetElasticBeatsDir(dir string) { + elasticBeatsDirLock.Lock() + defer elasticBeatsDirLock.Unlock() + + info, err := os.Stat(dir) + if err != nil { + panic(errors.Wrapf(err, "failed to read elastic beats dir at %v", dir)) + } + + if !info.IsDir() { + panic(errors.Errorf("elastic beats dir=%v is not a directory", dir)) + } + + elasticBeatsDirValue = filepath.Clean(dir) +} + +var ( + buildDate = time.Now().UTC().Format(time.RFC3339) +) + +// BuildDate returns the time that the build started. +func BuildDate() string { + return buildDate +} + +var ( + goVersionValue string + goVersionErr error + goVersionOnce sync.Once +) + +// GoVersion returns the version of Go defined in the project's .go-version +// file. +func GoVersion() (string, error) { + goVersionOnce.Do(func() { + goVersionValue = os.Getenv("BEAT_GO_VERSION") + if goVersionValue != "" { + return + } + + goVersionValue, goVersionErr = getBuildVariableSources().GetGoVersion() + }) + + return goVersionValue, goVersionErr +} + +var ( + beatVersionRegex = regexp.MustCompile(`(?m)^const defaultBeatVersion = "(.+)"\r?$`) + beatVersionValue string + beatVersionErr error + beatVersionOnce sync.Once +) + +// BeatVersion returns the Beat's version. The value can be overridden by +// setting BEAT_VERSION in the environment. +func BeatVersion() (string, error) { + beatVersionOnce.Do(func() { + beatVersionValue = os.Getenv("BEAT_VERSION") + if beatVersionValue != "" { + return + } + + beatVersionValue, beatVersionErr = getBuildVariableSources().GetBeatVersion() + }) + + return beatVersionValue, beatVersionErr +} + +var ( + beatDocBranchRegex = regexp.MustCompile(`(?m)doc-branch:\s*([^\s]+)\r?$`) + beatDocBranchValue string + beatDocBranchErr error + beatDocBranchOnce sync.Once +) + +// BeatDocBranch returns the documentation branch name associated with the +// Beat branch. +func BeatDocBranch() (string, error) { + beatDocBranchOnce.Do(func() { + beatDocBranchValue = os.Getenv("BEAT_DOC_BRANCH") + if beatDocBranchValue != "" { + return + } + + beatDocBranchValue, beatDocBranchErr = getBuildVariableSources().GetDocBranch() + }) + + return beatDocBranchValue, beatDocBranchErr +} + +// --- BuildVariableSources + +var ( + // DefaultBeatBuildVariableSources contains the default locations build + // variables are read from by Elastic Beats. + DefaultBeatBuildVariableSources = &BuildVariableSources{ + BeatVersion: "{{ elastic_beats_dir }}/libbeat/version/version.go", + GoVersion: "{{ elastic_beats_dir }}/.go-version", + DocBranch: "{{ elastic_beats_dir }}/libbeat/docs/version.asciidoc", + } + + buildVariableSources *BuildVariableSources + buildVariableSourcesLock sync.Mutex +) + +// SetBuildVariableSources sets the BuildVariableSources that defines where +// certain build data should be sourced from. Community Beats must call this. +func SetBuildVariableSources(s *BuildVariableSources) { + buildVariableSourcesLock.Lock() + defer buildVariableSourcesLock.Unlock() + + buildVariableSources = s +} + +func getBuildVariableSources() *BuildVariableSources { + buildVariableSourcesLock.Lock() + defer buildVariableSourcesLock.Unlock() + + if buildVariableSources != nil { + return buildVariableSources + } + + repo, err := GetProjectRepoInfo() + if err != nil { + panic(err) + } + if repo.IsElasticBeats() { + buildVariableSources = DefaultBeatBuildVariableSources + return buildVariableSources + } + + panic(errors.Errorf("magefile must call mage.SetBuildVariableSources() "+ + "because it is not an elastic beat (repo=%+v)", repo.RootImportPath)) +} + +// BuildVariableSources is used to explicitly define what files contain build +// variables and how to parse the values from that file. This removes ambiguity +// about where the data is sources and allows a degree of customization for +// community Beats. +// +// Default parsers are used if one is not defined. +type BuildVariableSources struct { + // File containing the Beat version. + BeatVersion string + + // Parses the Beat version from the BeatVersion file. + BeatVersionParser func(data []byte) (string, error) + + // File containing the Go version to be used in cross-builds. + GoVersion string + + // Parses the Go version from the GoVersion file. + GoVersionParser func(data []byte) (string, error) + + // File containing the documentation branch. + DocBranch string + + // Parses the documentation branch from the DocBranch file. + DocBranchParser func(data []byte) (string, error) +} + +func (s *BuildVariableSources) expandVar(in string) (string, error) { + return expandTemplate("inline", in, map[string]interface{}{ + "elastic_beats_dir": ElasticBeatsDir, + }) +} + +// GetBeatVersion reads the BeatVersion file and parses the version from it. +func (s *BuildVariableSources) GetBeatVersion() (string, error) { + file, err := s.expandVar(s.BeatVersion) + if err != nil { + return "", err + } + + data, err := ioutil.ReadFile(file) + if err != nil { + return "", errors.Wrapf(err, "failed to read beat version file=%v", file) + } + + if s.BeatVersionParser == nil { + s.BeatVersionParser = parseBeatVersion + } + return s.BeatVersionParser(data) +} + +// GetGoVersion reads the GoVersion file and parses the version from it. +func (s *BuildVariableSources) GetGoVersion() (string, error) { + file, err := s.expandVar(s.GoVersion) + if err != nil { + return "", err + } + + data, err := ioutil.ReadFile(file) + if err != nil { + return "", errors.Wrapf(err, "failed to read go version file=%v", file) + } + + if s.GoVersionParser == nil { + s.GoVersionParser = parseGoVersion + } + return s.GoVersionParser(data) +} + +// GetDocBranch reads the DocBranch file and parses the branch from it. +func (s *BuildVariableSources) GetDocBranch() (string, error) { + file, err := s.expandVar(s.DocBranch) + if err != nil { + return "", err + } + + data, err := ioutil.ReadFile(file) + if err != nil { + return "", errors.Wrapf(err, "failed to read doc branch file=%v", file) + } + + if s.DocBranchParser == nil { + s.DocBranchParser = parseDocBranch + } + return s.DocBranchParser(data) +} + +func parseBeatVersion(data []byte) (string, error) { + matches := beatVersionRegex.FindSubmatch(data) + if len(matches) == 2 { + return string(matches[1]), nil + } + + return "", errors.New("failed to parse beat version file") +} + +func parseGoVersion(data []byte) (string, error) { + return strings.TrimSpace(string(data)), nil +} + +func parseDocBranch(data []byte) (string, error) { + matches := beatDocBranchRegex.FindSubmatch(data) + if len(matches) == 2 { + return string(matches[1]), nil + } + + return "", errors.New("failed to parse beat doc branch") +} + +// --- ProjectRepoInfo + +// ProjectRepoInfo contains information about the project's repo. +type ProjectRepoInfo struct { + RootImportPath string // Import path at the project root. + RootDir string // Root directory of the project. + ImportPath string // Import path of the current directory. + SubDir string // Relative path from the root dir to the current dir. +} + +// IsElasticBeats returns true if the current project is +// github.com/elastic/beats. +func (r *ProjectRepoInfo) IsElasticBeats() bool { + return r.RootImportPath == elasticBeatsImportPath +} + +var ( + repoInfoValue *ProjectRepoInfo + repoInfoErr error + repoInfoOnce sync.Once +) + +// GetProjectRepoInfo returns information about the repo including the root +// import path and the current directory's import path. +func GetProjectRepoInfo() (*ProjectRepoInfo, error) { + repoInfoOnce.Do(func() { + repoInfoValue, repoInfoErr = getProjectRepoInfo() + }) + + return repoInfoValue, repoInfoErr +} + +func getProjectRepoInfo() (*ProjectRepoInfo, error) { + var ( + cwd = CWD() + rootImportPath string + srcDir string + ) + + // Search upward from the CWD to determine the project root based on VCS. + var errs []string + for _, gopath := range filepath.SplitList(build.Default.GOPATH) { + gopath = filepath.Clean(gopath) + + if !strings.HasPrefix(cwd, gopath) { + // Fixes an issue on macOS when /var is actually /private/var. + var err error + gopath, err = filepath.EvalSymlinks(gopath) + if err != nil { + errs = append(errs, err.Error()) + continue + } + } + + srcDir = filepath.Join(gopath, "src") + _, root, err := vcs.FromDir(cwd, srcDir) + if err != nil { + // Try the next gopath. + errs = append(errs, err.Error()) + continue + } + rootImportPath = root + break + } + if rootImportPath == "" { + return nil, errors.Errorf("failed to determine root import path (Did "+ + "you git init?, Is the project in the GOPATH? GOPATH=%v, CWD=%v?): %v", + build.Default.GOPATH, cwd, errs) + } + + rootDir := filepath.Join(srcDir, rootImportPath) + subDir, err := filepath.Rel(rootDir, cwd) + if err != nil { + return nil, errors.Wrap(err, "failed to get relative path to repo root") + } + importPath := filepath.ToSlash(filepath.Join(rootImportPath, subDir)) + + return &ProjectRepoInfo{ + RootImportPath: rootImportPath, + RootDir: rootDir, + SubDir: subDir, + ImportPath: importPath, + }, nil +} diff --git a/_beats/dev-tools/mage/templates/common/README.md.tmpl b/_beats/dev-tools/mage/templates/common/README.md.tmpl new file mode 100644 index 0000000000..5754ce7f87 --- /dev/null +++ b/_beats/dev-tools/mage/templates/common/README.md.tmpl @@ -0,0 +1,27 @@ +# Welcome to {{.BeatName | title}} {{.Version}}{{if .Snapshot}}-SNAPSHOT{{end}} + +{{.Description}} + +## Getting Started + +To get started with {{.BeatName | title}}, you need to set up Elasticsearch on +your localhost first. After that, start {{.BeatName | title}} with: + + ./{{.BeatName}} -c {{.BeatName}}.yml -e + +This will start {{.BeatName | title }} and send the data to your Elasticsearch +instance. To load the dashboards for {{.BeatName | title}} into Kibana, run: + + ./{{.BeatName}} setup -e + +For further steps visit the +[Getting started](https://www.elastic.co/guide/en/beats/{{.BeatName}}/{{ beat_doc_branch }}/{{.BeatName}}-getting-started.html) guide. + +## Documentation + +Visit [Elastic.co Docs](https://www.elastic.co/guide/en/beats/{{.BeatName}}/{{ beat_doc_branch }}/index.html) +for the full {{.BeatName | title}} documentation. + +## Release notes + +https://www.elastic.co/guide/en/beats/libbeat/{{ beat_doc_branch }}/release-notes-{{.Version}}.html diff --git a/_beats/dev-tools/mage/templates/common/magefile.go.tmpl b/_beats/dev-tools/mage/templates/common/magefile.go.tmpl new file mode 100644 index 0000000000..1a9822d249 --- /dev/null +++ b/_beats/dev-tools/mage/templates/common/magefile.go.tmpl @@ -0,0 +1,72 @@ +// +build mage + +package main + +import ( + "fmt" + "time" + + "github.com/magefile/mage/mg" + "github.com/magefile/mage/sh" + + "github.com/elastic/beats/dev-tools/mage" +) + +func init() { + mage.BeatDescription = "One sentence description of the Beat." +} + +// Build builds the Beat binary. +func Build() error { + return mage.Build(mage.DefaultBuildArgs()) +} + +// GolangCrossBuild build the Beat binary inside of the golang-builder. +// Do not use directly, use crossBuild instead. +func GolangCrossBuild() error { + return mage.GolangCrossBuild(mage.DefaultGolangCrossBuildArgs()) +} + +// BuildGoDaemon builds the go-daemon binary (use crossBuildGoDaemon). +func BuildGoDaemon() error { + return mage.BuildGoDaemon() +} + +// CrossBuild cross-builds the beat for all target platforms. +func CrossBuild() error { + return mage.CrossBuild() +} + +// CrossBuildGoDaemon cross-builds the go-daemon binary using Docker. +func CrossBuildGoDaemon() error { + return mage.CrossBuildGoDaemon() +} + +// Clean cleans all generated files and build artifacts. +func Clean() error { + return mage.Clean() +} + +// Package packages the Beat for distribution. +// Use SNAPSHOT=true to build snapshots. +// Use PLATFORMS to control the target platforms. +func Package() { + start := time.Now() + defer func() { fmt.Println("package ran for", time.Since(start)) }() + + mage.UseCommunityBeatPackaging() + + mg.Deps(Update) + mg.Deps(CrossBuild, CrossBuildGoDaemon) + mg.SerialDeps(mage.Package, TestPackages) +} + +// TestPackages tests the generated packages (i.e. file modes, owners, groups). +func TestPackages() error { + return mage.TestPackages() +} + +// Update updates the generated files (aka make update). +func Update() error { + return sh.Run("make", "update") +} diff --git a/_beats/dev-tools/packer/platforms/debian/init.j2 b/_beats/dev-tools/mage/templates/deb/init.sh.tmpl old mode 100755 new mode 100644 similarity index 85% rename from _beats/dev-tools/packer/platforms/debian/init.j2 rename to _beats/dev-tools/mage/templates/deb/init.sh.tmpl index 04c24242d8..1e793c9184 --- a/_beats/dev-tools/packer/platforms/debian/init.j2 +++ b/_beats/dev-tools/mage/templates/deb/init.sh.tmpl @@ -1,35 +1,35 @@ #!/bin/sh ### BEGIN INIT INFO -# Provides: {{.beat_pkg_name}} +# Provides: {{.ServiceName}} # Required-Start: $local_fs $network $syslog # Required-Stop: $local_fs $network $syslog # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 -# Short-Description: {{.beat_description}} -# Description: {{.beat_name}} is a shipper part of the Elastic Beats -# family. Please see: https://www.elastic.co/products/beats +# Short-Description: {{.Description}} +# Description: {{.BeatName | title}} is a shipper part of the Elastic Beats +# family. Please see: https://www.elastic.co/products/beats ### END INIT INFO # Do NOT "set -e" # PATH should only include /usr/* if it runs after the mountnfs.sh script PATH=/sbin:/usr/sbin:/bin:/usr/bin -DESC="{{.beat_description}}" -NAME="{{.beat_name}}" -DAEMON=/usr/share/{{.beat_name}}/bin/$NAME -DAEMON_ARGS="-c /etc/{{.beat_name}}/{{.beat_name}}.yml -path.home /usr/share/{{.beat_name}} -path.config /etc/{{.beat_name}} -path.data /var/lib/{{.beat_name}} -path.logs /var/log/{{.beat_name}}" +DESC="{{.Description}}" +NAME="{{.BeatName}}" +DAEMON=/usr/share/${NAME}/bin/${NAME} +DAEMON_ARGS="-c /etc/${NAME}/${NAME}.yml -path.home /usr/share/${NAME} -path.config /etc/${NAME} -path.data /var/lib/${NAME} -path.logs /var/log/${NAME}" TEST_ARGS="-e test config" -PIDFILE=/var/run/{{.beat_pkg_name}}.pid -WRAPPER="/usr/share/{{.beat_name}}/bin/{{.beat_name}}-god" +PIDFILE=/var/run/{{.ServiceName}}.pid +WRAPPER="/usr/share/${NAME}/bin/${NAME}-god" BEAT_USER="root" WRAPPER_ARGS="-r / -n -p $PIDFILE" -SCRIPTNAME=/etc/init.d/$NAME +SCRIPTNAME=/etc/init.d/{{.ServiceName}} # Exit if the package is not installed [ -x "$DAEMON" ] || exit 0 # Read configuration variable file if it is present -[ -r /etc/default/{{.beat_pkg_name}} ] && . /etc/default/{{.beat_pkg_name}} +[ -r /etc/default/{{.ServiceName}} ] && . /etc/default/{{.ServiceName}} [ "$BEAT_USER" != "root" ] && WRAPPER_ARGS="$WRAPPER_ARGS -u $BEAT_USER" USER_WRAPPER="su" diff --git a/_beats/dev-tools/mage/templates/linux/beatname.sh.tmpl b/_beats/dev-tools/mage/templates/linux/beatname.sh.tmpl new file mode 100644 index 0000000000..fce8cfb625 --- /dev/null +++ b/_beats/dev-tools/mage/templates/linux/beatname.sh.tmpl @@ -0,0 +1,11 @@ +#!/usr/bin/env bash + +# Script to run {{.BeatName | title}} in foreground with the same path settings that +# the init script / systemd unit file would do. + +exec /usr/share/{{.BeatName}}/bin/{{.BeatName}} \ + -path.home /usr/share/{{.BeatName}} \ + -path.config /etc/{{.BeatName}} \ + -path.data /var/lib/{{.BeatName}} \ + -path.logs /var/log/{{.BeatName}} \ + "$@" diff --git a/_beats/dev-tools/mage/templates/linux/systemd.unit.tmpl b/_beats/dev-tools/mage/templates/linux/systemd.unit.tmpl new file mode 100644 index 0000000000..5725ba3e2a --- /dev/null +++ b/_beats/dev-tools/mage/templates/linux/systemd.unit.tmpl @@ -0,0 +1,12 @@ +[Unit] +Description={{.Description}} +Documentation={{.URL}} +Wants=network-online.target +After=network-online.target + +[Service] +ExecStart=/usr/share/{{.BeatName}}/bin/{{.BeatName}} -c /etc/{{.BeatName}}/{{.BeatName}}.yml -path.home /usr/share/{{.BeatName}} -path.config /etc/{{.BeatName}} -path.data /var/lib/{{.BeatName}} -path.logs /var/log/{{.BeatName}} +Restart=always + +[Install] +WantedBy=multi-user.target diff --git a/_beats/dev-tools/packer/platforms/centos/init.j2 b/_beats/dev-tools/mage/templates/rpm/init.sh.tmpl old mode 100755 new mode 100644 similarity index 66% rename from _beats/dev-tools/packer/platforms/centos/init.j2 rename to _beats/dev-tools/mage/templates/rpm/init.sh.tmpl index f713575539..e9a32ae74a --- a/_beats/dev-tools/packer/platforms/centos/init.j2 +++ b/_beats/dev-tools/mage/templates/rpm/init.sh.tmpl @@ -1,20 +1,20 @@ #!/bin/bash # -# {{.beat_pkg_name}} {{.beat_name}} shipper +# {{.ServiceName}} {{.BeatName}} shipper # # chkconfig: 2345 98 02 -# description: Starts and stops a single {{.beat_name}} instance on this system +# description: Starts and stops a single {{.BeatName}} instance on this system # ### BEGIN INIT INFO -# Provides: {{.beat_pkg_name}} +# Provides: {{.ServiceName}} # Required-Start: $local_fs $network $syslog # Required-Stop: $local_fs $network $syslog # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 -# Short-Description: {{.beat_description}} -# Description: {{.beat_name}} is a shipper part of the Elastic Beats -# family. Please see: https://www.elastic.co/products/beats +# Short-Description: {{.Description}} +# Description: {{.BeatName | title}} is a shipper part of the Elastic Beats +# family. Please see: https://www.elastic.co/products/beats ### END INIT INFO @@ -22,13 +22,13 @@ PATH=/usr/bin:/sbin:/bin:/usr/sbin export PATH -[ -f /etc/sysconfig/{{.beat_pkg_name}} ] && . /etc/sysconfig/{{.beat_pkg_name}} -pidfile=${PIDFILE-/var/run/{{.beat_pkg_name}}.pid} -agent=${BEATS_AGENT-/usr/share/{{.beat_name}}/bin/{{.beat_name}}} -args="-c /etc/{{.beat_name}}/{{.beat_name}}.yml -path.home /usr/share/{{.beat_name}} -path.config /etc/{{.beat_name}} -path.data /var/lib/{{.beat_name}} -path.logs /var/log/{{.beat_name}}" +[ -f /etc/sysconfig/{{.ServiceName}} ] && . /etc/sysconfig/{{.ServiceName}} +pidfile=${PIDFILE-/var/run/{{.ServiceName}}.pid} +agent=${BEATS_AGENT-/usr/share/{{.BeatName}}/bin/{{.BeatName}}} +args="-c /etc/{{.BeatName}}/{{.BeatName}}.yml -path.home /usr/share/{{.BeatName}} -path.config /etc/{{.BeatName}} -path.data /var/lib/{{.BeatName}} -path.logs /var/log/{{.BeatName}}" test_args="-e test config" beat_user="${BEAT_USER:-root}" -wrapper="/usr/share/{{.beat_name}}/bin/{{.beat_name}}-god" +wrapper="/usr/share/{{.BeatName}}/bin/{{.BeatName}}-god" wrapperopts="-r / -n -p $pidfile" user_wrapper="su" user_wrapperopts="$beat_user -c" @@ -55,7 +55,7 @@ test() { } start() { - echo -n $"Starting {{.beat_name}}: " + echo -n $"Starting {{.BeatName}}: " test if [ $? -ne 0 ]; then echo @@ -68,7 +68,7 @@ start() { } stop() { - echo -n $"Stopping {{.beat_name}}: " + echo -n $"Stopping {{.BeatName}}: " killproc $pidopts $wrapper RETVAL=$? echo diff --git a/_beats/dev-tools/mage/templates/windows/install-service.ps1.tmpl b/_beats/dev-tools/mage/templates/windows/install-service.ps1.tmpl new file mode 100644 index 0000000000..c4b4f682f3 --- /dev/null +++ b/_beats/dev-tools/mage/templates/windows/install-service.ps1.tmpl @@ -0,0 +1,14 @@ +# Delete and stop the service if it already exists. +if (Get-Service {{.BeatName}} -ErrorAction SilentlyContinue) { + $service = Get-WmiObject -Class Win32_Service -Filter "name='{{.BeatName}}'" + $service.StopService() + Start-Sleep -s 1 + $service.delete() +} + +$workdir = Split-Path $MyInvocation.MyCommand.Path + +# Create the new service. +New-Service -name {{.BeatName}} ` + -displayName {{.BeatName | title}} ` + -binaryPathName "`"$workdir\{{.BeatName}}.exe`" -c `"$workdir\{{.BeatName}}.yml`" -path.home `"$workdir`" -path.data `"C:\ProgramData\{{.BeatName}}`" -path.logs `"C:\ProgramData\{{.BeatName}}\logs`"" diff --git a/_beats/dev-tools/mage/templates/windows/uninstall-service.ps1.tmpl b/_beats/dev-tools/mage/templates/windows/uninstall-service.ps1.tmpl new file mode 100644 index 0000000000..902a13a885 --- /dev/null +++ b/_beats/dev-tools/mage/templates/windows/uninstall-service.ps1.tmpl @@ -0,0 +1,7 @@ +# Delete and stop the service if it already exists. +if (Get-Service {{.BeatName}} -ErrorAction SilentlyContinue) { + $service = Get-WmiObject -Class Win32_Service -Filter "name='{{.BeatName}}'" + $service.StopService() + Start-Sleep -s 1 + $service.delete() +} diff --git a/_beats/dev-tools/mage/testdata/config.yml b/_beats/dev-tools/mage/testdata/config.yml new file mode 100644 index 0000000000..3b5bf4a1da --- /dev/null +++ b/_beats/dev-tools/mage/testdata/config.yml @@ -0,0 +1,7 @@ +brewbeat.modules: +- module: milling +- module: mashing +- module: lautering +- module: boil +- module: fermenting +- module: bottle diff --git a/_beats/dev-tools/package_test.go b/_beats/dev-tools/package_test.go index bc99374e50..2021a42a4a 100644 --- a/_beats/dev-tools/package_test.go +++ b/_beats/dev-tools/package_test.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package dev_tools // This file contains tests that can be run on the generated packages. @@ -30,7 +47,7 @@ const ( ) var ( - configFilePattern = regexp.MustCompile(`.*beat\.yml`) + configFilePattern = regexp.MustCompile(`.*beat\.yml|apm-server\.yml`) manifestFilePattern = regexp.MustCompile(`manifest.yml`) modulesDirPattern = regexp.MustCompile(`modules.d/$`) modulesFilePattern = regexp.MustCompile(`modules.d/.+`) diff --git a/_beats/dev-tools/packer/.gitignore b/_beats/dev-tools/packer/.gitignore deleted file mode 100644 index 5778a7d708..0000000000 --- a/_beats/dev-tools/packer/.gitignore +++ /dev/null @@ -1,7 +0,0 @@ -*.swp -*.swo -/build/ -/env/ - -# copied over from xgo-image/ -docker/xgo-image-deb7/base/build.sh diff --git a/_beats/dev-tools/packer/Makefile b/_beats/dev-tools/packer/Makefile deleted file mode 100644 index c89da1b2a1..0000000000 --- a/_beats/dev-tools/packer/Makefile +++ /dev/null @@ -1,131 +0,0 @@ -BUILDID?=$(shell git rev-parse HEAD) -SNAPSHOT?=yes - -BEATS_BUILDER_IMAGE?=tudorg/beats-builder -BEATS_BUILDER_DEB_IMAGE?=tudorg/beats-builder-deb7 -BEATS_GOPATH=$(firstword $(subst :, ,${GOPATH})) - -makefile_abspath:=$(abspath $(lastword $(MAKEFILE_LIST))) -packer_absdir=$(shell dirname ${makefile_abspath}) -beat_abspath=${BEATS_GOPATH}/src/${BEAT_PATH} - - -%/deb: ${BUILD_DIR}/god-linux-386 ${BUILD_DIR}/god-linux-amd64 fpm-image - echo Creating DEB packages for $(@D) - ARCH=386 BEAT=$(@D) BUILD_DIR=${BUILD_DIR} UPLOAD_DIR=${UPLOAD_DIR} BEAT_PATH=$(beat_abspath) BUILDID=$(BUILDID) SNAPSHOT=$(SNAPSHOT) BEAT_REF_YAML=${BEAT_REF_YAML} $(packer_absdir)/platforms/debian/build.sh - ARCH=amd64 BEAT=$(@D) BUILD_DIR=${BUILD_DIR} UPLOAD_DIR=${UPLOAD_DIR} BEAT_PATH=$(beat_abspath) BUILDID=$(BUILDID) SNAPSHOT=$(SNAPSHOT) BEAT_REF_YAML=${BEAT_REF_YAML} $(packer_absdir)/platforms/debian/build.sh - -%/rpm: ${BUILD_DIR}/god-linux-386 ${BUILD_DIR}/god-linux-amd64 fpm-image - echo Creating RPM packages for $(@D) - ARCH=386 BEAT=$(@D) BUILD_DIR=${BUILD_DIR} UPLOAD_DIR=${UPLOAD_DIR} BEAT_PATH=$(beat_abspath) BUILDID=$(BUILDID) SNAPSHOT=$(SNAPSHOT) BEAT_REF_YAML=${BEAT_REF_YAML} $(packer_absdir)/platforms/centos/build.sh - ARCH=amd64 BEAT=$(@D) BUILD_DIR=${BUILD_DIR} UPLOAD_DIR=${UPLOAD_DIR} BEAT_PATH=$(beat_abspath) BUILDID=$(BUILDID) SNAPSHOT=$(SNAPSHOT) BEAT_REF_YAML=${BEAT_REF_YAML} $(packer_absdir)/platforms/centos/build.sh - -%/darwin: - echo Creating Darwin packages for $(@D) - ARCH=amd64 BEAT=$(@D) BUILD_DIR=${BUILD_DIR} UPLOAD_DIR=${UPLOAD_DIR} BEAT_PATH=$(beat_abspath) BUILDID=$(BUILDID) SNAPSHOT=$(SNAPSHOT) BEAT_REF_YAML=${BEAT_REF_YAML} $(packer_absdir)/platforms/darwin/build.sh - -%/win: - echo Creating Darwin packages for $(@D) - ARCH=386 BEAT=$(@D) BUILD_DIR=${BUILD_DIR} UPLOAD_DIR=${UPLOAD_DIR} BEAT_PATH=$(beat_abspath) BUILDID=$(BUILDID) SNAPSHOT=$(SNAPSHOT) BEAT_REF_YAML=${BEAT_REF_YAML} $(packer_absdir)/platforms/windows/build.sh - ARCH=amd64 BEAT=$(@D) BUILD_DIR=${BUILD_DIR} UPLOAD_DIR=${UPLOAD_DIR} BEAT_PATH=$(beat_abspath) BUILDID=$(BUILDID) SNAPSHOT=$(SNAPSHOT) BEAT_REF_YAML=${BEAT_REF_YAML} $(packer_absdir)/platforms/windows/build.sh - -%/bin: - echo Creating Linux packages for $(@D) - ARCH=386 BEAT=$(@D) BUILD_DIR=${BUILD_DIR} UPLOAD_DIR=${UPLOAD_DIR} BEAT_PATH=$(beat_abspath) BUILDID=$(BUILDID) SNAPSHOT=$(SNAPSHOT) BEAT_REF_YAML=${BEAT_REF_YAML} $(packer_absdir)/platforms/binary/build.sh - ARCH=amd64 BEAT=$(@D) BUILD_DIR=${BUILD_DIR} UPLOAD_DIR=${UPLOAD_DIR} BEAT_PATH=$(beat_abspath) BUILDID=$(BUILDID) SNAPSHOT=$(SNAPSHOT) BEAT_REF_YAML=${BEAT_REF_YAML} $(packer_absdir)/platforms/binary/build.sh - -%/arm: - echo Creating ARM packages for $(@D) - ARCH=arm BEAT=$(@D) BUILD_DIR=${BUILD_DIR} BEAT_PATH=$(beat_abspath) BUILDID=$(BUILDID) SNAPSHOT=$(SNAPSHOT) $(packer_absdir)/platforms/binary/build.sh - -.PHONY: package-dashboards -package-dashboards: - echo Creating the Dashboards package - UPLOAD_DIR=${UPLOAD_DIR} BUILDID=$(BUILDID) SNAPSHOT=$(SNAPSHOT) BEAT_REF_YAML=${BEAT_REF_YAML} $(packer_absdir)/platforms/dashboards/build.sh - -.PHONY: deps -deps: - cd ../vendor/github.com/tsg/gotpl; go install - -.PHONY: xgo-image -xgo-image: - cd $(packer_absdir)/docker/xgo-image/; ./build.sh - # copy build.sh script in the xgo-image-deb7 to avoid code duplication - cp $(packer_absdir)/docker/xgo-image/base/build.sh $(packer_absdir)/docker/xgo-image-deb7/base/build.sh - cd $(packer_absdir)/docker/xgo-image-deb7/; ./build.sh - -.PHONY: fpm-image -fpm-image: - docker build --rm=true -t tudorg/fpm $(packer_absdir)/docker/fpm-image - -.PHONY: go-daemon-image -go-daemon-image: - docker build --rm=true -t tudorg/go-daemon $(packer_absdir)/docker/go-daemon/ - -${BUILD_DIR}/god-linux-386 ${BUILD_DIR}/god-linux-amd64: - docker run --rm -v ${BUILD_DIR}:/build tudorg/go-daemon - -${UPLOAD_DIR}: - mkdir -p ${UPLOAD_DIR} - -${UPLOAD_DIR}/build_id.txt: - echo $(BUILDID) > ${UPLOAD_DIR}/build_id.txt - -# Build the image required for package-upload. -.PHONY: deb-rpm-s3 -deb-rpm-s3: - $(packer_absdir)/docker/deb-rpm-s3/build.sh - -.PHONY: run-interactive-builder-deb -run-interactive-builder-deb: - docker run -t -i -v $(shell pwd)/build:/build \ - -v $(shell pwd)/xgo-scripts/:/scripts \ - -v $(shell pwd)/../..:/source \ - --entrypoint=bash ${BEATS_BUILDER_DEB_IMAGE} - -.PHONY: run-interactive-builder -run-interactive-builder: - docker run -t -i -v $(shell pwd)/build:/build \ - -v $(packer_absdir)/xgo-scripts/:/scripts \ - -v $(shell pwd)/../..:/source \ - --entrypoint=bash ${BEATS_BUILDER_IMAGE} - -.PHONY: images -images: xgo-image fpm-image go-daemon-image - -.PHONY: push-images -push-images: - docker push ${BEATS_BUILDER_IMAGE} - docker push ${BEATS_BUILDER_DEB_IMAGE} - docker push tudorg/fpm - docker push tudorg/go-daemon - -.PHONY: pull-images -pull-images: - docker pull ${BEATS_BUILDER_IMAGE} - docker pull ${BEATS_BUILDER_DEB_IMAGE} - docker pull tudorg/fpm - docker pull tudorg/go-daemon - - -define rm-image = -@echo "Cleaning $(1) image..." - @if [ $(shell docker ps -n 1 -a -q --filter="image=$(1)" ) ]; then \ - docker stop $(shell docker ps -a -q --filter="image=$(1)"); \ - docker rm $(shell docker ps -a -q --filter="image=$(1)"); \ - fi; \ -\ - if [ $(shell docker images -q $(1)) ]; then \ - docker rmi $(1); \ - fi -endef - - -.PHONY: clean-images -clean-images: - @$(call rm-image, ${BEATS_BUILDER_DEB_IMAGE}) - @$(call rm-image, ${BEATS_BUILDER_IMAGE}) - -.PHONY: clean -clean: - $(call rm-image,build-image) diff --git a/_beats/dev-tools/packer/README.md b/_beats/dev-tools/packer/README.md deleted file mode 100644 index 9860d123e4..0000000000 --- a/_beats/dev-tools/packer/README.md +++ /dev/null @@ -1,96 +0,0 @@ -[![Build Status](https://travis-ci.org/elastic/beats-packer.svg)](https://travis-ci.org/elastic/beats-packer) - -# Beats Packer - -Tools, scripts and docker images for cross-compiling and packaging the Elastic -[Beats](https://www.elastic.co/products/beats). - -## Prepare - -You need Go and docker installed. This project uses several docker files, you -can either build them with: - - make images - -Or pull them from the Docker registry with: - - make pull-images - -Prepare the rest with: - - make deps - -## Cross-compile - -The cross compilation part is based on [xgo](https://github.com/karalabe/xgo), -with some [changes](https://github.com/tsg/xgo) that add a bit more -extensibility that we needed for the Beats (e.g. static compiling, custom -docker image). - -You can cross-compile one Beat for all platforms with (e.g.): - - make packetbeat - -## Packaging - -For each OS (named platform here) we execute a `build.sh` script which is -free to do whatever it is required to build the proper packages for that -platform. This can include running docker containers with the right tools -included or with that OS installed for native packaging. - -The deb and rpm creation is based on [fpm](https://github.com/jordansissel/fpm) -which is executed from a container. - -Besides the platform, there are three other dimensions: architecture, -beat and the release. Each of these is defined by YAML files in their folders. -These dimensions only set static options, the platforms is the only one -scripted. - -The runner is currently (ab)using a Makefile, which is nice because it can -parallelize things automatically, but it's hacky so we might replace it in -a future. - -Building all Beats for all platforms: - - make clean && make - -## Naming conventions - -We use a set of package name conventions across all the Elastic stack: - -* The general form is `name-version-os-arch.ext`. Note that this means we - use dashes even for Deb files. -* The archs are called `x86` and `x64` except for deb/rpm where we keep the - OS preferred names (i386/amd64, i686/x86_64). -* For version strings like `5.0.0-alpha3` we use dashes in all filenames. The - only exception is the RPM metadata (not the filename) where we replace the - dash with an underscore (`5.0.0_alpha3`). -* We omit the release number from the filenames. It's always `1` in the metadata. - -For example, here are the artifacts created for Filebeat: - -``` -filebeat-5.0.0-amd64.deb -filebeat-5.0.0-darwin-x86_64.tar.gz -filebeat-5.0.0-i386.deb -filebeat-5.0.0-i686.rpm -filebeat-5.0.0-linux-x86.tar.gz -filebeat-5.0.0-linux-x86_64.tar.gz -filebeat-5.0.0-windows-x86.zip -filebeat-5.0.0-windows-x86_64.zip -filebeat-5.0.0-x86_64.rpm -``` - -And the SNAPSHOT versions: - -``` -filebeat-5.0.0-SNAPSHOT-amd64.deb -filebeat-5.0.0-SNAPSHOT-darwin-x86_64.tar.gz -filebeat-5.0.0-SNAPSHOT-i386.deb -filebeat-5.0.0-SNAPSHOT-i686.rpm -filebeat-5.0.0-SNAPSHOT-linux-x86.tar.gz -filebeat-5.0.0-SNAPSHOT-linux-x86_64.tar.gz -filebeat-5.0.0-SNAPSHOT-windows-x86.zip -filebeat-5.0.0-SNAPSHOT-windows-x86_64.zip -filebeat-5.0.0-SNAPSHOT-x86_64.rpm -``` diff --git a/_beats/dev-tools/packer/archs/386.yml b/_beats/dev-tools/packer/archs/386.yml deleted file mode 100644 index 96f314538e..0000000000 --- a/_beats/dev-tools/packer/archs/386.yml +++ /dev/null @@ -1,5 +0,0 @@ -arch: '386' -deb_arch: i386 -rpm_arch: i686 -bin_arch: x86 -win_arch: x86 diff --git a/_beats/dev-tools/packer/archs/amd64.yml b/_beats/dev-tools/packer/archs/amd64.yml deleted file mode 100644 index 299012d851..0000000000 --- a/_beats/dev-tools/packer/archs/amd64.yml +++ /dev/null @@ -1,5 +0,0 @@ -arch: amd64 -deb_arch: amd64 -rpm_arch: x86_64 -bin_arch: x86_64 -win_arch: x86_64 diff --git a/_beats/dev-tools/packer/archs/arm.yml b/_beats/dev-tools/packer/archs/arm.yml deleted file mode 100644 index 4b2e2f35f6..0000000000 --- a/_beats/dev-tools/packer/archs/arm.yml +++ /dev/null @@ -1,2 +0,0 @@ -arch: 'arm' -bin_arch: arm diff --git a/_beats/dev-tools/packer/docker/deb-rpm-s3/.gitignore b/_beats/dev-tools/packer/docker/deb-rpm-s3/.gitignore deleted file mode 100644 index 78a9141e37..0000000000 --- a/_beats/dev-tools/packer/docker/deb-rpm-s3/.gitignore +++ /dev/null @@ -1 +0,0 @@ -elasticsearch.asc diff --git a/_beats/dev-tools/packer/docker/deb-rpm-s3/Dockerfile b/_beats/dev-tools/packer/docker/deb-rpm-s3/Dockerfile deleted file mode 100644 index fca7551a61..0000000000 --- a/_beats/dev-tools/packer/docker/deb-rpm-s3/Dockerfile +++ /dev/null @@ -1,38 +0,0 @@ -# Dockerfile for building an image that contains all of the necessary -# dependencies for signing deb/rpm packages and publishing APT and YUM -# repositories to Amazon S3. -FROM debian:jessie - -RUN apt-get update -RUN apt-get install -y git \ - rubygems ruby-dev patch gcc make zlib1g-dev rpm curl dpkg-sig \ - yum python-deltarpm \ - expect - -# Install python-boto from source to get latest version. -RUN git clone git://github.com/boto/boto.git && \ - cd boto && \ - git checkout 2.38.0 && \ - python setup.py install - -# Install deb-s3 -RUN gem install deb-s3 - -# Install rpm-s3 -# WARNING: Pulling from master, may not be repeatable. -RUN cd /usr/local && \ - git clone https://github.com/crohr/rpm-s3 --recursive && \ - echo '[s3]\ncalling_format = boto.s3.connection.OrdinaryCallingFormat' > /etc/boto.cfg - # Use HTTP for debugging traffic to S3. - #echo '[Boto]\nis_secure = False' >> /etc/boto.cfg -ENV PATH /usr/local/rpm-s3/bin:$PATH -ADD rpmmacros /root/.rpmmacros - -# Add the scripts that are executed by within the container. -ADD *.expect / -ADD publish-package-repositories.sh / - -# Execute the publish-package-repositories.sh when the container -# is run. -ENTRYPOINT ["/publish-package-repositories.sh"] -CMD ["--help"] diff --git a/_beats/dev-tools/packer/docker/deb-rpm-s3/build.sh b/_beats/dev-tools/packer/docker/deb-rpm-s3/build.sh deleted file mode 100755 index e5a2537201..0000000000 --- a/_beats/dev-tools/packer/docker/deb-rpm-s3/build.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash -set -e - -# -# Build script for the deb-rpm-s3 docker container. -# - -cd "$(dirname "$0")" - -docker build -t deb-rpm-s3 . diff --git a/_beats/dev-tools/packer/docker/deb-rpm-s3/deb-rpm-s3.sh b/_beats/dev-tools/packer/docker/deb-rpm-s3/deb-rpm-s3.sh deleted file mode 100755 index bd0ed1c269..0000000000 --- a/_beats/dev-tools/packer/docker/deb-rpm-s3/deb-rpm-s3.sh +++ /dev/null @@ -1,45 +0,0 @@ -#!/bin/bash - -# -# Wrapper script for starting the docker container. -# -# You must set AWS_ACCESS_KEY and AWS_SECRET_KEY in your environment prior to -# running. You can optionally pass the GPG key's passphrase as the environment -# variable PASS. -# - -cd "$(dirname "$0")" - -if [ ! -e "elasticsearch.asc" ]; then - cat << EOF -You must place a copy of the Elasticsearch GPG signing key (named -elasticsearch.asc) into - - $PWD - -prior to building this docker image. - -EOF - exit 1 -fi - -bucket="packages.elasticsearch.org" -prefix="beats" -dir="/beats-packer/build/upload" -gpg_key="/beats-packer/dev-tools/packer/docker/deb-rpm-s3/elasticsearch.asc" -origin=Elastic - -docker run -it --rm \ - --env="PASS=$PASS" \ - --volume `pwd`/../../../..:/beats-packer \ - deb-rpm-s3 \ - --bucket=$bucket \ - --prefix=$prefix \ - --directory="$dir" \ - --aws-access-key="$AWS_ACCESS_KEY" \ - --aws-secret-key="$AWS_SECRET_KEY" \ - --gpg-key="$gpg_key" \ - --origin="$origin" \ - --verbose \ - "$@" - diff --git a/_beats/dev-tools/packer/docker/deb-rpm-s3/deb-s3.expect b/_beats/dev-tools/packer/docker/deb-rpm-s3/deb-s3.expect deleted file mode 100644 index ea6b146ab7..0000000000 --- a/_beats/dev-tools/packer/docker/deb-rpm-s3/deb-s3.expect +++ /dev/null @@ -1,19 +0,0 @@ -#!/usr/bin/expect -f - -# Expect wrapper for deb-s3 that provides the GPG signing password -# when prompted. - -spawn deb-s3 upload \ - --sign \ - --preserve_versions \ - --bucket "$env(BUCKET)" \ - --prefix "$env(PREFIX)/apt" \ - --arch $env(arch) \ - -o "$env(ORIGIN)" \ - {*}$argv -expect { - "Enter passphrase: " { - send -- "$env(PASS)\r" - exp_continue - } -} diff --git a/_beats/dev-tools/packer/docker/deb-rpm-s3/debsign.expect b/_beats/dev-tools/packer/docker/deb-rpm-s3/debsign.expect deleted file mode 100755 index c3bcac3f0e..0000000000 --- a/_beats/dev-tools/packer/docker/deb-rpm-s3/debsign.expect +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/expect -f - -# Expect wrapper for 'dpkg-sig --sign' that provides the GPG signing password -# when prompted. -# -# Set password in PASS environment variable prior to running -# this expect script. -# -# Example usage: -# expect debsign.expect example.deb -# -# expect debsign.expect example.deb other.deb - -spawn dpkg-sig --sign builder {*}$argv -expect { - "Enter passphrase: " { - send -- "$env(PASS)\r" - exp_continue - } -} diff --git a/_beats/dev-tools/packer/docker/deb-rpm-s3/publish-package-repositories.sh b/_beats/dev-tools/packer/docker/deb-rpm-s3/publish-package-repositories.sh deleted file mode 100755 index cc531aee39..0000000000 --- a/_beats/dev-tools/packer/docker/deb-rpm-s3/publish-package-repositories.sh +++ /dev/null @@ -1,226 +0,0 @@ -#!/bin/bash -set -e - -# Script directory: -SDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" - -usage() { -cat << EOF - Usage: $(basename $0) [-vh] [-d=directory] [-b=bucket] [-p=prefix] - [--access-key-id=aws id] [--secret-key-id=aws secret] - - Description: Sign packages and publish them to APT and YUM repositories - hosted from an S3 bucket. When publishing, the repository metadata is - also signed to prevent tampering. - - You will be prompted once for the GPG signing key's password. If the - PASS environment variable is set then that value will be used and you - will not be prompted. - - Options: - --aws-access-key=AWS_ACCESS_KEY Required. AWS access key. Alternatively, - AWS_ACCESS_KEY may be set as an environment - variable. - - --aws-secret-key=AWS_SECRET_KEY Required. AWS secret key. Alternatively, - AWS_SECRET_KEY may be set as an environment - variable. - - -b=BUCKET | --bucket=BUCKET Required. The S3 bucket in which to publish. - - -p=PREFIX | --prefix=PREFIX Required. Path to prefix to all published - repositories. - - -d=DIR | --directory=DIR Required. Directory to recursively search - for .rpm and .deb files. - - -g=GPG_KEY | --gpg-key=GPG_KEY Optional. Path to GPG key file to import. - - -o=ORIGIN | --origin=ORIGIN Optional. Origin to use in APT repo metadata. - - -v | --verbose Optional. Enable verbose logging to stderr. - - -h | --help Optional. Print this usage information. -EOF -} - -# Write a debug message to stderr. -debug() -{ - if [ "$VERBOSE" == "true" ]; then - echo "DEBUG: $1" >&2 - fi -} - -# Write and error message to stderr. -err() -{ - echo "ERROR: $1" >&2 -} - -# Parse command line arguments. -parseArgs() { - for i in "$@" - do - case $i in - --aws-access-key=*) - AWS_ACCESS_KEY="${i#*=}" - shift - ;; - --aws-secret-key=*) - AWS_SECRET_KEY="${i#*=}" - shift - ;; - -b=*|--bucket=*) - BUCKET="${i#*=}" - shift - ;; - -d=*|--directory=*) - DIRECTORY="${i#*=}" - shift - ;; - -g=*|--gpg-key=*) - GPG_KEY="${i#*=}" - shift - ;; - -h|--help) - usage - exit 1 - ;; - -o=*|--origin=*) - ORIGIN="${i#*=}" - shift - ;; - -p=*|--prefix=*) - PREFIX="${i#*=}" - shift - ;; - -v|--verbose) - VERBOSE=true - shift - ;; - *) - echo "Invalid argument: $i" - usage - exit 1 - ;; - esac - done - - if [ -z "$BUCKET" ]; then - err "-b=BUCKET or --bucket=BUCKET is required." - exit 1 - fi - - if [ -z "$DIRECTORY" ]; then - err "-d=DIRECTORY or --directory=DIRECTORY is required." - exit 1 - fi - - if [ ! -e "$DIRECTORY" ]; then - err "Directory $DIRECTORY does not exists." - exit 1 - fi - - if [ -z "$PREFIX" ]; then - err "-p=PREFIX or --prefix=PREFIX is required." - exit 1 - fi - - if [ -z "$AWS_ACCESS_KEY" ]; then - err "--access-key-id=AWS_ACCESS_KEY is required." - exit 1 - fi - - if [ -z "$AWS_SECRET_KEY" ]; then - err "--secret-access-key-id=AWS_SECRET_KEY is required." - exit 1 - fi - - export BUCKET - export ORIGIN - export PREFIX - export AWS_ACCESS_KEY - export AWS_SECRET_KEY -} - -importGpg() { - if [ ! -z "$GPG_KEY" ]; then - if [ ! -f "$GPG_KEY" ]; then - err "GPG key file $GPG_KEY does not exists." - exit 1 - fi - - debug "Importing GPG key $GPG_KEY" - gpg --import --allow-secret-key-import "$GPG_KEY" | true - else - debug "Not importing a GPG key because --gpg-key not specified." - fi -} - -getPassword() { - if [ -z "$PASS" ]; then - echo -n "Enter GPG pass phrase: " - read -s PASS - fi - - export PASS -} - -signDebianPackages() { - debug "Entering signDebianPackages" - find $DIRECTORY -name '*.deb' | xargs expect $SDIR/debsign.expect - debug "Exiting signDebianPackages" -} - -signRpmPackages() { - debug "Entering signRpmPackages" - find $DIRECTORY -name '*.rpm' | xargs expect $SDIR/rpmsign.expect - debug "Exiting signRpmPackages" -} - -publishToAptRepo() { - debug "Entering publishToAptRepo" - - # Verify the repository and credentials before continuing. - deb-s3 verify --bucket "$BUCKET" --prefix "${PREFIX}/apt" - - for arch in i386 amd64 - do - debug "Publishing $arch .deb packages..." - export arch - - for deb in $(find "$DIRECTORY" -name "*${arch}.deb") - do - expect $SDIR/deb-s3.expect "$deb" - done - done -} - -publishToYumRepo() { - debug "Entering publishToYumRepo" - - for arch in i686 x86_64 - do - debug "Publishing $arch .rpm packages..." - export arch - - for rpm in $(find "$DIRECTORY" -name "*${arch}.rpm") - do - expect $SDIR/rpm-s3.expect "$rpm" - done - done -} - -main() { - parseArgs $* - importGpg - getPassword - signDebianPackages - signRpmPackages - publishToAptRepo - publishToYumRepo - debug "Success" -} - -main $* diff --git a/_beats/dev-tools/packer/docker/deb-rpm-s3/rpm-s3.expect b/_beats/dev-tools/packer/docker/deb-rpm-s3/rpm-s3.expect deleted file mode 100644 index 246785f6ea..0000000000 --- a/_beats/dev-tools/packer/docker/deb-rpm-s3/rpm-s3.expect +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/expect -f - -# Expect wrapper for rpm-s3 that provides the GPG signing password -# when prompted. - -spawn rpm-s3 \ - -vv \ - --sign \ - --region=external-1 \ - --keep=500 \ - --visibility=public-read \ - --bucket=$env(BUCKET) \ - --repopath=$env(PREFIX)/yum/el/$env(arch) \ - {*}$argv -expect { - "Enter passphrase: " { - send -- "$env(PASS)\r" - exp_continue - } -} diff --git a/_beats/dev-tools/packer/docker/deb-rpm-s3/rpmmacros b/_beats/dev-tools/packer/docker/deb-rpm-s3/rpmmacros deleted file mode 100644 index 2408b6c189..0000000000 --- a/_beats/dev-tools/packer/docker/deb-rpm-s3/rpmmacros +++ /dev/null @@ -1,2 +0,0 @@ -%_signature gpg -%_gpg_name Elasticsearch (Elasticsearch Signing Key) diff --git a/_beats/dev-tools/packer/docker/deb-rpm-s3/rpmsign.expect b/_beats/dev-tools/packer/docker/deb-rpm-s3/rpmsign.expect deleted file mode 100755 index d60da47e8b..0000000000 --- a/_beats/dev-tools/packer/docker/deb-rpm-s3/rpmsign.expect +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/expect -f - -# Expect wrapper for 'rpm --resign' that provides the GPG signing password -# when prompted. -# -# Set password in PASS environment variable prior to running -# this expect script. -# -# Example usage: -# expect rpmsign.expect example.rpm -# -# expect rpmsign.expect example.rpm other.rpm - -spawn rpm --resign \ - --define "_signature gpg" \ - --define "_gpg_name Elasticsearch (Elasticsearch Signing Key) " \ - {*}$argv -expect -exact "Enter pass phrase: " -send -- "$env(PASS)\r" -expect eof diff --git a/_beats/dev-tools/packer/docker/fpm-image/Dockerfile b/_beats/dev-tools/packer/docker/fpm-image/Dockerfile deleted file mode 100644 index 1d8be72276..0000000000 --- a/_beats/dev-tools/packer/docker/fpm-image/Dockerfile +++ /dev/null @@ -1,11 +0,0 @@ -FROM ubuntu:16.04 - -MAINTAINER Tudor Golubenco - -# install fpm -RUN \ - apt-get update && \ - apt-get install -y --no-install-recommends \ - autoconf build-essential libffi-dev ruby-dev rpm zip dos2unix libgmp3-dev - -RUN gem install fpm -v 1.9.2 diff --git a/_beats/dev-tools/packer/docker/go-daemon/Dockerfile b/_beats/dev-tools/packer/docker/go-daemon/Dockerfile deleted file mode 100644 index 99d13c0d5c..0000000000 --- a/_beats/dev-tools/packer/docker/go-daemon/Dockerfile +++ /dev/null @@ -1,10 +0,0 @@ -FROM tudorg/xgo-base - -MAINTAINER Tudor Golubenco - -# Inject the build script -ADD build_go_daemon.sh /build_go_daemon.sh -ENV BUILD_GO_DAEMON /build_go_daemon.sh -RUN chmod +x $BUILD_GO_DAEMON - -ENTRYPOINT ["/build_go_daemon.sh"] diff --git a/_beats/dev-tools/packer/docker/go-daemon/build_go_daemon.sh b/_beats/dev-tools/packer/docker/go-daemon/build_go_daemon.sh deleted file mode 100644 index b5ace90659..0000000000 --- a/_beats/dev-tools/packer/docker/go-daemon/build_go_daemon.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/bash - -set -e - -echo "Fetching go-daemon" -git clone https://github.com/tsg/go-daemon.git - -cd /go-daemon - -echo "Compiling for linux/amd64.." -cc god.c -m64 -o god-linux-amd64 -lpthread -static - -echo "Compiling for linux/i386.." -gcc god.c -m32 -o god-linux-386 -lpthread -static - -echo "Copying to host.." -cp god-linux-amd64 god-linux-386 /build/ diff --git a/_beats/dev-tools/packer/docker/xgo-image-deb7/.gitignore b/_beats/dev-tools/packer/docker/xgo-image-deb7/.gitignore deleted file mode 100644 index 29554abab0..0000000000 --- a/_beats/dev-tools/packer/docker/xgo-image-deb7/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -beats-builder/yaml.v2 -beats-builder/gotpl diff --git a/_beats/dev-tools/packer/docker/xgo-image-deb7/base/Dockerfile b/_beats/dev-tools/packer/docker/xgo-image-deb7/base/Dockerfile deleted file mode 100644 index 62a57d770a..0000000000 --- a/_beats/dev-tools/packer/docker/xgo-image-deb7/base/Dockerfile +++ /dev/null @@ -1,49 +0,0 @@ -# Go cross compiler (xgo): Base cross-compilation layer -# Copyright (c) 2014 Péter Szilágyi. All rights reserved. -# -# Released under the MIT license. - -FROM debian:7 - -MAINTAINER Tudor Golubenco - -# Configure the Go environment, since it's not going to change -ENV PATH /usr/local/go/bin:$PATH -ENV GOPATH /go - - -# Inject the remote file fetcher and checksum verifier -ADD fetch.sh /fetch.sh -ENV FETCH /fetch.sh -RUN chmod +x $FETCH - - -# Make sure apt-get is up to date and dependent packages are installed -RUN \ - apt-get update && \ - apt-get install -y automake autogen build-essential ca-certificates \ - gcc-multilib \ - clang llvm-dev libtool libxml2-dev uuid-dev libssl-dev pkg-config \ - patch make xz-utils cpio wget unzip git mercurial bzr rsync --no-install-recommends - -# Inject the Go package downloader and tool-chain bootstrapper -ADD bootstrap.sh /bootstrap.sh -ENV BOOTSTRAP /bootstrap.sh -RUN chmod +x $BOOTSTRAP - -# Inject the new Go root distribution downloader and secondary bootstrapper -ADD bootstrap_pure.sh /bootstrap_pure.sh -ENV BOOTSTRAP_PURE /bootstrap_pure.sh -RUN chmod +x $BOOTSTRAP_PURE - -# Inject the C dependency cross compiler -ADD build_deps.sh /build_deps.sh -ENV BUILD_DEPS /build_deps.sh -RUN chmod +x $BUILD_DEPS - -# Inject the container entry point, the build script -ADD build.sh /build.sh -ENV BUILD /build.sh -RUN chmod +x $BUILD - -ENTRYPOINT ["/build.sh"] diff --git a/_beats/dev-tools/packer/docker/xgo-image-deb7/base/bootstrap.sh b/_beats/dev-tools/packer/docker/xgo-image-deb7/base/bootstrap.sh deleted file mode 100644 index ce0817756e..0000000000 --- a/_beats/dev-tools/packer/docker/xgo-image-deb7/base/bootstrap.sh +++ /dev/null @@ -1,31 +0,0 @@ -#!/bin/bash -# -# Contains the Go tool-chain bootstrapper, that retrieves all the configured -# distribution packages, extracts the binaries and deletes anything not needed. -# -# Usage: bootstrap.sh -# -# Needed environment variables: -# FETCH - Remote file fetcher and checksum verifier (injected by image) -# DIST_LINUX_64, DIST_LINUX_64_SHA1 - 64 bit Linux Go binaries and checksum -# DIST_LINUX_32, DIST_LINUX_32_SHA1 - 32 bit Linux Go binaries and checksum -# DIST_LINUX_ARM, DIST_LINUX_ARM_SHA1 - ARM v5 Linux Go binaries and checksum -# DIST_OSX_64, DIST_OSX_64_SHA1 - 64 bit Mac OSX Go binaries and checksum -# DIST_OSX_32, DIST_OSX_32_SHA1 - 32 bit Mac OSX Go binaries and checksum -# DIST_WIN_64, DIST_WIN_64_SHA1 - 64 bit Windows Go binaries and checksum -# DIST_WIN_32, DIST_WIN_32_SHA1 - 32 bit Windows Go binaries and checksum -set -e - -# Download and verify all the binary packages -$FETCH $DIST_LINUX_64 $DIST_LINUX_64_SHA1 -$FETCH $DIST_LINUX_32 $DIST_LINUX_32_SHA1 - -# Extract the 64 bit Linux package as the primary Go SDK -tar -C /usr/local -xzf `basename $DIST_LINUX_64` - -# Extract all other packages as secondary ones, keeping only the binaries -tar -C /usr/local --wildcards -xzf `basename $DIST_LINUX_32` go/pkg/linux_386* -GOOS=linux GOARCH=386 /usr/local/go/pkg/tool/linux_amd64/dist bootstrap - -# Delete all the intermediate downloaded files -rm -f `basename $DIST_LINUX_64` `basename $DIST_LINUX_32` diff --git a/_beats/dev-tools/packer/docker/xgo-image-deb7/base/bootstrap_pure.sh b/_beats/dev-tools/packer/docker/xgo-image-deb7/base/bootstrap_pure.sh deleted file mode 100644 index aa40cd40b7..0000000000 --- a/_beats/dev-tools/packer/docker/xgo-image-deb7/base/bootstrap_pure.sh +++ /dev/null @@ -1,26 +0,0 @@ -#!/bin/bash -# -# Contains the Go tool-chain pure-Go bootstrapper, that as of Go 1.5, initiates -# not only a few pre-built Go cross compilers, but rather bootstraps all of the -# supported platforms from the origin Linux amd64 distribution. -# -# Usage: bootstrap.sh -# -# Needed environment variables: -# FETCH - Remote file fetcher and checksum verifier (injected by image) -# ROOT_DIST - 64 bit Linux Go binary distribution package -# ROOT_DIST_SHA1 - 64 bit Linux Go distribution package checksum -set -e - -# Download, verify and install the root distribution -$FETCH $ROOT_DIST $ROOT_DIST_SHA1 - -tar -C /usr/local -xzf `basename $ROOT_DIST` -rm -f `basename $ROOT_DIST` - -export GOROOT=/usr/local/go -export GOROOT_BOOTSTRAP=$GOROOT - -# Pre-build all guest distributions based on the root distribution -echo "Bootstrapping linux/386..." -GOOS=linux GOARCH=386 CGO_ENABLED=1 go install std diff --git a/_beats/dev-tools/packer/docker/xgo-image-deb7/base/build_deps.sh b/_beats/dev-tools/packer/docker/xgo-image-deb7/base/build_deps.sh deleted file mode 100644 index e6445b95ed..0000000000 --- a/_beats/dev-tools/packer/docker/xgo-image-deb7/base/build_deps.sh +++ /dev/null @@ -1,36 +0,0 @@ -#!/bin/bash -# -# Contains the dependency builder to iterate over all installed dependencies -# and cross compile them to the requested target platform. -# -# Usage: build_deps.sh dependency_root_folder dependency1 dependency_2 ... -# -# Needed environment variables: -# CC - C cross compiler to use for the build -# HOST - Target platform to build (used to find the needed tool-chains) -# PREFIX - File-system path where to install the built binaries -# STATIC - true if the libraries are statically linked to the go application -set -e - -DEP_ROOT_FOLDER=$1 - -# Remove any previous build leftovers, and copy a fresh working set (clean doesn't work for cross compiling) -rm -rf /deps-build && cp -r $DEP_ROOT_FOLDER /deps-build - -args=("$@") - -if [ "$STATIC" == "true" ]; then DISABLE_SHARED=-disable-shared; fi - -# Build all the dependencies -for ((i=1; i<${#args[@]}; i++)); do - dep=${args[i]} - echo "Configuring dependency $dep for $HOST..." - if [ -f "/deps-build/$dep/autogen.sh" ]; then (cd /deps-build/$dep && ./autogen.sh); fi - (cd /deps-build/$dep && ./configure $DISABLE_SHARED --host=$HOST --prefix=$PREFIX --silent) - - echo "Building dependency $dep for $HOST..." - (cd /deps-build/$dep && make --silent -j install) -done - -# Remove any build artifacts -rm -rf /deps-build diff --git a/_beats/dev-tools/packer/docker/xgo-image-deb7/base/fetch.sh b/_beats/dev-tools/packer/docker/xgo-image-deb7/base/fetch.sh deleted file mode 100644 index baeae631f1..0000000000 --- a/_beats/dev-tools/packer/docker/xgo-image-deb7/base/fetch.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/bash -# -# Contains a simple fetcher to download a file from a remote URL and verify its -# SHA1 checksum. -# -# Usage: fetch.sh -set -e - -# Pull the file from the remote URL -file=`basename $1` -echo "Downloading $1..." -wget --no-check-certificate -q $1 - -# Generate a desired checksum report and check against it -echo "$2 $file" > $file.sum -sha1sum -c $file.sum -rm $file.sum diff --git a/_beats/dev-tools/packer/docker/xgo-image-deb7/beats-builder/Dockerfile b/_beats/dev-tools/packer/docker/xgo-image-deb7/beats-builder/Dockerfile deleted file mode 100644 index 20800e5b27..0000000000 --- a/_beats/dev-tools/packer/docker/xgo-image-deb7/beats-builder/Dockerfile +++ /dev/null @@ -1,33 +0,0 @@ -FROM tudorg/xgo-deb7-1.10.2 - -MAINTAINER Tudor Golubenco - -# Get libpcap-32 binaries from a DEB file -RUN \ - mkdir -p /libpcap && \ - wget http://archive.debian.org/debian/pool/main/libp/libpcap/libpcap0.8-dev_1.1.1-2+squeeze1_i386.deb && \ - dpkg -x libpcap0.8-dev_*_i386.deb /libpcap/i386 && \ - rm libpcap0.8-dev*.deb - -# Get libpcap-64 binaries by compiling from source -RUN \ - apt-get update && \ - apt-get install -y flex bison -RUN ./fetch.sh http://www.tcpdump.org/release/libpcap-1.8.1.tar.gz 32d7526dde8f8a2f75baf40c01670602aeef7e39 && \ - mkdir -p /libpcap/amd64 && \ - tar -C /libpcap/amd64/ -xvf libpcap-1.8.1.tar.gz && \ - cd /libpcap/amd64/libpcap-1.8.1 && \ - ./configure --enable-usb=no --enable-bluetooth=no --enable-dbus=no && \ - make - -# Old git version which does not support proxy with go get directly, and git cloning -# from github also no longer works. -ADD yaml.v2 /go/src/gopkg.in/yaml.v2 -ADD gotpl /go/src/github.com/tsg/gotpl - -# Load gotpl which is needed for creating the templates. -RUN cd /go/src/github.com/tsg/gotpl && \ - go install - -# add patch for gopacket -ADD gopacket_pcap.patch /gopacket_pcap.patch diff --git a/_beats/dev-tools/packer/docker/xgo-image-deb7/beats-builder/gopacket_pcap.patch b/_beats/dev-tools/packer/docker/xgo-image-deb7/beats-builder/gopacket_pcap.patch deleted file mode 100644 index cc7592b7de..0000000000 --- a/_beats/dev-tools/packer/docker/xgo-image-deb7/beats-builder/gopacket_pcap.patch +++ /dev/null @@ -1,26 +0,0 @@ -diff --git a/vendor/github.com/tsg/gopacket/pcap/pcap.go b/vendor/github.com/tsg/gopacket/pcap/pcap.go -index f5612e6..0c77efa 100644 ---- a/vendor/github.com/tsg/gopacket/pcap/pcap.go -+++ b/vendor/github.com/tsg/gopacket/pcap/pcap.go -@@ -8,14 +8,17 @@ - package pcap - - /* --#cgo linux LDFLAGS: -lpcap -+#cgo linux,386 CFLAGS: -I/libpcap/i386/usr/include/ -+#cgo linux,386 LDFLAGS: -L/libpcap/i386/usr/lib/ -lpcap -+#cgo linux,amd64 CFLAGS: -I/libpcap/amd64/libpcap-1.8.1 -+#cgo linux,amd64 LDFLAGS: -L/libpcap/amd64/libpcap-1.8.1 -lpcap - #cgo freebsd LDFLAGS: -lpcap - #cgo openbsd LDFLAGS: -lpcap - #cgo darwin LDFLAGS: -lpcap - #cgo solaris LDFLAGS: -lpcap --#cgo windows CFLAGS: -I C:/WpdPack/Include --#cgo windows,386 LDFLAGS: -L C:/WpdPack/Lib -lwpcap --#cgo windows,amd64 LDFLAGS: -L C:/WpdPack/Lib/x64 -lwpcap -+#cgo windows CFLAGS: -I/libpcap/win/WpdPack/Include -+#cgo windows,386 LDFLAGS: -L/libpcap/win/WpdPack/Lib -lwpcap -+#cgo windows,amd64 LDFLAGS: -L/libpcap/win/WpdPack/Lib/x64 -lwpcap - #include - #include - diff --git a/_beats/dev-tools/packer/docker/xgo-image-deb7/build.sh b/_beats/dev-tools/packer/docker/xgo-image-deb7/build.sh deleted file mode 100755 index 8791ddf6a3..0000000000 --- a/_beats/dev-tools/packer/docker/xgo-image-deb7/build.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh -cp -r ../../../vendor/gopkg.in/yaml.v2 beats-builder/yaml.v2 -cp -r ../../../vendor/github.com/tsg/gotpl beats-builder/gotpl -docker build --rm=true -t tudorg/xgo-deb7-base base/ && \ - docker build --rm=true -t tudorg/xgo-deb7-1.10.2 go-1.10.2/ && - docker build --rm=true -t tudorg/beats-builder-deb7 beats-builder diff --git a/_beats/dev-tools/packer/docker/xgo-image-deb7/go-1.10.2/Dockerfile b/_beats/dev-tools/packer/docker/xgo-image-deb7/go-1.10.2/Dockerfile deleted file mode 100644 index 5f83f7780a..0000000000 --- a/_beats/dev-tools/packer/docker/xgo-image-deb7/go-1.10.2/Dockerfile +++ /dev/null @@ -1,15 +0,0 @@ -# Go cross compiler (xgo): Go 1.10.2 layer -# Copyright (c) 2014 Péter Szilágyi. All rights reserved. -# -# Released under the MIT license. - -FROM tudorg/xgo-deb7-base - -MAINTAINER Tudor Golubenco - -# Configure the root Go distribution and bootstrap based on it -RUN \ - export ROOT_DIST="https://storage.googleapis.com/golang/go1.10.2.linux-amd64.tar.gz" && \ - export ROOT_DIST_SHA1="77f0ac48994946c0d3349baf2d973ed6decb15ca" && \ - \ - $BOOTSTRAP_PURE diff --git a/_beats/dev-tools/packer/docker/xgo-image/.gitignore b/_beats/dev-tools/packer/docker/xgo-image/.gitignore deleted file mode 100644 index 29554abab0..0000000000 --- a/_beats/dev-tools/packer/docker/xgo-image/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -beats-builder/yaml.v2 -beats-builder/gotpl diff --git a/_beats/dev-tools/packer/docker/xgo-image/base/Dockerfile b/_beats/dev-tools/packer/docker/xgo-image/base/Dockerfile deleted file mode 100644 index 81ea1eb447..0000000000 --- a/_beats/dev-tools/packer/docker/xgo-image/base/Dockerfile +++ /dev/null @@ -1,76 +0,0 @@ -# Go cross compiler (xgo): Base cross-compilation layer -# Copyright (c) 2014 Péter Szilágyi. All rights reserved. -# -# Released under the MIT license. - -FROM ubuntu:14.04 - -MAINTAINER Tudor Golubenco - -# Configure the Go environment, since it's not going to change -ENV PATH /usr/local/go/bin:$PATH -ENV GOPATH /go - - -# Inject the remote file fetcher and checksum verifier -ADD fetch.sh /fetch.sh -ENV FETCH /fetch.sh -RUN chmod +x $FETCH - - -# Make sure apt-get is up to date and dependent packages are installed -# XXX: The first line is a workaround for the "Sum hash mismatch" error, from here: -# https://askubuntu.com/questions/760574/sudo-apt-get-update-failes-due-to-hash-sum-mismatch -RUN \ - apt-get clean && \ - apt-get update && \ - apt-get install -y automake autogen build-essential ca-certificates \ - gcc-arm-linux-gnueabi g++-arm-linux-gnueabi libc6-dev-armel-cross \ - gcc-multilib g++-multilib mingw-w64 clang llvm-dev \ - libtool libxml2-dev uuid-dev libssl-dev swig pkg-config patch \ - make xz-utils cpio wget zip unzip p7zip git mercurial bzr texinfo help2man \ - binutils-multiarch rsync \ - --no-install-recommends - -# Configure the container for OSX cross compilation -ENV OSX_SDK MacOSX10.11.sdk -ENV OSX_NDK_X86 /usr/local/osx-ndk-x86 - -RUN \ - OSX_SDK_PATH=https://github.com/phracker/MacOSX-SDKs/releases/download/MacOSX10.11.sdk/MacOSX10.11.sdk.tar.xz && \ - $FETCH $OSX_SDK_PATH f3430e3d923644e66c0c13f7a48754e7b6aa2e3f && \ - \ - git clone https://github.com/tpoechtrager/osxcross.git && \ - mv `basename $OSX_SDK_PATH` /osxcross/tarballs/ && \ - \ - sed -i -e 's|-march=native||g' /osxcross/build_clang.sh /osxcross/wrapper/build.sh && \ - UNATTENDED=yes OSX_VERSION_MIN=10.6 /osxcross/build.sh && \ - mv /osxcross/target $OSX_NDK_X86 && \ - \ - rm -rf /osxcross - -ADD patch.tar.xz $OSX_NDK_X86/SDK/$OSX_SDK/usr/include/c++ -ENV PATH $OSX_NDK_X86/bin:$PATH - - -# Inject the Go package downloader and tool-chain bootstrapper -ADD bootstrap.sh /bootstrap.sh -ENV BOOTSTRAP /bootstrap.sh -RUN chmod +x $BOOTSTRAP - -# Inject the new Go root distribution downloader and secondary bootstrapper -ADD bootstrap_pure.sh /bootstrap_pure.sh -ENV BOOTSTRAP_PURE /bootstrap_pure.sh -RUN chmod +x $BOOTSTRAP_PURE - -# Inject the C dependency cross compiler -ADD build_deps.sh /build_deps.sh -ENV BUILD_DEPS /build_deps.sh -RUN chmod +x $BUILD_DEPS - -# Inject the container entry point, the build script -ADD build.sh /build.sh -ENV BUILD /build.sh -RUN chmod +x $BUILD - -ENTRYPOINT ["/build.sh"] diff --git a/_beats/dev-tools/packer/docker/xgo-image/base/bootstrap.sh b/_beats/dev-tools/packer/docker/xgo-image/base/bootstrap.sh deleted file mode 100644 index b0d44a05a3..0000000000 --- a/_beats/dev-tools/packer/docker/xgo-image/base/bootstrap.sh +++ /dev/null @@ -1,48 +0,0 @@ -#!/bin/bash -# -# Contains the Go tool-chain bootstrapper, that retrieves all the configured -# distribution packages, extracts the binaries and deletes anything not needed. -# -# Usage: bootstrap.sh -# -# Needed environment variables: -# FETCH - Remote file fetcher and checksum verifier (injected by image) -# DIST_LINUX_64, DIST_LINUX_64_SHA1 - 64 bit Linux Go binaries and checksum -# DIST_LINUX_32, DIST_LINUX_32_SHA1 - 32 bit Linux Go binaries and checksum -# DIST_LINUX_ARM, DIST_LINUX_ARM_SHA1 - ARM v5 Linux Go binaries and checksum -# DIST_OSX_64, DIST_OSX_64_SHA1 - 64 bit Mac OSX Go binaries and checksum -# DIST_OSX_32, DIST_OSX_32_SHA1 - 32 bit Mac OSX Go binaries and checksum -# DIST_WIN_64, DIST_WIN_64_SHA1 - 64 bit Windows Go binaries and checksum -# DIST_WIN_32, DIST_WIN_32_SHA1 - 32 bit Windows Go binaries and checksum -set -e - -# Download and verify all the binary packages -$FETCH $DIST_LINUX_64 $DIST_LINUX_64_SHA1 -$FETCH $DIST_LINUX_32 $DIST_LINUX_32_SHA1 -$FETCH $DIST_OSX_64 $DIST_OSX_64_SHA1 -$FETCH $DIST_WIN_64 $DIST_WIN_64_SHA1 -$FETCH $DIST_WIN_32 $DIST_WIN_32_SHA1 - -# Extract the 64 bit Linux package as the primary Go SDK -tar -C /usr/local -xzf `basename $DIST_LINUX_64` - -# Extract all other packages as secondary ones, keeping only the binaries -tar -C /usr/local --wildcards -xzf `basename $DIST_LINUX_32` go/pkg/linux_386* -GOOS=linux GOARCH=386 /usr/local/go/pkg/tool/linux_amd64/dist bootstrap -tar -C /usr/local --wildcards -xzf `basename $DIST_LINUX_ARM` go/pkg/linux_arm* -GOOS=linux GOARCH=arm /usr/local/go/pkg/tool/linux_amd64/dist bootstrap - -tar -C /usr/local --wildcards -xzf `basename $DIST_OSX_64` go/pkg/darwin_amd64* -GOOS=darwin GOARCH=amd64 /usr/local/go/pkg/tool/linux_amd64/dist bootstrap -tar -C /usr/local --wildcards -xzf `basename $DIST_OSX_32` go/pkg/darwin_386* -GOOS=darwin GOARCH=386 /usr/local/go/pkg/tool/linux_amd64/dist bootstrap - -unzip -d /usr/local -q `basename $DIST_WIN_64` go/pkg/windows_amd64* -GOOS=windows GOARCH=amd64 /usr/local/go/pkg/tool/linux_amd64/dist bootstrap -unzip -d /usr/local -q `basename $DIST_WIN_32` go/pkg/windows_386* -GOOS=windows GOARCH=386 /usr/local/go/pkg/tool/linux_amd64/dist bootstrap - -# Delete all the intermediate downloaded files -rm -f `basename $DIST_LINUX_64` `basename $DIST_LINUX_32` `basename $DIST_LINUX_ARM` \ - `basename $DIST_OSX_64` `basename $DIST_OSX_32` \ - `basename $DIST_WIN_64` `basename $DIST_WIN_32` diff --git a/_beats/dev-tools/packer/docker/xgo-image/base/bootstrap_pure.sh b/_beats/dev-tools/packer/docker/xgo-image/base/bootstrap_pure.sh deleted file mode 100644 index 98b04d3949..0000000000 --- a/_beats/dev-tools/packer/docker/xgo-image/base/bootstrap_pure.sh +++ /dev/null @@ -1,41 +0,0 @@ -#!/bin/bash -# -# Contains the Go tool-chain pure-Go bootstrapper, that as of Go 1.5, initiates -# not only a few pre-built Go cross compilers, but rather bootstraps all of the -# supported platforms from the origin Linux amd64 distribution. -# -# Usage: bootstrap.sh -# -# Needed environment variables: -# FETCH - Remote file fetcher and checksum verifier (injected by image) -# ROOT_DIST - 64 bit Linux Go binary distribution package -# ROOT_DIST_SHA1 - 64 bit Linux Go distribution package checksum -set -e - -# Download, verify and install the root distribution -$FETCH $ROOT_DIST $ROOT_DIST_SHA1 - -tar -C /usr/local -xzf `basename $ROOT_DIST` -rm -f `basename $ROOT_DIST` - -export GOROOT=/usr/local/go -export GOROOT_BOOTSTRAP=$GOROOT - -# Pre-build all guest distributions based on the root distribution -echo "Bootstrapping linux/386..." -GOOS=linux GOARCH=386 CGO_ENABLED=1 go install std - -echo "Bootstrapping linux/arm..." -GOOS=linux GOARCH=arm CGO_ENABLED=1 CC=arm-linux-gnueabi-gcc go install std - -echo "Bootstrapping windows/amd64..." -GOOS=windows GOARCH=amd64 CGO_ENABLED=1 CC=x86_64-w64-mingw32-gcc go install std - -echo "Bootstrapping windows/386..." -GOOS=windows GOARCH=386 CGO_ENABLED=1 CC=i686-w64-mingw32-gcc go install std - -echo "Bootstrapping darwin/amd64..." -GOOS=darwin GOARCH=amd64 CGO_ENABLED=1 CC=o64-clang go install std - -echo "Bootstrapping darwin/386..." -GOOS=darwin GOARCH=386 CGO_ENABLED=1 CC=o32-clang go install std diff --git a/_beats/dev-tools/packer/docker/xgo-image/base/build.sh b/_beats/dev-tools/packer/docker/xgo-image/base/build.sh deleted file mode 100644 index 50adedb1fa..0000000000 --- a/_beats/dev-tools/packer/docker/xgo-image/base/build.sh +++ /dev/null @@ -1,207 +0,0 @@ -#!/bin/bash -# -# Contains the main cross compiler, that individually sets up each target build -# platform, compiles all the C dependencies, then build the requested executable -# itself. -# -# Usage: build.sh -# -# Needed environment variables: -# REPO_REMOTE - Optional VCS remote if not the primary repository is needed -# REPO_BRANCH - Optional VCS branch to use, if not the master branch -# DEPS - Optional list of C dependency packages to build -# PACK - Optional sub-package, if not the import path is being built -# OUT - Optional output prefix to override the package name -# FLAG_V - Optional verbosity flag to set on the Go builder -# FLAG_RACE - Optional race flag to set on the Go builder -# TARGETS - Comma separated list of build targets to compile for - - - -# Download the canonical import path (may fail, don't allow failures beyond) -SRC_FOLDER=$SOURCE - -DST_FOLDER=`dirname $GOPATH/src/$BEAT_PATH` -GIT_REPO=$BEAT_PATH - -if [ "$PUREGO" == "yes" ]; then - CGO_ENABLED=0 -else - CGO_ENABLED=1 -fi - -# If it is an official beat, libbeat is not vendored, need special treatment -if [[ $GIT_REPO == "github.com/elastic/beats"* ]]; then - echo "Overwrite directories because official beat" - DST_FOLDER=$GOPATH/src/github.com/elastic/beats - GIT_REPO=github.com/elastic/beats -fi - -# It is assumed all dependencies are inside the working directory -# The working directory is the parent of the beat directory -WORKING_DIRECTORY=$DST_FOLDER - -echo "Working directory=$WORKING_DIRECTORY" - -if [ "$SOURCE" != "" ]; then - mkdir -p ${DST_FOLDER} - echo "Copying main source folder ${SRC_FOLDER} to folder ${DST_FOLDER}" - rsync --exclude ".git" --exclude "build/" -a ${SRC_FOLDER}/ ${DST_FOLDER} -else - mkdir -p $GOPATH/src/${GIT_REPO} - cd $GOPATH/src/${GIT_REPO} - echo "Fetching main git repository ${GIT_REPO} in folder $GOPATH/src/${GIT_REPO}" - git clone https://${GIT_REPO}.git -fi - -set -e - -cd $WORKING_DIRECTORY - -# Switch over the code-base to another checkout if requested -if [ "$REPO_REMOTE" != "" ]; then - echo "Switching over to remote $REPO_REMOTE..." - if [ -d ".git" ]; then - git remote set-url origin $REPO_REMOTE - git pull - elif [ -d ".hg" ]; then - echo -e "[paths]\ndefault = $REPO_REMOTE\n" >> .hg/hgrc - hg pull - fi -fi - -if [ "$REPO_BRANCH" != "" ]; then - echo "Switching over to branch $REPO_BRANCH..." - if [ -d ".git" ]; then - git checkout $REPO_BRANCH - elif [ -d ".hg" ]; then - hg checkout $REPO_BRANCH - fi -fi - -# Download all the C dependencies -echo "Fetching dependencies..." -BUILD_DEPS=/build_deps.sh -DEPS_FOLDER=/deps -LIST_DEPS="" -mkdir -p $DEPS_FOLDER -DEPS=($DEPS) && for dep in "${DEPS[@]}"; do - dep_filename=${dep##*/} - echo "Downloading $dep to $DEPS_FOLDER/$dep_filename" - wget -q $dep --directory-prefix=$DEPS_FOLDER - dep_name=$(tar --list --no-recursion --file=$DEPS_FOLDER/$dep_filename --exclude="*/*" | sed 's/\///g') - LIST_DEPS="${LIST_DEPS} ${dep_name}" - if [ "${dep_filename##*.}" == "tar" ]; then tar -xf $DEPS_FOLDER/$dep_filename --directory $DEPS_FOLDER/ ; fi - if [ "${dep_filename##*.}" == "gz" ]; then tar -xzf $DEPS_FOLDER/$dep_filename --directory $DEPS_FOLDER/ ; fi - if [ "${dep_filename##*.}" == "bz2" ]; then tar -xj $DEPS_FOLDER/$dep_filename --directory $DEPS_FOLDER/ ; fi -done - -# Configure some global build parameters -NAME=${PACK} -if [ "$OUT" != "" ]; then - NAME=$OUT -fi - - -if [ "$FLAG_V" == "true" ]; then V=-v; fi -if [ "$FLAG_RACE" == "true" ]; then R=-race; fi - -# exactly one -ldflags allowed -LDFLAGS_STATIC="" -if [ "$STATIC" == "true" ]; then LDFLAGS_STATIC='-extldflags "-static"'; fi -NOW=$(date -u '+%Y-%m-%dT%H:%M:%SZ') -LDFLAGS_VERSION="-X=github.com/elastic/beats/libbeat/version.buildTime=${NOW} -X=github.com/elastic/beats/libbeat/version.commit=${BUILDID}" -LDFLAGS_VENDOR_VERSION="-X=${BEAT_PATH}/vendor/github.com/elastic/beats/libbeat/version.buildTime=${NOW} -X=${BEAT_PATH}/vendor/github.com/elastic/beats/libbeat/version.commit=${BUILDID}" -LDFLAGS="${LDFLAGS_VERSION} ${LDFLAGS_VENDOR_VERSION} ${LDFLAGS_STATIC}" - -if [ -n $BEFORE_BUILD ]; then - chmod +x /scripts/$BEFORE_BUILD - echo "Execute /scripts/$BEFORE_BUILD ${BEAT_PATH} ${ES_BEATS}" - /scripts/$BEFORE_BUILD -fi - - -# If no build targets were specified, inject a catch all wildcard -if [ "$TARGETS" == "" ]; then - TARGETS="./." -fi - - -for TARGET in $TARGETS; do - # Split the target into platform and architecture - XGOOS=`echo $TARGET | cut -d '/' -f 1` - XGOARCH=`echo $TARGET | cut -d '/' -f 2` - - # Check and build for Linux targets - if ([ $XGOOS == "." ] || [ $XGOOS == "linux" ]) && ([ $XGOARCH == "." ] || [ $XGOARCH == "amd64" ]); then - echo "Compiling $PACK for linux/amd64..." - HOST=x86_64-linux PREFIX=/usr/local $BUILD_DEPS /deps $LIST_DEPS - export PKG_CONFIG_PATH=/usr/aarch64-linux-gnu/lib/pkgconfig - - GOOS=linux GOARCH=amd64 CGO_ENABLED=${CGO_ENABLED} go get -d ./$PACK - sh -c "GOOS=linux GOARCH=amd64 CGO_ENABLED=${CGO_ENABLED} go build $V $R -ldflags=\"${LDFLAGS}\" -o /build/$NAME-linux-amd64$R ./$PACK" - fi - if ([ $XGOOS == "." ] || [ $XGOOS == "linux" ]) && ([ $XGOARCH == "." ] || [ $XGOARCH == "386" ]); then - echo "Compiling $PACK for linux/386..." - CFLAGS=-m32 CXXFLAGS=-m32 LDFLAGS=-m32 HOST=i686-linux PREFIX=/usr/local $BUILD_DEPS /deps $LIST_DEPS - GOOS=linux GOARCH=386 CGO_ENABLED=${CGO_ENABLED} go get -d ./$PACK - sh -c "GOOS=linux GOARCH=386 CGO_ENABLED=${CGO_ENABLED} go build $V $R -ldflags=\"${LDFLAGS}\" -o /build/$NAME-linux-386$R ./$PACK" - fi - if ([ $XGOOS == "." ] || [ $XGOOS == "linux" ]) && ([ $XGOARCH == "." ] || [ $XGOARCH == "arm" ]); then - echo "Compiling $PACK for linux/arm..." - CC=arm-linux-gnueabi-gcc CXX=rm-linux-gnueabi-g++ HOST=arm-linux PREFIX=/usr/local/arm $BUILD_DEPS /deps $LIST_DEPS - - CC=arm-linux-gnueabi-gcc CXX=rm-linux-gnueabi-g++ GOOS=linux GOARCH=arm CGO_ENABLED=${CGO_ENABLED} GOARM=5 go get -d ./$PACK - CC=arm-linux-gnueabi-gcc CXX=rm-linux-gnueabi-g++ GOOS=linux GOARCH=arm CGO_ENABLED=${CGO_ENABLED} GOARM=5 go build $V -ldflags="${LDFLAGS}" -o /build/$NAME-linux-arm ./$PACK - fi - - # Check and build for Windows targets - if [ $XGOOS == "." ] || [[ $XGOOS == windows* ]]; then - # Split the platform version and configure the Windows NT version - PLATFORM=`echo $XGOOS | cut -d '-' -f 2` - if [ "$PLATFORM" == "" ] || [ "$PLATFORM" == "." ] || [ "$PLATFORM" == "windows" ]; then - PLATFORM=4.0 # Windows NT - fi - - MAJOR=`echo $PLATFORM | cut -d '.' -f 1` - if [ "${PLATFORM/.}" != "$PLATFORM" ] ; then - MINOR=`echo $PLATFORM | cut -d '.' -f 2` - fi - CGO_NTDEF="-D_WIN32_WINNT=0x`printf "%02d" $MAJOR``printf "%02d" $MINOR`" - - # Build the requested windows binaries - if [ $XGOARCH == "." ] || [ $XGOARCH == "amd64" ]; then - echo "Compiling $PACK for windows-$PLATFORM/amd64..." - CC=x86_64-w64-mingw32-gcc CXX=x86_64-w64-mingw32-g++ CFLAGS="$CGO_NTDEF" CXXFLAGS="$CGO_NTDEF" HOST=x86_64-w64-mingw32 PREFIX=/usr/x86_64-w64-mingw32 $BUILD_DEPS /deps $LIST_DEPS - export PKG_CONFIG_PATH=/usr/x86_64-w64-mingw32/lib/pkgconfig - - CC=x86_64-w64-mingw32-gcc CXX=x86_64-w64-mingw32-g++ GOOS=windows GOARCH=amd64 CGO_ENABLED=${CGO_ENABLED} CGO_CFLAGS="$CGO_NTDEF" CGO_CXXFLAGS="$CGO_NTDEF" go get -d ./$PACK - CC=x86_64-w64-mingw32-gcc CXX=x86_64-w64-mingw32-g++ GOOS=windows GOARCH=amd64 CGO_ENABLED=${CGO_ENABLED} CGO_CFLAGS="$CGO_NTDEF" CGO_CXXFLAGS="$CGO_NTDEF" go build $V $R -ldflags="${LDFLAGS}" -o /build/$NAME-windows-amd64$R.exe ./$PACK - fi - - if [ $XGOARCH == "." ] || [ $XGOARCH == "386" ]; then - echo "Compiling $PACK for windows-$PLATFORM/386..." - CC=i686-w64-mingw32-gcc CXX=i686-w64-mingw32-g++ CFLAGS="$CGO_NTDEF" CXXFLAGS="$CGO_NTDEF" HOST=i686-w64-mingw32 PREFIX=/usr/i686-w64-mingw32 $BUILD_DEPS /deps $LIST_DEPS - export PKG_CONFIG_PATH=/usr/i686-w64-mingw32/lib/pkgconfig - - CC=i686-w64-mingw32-gcc CXX=i686-w64-mingw32-g++ GOOS=windows GOARCH=386 CGO_ENABLED=${CGO_ENABLED} CGO_CFLAGS="$CGO_NTDEF" CGO_CXXFLAGS="$CGO_NTDEF" go get -d ./$PACK - CC=i686-w64-mingw32-gcc CXX=i686-w64-mingw32-g++ GOOS=windows GOARCH=386 CGO_ENABLED=${CGO_ENABLED} CGO_CFLAGS="$CGO_NTDEF" CGO_CXXFLAGS="$CGO_NTDEF" go build $V -ldflags="${LDFLAGS}" -o /build/$NAME-windows-386.exe ./$PACK - fi - fi - - # Check and build for OSX targets - if ([ $XGOOS == "." ] || [ $XGOOS == "darwin" ]) && ([ $XGOARCH == "." ] || [ $XGOARCH == "amd64" ]); then - echo "Compiling $PACK for darwin/amd64..." - CC=o64-clang CXX=o64-clang++ HOST=x86_64-apple-darwin10 PREFIX=/usr/local $BUILD_DEPS /deps $LIST_DEPS - CC=o64-clang CXX=o64-clang++ GOOS=darwin GOARCH=amd64 CGO_ENABLED=${CGO_ENABLED} go get -d ./$PACK - CC=o64-clang CXX=o64-clang++ GOOS=darwin GOARCH=amd64 CGO_ENABLED=${CGO_ENABLED} go build $V $R -ldflags="-s ${LDFLAGS}" -o /build/$NAME-darwin-amd64$R ./$PACK - fi - if ([ $XGOOS == "." ] || [ $XGOOS == "darwin" ]) && ([ $XGOARCH == "." ] || [ $XGOARCH == "386" ]); then - echo "Compiling for darwin/386..." - CC=o32-clang CXX=o32-clang++ HOST=i386-apple-darwin10 PREFIX=/usr/local $BUILD_DEPS /deps $LIST_DEPS - CC=o32-clang CXX=o32-clang++ GOOS=darwin GOARCH=386 CGO_ENABLED=${CGO_ENABLED} go get -d ./$PACK - CC=o32-clang CXX=o32-clang++ GOOS=darwin GOARCH=386 CGO_ENABLED=${CGO_ENABLED} go build $V -ldflags="${LDFLAGS}" -o /build/$NAME-darwin-386 ./$PACK - fi -done - -echo "Build process completed" diff --git a/_beats/dev-tools/packer/docker/xgo-image/base/build_deps.sh b/_beats/dev-tools/packer/docker/xgo-image/base/build_deps.sh deleted file mode 100644 index e6445b95ed..0000000000 --- a/_beats/dev-tools/packer/docker/xgo-image/base/build_deps.sh +++ /dev/null @@ -1,36 +0,0 @@ -#!/bin/bash -# -# Contains the dependency builder to iterate over all installed dependencies -# and cross compile them to the requested target platform. -# -# Usage: build_deps.sh dependency_root_folder dependency1 dependency_2 ... -# -# Needed environment variables: -# CC - C cross compiler to use for the build -# HOST - Target platform to build (used to find the needed tool-chains) -# PREFIX - File-system path where to install the built binaries -# STATIC - true if the libraries are statically linked to the go application -set -e - -DEP_ROOT_FOLDER=$1 - -# Remove any previous build leftovers, and copy a fresh working set (clean doesn't work for cross compiling) -rm -rf /deps-build && cp -r $DEP_ROOT_FOLDER /deps-build - -args=("$@") - -if [ "$STATIC" == "true" ]; then DISABLE_SHARED=-disable-shared; fi - -# Build all the dependencies -for ((i=1; i<${#args[@]}; i++)); do - dep=${args[i]} - echo "Configuring dependency $dep for $HOST..." - if [ -f "/deps-build/$dep/autogen.sh" ]; then (cd /deps-build/$dep && ./autogen.sh); fi - (cd /deps-build/$dep && ./configure $DISABLE_SHARED --host=$HOST --prefix=$PREFIX --silent) - - echo "Building dependency $dep for $HOST..." - (cd /deps-build/$dep && make --silent -j install) -done - -# Remove any build artifacts -rm -rf /deps-build diff --git a/_beats/dev-tools/packer/docker/xgo-image/base/fetch.sh b/_beats/dev-tools/packer/docker/xgo-image/base/fetch.sh deleted file mode 100644 index d0b50399e7..0000000000 --- a/_beats/dev-tools/packer/docker/xgo-image/base/fetch.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/bash -# -# Contains a simple fetcher to download a file from a remote URL and verify its -# SHA1 checksum. -# -# Usage: fetch.sh -set -e - -# Pull the file from the remote URL -file=`basename $1` -echo "Downloading $1..." -wget -q $1 - -# Generate a desired checksum report and check against it -echo "$2 $file" > $file.sum -sha1sum -c $file.sum -rm $file.sum diff --git a/_beats/dev-tools/packer/docker/xgo-image/base/patch.tar.xz b/_beats/dev-tools/packer/docker/xgo-image/base/patch.tar.xz deleted file mode 100644 index bff5da4eaf..0000000000 Binary files a/_beats/dev-tools/packer/docker/xgo-image/base/patch.tar.xz and /dev/null differ diff --git a/_beats/dev-tools/packer/docker/xgo-image/beats-builder/Dockerfile b/_beats/dev-tools/packer/docker/xgo-image/beats-builder/Dockerfile deleted file mode 100644 index 8fb3f1425c..0000000000 --- a/_beats/dev-tools/packer/docker/xgo-image/beats-builder/Dockerfile +++ /dev/null @@ -1,47 +0,0 @@ -FROM tudorg/xgo-1.10.2 - -MAINTAINER Tudor Golubenco - -# Get libpcap binaries for linux -RUN \ - dpkg --add-architecture i386 && \ - apt-get update && \ - apt-get install -y libpcap0.8-dev - -RUN \ - mkdir -p /libpcap && \ - apt-get download libpcap0.8-dev:i386 && \ - dpkg -x libpcap0.8-dev_*_i386.deb /libpcap/i386 && \ - apt-get download libpcap0.8-dev && \ - dpkg -x libpcap0.8-dev_*_amd64.deb /libpcap/amd64 && \ - rm libpcap0.8-dev*.deb - - -# Get libpcap binaries for win -ENV WPDPACK_URL https://www.winpcap.org/install/bin/WpdPack_4_1_2.zip -RUN \ - ./fetch.sh $WPDPACK_URL f5c80885bd48f07f41833d0f65bf85da1ef1727a && \ - unzip `basename $WPDPACK_URL` -d /libpcap/win && \ - rm `basename $WPDPACK_URL` - -# Load gotpl -ADD yaml.v2 /go/src/gopkg.in/yaml.v2 -ADD gotpl /go/src/github.com/tsg/gotpl -RUN cd /go/src/github.com/tsg/gotpl && \ - go install - -# Add patch for gopacket. -ADD gopacket_pcap.patch /gopacket_pcap.patch - -# Add the wpcap.dll from the WinPcap_4_1_2.exe installer so that -# we can generate a 64-bit compatible libwpcap.a. -ENV WINPCAP_DLL_SHA1 d2afb08d0379bd96e423857963791e2ba00c9645 -ADD wpcap.dll /libpcap/win/wpcap.dll -RUN \ - apt-get install mingw-w64-tools && \ - cd /libpcap/win && \ - echo "$WINPCAP_DLL_SHA1 wpcap.dll" | sha1sum -c - && \ - gendef /libpcap/win/wpcap.dll && \ - x86_64-w64-mingw32-dlltool --as-flags=--64 -m i386:x86-64 -k --output-lib /libpcap/win/WpdPack/Lib/x64/libwpcap.a --input-def wpcap.def && \ - rm wpcap.def wpcap.dll - diff --git a/_beats/dev-tools/packer/docker/xgo-image/beats-builder/gopacket_pcap.patch b/_beats/dev-tools/packer/docker/xgo-image/beats-builder/gopacket_pcap.patch deleted file mode 100644 index b3c3407a14..0000000000 --- a/_beats/dev-tools/packer/docker/xgo-image/beats-builder/gopacket_pcap.patch +++ /dev/null @@ -1,24 +0,0 @@ -diff --git a/vendor/github.com/tsg/gopacket/pcap/pcap.go b/vendor/github.com/tsg/gopacket/pcap/pcap.go -index f5612e6..4438e6f 100644 ---- a/vendor/github.com/tsg/gopacket/pcap/pcap.go -+++ b/vendor/github.com/tsg/gopacket/pcap/pcap.go -@@ -8,14 +8,15 @@ - package pcap - - /* --#cgo linux LDFLAGS: -lpcap -+#cgo linux,386 LDFLAGS: /libpcap/i386/usr/lib/i386-linux-gnu/libpcap.a -+#cgo linux,amd64 LDFLAGS: /libpcap/amd64/usr/lib/x86_64-linux-gnu/libpcap.a - #cgo freebsd LDFLAGS: -lpcap - #cgo openbsd LDFLAGS: -lpcap - #cgo darwin LDFLAGS: -lpcap - #cgo solaris LDFLAGS: -lpcap --#cgo windows CFLAGS: -I C:/WpdPack/Include --#cgo windows,386 LDFLAGS: -L C:/WpdPack/Lib -lwpcap --#cgo windows,amd64 LDFLAGS: -L C:/WpdPack/Lib/x64 -lwpcap -+#cgo windows CFLAGS: -I /libpcap/win/WpdPack/Include -+#cgo windows,386 LDFLAGS: -L /libpcap/win/WpdPack/Lib -lwpcap -+#cgo windows,amd64 LDFLAGS: -L /libpcap/win/WpdPack/Lib/x64 -lwpcap - #include - #include - diff --git a/_beats/dev-tools/packer/docker/xgo-image/beats-builder/wpcap.dll b/_beats/dev-tools/packer/docker/xgo-image/beats-builder/wpcap.dll deleted file mode 100644 index ebb17ad55c..0000000000 Binary files a/_beats/dev-tools/packer/docker/xgo-image/beats-builder/wpcap.dll and /dev/null differ diff --git a/_beats/dev-tools/packer/docker/xgo-image/build.sh b/_beats/dev-tools/packer/docker/xgo-image/build.sh deleted file mode 100755 index 401110afdc..0000000000 --- a/_beats/dev-tools/packer/docker/xgo-image/build.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/sh - -cp -r ../../../vendor/gopkg.in/yaml.v2 beats-builder/yaml.v2 -cp -r ../../../vendor/github.com/tsg/gotpl beats-builder/gotpl -docker pull tudorg/xgo-base:v20180222 && \ - docker build --rm=true -t tudorg/xgo-1.10.2 go-1.10.2/ && - docker build --rm=true -t tudorg/beats-builder beats-builder diff --git a/_beats/dev-tools/packer/docker/xgo-image/go-1.10.2/Dockerfile b/_beats/dev-tools/packer/docker/xgo-image/go-1.10.2/Dockerfile deleted file mode 100644 index d09a7ac74a..0000000000 --- a/_beats/dev-tools/packer/docker/xgo-image/go-1.10.2/Dockerfile +++ /dev/null @@ -1,15 +0,0 @@ -# Go cross compiler (xgo): Go 1.10.2 layer -# Copyright (c) 2014 Péter Szilágyi. All rights reserved. -# -# Released under the MIT license. - -FROM tudorg/xgo-base - -MAINTAINER Tudor Golubenco - -# Configure the root Go distribution and bootstrap based on it -RUN \ - export ROOT_DIST="https://storage.googleapis.com/golang/go1.10.2.linux-amd64.tar.gz" && \ - export ROOT_DIST_SHA1="77f0ac48994946c0d3349baf2d973ed6decb15ca" && \ - \ - $BOOTSTRAP_PURE diff --git a/_beats/dev-tools/packer/docker/xgo-image/push_image.md b/_beats/dev-tools/packer/docker/xgo-image/push_image.md deleted file mode 100644 index 30e6c2af93..0000000000 --- a/_beats/dev-tools/packer/docker/xgo-image/push_image.md +++ /dev/null @@ -1,16 +0,0 @@ -XXX: this should be temporary until we can use the Elastic Registry. - -To update the `tudorg/xgo-base` image on Docker HUB, do the following: - -* `docker login` with your docker hub credentials. Feel free to publish the image - to your own account if Tudor is not available. - -* Build the image: `docker build --rm=true -t tudorg/xgo-base base/` - -* List the images: `docker images` - -* Tag it: `docker tag tudorg/xgo-base:$(date '+v%Y%m%d')` - -* Push: `docker push tudorg/xgo-base` - -* Update `build.sh` to use the new image/tag diff --git a/_beats/dev-tools/packer/platforms/README b/_beats/dev-tools/packer/platforms/README deleted file mode 100644 index 60935fa546..0000000000 --- a/_beats/dev-tools/packer/platforms/README +++ /dev/null @@ -1 +0,0 @@ -Pseudo-platform to build the dashboards in their own package. diff --git a/_beats/dev-tools/packer/platforms/binary/build.sh b/_beats/dev-tools/packer/platforms/binary/build.sh deleted file mode 100755 index 06ee52052a..0000000000 --- a/_beats/dev-tools/packer/platforms/binary/build.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/sh - -set -e - -BASEDIR=$(dirname "$0") -ARCHDIR=${BASEDIR}/../../ - -# executed from the top directory -runid=binary-$BEAT-$ARCH - -cat ${BUILD_DIR}/package.yml ${ARCHDIR}/archs/$ARCH.yml > ${BUILD_DIR}/settings-$runid.yml -gotpl ${BASEDIR}/run.sh.j2 < ${BUILD_DIR}/settings-$runid.yml > ${BUILD_DIR}/run-$runid.sh -chmod +x ${BUILD_DIR}/run-$runid.sh - -docker run --rm -v ${BUILD_DIR}:/build -v ${UPLOAD_DIR}:/upload \ - -e BUILDID=$BUILDID -e SNAPSHOT=$SNAPSHOT -e RUNID=$runid -e BEAT_REF_YAML=$BEAT_REF_YAML \ - tudorg/fpm /build/run-$runid.sh - -rm ${BUILD_DIR}/settings-$runid.yml ${BUILD_DIR}/run-$runid.sh diff --git a/_beats/dev-tools/packer/platforms/binary/run.sh.j2 b/_beats/dev-tools/packer/platforms/binary/run.sh.j2 deleted file mode 100644 index 05eaadeecf..0000000000 --- a/_beats/dev-tools/packer/platforms/binary/run.sh.j2 +++ /dev/null @@ -1,31 +0,0 @@ -#!/bin/bash - -# this is executed in the docker fpm image -set -e -cd /build - -# add SNAPSHOT if it was requested -VERSION={{.version}} -if [ "$SNAPSHOT" = "yes" ]; then - VERSION="${VERSION}-SNAPSHOT" -fi - -BEATS_YML_NAME="{{.beat_name}}-linux-{{.arch}}" -[ -f "${BEATS_YML_NAME}.yml" ] || BEATS_YML_NAME="{{.beat_name}}-linux" - -mkdir /{{.beat_name}}-${VERSION}-linux-{{.bin_arch}} -cp -a homedir/. /{{.beat_name}}-${VERSION}-linux-{{.bin_arch}}/ -cp {{.beat_name}}-linux-{{.arch}} /{{.beat_name}}-${VERSION}-linux-{{.bin_arch}}/{{.beat_name}} -cp ${BEATS_YML_NAME}.yml /{{.beat_name}}-${VERSION}-linux-{{.bin_arch}}/{{.beat_name}}.yml -if [ -z "${BEAT_REF_YAML}" ] || [ ${BEAT_REF_YAML} = true ]; then - cp ${BEATS_YML_NAME}.reference.yml /{{.beat_name}}-${VERSION}-linux-{{.bin_arch}}/{{.beat_name}}.reference.yml -fi -cp fields.yml /{{.beat_name}}-${VERSION}-linux-{{.bin_arch}}/ -cp -a modules.d-linux/ /{{.beat_name}}-${VERSION}-linux-{{.bin_arch}}/modules.d || true - -tar czvf /upload/{{.beat_name}}{{.beat_pkg_suffix}}-${VERSION}-linux-{{.bin_arch}}.tar.gz /{{.beat_name}}-${VERSION}-linux-{{.bin_arch}} -echo "Created /upload/{{.beat_name}}{{.beat_pkg_suffix}}--${VERSION}-linux-{{.bin_arch}}.tar.gz" - -cd /upload -sha512sum {{.beat_name}}{{.beat_pkg_suffix}}-${VERSION}-linux-{{.bin_arch}}.tar.gz > {{.beat_name}}{{.beat_pkg_suffix}}-${VERSION}-linux-{{.bin_arch}}.tar.gz.sha512 -echo "Created /upload/{{.beat_name}}{{.beat_pkg_suffix}}-${VERSION}-linux-{{.bin_arch}}.tar.gz.sha512" diff --git a/_beats/dev-tools/packer/platforms/centos/beatname.sh.j2 b/_beats/dev-tools/packer/platforms/centos/beatname.sh.j2 deleted file mode 100644 index 2601507722..0000000000 --- a/_beats/dev-tools/packer/platforms/centos/beatname.sh.j2 +++ /dev/null @@ -1,11 +0,0 @@ -#!/usr/bin/env bash - -# Script to run {.beat_name} in foreground with the same path settings that -# the init script / systemd unit file would do. - -exec /usr/share/{{.beat_name}}/bin/{{.beat_name}} \ - -path.home /usr/share/{{.beat_name}} \ - -path.config /etc/{{.beat_name}} \ - -path.data /var/lib/{{.beat_name}} \ - -path.logs /var/log/{{.beat_name}} \ - "$@" diff --git a/_beats/dev-tools/packer/platforms/centos/build.sh b/_beats/dev-tools/packer/platforms/centos/build.sh deleted file mode 100755 index 7198928f26..0000000000 --- a/_beats/dev-tools/packer/platforms/centos/build.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/sh - -set -e - -BASEDIR=$(dirname "$0") -ARCHDIR=${BASEDIR}/../../ - -# executed from the top directory -runid=centos-$BEAT-$ARCH - -cat ${BUILD_DIR}/package.yml ${ARCHDIR}/archs/$ARCH.yml > ${BUILD_DIR}/settings-$runid.yml -gotpl ${BASEDIR}/run.sh.j2 < ${BUILD_DIR}/settings-$runid.yml > ${BUILD_DIR}/run-$runid.sh -chmod +x ${BUILD_DIR}/run-$runid.sh -gotpl ${BASEDIR}/init.j2 < ${BUILD_DIR}/settings-$runid.yml > ${BUILD_DIR}/$runid.init -gotpl ${BASEDIR}/systemd.j2 < ${BUILD_DIR}/settings-$runid.yml > ${BUILD_DIR}/$runid.service -gotpl ${BASEDIR}/beatname.sh.j2 < ${BUILD_DIR}/settings-$runid.yml > ${BUILD_DIR}/beatname-$runid.sh -chmod +x ${BUILD_DIR}/beatname-$runid.sh - -docker run --rm -v ${BUILD_DIR}:/build -v ${UPLOAD_DIR}:/upload \ - -e BUILDID=$BUILDID -e SNAPSHOT=$SNAPSHOT -e RUNID=$runid -e BEAT_REF_YAML=$BEAT_REF_YAML \ - tudorg/fpm /build/run-$runid.sh - -rm ${BUILD_DIR}/settings-$runid.yml ${BUILD_DIR}/run-$runid.sh diff --git a/_beats/dev-tools/packer/platforms/centos/run.sh.j2 b/_beats/dev-tools/packer/platforms/centos/run.sh.j2 deleted file mode 100644 index f23517d2e8..0000000000 --- a/_beats/dev-tools/packer/platforms/centos/run.sh.j2 +++ /dev/null @@ -1,64 +0,0 @@ -#!/bin/bash - -# this is executed in the docker fpm image -set -e -cd /build - -# the init scripts needs to have the right name -cp ${RUNID}.init /tmp/{{.beat_pkg_name}}.init - -# create script to reload systemd config -echo "#!/bin/bash" > /tmp/systemd-daemon-reload.sh -echo "systemctl daemon-reload 2> /dev/null || true" >> /tmp/systemd-daemon-reload.sh - -# add SNAPSHOT if it was requested -VERSION="{{.version}}" -if [ "$SNAPSHOT" = "yes" ]; then - VERSION="${VERSION}-SNAPSHOT" -fi - -BEATS_YML_NAME="{{.beat_name}}-linux-{{.arch}}" -[ -f "${BEATS_YML_NAME}.yml" ] || BEATS_YML_NAME="{{.beat_name}}-linux" - -# fpm replaces - with _ in the version -RPM_VERSION=`echo ${VERSION} | sed 's/-/_/g'` - -# create rpm -FPM_ARGS=( - --force -s dir -t rpm - -n {{.beat_pkg_name}}{{.beat_pkg_suffix}} -v ${RPM_VERSION} - --architecture {{.rpm_arch}} - --vendor "{{.beat_vendor}}" - --license "{{.beat_license}}" - --description "{{.beat_description}}" - --url {{.beat_url}} - --rpm-init /tmp/{{.beat_pkg_name}}.init - --after-install /tmp/systemd-daemon-reload.sh - --config-files /etc/{{.beat_name}}/{{.beat_name}}.yml - homedir/=/usr/share/{{.beat_name}} - beatname-${RUNID}.sh=/usr/bin/{{.beat_name}} - {{.beat_name}}-linux-{{.arch}}=/usr/share/{{.beat_name}}/bin/{{.beat_name}} - ${BEATS_YML_NAME}.yml=/etc/{{.beat_name}}/{{.beat_name}}.yml - fields.yml=/etc/{{.beat_name}}/fields.yml - ${RUNID}.service=/lib/systemd/system/{{.beat_pkg_name}}.service - god-linux-{{.arch}}=/usr/share/{{.beat_name}}/bin/{{.beat_name}}-god - ) - -if [ -z "${BEAT_REF_YAML}" ] || [ ${BEAT_REF_YAML} = true ]; then - FPM_ARGS+=(${BEATS_YML_NAME}.reference.yml=/etc/{{.beat_name}}/{{.beat_name}}.reference.yml) -fi - -if [ -d modules.d-linux ]; then - FPM_ARGS+=(modules.d-linux/=/etc/{{.beat_name}}/modules.d/) -fi - -fpm "${FPM_ARGS[@]}" - -# rename so that the filename respects semver rules -mv {{.beat_pkg_name}}{{.beat_pkg_suffix}}-${RPM_VERSION}-1.{{.rpm_arch}}.rpm /upload/{{.beat_name}}{{.beat_pkg_suffix}}-${VERSION}-{{.rpm_arch}}.rpm -echo "Created /upload/{{.beat_name}}{{.beat_pkg_suffix}}-${VERSION}-{{.rpm_arch}}.rpm" - -# create sha512 file -cd /upload -sha512sum {{.beat_name}}{{.beat_pkg_suffix}}-${VERSION}-{{.rpm_arch}}.rpm > {{.beat_name}}{{.beat_pkg_suffix}}-${VERSION}-{{.rpm_arch}}.rpm.sha512 -echo "Created /upload/{{.beat_name}}{{.beat_pkg_suffix}}-${VERSION}-{{.rpm_arch}}.rpm.sha512" diff --git a/_beats/dev-tools/packer/platforms/centos/systemd.j2 b/_beats/dev-tools/packer/platforms/centos/systemd.j2 deleted file mode 100644 index 8f14e9effc..0000000000 --- a/_beats/dev-tools/packer/platforms/centos/systemd.j2 +++ /dev/null @@ -1,12 +0,0 @@ -[Unit] -Description={{.beat_name}} -Documentation={{.beat_doc_url}} -Wants=network-online.target -After=network-online.target - -[Service] -ExecStart=/usr/share/{{.beat_name}}/bin/{{.beat_name}} -c /etc/{{.beat_name}}/{{.beat_name}}.yml -path.home /usr/share/{{.beat_name}} -path.config /etc/{{.beat_name}} -path.data /var/lib/{{.beat_name}} -path.logs /var/log/{{.beat_name}} -Restart=always - -[Install] -WantedBy=multi-user.target diff --git a/_beats/dev-tools/packer/platforms/darwin/build.sh b/_beats/dev-tools/packer/platforms/darwin/build.sh deleted file mode 100755 index 14c57f7514..0000000000 --- a/_beats/dev-tools/packer/platforms/darwin/build.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/sh - -set -e - -BASEDIR=$(dirname "$0") -ARCHDIR=${BASEDIR}/../../ - -# executed from the top directory -runid=darwin-$BEAT-$ARCH - -cat ${BUILD_DIR}/package.yml ${ARCHDIR}/archs/$ARCH.yml > ${BUILD_DIR}/settings-$runid.yml -gotpl ${BASEDIR}/run.sh.j2 < ${BUILD_DIR}/settings-$runid.yml > ${BUILD_DIR}/run-$runid.sh -chmod +x ${BUILD_DIR}/run-$runid.sh - -docker run --rm -v ${BUILD_DIR}:/build -v ${UPLOAD_DIR}:/upload \ - -e BUILDID=$BUILDID -e SNAPSHOT=$SNAPSHOT -e RUNID=$runid -e BEAT_REF_YAML=$BEAT_REF_YAML \ - tudorg/fpm /build/run-$runid.sh - -rm ${BUILD_DIR}/settings-$runid.yml ${BUILD_DIR}/run-$runid.sh diff --git a/_beats/dev-tools/packer/platforms/darwin/run.sh.j2 b/_beats/dev-tools/packer/platforms/darwin/run.sh.j2 deleted file mode 100644 index 18c8f62e5f..0000000000 --- a/_beats/dev-tools/packer/platforms/darwin/run.sh.j2 +++ /dev/null @@ -1,28 +0,0 @@ -#!/bin/bash - -# this is executed in the docker fpm image -set -e -cd /build - -# add SNAPSHOT if it was requested -VERSION={{.version}} -if [ "$SNAPSHOT" = "yes" ]; then - VERSION="${VERSION}-SNAPSHOT" -fi - -mkdir /{{.beat_name}}-${VERSION}-darwin-x86_64 -cp -a homedir/. /{{.beat_name}}-${VERSION}-darwin-x86_64/ -cp {{.beat_name}}-darwin-amd64 /{{.beat_name}}-${VERSION}-darwin-x86_64/{{.beat_name}} -cp {{.beat_name}}-darwin.yml /{{.beat_name}}-${VERSION}-darwin-x86_64/{{.beat_name}}.yml -if [ -z "${BEAT_REF_YAML}" ] || [ ${BEAT_REF_YAML} = true ]; then - cp {{.beat_name}}-darwin.reference.yml /{{.beat_name}}-${VERSION}-darwin-x86_64/{{.beat_name}}.reference.yml -fi -cp fields.yml /{{.beat_name}}-${VERSION}-darwin-x86_64/ -cp -a modules.d-darwin/ /{{.beat_name}}-${VERSION}-darwin-x86_64/modules.d || true - -tar czvf /upload/{{.beat_name}}{{.beat_pkg_suffix}}-${VERSION}-darwin-x86_64.tar.gz /{{.beat_name}}-${VERSION}-darwin-x86_64 -echo "Created /upload/{{.beat_name}}-${VERSION}-darwin-x86_64.tar.gz" - -cd /upload -sha512sum {{.beat_name}}{{.beat_pkg_suffix}}-${VERSION}-darwin-x86_64.tar.gz > {{.beat_name}}{{.beat_pkg_suffix}}-${VERSION}-darwin-x86_64.tar.gz.sha512 -echo "Created /upload/{{.beat_name}}{{.beat_pkg_suffix}}-${VERSION}-darwin-x86_64.tar.gz.sha512" diff --git a/_beats/dev-tools/packer/platforms/dashboards/build.sh b/_beats/dev-tools/packer/platforms/dashboards/build.sh deleted file mode 100755 index 67b04828fc..0000000000 --- a/_beats/dev-tools/packer/platforms/dashboards/build.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/sh - -set -e - -BASEDIR=$(dirname "$0") -ARCHDIR=${BASEDIR}/../../ - -runid=dashboards - -cat ${ARCHDIR}/version.yml > ${BUILD_DIR}/settings-$runid.yml -gotpl ${BASEDIR}/run.sh.j2 < ${BUILD_DIR}/settings-$runid.yml > ${BUILD_DIR}/run-$runid.sh -chmod +x ${BUILD_DIR}/run-$runid.sh - -docker run --rm -v ${BUILD_DIR}:/build -v ${UPLOAD_DIR}:/upload \ - -e BUILDID=$BUILDID -e SNAPSHOT=$SNAPSHOT -e RUNID=$runid -e BEAT_NAME=$BEAT_NAME -e BEAT_REF_YAML=$BEAT_REF_YAML \ - tudorg/fpm /build/run-$runid.sh - -rm ${BUILD_DIR}/settings-$runid.yml ${BUILD_DIR}/run-$runid.sh diff --git a/_beats/dev-tools/packer/platforms/dashboards/run.sh.j2 b/_beats/dev-tools/packer/platforms/dashboards/run.sh.j2 deleted file mode 100644 index 96d272aaf2..0000000000 --- a/_beats/dev-tools/packer/platforms/dashboards/run.sh.j2 +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/bash - -# this is executed in the docker fpm image -set -e -cd /build - -# add SNAPSHOT if it was requested -VERSION={{.version}} -if [ "$SNAPSHOT" = "yes" ]; then - VERSION="${VERSION}-SNAPSHOT" -fi - -mkdir /${BEAT_NAME:-beats}-dashboards-${VERSION} -cp -a dashboards/. /${BEAT_NAME:-beats}-dashboards-${VERSION}/ -echo "$BUILDID" > /${BEAT_NAME:-beats}-dashboards-${VERSION}/.build_hash.txt - -zip -r /upload/${BEAT_NAME:-beats}-dashboards-${VERSION}.zip /${BEAT_NAME:-beats}-dashboards-${VERSION} -echo "Created /upload/${BEAT_NAME:-beats}-dashboards-${VERSION}.zip" - -cd /upload -sha512sum ${BEAT_NAME:-beats}-dashboards-${VERSION}.zip > ${BEAT_NAME:-beats}-dashboards-${VERSION}.zip.sha512 -echo "Created /upload/${BEAT_NAME:-beats}-dashboards-${VERSION}.zip.sha512" diff --git a/_beats/dev-tools/packer/platforms/debian/beatname.sh.j2 b/_beats/dev-tools/packer/platforms/debian/beatname.sh.j2 deleted file mode 100644 index fc36a268b8..0000000000 --- a/_beats/dev-tools/packer/platforms/debian/beatname.sh.j2 +++ /dev/null @@ -1,11 +0,0 @@ -#!/usr/bin/env bash - -# Script to run {{.beat_name}} in foreground with the same path settings that -# the init script / systemd unit file would do. - -exec /usr/share/{{.beat_name}}/bin/{{.beat_name}} \ - -path.home /usr/share/{{.beat_name}} \ - -path.config /etc/{{.beat_name}} \ - -path.data /var/lib/{{.beat_name}} \ - -path.logs /var/log/{{.beat_name}} \ - "$@" diff --git a/_beats/dev-tools/packer/platforms/debian/build.sh b/_beats/dev-tools/packer/platforms/debian/build.sh deleted file mode 100755 index 64f989f7d8..0000000000 --- a/_beats/dev-tools/packer/platforms/debian/build.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/sh - -set -e - -BASEDIR=$(dirname "$0") -ARCHDIR=${BASEDIR}/../../ - -# executed from the top directory -runid=debian-$BEAT-$ARCH - -cat ${BUILD_DIR}/package.yml ${ARCHDIR}/archs/$ARCH.yml > ${BUILD_DIR}/settings-$runid.yml -gotpl ${BASEDIR}/run.sh.j2 < ${BUILD_DIR}/settings-$runid.yml > ${BUILD_DIR}/run-$runid.sh -chmod +x ${BUILD_DIR}/run-$runid.sh -gotpl ${BASEDIR}/init.j2 < ${BUILD_DIR}/settings-$runid.yml > ${BUILD_DIR}/$runid.init -gotpl ${BASEDIR}/systemd.j2 < ${BUILD_DIR}/settings-$runid.yml > ${BUILD_DIR}/$runid.service -gotpl ${BASEDIR}/beatname.sh.j2 < ${BUILD_DIR}/settings-$runid.yml > ${BUILD_DIR}/beatname-$runid.sh -chmod +x ${BUILD_DIR}/beatname-$runid.sh - -docker run --rm -v ${BUILD_DIR}:/build -v ${UPLOAD_DIR}:/upload \ - -e BUILDID=$BUILDID -e SNAPSHOT=$SNAPSHOT -e RUNID=$runid -e BEAT_REF_YAML=$BEAT_REF_YAML \ - tudorg/fpm /build/run-$runid.sh - -rm ${BUILD_DIR}/settings-$runid.yml ${BUILD_DIR}/run-$runid.sh diff --git a/_beats/dev-tools/packer/platforms/debian/run.sh.j2 b/_beats/dev-tools/packer/platforms/debian/run.sh.j2 deleted file mode 100644 index fcf2cdba33..0000000000 --- a/_beats/dev-tools/packer/platforms/debian/run.sh.j2 +++ /dev/null @@ -1,62 +0,0 @@ -#!/bin/bash - -# this is executed in the docker fpm image -set -e -cd /build - -# the init scripts needs to have the right name -cp ${RUNID}.init /tmp/{{.beat_pkg_name}}.init - -# create script to reload systemd config -echo "#!/bin/bash" > /tmp/systemd-daemon-reload.sh -echo "systemctl daemon-reload 2> /dev/null || true" >> /tmp/systemd-daemon-reload.sh - -# add SNAPSHOT if it was requested -VERSION="{{.version}}" -if [ "$SNAPSHOT" = "yes" ]; then - VERSION="${VERSION}-SNAPSHOT" -fi - -BEATS_YML_NAME="{{.beat_name}}-linux-{{.arch}}" -[ -f "${BEATS_YML_NAME}.yml" ] || BEATS_YML_NAME="{{.beat_name}}-linux" - -# create deb -FPM_ARGS=( - --force -s dir -t deb - -n {{.beat_pkg_name}}{{.beat_pkg_suffix}} -v ${VERSION} - --vendor "{{.beat_vendor}}" - --license $(echo {{.beat_license}} | tr " " "-") - --architecture {{.deb_arch}} - --description "{{.beat_description}}" - --url {{.beat_url}} - --deb-init /tmp/{{.beat_pkg_name}}.init - --after-install /tmp/systemd-daemon-reload.sh - --config-files /etc/{{.beat_name}}/{{.beat_name}}.yml - homedir/=/usr/share/{{.beat_name}} - beatname-${RUNID}.sh=/usr/bin/{{.beat_name}} - {{.beat_name}}-linux-{{.arch}}=/usr/share/{{.beat_name}}/bin/{{.beat_name}} - ${BEATS_YML_NAME}.yml=/etc/{{.beat_name}}/{{.beat_name}}.yml - fields.yml=/etc/{{.beat_name}}/fields.yml - ${RUNID}.service=/lib/systemd/system/{{.beat_pkg_name}}.service - god-linux-{{.arch}}=/usr/share/{{.beat_name}}/bin/{{.beat_name}}-god - ) - -if [ -z "${BEAT_REF_YAML}" ] || [ ${BEAT_REF_YAML} = true ]; then - FPM_ARGS+=(${BEATS_YML_NAME}.reference.yml=/etc/{{.beat_name}}/{{.beat_name}}.reference.yml) -fi - - -if [ -d modules.d-linux ]; then - FPM_ARGS+=(modules.d-linux/=/etc/{{.beat_name}}/modules.d/) -fi - -fpm "${FPM_ARGS[@]}" - -# move and rename to use the elastic conventions -mv {{.beat_pkg_name}}{{.beat_pkg_suffix}}_${VERSION}_{{.deb_arch}}.deb /upload/{{.beat_name}}{{.beat_pkg_suffix}}-${VERSION}-{{.deb_arch}}.deb -echo "Created /upload/{{.beat_name}}{{.beat_pkg_suffix}}-${VERSION}-{{.deb_arch}}.deb" - -# create sha512 file -cd /upload -sha512sum {{.beat_name}}{{.beat_pkg_suffix}}-${VERSION}-{{.deb_arch}}.deb > {{.beat_name}}{{.beat_pkg_suffix}}-${VERSION}-{{.deb_arch}}.deb.sha512 -echo "Created /upload/{{.beat_name}}{{.beat_pkg_suffix}}-${VERSION}-{{.deb_arch}}.deb.sha512" diff --git a/_beats/dev-tools/packer/platforms/debian/systemd.j2 b/_beats/dev-tools/packer/platforms/debian/systemd.j2 deleted file mode 100644 index 8f14e9effc..0000000000 --- a/_beats/dev-tools/packer/platforms/debian/systemd.j2 +++ /dev/null @@ -1,12 +0,0 @@ -[Unit] -Description={{.beat_name}} -Documentation={{.beat_doc_url}} -Wants=network-online.target -After=network-online.target - -[Service] -ExecStart=/usr/share/{{.beat_name}}/bin/{{.beat_name}} -c /etc/{{.beat_name}}/{{.beat_name}}.yml -path.home /usr/share/{{.beat_name}} -path.config /etc/{{.beat_name}} -path.data /var/lib/{{.beat_name}} -path.logs /var/log/{{.beat_name}} -Restart=always - -[Install] -WantedBy=multi-user.target diff --git a/_beats/dev-tools/packer/platforms/windows/build.sh b/_beats/dev-tools/packer/platforms/windows/build.sh deleted file mode 100755 index bdecc7c04f..0000000000 --- a/_beats/dev-tools/packer/platforms/windows/build.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/sh - -set -e - -BASEDIR=$(dirname "$0") -ARCHDIR=${BASEDIR}/../.. - -# executed from the top directory -runid=windows-$BEAT-$ARCH - -cat ${BUILD_DIR}/package.yml ${ARCHDIR}/archs/$ARCH.yml > ${BUILD_DIR}/settings-$runid.yml -gotpl ${BASEDIR}/run.sh.j2 < ${BUILD_DIR}/settings-$runid.yml > ${BUILD_DIR}/run-$runid.sh -gotpl ${BASEDIR}/install-service.ps1.j2 < ${BUILD_DIR}/settings-$runid.yml > ${BUILD_DIR}/install-service-$BEAT.ps1 -gotpl ${BASEDIR}/uninstall-service.ps1.j2 < ${BUILD_DIR}/settings-$runid.yml > ${BUILD_DIR}/uninstall-service-$BEAT.ps1 -chmod +x ${BUILD_DIR}/run-$runid.sh - -docker run --rm -v ${BUILD_DIR}:/build -v ${UPLOAD_DIR}:/upload \ - -e BUILDID=$BUILDID -e SNAPSHOT=$SNAPSHOT -e RUNID=$runid -e BEAT_REF_YAML=$BEAT_REF_YAML \ - tudorg/fpm /build/run-$runid.sh - -rm ${BUILD_DIR}/settings-$runid.yml ${BUILD_DIR}/run-$runid.sh diff --git a/_beats/dev-tools/packer/platforms/windows/install-service.ps1.j2 b/_beats/dev-tools/packer/platforms/windows/install-service.ps1.j2 deleted file mode 100644 index e95e431167..0000000000 --- a/_beats/dev-tools/packer/platforms/windows/install-service.ps1.j2 +++ /dev/null @@ -1,14 +0,0 @@ -# delete service if it already exists -if (Get-Service {{.beat_name}} -ErrorAction SilentlyContinue) { - $service = Get-WmiObject -Class Win32_Service -Filter "name='{{.beat_name}}'" - $service.StopService() - Start-Sleep -s 1 - $service.delete() -} - -$workdir = Split-Path $MyInvocation.MyCommand.Path - -# create new service -New-Service -name {{.beat_name}} ` - -displayName {{.beat_name}} ` - -binaryPathName "`"$workdir\{{.beat_name}}.exe`" -c `"$workdir\{{.beat_name}}.yml`" -path.home `"$workdir`" -path.data `"C:\ProgramData\{{.beat_name}}`" -path.logs `"C:\ProgramData\{{.beat_name}}\logs`"" diff --git a/_beats/dev-tools/packer/platforms/windows/run.sh.j2 b/_beats/dev-tools/packer/platforms/windows/run.sh.j2 deleted file mode 100644 index 2a65ca120d..0000000000 --- a/_beats/dev-tools/packer/platforms/windows/run.sh.j2 +++ /dev/null @@ -1,31 +0,0 @@ -#!/bin/bash - -# this is executed in the docker fpm image -set -e -cd /build - -# add SNAPSHOT if it was requested -VERSION={{.version}} -if [ "$SNAPSHOT" = "yes" ]; then - VERSION="${VERSION}-SNAPSHOT" -fi - -mkdir /{{.beat_name}}-${VERSION}-windows-{{.win_arch}} -cp -a homedir/. /{{.beat_name}}-${VERSION}-windows-{{.win_arch}}/ -cp {{.beat_name}}-windows-{{.arch}}.exe /{{.beat_name}}-${VERSION}-windows-{{.win_arch}}/{{.beat_name}}.exe -unix2dos {{.beat_name}}-win.yml -cp {{.beat_name}}-win.yml /{{.beat_name}}-${VERSION}-windows-{{.win_arch}}/{{.beat_name}}.yml -if [ -z "${BEAT_REF_YAML}" ] || [ ${BEAT_REF_YAML} = true ]; then - cp {{.beat_name}}-win.reference.yml /{{.beat_name}}-${VERSION}-windows-{{.win_arch}}/{{.beat_name}}.reference.yml -fi -cp fields.yml /{{.beat_name}}-${VERSION}-windows-{{.win_arch}}/ -cp -a modules.d-win/ /{{.beat_name}}-${VERSION}-windows-{{.win_arch}}/modules.d || true -cp install-service-{{.beat_name}}.ps1 /{{.beat_name}}-${VERSION}-windows-{{.win_arch}}/ -cp uninstall-service-{{.beat_name}}.ps1 /{{.beat_name}}-${VERSION}-windows-{{.win_arch}}/ - -zip -r /upload/{{.beat_name}}{{.beat_pkg_suffix}}-${VERSION}-windows-{{.win_arch}}.zip /{{.beat_name}}-${VERSION}-windows-{{.win_arch}} -echo "Created /upload/{{.beat_name}}{{.beat_pkg_suffix}}-${VERSION}-windows-{{.win_arch}}.zip" - -cd /upload -sha512sum {{.beat_name}}{{.beat_pkg_suffix}}-${VERSION}-windows-{{.win_arch}}.zip > {{.beat_name}}{{.beat_pkg_suffix}}-${VERSION}-windows-{{.win_arch}}.zip.sha512 -echo "Created /upload/{{.beat_name}}{{.beat_pkg_suffix}}-${VERSION}-windows-{{.win_arch}}.zip.sha512" diff --git a/_beats/dev-tools/packer/platforms/windows/uninstall-service.ps1.j2 b/_beats/dev-tools/packer/platforms/windows/uninstall-service.ps1.j2 deleted file mode 100644 index c9e753c7ce..0000000000 --- a/_beats/dev-tools/packer/platforms/windows/uninstall-service.ps1.j2 +++ /dev/null @@ -1,5 +0,0 @@ -# delete service if it exists -if (Get-Service {{.beat_name}} -ErrorAction SilentlyContinue) { - $service = Get-WmiObject -Class Win32_Service -Filter "name='{{.beat_name}}'" - $service.delete() -} diff --git a/_beats/dev-tools/packer/version.yml b/_beats/dev-tools/packer/version.yml deleted file mode 100644 index 5d5f902f66..0000000000 --- a/_beats/dev-tools/packer/version.yml +++ /dev/null @@ -1 +0,0 @@ -version: "7.0.0-alpha1" diff --git a/_beats/dev-tools/packer/xgo-scripts/before_build.sh b/_beats/dev-tools/packer/xgo-scripts/before_build.sh deleted file mode 100755 index ba80f676ff..0000000000 --- a/_beats/dev-tools/packer/xgo-scripts/before_build.sh +++ /dev/null @@ -1,68 +0,0 @@ -#!/bin/sh - -set -e - -if [ $BEAT_NAME = "packetbeat" ]; then - patch -p1 < /gopacket_pcap.patch -fi - -cd $GOPATH/src/$BEAT_PATH - -# Files must be copied before before-build calls to allow modifications on the config files - -PREFIX=/build - -# Copy fields.yml -cp fields.yml $PREFIX/fields.yml - -# linux -cp $BEAT_NAME.yml $PREFIX/$BEAT_NAME-linux.yml -chmod 0600 $PREFIX/$BEAT_NAME-linux.yml -chmod 0600 $PREFIX/$BEAT_NAME-linux-386.yml || true -if [ -z "${BEAT_REF_YAML}" ] || [ ${BEAT_REF_YAML} = true ]; then - cp $BEAT_NAME.reference.yml $PREFIX/$BEAT_NAME-linux.reference.yml -fi -rm -rf $PREFIX/modules.d-linux -cp -r modules.d/ $PREFIX/modules.d-linux || true -[ -d "$PREFIX/modules.d-linux" ] && chmod 0755 $PREFIX/modules.d-linux - -# darwin -cp $BEAT_NAME.yml $PREFIX/$BEAT_NAME-darwin.yml -chmod 0600 $PREFIX/$BEAT_NAME-darwin.yml -if [ -z "${BEAT_REF_YAML}" ] || [ ${BEAT_REF_YAML} = true ]; then - cp $BEAT_NAME.reference.yml $PREFIX/$BEAT_NAME-darwin.reference.yml -fi -rm -rf $PREFIX/modules.d-darwin -cp -r modules.d/ $PREFIX/modules.d-darwin || true -[ -d "$PREFIX/modules.d-darwin" ] && chmod 0755 $PREFIX/modules.d-darwin - -# win -cp $BEAT_NAME.yml $PREFIX/$BEAT_NAME-win.yml -chmod 0600 $PREFIX/$BEAT_NAME-win.yml -if [ -z "${BEAT_REF_YAML}" ] || [ ${BEAT_REF_YAML} = true ]; then - cp $BEAT_NAME.reference.yml $PREFIX/$BEAT_NAME-win.reference.yml -fi -rm -rf $PREFIX/modules.d-win -cp -r modules.d/ $PREFIX/modules.d-win || true -[ -d "$PREFIX/modules.d-win" ] && chmod 0755 $PREFIX/modules.d-win - -# Runs beat specific tasks which should be done before building -PREFIX=$PREFIX make before-build - -# Add data to the home directory -mkdir -p $PREFIX/homedir -make install-home HOME_PREFIX=$PREFIX/homedir LICENSE_FILE=${LICENSE_FILE} - -if [ -n "BUILDID" ]; then - echo "$BUILDID" > $PREFIX/homedir/.build_hash.txt -fi - -# Append doc versions to package.yml -cat ${ES_BEATS}/libbeat/docs/version.asciidoc >> ${PREFIX}/package.yml - -# Make variable naming of doc-branch compatible with gotpl. Generate and copy README.md into homedir -# Add " to the version as gotpl interprets 6.0 as 6 -sed -i -e 's/:doc-branch: \(.*\)/doc_branch: "\1" /g' ${PREFIX}/package.yml - -# Create README file -/go/bin/gotpl /templates/readme.md.j2 < ${PREFIX}/package.yml > ${PREFIX}/homedir/README.md diff --git a/_beats/dev-tools/vendor/github.com/tsg/go-daemon/LICENSE b/_beats/dev-tools/vendor/github.com/tsg/go-daemon/LICENSE new file mode 100644 index 0000000000..168a95e31f --- /dev/null +++ b/_beats/dev-tools/vendor/github.com/tsg/go-daemon/LICENSE @@ -0,0 +1,27 @@ +Copyright (c) 2013-2014 Alexandre Fiori. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the following disclaimer +in the documentation and/or other materials provided with the +distribution. + * The names of authors or contributors may NOT be used to endorse or +promote products derived from this software without specific prior +written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/_beats/dev-tools/vendor/github.com/tsg/go-daemon/god.c b/_beats/dev-tools/vendor/github.com/tsg/go-daemon/god.c new file mode 100644 index 0000000000..7f63e081ef --- /dev/null +++ b/_beats/dev-tools/vendor/github.com/tsg/go-daemon/god.c @@ -0,0 +1,313 @@ +// Copyright 2013-2014 Alexandre Fiori +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +void usage() { + printf( + "Use: god [options] [--] program [arguments]\n" + "Options:\n" + "-h --help show this help and exit\n" + "-v --version show version and exit\n" + "-f --foreground run in foreground\n" + "-n --nohup make the program immune to SIGHUP\n" + "-l --logfile FILE write the program's stdout and stderr to FILE\n" + "-p --pidfile FILE write pid to FILE\n" + "-r --rundir DIR switch to DIR before executing the program\n" + "-u --user USER switch to USER before executing the program\n" + "-g --group GROUP switch to GROUP before executing the program\n" + "\nThe program's output go to a blackhole if no logfile is set.\n" + "Log files are recycled on SIGHUP.\n" + ); + exit(1); +} + +static int nohup = 0; +static int logfd[2]; // pipe +static pid_t childpid = 0; +static FILE *logfp = NULL; +static FILE *pidfp = NULL; +static char logfile[PATH_MAX]; +static char pidfile[PATH_MAX]; +static char linebuf[1024]; +static struct passwd *pwd = NULL; +static struct group *grp = NULL; +static pthread_mutex_t logger_mutex; + +void daemon_main(int optind, char **argv); +void *logger_thread(void *cmdname); +void sighup(int signum); +void sigfwd(int signum); + +int main(int argc, char **argv) { + char rundir[PATH_MAX]; + char user[64]; + char group[64]; + int foreground = 0; + struct stat exec_stat; + + memset(logfile, 0, sizeof logfile); + memset(pidfile, 0, sizeof pidfile); + memset(rundir, 0, sizeof rundir); + memset(user, 0, sizeof user); + memset(group, 0, sizeof group); + + static struct option opts[] = { + { "help", no_argument, NULL, 'h' }, + { "version", no_argument, NULL, 'v' }, + { "foreground", no_argument, NULL, 'f' }, + { "nohup", no_argument, NULL, 'n' }, + { "logfile", required_argument, NULL, 'l' }, + { "pidfile", required_argument, NULL, 'p' }, + { "rundir", required_argument, NULL, 'r' }, + { "user", required_argument, NULL, 'u' }, + { "group", required_argument, NULL, 'g' }, + { NULL, 0, NULL, 0 }, + }; + + int ch; + while (1) { + ch = getopt_long(argc, argv, "l:p:r:u:g:hvfns", opts, NULL); + if (ch == -1) + break; + + switch (ch) { + case 'v': + printf("Go daemon v1.2\n"); + printf("http://github.com/fiorix/go-daemon\n"); + return 0; + case 'f': + foreground = 1; + break; + case 'n': + nohup = 1; + break; + case 'l': + strncpy(logfile, optarg, sizeof logfile - 1); + break; + case 'p': + strncpy(pidfile, optarg, sizeof pidfile - 1); + break; + case 'r': + strncpy(rundir, optarg, sizeof rundir - 1); + break; + case 'u': + strncpy(user, optarg, sizeof user - 1); + break; + case 'g': + strncpy(group, optarg, sizeof group - 1); + break; + default: + usage(); + } + } + + // utility is expected to be argv's leftovers. + if (optind >= argc) + usage(); + + if (*rundir != 0 && chdir(rundir) == -1) { + perror("failed to switch to rundir"); + return 1; + } + + if (*user != 0 && (pwd = getpwnam(user)) == NULL) { + fprintf(stderr, "failed to switch to user %s: %s\n", + user, strerror(errno)); + return 1; + } + + if (*group != 0 && (grp = getgrnam(group)) == NULL) { + fprintf(stderr, "failed to switch to group %s: %s\n", + group, strerror(errno)); + return 1; + } + + if (*logfile != 0 && (logfp = fopen(logfile, "a")) == NULL) { + perror("failed to open logfile"); + return 1; + } + if (logfp) + setvbuf(logfp, linebuf, _IOLBF, sizeof linebuf); + + if (*pidfile != 0 && (pidfp = fopen(pidfile, "w+")) == NULL) { + perror("failed to open pidfile"); + return 1; + } + + if (grp != NULL && setegid(grp->gr_gid) == -1) { + fprintf(stderr, "failed to switch to group %s: %s\n", + group, strerror(errno)); + return 1; + } + + if (pwd != NULL && seteuid(pwd->pw_uid) == -1) { + fprintf(stderr, "failed to switch to user %s: %s\n", + user, strerror(errno)); + return 1; + } + + if (stat(argv[optind], &exec_stat) < 0) { + fprintf(stderr, "failed to stat %s: %s\n", + argv[optind], strerror(errno)); + return 1; + } + if (!(exec_stat.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH))) { + fprintf(stderr, "permission denied: %s\n", + argv[optind]); + return 1; + } + + if (foreground) { + daemon_main(optind, argv); + } else { + // Daemonize. + pid_t pid = fork(); + if (pid) { + waitpid(pid, NULL, 0); + } else if (!pid) { + if ((pid = fork())) { + exit(0); + } else if (!pid) { + close(0); + close(1); + close(2); + daemon_main(optind, argv); + } else { + perror("fork"); + exit(1); + } + } else { + perror("fork"); + exit(1); + } + } + + return 0; +} + +void daemon_main(int optind, char **argv) { + if (pidfp) { + fprintf(pidfp, "%d\n", getpid()); + fclose(pidfp); + } + // Fwd all signals to the child, except SIGHUP. + int signum; + for (signum = 1; signum < 33; signum++) { + if (signal(signum, sigfwd) == SIG_IGN) + signal(signum, SIG_IGN); + } + signal(SIGHUP, sighup); + pipe(logfd); + if ((childpid = fork())) { + close(logfd[1]); + pthread_t logth; + pthread_create(&logth, NULL, logger_thread, argv[optind]); + waitpid(childpid, NULL, 0); + pthread_join(logth, NULL); + } else if (!childpid) { + close(logfd[0]); + close(0); + close(1); + close(2); + dup2(logfd[1], 1); + dup2(logfd[1], 2); + execvp(argv[optind], argv + optind); + printf("\x1b%s", strerror(errno)); + fflush(stdout); + close(logfd[1]); + close(1); + close(2); + } else { + perror("fork"); + exit(1); + } + if (pidfp) + unlink(pidfile); +} + +void *logger_thread(void *cmdname) { + int n; + char buf[4096]; + int has_read = 0; + + while(1) { + // read() will fail when the child process fails + // to execute or dies, and closes its terminal. + // This is what terminates this thread and therefore + // the main thread can move along. + n = read(logfd[0], buf, sizeof buf); + if (n <= 0) + break; + + buf[n] = 0; + if (!has_read) { + has_read = 1; + if (*buf == '\x1b') { + char *p = buf; + printf("%s: %s\n", (char *) cmdname, ++p); + close(logfd[0]); + break; + } + } + + pthread_mutex_lock(&logger_mutex); + if (logfp) { + fwrite(buf, 1, n, logfp); + //fflush(logfp); + } + pthread_mutex_unlock(&logger_mutex); + } + + return NULL; +} + +void sighup(int signum) { + if (pwd != NULL) { + seteuid(getuid()); + } + if (grp != NULL) { + setegid(getgid()); + } + pthread_mutex_lock(&logger_mutex); + if (logfp) { + FILE *fp = fopen(logfile, "a"); + if (fp != NULL) { + fclose(logfp); + logfp = fp; + setvbuf(logfp, linebuf, _IOLBF, sizeof linebuf); + } + } + if (grp != NULL) { + setegid(grp->gr_gid); + } + if (pwd != NULL) { + seteuid(pwd->pw_uid); + } + pthread_mutex_unlock(&logger_mutex); + if (!nohup && childpid) // nonohup :~ + kill(childpid, signum); +} + +void sigfwd(int signum) { + if (childpid) + kill(childpid, signum); +} diff --git a/_beats/dev-tools/vendor/github.com/tsg/gotpl/LICENSE b/_beats/dev-tools/vendor/github.com/tsg/gotpl/LICENSE deleted file mode 100644 index 51fca54c2a..0000000000 --- a/_beats/dev-tools/vendor/github.com/tsg/gotpl/LICENSE +++ /dev/null @@ -1,11 +0,0 @@ -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. diff --git a/_beats/dev-tools/vendor/github.com/tsg/gotpl/README.md b/_beats/dev-tools/vendor/github.com/tsg/gotpl/README.md deleted file mode 100644 index 6914c14836..0000000000 --- a/_beats/dev-tools/vendor/github.com/tsg/gotpl/README.md +++ /dev/null @@ -1,26 +0,0 @@ -# gotpl - CLI tool for Golang templates - -Command line tool that compiles Golang -[templates](http://golang.org/pkg/text/template/) with values from YAML files. - -Inspired by Python/Jinja2's [j2cli](https://github.com/kolypto/j2cli). - -## Install - - go get github.com/tsg/gotpl - -## Usage - -Say you have a `template` file like this: - - {{.first_name}} {{.last_name}} is {{.age}} years old. - -and a `user.yml` YAML file like this one: - - first_name: Max - last_name: Mustermann - age: 30 - -You can compile the template like this: - - gotpl template < user.yml diff --git a/_beats/dev-tools/vendor/github.com/tsg/gotpl/tpl.go b/_beats/dev-tools/vendor/github.com/tsg/gotpl/tpl.go deleted file mode 100644 index 563d847136..0000000000 --- a/_beats/dev-tools/vendor/github.com/tsg/gotpl/tpl.go +++ /dev/null @@ -1,48 +0,0 @@ -package main - -import ( - "bytes" - "fmt" - "io" - "log" - "os" - "text/template" - - "gopkg.in/yaml.v2" -) - -// Reads a YAML document from the values_in stream, uses it as values -// for the tpl_files templates and writes the executed templates to -// the out stream. -func ExecuteTemplates(values_in io.Reader, out io.Writer, tpl_files ...string) error { - tpl, err := template.ParseFiles(tpl_files...) - if err != nil { - return fmt.Errorf("Error parsing template(s): %v", err) - } - - buf := bytes.NewBuffer(nil) - _, err = io.Copy(buf, values_in) - if err != nil { - return fmt.Errorf("Failed to read standard input: %v", err) - } - - var values map[string]interface{} - err = yaml.Unmarshal(buf.Bytes(), &values) - if err != nil { - return fmt.Errorf("Failed to parse standard input: %v", err) - } - - err = tpl.Execute(out, values) - if err != nil { - return fmt.Errorf("Failed to parse standard input: %v", err) - } - return nil -} - -func main() { - err := ExecuteTemplates(os.Stdin, os.Stdout, os.Args[1:]...) - if err != nil { - log.Println(err) - os.Exit(1) - } -} diff --git a/_beats/dev-tools/vendor/golang.org/x/tools/LICENSE b/_beats/dev-tools/vendor/golang.org/x/tools/LICENSE new file mode 100644 index 0000000000..6a66aea5ea --- /dev/null +++ b/_beats/dev-tools/vendor/golang.org/x/tools/LICENSE @@ -0,0 +1,27 @@ +Copyright (c) 2009 The Go Authors. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the following disclaimer +in the documentation and/or other materials provided with the +distribution. + * Neither the name of Google Inc. nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/_beats/dev-tools/vendor/golang.org/x/tools/PATENTS b/_beats/dev-tools/vendor/golang.org/x/tools/PATENTS new file mode 100644 index 0000000000..733099041f --- /dev/null +++ b/_beats/dev-tools/vendor/golang.org/x/tools/PATENTS @@ -0,0 +1,22 @@ +Additional IP Rights Grant (Patents) + +"This implementation" means the copyrightable works distributed by +Google as part of the Go project. + +Google hereby grants to You a perpetual, worldwide, non-exclusive, +no-charge, royalty-free, irrevocable (except as stated in this section) +patent license to make, have made, use, offer to sell, sell, import, +transfer and otherwise run, modify and propagate the contents of this +implementation of Go, where such license applies only to those patent +claims, both currently owned or controlled by Google and acquired in +the future, licensable by Google that are necessarily infringed by this +implementation of Go. This grant does not include claims that would be +infringed only as a consequence of further modification of this +implementation. If you or your agent or exclusive licensee institute or +order or agree to the institution of patent litigation against any +entity (including a cross-claim or counterclaim in a lawsuit) alleging +that this implementation of Go or any code incorporated within this +implementation of Go constitutes direct or contributory patent +infringement, or inducement of patent infringement, then any patent +rights granted to you under this License for this implementation of Go +shall terminate as of the date such litigation is filed. diff --git a/_beats/dev-tools/vendor/golang.org/x/tools/go/vcs/discovery.go b/_beats/dev-tools/vendor/golang.org/x/tools/go/vcs/discovery.go new file mode 100644 index 0000000000..f431dc1c5b --- /dev/null +++ b/_beats/dev-tools/vendor/golang.org/x/tools/go/vcs/discovery.go @@ -0,0 +1,76 @@ +// Copyright 2012 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. + +package vcs + +import ( + "encoding/xml" + "fmt" + "io" + "strings" +) + +// charsetReader returns a reader for the given charset. Currently +// it only supports UTF-8 and ASCII. Otherwise, it returns a meaningful +// error which is printed by go get, so the user can find why the package +// wasn't downloaded if the encoding is not supported. Note that, in +// order to reduce potential errors, ASCII is treated as UTF-8 (i.e. characters +// greater than 0x7f are not rejected). +func charsetReader(charset string, input io.Reader) (io.Reader, error) { + switch strings.ToLower(charset) { + case "ascii": + return input, nil + default: + return nil, fmt.Errorf("can't decode XML document using charset %q", charset) + } +} + +// parseMetaGoImports returns meta imports from the HTML in r. +// Parsing ends at the end of the section or the beginning of the . +func parseMetaGoImports(r io.Reader) (imports []metaImport, err error) { + d := xml.NewDecoder(r) + d.CharsetReader = charsetReader + d.Strict = false + var t xml.Token + for { + t, err = d.Token() + if err != nil { + if err == io.EOF || len(imports) > 0 { + err = nil + } + return + } + if e, ok := t.(xml.StartElement); ok && strings.EqualFold(e.Name.Local, "body") { + return + } + if e, ok := t.(xml.EndElement); ok && strings.EqualFold(e.Name.Local, "head") { + return + } + e, ok := t.(xml.StartElement) + if !ok || !strings.EqualFold(e.Name.Local, "meta") { + continue + } + if attrValue(e.Attr, "name") != "go-import" { + continue + } + if f := strings.Fields(attrValue(e.Attr, "content")); len(f) == 3 { + imports = append(imports, metaImport{ + Prefix: f[0], + VCS: f[1], + RepoRoot: f[2], + }) + } + } +} + +// attrValue returns the attribute value for the case-insensitive key +// `name', or the empty string if nothing is found. +func attrValue(attrs []xml.Attr, name string) string { + for _, a := range attrs { + if strings.EqualFold(a.Name.Local, name) { + return a.Value + } + } + return "" +} diff --git a/_beats/dev-tools/vendor/golang.org/x/tools/go/vcs/env.go b/_beats/dev-tools/vendor/golang.org/x/tools/go/vcs/env.go new file mode 100644 index 0000000000..e846f5b3b8 --- /dev/null +++ b/_beats/dev-tools/vendor/golang.org/x/tools/go/vcs/env.go @@ -0,0 +1,39 @@ +// Copyright 2013 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. + +package vcs + +import ( + "os" + "strings" +) + +// envForDir returns a copy of the environment +// suitable for running in the given directory. +// The environment is the current process's environment +// but with an updated $PWD, so that an os.Getwd in the +// child will be faster. +func envForDir(dir string) []string { + env := os.Environ() + // Internally we only use rooted paths, so dir is rooted. + // Even if dir is not rooted, no harm done. + return mergeEnvLists([]string{"PWD=" + dir}, env) +} + +// mergeEnvLists merges the two environment lists such that +// variables with the same name in "in" replace those in "out". +func mergeEnvLists(in, out []string) []string { +NextVar: + for _, inkv := range in { + k := strings.SplitAfterN(inkv, "=", 2)[0] + for i, outkv := range out { + if strings.HasPrefix(outkv, k) { + out[i] = inkv + continue NextVar + } + } + out = append(out, inkv) + } + return out +} diff --git a/_beats/dev-tools/vendor/golang.org/x/tools/go/vcs/http.go b/_beats/dev-tools/vendor/golang.org/x/tools/go/vcs/http.go new file mode 100644 index 0000000000..96188185cb --- /dev/null +++ b/_beats/dev-tools/vendor/golang.org/x/tools/go/vcs/http.go @@ -0,0 +1,80 @@ +// Copyright 2012 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. + +package vcs + +import ( + "fmt" + "io" + "io/ioutil" + "log" + "net/http" + "net/url" +) + +// httpClient is the default HTTP client, but a variable so it can be +// changed by tests, without modifying http.DefaultClient. +var httpClient = http.DefaultClient + +// httpGET returns the data from an HTTP GET request for the given URL. +func httpGET(url string) ([]byte, error) { + resp, err := httpClient.Get(url) + if err != nil { + return nil, err + } + defer resp.Body.Close() + if resp.StatusCode != 200 { + return nil, fmt.Errorf("%s: %s", url, resp.Status) + } + b, err := ioutil.ReadAll(resp.Body) + if err != nil { + return nil, fmt.Errorf("%s: %v", url, err) + } + return b, nil +} + +// httpsOrHTTP returns the body of either the importPath's +// https resource or, if unavailable, the http resource. +func httpsOrHTTP(importPath string) (urlStr string, body io.ReadCloser, err error) { + fetch := func(scheme string) (urlStr string, res *http.Response, err error) { + u, err := url.Parse(scheme + "://" + importPath) + if err != nil { + return "", nil, err + } + u.RawQuery = "go-get=1" + urlStr = u.String() + if Verbose { + log.Printf("Fetching %s", urlStr) + } + res, err = httpClient.Get(urlStr) + return + } + closeBody := func(res *http.Response) { + if res != nil { + res.Body.Close() + } + } + urlStr, res, err := fetch("https") + if err != nil || res.StatusCode != 200 { + if Verbose { + if err != nil { + log.Printf("https fetch failed.") + } else { + log.Printf("ignoring https fetch with status code %d", res.StatusCode) + } + } + closeBody(res) + urlStr, res, err = fetch("http") + } + if err != nil { + closeBody(res) + return "", nil, err + } + // Note: accepting a non-200 OK here, so people can serve a + // meta import in their http 404 page. + if Verbose { + log.Printf("Parsing meta tags from %s (status code %d)", urlStr, res.StatusCode) + } + return urlStr, res.Body, nil +} diff --git a/_beats/dev-tools/vendor/golang.org/x/tools/go/vcs/vcs.go b/_beats/dev-tools/vendor/golang.org/x/tools/go/vcs/vcs.go new file mode 100644 index 0000000000..89319be04b --- /dev/null +++ b/_beats/dev-tools/vendor/golang.org/x/tools/go/vcs/vcs.go @@ -0,0 +1,755 @@ +// Copyright 2012 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. + +// Package vcs exposes functions for resolving import paths +// and using version control systems, which can be used to +// implement behavior similar to the standard "go get" command. +// +// This package is a copy of internal code in package cmd/go/internal/get, +// modified to make the identifiers exported. It's provided here +// for developers who want to write tools with similar semantics. +// It needs to be manually kept in sync with upstream when changes are +// made to cmd/go/internal/get; see https://golang.org/issues/11490. +// +package vcs // import "golang.org/x/tools/go/vcs" + +import ( + "bytes" + "encoding/json" + "errors" + "fmt" + "log" + "net/url" + "os" + "os/exec" + "path/filepath" + "regexp" + "strconv" + "strings" +) + +// Verbose enables verbose operation logging. +var Verbose bool + +// ShowCmd controls whether VCS commands are printed. +var ShowCmd bool + +// A Cmd describes how to use a version control system +// like Mercurial, Git, or Subversion. +type Cmd struct { + Name string + Cmd string // name of binary to invoke command + + CreateCmd string // command to download a fresh copy of a repository + DownloadCmd string // command to download updates into an existing repository + + TagCmd []TagCmd // commands to list tags + TagLookupCmd []TagCmd // commands to lookup tags before running tagSyncCmd + TagSyncCmd string // command to sync to specific tag + TagSyncDefault string // command to sync to default tag + + LogCmd string // command to list repository changelogs in an XML format + + Scheme []string + PingCmd string +} + +// A TagCmd describes a command to list available tags +// that can be passed to Cmd.TagSyncCmd. +type TagCmd struct { + Cmd string // command to list tags + Pattern string // regexp to extract tags from list +} + +// vcsList lists the known version control systems +var vcsList = []*Cmd{ + vcsHg, + vcsGit, + vcsSvn, + vcsBzr, +} + +// ByCmd returns the version control system for the given +// command name (hg, git, svn, bzr). +func ByCmd(cmd string) *Cmd { + for _, vcs := range vcsList { + if vcs.Cmd == cmd { + return vcs + } + } + return nil +} + +// vcsHg describes how to use Mercurial. +var vcsHg = &Cmd{ + Name: "Mercurial", + Cmd: "hg", + + CreateCmd: "clone -U {repo} {dir}", + DownloadCmd: "pull", + + // We allow both tag and branch names as 'tags' + // for selecting a version. This lets people have + // a go.release.r60 branch and a go1 branch + // and make changes in both, without constantly + // editing .hgtags. + TagCmd: []TagCmd{ + {"tags", `^(\S+)`}, + {"branches", `^(\S+)`}, + }, + TagSyncCmd: "update -r {tag}", + TagSyncDefault: "update default", + + LogCmd: "log --encoding=utf-8 --limit={limit} --template={template}", + + Scheme: []string{"https", "http", "ssh"}, + PingCmd: "identify {scheme}://{repo}", +} + +// vcsGit describes how to use Git. +var vcsGit = &Cmd{ + Name: "Git", + Cmd: "git", + + CreateCmd: "clone {repo} {dir}", + DownloadCmd: "pull --ff-only", + + TagCmd: []TagCmd{ + // tags/xxx matches a git tag named xxx + // origin/xxx matches a git branch named xxx on the default remote repository + {"show-ref", `(?:tags|origin)/(\S+)$`}, + }, + TagLookupCmd: []TagCmd{ + {"show-ref tags/{tag} origin/{tag}", `((?:tags|origin)/\S+)$`}, + }, + TagSyncCmd: "checkout {tag}", + TagSyncDefault: "checkout master", + + Scheme: []string{"git", "https", "http", "git+ssh"}, + PingCmd: "ls-remote {scheme}://{repo}", +} + +// vcsBzr describes how to use Bazaar. +var vcsBzr = &Cmd{ + Name: "Bazaar", + Cmd: "bzr", + + CreateCmd: "branch {repo} {dir}", + + // Without --overwrite bzr will not pull tags that changed. + // Replace by --overwrite-tags after http://pad.lv/681792 goes in. + DownloadCmd: "pull --overwrite", + + TagCmd: []TagCmd{{"tags", `^(\S+)`}}, + TagSyncCmd: "update -r {tag}", + TagSyncDefault: "update -r revno:-1", + + Scheme: []string{"https", "http", "bzr", "bzr+ssh"}, + PingCmd: "info {scheme}://{repo}", +} + +// vcsSvn describes how to use Subversion. +var vcsSvn = &Cmd{ + Name: "Subversion", + Cmd: "svn", + + CreateCmd: "checkout {repo} {dir}", + DownloadCmd: "update", + + // There is no tag command in subversion. + // The branch information is all in the path names. + + LogCmd: "log --xml --limit={limit}", + + Scheme: []string{"https", "http", "svn", "svn+ssh"}, + PingCmd: "info {scheme}://{repo}", +} + +func (v *Cmd) String() string { + return v.Name +} + +// run runs the command line cmd in the given directory. +// keyval is a list of key, value pairs. run expands +// instances of {key} in cmd into value, but only after +// splitting cmd into individual arguments. +// If an error occurs, run prints the command line and the +// command's combined stdout+stderr to standard error. +// Otherwise run discards the command's output. +func (v *Cmd) run(dir string, cmd string, keyval ...string) error { + _, err := v.run1(dir, cmd, keyval, true) + return err +} + +// runVerboseOnly is like run but only generates error output to standard error in verbose mode. +func (v *Cmd) runVerboseOnly(dir string, cmd string, keyval ...string) error { + _, err := v.run1(dir, cmd, keyval, false) + return err +} + +// runOutput is like run but returns the output of the command. +func (v *Cmd) runOutput(dir string, cmd string, keyval ...string) ([]byte, error) { + return v.run1(dir, cmd, keyval, true) +} + +// run1 is the generalized implementation of run and runOutput. +func (v *Cmd) run1(dir string, cmdline string, keyval []string, verbose bool) ([]byte, error) { + m := make(map[string]string) + for i := 0; i < len(keyval); i += 2 { + m[keyval[i]] = keyval[i+1] + } + args := strings.Fields(cmdline) + for i, arg := range args { + args[i] = expand(m, arg) + } + + _, err := exec.LookPath(v.Cmd) + if err != nil { + fmt.Fprintf(os.Stderr, + "go: missing %s command. See http://golang.org/s/gogetcmd\n", + v.Name) + return nil, err + } + + cmd := exec.Command(v.Cmd, args...) + cmd.Dir = dir + cmd.Env = envForDir(cmd.Dir) + if ShowCmd { + fmt.Printf("cd %s\n", dir) + fmt.Printf("%s %s\n", v.Cmd, strings.Join(args, " ")) + } + var buf bytes.Buffer + cmd.Stdout = &buf + cmd.Stderr = &buf + err = cmd.Run() + out := buf.Bytes() + if err != nil { + if verbose || Verbose { + fmt.Fprintf(os.Stderr, "# cd %s; %s %s\n", dir, v.Cmd, strings.Join(args, " ")) + os.Stderr.Write(out) + } + return nil, err + } + return out, nil +} + +// Ping pings the repo to determine if scheme used is valid. +// This repo must be pingable with this scheme and VCS. +func (v *Cmd) Ping(scheme, repo string) error { + return v.runVerboseOnly(".", v.PingCmd, "scheme", scheme, "repo", repo) +} + +// Create creates a new copy of repo in dir. +// The parent of dir must exist; dir must not. +func (v *Cmd) Create(dir, repo string) error { + return v.run(".", v.CreateCmd, "dir", dir, "repo", repo) +} + +// CreateAtRev creates a new copy of repo in dir at revision rev. +// The parent of dir must exist; dir must not. +// rev must be a valid revision in repo. +func (v *Cmd) CreateAtRev(dir, repo, rev string) error { + if err := v.Create(dir, repo); err != nil { + return err + } + return v.run(dir, v.TagSyncCmd, "tag", rev) +} + +// Download downloads any new changes for the repo in dir. +// dir must be a valid VCS repo compatible with v. +func (v *Cmd) Download(dir string) error { + return v.run(dir, v.DownloadCmd) +} + +// Tags returns the list of available tags for the repo in dir. +// dir must be a valid VCS repo compatible with v. +func (v *Cmd) Tags(dir string) ([]string, error) { + var tags []string + for _, tc := range v.TagCmd { + out, err := v.runOutput(dir, tc.Cmd) + if err != nil { + return nil, err + } + re := regexp.MustCompile(`(?m-s)` + tc.Pattern) + for _, m := range re.FindAllStringSubmatch(string(out), -1) { + tags = append(tags, m[1]) + } + } + return tags, nil +} + +// TagSync syncs the repo in dir to the named tag, which is either a +// tag returned by Tags or the empty string (the default tag). +// dir must be a valid VCS repo compatible with v and the tag must exist. +func (v *Cmd) TagSync(dir, tag string) error { + if v.TagSyncCmd == "" { + return nil + } + if tag != "" { + for _, tc := range v.TagLookupCmd { + out, err := v.runOutput(dir, tc.Cmd, "tag", tag) + if err != nil { + return err + } + re := regexp.MustCompile(`(?m-s)` + tc.Pattern) + m := re.FindStringSubmatch(string(out)) + if len(m) > 1 { + tag = m[1] + break + } + } + } + if tag == "" && v.TagSyncDefault != "" { + return v.run(dir, v.TagSyncDefault) + } + return v.run(dir, v.TagSyncCmd, "tag", tag) +} + +// Log logs the changes for the repo in dir. +// dir must be a valid VCS repo compatible with v. +func (v *Cmd) Log(dir, logTemplate string) ([]byte, error) { + if err := v.Download(dir); err != nil { + return []byte{}, err + } + + const N = 50 // how many revisions to grab + return v.runOutput(dir, v.LogCmd, "limit", strconv.Itoa(N), "template", logTemplate) +} + +// LogAtRev logs the change for repo in dir at the rev revision. +// dir must be a valid VCS repo compatible with v. +// rev must be a valid revision for the repo in dir. +func (v *Cmd) LogAtRev(dir, rev, logTemplate string) ([]byte, error) { + if err := v.Download(dir); err != nil { + return []byte{}, err + } + + // Append revision flag to LogCmd. + logAtRevCmd := v.LogCmd + " --rev=" + rev + return v.runOutput(dir, logAtRevCmd, "limit", strconv.Itoa(1), "template", logTemplate) +} + +// A vcsPath describes how to convert an import path into a +// version control system and repository name. +type vcsPath struct { + prefix string // prefix this description applies to + re string // pattern for import path + repo string // repository to use (expand with match of re) + vcs string // version control system to use (expand with match of re) + check func(match map[string]string) error // additional checks + ping bool // ping for scheme to use to download repo + + regexp *regexp.Regexp // cached compiled form of re +} + +// FromDir inspects dir and its parents to determine the +// version control system and code repository to use. +// On return, root is the import path +// corresponding to the root of the repository. +func FromDir(dir, srcRoot string) (vcs *Cmd, root string, err error) { + // Clean and double-check that dir is in (a subdirectory of) srcRoot. + dir = filepath.Clean(dir) + srcRoot = filepath.Clean(srcRoot) + if len(dir) <= len(srcRoot) || dir[len(srcRoot)] != filepath.Separator { + return nil, "", fmt.Errorf("directory %q is outside source root %q", dir, srcRoot) + } + + var vcsRet *Cmd + var rootRet string + + origDir := dir + for len(dir) > len(srcRoot) { + for _, vcs := range vcsList { + if _, err := os.Stat(filepath.Join(dir, "."+vcs.Cmd)); err == nil { + root := filepath.ToSlash(dir[len(srcRoot)+1:]) + // Record first VCS we find, but keep looking, + // to detect mistakes like one kind of VCS inside another. + if vcsRet == nil { + vcsRet = vcs + rootRet = root + continue + } + // Allow .git inside .git, which can arise due to submodules. + if vcsRet == vcs && vcs.Cmd == "git" { + continue + } + // Otherwise, we have one VCS inside a different VCS. + return nil, "", fmt.Errorf("directory %q uses %s, but parent %q uses %s", + filepath.Join(srcRoot, rootRet), vcsRet.Cmd, filepath.Join(srcRoot, root), vcs.Cmd) + } + } + + // Move to parent. + ndir := filepath.Dir(dir) + if len(ndir) >= len(dir) { + // Shouldn't happen, but just in case, stop. + break + } + dir = ndir + } + + if vcsRet != nil { + return vcsRet, rootRet, nil + } + + return nil, "", fmt.Errorf("directory %q is not using a known version control system", origDir) +} + +// RepoRoot represents a version control system, a repo, and a root of +// where to put it on disk. +type RepoRoot struct { + VCS *Cmd + + // Repo is the repository URL, including scheme. + Repo string + + // Root is the import path corresponding to the root of the + // repository. + Root string +} + +// RepoRootForImportPath analyzes importPath to determine the +// version control system, and code repository to use. +func RepoRootForImportPath(importPath string, verbose bool) (*RepoRoot, error) { + rr, err := RepoRootForImportPathStatic(importPath, "") + if err == errUnknownSite { + rr, err = RepoRootForImportDynamic(importPath, verbose) + + // RepoRootForImportDynamic returns error detail + // that is irrelevant if the user didn't intend to use a + // dynamic import in the first place. + // Squelch it. + if err != nil { + if Verbose { + log.Printf("import %q: %v", importPath, err) + } + err = fmt.Errorf("unrecognized import path %q", importPath) + } + } + + if err == nil && strings.Contains(importPath, "...") && strings.Contains(rr.Root, "...") { + // Do not allow wildcards in the repo root. + rr = nil + err = fmt.Errorf("cannot expand ... in %q", importPath) + } + return rr, err +} + +var errUnknownSite = errors.New("dynamic lookup required to find mapping") + +// RepoRootForImportPathStatic attempts to map importPath to a +// RepoRoot using the commonly-used VCS hosting sites in vcsPaths +// (github.com/user/dir), or from a fully-qualified importPath already +// containing its VCS type (foo.com/repo.git/dir) +// +// If scheme is non-empty, that scheme is forced. +func RepoRootForImportPathStatic(importPath, scheme string) (*RepoRoot, error) { + if strings.Contains(importPath, "://") { + return nil, fmt.Errorf("invalid import path %q", importPath) + } + for _, srv := range vcsPaths { + if !strings.HasPrefix(importPath, srv.prefix) { + continue + } + m := srv.regexp.FindStringSubmatch(importPath) + if m == nil { + if srv.prefix != "" { + return nil, fmt.Errorf("invalid %s import path %q", srv.prefix, importPath) + } + continue + } + + // Build map of named subexpression matches for expand. + match := map[string]string{ + "prefix": srv.prefix, + "import": importPath, + } + for i, name := range srv.regexp.SubexpNames() { + if name != "" && match[name] == "" { + match[name] = m[i] + } + } + if srv.vcs != "" { + match["vcs"] = expand(match, srv.vcs) + } + if srv.repo != "" { + match["repo"] = expand(match, srv.repo) + } + if srv.check != nil { + if err := srv.check(match); err != nil { + return nil, err + } + } + vcs := ByCmd(match["vcs"]) + if vcs == nil { + return nil, fmt.Errorf("unknown version control system %q", match["vcs"]) + } + if srv.ping { + if scheme != "" { + match["repo"] = scheme + "://" + match["repo"] + } else { + for _, scheme := range vcs.Scheme { + if vcs.Ping(scheme, match["repo"]) == nil { + match["repo"] = scheme + "://" + match["repo"] + break + } + } + } + } + rr := &RepoRoot{ + VCS: vcs, + Repo: match["repo"], + Root: match["root"], + } + return rr, nil + } + return nil, errUnknownSite +} + +// RepoRootForImportDynamic finds a *RepoRoot for a custom domain that's not +// statically known by RepoRootForImportPathStatic. +// +// This handles custom import paths like "name.tld/pkg/foo" or just "name.tld". +func RepoRootForImportDynamic(importPath string, verbose bool) (*RepoRoot, error) { + slash := strings.Index(importPath, "/") + if slash < 0 { + slash = len(importPath) + } + host := importPath[:slash] + if !strings.Contains(host, ".") { + return nil, errors.New("import path doesn't contain a hostname") + } + urlStr, body, err := httpsOrHTTP(importPath) + if err != nil { + return nil, fmt.Errorf("http/https fetch: %v", err) + } + defer body.Close() + imports, err := parseMetaGoImports(body) + if err != nil { + return nil, fmt.Errorf("parsing %s: %v", importPath, err) + } + metaImport, err := matchGoImport(imports, importPath) + if err != nil { + if err != errNoMatch { + return nil, fmt.Errorf("parse %s: %v", urlStr, err) + } + return nil, fmt.Errorf("parse %s: no go-import meta tags", urlStr) + } + if verbose { + log.Printf("get %q: found meta tag %#v at %s", importPath, metaImport, urlStr) + } + // If the import was "uni.edu/bob/project", which said the + // prefix was "uni.edu" and the RepoRoot was "evilroot.com", + // make sure we don't trust Bob and check out evilroot.com to + // "uni.edu" yet (possibly overwriting/preempting another + // non-evil student). Instead, first verify the root and see + // if it matches Bob's claim. + if metaImport.Prefix != importPath { + if verbose { + log.Printf("get %q: verifying non-authoritative meta tag", importPath) + } + urlStr0 := urlStr + urlStr, body, err = httpsOrHTTP(metaImport.Prefix) + if err != nil { + return nil, fmt.Errorf("fetch %s: %v", urlStr, err) + } + imports, err := parseMetaGoImports(body) + if err != nil { + return nil, fmt.Errorf("parsing %s: %v", importPath, err) + } + if len(imports) == 0 { + return nil, fmt.Errorf("fetch %s: no go-import meta tag", urlStr) + } + metaImport2, err := matchGoImport(imports, importPath) + if err != nil || metaImport != metaImport2 { + return nil, fmt.Errorf("%s and %s disagree about go-import for %s", urlStr0, urlStr, metaImport.Prefix) + } + } + + if err := validateRepoRoot(metaImport.RepoRoot); err != nil { + return nil, fmt.Errorf("%s: invalid repo root %q: %v", urlStr, metaImport.RepoRoot, err) + } + rr := &RepoRoot{ + VCS: ByCmd(metaImport.VCS), + Repo: metaImport.RepoRoot, + Root: metaImport.Prefix, + } + if rr.VCS == nil { + return nil, fmt.Errorf("%s: unknown vcs %q", urlStr, metaImport.VCS) + } + return rr, nil +} + +// validateRepoRoot returns an error if repoRoot does not seem to be +// a valid URL with scheme. +func validateRepoRoot(repoRoot string) error { + url, err := url.Parse(repoRoot) + if err != nil { + return err + } + if url.Scheme == "" { + return errors.New("no scheme") + } + return nil +} + +// metaImport represents the parsed tags from HTML files. +type metaImport struct { + Prefix, VCS, RepoRoot string +} + +// errNoMatch is returned from matchGoImport when there's no applicable match. +var errNoMatch = errors.New("no import match") + +// matchGoImport returns the metaImport from imports matching importPath. +// An error is returned if there are multiple matches. +// errNoMatch is returned if none match. +func matchGoImport(imports []metaImport, importPath string) (_ metaImport, err error) { + match := -1 + for i, im := range imports { + if !strings.HasPrefix(importPath, im.Prefix) { + continue + } + if match != -1 { + err = fmt.Errorf("multiple meta tags match import path %q", importPath) + return + } + match = i + } + if match == -1 { + err = errNoMatch + return + } + return imports[match], nil +} + +// expand rewrites s to replace {k} with match[k] for each key k in match. +func expand(match map[string]string, s string) string { + for k, v := range match { + s = strings.Replace(s, "{"+k+"}", v, -1) + } + return s +} + +// vcsPaths lists the known vcs paths. +var vcsPaths = []*vcsPath{ + // go.googlesource.com + { + prefix: "go.googlesource.com", + re: `^(?Pgo\.googlesource\.com/[A-Za-z0-9_.\-]+/?)$`, + vcs: "git", + repo: "https://{root}", + check: noVCSSuffix, + }, + + // Github + { + prefix: "github.com/", + re: `^(?Pgithub\.com/[A-Za-z0-9_.\-]+/[A-Za-z0-9_.\-]+)(/[\p{L}0-9_.\-]+)*$`, + vcs: "git", + repo: "https://{root}", + check: noVCSSuffix, + }, + + // Bitbucket + { + prefix: "bitbucket.org/", + re: `^(?Pbitbucket\.org/(?P[A-Za-z0-9_.\-]+/[A-Za-z0-9_.\-]+))(/[A-Za-z0-9_.\-]+)*$`, + repo: "https://{root}", + check: bitbucketVCS, + }, + + // Launchpad + { + prefix: "launchpad.net/", + re: `^(?Plaunchpad\.net/((?P[A-Za-z0-9_.\-]+)(?P/[A-Za-z0-9_.\-]+)?|~[A-Za-z0-9_.\-]+/(\+junk|[A-Za-z0-9_.\-]+)/[A-Za-z0-9_.\-]+))(/[A-Za-z0-9_.\-]+)*$`, + vcs: "bzr", + repo: "https://{root}", + check: launchpadVCS, + }, + + // Git at OpenStack + { + prefix: "git.openstack.org", + re: `^(?Pgit\.openstack\.org/[A-Za-z0-9_.\-]+/[A-Za-z0-9_.\-]+)(\.git)?(/[A-Za-z0-9_.\-]+)*$`, + vcs: "git", + repo: "https://{root}", + check: noVCSSuffix, + }, + + // General syntax for any server. + { + re: `^(?P(?P([a-z0-9.\-]+\.)+[a-z0-9.\-]+(:[0-9]+)?/[A-Za-z0-9_.\-/]*?)\.(?Pbzr|git|hg|svn))(/[A-Za-z0-9_.\-]+)*$`, + ping: true, + }, +} + +func init() { + // fill in cached regexps. + // Doing this eagerly discovers invalid regexp syntax + // without having to run a command that needs that regexp. + for _, srv := range vcsPaths { + srv.regexp = regexp.MustCompile(srv.re) + } +} + +// noVCSSuffix checks that the repository name does not +// end in .foo for any version control system foo. +// The usual culprit is ".git". +func noVCSSuffix(match map[string]string) error { + repo := match["repo"] + for _, vcs := range vcsList { + if strings.HasSuffix(repo, "."+vcs.Cmd) { + return fmt.Errorf("invalid version control suffix in %s path", match["prefix"]) + } + } + return nil +} + +// bitbucketVCS determines the version control system for a +// Bitbucket repository, by using the Bitbucket API. +func bitbucketVCS(match map[string]string) error { + if err := noVCSSuffix(match); err != nil { + return err + } + + var resp struct { + SCM string `json:"scm"` + } + url := expand(match, "https://api.bitbucket.org/1.0/repositories/{bitname}") + data, err := httpGET(url) + if err != nil { + return err + } + if err := json.Unmarshal(data, &resp); err != nil { + return fmt.Errorf("decoding %s: %v", url, err) + } + + if ByCmd(resp.SCM) != nil { + match["vcs"] = resp.SCM + if resp.SCM == "git" { + match["repo"] += ".git" + } + return nil + } + + return fmt.Errorf("unable to detect version control system for bitbucket.org/ path") +} + +// launchpadVCS solves the ambiguity for "lp.net/project/foo". In this case, +// "foo" could be a series name registered in Launchpad with its own branch, +// and it could also be the name of a directory within the main project +// branch one level up. +func launchpadVCS(match map[string]string) error { + if match["project"] == "" || match["series"] == "" { + return nil + } + _, err := httpGET(expand(match, "https://code.launchpad.net/{project}{series}/.bzr/branch-format")) + if err != nil { + match["root"] = expand(match, "launchpad.net/{project}") + match["repo"] = expand(match, "https://{root}") + } + return nil +} diff --git a/_beats/dev-tools/vendor/gopkg.in/yaml.v2/LICENSE.libyaml b/_beats/dev-tools/vendor/gopkg.in/yaml.v2/LICENSE.libyaml deleted file mode 100644 index 8da58fbf6f..0000000000 --- a/_beats/dev-tools/vendor/gopkg.in/yaml.v2/LICENSE.libyaml +++ /dev/null @@ -1,31 +0,0 @@ -The following files were ported to Go from C files of libyaml, and thus -are still covered by their original copyright and license: - - apic.go - emitterc.go - parserc.go - readerc.go - scannerc.go - writerc.go - yamlh.go - yamlprivateh.go - -Copyright (c) 2006 Kirill Simonov - -Permission is hereby granted, free of charge, to any person obtaining a copy of -this software and associated documentation files (the "Software"), to deal in -the Software without restriction, including without limitation the rights to -use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies -of the Software, and to permit persons to whom the Software is furnished to do -so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/_beats/dev-tools/vendor/gopkg.in/yaml.v2/README.md b/_beats/dev-tools/vendor/gopkg.in/yaml.v2/README.md deleted file mode 100644 index 2ed3314c73..0000000000 --- a/_beats/dev-tools/vendor/gopkg.in/yaml.v2/README.md +++ /dev/null @@ -1,135 +0,0 @@ -# YAML support for the Go language - -Introduction ------------- - -The yaml package enables Go programs to comfortably encode and decode YAML -values. It was developed within [Canonical](https://www.canonical.com) as -part of the [juju](https://juju.ubuntu.com) project, and is based on a -pure Go port of the well-known [libyaml](http://pyyaml.org/wiki/LibYAML) -C library to parse and generate YAML data quickly and reliably. - -Compatibility -------------- - -The yaml package supports most of YAML 1.1 and 1.2, including support for -anchors, tags, map merging, etc. Multi-document unmarshalling is not yet -implemented, and base-60 floats from YAML 1.1 are purposefully not -supported since they're a poor design and are gone in YAML 1.2. - -Installation and usage ----------------------- - -The import path for the package is *gopkg.in/yaml.v2*. - -To install it, run: - - go get gopkg.in/yaml.v2 - -API documentation ------------------ - -If opened in a browser, the import path itself leads to the API documentation: - - * [https://gopkg.in/yaml.v2](https://gopkg.in/yaml.v2) - -API stability -------------- - -The package API for yaml v2 will remain stable as described in [gopkg.in](https://gopkg.in). - - -License -------- - -The yaml package is licensed under the Apache License 2.0. Please see the LICENSE file for details. - - -Example -------- - -Some more examples can be found in the "examples" folder. - -```Go -package main - -import ( - "fmt" - "log" - - "gopkg.in/yaml.v2" -) - -var data = ` -a: Easy! -b: - c: 2 - d: [3, 4] -` - -// Note: struct fields must be public in order for unmarshal to -// correctly populate the data. -type T struct { - A string - B struct { - RenamedC int `yaml:"c"` - D []int `yaml:",flow"` - } -} - -func main() { - t := T{} - - err := yaml.Unmarshal([]byte(data), &t) - if err != nil { - log.Fatalf("error: %v", err) - } - fmt.Printf("--- t:\n%v\n\n", t) - - d, err := yaml.Marshal(&t) - if err != nil { - log.Fatalf("error: %v", err) - } - fmt.Printf("--- t dump:\n%s\n\n", string(d)) - - m := make(map[interface{}]interface{}) - - err = yaml.Unmarshal([]byte(data), &m) - if err != nil { - log.Fatalf("error: %v", err) - } - fmt.Printf("--- m:\n%v\n\n", m) - - d, err = yaml.Marshal(&m) - if err != nil { - log.Fatalf("error: %v", err) - } - fmt.Printf("--- m dump:\n%s\n\n", string(d)) -} -``` - -This example will generate the following output: - -``` ---- t: -{Easy! {2 [3 4]}} - ---- t dump: -a: Easy! -b: - c: 2 - d: [3, 4] - - ---- m: -map[a:Easy! b:map[c:2 d:[3 4]]] - ---- m dump: -a: Easy! -b: - c: 2 - d: - - 3 - - 4 -``` - diff --git a/_beats/dev-tools/vendor/gopkg.in/yaml.v2/apic.go b/_beats/dev-tools/vendor/gopkg.in/yaml.v2/apic.go deleted file mode 100644 index 95ec014e8c..0000000000 --- a/_beats/dev-tools/vendor/gopkg.in/yaml.v2/apic.go +++ /dev/null @@ -1,742 +0,0 @@ -package yaml - -import ( - "io" - "os" -) - -func yaml_insert_token(parser *yaml_parser_t, pos int, token *yaml_token_t) { - //fmt.Println("yaml_insert_token", "pos:", pos, "typ:", token.typ, "head:", parser.tokens_head, "len:", len(parser.tokens)) - - // Check if we can move the queue at the beginning of the buffer. - if parser.tokens_head > 0 && len(parser.tokens) == cap(parser.tokens) { - if parser.tokens_head != len(parser.tokens) { - copy(parser.tokens, parser.tokens[parser.tokens_head:]) - } - parser.tokens = parser.tokens[:len(parser.tokens)-parser.tokens_head] - parser.tokens_head = 0 - } - parser.tokens = append(parser.tokens, *token) - if pos < 0 { - return - } - copy(parser.tokens[parser.tokens_head+pos+1:], parser.tokens[parser.tokens_head+pos:]) - parser.tokens[parser.tokens_head+pos] = *token -} - -// Create a new parser object. -func yaml_parser_initialize(parser *yaml_parser_t) bool { - *parser = yaml_parser_t{ - raw_buffer: make([]byte, 0, input_raw_buffer_size), - buffer: make([]byte, 0, input_buffer_size), - } - return true -} - -// Destroy a parser object. -func yaml_parser_delete(parser *yaml_parser_t) { - *parser = yaml_parser_t{} -} - -// String read handler. -func yaml_string_read_handler(parser *yaml_parser_t, buffer []byte) (n int, err error) { - if parser.input_pos == len(parser.input) { - return 0, io.EOF - } - n = copy(buffer, parser.input[parser.input_pos:]) - parser.input_pos += n - return n, nil -} - -// File read handler. -func yaml_file_read_handler(parser *yaml_parser_t, buffer []byte) (n int, err error) { - return parser.input_file.Read(buffer) -} - -// Set a string input. -func yaml_parser_set_input_string(parser *yaml_parser_t, input []byte) { - if parser.read_handler != nil { - panic("must set the input source only once") - } - parser.read_handler = yaml_string_read_handler - parser.input = input - parser.input_pos = 0 -} - -// Set a file input. -func yaml_parser_set_input_file(parser *yaml_parser_t, file *os.File) { - if parser.read_handler != nil { - panic("must set the input source only once") - } - parser.read_handler = yaml_file_read_handler - parser.input_file = file -} - -// Set the source encoding. -func yaml_parser_set_encoding(parser *yaml_parser_t, encoding yaml_encoding_t) { - if parser.encoding != yaml_ANY_ENCODING { - panic("must set the encoding only once") - } - parser.encoding = encoding -} - -// Create a new emitter object. -func yaml_emitter_initialize(emitter *yaml_emitter_t) bool { - *emitter = yaml_emitter_t{ - buffer: make([]byte, output_buffer_size), - raw_buffer: make([]byte, 0, output_raw_buffer_size), - states: make([]yaml_emitter_state_t, 0, initial_stack_size), - events: make([]yaml_event_t, 0, initial_queue_size), - } - return true -} - -// Destroy an emitter object. -func yaml_emitter_delete(emitter *yaml_emitter_t) { - *emitter = yaml_emitter_t{} -} - -// String write handler. -func yaml_string_write_handler(emitter *yaml_emitter_t, buffer []byte) error { - *emitter.output_buffer = append(*emitter.output_buffer, buffer...) - return nil -} - -// File write handler. -func yaml_file_write_handler(emitter *yaml_emitter_t, buffer []byte) error { - _, err := emitter.output_file.Write(buffer) - return err -} - -// Set a string output. -func yaml_emitter_set_output_string(emitter *yaml_emitter_t, output_buffer *[]byte) { - if emitter.write_handler != nil { - panic("must set the output target only once") - } - emitter.write_handler = yaml_string_write_handler - emitter.output_buffer = output_buffer -} - -// Set a file output. -func yaml_emitter_set_output_file(emitter *yaml_emitter_t, file io.Writer) { - if emitter.write_handler != nil { - panic("must set the output target only once") - } - emitter.write_handler = yaml_file_write_handler - emitter.output_file = file -} - -// Set the output encoding. -func yaml_emitter_set_encoding(emitter *yaml_emitter_t, encoding yaml_encoding_t) { - if emitter.encoding != yaml_ANY_ENCODING { - panic("must set the output encoding only once") - } - emitter.encoding = encoding -} - -// Set the canonical output style. -func yaml_emitter_set_canonical(emitter *yaml_emitter_t, canonical bool) { - emitter.canonical = canonical -} - -//// Set the indentation increment. -func yaml_emitter_set_indent(emitter *yaml_emitter_t, indent int) { - if indent < 2 || indent > 9 { - indent = 2 - } - emitter.best_indent = indent -} - -// Set the preferred line width. -func yaml_emitter_set_width(emitter *yaml_emitter_t, width int) { - if width < 0 { - width = -1 - } - emitter.best_width = width -} - -// Set if unescaped non-ASCII characters are allowed. -func yaml_emitter_set_unicode(emitter *yaml_emitter_t, unicode bool) { - emitter.unicode = unicode -} - -// Set the preferred line break character. -func yaml_emitter_set_break(emitter *yaml_emitter_t, line_break yaml_break_t) { - emitter.line_break = line_break -} - -///* -// * Destroy a token object. -// */ -// -//YAML_DECLARE(void) -//yaml_token_delete(yaml_token_t *token) -//{ -// assert(token); // Non-NULL token object expected. -// -// switch (token.type) -// { -// case YAML_TAG_DIRECTIVE_TOKEN: -// yaml_free(token.data.tag_directive.handle); -// yaml_free(token.data.tag_directive.prefix); -// break; -// -// case YAML_ALIAS_TOKEN: -// yaml_free(token.data.alias.value); -// break; -// -// case YAML_ANCHOR_TOKEN: -// yaml_free(token.data.anchor.value); -// break; -// -// case YAML_TAG_TOKEN: -// yaml_free(token.data.tag.handle); -// yaml_free(token.data.tag.suffix); -// break; -// -// case YAML_SCALAR_TOKEN: -// yaml_free(token.data.scalar.value); -// break; -// -// default: -// break; -// } -// -// memset(token, 0, sizeof(yaml_token_t)); -//} -// -///* -// * Check if a string is a valid UTF-8 sequence. -// * -// * Check 'reader.c' for more details on UTF-8 encoding. -// */ -// -//static int -//yaml_check_utf8(yaml_char_t *start, size_t length) -//{ -// yaml_char_t *end = start+length; -// yaml_char_t *pointer = start; -// -// while (pointer < end) { -// unsigned char octet; -// unsigned int width; -// unsigned int value; -// size_t k; -// -// octet = pointer[0]; -// width = (octet & 0x80) == 0x00 ? 1 : -// (octet & 0xE0) == 0xC0 ? 2 : -// (octet & 0xF0) == 0xE0 ? 3 : -// (octet & 0xF8) == 0xF0 ? 4 : 0; -// value = (octet & 0x80) == 0x00 ? octet & 0x7F : -// (octet & 0xE0) == 0xC0 ? octet & 0x1F : -// (octet & 0xF0) == 0xE0 ? octet & 0x0F : -// (octet & 0xF8) == 0xF0 ? octet & 0x07 : 0; -// if (!width) return 0; -// if (pointer+width > end) return 0; -// for (k = 1; k < width; k ++) { -// octet = pointer[k]; -// if ((octet & 0xC0) != 0x80) return 0; -// value = (value << 6) + (octet & 0x3F); -// } -// if (!((width == 1) || -// (width == 2 && value >= 0x80) || -// (width == 3 && value >= 0x800) || -// (width == 4 && value >= 0x10000))) return 0; -// -// pointer += width; -// } -// -// return 1; -//} -// - -// Create STREAM-START. -func yaml_stream_start_event_initialize(event *yaml_event_t, encoding yaml_encoding_t) bool { - *event = yaml_event_t{ - typ: yaml_STREAM_START_EVENT, - encoding: encoding, - } - return true -} - -// Create STREAM-END. -func yaml_stream_end_event_initialize(event *yaml_event_t) bool { - *event = yaml_event_t{ - typ: yaml_STREAM_END_EVENT, - } - return true -} - -// Create DOCUMENT-START. -func yaml_document_start_event_initialize(event *yaml_event_t, version_directive *yaml_version_directive_t, - tag_directives []yaml_tag_directive_t, implicit bool) bool { - *event = yaml_event_t{ - typ: yaml_DOCUMENT_START_EVENT, - version_directive: version_directive, - tag_directives: tag_directives, - implicit: implicit, - } - return true -} - -// Create DOCUMENT-END. -func yaml_document_end_event_initialize(event *yaml_event_t, implicit bool) bool { - *event = yaml_event_t{ - typ: yaml_DOCUMENT_END_EVENT, - implicit: implicit, - } - return true -} - -///* -// * Create ALIAS. -// */ -// -//YAML_DECLARE(int) -//yaml_alias_event_initialize(event *yaml_event_t, anchor *yaml_char_t) -//{ -// mark yaml_mark_t = { 0, 0, 0 } -// anchor_copy *yaml_char_t = NULL -// -// assert(event) // Non-NULL event object is expected. -// assert(anchor) // Non-NULL anchor is expected. -// -// if (!yaml_check_utf8(anchor, strlen((char *)anchor))) return 0 -// -// anchor_copy = yaml_strdup(anchor) -// if (!anchor_copy) -// return 0 -// -// ALIAS_EVENT_INIT(*event, anchor_copy, mark, mark) -// -// return 1 -//} - -// Create SCALAR. -func yaml_scalar_event_initialize(event *yaml_event_t, anchor, tag, value []byte, plain_implicit, quoted_implicit bool, style yaml_scalar_style_t) bool { - *event = yaml_event_t{ - typ: yaml_SCALAR_EVENT, - anchor: anchor, - tag: tag, - value: value, - implicit: plain_implicit, - quoted_implicit: quoted_implicit, - style: yaml_style_t(style), - } - return true -} - -// Create SEQUENCE-START. -func yaml_sequence_start_event_initialize(event *yaml_event_t, anchor, tag []byte, implicit bool, style yaml_sequence_style_t) bool { - *event = yaml_event_t{ - typ: yaml_SEQUENCE_START_EVENT, - anchor: anchor, - tag: tag, - implicit: implicit, - style: yaml_style_t(style), - } - return true -} - -// Create SEQUENCE-END. -func yaml_sequence_end_event_initialize(event *yaml_event_t) bool { - *event = yaml_event_t{ - typ: yaml_SEQUENCE_END_EVENT, - } - return true -} - -// Create MAPPING-START. -func yaml_mapping_start_event_initialize(event *yaml_event_t, anchor, tag []byte, implicit bool, style yaml_mapping_style_t) bool { - *event = yaml_event_t{ - typ: yaml_MAPPING_START_EVENT, - anchor: anchor, - tag: tag, - implicit: implicit, - style: yaml_style_t(style), - } - return true -} - -// Create MAPPING-END. -func yaml_mapping_end_event_initialize(event *yaml_event_t) bool { - *event = yaml_event_t{ - typ: yaml_MAPPING_END_EVENT, - } - return true -} - -// Destroy an event object. -func yaml_event_delete(event *yaml_event_t) { - *event = yaml_event_t{} -} - -///* -// * Create a document object. -// */ -// -//YAML_DECLARE(int) -//yaml_document_initialize(document *yaml_document_t, -// version_directive *yaml_version_directive_t, -// tag_directives_start *yaml_tag_directive_t, -// tag_directives_end *yaml_tag_directive_t, -// start_implicit int, end_implicit int) -//{ -// struct { -// error yaml_error_type_t -// } context -// struct { -// start *yaml_node_t -// end *yaml_node_t -// top *yaml_node_t -// } nodes = { NULL, NULL, NULL } -// version_directive_copy *yaml_version_directive_t = NULL -// struct { -// start *yaml_tag_directive_t -// end *yaml_tag_directive_t -// top *yaml_tag_directive_t -// } tag_directives_copy = { NULL, NULL, NULL } -// value yaml_tag_directive_t = { NULL, NULL } -// mark yaml_mark_t = { 0, 0, 0 } -// -// assert(document) // Non-NULL document object is expected. -// assert((tag_directives_start && tag_directives_end) || -// (tag_directives_start == tag_directives_end)) -// // Valid tag directives are expected. -// -// if (!STACK_INIT(&context, nodes, INITIAL_STACK_SIZE)) goto error -// -// if (version_directive) { -// version_directive_copy = yaml_malloc(sizeof(yaml_version_directive_t)) -// if (!version_directive_copy) goto error -// version_directive_copy.major = version_directive.major -// version_directive_copy.minor = version_directive.minor -// } -// -// if (tag_directives_start != tag_directives_end) { -// tag_directive *yaml_tag_directive_t -// if (!STACK_INIT(&context, tag_directives_copy, INITIAL_STACK_SIZE)) -// goto error -// for (tag_directive = tag_directives_start -// tag_directive != tag_directives_end; tag_directive ++) { -// assert(tag_directive.handle) -// assert(tag_directive.prefix) -// if (!yaml_check_utf8(tag_directive.handle, -// strlen((char *)tag_directive.handle))) -// goto error -// if (!yaml_check_utf8(tag_directive.prefix, -// strlen((char *)tag_directive.prefix))) -// goto error -// value.handle = yaml_strdup(tag_directive.handle) -// value.prefix = yaml_strdup(tag_directive.prefix) -// if (!value.handle || !value.prefix) goto error -// if (!PUSH(&context, tag_directives_copy, value)) -// goto error -// value.handle = NULL -// value.prefix = NULL -// } -// } -// -// DOCUMENT_INIT(*document, nodes.start, nodes.end, version_directive_copy, -// tag_directives_copy.start, tag_directives_copy.top, -// start_implicit, end_implicit, mark, mark) -// -// return 1 -// -//error: -// STACK_DEL(&context, nodes) -// yaml_free(version_directive_copy) -// while (!STACK_EMPTY(&context, tag_directives_copy)) { -// value yaml_tag_directive_t = POP(&context, tag_directives_copy) -// yaml_free(value.handle) -// yaml_free(value.prefix) -// } -// STACK_DEL(&context, tag_directives_copy) -// yaml_free(value.handle) -// yaml_free(value.prefix) -// -// return 0 -//} -// -///* -// * Destroy a document object. -// */ -// -//YAML_DECLARE(void) -//yaml_document_delete(document *yaml_document_t) -//{ -// struct { -// error yaml_error_type_t -// } context -// tag_directive *yaml_tag_directive_t -// -// context.error = YAML_NO_ERROR // Eliminate a compliler warning. -// -// assert(document) // Non-NULL document object is expected. -// -// while (!STACK_EMPTY(&context, document.nodes)) { -// node yaml_node_t = POP(&context, document.nodes) -// yaml_free(node.tag) -// switch (node.type) { -// case YAML_SCALAR_NODE: -// yaml_free(node.data.scalar.value) -// break -// case YAML_SEQUENCE_NODE: -// STACK_DEL(&context, node.data.sequence.items) -// break -// case YAML_MAPPING_NODE: -// STACK_DEL(&context, node.data.mapping.pairs) -// break -// default: -// assert(0) // Should not happen. -// } -// } -// STACK_DEL(&context, document.nodes) -// -// yaml_free(document.version_directive) -// for (tag_directive = document.tag_directives.start -// tag_directive != document.tag_directives.end -// tag_directive++) { -// yaml_free(tag_directive.handle) -// yaml_free(tag_directive.prefix) -// } -// yaml_free(document.tag_directives.start) -// -// memset(document, 0, sizeof(yaml_document_t)) -//} -// -///** -// * Get a document node. -// */ -// -//YAML_DECLARE(yaml_node_t *) -//yaml_document_get_node(document *yaml_document_t, index int) -//{ -// assert(document) // Non-NULL document object is expected. -// -// if (index > 0 && document.nodes.start + index <= document.nodes.top) { -// return document.nodes.start + index - 1 -// } -// return NULL -//} -// -///** -// * Get the root object. -// */ -// -//YAML_DECLARE(yaml_node_t *) -//yaml_document_get_root_node(document *yaml_document_t) -//{ -// assert(document) // Non-NULL document object is expected. -// -// if (document.nodes.top != document.nodes.start) { -// return document.nodes.start -// } -// return NULL -//} -// -///* -// * Add a scalar node to a document. -// */ -// -//YAML_DECLARE(int) -//yaml_document_add_scalar(document *yaml_document_t, -// tag *yaml_char_t, value *yaml_char_t, length int, -// style yaml_scalar_style_t) -//{ -// struct { -// error yaml_error_type_t -// } context -// mark yaml_mark_t = { 0, 0, 0 } -// tag_copy *yaml_char_t = NULL -// value_copy *yaml_char_t = NULL -// node yaml_node_t -// -// assert(document) // Non-NULL document object is expected. -// assert(value) // Non-NULL value is expected. -// -// if (!tag) { -// tag = (yaml_char_t *)YAML_DEFAULT_SCALAR_TAG -// } -// -// if (!yaml_check_utf8(tag, strlen((char *)tag))) goto error -// tag_copy = yaml_strdup(tag) -// if (!tag_copy) goto error -// -// if (length < 0) { -// length = strlen((char *)value) -// } -// -// if (!yaml_check_utf8(value, length)) goto error -// value_copy = yaml_malloc(length+1) -// if (!value_copy) goto error -// memcpy(value_copy, value, length) -// value_copy[length] = '\0' -// -// SCALAR_NODE_INIT(node, tag_copy, value_copy, length, style, mark, mark) -// if (!PUSH(&context, document.nodes, node)) goto error -// -// return document.nodes.top - document.nodes.start -// -//error: -// yaml_free(tag_copy) -// yaml_free(value_copy) -// -// return 0 -//} -// -///* -// * Add a sequence node to a document. -// */ -// -//YAML_DECLARE(int) -//yaml_document_add_sequence(document *yaml_document_t, -// tag *yaml_char_t, style yaml_sequence_style_t) -//{ -// struct { -// error yaml_error_type_t -// } context -// mark yaml_mark_t = { 0, 0, 0 } -// tag_copy *yaml_char_t = NULL -// struct { -// start *yaml_node_item_t -// end *yaml_node_item_t -// top *yaml_node_item_t -// } items = { NULL, NULL, NULL } -// node yaml_node_t -// -// assert(document) // Non-NULL document object is expected. -// -// if (!tag) { -// tag = (yaml_char_t *)YAML_DEFAULT_SEQUENCE_TAG -// } -// -// if (!yaml_check_utf8(tag, strlen((char *)tag))) goto error -// tag_copy = yaml_strdup(tag) -// if (!tag_copy) goto error -// -// if (!STACK_INIT(&context, items, INITIAL_STACK_SIZE)) goto error -// -// SEQUENCE_NODE_INIT(node, tag_copy, items.start, items.end, -// style, mark, mark) -// if (!PUSH(&context, document.nodes, node)) goto error -// -// return document.nodes.top - document.nodes.start -// -//error: -// STACK_DEL(&context, items) -// yaml_free(tag_copy) -// -// return 0 -//} -// -///* -// * Add a mapping node to a document. -// */ -// -//YAML_DECLARE(int) -//yaml_document_add_mapping(document *yaml_document_t, -// tag *yaml_char_t, style yaml_mapping_style_t) -//{ -// struct { -// error yaml_error_type_t -// } context -// mark yaml_mark_t = { 0, 0, 0 } -// tag_copy *yaml_char_t = NULL -// struct { -// start *yaml_node_pair_t -// end *yaml_node_pair_t -// top *yaml_node_pair_t -// } pairs = { NULL, NULL, NULL } -// node yaml_node_t -// -// assert(document) // Non-NULL document object is expected. -// -// if (!tag) { -// tag = (yaml_char_t *)YAML_DEFAULT_MAPPING_TAG -// } -// -// if (!yaml_check_utf8(tag, strlen((char *)tag))) goto error -// tag_copy = yaml_strdup(tag) -// if (!tag_copy) goto error -// -// if (!STACK_INIT(&context, pairs, INITIAL_STACK_SIZE)) goto error -// -// MAPPING_NODE_INIT(node, tag_copy, pairs.start, pairs.end, -// style, mark, mark) -// if (!PUSH(&context, document.nodes, node)) goto error -// -// return document.nodes.top - document.nodes.start -// -//error: -// STACK_DEL(&context, pairs) -// yaml_free(tag_copy) -// -// return 0 -//} -// -///* -// * Append an item to a sequence node. -// */ -// -//YAML_DECLARE(int) -//yaml_document_append_sequence_item(document *yaml_document_t, -// sequence int, item int) -//{ -// struct { -// error yaml_error_type_t -// } context -// -// assert(document) // Non-NULL document is required. -// assert(sequence > 0 -// && document.nodes.start + sequence <= document.nodes.top) -// // Valid sequence id is required. -// assert(document.nodes.start[sequence-1].type == YAML_SEQUENCE_NODE) -// // A sequence node is required. -// assert(item > 0 && document.nodes.start + item <= document.nodes.top) -// // Valid item id is required. -// -// if (!PUSH(&context, -// document.nodes.start[sequence-1].data.sequence.items, item)) -// return 0 -// -// return 1 -//} -// -///* -// * Append a pair of a key and a value to a mapping node. -// */ -// -//YAML_DECLARE(int) -//yaml_document_append_mapping_pair(document *yaml_document_t, -// mapping int, key int, value int) -//{ -// struct { -// error yaml_error_type_t -// } context -// -// pair yaml_node_pair_t -// -// assert(document) // Non-NULL document is required. -// assert(mapping > 0 -// && document.nodes.start + mapping <= document.nodes.top) -// // Valid mapping id is required. -// assert(document.nodes.start[mapping-1].type == YAML_MAPPING_NODE) -// // A mapping node is required. -// assert(key > 0 && document.nodes.start + key <= document.nodes.top) -// // Valid key id is required. -// assert(value > 0 && document.nodes.start + value <= document.nodes.top) -// // Valid value id is required. -// -// pair.key = key -// pair.value = value -// -// if (!PUSH(&context, -// document.nodes.start[mapping-1].data.mapping.pairs, pair)) -// return 0 -// -// return 1 -//} -// -// diff --git a/_beats/dev-tools/vendor/gopkg.in/yaml.v2/decode.go b/_beats/dev-tools/vendor/gopkg.in/yaml.v2/decode.go deleted file mode 100644 index e85eb2e3fe..0000000000 --- a/_beats/dev-tools/vendor/gopkg.in/yaml.v2/decode.go +++ /dev/null @@ -1,685 +0,0 @@ -package yaml - -import ( - "encoding" - "encoding/base64" - "fmt" - "math" - "reflect" - "strconv" - "time" -) - -const ( - documentNode = 1 << iota - mappingNode - sequenceNode - scalarNode - aliasNode -) - -type node struct { - kind int - line, column int - tag string - value string - implicit bool - children []*node - anchors map[string]*node -} - -// ---------------------------------------------------------------------------- -// Parser, produces a node tree out of a libyaml event stream. - -type parser struct { - parser yaml_parser_t - event yaml_event_t - doc *node -} - -func newParser(b []byte) *parser { - p := parser{} - if !yaml_parser_initialize(&p.parser) { - panic("failed to initialize YAML emitter") - } - - if len(b) == 0 { - b = []byte{'\n'} - } - - yaml_parser_set_input_string(&p.parser, b) - - p.skip() - if p.event.typ != yaml_STREAM_START_EVENT { - panic("expected stream start event, got " + strconv.Itoa(int(p.event.typ))) - } - p.skip() - return &p -} - -func (p *parser) destroy() { - if p.event.typ != yaml_NO_EVENT { - yaml_event_delete(&p.event) - } - yaml_parser_delete(&p.parser) -} - -func (p *parser) skip() { - if p.event.typ != yaml_NO_EVENT { - if p.event.typ == yaml_STREAM_END_EVENT { - failf("attempted to go past the end of stream; corrupted value?") - } - yaml_event_delete(&p.event) - } - if !yaml_parser_parse(&p.parser, &p.event) { - p.fail() - } -} - -func (p *parser) fail() { - var where string - var line int - if p.parser.problem_mark.line != 0 { - line = p.parser.problem_mark.line - } else if p.parser.context_mark.line != 0 { - line = p.parser.context_mark.line - } - if line != 0 { - where = "line " + strconv.Itoa(line) + ": " - } - var msg string - if len(p.parser.problem) > 0 { - msg = p.parser.problem - } else { - msg = "unknown problem parsing YAML content" - } - failf("%s%s", where, msg) -} - -func (p *parser) anchor(n *node, anchor []byte) { - if anchor != nil { - p.doc.anchors[string(anchor)] = n - } -} - -func (p *parser) parse() *node { - switch p.event.typ { - case yaml_SCALAR_EVENT: - return p.scalar() - case yaml_ALIAS_EVENT: - return p.alias() - case yaml_MAPPING_START_EVENT: - return p.mapping() - case yaml_SEQUENCE_START_EVENT: - return p.sequence() - case yaml_DOCUMENT_START_EVENT: - return p.document() - case yaml_STREAM_END_EVENT: - // Happens when attempting to decode an empty buffer. - return nil - default: - panic("attempted to parse unknown event: " + strconv.Itoa(int(p.event.typ))) - } -} - -func (p *parser) node(kind int) *node { - return &node{ - kind: kind, - line: p.event.start_mark.line, - column: p.event.start_mark.column, - } -} - -func (p *parser) document() *node { - n := p.node(documentNode) - n.anchors = make(map[string]*node) - p.doc = n - p.skip() - n.children = append(n.children, p.parse()) - if p.event.typ != yaml_DOCUMENT_END_EVENT { - panic("expected end of document event but got " + strconv.Itoa(int(p.event.typ))) - } - p.skip() - return n -} - -func (p *parser) alias() *node { - n := p.node(aliasNode) - n.value = string(p.event.anchor) - p.skip() - return n -} - -func (p *parser) scalar() *node { - n := p.node(scalarNode) - n.value = string(p.event.value) - n.tag = string(p.event.tag) - n.implicit = p.event.implicit - p.anchor(n, p.event.anchor) - p.skip() - return n -} - -func (p *parser) sequence() *node { - n := p.node(sequenceNode) - p.anchor(n, p.event.anchor) - p.skip() - for p.event.typ != yaml_SEQUENCE_END_EVENT { - n.children = append(n.children, p.parse()) - } - p.skip() - return n -} - -func (p *parser) mapping() *node { - n := p.node(mappingNode) - p.anchor(n, p.event.anchor) - p.skip() - for p.event.typ != yaml_MAPPING_END_EVENT { - n.children = append(n.children, p.parse(), p.parse()) - } - p.skip() - return n -} - -// ---------------------------------------------------------------------------- -// Decoder, unmarshals a node into a provided value. - -type decoder struct { - doc *node - aliases map[string]bool - mapType reflect.Type - terrors []string - strict bool -} - -var ( - mapItemType = reflect.TypeOf(MapItem{}) - durationType = reflect.TypeOf(time.Duration(0)) - defaultMapType = reflect.TypeOf(map[interface{}]interface{}{}) - ifaceType = defaultMapType.Elem() -) - -func newDecoder(strict bool) *decoder { - d := &decoder{mapType: defaultMapType, strict: strict} - d.aliases = make(map[string]bool) - return d -} - -func (d *decoder) terror(n *node, tag string, out reflect.Value) { - if n.tag != "" { - tag = n.tag - } - value := n.value - if tag != yaml_SEQ_TAG && tag != yaml_MAP_TAG { - if len(value) > 10 { - value = " `" + value[:7] + "...`" - } else { - value = " `" + value + "`" - } - } - d.terrors = append(d.terrors, fmt.Sprintf("line %d: cannot unmarshal %s%s into %s", n.line+1, shortTag(tag), value, out.Type())) -} - -func (d *decoder) callUnmarshaler(n *node, u Unmarshaler) (good bool) { - terrlen := len(d.terrors) - err := u.UnmarshalYAML(func(v interface{}) (err error) { - defer handleErr(&err) - d.unmarshal(n, reflect.ValueOf(v)) - if len(d.terrors) > terrlen { - issues := d.terrors[terrlen:] - d.terrors = d.terrors[:terrlen] - return &TypeError{issues} - } - return nil - }) - if e, ok := err.(*TypeError); ok { - d.terrors = append(d.terrors, e.Errors...) - return false - } - if err != nil { - fail(err) - } - return true -} - -// d.prepare initializes and dereferences pointers and calls UnmarshalYAML -// if a value is found to implement it. -// It returns the initialized and dereferenced out value, whether -// unmarshalling was already done by UnmarshalYAML, and if so whether -// its types unmarshalled appropriately. -// -// If n holds a null value, prepare returns before doing anything. -func (d *decoder) prepare(n *node, out reflect.Value) (newout reflect.Value, unmarshaled, good bool) { - if n.tag == yaml_NULL_TAG || n.kind == scalarNode && n.tag == "" && (n.value == "null" || n.value == "~" || n.value == "" && n.implicit) { - return out, false, false - } - again := true - for again { - again = false - if out.Kind() == reflect.Ptr { - if out.IsNil() { - out.Set(reflect.New(out.Type().Elem())) - } - out = out.Elem() - again = true - } - if out.CanAddr() { - if u, ok := out.Addr().Interface().(Unmarshaler); ok { - good = d.callUnmarshaler(n, u) - return out, true, good - } - } - } - return out, false, false -} - -func (d *decoder) unmarshal(n *node, out reflect.Value) (good bool) { - switch n.kind { - case documentNode: - return d.document(n, out) - case aliasNode: - return d.alias(n, out) - } - out, unmarshaled, good := d.prepare(n, out) - if unmarshaled { - return good - } - switch n.kind { - case scalarNode: - good = d.scalar(n, out) - case mappingNode: - good = d.mapping(n, out) - case sequenceNode: - good = d.sequence(n, out) - default: - panic("internal error: unknown node kind: " + strconv.Itoa(n.kind)) - } - return good -} - -func (d *decoder) document(n *node, out reflect.Value) (good bool) { - if len(n.children) == 1 { - d.doc = n - d.unmarshal(n.children[0], out) - return true - } - return false -} - -func (d *decoder) alias(n *node, out reflect.Value) (good bool) { - an, ok := d.doc.anchors[n.value] - if !ok { - failf("unknown anchor '%s' referenced", n.value) - } - if d.aliases[n.value] { - failf("anchor '%s' value contains itself", n.value) - } - d.aliases[n.value] = true - good = d.unmarshal(an, out) - delete(d.aliases, n.value) - return good -} - -var zeroValue reflect.Value - -func resetMap(out reflect.Value) { - for _, k := range out.MapKeys() { - out.SetMapIndex(k, zeroValue) - } -} - -func (d *decoder) scalar(n *node, out reflect.Value) (good bool) { - var tag string - var resolved interface{} - if n.tag == "" && !n.implicit { - tag = yaml_STR_TAG - resolved = n.value - } else { - tag, resolved = resolve(n.tag, n.value) - if tag == yaml_BINARY_TAG { - data, err := base64.StdEncoding.DecodeString(resolved.(string)) - if err != nil { - failf("!!binary value contains invalid base64 data") - } - resolved = string(data) - } - } - if resolved == nil { - if out.Kind() == reflect.Map && !out.CanAddr() { - resetMap(out) - } else { - out.Set(reflect.Zero(out.Type())) - } - return true - } - if s, ok := resolved.(string); ok && out.CanAddr() { - if u, ok := out.Addr().Interface().(encoding.TextUnmarshaler); ok { - err := u.UnmarshalText([]byte(s)) - if err != nil { - fail(err) - } - return true - } - } - switch out.Kind() { - case reflect.String: - if tag == yaml_BINARY_TAG { - out.SetString(resolved.(string)) - good = true - } else if resolved != nil { - out.SetString(n.value) - good = true - } - case reflect.Interface: - if resolved == nil { - out.Set(reflect.Zero(out.Type())) - } else { - out.Set(reflect.ValueOf(resolved)) - } - good = true - case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: - switch resolved := resolved.(type) { - case int: - if !out.OverflowInt(int64(resolved)) { - out.SetInt(int64(resolved)) - good = true - } - case int64: - if !out.OverflowInt(resolved) { - out.SetInt(resolved) - good = true - } - case uint64: - if resolved <= math.MaxInt64 && !out.OverflowInt(int64(resolved)) { - out.SetInt(int64(resolved)) - good = true - } - case float64: - if resolved <= math.MaxInt64 && !out.OverflowInt(int64(resolved)) { - out.SetInt(int64(resolved)) - good = true - } - case string: - if out.Type() == durationType { - d, err := time.ParseDuration(resolved) - if err == nil { - out.SetInt(int64(d)) - good = true - } - } - } - case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr: - switch resolved := resolved.(type) { - case int: - if resolved >= 0 && !out.OverflowUint(uint64(resolved)) { - out.SetUint(uint64(resolved)) - good = true - } - case int64: - if resolved >= 0 && !out.OverflowUint(uint64(resolved)) { - out.SetUint(uint64(resolved)) - good = true - } - case uint64: - if !out.OverflowUint(uint64(resolved)) { - out.SetUint(uint64(resolved)) - good = true - } - case float64: - if resolved <= math.MaxUint64 && !out.OverflowUint(uint64(resolved)) { - out.SetUint(uint64(resolved)) - good = true - } - } - case reflect.Bool: - switch resolved := resolved.(type) { - case bool: - out.SetBool(resolved) - good = true - } - case reflect.Float32, reflect.Float64: - switch resolved := resolved.(type) { - case int: - out.SetFloat(float64(resolved)) - good = true - case int64: - out.SetFloat(float64(resolved)) - good = true - case uint64: - out.SetFloat(float64(resolved)) - good = true - case float64: - out.SetFloat(resolved) - good = true - } - case reflect.Ptr: - if out.Type().Elem() == reflect.TypeOf(resolved) { - // TODO DOes this make sense? When is out a Ptr except when decoding a nil value? - elem := reflect.New(out.Type().Elem()) - elem.Elem().Set(reflect.ValueOf(resolved)) - out.Set(elem) - good = true - } - } - if !good { - d.terror(n, tag, out) - } - return good -} - -func settableValueOf(i interface{}) reflect.Value { - v := reflect.ValueOf(i) - sv := reflect.New(v.Type()).Elem() - sv.Set(v) - return sv -} - -func (d *decoder) sequence(n *node, out reflect.Value) (good bool) { - l := len(n.children) - - var iface reflect.Value - switch out.Kind() { - case reflect.Slice: - out.Set(reflect.MakeSlice(out.Type(), l, l)) - case reflect.Interface: - // No type hints. Will have to use a generic sequence. - iface = out - out = settableValueOf(make([]interface{}, l)) - default: - d.terror(n, yaml_SEQ_TAG, out) - return false - } - et := out.Type().Elem() - - j := 0 - for i := 0; i < l; i++ { - e := reflect.New(et).Elem() - if ok := d.unmarshal(n.children[i], e); ok { - out.Index(j).Set(e) - j++ - } - } - out.Set(out.Slice(0, j)) - if iface.IsValid() { - iface.Set(out) - } - return true -} - -func (d *decoder) mapping(n *node, out reflect.Value) (good bool) { - switch out.Kind() { - case reflect.Struct: - return d.mappingStruct(n, out) - case reflect.Slice: - return d.mappingSlice(n, out) - case reflect.Map: - // okay - case reflect.Interface: - if d.mapType.Kind() == reflect.Map { - iface := out - out = reflect.MakeMap(d.mapType) - iface.Set(out) - } else { - slicev := reflect.New(d.mapType).Elem() - if !d.mappingSlice(n, slicev) { - return false - } - out.Set(slicev) - return true - } - default: - d.terror(n, yaml_MAP_TAG, out) - return false - } - outt := out.Type() - kt := outt.Key() - et := outt.Elem() - - mapType := d.mapType - if outt.Key() == ifaceType && outt.Elem() == ifaceType { - d.mapType = outt - } - - if out.IsNil() { - out.Set(reflect.MakeMap(outt)) - } - l := len(n.children) - for i := 0; i < l; i += 2 { - if isMerge(n.children[i]) { - d.merge(n.children[i+1], out) - continue - } - k := reflect.New(kt).Elem() - if d.unmarshal(n.children[i], k) { - kkind := k.Kind() - if kkind == reflect.Interface { - kkind = k.Elem().Kind() - } - if kkind == reflect.Map || kkind == reflect.Slice { - failf("invalid map key: %#v", k.Interface()) - } - e := reflect.New(et).Elem() - if d.unmarshal(n.children[i+1], e) { - out.SetMapIndex(k, e) - } - } - } - d.mapType = mapType - return true -} - -func (d *decoder) mappingSlice(n *node, out reflect.Value) (good bool) { - outt := out.Type() - if outt.Elem() != mapItemType { - d.terror(n, yaml_MAP_TAG, out) - return false - } - - mapType := d.mapType - d.mapType = outt - - var slice []MapItem - var l = len(n.children) - for i := 0; i < l; i += 2 { - if isMerge(n.children[i]) { - d.merge(n.children[i+1], out) - continue - } - item := MapItem{} - k := reflect.ValueOf(&item.Key).Elem() - if d.unmarshal(n.children[i], k) { - v := reflect.ValueOf(&item.Value).Elem() - if d.unmarshal(n.children[i+1], v) { - slice = append(slice, item) - } - } - } - out.Set(reflect.ValueOf(slice)) - d.mapType = mapType - return true -} - -func (d *decoder) mappingStruct(n *node, out reflect.Value) (good bool) { - sinfo, err := getStructInfo(out.Type()) - if err != nil { - panic(err) - } - name := settableValueOf("") - l := len(n.children) - - var inlineMap reflect.Value - var elemType reflect.Type - if sinfo.InlineMap != -1 { - inlineMap = out.Field(sinfo.InlineMap) - inlineMap.Set(reflect.New(inlineMap.Type()).Elem()) - elemType = inlineMap.Type().Elem() - } - - for i := 0; i < l; i += 2 { - ni := n.children[i] - if isMerge(ni) { - d.merge(n.children[i+1], out) - continue - } - if !d.unmarshal(ni, name) { - continue - } - if info, ok := sinfo.FieldsMap[name.String()]; ok { - var field reflect.Value - if info.Inline == nil { - field = out.Field(info.Num) - } else { - field = out.FieldByIndex(info.Inline) - } - d.unmarshal(n.children[i+1], field) - } else if sinfo.InlineMap != -1 { - if inlineMap.IsNil() { - inlineMap.Set(reflect.MakeMap(inlineMap.Type())) - } - value := reflect.New(elemType).Elem() - d.unmarshal(n.children[i+1], value) - inlineMap.SetMapIndex(name, value) - } else if d.strict { - d.terrors = append(d.terrors, fmt.Sprintf("line %d: field %s not found in struct %s", ni.line+1, name.String(), out.Type())) - } - } - return true -} - -func failWantMap() { - failf("map merge requires map or sequence of maps as the value") -} - -func (d *decoder) merge(n *node, out reflect.Value) { - switch n.kind { - case mappingNode: - d.unmarshal(n, out) - case aliasNode: - an, ok := d.doc.anchors[n.value] - if ok && an.kind != mappingNode { - failWantMap() - } - d.unmarshal(n, out) - case sequenceNode: - // Step backwards as earlier nodes take precedence. - for i := len(n.children) - 1; i >= 0; i-- { - ni := n.children[i] - if ni.kind == aliasNode { - an, ok := d.doc.anchors[ni.value] - if ok && an.kind != mappingNode { - failWantMap() - } - } else if ni.kind != mappingNode { - failWantMap() - } - d.unmarshal(ni, out) - } - default: - failWantMap() - } -} - -func isMerge(n *node) bool { - return n.kind == scalarNode && n.value == "<<" && (n.implicit == true || n.tag == yaml_MERGE_TAG) -} diff --git a/_beats/dev-tools/vendor/gopkg.in/yaml.v2/emitterc.go b/_beats/dev-tools/vendor/gopkg.in/yaml.v2/emitterc.go deleted file mode 100644 index dcaf502f0e..0000000000 --- a/_beats/dev-tools/vendor/gopkg.in/yaml.v2/emitterc.go +++ /dev/null @@ -1,1684 +0,0 @@ -package yaml - -import ( - "bytes" -) - -// Flush the buffer if needed. -func flush(emitter *yaml_emitter_t) bool { - if emitter.buffer_pos+5 >= len(emitter.buffer) { - return yaml_emitter_flush(emitter) - } - return true -} - -// Put a character to the output buffer. -func put(emitter *yaml_emitter_t, value byte) bool { - if emitter.buffer_pos+5 >= len(emitter.buffer) && !yaml_emitter_flush(emitter) { - return false - } - emitter.buffer[emitter.buffer_pos] = value - emitter.buffer_pos++ - emitter.column++ - return true -} - -// Put a line break to the output buffer. -func put_break(emitter *yaml_emitter_t) bool { - if emitter.buffer_pos+5 >= len(emitter.buffer) && !yaml_emitter_flush(emitter) { - return false - } - switch emitter.line_break { - case yaml_CR_BREAK: - emitter.buffer[emitter.buffer_pos] = '\r' - emitter.buffer_pos += 1 - case yaml_LN_BREAK: - emitter.buffer[emitter.buffer_pos] = '\n' - emitter.buffer_pos += 1 - case yaml_CRLN_BREAK: - emitter.buffer[emitter.buffer_pos+0] = '\r' - emitter.buffer[emitter.buffer_pos+1] = '\n' - emitter.buffer_pos += 2 - default: - panic("unknown line break setting") - } - emitter.column = 0 - emitter.line++ - return true -} - -// Copy a character from a string into buffer. -func write(emitter *yaml_emitter_t, s []byte, i *int) bool { - if emitter.buffer_pos+5 >= len(emitter.buffer) && !yaml_emitter_flush(emitter) { - return false - } - p := emitter.buffer_pos - w := width(s[*i]) - switch w { - case 4: - emitter.buffer[p+3] = s[*i+3] - fallthrough - case 3: - emitter.buffer[p+2] = s[*i+2] - fallthrough - case 2: - emitter.buffer[p+1] = s[*i+1] - fallthrough - case 1: - emitter.buffer[p+0] = s[*i+0] - default: - panic("unknown character width") - } - emitter.column++ - emitter.buffer_pos += w - *i += w - return true -} - -// Write a whole string into buffer. -func write_all(emitter *yaml_emitter_t, s []byte) bool { - for i := 0; i < len(s); { - if !write(emitter, s, &i) { - return false - } - } - return true -} - -// Copy a line break character from a string into buffer. -func write_break(emitter *yaml_emitter_t, s []byte, i *int) bool { - if s[*i] == '\n' { - if !put_break(emitter) { - return false - } - *i++ - } else { - if !write(emitter, s, i) { - return false - } - emitter.column = 0 - emitter.line++ - } - return true -} - -// Set an emitter error and return false. -func yaml_emitter_set_emitter_error(emitter *yaml_emitter_t, problem string) bool { - emitter.error = yaml_EMITTER_ERROR - emitter.problem = problem - return false -} - -// Emit an event. -func yaml_emitter_emit(emitter *yaml_emitter_t, event *yaml_event_t) bool { - emitter.events = append(emitter.events, *event) - for !yaml_emitter_need_more_events(emitter) { - event := &emitter.events[emitter.events_head] - if !yaml_emitter_analyze_event(emitter, event) { - return false - } - if !yaml_emitter_state_machine(emitter, event) { - return false - } - yaml_event_delete(event) - emitter.events_head++ - } - return true -} - -// Check if we need to accumulate more events before emitting. -// -// We accumulate extra -// - 1 event for DOCUMENT-START -// - 2 events for SEQUENCE-START -// - 3 events for MAPPING-START -// -func yaml_emitter_need_more_events(emitter *yaml_emitter_t) bool { - if emitter.events_head == len(emitter.events) { - return true - } - var accumulate int - switch emitter.events[emitter.events_head].typ { - case yaml_DOCUMENT_START_EVENT: - accumulate = 1 - break - case yaml_SEQUENCE_START_EVENT: - accumulate = 2 - break - case yaml_MAPPING_START_EVENT: - accumulate = 3 - break - default: - return false - } - if len(emitter.events)-emitter.events_head > accumulate { - return false - } - var level int - for i := emitter.events_head; i < len(emitter.events); i++ { - switch emitter.events[i].typ { - case yaml_STREAM_START_EVENT, yaml_DOCUMENT_START_EVENT, yaml_SEQUENCE_START_EVENT, yaml_MAPPING_START_EVENT: - level++ - case yaml_STREAM_END_EVENT, yaml_DOCUMENT_END_EVENT, yaml_SEQUENCE_END_EVENT, yaml_MAPPING_END_EVENT: - level-- - } - if level == 0 { - return false - } - } - return true -} - -// Append a directive to the directives stack. -func yaml_emitter_append_tag_directive(emitter *yaml_emitter_t, value *yaml_tag_directive_t, allow_duplicates bool) bool { - for i := 0; i < len(emitter.tag_directives); i++ { - if bytes.Equal(value.handle, emitter.tag_directives[i].handle) { - if allow_duplicates { - return true - } - return yaml_emitter_set_emitter_error(emitter, "duplicate %TAG directive") - } - } - - // [Go] Do we actually need to copy this given garbage collection - // and the lack of deallocating destructors? - tag_copy := yaml_tag_directive_t{ - handle: make([]byte, len(value.handle)), - prefix: make([]byte, len(value.prefix)), - } - copy(tag_copy.handle, value.handle) - copy(tag_copy.prefix, value.prefix) - emitter.tag_directives = append(emitter.tag_directives, tag_copy) - return true -} - -// Increase the indentation level. -func yaml_emitter_increase_indent(emitter *yaml_emitter_t, flow, indentless bool) bool { - emitter.indents = append(emitter.indents, emitter.indent) - if emitter.indent < 0 { - if flow { - emitter.indent = emitter.best_indent - } else { - emitter.indent = 0 - } - } else if !indentless { - emitter.indent += emitter.best_indent - } - return true -} - -// State dispatcher. -func yaml_emitter_state_machine(emitter *yaml_emitter_t, event *yaml_event_t) bool { - switch emitter.state { - default: - case yaml_EMIT_STREAM_START_STATE: - return yaml_emitter_emit_stream_start(emitter, event) - - case yaml_EMIT_FIRST_DOCUMENT_START_STATE: - return yaml_emitter_emit_document_start(emitter, event, true) - - case yaml_EMIT_DOCUMENT_START_STATE: - return yaml_emitter_emit_document_start(emitter, event, false) - - case yaml_EMIT_DOCUMENT_CONTENT_STATE: - return yaml_emitter_emit_document_content(emitter, event) - - case yaml_EMIT_DOCUMENT_END_STATE: - return yaml_emitter_emit_document_end(emitter, event) - - case yaml_EMIT_FLOW_SEQUENCE_FIRST_ITEM_STATE: - return yaml_emitter_emit_flow_sequence_item(emitter, event, true) - - case yaml_EMIT_FLOW_SEQUENCE_ITEM_STATE: - return yaml_emitter_emit_flow_sequence_item(emitter, event, false) - - case yaml_EMIT_FLOW_MAPPING_FIRST_KEY_STATE: - return yaml_emitter_emit_flow_mapping_key(emitter, event, true) - - case yaml_EMIT_FLOW_MAPPING_KEY_STATE: - return yaml_emitter_emit_flow_mapping_key(emitter, event, false) - - case yaml_EMIT_FLOW_MAPPING_SIMPLE_VALUE_STATE: - return yaml_emitter_emit_flow_mapping_value(emitter, event, true) - - case yaml_EMIT_FLOW_MAPPING_VALUE_STATE: - return yaml_emitter_emit_flow_mapping_value(emitter, event, false) - - case yaml_EMIT_BLOCK_SEQUENCE_FIRST_ITEM_STATE: - return yaml_emitter_emit_block_sequence_item(emitter, event, true) - - case yaml_EMIT_BLOCK_SEQUENCE_ITEM_STATE: - return yaml_emitter_emit_block_sequence_item(emitter, event, false) - - case yaml_EMIT_BLOCK_MAPPING_FIRST_KEY_STATE: - return yaml_emitter_emit_block_mapping_key(emitter, event, true) - - case yaml_EMIT_BLOCK_MAPPING_KEY_STATE: - return yaml_emitter_emit_block_mapping_key(emitter, event, false) - - case yaml_EMIT_BLOCK_MAPPING_SIMPLE_VALUE_STATE: - return yaml_emitter_emit_block_mapping_value(emitter, event, true) - - case yaml_EMIT_BLOCK_MAPPING_VALUE_STATE: - return yaml_emitter_emit_block_mapping_value(emitter, event, false) - - case yaml_EMIT_END_STATE: - return yaml_emitter_set_emitter_error(emitter, "expected nothing after STREAM-END") - } - panic("invalid emitter state") -} - -// Expect STREAM-START. -func yaml_emitter_emit_stream_start(emitter *yaml_emitter_t, event *yaml_event_t) bool { - if event.typ != yaml_STREAM_START_EVENT { - return yaml_emitter_set_emitter_error(emitter, "expected STREAM-START") - } - if emitter.encoding == yaml_ANY_ENCODING { - emitter.encoding = event.encoding - if emitter.encoding == yaml_ANY_ENCODING { - emitter.encoding = yaml_UTF8_ENCODING - } - } - if emitter.best_indent < 2 || emitter.best_indent > 9 { - emitter.best_indent = 2 - } - if emitter.best_width >= 0 && emitter.best_width <= emitter.best_indent*2 { - emitter.best_width = 80 - } - if emitter.best_width < 0 { - emitter.best_width = 1<<31 - 1 - } - if emitter.line_break == yaml_ANY_BREAK { - emitter.line_break = yaml_LN_BREAK - } - - emitter.indent = -1 - emitter.line = 0 - emitter.column = 0 - emitter.whitespace = true - emitter.indention = true - - if emitter.encoding != yaml_UTF8_ENCODING { - if !yaml_emitter_write_bom(emitter) { - return false - } - } - emitter.state = yaml_EMIT_FIRST_DOCUMENT_START_STATE - return true -} - -// Expect DOCUMENT-START or STREAM-END. -func yaml_emitter_emit_document_start(emitter *yaml_emitter_t, event *yaml_event_t, first bool) bool { - - if event.typ == yaml_DOCUMENT_START_EVENT { - - if event.version_directive != nil { - if !yaml_emitter_analyze_version_directive(emitter, event.version_directive) { - return false - } - } - - for i := 0; i < len(event.tag_directives); i++ { - tag_directive := &event.tag_directives[i] - if !yaml_emitter_analyze_tag_directive(emitter, tag_directive) { - return false - } - if !yaml_emitter_append_tag_directive(emitter, tag_directive, false) { - return false - } - } - - for i := 0; i < len(default_tag_directives); i++ { - tag_directive := &default_tag_directives[i] - if !yaml_emitter_append_tag_directive(emitter, tag_directive, true) { - return false - } - } - - implicit := event.implicit - if !first || emitter.canonical { - implicit = false - } - - if emitter.open_ended && (event.version_directive != nil || len(event.tag_directives) > 0) { - if !yaml_emitter_write_indicator(emitter, []byte("..."), true, false, false) { - return false - } - if !yaml_emitter_write_indent(emitter) { - return false - } - } - - if event.version_directive != nil { - implicit = false - if !yaml_emitter_write_indicator(emitter, []byte("%YAML"), true, false, false) { - return false - } - if !yaml_emitter_write_indicator(emitter, []byte("1.1"), true, false, false) { - return false - } - if !yaml_emitter_write_indent(emitter) { - return false - } - } - - if len(event.tag_directives) > 0 { - implicit = false - for i := 0; i < len(event.tag_directives); i++ { - tag_directive := &event.tag_directives[i] - if !yaml_emitter_write_indicator(emitter, []byte("%TAG"), true, false, false) { - return false - } - if !yaml_emitter_write_tag_handle(emitter, tag_directive.handle) { - return false - } - if !yaml_emitter_write_tag_content(emitter, tag_directive.prefix, true) { - return false - } - if !yaml_emitter_write_indent(emitter) { - return false - } - } - } - - if yaml_emitter_check_empty_document(emitter) { - implicit = false - } - if !implicit { - if !yaml_emitter_write_indent(emitter) { - return false - } - if !yaml_emitter_write_indicator(emitter, []byte("---"), true, false, false) { - return false - } - if emitter.canonical { - if !yaml_emitter_write_indent(emitter) { - return false - } - } - } - - emitter.state = yaml_EMIT_DOCUMENT_CONTENT_STATE - return true - } - - if event.typ == yaml_STREAM_END_EVENT { - if emitter.open_ended { - if !yaml_emitter_write_indicator(emitter, []byte("..."), true, false, false) { - return false - } - if !yaml_emitter_write_indent(emitter) { - return false - } - } - if !yaml_emitter_flush(emitter) { - return false - } - emitter.state = yaml_EMIT_END_STATE - return true - } - - return yaml_emitter_set_emitter_error(emitter, "expected DOCUMENT-START or STREAM-END") -} - -// Expect the root node. -func yaml_emitter_emit_document_content(emitter *yaml_emitter_t, event *yaml_event_t) bool { - emitter.states = append(emitter.states, yaml_EMIT_DOCUMENT_END_STATE) - return yaml_emitter_emit_node(emitter, event, true, false, false, false) -} - -// Expect DOCUMENT-END. -func yaml_emitter_emit_document_end(emitter *yaml_emitter_t, event *yaml_event_t) bool { - if event.typ != yaml_DOCUMENT_END_EVENT { - return yaml_emitter_set_emitter_error(emitter, "expected DOCUMENT-END") - } - if !yaml_emitter_write_indent(emitter) { - return false - } - if !event.implicit { - // [Go] Allocate the slice elsewhere. - if !yaml_emitter_write_indicator(emitter, []byte("..."), true, false, false) { - return false - } - if !yaml_emitter_write_indent(emitter) { - return false - } - } - if !yaml_emitter_flush(emitter) { - return false - } - emitter.state = yaml_EMIT_DOCUMENT_START_STATE - emitter.tag_directives = emitter.tag_directives[:0] - return true -} - -// Expect a flow item node. -func yaml_emitter_emit_flow_sequence_item(emitter *yaml_emitter_t, event *yaml_event_t, first bool) bool { - if first { - if !yaml_emitter_write_indicator(emitter, []byte{'['}, true, true, false) { - return false - } - if !yaml_emitter_increase_indent(emitter, true, false) { - return false - } - emitter.flow_level++ - } - - if event.typ == yaml_SEQUENCE_END_EVENT { - emitter.flow_level-- - emitter.indent = emitter.indents[len(emitter.indents)-1] - emitter.indents = emitter.indents[:len(emitter.indents)-1] - if emitter.canonical && !first { - if !yaml_emitter_write_indicator(emitter, []byte{','}, false, false, false) { - return false - } - if !yaml_emitter_write_indent(emitter) { - return false - } - } - if !yaml_emitter_write_indicator(emitter, []byte{']'}, false, false, false) { - return false - } - emitter.state = emitter.states[len(emitter.states)-1] - emitter.states = emitter.states[:len(emitter.states)-1] - - return true - } - - if !first { - if !yaml_emitter_write_indicator(emitter, []byte{','}, false, false, false) { - return false - } - } - - if emitter.canonical || emitter.column > emitter.best_width { - if !yaml_emitter_write_indent(emitter) { - return false - } - } - emitter.states = append(emitter.states, yaml_EMIT_FLOW_SEQUENCE_ITEM_STATE) - return yaml_emitter_emit_node(emitter, event, false, true, false, false) -} - -// Expect a flow key node. -func yaml_emitter_emit_flow_mapping_key(emitter *yaml_emitter_t, event *yaml_event_t, first bool) bool { - if first { - if !yaml_emitter_write_indicator(emitter, []byte{'{'}, true, true, false) { - return false - } - if !yaml_emitter_increase_indent(emitter, true, false) { - return false - } - emitter.flow_level++ - } - - if event.typ == yaml_MAPPING_END_EVENT { - emitter.flow_level-- - emitter.indent = emitter.indents[len(emitter.indents)-1] - emitter.indents = emitter.indents[:len(emitter.indents)-1] - if emitter.canonical && !first { - if !yaml_emitter_write_indicator(emitter, []byte{','}, false, false, false) { - return false - } - if !yaml_emitter_write_indent(emitter) { - return false - } - } - if !yaml_emitter_write_indicator(emitter, []byte{'}'}, false, false, false) { - return false - } - emitter.state = emitter.states[len(emitter.states)-1] - emitter.states = emitter.states[:len(emitter.states)-1] - return true - } - - if !first { - if !yaml_emitter_write_indicator(emitter, []byte{','}, false, false, false) { - return false - } - } - if emitter.canonical || emitter.column > emitter.best_width { - if !yaml_emitter_write_indent(emitter) { - return false - } - } - - if !emitter.canonical && yaml_emitter_check_simple_key(emitter) { - emitter.states = append(emitter.states, yaml_EMIT_FLOW_MAPPING_SIMPLE_VALUE_STATE) - return yaml_emitter_emit_node(emitter, event, false, false, true, true) - } - if !yaml_emitter_write_indicator(emitter, []byte{'?'}, true, false, false) { - return false - } - emitter.states = append(emitter.states, yaml_EMIT_FLOW_MAPPING_VALUE_STATE) - return yaml_emitter_emit_node(emitter, event, false, false, true, false) -} - -// Expect a flow value node. -func yaml_emitter_emit_flow_mapping_value(emitter *yaml_emitter_t, event *yaml_event_t, simple bool) bool { - if simple { - if !yaml_emitter_write_indicator(emitter, []byte{':'}, false, false, false) { - return false - } - } else { - if emitter.canonical || emitter.column > emitter.best_width { - if !yaml_emitter_write_indent(emitter) { - return false - } - } - if !yaml_emitter_write_indicator(emitter, []byte{':'}, true, false, false) { - return false - } - } - emitter.states = append(emitter.states, yaml_EMIT_FLOW_MAPPING_KEY_STATE) - return yaml_emitter_emit_node(emitter, event, false, false, true, false) -} - -// Expect a block item node. -func yaml_emitter_emit_block_sequence_item(emitter *yaml_emitter_t, event *yaml_event_t, first bool) bool { - if first { - if !yaml_emitter_increase_indent(emitter, false, emitter.mapping_context && !emitter.indention) { - return false - } - } - if event.typ == yaml_SEQUENCE_END_EVENT { - emitter.indent = emitter.indents[len(emitter.indents)-1] - emitter.indents = emitter.indents[:len(emitter.indents)-1] - emitter.state = emitter.states[len(emitter.states)-1] - emitter.states = emitter.states[:len(emitter.states)-1] - return true - } - if !yaml_emitter_write_indent(emitter) { - return false - } - if !yaml_emitter_write_indicator(emitter, []byte{'-'}, true, false, true) { - return false - } - emitter.states = append(emitter.states, yaml_EMIT_BLOCK_SEQUENCE_ITEM_STATE) - return yaml_emitter_emit_node(emitter, event, false, true, false, false) -} - -// Expect a block key node. -func yaml_emitter_emit_block_mapping_key(emitter *yaml_emitter_t, event *yaml_event_t, first bool) bool { - if first { - if !yaml_emitter_increase_indent(emitter, false, false) { - return false - } - } - if event.typ == yaml_MAPPING_END_EVENT { - emitter.indent = emitter.indents[len(emitter.indents)-1] - emitter.indents = emitter.indents[:len(emitter.indents)-1] - emitter.state = emitter.states[len(emitter.states)-1] - emitter.states = emitter.states[:len(emitter.states)-1] - return true - } - if !yaml_emitter_write_indent(emitter) { - return false - } - if yaml_emitter_check_simple_key(emitter) { - emitter.states = append(emitter.states, yaml_EMIT_BLOCK_MAPPING_SIMPLE_VALUE_STATE) - return yaml_emitter_emit_node(emitter, event, false, false, true, true) - } - if !yaml_emitter_write_indicator(emitter, []byte{'?'}, true, false, true) { - return false - } - emitter.states = append(emitter.states, yaml_EMIT_BLOCK_MAPPING_VALUE_STATE) - return yaml_emitter_emit_node(emitter, event, false, false, true, false) -} - -// Expect a block value node. -func yaml_emitter_emit_block_mapping_value(emitter *yaml_emitter_t, event *yaml_event_t, simple bool) bool { - if simple { - if !yaml_emitter_write_indicator(emitter, []byte{':'}, false, false, false) { - return false - } - } else { - if !yaml_emitter_write_indent(emitter) { - return false - } - if !yaml_emitter_write_indicator(emitter, []byte{':'}, true, false, true) { - return false - } - } - emitter.states = append(emitter.states, yaml_EMIT_BLOCK_MAPPING_KEY_STATE) - return yaml_emitter_emit_node(emitter, event, false, false, true, false) -} - -// Expect a node. -func yaml_emitter_emit_node(emitter *yaml_emitter_t, event *yaml_event_t, - root bool, sequence bool, mapping bool, simple_key bool) bool { - - emitter.root_context = root - emitter.sequence_context = sequence - emitter.mapping_context = mapping - emitter.simple_key_context = simple_key - - switch event.typ { - case yaml_ALIAS_EVENT: - return yaml_emitter_emit_alias(emitter, event) - case yaml_SCALAR_EVENT: - return yaml_emitter_emit_scalar(emitter, event) - case yaml_SEQUENCE_START_EVENT: - return yaml_emitter_emit_sequence_start(emitter, event) - case yaml_MAPPING_START_EVENT: - return yaml_emitter_emit_mapping_start(emitter, event) - default: - return yaml_emitter_set_emitter_error(emitter, - "expected SCALAR, SEQUENCE-START, MAPPING-START, or ALIAS") - } -} - -// Expect ALIAS. -func yaml_emitter_emit_alias(emitter *yaml_emitter_t, event *yaml_event_t) bool { - if !yaml_emitter_process_anchor(emitter) { - return false - } - emitter.state = emitter.states[len(emitter.states)-1] - emitter.states = emitter.states[:len(emitter.states)-1] - return true -} - -// Expect SCALAR. -func yaml_emitter_emit_scalar(emitter *yaml_emitter_t, event *yaml_event_t) bool { - if !yaml_emitter_select_scalar_style(emitter, event) { - return false - } - if !yaml_emitter_process_anchor(emitter) { - return false - } - if !yaml_emitter_process_tag(emitter) { - return false - } - if !yaml_emitter_increase_indent(emitter, true, false) { - return false - } - if !yaml_emitter_process_scalar(emitter) { - return false - } - emitter.indent = emitter.indents[len(emitter.indents)-1] - emitter.indents = emitter.indents[:len(emitter.indents)-1] - emitter.state = emitter.states[len(emitter.states)-1] - emitter.states = emitter.states[:len(emitter.states)-1] - return true -} - -// Expect SEQUENCE-START. -func yaml_emitter_emit_sequence_start(emitter *yaml_emitter_t, event *yaml_event_t) bool { - if !yaml_emitter_process_anchor(emitter) { - return false - } - if !yaml_emitter_process_tag(emitter) { - return false - } - if emitter.flow_level > 0 || emitter.canonical || event.sequence_style() == yaml_FLOW_SEQUENCE_STYLE || - yaml_emitter_check_empty_sequence(emitter) { - emitter.state = yaml_EMIT_FLOW_SEQUENCE_FIRST_ITEM_STATE - } else { - emitter.state = yaml_EMIT_BLOCK_SEQUENCE_FIRST_ITEM_STATE - } - return true -} - -// Expect MAPPING-START. -func yaml_emitter_emit_mapping_start(emitter *yaml_emitter_t, event *yaml_event_t) bool { - if !yaml_emitter_process_anchor(emitter) { - return false - } - if !yaml_emitter_process_tag(emitter) { - return false - } - if emitter.flow_level > 0 || emitter.canonical || event.mapping_style() == yaml_FLOW_MAPPING_STYLE || - yaml_emitter_check_empty_mapping(emitter) { - emitter.state = yaml_EMIT_FLOW_MAPPING_FIRST_KEY_STATE - } else { - emitter.state = yaml_EMIT_BLOCK_MAPPING_FIRST_KEY_STATE - } - return true -} - -// Check if the document content is an empty scalar. -func yaml_emitter_check_empty_document(emitter *yaml_emitter_t) bool { - return false // [Go] Huh? -} - -// Check if the next events represent an empty sequence. -func yaml_emitter_check_empty_sequence(emitter *yaml_emitter_t) bool { - if len(emitter.events)-emitter.events_head < 2 { - return false - } - return emitter.events[emitter.events_head].typ == yaml_SEQUENCE_START_EVENT && - emitter.events[emitter.events_head+1].typ == yaml_SEQUENCE_END_EVENT -} - -// Check if the next events represent an empty mapping. -func yaml_emitter_check_empty_mapping(emitter *yaml_emitter_t) bool { - if len(emitter.events)-emitter.events_head < 2 { - return false - } - return emitter.events[emitter.events_head].typ == yaml_MAPPING_START_EVENT && - emitter.events[emitter.events_head+1].typ == yaml_MAPPING_END_EVENT -} - -// Check if the next node can be expressed as a simple key. -func yaml_emitter_check_simple_key(emitter *yaml_emitter_t) bool { - length := 0 - switch emitter.events[emitter.events_head].typ { - case yaml_ALIAS_EVENT: - length += len(emitter.anchor_data.anchor) - case yaml_SCALAR_EVENT: - if emitter.scalar_data.multiline { - return false - } - length += len(emitter.anchor_data.anchor) + - len(emitter.tag_data.handle) + - len(emitter.tag_data.suffix) + - len(emitter.scalar_data.value) - case yaml_SEQUENCE_START_EVENT: - if !yaml_emitter_check_empty_sequence(emitter) { - return false - } - length += len(emitter.anchor_data.anchor) + - len(emitter.tag_data.handle) + - len(emitter.tag_data.suffix) - case yaml_MAPPING_START_EVENT: - if !yaml_emitter_check_empty_mapping(emitter) { - return false - } - length += len(emitter.anchor_data.anchor) + - len(emitter.tag_data.handle) + - len(emitter.tag_data.suffix) - default: - return false - } - return length <= 128 -} - -// Determine an acceptable scalar style. -func yaml_emitter_select_scalar_style(emitter *yaml_emitter_t, event *yaml_event_t) bool { - - no_tag := len(emitter.tag_data.handle) == 0 && len(emitter.tag_data.suffix) == 0 - if no_tag && !event.implicit && !event.quoted_implicit { - return yaml_emitter_set_emitter_error(emitter, "neither tag nor implicit flags are specified") - } - - style := event.scalar_style() - if style == yaml_ANY_SCALAR_STYLE { - style = yaml_PLAIN_SCALAR_STYLE - } - if emitter.canonical { - style = yaml_DOUBLE_QUOTED_SCALAR_STYLE - } - if emitter.simple_key_context && emitter.scalar_data.multiline { - style = yaml_DOUBLE_QUOTED_SCALAR_STYLE - } - - if style == yaml_PLAIN_SCALAR_STYLE { - if emitter.flow_level > 0 && !emitter.scalar_data.flow_plain_allowed || - emitter.flow_level == 0 && !emitter.scalar_data.block_plain_allowed { - style = yaml_SINGLE_QUOTED_SCALAR_STYLE - } - if len(emitter.scalar_data.value) == 0 && (emitter.flow_level > 0 || emitter.simple_key_context) { - style = yaml_SINGLE_QUOTED_SCALAR_STYLE - } - if no_tag && !event.implicit { - style = yaml_SINGLE_QUOTED_SCALAR_STYLE - } - } - if style == yaml_SINGLE_QUOTED_SCALAR_STYLE { - if !emitter.scalar_data.single_quoted_allowed { - style = yaml_DOUBLE_QUOTED_SCALAR_STYLE - } - } - if style == yaml_LITERAL_SCALAR_STYLE || style == yaml_FOLDED_SCALAR_STYLE { - if !emitter.scalar_data.block_allowed || emitter.flow_level > 0 || emitter.simple_key_context { - style = yaml_DOUBLE_QUOTED_SCALAR_STYLE - } - } - - if no_tag && !event.quoted_implicit && style != yaml_PLAIN_SCALAR_STYLE { - emitter.tag_data.handle = []byte{'!'} - } - emitter.scalar_data.style = style - return true -} - -// Write an achor. -func yaml_emitter_process_anchor(emitter *yaml_emitter_t) bool { - if emitter.anchor_data.anchor == nil { - return true - } - c := []byte{'&'} - if emitter.anchor_data.alias { - c[0] = '*' - } - if !yaml_emitter_write_indicator(emitter, c, true, false, false) { - return false - } - return yaml_emitter_write_anchor(emitter, emitter.anchor_data.anchor) -} - -// Write a tag. -func yaml_emitter_process_tag(emitter *yaml_emitter_t) bool { - if len(emitter.tag_data.handle) == 0 && len(emitter.tag_data.suffix) == 0 { - return true - } - if len(emitter.tag_data.handle) > 0 { - if !yaml_emitter_write_tag_handle(emitter, emitter.tag_data.handle) { - return false - } - if len(emitter.tag_data.suffix) > 0 { - if !yaml_emitter_write_tag_content(emitter, emitter.tag_data.suffix, false) { - return false - } - } - } else { - // [Go] Allocate these slices elsewhere. - if !yaml_emitter_write_indicator(emitter, []byte("!<"), true, false, false) { - return false - } - if !yaml_emitter_write_tag_content(emitter, emitter.tag_data.suffix, false) { - return false - } - if !yaml_emitter_write_indicator(emitter, []byte{'>'}, false, false, false) { - return false - } - } - return true -} - -// Write a scalar. -func yaml_emitter_process_scalar(emitter *yaml_emitter_t) bool { - switch emitter.scalar_data.style { - case yaml_PLAIN_SCALAR_STYLE: - return yaml_emitter_write_plain_scalar(emitter, emitter.scalar_data.value, !emitter.simple_key_context) - - case yaml_SINGLE_QUOTED_SCALAR_STYLE: - return yaml_emitter_write_single_quoted_scalar(emitter, emitter.scalar_data.value, !emitter.simple_key_context) - - case yaml_DOUBLE_QUOTED_SCALAR_STYLE: - return yaml_emitter_write_double_quoted_scalar(emitter, emitter.scalar_data.value, !emitter.simple_key_context) - - case yaml_LITERAL_SCALAR_STYLE: - return yaml_emitter_write_literal_scalar(emitter, emitter.scalar_data.value) - - case yaml_FOLDED_SCALAR_STYLE: - return yaml_emitter_write_folded_scalar(emitter, emitter.scalar_data.value) - } - panic("unknown scalar style") -} - -// Check if a %YAML directive is valid. -func yaml_emitter_analyze_version_directive(emitter *yaml_emitter_t, version_directive *yaml_version_directive_t) bool { - if version_directive.major != 1 || version_directive.minor != 1 { - return yaml_emitter_set_emitter_error(emitter, "incompatible %YAML directive") - } - return true -} - -// Check if a %TAG directive is valid. -func yaml_emitter_analyze_tag_directive(emitter *yaml_emitter_t, tag_directive *yaml_tag_directive_t) bool { - handle := tag_directive.handle - prefix := tag_directive.prefix - if len(handle) == 0 { - return yaml_emitter_set_emitter_error(emitter, "tag handle must not be empty") - } - if handle[0] != '!' { - return yaml_emitter_set_emitter_error(emitter, "tag handle must start with '!'") - } - if handle[len(handle)-1] != '!' { - return yaml_emitter_set_emitter_error(emitter, "tag handle must end with '!'") - } - for i := 1; i < len(handle)-1; i += width(handle[i]) { - if !is_alpha(handle, i) { - return yaml_emitter_set_emitter_error(emitter, "tag handle must contain alphanumerical characters only") - } - } - if len(prefix) == 0 { - return yaml_emitter_set_emitter_error(emitter, "tag prefix must not be empty") - } - return true -} - -// Check if an anchor is valid. -func yaml_emitter_analyze_anchor(emitter *yaml_emitter_t, anchor []byte, alias bool) bool { - if len(anchor) == 0 { - problem := "anchor value must not be empty" - if alias { - problem = "alias value must not be empty" - } - return yaml_emitter_set_emitter_error(emitter, problem) - } - for i := 0; i < len(anchor); i += width(anchor[i]) { - if !is_alpha(anchor, i) { - problem := "anchor value must contain alphanumerical characters only" - if alias { - problem = "alias value must contain alphanumerical characters only" - } - return yaml_emitter_set_emitter_error(emitter, problem) - } - } - emitter.anchor_data.anchor = anchor - emitter.anchor_data.alias = alias - return true -} - -// Check if a tag is valid. -func yaml_emitter_analyze_tag(emitter *yaml_emitter_t, tag []byte) bool { - if len(tag) == 0 { - return yaml_emitter_set_emitter_error(emitter, "tag value must not be empty") - } - for i := 0; i < len(emitter.tag_directives); i++ { - tag_directive := &emitter.tag_directives[i] - if bytes.HasPrefix(tag, tag_directive.prefix) { - emitter.tag_data.handle = tag_directive.handle - emitter.tag_data.suffix = tag[len(tag_directive.prefix):] - return true - } - } - emitter.tag_data.suffix = tag - return true -} - -// Check if a scalar is valid. -func yaml_emitter_analyze_scalar(emitter *yaml_emitter_t, value []byte) bool { - var ( - block_indicators = false - flow_indicators = false - line_breaks = false - special_characters = false - - leading_space = false - leading_break = false - trailing_space = false - trailing_break = false - break_space = false - space_break = false - - preceded_by_whitespace = false - followed_by_whitespace = false - previous_space = false - previous_break = false - ) - - emitter.scalar_data.value = value - - if len(value) == 0 { - emitter.scalar_data.multiline = false - emitter.scalar_data.flow_plain_allowed = false - emitter.scalar_data.block_plain_allowed = true - emitter.scalar_data.single_quoted_allowed = true - emitter.scalar_data.block_allowed = false - return true - } - - if len(value) >= 3 && ((value[0] == '-' && value[1] == '-' && value[2] == '-') || (value[0] == '.' && value[1] == '.' && value[2] == '.')) { - block_indicators = true - flow_indicators = true - } - - preceded_by_whitespace = true - for i, w := 0, 0; i < len(value); i += w { - w = width(value[i]) - followed_by_whitespace = i+w >= len(value) || is_blank(value, i+w) - - if i == 0 { - switch value[i] { - case '#', ',', '[', ']', '{', '}', '&', '*', '!', '|', '>', '\'', '"', '%', '@', '`': - flow_indicators = true - block_indicators = true - case '?', ':': - flow_indicators = true - if followed_by_whitespace { - block_indicators = true - } - case '-': - if followed_by_whitespace { - flow_indicators = true - block_indicators = true - } - } - } else { - switch value[i] { - case ',', '?', '[', ']', '{', '}': - flow_indicators = true - case ':': - flow_indicators = true - if followed_by_whitespace { - block_indicators = true - } - case '#': - if preceded_by_whitespace { - flow_indicators = true - block_indicators = true - } - } - } - - if !is_printable(value, i) || !is_ascii(value, i) && !emitter.unicode { - special_characters = true - } - if is_space(value, i) { - if i == 0 { - leading_space = true - } - if i+width(value[i]) == len(value) { - trailing_space = true - } - if previous_break { - break_space = true - } - previous_space = true - previous_break = false - } else if is_break(value, i) { - line_breaks = true - if i == 0 { - leading_break = true - } - if i+width(value[i]) == len(value) { - trailing_break = true - } - if previous_space { - space_break = true - } - previous_space = false - previous_break = true - } else { - previous_space = false - previous_break = false - } - - // [Go]: Why 'z'? Couldn't be the end of the string as that's the loop condition. - preceded_by_whitespace = is_blankz(value, i) - } - - emitter.scalar_data.multiline = line_breaks - emitter.scalar_data.flow_plain_allowed = true - emitter.scalar_data.block_plain_allowed = true - emitter.scalar_data.single_quoted_allowed = true - emitter.scalar_data.block_allowed = true - - if leading_space || leading_break || trailing_space || trailing_break { - emitter.scalar_data.flow_plain_allowed = false - emitter.scalar_data.block_plain_allowed = false - } - if trailing_space { - emitter.scalar_data.block_allowed = false - } - if break_space { - emitter.scalar_data.flow_plain_allowed = false - emitter.scalar_data.block_plain_allowed = false - emitter.scalar_data.single_quoted_allowed = false - } - if space_break || special_characters { - emitter.scalar_data.flow_plain_allowed = false - emitter.scalar_data.block_plain_allowed = false - emitter.scalar_data.single_quoted_allowed = false - emitter.scalar_data.block_allowed = false - } - if line_breaks { - emitter.scalar_data.flow_plain_allowed = false - emitter.scalar_data.block_plain_allowed = false - } - if flow_indicators { - emitter.scalar_data.flow_plain_allowed = false - } - if block_indicators { - emitter.scalar_data.block_plain_allowed = false - } - return true -} - -// Check if the event data is valid. -func yaml_emitter_analyze_event(emitter *yaml_emitter_t, event *yaml_event_t) bool { - - emitter.anchor_data.anchor = nil - emitter.tag_data.handle = nil - emitter.tag_data.suffix = nil - emitter.scalar_data.value = nil - - switch event.typ { - case yaml_ALIAS_EVENT: - if !yaml_emitter_analyze_anchor(emitter, event.anchor, true) { - return false - } - - case yaml_SCALAR_EVENT: - if len(event.anchor) > 0 { - if !yaml_emitter_analyze_anchor(emitter, event.anchor, false) { - return false - } - } - if len(event.tag) > 0 && (emitter.canonical || (!event.implicit && !event.quoted_implicit)) { - if !yaml_emitter_analyze_tag(emitter, event.tag) { - return false - } - } - if !yaml_emitter_analyze_scalar(emitter, event.value) { - return false - } - - case yaml_SEQUENCE_START_EVENT: - if len(event.anchor) > 0 { - if !yaml_emitter_analyze_anchor(emitter, event.anchor, false) { - return false - } - } - if len(event.tag) > 0 && (emitter.canonical || !event.implicit) { - if !yaml_emitter_analyze_tag(emitter, event.tag) { - return false - } - } - - case yaml_MAPPING_START_EVENT: - if len(event.anchor) > 0 { - if !yaml_emitter_analyze_anchor(emitter, event.anchor, false) { - return false - } - } - if len(event.tag) > 0 && (emitter.canonical || !event.implicit) { - if !yaml_emitter_analyze_tag(emitter, event.tag) { - return false - } - } - } - return true -} - -// Write the BOM character. -func yaml_emitter_write_bom(emitter *yaml_emitter_t) bool { - if !flush(emitter) { - return false - } - pos := emitter.buffer_pos - emitter.buffer[pos+0] = '\xEF' - emitter.buffer[pos+1] = '\xBB' - emitter.buffer[pos+2] = '\xBF' - emitter.buffer_pos += 3 - return true -} - -func yaml_emitter_write_indent(emitter *yaml_emitter_t) bool { - indent := emitter.indent - if indent < 0 { - indent = 0 - } - if !emitter.indention || emitter.column > indent || (emitter.column == indent && !emitter.whitespace) { - if !put_break(emitter) { - return false - } - } - for emitter.column < indent { - if !put(emitter, ' ') { - return false - } - } - emitter.whitespace = true - emitter.indention = true - return true -} - -func yaml_emitter_write_indicator(emitter *yaml_emitter_t, indicator []byte, need_whitespace, is_whitespace, is_indention bool) bool { - if need_whitespace && !emitter.whitespace { - if !put(emitter, ' ') { - return false - } - } - if !write_all(emitter, indicator) { - return false - } - emitter.whitespace = is_whitespace - emitter.indention = (emitter.indention && is_indention) - emitter.open_ended = false - return true -} - -func yaml_emitter_write_anchor(emitter *yaml_emitter_t, value []byte) bool { - if !write_all(emitter, value) { - return false - } - emitter.whitespace = false - emitter.indention = false - return true -} - -func yaml_emitter_write_tag_handle(emitter *yaml_emitter_t, value []byte) bool { - if !emitter.whitespace { - if !put(emitter, ' ') { - return false - } - } - if !write_all(emitter, value) { - return false - } - emitter.whitespace = false - emitter.indention = false - return true -} - -func yaml_emitter_write_tag_content(emitter *yaml_emitter_t, value []byte, need_whitespace bool) bool { - if need_whitespace && !emitter.whitespace { - if !put(emitter, ' ') { - return false - } - } - for i := 0; i < len(value); { - var must_write bool - switch value[i] { - case ';', '/', '?', ':', '@', '&', '=', '+', '$', ',', '_', '.', '~', '*', '\'', '(', ')', '[', ']': - must_write = true - default: - must_write = is_alpha(value, i) - } - if must_write { - if !write(emitter, value, &i) { - return false - } - } else { - w := width(value[i]) - for k := 0; k < w; k++ { - octet := value[i] - i++ - if !put(emitter, '%') { - return false - } - - c := octet >> 4 - if c < 10 { - c += '0' - } else { - c += 'A' - 10 - } - if !put(emitter, c) { - return false - } - - c = octet & 0x0f - if c < 10 { - c += '0' - } else { - c += 'A' - 10 - } - if !put(emitter, c) { - return false - } - } - } - } - emitter.whitespace = false - emitter.indention = false - return true -} - -func yaml_emitter_write_plain_scalar(emitter *yaml_emitter_t, value []byte, allow_breaks bool) bool { - if !emitter.whitespace { - if !put(emitter, ' ') { - return false - } - } - - spaces := false - breaks := false - for i := 0; i < len(value); { - if is_space(value, i) { - if allow_breaks && !spaces && emitter.column > emitter.best_width && !is_space(value, i+1) { - if !yaml_emitter_write_indent(emitter) { - return false - } - i += width(value[i]) - } else { - if !write(emitter, value, &i) { - return false - } - } - spaces = true - } else if is_break(value, i) { - if !breaks && value[i] == '\n' { - if !put_break(emitter) { - return false - } - } - if !write_break(emitter, value, &i) { - return false - } - emitter.indention = true - breaks = true - } else { - if breaks { - if !yaml_emitter_write_indent(emitter) { - return false - } - } - if !write(emitter, value, &i) { - return false - } - emitter.indention = false - spaces = false - breaks = false - } - } - - emitter.whitespace = false - emitter.indention = false - if emitter.root_context { - emitter.open_ended = true - } - - return true -} - -func yaml_emitter_write_single_quoted_scalar(emitter *yaml_emitter_t, value []byte, allow_breaks bool) bool { - - if !yaml_emitter_write_indicator(emitter, []byte{'\''}, true, false, false) { - return false - } - - spaces := false - breaks := false - for i := 0; i < len(value); { - if is_space(value, i) { - if allow_breaks && !spaces && emitter.column > emitter.best_width && i > 0 && i < len(value)-1 && !is_space(value, i+1) { - if !yaml_emitter_write_indent(emitter) { - return false - } - i += width(value[i]) - } else { - if !write(emitter, value, &i) { - return false - } - } - spaces = true - } else if is_break(value, i) { - if !breaks && value[i] == '\n' { - if !put_break(emitter) { - return false - } - } - if !write_break(emitter, value, &i) { - return false - } - emitter.indention = true - breaks = true - } else { - if breaks { - if !yaml_emitter_write_indent(emitter) { - return false - } - } - if value[i] == '\'' { - if !put(emitter, '\'') { - return false - } - } - if !write(emitter, value, &i) { - return false - } - emitter.indention = false - spaces = false - breaks = false - } - } - if !yaml_emitter_write_indicator(emitter, []byte{'\''}, false, false, false) { - return false - } - emitter.whitespace = false - emitter.indention = false - return true -} - -func yaml_emitter_write_double_quoted_scalar(emitter *yaml_emitter_t, value []byte, allow_breaks bool) bool { - spaces := false - if !yaml_emitter_write_indicator(emitter, []byte{'"'}, true, false, false) { - return false - } - - for i := 0; i < len(value); { - if !is_printable(value, i) || (!emitter.unicode && !is_ascii(value, i)) || - is_bom(value, i) || is_break(value, i) || - value[i] == '"' || value[i] == '\\' { - - octet := value[i] - - var w int - var v rune - switch { - case octet&0x80 == 0x00: - w, v = 1, rune(octet&0x7F) - case octet&0xE0 == 0xC0: - w, v = 2, rune(octet&0x1F) - case octet&0xF0 == 0xE0: - w, v = 3, rune(octet&0x0F) - case octet&0xF8 == 0xF0: - w, v = 4, rune(octet&0x07) - } - for k := 1; k < w; k++ { - octet = value[i+k] - v = (v << 6) + (rune(octet) & 0x3F) - } - i += w - - if !put(emitter, '\\') { - return false - } - - var ok bool - switch v { - case 0x00: - ok = put(emitter, '0') - case 0x07: - ok = put(emitter, 'a') - case 0x08: - ok = put(emitter, 'b') - case 0x09: - ok = put(emitter, 't') - case 0x0A: - ok = put(emitter, 'n') - case 0x0b: - ok = put(emitter, 'v') - case 0x0c: - ok = put(emitter, 'f') - case 0x0d: - ok = put(emitter, 'r') - case 0x1b: - ok = put(emitter, 'e') - case 0x22: - ok = put(emitter, '"') - case 0x5c: - ok = put(emitter, '\\') - case 0x85: - ok = put(emitter, 'N') - case 0xA0: - ok = put(emitter, '_') - case 0x2028: - ok = put(emitter, 'L') - case 0x2029: - ok = put(emitter, 'P') - default: - if v <= 0xFF { - ok = put(emitter, 'x') - w = 2 - } else if v <= 0xFFFF { - ok = put(emitter, 'u') - w = 4 - } else { - ok = put(emitter, 'U') - w = 8 - } - for k := (w - 1) * 4; ok && k >= 0; k -= 4 { - digit := byte((v >> uint(k)) & 0x0F) - if digit < 10 { - ok = put(emitter, digit+'0') - } else { - ok = put(emitter, digit+'A'-10) - } - } - } - if !ok { - return false - } - spaces = false - } else if is_space(value, i) { - if allow_breaks && !spaces && emitter.column > emitter.best_width && i > 0 && i < len(value)-1 { - if !yaml_emitter_write_indent(emitter) { - return false - } - if is_space(value, i+1) { - if !put(emitter, '\\') { - return false - } - } - i += width(value[i]) - } else if !write(emitter, value, &i) { - return false - } - spaces = true - } else { - if !write(emitter, value, &i) { - return false - } - spaces = false - } - } - if !yaml_emitter_write_indicator(emitter, []byte{'"'}, false, false, false) { - return false - } - emitter.whitespace = false - emitter.indention = false - return true -} - -func yaml_emitter_write_block_scalar_hints(emitter *yaml_emitter_t, value []byte) bool { - if is_space(value, 0) || is_break(value, 0) { - indent_hint := []byte{'0' + byte(emitter.best_indent)} - if !yaml_emitter_write_indicator(emitter, indent_hint, false, false, false) { - return false - } - } - - emitter.open_ended = false - - var chomp_hint [1]byte - if len(value) == 0 { - chomp_hint[0] = '-' - } else { - i := len(value) - 1 - for value[i]&0xC0 == 0x80 { - i-- - } - if !is_break(value, i) { - chomp_hint[0] = '-' - } else if i == 0 { - chomp_hint[0] = '+' - emitter.open_ended = true - } else { - i-- - for value[i]&0xC0 == 0x80 { - i-- - } - if is_break(value, i) { - chomp_hint[0] = '+' - emitter.open_ended = true - } - } - } - if chomp_hint[0] != 0 { - if !yaml_emitter_write_indicator(emitter, chomp_hint[:], false, false, false) { - return false - } - } - return true -} - -func yaml_emitter_write_literal_scalar(emitter *yaml_emitter_t, value []byte) bool { - if !yaml_emitter_write_indicator(emitter, []byte{'|'}, true, false, false) { - return false - } - if !yaml_emitter_write_block_scalar_hints(emitter, value) { - return false - } - if !put_break(emitter) { - return false - } - emitter.indention = true - emitter.whitespace = true - breaks := true - for i := 0; i < len(value); { - if is_break(value, i) { - if !write_break(emitter, value, &i) { - return false - } - emitter.indention = true - breaks = true - } else { - if breaks { - if !yaml_emitter_write_indent(emitter) { - return false - } - } - if !write(emitter, value, &i) { - return false - } - emitter.indention = false - breaks = false - } - } - - return true -} - -func yaml_emitter_write_folded_scalar(emitter *yaml_emitter_t, value []byte) bool { - if !yaml_emitter_write_indicator(emitter, []byte{'>'}, true, false, false) { - return false - } - if !yaml_emitter_write_block_scalar_hints(emitter, value) { - return false - } - - if !put_break(emitter) { - return false - } - emitter.indention = true - emitter.whitespace = true - - breaks := true - leading_spaces := true - for i := 0; i < len(value); { - if is_break(value, i) { - if !breaks && !leading_spaces && value[i] == '\n' { - k := 0 - for is_break(value, k) { - k += width(value[k]) - } - if !is_blankz(value, k) { - if !put_break(emitter) { - return false - } - } - } - if !write_break(emitter, value, &i) { - return false - } - emitter.indention = true - breaks = true - } else { - if breaks { - if !yaml_emitter_write_indent(emitter) { - return false - } - leading_spaces = is_blank(value, i) - } - if !breaks && is_space(value, i) && !is_space(value, i+1) && emitter.column > emitter.best_width { - if !yaml_emitter_write_indent(emitter) { - return false - } - i += width(value[i]) - } else { - if !write(emitter, value, &i) { - return false - } - } - emitter.indention = false - breaks = false - } - } - return true -} diff --git a/_beats/dev-tools/vendor/gopkg.in/yaml.v2/encode.go b/_beats/dev-tools/vendor/gopkg.in/yaml.v2/encode.go deleted file mode 100644 index 84f8499551..0000000000 --- a/_beats/dev-tools/vendor/gopkg.in/yaml.v2/encode.go +++ /dev/null @@ -1,306 +0,0 @@ -package yaml - -import ( - "encoding" - "fmt" - "reflect" - "regexp" - "sort" - "strconv" - "strings" - "time" -) - -type encoder struct { - emitter yaml_emitter_t - event yaml_event_t - out []byte - flow bool -} - -func newEncoder() (e *encoder) { - e = &encoder{} - e.must(yaml_emitter_initialize(&e.emitter)) - yaml_emitter_set_output_string(&e.emitter, &e.out) - yaml_emitter_set_unicode(&e.emitter, true) - e.must(yaml_stream_start_event_initialize(&e.event, yaml_UTF8_ENCODING)) - e.emit() - e.must(yaml_document_start_event_initialize(&e.event, nil, nil, true)) - e.emit() - return e -} - -func (e *encoder) finish() { - e.must(yaml_document_end_event_initialize(&e.event, true)) - e.emit() - e.emitter.open_ended = false - e.must(yaml_stream_end_event_initialize(&e.event)) - e.emit() -} - -func (e *encoder) destroy() { - yaml_emitter_delete(&e.emitter) -} - -func (e *encoder) emit() { - // This will internally delete the e.event value. - if !yaml_emitter_emit(&e.emitter, &e.event) && e.event.typ != yaml_DOCUMENT_END_EVENT && e.event.typ != yaml_STREAM_END_EVENT { - e.must(false) - } -} - -func (e *encoder) must(ok bool) { - if !ok { - msg := e.emitter.problem - if msg == "" { - msg = "unknown problem generating YAML content" - } - failf("%s", msg) - } -} - -func (e *encoder) marshal(tag string, in reflect.Value) { - if !in.IsValid() { - e.nilv() - return - } - iface := in.Interface() - if m, ok := iface.(Marshaler); ok { - v, err := m.MarshalYAML() - if err != nil { - fail(err) - } - if v == nil { - e.nilv() - return - } - in = reflect.ValueOf(v) - } else if m, ok := iface.(encoding.TextMarshaler); ok { - text, err := m.MarshalText() - if err != nil { - fail(err) - } - in = reflect.ValueOf(string(text)) - } - switch in.Kind() { - case reflect.Interface: - if in.IsNil() { - e.nilv() - } else { - e.marshal(tag, in.Elem()) - } - case reflect.Map: - e.mapv(tag, in) - case reflect.Ptr: - if in.IsNil() { - e.nilv() - } else { - e.marshal(tag, in.Elem()) - } - case reflect.Struct: - e.structv(tag, in) - case reflect.Slice: - if in.Type().Elem() == mapItemType { - e.itemsv(tag, in) - } else { - e.slicev(tag, in) - } - case reflect.String: - e.stringv(tag, in) - case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: - if in.Type() == durationType { - e.stringv(tag, reflect.ValueOf(iface.(time.Duration).String())) - } else { - e.intv(tag, in) - } - case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr: - e.uintv(tag, in) - case reflect.Float32, reflect.Float64: - e.floatv(tag, in) - case reflect.Bool: - e.boolv(tag, in) - default: - panic("cannot marshal type: " + in.Type().String()) - } -} - -func (e *encoder) mapv(tag string, in reflect.Value) { - e.mappingv(tag, func() { - keys := keyList(in.MapKeys()) - sort.Sort(keys) - for _, k := range keys { - e.marshal("", k) - e.marshal("", in.MapIndex(k)) - } - }) -} - -func (e *encoder) itemsv(tag string, in reflect.Value) { - e.mappingv(tag, func() { - slice := in.Convert(reflect.TypeOf([]MapItem{})).Interface().([]MapItem) - for _, item := range slice { - e.marshal("", reflect.ValueOf(item.Key)) - e.marshal("", reflect.ValueOf(item.Value)) - } - }) -} - -func (e *encoder) structv(tag string, in reflect.Value) { - sinfo, err := getStructInfo(in.Type()) - if err != nil { - panic(err) - } - e.mappingv(tag, func() { - for _, info := range sinfo.FieldsList { - var value reflect.Value - if info.Inline == nil { - value = in.Field(info.Num) - } else { - value = in.FieldByIndex(info.Inline) - } - if info.OmitEmpty && isZero(value) { - continue - } - e.marshal("", reflect.ValueOf(info.Key)) - e.flow = info.Flow - e.marshal("", value) - } - if sinfo.InlineMap >= 0 { - m := in.Field(sinfo.InlineMap) - if m.Len() > 0 { - e.flow = false - keys := keyList(m.MapKeys()) - sort.Sort(keys) - for _, k := range keys { - if _, found := sinfo.FieldsMap[k.String()]; found { - panic(fmt.Sprintf("Can't have key %q in inlined map; conflicts with struct field", k.String())) - } - e.marshal("", k) - e.flow = false - e.marshal("", m.MapIndex(k)) - } - } - } - }) -} - -func (e *encoder) mappingv(tag string, f func()) { - implicit := tag == "" - style := yaml_BLOCK_MAPPING_STYLE - if e.flow { - e.flow = false - style = yaml_FLOW_MAPPING_STYLE - } - e.must(yaml_mapping_start_event_initialize(&e.event, nil, []byte(tag), implicit, style)) - e.emit() - f() - e.must(yaml_mapping_end_event_initialize(&e.event)) - e.emit() -} - -func (e *encoder) slicev(tag string, in reflect.Value) { - implicit := tag == "" - style := yaml_BLOCK_SEQUENCE_STYLE - if e.flow { - e.flow = false - style = yaml_FLOW_SEQUENCE_STYLE - } - e.must(yaml_sequence_start_event_initialize(&e.event, nil, []byte(tag), implicit, style)) - e.emit() - n := in.Len() - for i := 0; i < n; i++ { - e.marshal("", in.Index(i)) - } - e.must(yaml_sequence_end_event_initialize(&e.event)) - e.emit() -} - -// isBase60 returns whether s is in base 60 notation as defined in YAML 1.1. -// -// The base 60 float notation in YAML 1.1 is a terrible idea and is unsupported -// in YAML 1.2 and by this package, but these should be marshalled quoted for -// the time being for compatibility with other parsers. -func isBase60Float(s string) (result bool) { - // Fast path. - if s == "" { - return false - } - c := s[0] - if !(c == '+' || c == '-' || c >= '0' && c <= '9') || strings.IndexByte(s, ':') < 0 { - return false - } - // Do the full match. - return base60float.MatchString(s) -} - -// From http://yaml.org/type/float.html, except the regular expression there -// is bogus. In practice parsers do not enforce the "\.[0-9_]*" suffix. -var base60float = regexp.MustCompile(`^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+(?:\.[0-9_]*)?$`) - -func (e *encoder) stringv(tag string, in reflect.Value) { - var style yaml_scalar_style_t - s := in.String() - rtag, rs := resolve("", s) - if rtag == yaml_BINARY_TAG { - if tag == "" || tag == yaml_STR_TAG { - tag = rtag - s = rs.(string) - } else if tag == yaml_BINARY_TAG { - failf("explicitly tagged !!binary data must be base64-encoded") - } else { - failf("cannot marshal invalid UTF-8 data as %s", shortTag(tag)) - } - } - if tag == "" && (rtag != yaml_STR_TAG || isBase60Float(s)) { - style = yaml_DOUBLE_QUOTED_SCALAR_STYLE - } else if strings.Contains(s, "\n") { - style = yaml_LITERAL_SCALAR_STYLE - } else { - style = yaml_PLAIN_SCALAR_STYLE - } - e.emitScalar(s, "", tag, style) -} - -func (e *encoder) boolv(tag string, in reflect.Value) { - var s string - if in.Bool() { - s = "true" - } else { - s = "false" - } - e.emitScalar(s, "", tag, yaml_PLAIN_SCALAR_STYLE) -} - -func (e *encoder) intv(tag string, in reflect.Value) { - s := strconv.FormatInt(in.Int(), 10) - e.emitScalar(s, "", tag, yaml_PLAIN_SCALAR_STYLE) -} - -func (e *encoder) uintv(tag string, in reflect.Value) { - s := strconv.FormatUint(in.Uint(), 10) - e.emitScalar(s, "", tag, yaml_PLAIN_SCALAR_STYLE) -} - -func (e *encoder) floatv(tag string, in reflect.Value) { - // FIXME: Handle 64 bits here. - s := strconv.FormatFloat(float64(in.Float()), 'g', -1, 32) - switch s { - case "+Inf": - s = ".inf" - case "-Inf": - s = "-.inf" - case "NaN": - s = ".nan" - } - e.emitScalar(s, "", tag, yaml_PLAIN_SCALAR_STYLE) -} - -func (e *encoder) nilv() { - e.emitScalar("null", "", "", yaml_PLAIN_SCALAR_STYLE) -} - -func (e *encoder) emitScalar(value, anchor, tag string, style yaml_scalar_style_t) { - implicit := tag == "" - e.must(yaml_scalar_event_initialize(&e.event, []byte(anchor), []byte(tag), []byte(value), implicit, implicit, style)) - e.emit() -} diff --git a/_beats/dev-tools/vendor/gopkg.in/yaml.v2/parserc.go b/_beats/dev-tools/vendor/gopkg.in/yaml.v2/parserc.go deleted file mode 100644 index 81d05dfe57..0000000000 --- a/_beats/dev-tools/vendor/gopkg.in/yaml.v2/parserc.go +++ /dev/null @@ -1,1095 +0,0 @@ -package yaml - -import ( - "bytes" -) - -// The parser implements the following grammar: -// -// stream ::= STREAM-START implicit_document? explicit_document* STREAM-END -// implicit_document ::= block_node DOCUMENT-END* -// explicit_document ::= DIRECTIVE* DOCUMENT-START block_node? DOCUMENT-END* -// block_node_or_indentless_sequence ::= -// ALIAS -// | properties (block_content | indentless_block_sequence)? -// | block_content -// | indentless_block_sequence -// block_node ::= ALIAS -// | properties block_content? -// | block_content -// flow_node ::= ALIAS -// | properties flow_content? -// | flow_content -// properties ::= TAG ANCHOR? | ANCHOR TAG? -// block_content ::= block_collection | flow_collection | SCALAR -// flow_content ::= flow_collection | SCALAR -// block_collection ::= block_sequence | block_mapping -// flow_collection ::= flow_sequence | flow_mapping -// block_sequence ::= BLOCK-SEQUENCE-START (BLOCK-ENTRY block_node?)* BLOCK-END -// indentless_sequence ::= (BLOCK-ENTRY block_node?)+ -// block_mapping ::= BLOCK-MAPPING_START -// ((KEY block_node_or_indentless_sequence?)? -// (VALUE block_node_or_indentless_sequence?)?)* -// BLOCK-END -// flow_sequence ::= FLOW-SEQUENCE-START -// (flow_sequence_entry FLOW-ENTRY)* -// flow_sequence_entry? -// FLOW-SEQUENCE-END -// flow_sequence_entry ::= flow_node | KEY flow_node? (VALUE flow_node?)? -// flow_mapping ::= FLOW-MAPPING-START -// (flow_mapping_entry FLOW-ENTRY)* -// flow_mapping_entry? -// FLOW-MAPPING-END -// flow_mapping_entry ::= flow_node | KEY flow_node? (VALUE flow_node?)? - -// Peek the next token in the token queue. -func peek_token(parser *yaml_parser_t) *yaml_token_t { - if parser.token_available || yaml_parser_fetch_more_tokens(parser) { - return &parser.tokens[parser.tokens_head] - } - return nil -} - -// Remove the next token from the queue (must be called after peek_token). -func skip_token(parser *yaml_parser_t) { - parser.token_available = false - parser.tokens_parsed++ - parser.stream_end_produced = parser.tokens[parser.tokens_head].typ == yaml_STREAM_END_TOKEN - parser.tokens_head++ -} - -// Get the next event. -func yaml_parser_parse(parser *yaml_parser_t, event *yaml_event_t) bool { - // Erase the event object. - *event = yaml_event_t{} - - // No events after the end of the stream or error. - if parser.stream_end_produced || parser.error != yaml_NO_ERROR || parser.state == yaml_PARSE_END_STATE { - return true - } - - // Generate the next event. - return yaml_parser_state_machine(parser, event) -} - -// Set parser error. -func yaml_parser_set_parser_error(parser *yaml_parser_t, problem string, problem_mark yaml_mark_t) bool { - parser.error = yaml_PARSER_ERROR - parser.problem = problem - parser.problem_mark = problem_mark - return false -} - -func yaml_parser_set_parser_error_context(parser *yaml_parser_t, context string, context_mark yaml_mark_t, problem string, problem_mark yaml_mark_t) bool { - parser.error = yaml_PARSER_ERROR - parser.context = context - parser.context_mark = context_mark - parser.problem = problem - parser.problem_mark = problem_mark - return false -} - -// State dispatcher. -func yaml_parser_state_machine(parser *yaml_parser_t, event *yaml_event_t) bool { - //trace("yaml_parser_state_machine", "state:", parser.state.String()) - - switch parser.state { - case yaml_PARSE_STREAM_START_STATE: - return yaml_parser_parse_stream_start(parser, event) - - case yaml_PARSE_IMPLICIT_DOCUMENT_START_STATE: - return yaml_parser_parse_document_start(parser, event, true) - - case yaml_PARSE_DOCUMENT_START_STATE: - return yaml_parser_parse_document_start(parser, event, false) - - case yaml_PARSE_DOCUMENT_CONTENT_STATE: - return yaml_parser_parse_document_content(parser, event) - - case yaml_PARSE_DOCUMENT_END_STATE: - return yaml_parser_parse_document_end(parser, event) - - case yaml_PARSE_BLOCK_NODE_STATE: - return yaml_parser_parse_node(parser, event, true, false) - - case yaml_PARSE_BLOCK_NODE_OR_INDENTLESS_SEQUENCE_STATE: - return yaml_parser_parse_node(parser, event, true, true) - - case yaml_PARSE_FLOW_NODE_STATE: - return yaml_parser_parse_node(parser, event, false, false) - - case yaml_PARSE_BLOCK_SEQUENCE_FIRST_ENTRY_STATE: - return yaml_parser_parse_block_sequence_entry(parser, event, true) - - case yaml_PARSE_BLOCK_SEQUENCE_ENTRY_STATE: - return yaml_parser_parse_block_sequence_entry(parser, event, false) - - case yaml_PARSE_INDENTLESS_SEQUENCE_ENTRY_STATE: - return yaml_parser_parse_indentless_sequence_entry(parser, event) - - case yaml_PARSE_BLOCK_MAPPING_FIRST_KEY_STATE: - return yaml_parser_parse_block_mapping_key(parser, event, true) - - case yaml_PARSE_BLOCK_MAPPING_KEY_STATE: - return yaml_parser_parse_block_mapping_key(parser, event, false) - - case yaml_PARSE_BLOCK_MAPPING_VALUE_STATE: - return yaml_parser_parse_block_mapping_value(parser, event) - - case yaml_PARSE_FLOW_SEQUENCE_FIRST_ENTRY_STATE: - return yaml_parser_parse_flow_sequence_entry(parser, event, true) - - case yaml_PARSE_FLOW_SEQUENCE_ENTRY_STATE: - return yaml_parser_parse_flow_sequence_entry(parser, event, false) - - case yaml_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_KEY_STATE: - return yaml_parser_parse_flow_sequence_entry_mapping_key(parser, event) - - case yaml_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_VALUE_STATE: - return yaml_parser_parse_flow_sequence_entry_mapping_value(parser, event) - - case yaml_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_END_STATE: - return yaml_parser_parse_flow_sequence_entry_mapping_end(parser, event) - - case yaml_PARSE_FLOW_MAPPING_FIRST_KEY_STATE: - return yaml_parser_parse_flow_mapping_key(parser, event, true) - - case yaml_PARSE_FLOW_MAPPING_KEY_STATE: - return yaml_parser_parse_flow_mapping_key(parser, event, false) - - case yaml_PARSE_FLOW_MAPPING_VALUE_STATE: - return yaml_parser_parse_flow_mapping_value(parser, event, false) - - case yaml_PARSE_FLOW_MAPPING_EMPTY_VALUE_STATE: - return yaml_parser_parse_flow_mapping_value(parser, event, true) - - default: - panic("invalid parser state") - } -} - -// Parse the production: -// stream ::= STREAM-START implicit_document? explicit_document* STREAM-END -// ************ -func yaml_parser_parse_stream_start(parser *yaml_parser_t, event *yaml_event_t) bool { - token := peek_token(parser) - if token == nil { - return false - } - if token.typ != yaml_STREAM_START_TOKEN { - return yaml_parser_set_parser_error(parser, "did not find expected ", token.start_mark) - } - parser.state = yaml_PARSE_IMPLICIT_DOCUMENT_START_STATE - *event = yaml_event_t{ - typ: yaml_STREAM_START_EVENT, - start_mark: token.start_mark, - end_mark: token.end_mark, - encoding: token.encoding, - } - skip_token(parser) - return true -} - -// Parse the productions: -// implicit_document ::= block_node DOCUMENT-END* -// * -// explicit_document ::= DIRECTIVE* DOCUMENT-START block_node? DOCUMENT-END* -// ************************* -func yaml_parser_parse_document_start(parser *yaml_parser_t, event *yaml_event_t, implicit bool) bool { - - token := peek_token(parser) - if token == nil { - return false - } - - // Parse extra document end indicators. - if !implicit { - for token.typ == yaml_DOCUMENT_END_TOKEN { - skip_token(parser) - token = peek_token(parser) - if token == nil { - return false - } - } - } - - if implicit && token.typ != yaml_VERSION_DIRECTIVE_TOKEN && - token.typ != yaml_TAG_DIRECTIVE_TOKEN && - token.typ != yaml_DOCUMENT_START_TOKEN && - token.typ != yaml_STREAM_END_TOKEN { - // Parse an implicit document. - if !yaml_parser_process_directives(parser, nil, nil) { - return false - } - parser.states = append(parser.states, yaml_PARSE_DOCUMENT_END_STATE) - parser.state = yaml_PARSE_BLOCK_NODE_STATE - - *event = yaml_event_t{ - typ: yaml_DOCUMENT_START_EVENT, - start_mark: token.start_mark, - end_mark: token.end_mark, - } - - } else if token.typ != yaml_STREAM_END_TOKEN { - // Parse an explicit document. - var version_directive *yaml_version_directive_t - var tag_directives []yaml_tag_directive_t - start_mark := token.start_mark - if !yaml_parser_process_directives(parser, &version_directive, &tag_directives) { - return false - } - token = peek_token(parser) - if token == nil { - return false - } - if token.typ != yaml_DOCUMENT_START_TOKEN { - yaml_parser_set_parser_error(parser, - "did not find expected ", token.start_mark) - return false - } - parser.states = append(parser.states, yaml_PARSE_DOCUMENT_END_STATE) - parser.state = yaml_PARSE_DOCUMENT_CONTENT_STATE - end_mark := token.end_mark - - *event = yaml_event_t{ - typ: yaml_DOCUMENT_START_EVENT, - start_mark: start_mark, - end_mark: end_mark, - version_directive: version_directive, - tag_directives: tag_directives, - implicit: false, - } - skip_token(parser) - - } else { - // Parse the stream end. - parser.state = yaml_PARSE_END_STATE - *event = yaml_event_t{ - typ: yaml_STREAM_END_EVENT, - start_mark: token.start_mark, - end_mark: token.end_mark, - } - skip_token(parser) - } - - return true -} - -// Parse the productions: -// explicit_document ::= DIRECTIVE* DOCUMENT-START block_node? DOCUMENT-END* -// *********** -// -func yaml_parser_parse_document_content(parser *yaml_parser_t, event *yaml_event_t) bool { - token := peek_token(parser) - if token == nil { - return false - } - if token.typ == yaml_VERSION_DIRECTIVE_TOKEN || - token.typ == yaml_TAG_DIRECTIVE_TOKEN || - token.typ == yaml_DOCUMENT_START_TOKEN || - token.typ == yaml_DOCUMENT_END_TOKEN || - token.typ == yaml_STREAM_END_TOKEN { - parser.state = parser.states[len(parser.states)-1] - parser.states = parser.states[:len(parser.states)-1] - return yaml_parser_process_empty_scalar(parser, event, - token.start_mark) - } - return yaml_parser_parse_node(parser, event, true, false) -} - -// Parse the productions: -// implicit_document ::= block_node DOCUMENT-END* -// ************* -// explicit_document ::= DIRECTIVE* DOCUMENT-START block_node? DOCUMENT-END* -// -func yaml_parser_parse_document_end(parser *yaml_parser_t, event *yaml_event_t) bool { - token := peek_token(parser) - if token == nil { - return false - } - - start_mark := token.start_mark - end_mark := token.start_mark - - implicit := true - if token.typ == yaml_DOCUMENT_END_TOKEN { - end_mark = token.end_mark - skip_token(parser) - implicit = false - } - - parser.tag_directives = parser.tag_directives[:0] - - parser.state = yaml_PARSE_DOCUMENT_START_STATE - *event = yaml_event_t{ - typ: yaml_DOCUMENT_END_EVENT, - start_mark: start_mark, - end_mark: end_mark, - implicit: implicit, - } - return true -} - -// Parse the productions: -// block_node_or_indentless_sequence ::= -// ALIAS -// ***** -// | properties (block_content | indentless_block_sequence)? -// ********** * -// | block_content | indentless_block_sequence -// * -// block_node ::= ALIAS -// ***** -// | properties block_content? -// ********** * -// | block_content -// * -// flow_node ::= ALIAS -// ***** -// | properties flow_content? -// ********** * -// | flow_content -// * -// properties ::= TAG ANCHOR? | ANCHOR TAG? -// ************************* -// block_content ::= block_collection | flow_collection | SCALAR -// ****** -// flow_content ::= flow_collection | SCALAR -// ****** -func yaml_parser_parse_node(parser *yaml_parser_t, event *yaml_event_t, block, indentless_sequence bool) bool { - //defer trace("yaml_parser_parse_node", "block:", block, "indentless_sequence:", indentless_sequence)() - - token := peek_token(parser) - if token == nil { - return false - } - - if token.typ == yaml_ALIAS_TOKEN { - parser.state = parser.states[len(parser.states)-1] - parser.states = parser.states[:len(parser.states)-1] - *event = yaml_event_t{ - typ: yaml_ALIAS_EVENT, - start_mark: token.start_mark, - end_mark: token.end_mark, - anchor: token.value, - } - skip_token(parser) - return true - } - - start_mark := token.start_mark - end_mark := token.start_mark - - var tag_token bool - var tag_handle, tag_suffix, anchor []byte - var tag_mark yaml_mark_t - if token.typ == yaml_ANCHOR_TOKEN { - anchor = token.value - start_mark = token.start_mark - end_mark = token.end_mark - skip_token(parser) - token = peek_token(parser) - if token == nil { - return false - } - if token.typ == yaml_TAG_TOKEN { - tag_token = true - tag_handle = token.value - tag_suffix = token.suffix - tag_mark = token.start_mark - end_mark = token.end_mark - skip_token(parser) - token = peek_token(parser) - if token == nil { - return false - } - } - } else if token.typ == yaml_TAG_TOKEN { - tag_token = true - tag_handle = token.value - tag_suffix = token.suffix - start_mark = token.start_mark - tag_mark = token.start_mark - end_mark = token.end_mark - skip_token(parser) - token = peek_token(parser) - if token == nil { - return false - } - if token.typ == yaml_ANCHOR_TOKEN { - anchor = token.value - end_mark = token.end_mark - skip_token(parser) - token = peek_token(parser) - if token == nil { - return false - } - } - } - - var tag []byte - if tag_token { - if len(tag_handle) == 0 { - tag = tag_suffix - tag_suffix = nil - } else { - for i := range parser.tag_directives { - if bytes.Equal(parser.tag_directives[i].handle, tag_handle) { - tag = append([]byte(nil), parser.tag_directives[i].prefix...) - tag = append(tag, tag_suffix...) - break - } - } - if len(tag) == 0 { - yaml_parser_set_parser_error_context(parser, - "while parsing a node", start_mark, - "found undefined tag handle", tag_mark) - return false - } - } - } - - implicit := len(tag) == 0 - if indentless_sequence && token.typ == yaml_BLOCK_ENTRY_TOKEN { - end_mark = token.end_mark - parser.state = yaml_PARSE_INDENTLESS_SEQUENCE_ENTRY_STATE - *event = yaml_event_t{ - typ: yaml_SEQUENCE_START_EVENT, - start_mark: start_mark, - end_mark: end_mark, - anchor: anchor, - tag: tag, - implicit: implicit, - style: yaml_style_t(yaml_BLOCK_SEQUENCE_STYLE), - } - return true - } - if token.typ == yaml_SCALAR_TOKEN { - var plain_implicit, quoted_implicit bool - end_mark = token.end_mark - if (len(tag) == 0 && token.style == yaml_PLAIN_SCALAR_STYLE) || (len(tag) == 1 && tag[0] == '!') { - plain_implicit = true - } else if len(tag) == 0 { - quoted_implicit = true - } - parser.state = parser.states[len(parser.states)-1] - parser.states = parser.states[:len(parser.states)-1] - - *event = yaml_event_t{ - typ: yaml_SCALAR_EVENT, - start_mark: start_mark, - end_mark: end_mark, - anchor: anchor, - tag: tag, - value: token.value, - implicit: plain_implicit, - quoted_implicit: quoted_implicit, - style: yaml_style_t(token.style), - } - skip_token(parser) - return true - } - if token.typ == yaml_FLOW_SEQUENCE_START_TOKEN { - // [Go] Some of the events below can be merged as they differ only on style. - end_mark = token.end_mark - parser.state = yaml_PARSE_FLOW_SEQUENCE_FIRST_ENTRY_STATE - *event = yaml_event_t{ - typ: yaml_SEQUENCE_START_EVENT, - start_mark: start_mark, - end_mark: end_mark, - anchor: anchor, - tag: tag, - implicit: implicit, - style: yaml_style_t(yaml_FLOW_SEQUENCE_STYLE), - } - return true - } - if token.typ == yaml_FLOW_MAPPING_START_TOKEN { - end_mark = token.end_mark - parser.state = yaml_PARSE_FLOW_MAPPING_FIRST_KEY_STATE - *event = yaml_event_t{ - typ: yaml_MAPPING_START_EVENT, - start_mark: start_mark, - end_mark: end_mark, - anchor: anchor, - tag: tag, - implicit: implicit, - style: yaml_style_t(yaml_FLOW_MAPPING_STYLE), - } - return true - } - if block && token.typ == yaml_BLOCK_SEQUENCE_START_TOKEN { - end_mark = token.end_mark - parser.state = yaml_PARSE_BLOCK_SEQUENCE_FIRST_ENTRY_STATE - *event = yaml_event_t{ - typ: yaml_SEQUENCE_START_EVENT, - start_mark: start_mark, - end_mark: end_mark, - anchor: anchor, - tag: tag, - implicit: implicit, - style: yaml_style_t(yaml_BLOCK_SEQUENCE_STYLE), - } - return true - } - if block && token.typ == yaml_BLOCK_MAPPING_START_TOKEN { - end_mark = token.end_mark - parser.state = yaml_PARSE_BLOCK_MAPPING_FIRST_KEY_STATE - *event = yaml_event_t{ - typ: yaml_MAPPING_START_EVENT, - start_mark: start_mark, - end_mark: end_mark, - anchor: anchor, - tag: tag, - implicit: implicit, - style: yaml_style_t(yaml_BLOCK_MAPPING_STYLE), - } - return true - } - if len(anchor) > 0 || len(tag) > 0 { - parser.state = parser.states[len(parser.states)-1] - parser.states = parser.states[:len(parser.states)-1] - - *event = yaml_event_t{ - typ: yaml_SCALAR_EVENT, - start_mark: start_mark, - end_mark: end_mark, - anchor: anchor, - tag: tag, - implicit: implicit, - quoted_implicit: false, - style: yaml_style_t(yaml_PLAIN_SCALAR_STYLE), - } - return true - } - - context := "while parsing a flow node" - if block { - context = "while parsing a block node" - } - yaml_parser_set_parser_error_context(parser, context, start_mark, - "did not find expected node content", token.start_mark) - return false -} - -// Parse the productions: -// block_sequence ::= BLOCK-SEQUENCE-START (BLOCK-ENTRY block_node?)* BLOCK-END -// ******************** *********** * ********* -// -func yaml_parser_parse_block_sequence_entry(parser *yaml_parser_t, event *yaml_event_t, first bool) bool { - if first { - token := peek_token(parser) - parser.marks = append(parser.marks, token.start_mark) - skip_token(parser) - } - - token := peek_token(parser) - if token == nil { - return false - } - - if token.typ == yaml_BLOCK_ENTRY_TOKEN { - mark := token.end_mark - skip_token(parser) - token = peek_token(parser) - if token == nil { - return false - } - if token.typ != yaml_BLOCK_ENTRY_TOKEN && token.typ != yaml_BLOCK_END_TOKEN { - parser.states = append(parser.states, yaml_PARSE_BLOCK_SEQUENCE_ENTRY_STATE) - return yaml_parser_parse_node(parser, event, true, false) - } else { - parser.state = yaml_PARSE_BLOCK_SEQUENCE_ENTRY_STATE - return yaml_parser_process_empty_scalar(parser, event, mark) - } - } - if token.typ == yaml_BLOCK_END_TOKEN { - parser.state = parser.states[len(parser.states)-1] - parser.states = parser.states[:len(parser.states)-1] - parser.marks = parser.marks[:len(parser.marks)-1] - - *event = yaml_event_t{ - typ: yaml_SEQUENCE_END_EVENT, - start_mark: token.start_mark, - end_mark: token.end_mark, - } - - skip_token(parser) - return true - } - - context_mark := parser.marks[len(parser.marks)-1] - parser.marks = parser.marks[:len(parser.marks)-1] - return yaml_parser_set_parser_error_context(parser, - "while parsing a block collection", context_mark, - "did not find expected '-' indicator", token.start_mark) -} - -// Parse the productions: -// indentless_sequence ::= (BLOCK-ENTRY block_node?)+ -// *********** * -func yaml_parser_parse_indentless_sequence_entry(parser *yaml_parser_t, event *yaml_event_t) bool { - token := peek_token(parser) - if token == nil { - return false - } - - if token.typ == yaml_BLOCK_ENTRY_TOKEN { - mark := token.end_mark - skip_token(parser) - token = peek_token(parser) - if token == nil { - return false - } - if token.typ != yaml_BLOCK_ENTRY_TOKEN && - token.typ != yaml_KEY_TOKEN && - token.typ != yaml_VALUE_TOKEN && - token.typ != yaml_BLOCK_END_TOKEN { - parser.states = append(parser.states, yaml_PARSE_INDENTLESS_SEQUENCE_ENTRY_STATE) - return yaml_parser_parse_node(parser, event, true, false) - } - parser.state = yaml_PARSE_INDENTLESS_SEQUENCE_ENTRY_STATE - return yaml_parser_process_empty_scalar(parser, event, mark) - } - parser.state = parser.states[len(parser.states)-1] - parser.states = parser.states[:len(parser.states)-1] - - *event = yaml_event_t{ - typ: yaml_SEQUENCE_END_EVENT, - start_mark: token.start_mark, - end_mark: token.start_mark, // [Go] Shouldn't this be token.end_mark? - } - return true -} - -// Parse the productions: -// block_mapping ::= BLOCK-MAPPING_START -// ******************* -// ((KEY block_node_or_indentless_sequence?)? -// *** * -// (VALUE block_node_or_indentless_sequence?)?)* -// -// BLOCK-END -// ********* -// -func yaml_parser_parse_block_mapping_key(parser *yaml_parser_t, event *yaml_event_t, first bool) bool { - if first { - token := peek_token(parser) - parser.marks = append(parser.marks, token.start_mark) - skip_token(parser) - } - - token := peek_token(parser) - if token == nil { - return false - } - - if token.typ == yaml_KEY_TOKEN { - mark := token.end_mark - skip_token(parser) - token = peek_token(parser) - if token == nil { - return false - } - if token.typ != yaml_KEY_TOKEN && - token.typ != yaml_VALUE_TOKEN && - token.typ != yaml_BLOCK_END_TOKEN { - parser.states = append(parser.states, yaml_PARSE_BLOCK_MAPPING_VALUE_STATE) - return yaml_parser_parse_node(parser, event, true, true) - } else { - parser.state = yaml_PARSE_BLOCK_MAPPING_VALUE_STATE - return yaml_parser_process_empty_scalar(parser, event, mark) - } - } else if token.typ == yaml_BLOCK_END_TOKEN { - parser.state = parser.states[len(parser.states)-1] - parser.states = parser.states[:len(parser.states)-1] - parser.marks = parser.marks[:len(parser.marks)-1] - *event = yaml_event_t{ - typ: yaml_MAPPING_END_EVENT, - start_mark: token.start_mark, - end_mark: token.end_mark, - } - skip_token(parser) - return true - } - - context_mark := parser.marks[len(parser.marks)-1] - parser.marks = parser.marks[:len(parser.marks)-1] - return yaml_parser_set_parser_error_context(parser, - "while parsing a block mapping", context_mark, - "did not find expected key", token.start_mark) -} - -// Parse the productions: -// block_mapping ::= BLOCK-MAPPING_START -// -// ((KEY block_node_or_indentless_sequence?)? -// -// (VALUE block_node_or_indentless_sequence?)?)* -// ***** * -// BLOCK-END -// -// -func yaml_parser_parse_block_mapping_value(parser *yaml_parser_t, event *yaml_event_t) bool { - token := peek_token(parser) - if token == nil { - return false - } - if token.typ == yaml_VALUE_TOKEN { - mark := token.end_mark - skip_token(parser) - token = peek_token(parser) - if token == nil { - return false - } - if token.typ != yaml_KEY_TOKEN && - token.typ != yaml_VALUE_TOKEN && - token.typ != yaml_BLOCK_END_TOKEN { - parser.states = append(parser.states, yaml_PARSE_BLOCK_MAPPING_KEY_STATE) - return yaml_parser_parse_node(parser, event, true, true) - } - parser.state = yaml_PARSE_BLOCK_MAPPING_KEY_STATE - return yaml_parser_process_empty_scalar(parser, event, mark) - } - parser.state = yaml_PARSE_BLOCK_MAPPING_KEY_STATE - return yaml_parser_process_empty_scalar(parser, event, token.start_mark) -} - -// Parse the productions: -// flow_sequence ::= FLOW-SEQUENCE-START -// ******************* -// (flow_sequence_entry FLOW-ENTRY)* -// * ********** -// flow_sequence_entry? -// * -// FLOW-SEQUENCE-END -// ***************** -// flow_sequence_entry ::= flow_node | KEY flow_node? (VALUE flow_node?)? -// * -// -func yaml_parser_parse_flow_sequence_entry(parser *yaml_parser_t, event *yaml_event_t, first bool) bool { - if first { - token := peek_token(parser) - parser.marks = append(parser.marks, token.start_mark) - skip_token(parser) - } - token := peek_token(parser) - if token == nil { - return false - } - if token.typ != yaml_FLOW_SEQUENCE_END_TOKEN { - if !first { - if token.typ == yaml_FLOW_ENTRY_TOKEN { - skip_token(parser) - token = peek_token(parser) - if token == nil { - return false - } - } else { - context_mark := parser.marks[len(parser.marks)-1] - parser.marks = parser.marks[:len(parser.marks)-1] - return yaml_parser_set_parser_error_context(parser, - "while parsing a flow sequence", context_mark, - "did not find expected ',' or ']'", token.start_mark) - } - } - - if token.typ == yaml_KEY_TOKEN { - parser.state = yaml_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_KEY_STATE - *event = yaml_event_t{ - typ: yaml_MAPPING_START_EVENT, - start_mark: token.start_mark, - end_mark: token.end_mark, - implicit: true, - style: yaml_style_t(yaml_FLOW_MAPPING_STYLE), - } - skip_token(parser) - return true - } else if token.typ != yaml_FLOW_SEQUENCE_END_TOKEN { - parser.states = append(parser.states, yaml_PARSE_FLOW_SEQUENCE_ENTRY_STATE) - return yaml_parser_parse_node(parser, event, false, false) - } - } - - parser.state = parser.states[len(parser.states)-1] - parser.states = parser.states[:len(parser.states)-1] - parser.marks = parser.marks[:len(parser.marks)-1] - - *event = yaml_event_t{ - typ: yaml_SEQUENCE_END_EVENT, - start_mark: token.start_mark, - end_mark: token.end_mark, - } - - skip_token(parser) - return true -} - -// -// Parse the productions: -// flow_sequence_entry ::= flow_node | KEY flow_node? (VALUE flow_node?)? -// *** * -// -func yaml_parser_parse_flow_sequence_entry_mapping_key(parser *yaml_parser_t, event *yaml_event_t) bool { - token := peek_token(parser) - if token == nil { - return false - } - if token.typ != yaml_VALUE_TOKEN && - token.typ != yaml_FLOW_ENTRY_TOKEN && - token.typ != yaml_FLOW_SEQUENCE_END_TOKEN { - parser.states = append(parser.states, yaml_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_VALUE_STATE) - return yaml_parser_parse_node(parser, event, false, false) - } - mark := token.end_mark - skip_token(parser) - parser.state = yaml_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_VALUE_STATE - return yaml_parser_process_empty_scalar(parser, event, mark) -} - -// Parse the productions: -// flow_sequence_entry ::= flow_node | KEY flow_node? (VALUE flow_node?)? -// ***** * -// -func yaml_parser_parse_flow_sequence_entry_mapping_value(parser *yaml_parser_t, event *yaml_event_t) bool { - token := peek_token(parser) - if token == nil { - return false - } - if token.typ == yaml_VALUE_TOKEN { - skip_token(parser) - token := peek_token(parser) - if token == nil { - return false - } - if token.typ != yaml_FLOW_ENTRY_TOKEN && token.typ != yaml_FLOW_SEQUENCE_END_TOKEN { - parser.states = append(parser.states, yaml_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_END_STATE) - return yaml_parser_parse_node(parser, event, false, false) - } - } - parser.state = yaml_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_END_STATE - return yaml_parser_process_empty_scalar(parser, event, token.start_mark) -} - -// Parse the productions: -// flow_sequence_entry ::= flow_node | KEY flow_node? (VALUE flow_node?)? -// * -// -func yaml_parser_parse_flow_sequence_entry_mapping_end(parser *yaml_parser_t, event *yaml_event_t) bool { - token := peek_token(parser) - if token == nil { - return false - } - parser.state = yaml_PARSE_FLOW_SEQUENCE_ENTRY_STATE - *event = yaml_event_t{ - typ: yaml_MAPPING_END_EVENT, - start_mark: token.start_mark, - end_mark: token.start_mark, // [Go] Shouldn't this be end_mark? - } - return true -} - -// Parse the productions: -// flow_mapping ::= FLOW-MAPPING-START -// ****************** -// (flow_mapping_entry FLOW-ENTRY)* -// * ********** -// flow_mapping_entry? -// ****************** -// FLOW-MAPPING-END -// **************** -// flow_mapping_entry ::= flow_node | KEY flow_node? (VALUE flow_node?)? -// * *** * -// -func yaml_parser_parse_flow_mapping_key(parser *yaml_parser_t, event *yaml_event_t, first bool) bool { - if first { - token := peek_token(parser) - parser.marks = append(parser.marks, token.start_mark) - skip_token(parser) - } - - token := peek_token(parser) - if token == nil { - return false - } - - if token.typ != yaml_FLOW_MAPPING_END_TOKEN { - if !first { - if token.typ == yaml_FLOW_ENTRY_TOKEN { - skip_token(parser) - token = peek_token(parser) - if token == nil { - return false - } - } else { - context_mark := parser.marks[len(parser.marks)-1] - parser.marks = parser.marks[:len(parser.marks)-1] - return yaml_parser_set_parser_error_context(parser, - "while parsing a flow mapping", context_mark, - "did not find expected ',' or '}'", token.start_mark) - } - } - - if token.typ == yaml_KEY_TOKEN { - skip_token(parser) - token = peek_token(parser) - if token == nil { - return false - } - if token.typ != yaml_VALUE_TOKEN && - token.typ != yaml_FLOW_ENTRY_TOKEN && - token.typ != yaml_FLOW_MAPPING_END_TOKEN { - parser.states = append(parser.states, yaml_PARSE_FLOW_MAPPING_VALUE_STATE) - return yaml_parser_parse_node(parser, event, false, false) - } else { - parser.state = yaml_PARSE_FLOW_MAPPING_VALUE_STATE - return yaml_parser_process_empty_scalar(parser, event, token.start_mark) - } - } else if token.typ != yaml_FLOW_MAPPING_END_TOKEN { - parser.states = append(parser.states, yaml_PARSE_FLOW_MAPPING_EMPTY_VALUE_STATE) - return yaml_parser_parse_node(parser, event, false, false) - } - } - - parser.state = parser.states[len(parser.states)-1] - parser.states = parser.states[:len(parser.states)-1] - parser.marks = parser.marks[:len(parser.marks)-1] - *event = yaml_event_t{ - typ: yaml_MAPPING_END_EVENT, - start_mark: token.start_mark, - end_mark: token.end_mark, - } - skip_token(parser) - return true -} - -// Parse the productions: -// flow_mapping_entry ::= flow_node | KEY flow_node? (VALUE flow_node?)? -// * ***** * -// -func yaml_parser_parse_flow_mapping_value(parser *yaml_parser_t, event *yaml_event_t, empty bool) bool { - token := peek_token(parser) - if token == nil { - return false - } - if empty { - parser.state = yaml_PARSE_FLOW_MAPPING_KEY_STATE - return yaml_parser_process_empty_scalar(parser, event, token.start_mark) - } - if token.typ == yaml_VALUE_TOKEN { - skip_token(parser) - token = peek_token(parser) - if token == nil { - return false - } - if token.typ != yaml_FLOW_ENTRY_TOKEN && token.typ != yaml_FLOW_MAPPING_END_TOKEN { - parser.states = append(parser.states, yaml_PARSE_FLOW_MAPPING_KEY_STATE) - return yaml_parser_parse_node(parser, event, false, false) - } - } - parser.state = yaml_PARSE_FLOW_MAPPING_KEY_STATE - return yaml_parser_process_empty_scalar(parser, event, token.start_mark) -} - -// Generate an empty scalar event. -func yaml_parser_process_empty_scalar(parser *yaml_parser_t, event *yaml_event_t, mark yaml_mark_t) bool { - *event = yaml_event_t{ - typ: yaml_SCALAR_EVENT, - start_mark: mark, - end_mark: mark, - value: nil, // Empty - implicit: true, - style: yaml_style_t(yaml_PLAIN_SCALAR_STYLE), - } - return true -} - -var default_tag_directives = []yaml_tag_directive_t{ - {[]byte("!"), []byte("!")}, - {[]byte("!!"), []byte("tag:yaml.org,2002:")}, -} - -// Parse directives. -func yaml_parser_process_directives(parser *yaml_parser_t, - version_directive_ref **yaml_version_directive_t, - tag_directives_ref *[]yaml_tag_directive_t) bool { - - var version_directive *yaml_version_directive_t - var tag_directives []yaml_tag_directive_t - - token := peek_token(parser) - if token == nil { - return false - } - - for token.typ == yaml_VERSION_DIRECTIVE_TOKEN || token.typ == yaml_TAG_DIRECTIVE_TOKEN { - if token.typ == yaml_VERSION_DIRECTIVE_TOKEN { - if version_directive != nil { - yaml_parser_set_parser_error(parser, - "found duplicate %YAML directive", token.start_mark) - return false - } - if token.major != 1 || token.minor != 1 { - yaml_parser_set_parser_error(parser, - "found incompatible YAML document", token.start_mark) - return false - } - version_directive = &yaml_version_directive_t{ - major: token.major, - minor: token.minor, - } - } else if token.typ == yaml_TAG_DIRECTIVE_TOKEN { - value := yaml_tag_directive_t{ - handle: token.value, - prefix: token.prefix, - } - if !yaml_parser_append_tag_directive(parser, value, false, token.start_mark) { - return false - } - tag_directives = append(tag_directives, value) - } - - skip_token(parser) - token = peek_token(parser) - if token == nil { - return false - } - } - - for i := range default_tag_directives { - if !yaml_parser_append_tag_directive(parser, default_tag_directives[i], true, token.start_mark) { - return false - } - } - - if version_directive_ref != nil { - *version_directive_ref = version_directive - } - if tag_directives_ref != nil { - *tag_directives_ref = tag_directives - } - return true -} - -// Append a tag directive to the directives stack. -func yaml_parser_append_tag_directive(parser *yaml_parser_t, value yaml_tag_directive_t, allow_duplicates bool, mark yaml_mark_t) bool { - for i := range parser.tag_directives { - if bytes.Equal(value.handle, parser.tag_directives[i].handle) { - if allow_duplicates { - return true - } - return yaml_parser_set_parser_error(parser, "found duplicate %TAG directive", mark) - } - } - - // [Go] I suspect the copy is unnecessary. This was likely done - // because there was no way to track ownership of the data. - value_copy := yaml_tag_directive_t{ - handle: make([]byte, len(value.handle)), - prefix: make([]byte, len(value.prefix)), - } - copy(value_copy.handle, value.handle) - copy(value_copy.prefix, value.prefix) - parser.tag_directives = append(parser.tag_directives, value_copy) - return true -} diff --git a/_beats/dev-tools/vendor/gopkg.in/yaml.v2/readerc.go b/_beats/dev-tools/vendor/gopkg.in/yaml.v2/readerc.go deleted file mode 100644 index f450791717..0000000000 --- a/_beats/dev-tools/vendor/gopkg.in/yaml.v2/readerc.go +++ /dev/null @@ -1,394 +0,0 @@ -package yaml - -import ( - "io" -) - -// Set the reader error and return 0. -func yaml_parser_set_reader_error(parser *yaml_parser_t, problem string, offset int, value int) bool { - parser.error = yaml_READER_ERROR - parser.problem = problem - parser.problem_offset = offset - parser.problem_value = value - return false -} - -// Byte order marks. -const ( - bom_UTF8 = "\xef\xbb\xbf" - bom_UTF16LE = "\xff\xfe" - bom_UTF16BE = "\xfe\xff" -) - -// Determine the input stream encoding by checking the BOM symbol. If no BOM is -// found, the UTF-8 encoding is assumed. Return 1 on success, 0 on failure. -func yaml_parser_determine_encoding(parser *yaml_parser_t) bool { - // Ensure that we had enough bytes in the raw buffer. - for !parser.eof && len(parser.raw_buffer)-parser.raw_buffer_pos < 3 { - if !yaml_parser_update_raw_buffer(parser) { - return false - } - } - - // Determine the encoding. - buf := parser.raw_buffer - pos := parser.raw_buffer_pos - avail := len(buf) - pos - if avail >= 2 && buf[pos] == bom_UTF16LE[0] && buf[pos+1] == bom_UTF16LE[1] { - parser.encoding = yaml_UTF16LE_ENCODING - parser.raw_buffer_pos += 2 - parser.offset += 2 - } else if avail >= 2 && buf[pos] == bom_UTF16BE[0] && buf[pos+1] == bom_UTF16BE[1] { - parser.encoding = yaml_UTF16BE_ENCODING - parser.raw_buffer_pos += 2 - parser.offset += 2 - } else if avail >= 3 && buf[pos] == bom_UTF8[0] && buf[pos+1] == bom_UTF8[1] && buf[pos+2] == bom_UTF8[2] { - parser.encoding = yaml_UTF8_ENCODING - parser.raw_buffer_pos += 3 - parser.offset += 3 - } else { - parser.encoding = yaml_UTF8_ENCODING - } - return true -} - -// Update the raw buffer. -func yaml_parser_update_raw_buffer(parser *yaml_parser_t) bool { - size_read := 0 - - // Return if the raw buffer is full. - if parser.raw_buffer_pos == 0 && len(parser.raw_buffer) == cap(parser.raw_buffer) { - return true - } - - // Return on EOF. - if parser.eof { - return true - } - - // Move the remaining bytes in the raw buffer to the beginning. - if parser.raw_buffer_pos > 0 && parser.raw_buffer_pos < len(parser.raw_buffer) { - copy(parser.raw_buffer, parser.raw_buffer[parser.raw_buffer_pos:]) - } - parser.raw_buffer = parser.raw_buffer[:len(parser.raw_buffer)-parser.raw_buffer_pos] - parser.raw_buffer_pos = 0 - - // Call the read handler to fill the buffer. - size_read, err := parser.read_handler(parser, parser.raw_buffer[len(parser.raw_buffer):cap(parser.raw_buffer)]) - parser.raw_buffer = parser.raw_buffer[:len(parser.raw_buffer)+size_read] - if err == io.EOF { - parser.eof = true - } else if err != nil { - return yaml_parser_set_reader_error(parser, "input error: "+err.Error(), parser.offset, -1) - } - return true -} - -// Ensure that the buffer contains at least `length` characters. -// Return true on success, false on failure. -// -// The length is supposed to be significantly less that the buffer size. -func yaml_parser_update_buffer(parser *yaml_parser_t, length int) bool { - if parser.read_handler == nil { - panic("read handler must be set") - } - - // If the EOF flag is set and the raw buffer is empty, do nothing. - if parser.eof && parser.raw_buffer_pos == len(parser.raw_buffer) { - return true - } - - // Return if the buffer contains enough characters. - if parser.unread >= length { - return true - } - - // Determine the input encoding if it is not known yet. - if parser.encoding == yaml_ANY_ENCODING { - if !yaml_parser_determine_encoding(parser) { - return false - } - } - - // Move the unread characters to the beginning of the buffer. - buffer_len := len(parser.buffer) - if parser.buffer_pos > 0 && parser.buffer_pos < buffer_len { - copy(parser.buffer, parser.buffer[parser.buffer_pos:]) - buffer_len -= parser.buffer_pos - parser.buffer_pos = 0 - } else if parser.buffer_pos == buffer_len { - buffer_len = 0 - parser.buffer_pos = 0 - } - - // Open the whole buffer for writing, and cut it before returning. - parser.buffer = parser.buffer[:cap(parser.buffer)] - - // Fill the buffer until it has enough characters. - first := true - for parser.unread < length { - - // Fill the raw buffer if necessary. - if !first || parser.raw_buffer_pos == len(parser.raw_buffer) { - if !yaml_parser_update_raw_buffer(parser) { - parser.buffer = parser.buffer[:buffer_len] - return false - } - } - first = false - - // Decode the raw buffer. - inner: - for parser.raw_buffer_pos != len(parser.raw_buffer) { - var value rune - var width int - - raw_unread := len(parser.raw_buffer) - parser.raw_buffer_pos - - // Decode the next character. - switch parser.encoding { - case yaml_UTF8_ENCODING: - // Decode a UTF-8 character. Check RFC 3629 - // (http://www.ietf.org/rfc/rfc3629.txt) for more details. - // - // The following table (taken from the RFC) is used for - // decoding. - // - // Char. number range | UTF-8 octet sequence - // (hexadecimal) | (binary) - // --------------------+------------------------------------ - // 0000 0000-0000 007F | 0xxxxxxx - // 0000 0080-0000 07FF | 110xxxxx 10xxxxxx - // 0000 0800-0000 FFFF | 1110xxxx 10xxxxxx 10xxxxxx - // 0001 0000-0010 FFFF | 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx - // - // Additionally, the characters in the range 0xD800-0xDFFF - // are prohibited as they are reserved for use with UTF-16 - // surrogate pairs. - - // Determine the length of the UTF-8 sequence. - octet := parser.raw_buffer[parser.raw_buffer_pos] - switch { - case octet&0x80 == 0x00: - width = 1 - case octet&0xE0 == 0xC0: - width = 2 - case octet&0xF0 == 0xE0: - width = 3 - case octet&0xF8 == 0xF0: - width = 4 - default: - // The leading octet is invalid. - return yaml_parser_set_reader_error(parser, - "invalid leading UTF-8 octet", - parser.offset, int(octet)) - } - - // Check if the raw buffer contains an incomplete character. - if width > raw_unread { - if parser.eof { - return yaml_parser_set_reader_error(parser, - "incomplete UTF-8 octet sequence", - parser.offset, -1) - } - break inner - } - - // Decode the leading octet. - switch { - case octet&0x80 == 0x00: - value = rune(octet & 0x7F) - case octet&0xE0 == 0xC0: - value = rune(octet & 0x1F) - case octet&0xF0 == 0xE0: - value = rune(octet & 0x0F) - case octet&0xF8 == 0xF0: - value = rune(octet & 0x07) - default: - value = 0 - } - - // Check and decode the trailing octets. - for k := 1; k < width; k++ { - octet = parser.raw_buffer[parser.raw_buffer_pos+k] - - // Check if the octet is valid. - if (octet & 0xC0) != 0x80 { - return yaml_parser_set_reader_error(parser, - "invalid trailing UTF-8 octet", - parser.offset+k, int(octet)) - } - - // Decode the octet. - value = (value << 6) + rune(octet&0x3F) - } - - // Check the length of the sequence against the value. - switch { - case width == 1: - case width == 2 && value >= 0x80: - case width == 3 && value >= 0x800: - case width == 4 && value >= 0x10000: - default: - return yaml_parser_set_reader_error(parser, - "invalid length of a UTF-8 sequence", - parser.offset, -1) - } - - // Check the range of the value. - if value >= 0xD800 && value <= 0xDFFF || value > 0x10FFFF { - return yaml_parser_set_reader_error(parser, - "invalid Unicode character", - parser.offset, int(value)) - } - - case yaml_UTF16LE_ENCODING, yaml_UTF16BE_ENCODING: - var low, high int - if parser.encoding == yaml_UTF16LE_ENCODING { - low, high = 0, 1 - } else { - low, high = 1, 0 - } - - // The UTF-16 encoding is not as simple as one might - // naively think. Check RFC 2781 - // (http://www.ietf.org/rfc/rfc2781.txt). - // - // Normally, two subsequent bytes describe a Unicode - // character. However a special technique (called a - // surrogate pair) is used for specifying character - // values larger than 0xFFFF. - // - // A surrogate pair consists of two pseudo-characters: - // high surrogate area (0xD800-0xDBFF) - // low surrogate area (0xDC00-0xDFFF) - // - // The following formulas are used for decoding - // and encoding characters using surrogate pairs: - // - // U = U' + 0x10000 (0x01 00 00 <= U <= 0x10 FF FF) - // U' = yyyyyyyyyyxxxxxxxxxx (0 <= U' <= 0x0F FF FF) - // W1 = 110110yyyyyyyyyy - // W2 = 110111xxxxxxxxxx - // - // where U is the character value, W1 is the high surrogate - // area, W2 is the low surrogate area. - - // Check for incomplete UTF-16 character. - if raw_unread < 2 { - if parser.eof { - return yaml_parser_set_reader_error(parser, - "incomplete UTF-16 character", - parser.offset, -1) - } - break inner - } - - // Get the character. - value = rune(parser.raw_buffer[parser.raw_buffer_pos+low]) + - (rune(parser.raw_buffer[parser.raw_buffer_pos+high]) << 8) - - // Check for unexpected low surrogate area. - if value&0xFC00 == 0xDC00 { - return yaml_parser_set_reader_error(parser, - "unexpected low surrogate area", - parser.offset, int(value)) - } - - // Check for a high surrogate area. - if value&0xFC00 == 0xD800 { - width = 4 - - // Check for incomplete surrogate pair. - if raw_unread < 4 { - if parser.eof { - return yaml_parser_set_reader_error(parser, - "incomplete UTF-16 surrogate pair", - parser.offset, -1) - } - break inner - } - - // Get the next character. - value2 := rune(parser.raw_buffer[parser.raw_buffer_pos+low+2]) + - (rune(parser.raw_buffer[parser.raw_buffer_pos+high+2]) << 8) - - // Check for a low surrogate area. - if value2&0xFC00 != 0xDC00 { - return yaml_parser_set_reader_error(parser, - "expected low surrogate area", - parser.offset+2, int(value2)) - } - - // Generate the value of the surrogate pair. - value = 0x10000 + ((value & 0x3FF) << 10) + (value2 & 0x3FF) - } else { - width = 2 - } - - default: - panic("impossible") - } - - // Check if the character is in the allowed range: - // #x9 | #xA | #xD | [#x20-#x7E] (8 bit) - // | #x85 | [#xA0-#xD7FF] | [#xE000-#xFFFD] (16 bit) - // | [#x10000-#x10FFFF] (32 bit) - switch { - case value == 0x09: - case value == 0x0A: - case value == 0x0D: - case value >= 0x20 && value <= 0x7E: - case value == 0x85: - case value >= 0xA0 && value <= 0xD7FF: - case value >= 0xE000 && value <= 0xFFFD: - case value >= 0x10000 && value <= 0x10FFFF: - default: - return yaml_parser_set_reader_error(parser, - "control characters are not allowed", - parser.offset, int(value)) - } - - // Move the raw pointers. - parser.raw_buffer_pos += width - parser.offset += width - - // Finally put the character into the buffer. - if value <= 0x7F { - // 0000 0000-0000 007F . 0xxxxxxx - parser.buffer[buffer_len+0] = byte(value) - buffer_len += 1 - } else if value <= 0x7FF { - // 0000 0080-0000 07FF . 110xxxxx 10xxxxxx - parser.buffer[buffer_len+0] = byte(0xC0 + (value >> 6)) - parser.buffer[buffer_len+1] = byte(0x80 + (value & 0x3F)) - buffer_len += 2 - } else if value <= 0xFFFF { - // 0000 0800-0000 FFFF . 1110xxxx 10xxxxxx 10xxxxxx - parser.buffer[buffer_len+0] = byte(0xE0 + (value >> 12)) - parser.buffer[buffer_len+1] = byte(0x80 + ((value >> 6) & 0x3F)) - parser.buffer[buffer_len+2] = byte(0x80 + (value & 0x3F)) - buffer_len += 3 - } else { - // 0001 0000-0010 FFFF . 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx - parser.buffer[buffer_len+0] = byte(0xF0 + (value >> 18)) - parser.buffer[buffer_len+1] = byte(0x80 + ((value >> 12) & 0x3F)) - parser.buffer[buffer_len+2] = byte(0x80 + ((value >> 6) & 0x3F)) - parser.buffer[buffer_len+3] = byte(0x80 + (value & 0x3F)) - buffer_len += 4 - } - - parser.unread++ - } - - // On EOF, put NUL into the buffer and return. - if parser.eof { - parser.buffer[buffer_len] = 0 - buffer_len++ - parser.unread++ - break - } - } - parser.buffer = parser.buffer[:buffer_len] - return true -} diff --git a/_beats/dev-tools/vendor/gopkg.in/yaml.v2/resolve.go b/_beats/dev-tools/vendor/gopkg.in/yaml.v2/resolve.go deleted file mode 100644 index 232313cc08..0000000000 --- a/_beats/dev-tools/vendor/gopkg.in/yaml.v2/resolve.go +++ /dev/null @@ -1,208 +0,0 @@ -package yaml - -import ( - "encoding/base64" - "math" - "regexp" - "strconv" - "strings" - "unicode/utf8" -) - -type resolveMapItem struct { - value interface{} - tag string -} - -var resolveTable = make([]byte, 256) -var resolveMap = make(map[string]resolveMapItem) - -func init() { - t := resolveTable - t[int('+')] = 'S' // Sign - t[int('-')] = 'S' - for _, c := range "0123456789" { - t[int(c)] = 'D' // Digit - } - for _, c := range "yYnNtTfFoO~" { - t[int(c)] = 'M' // In map - } - t[int('.')] = '.' // Float (potentially in map) - - var resolveMapList = []struct { - v interface{} - tag string - l []string - }{ - {true, yaml_BOOL_TAG, []string{"y", "Y", "yes", "Yes", "YES"}}, - {true, yaml_BOOL_TAG, []string{"true", "True", "TRUE"}}, - {true, yaml_BOOL_TAG, []string{"on", "On", "ON"}}, - {false, yaml_BOOL_TAG, []string{"n", "N", "no", "No", "NO"}}, - {false, yaml_BOOL_TAG, []string{"false", "False", "FALSE"}}, - {false, yaml_BOOL_TAG, []string{"off", "Off", "OFF"}}, - {nil, yaml_NULL_TAG, []string{"", "~", "null", "Null", "NULL"}}, - {math.NaN(), yaml_FLOAT_TAG, []string{".nan", ".NaN", ".NAN"}}, - {math.Inf(+1), yaml_FLOAT_TAG, []string{".inf", ".Inf", ".INF"}}, - {math.Inf(+1), yaml_FLOAT_TAG, []string{"+.inf", "+.Inf", "+.INF"}}, - {math.Inf(-1), yaml_FLOAT_TAG, []string{"-.inf", "-.Inf", "-.INF"}}, - {"<<", yaml_MERGE_TAG, []string{"<<"}}, - } - - m := resolveMap - for _, item := range resolveMapList { - for _, s := range item.l { - m[s] = resolveMapItem{item.v, item.tag} - } - } -} - -const longTagPrefix = "tag:yaml.org,2002:" - -func shortTag(tag string) string { - // TODO This can easily be made faster and produce less garbage. - if strings.HasPrefix(tag, longTagPrefix) { - return "!!" + tag[len(longTagPrefix):] - } - return tag -} - -func longTag(tag string) string { - if strings.HasPrefix(tag, "!!") { - return longTagPrefix + tag[2:] - } - return tag -} - -func resolvableTag(tag string) bool { - switch tag { - case "", yaml_STR_TAG, yaml_BOOL_TAG, yaml_INT_TAG, yaml_FLOAT_TAG, yaml_NULL_TAG: - return true - } - return false -} - -var yamlStyleFloat = regexp.MustCompile(`^[-+]?[0-9]*\.?[0-9]+([eE][-+][0-9]+)?$`) - -func resolve(tag string, in string) (rtag string, out interface{}) { - if !resolvableTag(tag) { - return tag, in - } - - defer func() { - switch tag { - case "", rtag, yaml_STR_TAG, yaml_BINARY_TAG: - return - } - failf("cannot decode %s `%s` as a %s", shortTag(rtag), in, shortTag(tag)) - }() - - // Any data is accepted as a !!str or !!binary. - // Otherwise, the prefix is enough of a hint about what it might be. - hint := byte('N') - if in != "" { - hint = resolveTable[in[0]] - } - if hint != 0 && tag != yaml_STR_TAG && tag != yaml_BINARY_TAG { - // Handle things we can lookup in a map. - if item, ok := resolveMap[in]; ok { - return item.tag, item.value - } - - // Base 60 floats are a bad idea, were dropped in YAML 1.2, and - // are purposefully unsupported here. They're still quoted on - // the way out for compatibility with other parser, though. - - switch hint { - case 'M': - // We've already checked the map above. - - case '.': - // Not in the map, so maybe a normal float. - floatv, err := strconv.ParseFloat(in, 64) - if err == nil { - return yaml_FLOAT_TAG, floatv - } - - case 'D', 'S': - // Int, float, or timestamp. - plain := strings.Replace(in, "_", "", -1) - intv, err := strconv.ParseInt(plain, 0, 64) - if err == nil { - if intv == int64(int(intv)) { - return yaml_INT_TAG, int(intv) - } else { - return yaml_INT_TAG, intv - } - } - uintv, err := strconv.ParseUint(plain, 0, 64) - if err == nil { - return yaml_INT_TAG, uintv - } - if yamlStyleFloat.MatchString(plain) { - floatv, err := strconv.ParseFloat(plain, 64) - if err == nil { - return yaml_FLOAT_TAG, floatv - } - } - if strings.HasPrefix(plain, "0b") { - intv, err := strconv.ParseInt(plain[2:], 2, 64) - if err == nil { - if intv == int64(int(intv)) { - return yaml_INT_TAG, int(intv) - } else { - return yaml_INT_TAG, intv - } - } - uintv, err := strconv.ParseUint(plain[2:], 2, 64) - if err == nil { - return yaml_INT_TAG, uintv - } - } else if strings.HasPrefix(plain, "-0b") { - intv, err := strconv.ParseInt(plain[3:], 2, 64) - if err == nil { - if intv == int64(int(intv)) { - return yaml_INT_TAG, -int(intv) - } else { - return yaml_INT_TAG, -intv - } - } - } - // XXX Handle timestamps here. - - default: - panic("resolveTable item not yet handled: " + string(rune(hint)) + " (with " + in + ")") - } - } - if tag == yaml_BINARY_TAG { - return yaml_BINARY_TAG, in - } - if utf8.ValidString(in) { - return yaml_STR_TAG, in - } - return yaml_BINARY_TAG, encodeBase64(in) -} - -// encodeBase64 encodes s as base64 that is broken up into multiple lines -// as appropriate for the resulting length. -func encodeBase64(s string) string { - const lineLen = 70 - encLen := base64.StdEncoding.EncodedLen(len(s)) - lines := encLen/lineLen + 1 - buf := make([]byte, encLen*2+lines) - in := buf[0:encLen] - out := buf[encLen:] - base64.StdEncoding.Encode(in, []byte(s)) - k := 0 - for i := 0; i < len(in); i += lineLen { - j := i + lineLen - if j > len(in) { - j = len(in) - } - k += copy(out[k:], in[i:j]) - if lines > 1 { - out[k] = '\n' - k++ - } - } - return string(out[:k]) -} diff --git a/_beats/dev-tools/vendor/gopkg.in/yaml.v2/scannerc.go b/_beats/dev-tools/vendor/gopkg.in/yaml.v2/scannerc.go deleted file mode 100644 index 0744844558..0000000000 --- a/_beats/dev-tools/vendor/gopkg.in/yaml.v2/scannerc.go +++ /dev/null @@ -1,2711 +0,0 @@ -package yaml - -import ( - "bytes" - "fmt" -) - -// Introduction -// ************ -// -// The following notes assume that you are familiar with the YAML specification -// (http://yaml.org/spec/1.2/spec.html). We mostly follow it, although in -// some cases we are less restrictive that it requires. -// -// The process of transforming a YAML stream into a sequence of events is -// divided on two steps: Scanning and Parsing. -// -// The Scanner transforms the input stream into a sequence of tokens, while the -// parser transform the sequence of tokens produced by the Scanner into a -// sequence of parsing events. -// -// The Scanner is rather clever and complicated. The Parser, on the contrary, -// is a straightforward implementation of a recursive-descendant parser (or, -// LL(1) parser, as it is usually called). -// -// Actually there are two issues of Scanning that might be called "clever", the -// rest is quite straightforward. The issues are "block collection start" and -// "simple keys". Both issues are explained below in details. -// -// Here the Scanning step is explained and implemented. We start with the list -// of all the tokens produced by the Scanner together with short descriptions. -// -// Now, tokens: -// -// STREAM-START(encoding) # The stream start. -// STREAM-END # The stream end. -// VERSION-DIRECTIVE(major,minor) # The '%YAML' directive. -// TAG-DIRECTIVE(handle,prefix) # The '%TAG' directive. -// DOCUMENT-START # '---' -// DOCUMENT-END # '...' -// BLOCK-SEQUENCE-START # Indentation increase denoting a block -// BLOCK-MAPPING-START # sequence or a block mapping. -// BLOCK-END # Indentation decrease. -// FLOW-SEQUENCE-START # '[' -// FLOW-SEQUENCE-END # ']' -// BLOCK-SEQUENCE-START # '{' -// BLOCK-SEQUENCE-END # '}' -// BLOCK-ENTRY # '-' -// FLOW-ENTRY # ',' -// KEY # '?' or nothing (simple keys). -// VALUE # ':' -// ALIAS(anchor) # '*anchor' -// ANCHOR(anchor) # '&anchor' -// TAG(handle,suffix) # '!handle!suffix' -// SCALAR(value,style) # A scalar. -// -// The following two tokens are "virtual" tokens denoting the beginning and the -// end of the stream: -// -// STREAM-START(encoding) -// STREAM-END -// -// We pass the information about the input stream encoding with the -// STREAM-START token. -// -// The next two tokens are responsible for tags: -// -// VERSION-DIRECTIVE(major,minor) -// TAG-DIRECTIVE(handle,prefix) -// -// Example: -// -// %YAML 1.1 -// %TAG ! !foo -// %TAG !yaml! tag:yaml.org,2002: -// --- -// -// The correspoding sequence of tokens: -// -// STREAM-START(utf-8) -// VERSION-DIRECTIVE(1,1) -// TAG-DIRECTIVE("!","!foo") -// TAG-DIRECTIVE("!yaml","tag:yaml.org,2002:") -// DOCUMENT-START -// STREAM-END -// -// Note that the VERSION-DIRECTIVE and TAG-DIRECTIVE tokens occupy a whole -// line. -// -// The document start and end indicators are represented by: -// -// DOCUMENT-START -// DOCUMENT-END -// -// Note that if a YAML stream contains an implicit document (without '---' -// and '...' indicators), no DOCUMENT-START and DOCUMENT-END tokens will be -// produced. -// -// In the following examples, we present whole documents together with the -// produced tokens. -// -// 1. An implicit document: -// -// 'a scalar' -// -// Tokens: -// -// STREAM-START(utf-8) -// SCALAR("a scalar",single-quoted) -// STREAM-END -// -// 2. An explicit document: -// -// --- -// 'a scalar' -// ... -// -// Tokens: -// -// STREAM-START(utf-8) -// DOCUMENT-START -// SCALAR("a scalar",single-quoted) -// DOCUMENT-END -// STREAM-END -// -// 3. Several documents in a stream: -// -// 'a scalar' -// --- -// 'another scalar' -// --- -// 'yet another scalar' -// -// Tokens: -// -// STREAM-START(utf-8) -// SCALAR("a scalar",single-quoted) -// DOCUMENT-START -// SCALAR("another scalar",single-quoted) -// DOCUMENT-START -// SCALAR("yet another scalar",single-quoted) -// STREAM-END -// -// We have already introduced the SCALAR token above. The following tokens are -// used to describe aliases, anchors, tag, and scalars: -// -// ALIAS(anchor) -// ANCHOR(anchor) -// TAG(handle,suffix) -// SCALAR(value,style) -// -// The following series of examples illustrate the usage of these tokens: -// -// 1. A recursive sequence: -// -// &A [ *A ] -// -// Tokens: -// -// STREAM-START(utf-8) -// ANCHOR("A") -// FLOW-SEQUENCE-START -// ALIAS("A") -// FLOW-SEQUENCE-END -// STREAM-END -// -// 2. A tagged scalar: -// -// !!float "3.14" # A good approximation. -// -// Tokens: -// -// STREAM-START(utf-8) -// TAG("!!","float") -// SCALAR("3.14",double-quoted) -// STREAM-END -// -// 3. Various scalar styles: -// -// --- # Implicit empty plain scalars do not produce tokens. -// --- a plain scalar -// --- 'a single-quoted scalar' -// --- "a double-quoted scalar" -// --- |- -// a literal scalar -// --- >- -// a folded -// scalar -// -// Tokens: -// -// STREAM-START(utf-8) -// DOCUMENT-START -// DOCUMENT-START -// SCALAR("a plain scalar",plain) -// DOCUMENT-START -// SCALAR("a single-quoted scalar",single-quoted) -// DOCUMENT-START -// SCALAR("a double-quoted scalar",double-quoted) -// DOCUMENT-START -// SCALAR("a literal scalar",literal) -// DOCUMENT-START -// SCALAR("a folded scalar",folded) -// STREAM-END -// -// Now it's time to review collection-related tokens. We will start with -// flow collections: -// -// FLOW-SEQUENCE-START -// FLOW-SEQUENCE-END -// FLOW-MAPPING-START -// FLOW-MAPPING-END -// FLOW-ENTRY -// KEY -// VALUE -// -// The tokens FLOW-SEQUENCE-START, FLOW-SEQUENCE-END, FLOW-MAPPING-START, and -// FLOW-MAPPING-END represent the indicators '[', ']', '{', and '}' -// correspondingly. FLOW-ENTRY represent the ',' indicator. Finally the -// indicators '?' and ':', which are used for denoting mapping keys and values, -// are represented by the KEY and VALUE tokens. -// -// The following examples show flow collections: -// -// 1. A flow sequence: -// -// [item 1, item 2, item 3] -// -// Tokens: -// -// STREAM-START(utf-8) -// FLOW-SEQUENCE-START -// SCALAR("item 1",plain) -// FLOW-ENTRY -// SCALAR("item 2",plain) -// FLOW-ENTRY -// SCALAR("item 3",plain) -// FLOW-SEQUENCE-END -// STREAM-END -// -// 2. A flow mapping: -// -// { -// a simple key: a value, # Note that the KEY token is produced. -// ? a complex key: another value, -// } -// -// Tokens: -// -// STREAM-START(utf-8) -// FLOW-MAPPING-START -// KEY -// SCALAR("a simple key",plain) -// VALUE -// SCALAR("a value",plain) -// FLOW-ENTRY -// KEY -// SCALAR("a complex key",plain) -// VALUE -// SCALAR("another value",plain) -// FLOW-ENTRY -// FLOW-MAPPING-END -// STREAM-END -// -// A simple key is a key which is not denoted by the '?' indicator. Note that -// the Scanner still produce the KEY token whenever it encounters a simple key. -// -// For scanning block collections, the following tokens are used (note that we -// repeat KEY and VALUE here): -// -// BLOCK-SEQUENCE-START -// BLOCK-MAPPING-START -// BLOCK-END -// BLOCK-ENTRY -// KEY -// VALUE -// -// The tokens BLOCK-SEQUENCE-START and BLOCK-MAPPING-START denote indentation -// increase that precedes a block collection (cf. the INDENT token in Python). -// The token BLOCK-END denote indentation decrease that ends a block collection -// (cf. the DEDENT token in Python). However YAML has some syntax pecularities -// that makes detections of these tokens more complex. -// -// The tokens BLOCK-ENTRY, KEY, and VALUE are used to represent the indicators -// '-', '?', and ':' correspondingly. -// -// The following examples show how the tokens BLOCK-SEQUENCE-START, -// BLOCK-MAPPING-START, and BLOCK-END are emitted by the Scanner: -// -// 1. Block sequences: -// -// - item 1 -// - item 2 -// - -// - item 3.1 -// - item 3.2 -// - -// key 1: value 1 -// key 2: value 2 -// -// Tokens: -// -// STREAM-START(utf-8) -// BLOCK-SEQUENCE-START -// BLOCK-ENTRY -// SCALAR("item 1",plain) -// BLOCK-ENTRY -// SCALAR("item 2",plain) -// BLOCK-ENTRY -// BLOCK-SEQUENCE-START -// BLOCK-ENTRY -// SCALAR("item 3.1",plain) -// BLOCK-ENTRY -// SCALAR("item 3.2",plain) -// BLOCK-END -// BLOCK-ENTRY -// BLOCK-MAPPING-START -// KEY -// SCALAR("key 1",plain) -// VALUE -// SCALAR("value 1",plain) -// KEY -// SCALAR("key 2",plain) -// VALUE -// SCALAR("value 2",plain) -// BLOCK-END -// BLOCK-END -// STREAM-END -// -// 2. Block mappings: -// -// a simple key: a value # The KEY token is produced here. -// ? a complex key -// : another value -// a mapping: -// key 1: value 1 -// key 2: value 2 -// a sequence: -// - item 1 -// - item 2 -// -// Tokens: -// -// STREAM-START(utf-8) -// BLOCK-MAPPING-START -// KEY -// SCALAR("a simple key",plain) -// VALUE -// SCALAR("a value",plain) -// KEY -// SCALAR("a complex key",plain) -// VALUE -// SCALAR("another value",plain) -// KEY -// SCALAR("a mapping",plain) -// BLOCK-MAPPING-START -// KEY -// SCALAR("key 1",plain) -// VALUE -// SCALAR("value 1",plain) -// KEY -// SCALAR("key 2",plain) -// VALUE -// SCALAR("value 2",plain) -// BLOCK-END -// KEY -// SCALAR("a sequence",plain) -// VALUE -// BLOCK-SEQUENCE-START -// BLOCK-ENTRY -// SCALAR("item 1",plain) -// BLOCK-ENTRY -// SCALAR("item 2",plain) -// BLOCK-END -// BLOCK-END -// STREAM-END -// -// YAML does not always require to start a new block collection from a new -// line. If the current line contains only '-', '?', and ':' indicators, a new -// block collection may start at the current line. The following examples -// illustrate this case: -// -// 1. Collections in a sequence: -// -// - - item 1 -// - item 2 -// - key 1: value 1 -// key 2: value 2 -// - ? complex key -// : complex value -// -// Tokens: -// -// STREAM-START(utf-8) -// BLOCK-SEQUENCE-START -// BLOCK-ENTRY -// BLOCK-SEQUENCE-START -// BLOCK-ENTRY -// SCALAR("item 1",plain) -// BLOCK-ENTRY -// SCALAR("item 2",plain) -// BLOCK-END -// BLOCK-ENTRY -// BLOCK-MAPPING-START -// KEY -// SCALAR("key 1",plain) -// VALUE -// SCALAR("value 1",plain) -// KEY -// SCALAR("key 2",plain) -// VALUE -// SCALAR("value 2",plain) -// BLOCK-END -// BLOCK-ENTRY -// BLOCK-MAPPING-START -// KEY -// SCALAR("complex key") -// VALUE -// SCALAR("complex value") -// BLOCK-END -// BLOCK-END -// STREAM-END -// -// 2. Collections in a mapping: -// -// ? a sequence -// : - item 1 -// - item 2 -// ? a mapping -// : key 1: value 1 -// key 2: value 2 -// -// Tokens: -// -// STREAM-START(utf-8) -// BLOCK-MAPPING-START -// KEY -// SCALAR("a sequence",plain) -// VALUE -// BLOCK-SEQUENCE-START -// BLOCK-ENTRY -// SCALAR("item 1",plain) -// BLOCK-ENTRY -// SCALAR("item 2",plain) -// BLOCK-END -// KEY -// SCALAR("a mapping",plain) -// VALUE -// BLOCK-MAPPING-START -// KEY -// SCALAR("key 1",plain) -// VALUE -// SCALAR("value 1",plain) -// KEY -// SCALAR("key 2",plain) -// VALUE -// SCALAR("value 2",plain) -// BLOCK-END -// BLOCK-END -// STREAM-END -// -// YAML also permits non-indented sequences if they are included into a block -// mapping. In this case, the token BLOCK-SEQUENCE-START is not produced: -// -// key: -// - item 1 # BLOCK-SEQUENCE-START is NOT produced here. -// - item 2 -// -// Tokens: -// -// STREAM-START(utf-8) -// BLOCK-MAPPING-START -// KEY -// SCALAR("key",plain) -// VALUE -// BLOCK-ENTRY -// SCALAR("item 1",plain) -// BLOCK-ENTRY -// SCALAR("item 2",plain) -// BLOCK-END -// - -// Ensure that the buffer contains the required number of characters. -// Return true on success, false on failure (reader error or memory error). -func cache(parser *yaml_parser_t, length int) bool { - // [Go] This was inlined: !cache(A, B) -> unread < B && !update(A, B) - return parser.unread >= length || yaml_parser_update_buffer(parser, length) -} - -// Advance the buffer pointer. -func skip(parser *yaml_parser_t) { - parser.mark.index++ - parser.mark.column++ - parser.unread-- - parser.buffer_pos += width(parser.buffer[parser.buffer_pos]) -} - -func skip_line(parser *yaml_parser_t) { - if is_crlf(parser.buffer, parser.buffer_pos) { - parser.mark.index += 2 - parser.mark.column = 0 - parser.mark.line++ - parser.unread -= 2 - parser.buffer_pos += 2 - } else if is_break(parser.buffer, parser.buffer_pos) { - parser.mark.index++ - parser.mark.column = 0 - parser.mark.line++ - parser.unread-- - parser.buffer_pos += width(parser.buffer[parser.buffer_pos]) - } -} - -// Copy a character to a string buffer and advance pointers. -func read(parser *yaml_parser_t, s []byte) []byte { - w := width(parser.buffer[parser.buffer_pos]) - if w == 0 { - panic("invalid character sequence") - } - if len(s) == 0 { - s = make([]byte, 0, 32) - } - if w == 1 && len(s)+w <= cap(s) { - s = s[:len(s)+1] - s[len(s)-1] = parser.buffer[parser.buffer_pos] - parser.buffer_pos++ - } else { - s = append(s, parser.buffer[parser.buffer_pos:parser.buffer_pos+w]...) - parser.buffer_pos += w - } - parser.mark.index++ - parser.mark.column++ - parser.unread-- - return s -} - -// Copy a line break character to a string buffer and advance pointers. -func read_line(parser *yaml_parser_t, s []byte) []byte { - buf := parser.buffer - pos := parser.buffer_pos - switch { - case buf[pos] == '\r' && buf[pos+1] == '\n': - // CR LF . LF - s = append(s, '\n') - parser.buffer_pos += 2 - parser.mark.index++ - parser.unread-- - case buf[pos] == '\r' || buf[pos] == '\n': - // CR|LF . LF - s = append(s, '\n') - parser.buffer_pos += 1 - case buf[pos] == '\xC2' && buf[pos+1] == '\x85': - // NEL . LF - s = append(s, '\n') - parser.buffer_pos += 2 - case buf[pos] == '\xE2' && buf[pos+1] == '\x80' && (buf[pos+2] == '\xA8' || buf[pos+2] == '\xA9'): - // LS|PS . LS|PS - s = append(s, buf[parser.buffer_pos:pos+3]...) - parser.buffer_pos += 3 - default: - return s - } - parser.mark.index++ - parser.mark.column = 0 - parser.mark.line++ - parser.unread-- - return s -} - -// Get the next token. -func yaml_parser_scan(parser *yaml_parser_t, token *yaml_token_t) bool { - // Erase the token object. - *token = yaml_token_t{} // [Go] Is this necessary? - - // No tokens after STREAM-END or error. - if parser.stream_end_produced || parser.error != yaml_NO_ERROR { - return true - } - - // Ensure that the tokens queue contains enough tokens. - if !parser.token_available { - if !yaml_parser_fetch_more_tokens(parser) { - return false - } - } - - // Fetch the next token from the queue. - *token = parser.tokens[parser.tokens_head] - parser.tokens_head++ - parser.tokens_parsed++ - parser.token_available = false - - if token.typ == yaml_STREAM_END_TOKEN { - parser.stream_end_produced = true - } - return true -} - -// Set the scanner error and return false. -func yaml_parser_set_scanner_error(parser *yaml_parser_t, context string, context_mark yaml_mark_t, problem string) bool { - parser.error = yaml_SCANNER_ERROR - parser.context = context - parser.context_mark = context_mark - parser.problem = problem - parser.problem_mark = parser.mark - return false -} - -func yaml_parser_set_scanner_tag_error(parser *yaml_parser_t, directive bool, context_mark yaml_mark_t, problem string) bool { - context := "while parsing a tag" - if directive { - context = "while parsing a %TAG directive" - } - return yaml_parser_set_scanner_error(parser, context, context_mark, problem) -} - -func trace(args ...interface{}) func() { - pargs := append([]interface{}{"+++"}, args...) - fmt.Println(pargs...) - pargs = append([]interface{}{"---"}, args...) - return func() { fmt.Println(pargs...) } -} - -// Ensure that the tokens queue contains at least one token which can be -// returned to the Parser. -func yaml_parser_fetch_more_tokens(parser *yaml_parser_t) bool { - // While we need more tokens to fetch, do it. - for { - // Check if we really need to fetch more tokens. - need_more_tokens := false - - if parser.tokens_head == len(parser.tokens) { - // Queue is empty. - need_more_tokens = true - } else { - // Check if any potential simple key may occupy the head position. - if !yaml_parser_stale_simple_keys(parser) { - return false - } - - for i := range parser.simple_keys { - simple_key := &parser.simple_keys[i] - if simple_key.possible && simple_key.token_number == parser.tokens_parsed { - need_more_tokens = true - break - } - } - } - - // We are finished. - if !need_more_tokens { - break - } - // Fetch the next token. - if !yaml_parser_fetch_next_token(parser) { - return false - } - } - - parser.token_available = true - return true -} - -// The dispatcher for token fetchers. -func yaml_parser_fetch_next_token(parser *yaml_parser_t) bool { - // Ensure that the buffer is initialized. - if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { - return false - } - - // Check if we just started scanning. Fetch STREAM-START then. - if !parser.stream_start_produced { - return yaml_parser_fetch_stream_start(parser) - } - - // Eat whitespaces and comments until we reach the next token. - if !yaml_parser_scan_to_next_token(parser) { - return false - } - - // Remove obsolete potential simple keys. - if !yaml_parser_stale_simple_keys(parser) { - return false - } - - // Check the indentation level against the current column. - if !yaml_parser_unroll_indent(parser, parser.mark.column) { - return false - } - - // Ensure that the buffer contains at least 4 characters. 4 is the length - // of the longest indicators ('--- ' and '... '). - if parser.unread < 4 && !yaml_parser_update_buffer(parser, 4) { - return false - } - - // Is it the end of the stream? - if is_z(parser.buffer, parser.buffer_pos) { - return yaml_parser_fetch_stream_end(parser) - } - - // Is it a directive? - if parser.mark.column == 0 && parser.buffer[parser.buffer_pos] == '%' { - return yaml_parser_fetch_directive(parser) - } - - buf := parser.buffer - pos := parser.buffer_pos - - // Is it the document start indicator? - if parser.mark.column == 0 && buf[pos] == '-' && buf[pos+1] == '-' && buf[pos+2] == '-' && is_blankz(buf, pos+3) { - return yaml_parser_fetch_document_indicator(parser, yaml_DOCUMENT_START_TOKEN) - } - - // Is it the document end indicator? - if parser.mark.column == 0 && buf[pos] == '.' && buf[pos+1] == '.' && buf[pos+2] == '.' && is_blankz(buf, pos+3) { - return yaml_parser_fetch_document_indicator(parser, yaml_DOCUMENT_END_TOKEN) - } - - // Is it the flow sequence start indicator? - if buf[pos] == '[' { - return yaml_parser_fetch_flow_collection_start(parser, yaml_FLOW_SEQUENCE_START_TOKEN) - } - - // Is it the flow mapping start indicator? - if parser.buffer[parser.buffer_pos] == '{' { - return yaml_parser_fetch_flow_collection_start(parser, yaml_FLOW_MAPPING_START_TOKEN) - } - - // Is it the flow sequence end indicator? - if parser.buffer[parser.buffer_pos] == ']' { - return yaml_parser_fetch_flow_collection_end(parser, - yaml_FLOW_SEQUENCE_END_TOKEN) - } - - // Is it the flow mapping end indicator? - if parser.buffer[parser.buffer_pos] == '}' { - return yaml_parser_fetch_flow_collection_end(parser, - yaml_FLOW_MAPPING_END_TOKEN) - } - - // Is it the flow entry indicator? - if parser.buffer[parser.buffer_pos] == ',' { - return yaml_parser_fetch_flow_entry(parser) - } - - // Is it the block entry indicator? - if parser.buffer[parser.buffer_pos] == '-' && is_blankz(parser.buffer, parser.buffer_pos+1) { - return yaml_parser_fetch_block_entry(parser) - } - - // Is it the key indicator? - if parser.buffer[parser.buffer_pos] == '?' && (parser.flow_level > 0 || is_blankz(parser.buffer, parser.buffer_pos+1)) { - return yaml_parser_fetch_key(parser) - } - - // Is it the value indicator? - if parser.buffer[parser.buffer_pos] == ':' && (parser.flow_level > 0 || is_blankz(parser.buffer, parser.buffer_pos+1)) { - return yaml_parser_fetch_value(parser) - } - - // Is it an alias? - if parser.buffer[parser.buffer_pos] == '*' { - return yaml_parser_fetch_anchor(parser, yaml_ALIAS_TOKEN) - } - - // Is it an anchor? - if parser.buffer[parser.buffer_pos] == '&' { - return yaml_parser_fetch_anchor(parser, yaml_ANCHOR_TOKEN) - } - - // Is it a tag? - if parser.buffer[parser.buffer_pos] == '!' { - return yaml_parser_fetch_tag(parser) - } - - // Is it a literal scalar? - if parser.buffer[parser.buffer_pos] == '|' && parser.flow_level == 0 { - return yaml_parser_fetch_block_scalar(parser, true) - } - - // Is it a folded scalar? - if parser.buffer[parser.buffer_pos] == '>' && parser.flow_level == 0 { - return yaml_parser_fetch_block_scalar(parser, false) - } - - // Is it a single-quoted scalar? - if parser.buffer[parser.buffer_pos] == '\'' { - return yaml_parser_fetch_flow_scalar(parser, true) - } - - // Is it a double-quoted scalar? - if parser.buffer[parser.buffer_pos] == '"' { - return yaml_parser_fetch_flow_scalar(parser, false) - } - - // Is it a plain scalar? - // - // A plain scalar may start with any non-blank characters except - // - // '-', '?', ':', ',', '[', ']', '{', '}', - // '#', '&', '*', '!', '|', '>', '\'', '\"', - // '%', '@', '`'. - // - // In the block context (and, for the '-' indicator, in the flow context - // too), it may also start with the characters - // - // '-', '?', ':' - // - // if it is followed by a non-space character. - // - // The last rule is more restrictive than the specification requires. - // [Go] Make this logic more reasonable. - //switch parser.buffer[parser.buffer_pos] { - //case '-', '?', ':', ',', '?', '-', ',', ':', ']', '[', '}', '{', '&', '#', '!', '*', '>', '|', '"', '\'', '@', '%', '-', '`': - //} - if !(is_blankz(parser.buffer, parser.buffer_pos) || parser.buffer[parser.buffer_pos] == '-' || - parser.buffer[parser.buffer_pos] == '?' || parser.buffer[parser.buffer_pos] == ':' || - parser.buffer[parser.buffer_pos] == ',' || parser.buffer[parser.buffer_pos] == '[' || - parser.buffer[parser.buffer_pos] == ']' || parser.buffer[parser.buffer_pos] == '{' || - parser.buffer[parser.buffer_pos] == '}' || parser.buffer[parser.buffer_pos] == '#' || - parser.buffer[parser.buffer_pos] == '&' || parser.buffer[parser.buffer_pos] == '*' || - parser.buffer[parser.buffer_pos] == '!' || parser.buffer[parser.buffer_pos] == '|' || - parser.buffer[parser.buffer_pos] == '>' || parser.buffer[parser.buffer_pos] == '\'' || - parser.buffer[parser.buffer_pos] == '"' || parser.buffer[parser.buffer_pos] == '%' || - parser.buffer[parser.buffer_pos] == '@' || parser.buffer[parser.buffer_pos] == '`') || - (parser.buffer[parser.buffer_pos] == '-' && !is_blank(parser.buffer, parser.buffer_pos+1)) || - (parser.flow_level == 0 && - (parser.buffer[parser.buffer_pos] == '?' || parser.buffer[parser.buffer_pos] == ':') && - !is_blankz(parser.buffer, parser.buffer_pos+1)) { - return yaml_parser_fetch_plain_scalar(parser) - } - - // If we don't determine the token type so far, it is an error. - return yaml_parser_set_scanner_error(parser, - "while scanning for the next token", parser.mark, - "found character that cannot start any token") -} - -// Check the list of potential simple keys and remove the positions that -// cannot contain simple keys anymore. -func yaml_parser_stale_simple_keys(parser *yaml_parser_t) bool { - // Check for a potential simple key for each flow level. - for i := range parser.simple_keys { - simple_key := &parser.simple_keys[i] - - // The specification requires that a simple key - // - // - is limited to a single line, - // - is shorter than 1024 characters. - if simple_key.possible && (simple_key.mark.line < parser.mark.line || simple_key.mark.index+1024 < parser.mark.index) { - - // Check if the potential simple key to be removed is required. - if simple_key.required { - return yaml_parser_set_scanner_error(parser, - "while scanning a simple key", simple_key.mark, - "could not find expected ':'") - } - simple_key.possible = false - } - } - return true -} - -// Check if a simple key may start at the current position and add it if -// needed. -func yaml_parser_save_simple_key(parser *yaml_parser_t) bool { - // A simple key is required at the current position if the scanner is in - // the block context and the current column coincides with the indentation - // level. - - required := parser.flow_level == 0 && parser.indent == parser.mark.column - - // A simple key is required only when it is the first token in the current - // line. Therefore it is always allowed. But we add a check anyway. - if required && !parser.simple_key_allowed { - panic("should not happen") - } - - // - // If the current position may start a simple key, save it. - // - if parser.simple_key_allowed { - simple_key := yaml_simple_key_t{ - possible: true, - required: required, - token_number: parser.tokens_parsed + (len(parser.tokens) - parser.tokens_head), - } - simple_key.mark = parser.mark - - if !yaml_parser_remove_simple_key(parser) { - return false - } - parser.simple_keys[len(parser.simple_keys)-1] = simple_key - } - return true -} - -// Remove a potential simple key at the current flow level. -func yaml_parser_remove_simple_key(parser *yaml_parser_t) bool { - i := len(parser.simple_keys) - 1 - if parser.simple_keys[i].possible { - // If the key is required, it is an error. - if parser.simple_keys[i].required { - return yaml_parser_set_scanner_error(parser, - "while scanning a simple key", parser.simple_keys[i].mark, - "could not find expected ':'") - } - } - // Remove the key from the stack. - parser.simple_keys[i].possible = false - return true -} - -// Increase the flow level and resize the simple key list if needed. -func yaml_parser_increase_flow_level(parser *yaml_parser_t) bool { - // Reset the simple key on the next level. - parser.simple_keys = append(parser.simple_keys, yaml_simple_key_t{}) - - // Increase the flow level. - parser.flow_level++ - return true -} - -// Decrease the flow level. -func yaml_parser_decrease_flow_level(parser *yaml_parser_t) bool { - if parser.flow_level > 0 { - parser.flow_level-- - parser.simple_keys = parser.simple_keys[:len(parser.simple_keys)-1] - } - return true -} - -// Push the current indentation level to the stack and set the new level -// the current column is greater than the indentation level. In this case, -// append or insert the specified token into the token queue. -func yaml_parser_roll_indent(parser *yaml_parser_t, column, number int, typ yaml_token_type_t, mark yaml_mark_t) bool { - // In the flow context, do nothing. - if parser.flow_level > 0 { - return true - } - - if parser.indent < column { - // Push the current indentation level to the stack and set the new - // indentation level. - parser.indents = append(parser.indents, parser.indent) - parser.indent = column - - // Create a token and insert it into the queue. - token := yaml_token_t{ - typ: typ, - start_mark: mark, - end_mark: mark, - } - if number > -1 { - number -= parser.tokens_parsed - } - yaml_insert_token(parser, number, &token) - } - return true -} - -// Pop indentation levels from the indents stack until the current level -// becomes less or equal to the column. For each indentation level, append -// the BLOCK-END token. -func yaml_parser_unroll_indent(parser *yaml_parser_t, column int) bool { - // In the flow context, do nothing. - if parser.flow_level > 0 { - return true - } - - // Loop through the indentation levels in the stack. - for parser.indent > column { - // Create a token and append it to the queue. - token := yaml_token_t{ - typ: yaml_BLOCK_END_TOKEN, - start_mark: parser.mark, - end_mark: parser.mark, - } - yaml_insert_token(parser, -1, &token) - - // Pop the indentation level. - parser.indent = parser.indents[len(parser.indents)-1] - parser.indents = parser.indents[:len(parser.indents)-1] - } - return true -} - -// Initialize the scanner and produce the STREAM-START token. -func yaml_parser_fetch_stream_start(parser *yaml_parser_t) bool { - - // Set the initial indentation. - parser.indent = -1 - - // Initialize the simple key stack. - parser.simple_keys = append(parser.simple_keys, yaml_simple_key_t{}) - - // A simple key is allowed at the beginning of the stream. - parser.simple_key_allowed = true - - // We have started. - parser.stream_start_produced = true - - // Create the STREAM-START token and append it to the queue. - token := yaml_token_t{ - typ: yaml_STREAM_START_TOKEN, - start_mark: parser.mark, - end_mark: parser.mark, - encoding: parser.encoding, - } - yaml_insert_token(parser, -1, &token) - return true -} - -// Produce the STREAM-END token and shut down the scanner. -func yaml_parser_fetch_stream_end(parser *yaml_parser_t) bool { - - // Force new line. - if parser.mark.column != 0 { - parser.mark.column = 0 - parser.mark.line++ - } - - // Reset the indentation level. - if !yaml_parser_unroll_indent(parser, -1) { - return false - } - - // Reset simple keys. - if !yaml_parser_remove_simple_key(parser) { - return false - } - - parser.simple_key_allowed = false - - // Create the STREAM-END token and append it to the queue. - token := yaml_token_t{ - typ: yaml_STREAM_END_TOKEN, - start_mark: parser.mark, - end_mark: parser.mark, - } - yaml_insert_token(parser, -1, &token) - return true -} - -// Produce a VERSION-DIRECTIVE or TAG-DIRECTIVE token. -func yaml_parser_fetch_directive(parser *yaml_parser_t) bool { - // Reset the indentation level. - if !yaml_parser_unroll_indent(parser, -1) { - return false - } - - // Reset simple keys. - if !yaml_parser_remove_simple_key(parser) { - return false - } - - parser.simple_key_allowed = false - - // Create the YAML-DIRECTIVE or TAG-DIRECTIVE token. - token := yaml_token_t{} - if !yaml_parser_scan_directive(parser, &token) { - return false - } - // Append the token to the queue. - yaml_insert_token(parser, -1, &token) - return true -} - -// Produce the DOCUMENT-START or DOCUMENT-END token. -func yaml_parser_fetch_document_indicator(parser *yaml_parser_t, typ yaml_token_type_t) bool { - // Reset the indentation level. - if !yaml_parser_unroll_indent(parser, -1) { - return false - } - - // Reset simple keys. - if !yaml_parser_remove_simple_key(parser) { - return false - } - - parser.simple_key_allowed = false - - // Consume the token. - start_mark := parser.mark - - skip(parser) - skip(parser) - skip(parser) - - end_mark := parser.mark - - // Create the DOCUMENT-START or DOCUMENT-END token. - token := yaml_token_t{ - typ: typ, - start_mark: start_mark, - end_mark: end_mark, - } - // Append the token to the queue. - yaml_insert_token(parser, -1, &token) - return true -} - -// Produce the FLOW-SEQUENCE-START or FLOW-MAPPING-START token. -func yaml_parser_fetch_flow_collection_start(parser *yaml_parser_t, typ yaml_token_type_t) bool { - // The indicators '[' and '{' may start a simple key. - if !yaml_parser_save_simple_key(parser) { - return false - } - - // Increase the flow level. - if !yaml_parser_increase_flow_level(parser) { - return false - } - - // A simple key may follow the indicators '[' and '{'. - parser.simple_key_allowed = true - - // Consume the token. - start_mark := parser.mark - skip(parser) - end_mark := parser.mark - - // Create the FLOW-SEQUENCE-START of FLOW-MAPPING-START token. - token := yaml_token_t{ - typ: typ, - start_mark: start_mark, - end_mark: end_mark, - } - // Append the token to the queue. - yaml_insert_token(parser, -1, &token) - return true -} - -// Produce the FLOW-SEQUENCE-END or FLOW-MAPPING-END token. -func yaml_parser_fetch_flow_collection_end(parser *yaml_parser_t, typ yaml_token_type_t) bool { - // Reset any potential simple key on the current flow level. - if !yaml_parser_remove_simple_key(parser) { - return false - } - - // Decrease the flow level. - if !yaml_parser_decrease_flow_level(parser) { - return false - } - - // No simple keys after the indicators ']' and '}'. - parser.simple_key_allowed = false - - // Consume the token. - - start_mark := parser.mark - skip(parser) - end_mark := parser.mark - - // Create the FLOW-SEQUENCE-END of FLOW-MAPPING-END token. - token := yaml_token_t{ - typ: typ, - start_mark: start_mark, - end_mark: end_mark, - } - // Append the token to the queue. - yaml_insert_token(parser, -1, &token) - return true -} - -// Produce the FLOW-ENTRY token. -func yaml_parser_fetch_flow_entry(parser *yaml_parser_t) bool { - // Reset any potential simple keys on the current flow level. - if !yaml_parser_remove_simple_key(parser) { - return false - } - - // Simple keys are allowed after ','. - parser.simple_key_allowed = true - - // Consume the token. - start_mark := parser.mark - skip(parser) - end_mark := parser.mark - - // Create the FLOW-ENTRY token and append it to the queue. - token := yaml_token_t{ - typ: yaml_FLOW_ENTRY_TOKEN, - start_mark: start_mark, - end_mark: end_mark, - } - yaml_insert_token(parser, -1, &token) - return true -} - -// Produce the BLOCK-ENTRY token. -func yaml_parser_fetch_block_entry(parser *yaml_parser_t) bool { - // Check if the scanner is in the block context. - if parser.flow_level == 0 { - // Check if we are allowed to start a new entry. - if !parser.simple_key_allowed { - return yaml_parser_set_scanner_error(parser, "", parser.mark, - "block sequence entries are not allowed in this context") - } - // Add the BLOCK-SEQUENCE-START token if needed. - if !yaml_parser_roll_indent(parser, parser.mark.column, -1, yaml_BLOCK_SEQUENCE_START_TOKEN, parser.mark) { - return false - } - } else { - // It is an error for the '-' indicator to occur in the flow context, - // but we let the Parser detect and report about it because the Parser - // is able to point to the context. - } - - // Reset any potential simple keys on the current flow level. - if !yaml_parser_remove_simple_key(parser) { - return false - } - - // Simple keys are allowed after '-'. - parser.simple_key_allowed = true - - // Consume the token. - start_mark := parser.mark - skip(parser) - end_mark := parser.mark - - // Create the BLOCK-ENTRY token and append it to the queue. - token := yaml_token_t{ - typ: yaml_BLOCK_ENTRY_TOKEN, - start_mark: start_mark, - end_mark: end_mark, - } - yaml_insert_token(parser, -1, &token) - return true -} - -// Produce the KEY token. -func yaml_parser_fetch_key(parser *yaml_parser_t) bool { - - // In the block context, additional checks are required. - if parser.flow_level == 0 { - // Check if we are allowed to start a new key (not nessesary simple). - if !parser.simple_key_allowed { - return yaml_parser_set_scanner_error(parser, "", parser.mark, - "mapping keys are not allowed in this context") - } - // Add the BLOCK-MAPPING-START token if needed. - if !yaml_parser_roll_indent(parser, parser.mark.column, -1, yaml_BLOCK_MAPPING_START_TOKEN, parser.mark) { - return false - } - } - - // Reset any potential simple keys on the current flow level. - if !yaml_parser_remove_simple_key(parser) { - return false - } - - // Simple keys are allowed after '?' in the block context. - parser.simple_key_allowed = parser.flow_level == 0 - - // Consume the token. - start_mark := parser.mark - skip(parser) - end_mark := parser.mark - - // Create the KEY token and append it to the queue. - token := yaml_token_t{ - typ: yaml_KEY_TOKEN, - start_mark: start_mark, - end_mark: end_mark, - } - yaml_insert_token(parser, -1, &token) - return true -} - -// Produce the VALUE token. -func yaml_parser_fetch_value(parser *yaml_parser_t) bool { - - simple_key := &parser.simple_keys[len(parser.simple_keys)-1] - - // Have we found a simple key? - if simple_key.possible { - // Create the KEY token and insert it into the queue. - token := yaml_token_t{ - typ: yaml_KEY_TOKEN, - start_mark: simple_key.mark, - end_mark: simple_key.mark, - } - yaml_insert_token(parser, simple_key.token_number-parser.tokens_parsed, &token) - - // In the block context, we may need to add the BLOCK-MAPPING-START token. - if !yaml_parser_roll_indent(parser, simple_key.mark.column, - simple_key.token_number, - yaml_BLOCK_MAPPING_START_TOKEN, simple_key.mark) { - return false - } - - // Remove the simple key. - simple_key.possible = false - - // A simple key cannot follow another simple key. - parser.simple_key_allowed = false - - } else { - // The ':' indicator follows a complex key. - - // In the block context, extra checks are required. - if parser.flow_level == 0 { - - // Check if we are allowed to start a complex value. - if !parser.simple_key_allowed { - return yaml_parser_set_scanner_error(parser, "", parser.mark, - "mapping values are not allowed in this context") - } - - // Add the BLOCK-MAPPING-START token if needed. - if !yaml_parser_roll_indent(parser, parser.mark.column, -1, yaml_BLOCK_MAPPING_START_TOKEN, parser.mark) { - return false - } - } - - // Simple keys after ':' are allowed in the block context. - parser.simple_key_allowed = parser.flow_level == 0 - } - - // Consume the token. - start_mark := parser.mark - skip(parser) - end_mark := parser.mark - - // Create the VALUE token and append it to the queue. - token := yaml_token_t{ - typ: yaml_VALUE_TOKEN, - start_mark: start_mark, - end_mark: end_mark, - } - yaml_insert_token(parser, -1, &token) - return true -} - -// Produce the ALIAS or ANCHOR token. -func yaml_parser_fetch_anchor(parser *yaml_parser_t, typ yaml_token_type_t) bool { - // An anchor or an alias could be a simple key. - if !yaml_parser_save_simple_key(parser) { - return false - } - - // A simple key cannot follow an anchor or an alias. - parser.simple_key_allowed = false - - // Create the ALIAS or ANCHOR token and append it to the queue. - var token yaml_token_t - if !yaml_parser_scan_anchor(parser, &token, typ) { - return false - } - yaml_insert_token(parser, -1, &token) - return true -} - -// Produce the TAG token. -func yaml_parser_fetch_tag(parser *yaml_parser_t) bool { - // A tag could be a simple key. - if !yaml_parser_save_simple_key(parser) { - return false - } - - // A simple key cannot follow a tag. - parser.simple_key_allowed = false - - // Create the TAG token and append it to the queue. - var token yaml_token_t - if !yaml_parser_scan_tag(parser, &token) { - return false - } - yaml_insert_token(parser, -1, &token) - return true -} - -// Produce the SCALAR(...,literal) or SCALAR(...,folded) tokens. -func yaml_parser_fetch_block_scalar(parser *yaml_parser_t, literal bool) bool { - // Remove any potential simple keys. - if !yaml_parser_remove_simple_key(parser) { - return false - } - - // A simple key may follow a block scalar. - parser.simple_key_allowed = true - - // Create the SCALAR token and append it to the queue. - var token yaml_token_t - if !yaml_parser_scan_block_scalar(parser, &token, literal) { - return false - } - yaml_insert_token(parser, -1, &token) - return true -} - -// Produce the SCALAR(...,single-quoted) or SCALAR(...,double-quoted) tokens. -func yaml_parser_fetch_flow_scalar(parser *yaml_parser_t, single bool) bool { - // A plain scalar could be a simple key. - if !yaml_parser_save_simple_key(parser) { - return false - } - - // A simple key cannot follow a flow scalar. - parser.simple_key_allowed = false - - // Create the SCALAR token and append it to the queue. - var token yaml_token_t - if !yaml_parser_scan_flow_scalar(parser, &token, single) { - return false - } - yaml_insert_token(parser, -1, &token) - return true -} - -// Produce the SCALAR(...,plain) token. -func yaml_parser_fetch_plain_scalar(parser *yaml_parser_t) bool { - // A plain scalar could be a simple key. - if !yaml_parser_save_simple_key(parser) { - return false - } - - // A simple key cannot follow a flow scalar. - parser.simple_key_allowed = false - - // Create the SCALAR token and append it to the queue. - var token yaml_token_t - if !yaml_parser_scan_plain_scalar(parser, &token) { - return false - } - yaml_insert_token(parser, -1, &token) - return true -} - -// Eat whitespaces and comments until the next token is found. -func yaml_parser_scan_to_next_token(parser *yaml_parser_t) bool { - - // Until the next token is not found. - for { - // Allow the BOM mark to start a line. - if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { - return false - } - if parser.mark.column == 0 && is_bom(parser.buffer, parser.buffer_pos) { - skip(parser) - } - - // Eat whitespaces. - // Tabs are allowed: - // - in the flow context - // - in the block context, but not at the beginning of the line or - // after '-', '?', or ':' (complex value). - if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { - return false - } - - for parser.buffer[parser.buffer_pos] == ' ' || ((parser.flow_level > 0 || !parser.simple_key_allowed) && parser.buffer[parser.buffer_pos] == '\t') { - skip(parser) - if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { - return false - } - } - - // Eat a comment until a line break. - if parser.buffer[parser.buffer_pos] == '#' { - for !is_breakz(parser.buffer, parser.buffer_pos) { - skip(parser) - if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { - return false - } - } - } - - // If it is a line break, eat it. - if is_break(parser.buffer, parser.buffer_pos) { - if parser.unread < 2 && !yaml_parser_update_buffer(parser, 2) { - return false - } - skip_line(parser) - - // In the block context, a new line may start a simple key. - if parser.flow_level == 0 { - parser.simple_key_allowed = true - } - } else { - break // We have found a token. - } - } - - return true -} - -// Scan a YAML-DIRECTIVE or TAG-DIRECTIVE token. -// -// Scope: -// %YAML 1.1 # a comment \n -// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -// %TAG !yaml! tag:yaml.org,2002: \n -// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -// -func yaml_parser_scan_directive(parser *yaml_parser_t, token *yaml_token_t) bool { - // Eat '%'. - start_mark := parser.mark - skip(parser) - - // Scan the directive name. - var name []byte - if !yaml_parser_scan_directive_name(parser, start_mark, &name) { - return false - } - - // Is it a YAML directive? - if bytes.Equal(name, []byte("YAML")) { - // Scan the VERSION directive value. - var major, minor int8 - if !yaml_parser_scan_version_directive_value(parser, start_mark, &major, &minor) { - return false - } - end_mark := parser.mark - - // Create a VERSION-DIRECTIVE token. - *token = yaml_token_t{ - typ: yaml_VERSION_DIRECTIVE_TOKEN, - start_mark: start_mark, - end_mark: end_mark, - major: major, - minor: minor, - } - - // Is it a TAG directive? - } else if bytes.Equal(name, []byte("TAG")) { - // Scan the TAG directive value. - var handle, prefix []byte - if !yaml_parser_scan_tag_directive_value(parser, start_mark, &handle, &prefix) { - return false - } - end_mark := parser.mark - - // Create a TAG-DIRECTIVE token. - *token = yaml_token_t{ - typ: yaml_TAG_DIRECTIVE_TOKEN, - start_mark: start_mark, - end_mark: end_mark, - value: handle, - prefix: prefix, - } - - // Unknown directive. - } else { - yaml_parser_set_scanner_error(parser, "while scanning a directive", - start_mark, "found unknown directive name") - return false - } - - // Eat the rest of the line including any comments. - if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { - return false - } - - for is_blank(parser.buffer, parser.buffer_pos) { - skip(parser) - if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { - return false - } - } - - if parser.buffer[parser.buffer_pos] == '#' { - for !is_breakz(parser.buffer, parser.buffer_pos) { - skip(parser) - if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { - return false - } - } - } - - // Check if we are at the end of the line. - if !is_breakz(parser.buffer, parser.buffer_pos) { - yaml_parser_set_scanner_error(parser, "while scanning a directive", - start_mark, "did not find expected comment or line break") - return false - } - - // Eat a line break. - if is_break(parser.buffer, parser.buffer_pos) { - if parser.unread < 2 && !yaml_parser_update_buffer(parser, 2) { - return false - } - skip_line(parser) - } - - return true -} - -// Scan the directive name. -// -// Scope: -// %YAML 1.1 # a comment \n -// ^^^^ -// %TAG !yaml! tag:yaml.org,2002: \n -// ^^^ -// -func yaml_parser_scan_directive_name(parser *yaml_parser_t, start_mark yaml_mark_t, name *[]byte) bool { - // Consume the directive name. - if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { - return false - } - - var s []byte - for is_alpha(parser.buffer, parser.buffer_pos) { - s = read(parser, s) - if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { - return false - } - } - - // Check if the name is empty. - if len(s) == 0 { - yaml_parser_set_scanner_error(parser, "while scanning a directive", - start_mark, "could not find expected directive name") - return false - } - - // Check for an blank character after the name. - if !is_blankz(parser.buffer, parser.buffer_pos) { - yaml_parser_set_scanner_error(parser, "while scanning a directive", - start_mark, "found unexpected non-alphabetical character") - return false - } - *name = s - return true -} - -// Scan the value of VERSION-DIRECTIVE. -// -// Scope: -// %YAML 1.1 # a comment \n -// ^^^^^^ -func yaml_parser_scan_version_directive_value(parser *yaml_parser_t, start_mark yaml_mark_t, major, minor *int8) bool { - // Eat whitespaces. - if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { - return false - } - for is_blank(parser.buffer, parser.buffer_pos) { - skip(parser) - if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { - return false - } - } - - // Consume the major version number. - if !yaml_parser_scan_version_directive_number(parser, start_mark, major) { - return false - } - - // Eat '.'. - if parser.buffer[parser.buffer_pos] != '.' { - return yaml_parser_set_scanner_error(parser, "while scanning a %YAML directive", - start_mark, "did not find expected digit or '.' character") - } - - skip(parser) - - // Consume the minor version number. - if !yaml_parser_scan_version_directive_number(parser, start_mark, minor) { - return false - } - return true -} - -const max_number_length = 2 - -// Scan the version number of VERSION-DIRECTIVE. -// -// Scope: -// %YAML 1.1 # a comment \n -// ^ -// %YAML 1.1 # a comment \n -// ^ -func yaml_parser_scan_version_directive_number(parser *yaml_parser_t, start_mark yaml_mark_t, number *int8) bool { - - // Repeat while the next character is digit. - if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { - return false - } - var value, length int8 - for is_digit(parser.buffer, parser.buffer_pos) { - // Check if the number is too long. - length++ - if length > max_number_length { - return yaml_parser_set_scanner_error(parser, "while scanning a %YAML directive", - start_mark, "found extremely long version number") - } - value = value*10 + int8(as_digit(parser.buffer, parser.buffer_pos)) - skip(parser) - if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { - return false - } - } - - // Check if the number was present. - if length == 0 { - return yaml_parser_set_scanner_error(parser, "while scanning a %YAML directive", - start_mark, "did not find expected version number") - } - *number = value - return true -} - -// Scan the value of a TAG-DIRECTIVE token. -// -// Scope: -// %TAG !yaml! tag:yaml.org,2002: \n -// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -// -func yaml_parser_scan_tag_directive_value(parser *yaml_parser_t, start_mark yaml_mark_t, handle, prefix *[]byte) bool { - var handle_value, prefix_value []byte - - // Eat whitespaces. - if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { - return false - } - - for is_blank(parser.buffer, parser.buffer_pos) { - skip(parser) - if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { - return false - } - } - - // Scan a handle. - if !yaml_parser_scan_tag_handle(parser, true, start_mark, &handle_value) { - return false - } - - // Expect a whitespace. - if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { - return false - } - if !is_blank(parser.buffer, parser.buffer_pos) { - yaml_parser_set_scanner_error(parser, "while scanning a %TAG directive", - start_mark, "did not find expected whitespace") - return false - } - - // Eat whitespaces. - for is_blank(parser.buffer, parser.buffer_pos) { - skip(parser) - if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { - return false - } - } - - // Scan a prefix. - if !yaml_parser_scan_tag_uri(parser, true, nil, start_mark, &prefix_value) { - return false - } - - // Expect a whitespace or line break. - if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { - return false - } - if !is_blankz(parser.buffer, parser.buffer_pos) { - yaml_parser_set_scanner_error(parser, "while scanning a %TAG directive", - start_mark, "did not find expected whitespace or line break") - return false - } - - *handle = handle_value - *prefix = prefix_value - return true -} - -func yaml_parser_scan_anchor(parser *yaml_parser_t, token *yaml_token_t, typ yaml_token_type_t) bool { - var s []byte - - // Eat the indicator character. - start_mark := parser.mark - skip(parser) - - // Consume the value. - if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { - return false - } - - for is_alpha(parser.buffer, parser.buffer_pos) { - s = read(parser, s) - if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { - return false - } - } - - end_mark := parser.mark - - /* - * Check if length of the anchor is greater than 0 and it is followed by - * a whitespace character or one of the indicators: - * - * '?', ':', ',', ']', '}', '%', '@', '`'. - */ - - if len(s) == 0 || - !(is_blankz(parser.buffer, parser.buffer_pos) || parser.buffer[parser.buffer_pos] == '?' || - parser.buffer[parser.buffer_pos] == ':' || parser.buffer[parser.buffer_pos] == ',' || - parser.buffer[parser.buffer_pos] == ']' || parser.buffer[parser.buffer_pos] == '}' || - parser.buffer[parser.buffer_pos] == '%' || parser.buffer[parser.buffer_pos] == '@' || - parser.buffer[parser.buffer_pos] == '`') { - context := "while scanning an alias" - if typ == yaml_ANCHOR_TOKEN { - context = "while scanning an anchor" - } - yaml_parser_set_scanner_error(parser, context, start_mark, - "did not find expected alphabetic or numeric character") - return false - } - - // Create a token. - *token = yaml_token_t{ - typ: typ, - start_mark: start_mark, - end_mark: end_mark, - value: s, - } - - return true -} - -/* - * Scan a TAG token. - */ - -func yaml_parser_scan_tag(parser *yaml_parser_t, token *yaml_token_t) bool { - var handle, suffix []byte - - start_mark := parser.mark - - // Check if the tag is in the canonical form. - if parser.unread < 2 && !yaml_parser_update_buffer(parser, 2) { - return false - } - - if parser.buffer[parser.buffer_pos+1] == '<' { - // Keep the handle as '' - - // Eat '!<' - skip(parser) - skip(parser) - - // Consume the tag value. - if !yaml_parser_scan_tag_uri(parser, false, nil, start_mark, &suffix) { - return false - } - - // Check for '>' and eat it. - if parser.buffer[parser.buffer_pos] != '>' { - yaml_parser_set_scanner_error(parser, "while scanning a tag", - start_mark, "did not find the expected '>'") - return false - } - - skip(parser) - } else { - // The tag has either the '!suffix' or the '!handle!suffix' form. - - // First, try to scan a handle. - if !yaml_parser_scan_tag_handle(parser, false, start_mark, &handle) { - return false - } - - // Check if it is, indeed, handle. - if handle[0] == '!' && len(handle) > 1 && handle[len(handle)-1] == '!' { - // Scan the suffix now. - if !yaml_parser_scan_tag_uri(parser, false, nil, start_mark, &suffix) { - return false - } - } else { - // It wasn't a handle after all. Scan the rest of the tag. - if !yaml_parser_scan_tag_uri(parser, false, handle, start_mark, &suffix) { - return false - } - - // Set the handle to '!'. - handle = []byte{'!'} - - // A special case: the '!' tag. Set the handle to '' and the - // suffix to '!'. - if len(suffix) == 0 { - handle, suffix = suffix, handle - } - } - } - - // Check the character which ends the tag. - if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { - return false - } - if !is_blankz(parser.buffer, parser.buffer_pos) { - yaml_parser_set_scanner_error(parser, "while scanning a tag", - start_mark, "did not find expected whitespace or line break") - return false - } - - end_mark := parser.mark - - // Create a token. - *token = yaml_token_t{ - typ: yaml_TAG_TOKEN, - start_mark: start_mark, - end_mark: end_mark, - value: handle, - suffix: suffix, - } - return true -} - -// Scan a tag handle. -func yaml_parser_scan_tag_handle(parser *yaml_parser_t, directive bool, start_mark yaml_mark_t, handle *[]byte) bool { - // Check the initial '!' character. - if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { - return false - } - if parser.buffer[parser.buffer_pos] != '!' { - yaml_parser_set_scanner_tag_error(parser, directive, - start_mark, "did not find expected '!'") - return false - } - - var s []byte - - // Copy the '!' character. - s = read(parser, s) - - // Copy all subsequent alphabetical and numerical characters. - if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { - return false - } - for is_alpha(parser.buffer, parser.buffer_pos) { - s = read(parser, s) - if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { - return false - } - } - - // Check if the trailing character is '!' and copy it. - if parser.buffer[parser.buffer_pos] == '!' { - s = read(parser, s) - } else { - // It's either the '!' tag or not really a tag handle. If it's a %TAG - // directive, it's an error. If it's a tag token, it must be a part of URI. - if directive && string(s) != "!" { - yaml_parser_set_scanner_tag_error(parser, directive, - start_mark, "did not find expected '!'") - return false - } - } - - *handle = s - return true -} - -// Scan a tag. -func yaml_parser_scan_tag_uri(parser *yaml_parser_t, directive bool, head []byte, start_mark yaml_mark_t, uri *[]byte) bool { - //size_t length = head ? strlen((char *)head) : 0 - var s []byte - hasTag := len(head) > 0 - - // Copy the head if needed. - // - // Note that we don't copy the leading '!' character. - if len(head) > 1 { - s = append(s, head[1:]...) - } - - // Scan the tag. - if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { - return false - } - - // The set of characters that may appear in URI is as follows: - // - // '0'-'9', 'A'-'Z', 'a'-'z', '_', '-', ';', '/', '?', ':', '@', '&', - // '=', '+', '$', ',', '.', '!', '~', '*', '\'', '(', ')', '[', ']', - // '%'. - // [Go] Convert this into more reasonable logic. - for is_alpha(parser.buffer, parser.buffer_pos) || parser.buffer[parser.buffer_pos] == ';' || - parser.buffer[parser.buffer_pos] == '/' || parser.buffer[parser.buffer_pos] == '?' || - parser.buffer[parser.buffer_pos] == ':' || parser.buffer[parser.buffer_pos] == '@' || - parser.buffer[parser.buffer_pos] == '&' || parser.buffer[parser.buffer_pos] == '=' || - parser.buffer[parser.buffer_pos] == '+' || parser.buffer[parser.buffer_pos] == '$' || - parser.buffer[parser.buffer_pos] == ',' || parser.buffer[parser.buffer_pos] == '.' || - parser.buffer[parser.buffer_pos] == '!' || parser.buffer[parser.buffer_pos] == '~' || - parser.buffer[parser.buffer_pos] == '*' || parser.buffer[parser.buffer_pos] == '\'' || - parser.buffer[parser.buffer_pos] == '(' || parser.buffer[parser.buffer_pos] == ')' || - parser.buffer[parser.buffer_pos] == '[' || parser.buffer[parser.buffer_pos] == ']' || - parser.buffer[parser.buffer_pos] == '%' { - // Check if it is a URI-escape sequence. - if parser.buffer[parser.buffer_pos] == '%' { - if !yaml_parser_scan_uri_escapes(parser, directive, start_mark, &s) { - return false - } - } else { - s = read(parser, s) - } - if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { - return false - } - hasTag = true - } - - if !hasTag { - yaml_parser_set_scanner_tag_error(parser, directive, - start_mark, "did not find expected tag URI") - return false - } - *uri = s - return true -} - -// Decode an URI-escape sequence corresponding to a single UTF-8 character. -func yaml_parser_scan_uri_escapes(parser *yaml_parser_t, directive bool, start_mark yaml_mark_t, s *[]byte) bool { - - // Decode the required number of characters. - w := 1024 - for w > 0 { - // Check for a URI-escaped octet. - if parser.unread < 3 && !yaml_parser_update_buffer(parser, 3) { - return false - } - - if !(parser.buffer[parser.buffer_pos] == '%' && - is_hex(parser.buffer, parser.buffer_pos+1) && - is_hex(parser.buffer, parser.buffer_pos+2)) { - return yaml_parser_set_scanner_tag_error(parser, directive, - start_mark, "did not find URI escaped octet") - } - - // Get the octet. - octet := byte((as_hex(parser.buffer, parser.buffer_pos+1) << 4) + as_hex(parser.buffer, parser.buffer_pos+2)) - - // If it is the leading octet, determine the length of the UTF-8 sequence. - if w == 1024 { - w = width(octet) - if w == 0 { - return yaml_parser_set_scanner_tag_error(parser, directive, - start_mark, "found an incorrect leading UTF-8 octet") - } - } else { - // Check if the trailing octet is correct. - if octet&0xC0 != 0x80 { - return yaml_parser_set_scanner_tag_error(parser, directive, - start_mark, "found an incorrect trailing UTF-8 octet") - } - } - - // Copy the octet and move the pointers. - *s = append(*s, octet) - skip(parser) - skip(parser) - skip(parser) - w-- - } - return true -} - -// Scan a block scalar. -func yaml_parser_scan_block_scalar(parser *yaml_parser_t, token *yaml_token_t, literal bool) bool { - // Eat the indicator '|' or '>'. - start_mark := parser.mark - skip(parser) - - // Scan the additional block scalar indicators. - if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { - return false - } - - // Check for a chomping indicator. - var chomping, increment int - if parser.buffer[parser.buffer_pos] == '+' || parser.buffer[parser.buffer_pos] == '-' { - // Set the chomping method and eat the indicator. - if parser.buffer[parser.buffer_pos] == '+' { - chomping = +1 - } else { - chomping = -1 - } - skip(parser) - - // Check for an indentation indicator. - if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { - return false - } - if is_digit(parser.buffer, parser.buffer_pos) { - // Check that the indentation is greater than 0. - if parser.buffer[parser.buffer_pos] == '0' { - yaml_parser_set_scanner_error(parser, "while scanning a block scalar", - start_mark, "found an indentation indicator equal to 0") - return false - } - - // Get the indentation level and eat the indicator. - increment = as_digit(parser.buffer, parser.buffer_pos) - skip(parser) - } - - } else if is_digit(parser.buffer, parser.buffer_pos) { - // Do the same as above, but in the opposite order. - - if parser.buffer[parser.buffer_pos] == '0' { - yaml_parser_set_scanner_error(parser, "while scanning a block scalar", - start_mark, "found an indentation indicator equal to 0") - return false - } - increment = as_digit(parser.buffer, parser.buffer_pos) - skip(parser) - - if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { - return false - } - if parser.buffer[parser.buffer_pos] == '+' || parser.buffer[parser.buffer_pos] == '-' { - if parser.buffer[parser.buffer_pos] == '+' { - chomping = +1 - } else { - chomping = -1 - } - skip(parser) - } - } - - // Eat whitespaces and comments to the end of the line. - if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { - return false - } - for is_blank(parser.buffer, parser.buffer_pos) { - skip(parser) - if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { - return false - } - } - if parser.buffer[parser.buffer_pos] == '#' { - for !is_breakz(parser.buffer, parser.buffer_pos) { - skip(parser) - if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { - return false - } - } - } - - // Check if we are at the end of the line. - if !is_breakz(parser.buffer, parser.buffer_pos) { - yaml_parser_set_scanner_error(parser, "while scanning a block scalar", - start_mark, "did not find expected comment or line break") - return false - } - - // Eat a line break. - if is_break(parser.buffer, parser.buffer_pos) { - if parser.unread < 2 && !yaml_parser_update_buffer(parser, 2) { - return false - } - skip_line(parser) - } - - end_mark := parser.mark - - // Set the indentation level if it was specified. - var indent int - if increment > 0 { - if parser.indent >= 0 { - indent = parser.indent + increment - } else { - indent = increment - } - } - - // Scan the leading line breaks and determine the indentation level if needed. - var s, leading_break, trailing_breaks []byte - if !yaml_parser_scan_block_scalar_breaks(parser, &indent, &trailing_breaks, start_mark, &end_mark) { - return false - } - - // Scan the block scalar content. - if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { - return false - } - var leading_blank, trailing_blank bool - for parser.mark.column == indent && !is_z(parser.buffer, parser.buffer_pos) { - // We are at the beginning of a non-empty line. - - // Is it a trailing whitespace? - trailing_blank = is_blank(parser.buffer, parser.buffer_pos) - - // Check if we need to fold the leading line break. - if !literal && !leading_blank && !trailing_blank && len(leading_break) > 0 && leading_break[0] == '\n' { - // Do we need to join the lines by space? - if len(trailing_breaks) == 0 { - s = append(s, ' ') - } - } else { - s = append(s, leading_break...) - } - leading_break = leading_break[:0] - - // Append the remaining line breaks. - s = append(s, trailing_breaks...) - trailing_breaks = trailing_breaks[:0] - - // Is it a leading whitespace? - leading_blank = is_blank(parser.buffer, parser.buffer_pos) - - // Consume the current line. - for !is_breakz(parser.buffer, parser.buffer_pos) { - s = read(parser, s) - if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { - return false - } - } - - // Consume the line break. - if parser.unread < 2 && !yaml_parser_update_buffer(parser, 2) { - return false - } - - leading_break = read_line(parser, leading_break) - - // Eat the following indentation spaces and line breaks. - if !yaml_parser_scan_block_scalar_breaks(parser, &indent, &trailing_breaks, start_mark, &end_mark) { - return false - } - } - - // Chomp the tail. - if chomping != -1 { - s = append(s, leading_break...) - } - if chomping == 1 { - s = append(s, trailing_breaks...) - } - - // Create a token. - *token = yaml_token_t{ - typ: yaml_SCALAR_TOKEN, - start_mark: start_mark, - end_mark: end_mark, - value: s, - style: yaml_LITERAL_SCALAR_STYLE, - } - if !literal { - token.style = yaml_FOLDED_SCALAR_STYLE - } - return true -} - -// Scan indentation spaces and line breaks for a block scalar. Determine the -// indentation level if needed. -func yaml_parser_scan_block_scalar_breaks(parser *yaml_parser_t, indent *int, breaks *[]byte, start_mark yaml_mark_t, end_mark *yaml_mark_t) bool { - *end_mark = parser.mark - - // Eat the indentation spaces and line breaks. - max_indent := 0 - for { - // Eat the indentation spaces. - if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { - return false - } - for (*indent == 0 || parser.mark.column < *indent) && is_space(parser.buffer, parser.buffer_pos) { - skip(parser) - if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { - return false - } - } - if parser.mark.column > max_indent { - max_indent = parser.mark.column - } - - // Check for a tab character messing the indentation. - if (*indent == 0 || parser.mark.column < *indent) && is_tab(parser.buffer, parser.buffer_pos) { - return yaml_parser_set_scanner_error(parser, "while scanning a block scalar", - start_mark, "found a tab character where an indentation space is expected") - } - - // Have we found a non-empty line? - if !is_break(parser.buffer, parser.buffer_pos) { - break - } - - // Consume the line break. - if parser.unread < 2 && !yaml_parser_update_buffer(parser, 2) { - return false - } - // [Go] Should really be returning breaks instead. - *breaks = read_line(parser, *breaks) - *end_mark = parser.mark - } - - // Determine the indentation level if needed. - if *indent == 0 { - *indent = max_indent - if *indent < parser.indent+1 { - *indent = parser.indent + 1 - } - if *indent < 1 { - *indent = 1 - } - } - return true -} - -// Scan a quoted scalar. -func yaml_parser_scan_flow_scalar(parser *yaml_parser_t, token *yaml_token_t, single bool) bool { - // Eat the left quote. - start_mark := parser.mark - skip(parser) - - // Consume the content of the quoted scalar. - var s, leading_break, trailing_breaks, whitespaces []byte - for { - // Check that there are no document indicators at the beginning of the line. - if parser.unread < 4 && !yaml_parser_update_buffer(parser, 4) { - return false - } - - if parser.mark.column == 0 && - ((parser.buffer[parser.buffer_pos+0] == '-' && - parser.buffer[parser.buffer_pos+1] == '-' && - parser.buffer[parser.buffer_pos+2] == '-') || - (parser.buffer[parser.buffer_pos+0] == '.' && - parser.buffer[parser.buffer_pos+1] == '.' && - parser.buffer[parser.buffer_pos+2] == '.')) && - is_blankz(parser.buffer, parser.buffer_pos+3) { - yaml_parser_set_scanner_error(parser, "while scanning a quoted scalar", - start_mark, "found unexpected document indicator") - return false - } - - // Check for EOF. - if is_z(parser.buffer, parser.buffer_pos) { - yaml_parser_set_scanner_error(parser, "while scanning a quoted scalar", - start_mark, "found unexpected end of stream") - return false - } - - // Consume non-blank characters. - leading_blanks := false - for !is_blankz(parser.buffer, parser.buffer_pos) { - if single && parser.buffer[parser.buffer_pos] == '\'' && parser.buffer[parser.buffer_pos+1] == '\'' { - // Is is an escaped single quote. - s = append(s, '\'') - skip(parser) - skip(parser) - - } else if single && parser.buffer[parser.buffer_pos] == '\'' { - // It is a right single quote. - break - } else if !single && parser.buffer[parser.buffer_pos] == '"' { - // It is a right double quote. - break - - } else if !single && parser.buffer[parser.buffer_pos] == '\\' && is_break(parser.buffer, parser.buffer_pos+1) { - // It is an escaped line break. - if parser.unread < 3 && !yaml_parser_update_buffer(parser, 3) { - return false - } - skip(parser) - skip_line(parser) - leading_blanks = true - break - - } else if !single && parser.buffer[parser.buffer_pos] == '\\' { - // It is an escape sequence. - code_length := 0 - - // Check the escape character. - switch parser.buffer[parser.buffer_pos+1] { - case '0': - s = append(s, 0) - case 'a': - s = append(s, '\x07') - case 'b': - s = append(s, '\x08') - case 't', '\t': - s = append(s, '\x09') - case 'n': - s = append(s, '\x0A') - case 'v': - s = append(s, '\x0B') - case 'f': - s = append(s, '\x0C') - case 'r': - s = append(s, '\x0D') - case 'e': - s = append(s, '\x1B') - case ' ': - s = append(s, '\x20') - case '"': - s = append(s, '"') - case '\'': - s = append(s, '\'') - case '\\': - s = append(s, '\\') - case 'N': // NEL (#x85) - s = append(s, '\xC2') - s = append(s, '\x85') - case '_': // #xA0 - s = append(s, '\xC2') - s = append(s, '\xA0') - case 'L': // LS (#x2028) - s = append(s, '\xE2') - s = append(s, '\x80') - s = append(s, '\xA8') - case 'P': // PS (#x2029) - s = append(s, '\xE2') - s = append(s, '\x80') - s = append(s, '\xA9') - case 'x': - code_length = 2 - case 'u': - code_length = 4 - case 'U': - code_length = 8 - default: - yaml_parser_set_scanner_error(parser, "while parsing a quoted scalar", - start_mark, "found unknown escape character") - return false - } - - skip(parser) - skip(parser) - - // Consume an arbitrary escape code. - if code_length > 0 { - var value int - - // Scan the character value. - if parser.unread < code_length && !yaml_parser_update_buffer(parser, code_length) { - return false - } - for k := 0; k < code_length; k++ { - if !is_hex(parser.buffer, parser.buffer_pos+k) { - yaml_parser_set_scanner_error(parser, "while parsing a quoted scalar", - start_mark, "did not find expected hexdecimal number") - return false - } - value = (value << 4) + as_hex(parser.buffer, parser.buffer_pos+k) - } - - // Check the value and write the character. - if (value >= 0xD800 && value <= 0xDFFF) || value > 0x10FFFF { - yaml_parser_set_scanner_error(parser, "while parsing a quoted scalar", - start_mark, "found invalid Unicode character escape code") - return false - } - if value <= 0x7F { - s = append(s, byte(value)) - } else if value <= 0x7FF { - s = append(s, byte(0xC0+(value>>6))) - s = append(s, byte(0x80+(value&0x3F))) - } else if value <= 0xFFFF { - s = append(s, byte(0xE0+(value>>12))) - s = append(s, byte(0x80+((value>>6)&0x3F))) - s = append(s, byte(0x80+(value&0x3F))) - } else { - s = append(s, byte(0xF0+(value>>18))) - s = append(s, byte(0x80+((value>>12)&0x3F))) - s = append(s, byte(0x80+((value>>6)&0x3F))) - s = append(s, byte(0x80+(value&0x3F))) - } - - // Advance the pointer. - for k := 0; k < code_length; k++ { - skip(parser) - } - } - } else { - // It is a non-escaped non-blank character. - s = read(parser, s) - } - if parser.unread < 2 && !yaml_parser_update_buffer(parser, 2) { - return false - } - } - - // Check if we are at the end of the scalar. - if single { - if parser.buffer[parser.buffer_pos] == '\'' { - break - } - } else { - if parser.buffer[parser.buffer_pos] == '"' { - break - } - } - - // Consume blank characters. - if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { - return false - } - - for is_blank(parser.buffer, parser.buffer_pos) || is_break(parser.buffer, parser.buffer_pos) { - if is_blank(parser.buffer, parser.buffer_pos) { - // Consume a space or a tab character. - if !leading_blanks { - whitespaces = read(parser, whitespaces) - } else { - skip(parser) - } - } else { - if parser.unread < 2 && !yaml_parser_update_buffer(parser, 2) { - return false - } - - // Check if it is a first line break. - if !leading_blanks { - whitespaces = whitespaces[:0] - leading_break = read_line(parser, leading_break) - leading_blanks = true - } else { - trailing_breaks = read_line(parser, trailing_breaks) - } - } - if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { - return false - } - } - - // Join the whitespaces or fold line breaks. - if leading_blanks { - // Do we need to fold line breaks? - if len(leading_break) > 0 && leading_break[0] == '\n' { - if len(trailing_breaks) == 0 { - s = append(s, ' ') - } else { - s = append(s, trailing_breaks...) - } - } else { - s = append(s, leading_break...) - s = append(s, trailing_breaks...) - } - trailing_breaks = trailing_breaks[:0] - leading_break = leading_break[:0] - } else { - s = append(s, whitespaces...) - whitespaces = whitespaces[:0] - } - } - - // Eat the right quote. - skip(parser) - end_mark := parser.mark - - // Create a token. - *token = yaml_token_t{ - typ: yaml_SCALAR_TOKEN, - start_mark: start_mark, - end_mark: end_mark, - value: s, - style: yaml_SINGLE_QUOTED_SCALAR_STYLE, - } - if !single { - token.style = yaml_DOUBLE_QUOTED_SCALAR_STYLE - } - return true -} - -// Scan a plain scalar. -func yaml_parser_scan_plain_scalar(parser *yaml_parser_t, token *yaml_token_t) bool { - - var s, leading_break, trailing_breaks, whitespaces []byte - var leading_blanks bool - var indent = parser.indent + 1 - - start_mark := parser.mark - end_mark := parser.mark - - // Consume the content of the plain scalar. - for { - // Check for a document indicator. - if parser.unread < 4 && !yaml_parser_update_buffer(parser, 4) { - return false - } - if parser.mark.column == 0 && - ((parser.buffer[parser.buffer_pos+0] == '-' && - parser.buffer[parser.buffer_pos+1] == '-' && - parser.buffer[parser.buffer_pos+2] == '-') || - (parser.buffer[parser.buffer_pos+0] == '.' && - parser.buffer[parser.buffer_pos+1] == '.' && - parser.buffer[parser.buffer_pos+2] == '.')) && - is_blankz(parser.buffer, parser.buffer_pos+3) { - break - } - - // Check for a comment. - if parser.buffer[parser.buffer_pos] == '#' { - break - } - - // Consume non-blank characters. - for !is_blankz(parser.buffer, parser.buffer_pos) { - - // Check for 'x:x' in the flow context. TODO: Fix the test "spec-08-13". - if parser.flow_level > 0 && - parser.buffer[parser.buffer_pos] == ':' && - !is_blankz(parser.buffer, parser.buffer_pos+1) { - yaml_parser_set_scanner_error(parser, "while scanning a plain scalar", - start_mark, "found unexpected ':'") - return false - } - - // Check for indicators that may end a plain scalar. - if (parser.buffer[parser.buffer_pos] == ':' && is_blankz(parser.buffer, parser.buffer_pos+1)) || - (parser.flow_level > 0 && - (parser.buffer[parser.buffer_pos] == ',' || parser.buffer[parser.buffer_pos] == ':' || - parser.buffer[parser.buffer_pos] == '?' || parser.buffer[parser.buffer_pos] == '[' || - parser.buffer[parser.buffer_pos] == ']' || parser.buffer[parser.buffer_pos] == '{' || - parser.buffer[parser.buffer_pos] == '}')) { - break - } - - // Check if we need to join whitespaces and breaks. - if leading_blanks || len(whitespaces) > 0 { - if leading_blanks { - // Do we need to fold line breaks? - if leading_break[0] == '\n' { - if len(trailing_breaks) == 0 { - s = append(s, ' ') - } else { - s = append(s, trailing_breaks...) - } - } else { - s = append(s, leading_break...) - s = append(s, trailing_breaks...) - } - trailing_breaks = trailing_breaks[:0] - leading_break = leading_break[:0] - leading_blanks = false - } else { - s = append(s, whitespaces...) - whitespaces = whitespaces[:0] - } - } - - // Copy the character. - s = read(parser, s) - - end_mark = parser.mark - if parser.unread < 2 && !yaml_parser_update_buffer(parser, 2) { - return false - } - } - - // Is it the end? - if !(is_blank(parser.buffer, parser.buffer_pos) || is_break(parser.buffer, parser.buffer_pos)) { - break - } - - // Consume blank characters. - if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { - return false - } - - for is_blank(parser.buffer, parser.buffer_pos) || is_break(parser.buffer, parser.buffer_pos) { - if is_blank(parser.buffer, parser.buffer_pos) { - - // Check for tab character that abuse indentation. - if leading_blanks && parser.mark.column < indent && is_tab(parser.buffer, parser.buffer_pos) { - yaml_parser_set_scanner_error(parser, "while scanning a plain scalar", - start_mark, "found a tab character that violate indentation") - return false - } - - // Consume a space or a tab character. - if !leading_blanks { - whitespaces = read(parser, whitespaces) - } else { - skip(parser) - } - } else { - if parser.unread < 2 && !yaml_parser_update_buffer(parser, 2) { - return false - } - - // Check if it is a first line break. - if !leading_blanks { - whitespaces = whitespaces[:0] - leading_break = read_line(parser, leading_break) - leading_blanks = true - } else { - trailing_breaks = read_line(parser, trailing_breaks) - } - } - if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { - return false - } - } - - // Check indentation level. - if parser.flow_level == 0 && parser.mark.column < indent { - break - } - } - - // Create a token. - *token = yaml_token_t{ - typ: yaml_SCALAR_TOKEN, - start_mark: start_mark, - end_mark: end_mark, - value: s, - style: yaml_PLAIN_SCALAR_STYLE, - } - - // Note that we change the 'simple_key_allowed' flag. - if leading_blanks { - parser.simple_key_allowed = true - } - return true -} diff --git a/_beats/dev-tools/vendor/gopkg.in/yaml.v2/sorter.go b/_beats/dev-tools/vendor/gopkg.in/yaml.v2/sorter.go deleted file mode 100644 index 5958822f9c..0000000000 --- a/_beats/dev-tools/vendor/gopkg.in/yaml.v2/sorter.go +++ /dev/null @@ -1,104 +0,0 @@ -package yaml - -import ( - "reflect" - "unicode" -) - -type keyList []reflect.Value - -func (l keyList) Len() int { return len(l) } -func (l keyList) Swap(i, j int) { l[i], l[j] = l[j], l[i] } -func (l keyList) Less(i, j int) bool { - a := l[i] - b := l[j] - ak := a.Kind() - bk := b.Kind() - for (ak == reflect.Interface || ak == reflect.Ptr) && !a.IsNil() { - a = a.Elem() - ak = a.Kind() - } - for (bk == reflect.Interface || bk == reflect.Ptr) && !b.IsNil() { - b = b.Elem() - bk = b.Kind() - } - af, aok := keyFloat(a) - bf, bok := keyFloat(b) - if aok && bok { - if af != bf { - return af < bf - } - if ak != bk { - return ak < bk - } - return numLess(a, b) - } - if ak != reflect.String || bk != reflect.String { - return ak < bk - } - ar, br := []rune(a.String()), []rune(b.String()) - for i := 0; i < len(ar) && i < len(br); i++ { - if ar[i] == br[i] { - continue - } - al := unicode.IsLetter(ar[i]) - bl := unicode.IsLetter(br[i]) - if al && bl { - return ar[i] < br[i] - } - if al || bl { - return bl - } - var ai, bi int - var an, bn int64 - for ai = i; ai < len(ar) && unicode.IsDigit(ar[ai]); ai++ { - an = an*10 + int64(ar[ai]-'0') - } - for bi = i; bi < len(br) && unicode.IsDigit(br[bi]); bi++ { - bn = bn*10 + int64(br[bi]-'0') - } - if an != bn { - return an < bn - } - if ai != bi { - return ai < bi - } - return ar[i] < br[i] - } - return len(ar) < len(br) -} - -// keyFloat returns a float value for v if it is a number/bool -// and whether it is a number/bool or not. -func keyFloat(v reflect.Value) (f float64, ok bool) { - switch v.Kind() { - case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: - return float64(v.Int()), true - case reflect.Float32, reflect.Float64: - return v.Float(), true - case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr: - return float64(v.Uint()), true - case reflect.Bool: - if v.Bool() { - return 1, true - } - return 0, true - } - return 0, false -} - -// numLess returns whether a < b. -// a and b must necessarily have the same kind. -func numLess(a, b reflect.Value) bool { - switch a.Kind() { - case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: - return a.Int() < b.Int() - case reflect.Float32, reflect.Float64: - return a.Float() < b.Float() - case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr: - return a.Uint() < b.Uint() - case reflect.Bool: - return !a.Bool() && b.Bool() - } - panic("not a number") -} diff --git a/_beats/dev-tools/vendor/gopkg.in/yaml.v2/writerc.go b/_beats/dev-tools/vendor/gopkg.in/yaml.v2/writerc.go deleted file mode 100644 index 190362f25d..0000000000 --- a/_beats/dev-tools/vendor/gopkg.in/yaml.v2/writerc.go +++ /dev/null @@ -1,89 +0,0 @@ -package yaml - -// Set the writer error and return false. -func yaml_emitter_set_writer_error(emitter *yaml_emitter_t, problem string) bool { - emitter.error = yaml_WRITER_ERROR - emitter.problem = problem - return false -} - -// Flush the output buffer. -func yaml_emitter_flush(emitter *yaml_emitter_t) bool { - if emitter.write_handler == nil { - panic("write handler not set") - } - - // Check if the buffer is empty. - if emitter.buffer_pos == 0 { - return true - } - - // If the output encoding is UTF-8, we don't need to recode the buffer. - if emitter.encoding == yaml_UTF8_ENCODING { - if err := emitter.write_handler(emitter, emitter.buffer[:emitter.buffer_pos]); err != nil { - return yaml_emitter_set_writer_error(emitter, "write error: "+err.Error()) - } - emitter.buffer_pos = 0 - return true - } - - // Recode the buffer into the raw buffer. - var low, high int - if emitter.encoding == yaml_UTF16LE_ENCODING { - low, high = 0, 1 - } else { - high, low = 1, 0 - } - - pos := 0 - for pos < emitter.buffer_pos { - // See the "reader.c" code for more details on UTF-8 encoding. Note - // that we assume that the buffer contains a valid UTF-8 sequence. - - // Read the next UTF-8 character. - octet := emitter.buffer[pos] - - var w int - var value rune - switch { - case octet&0x80 == 0x00: - w, value = 1, rune(octet&0x7F) - case octet&0xE0 == 0xC0: - w, value = 2, rune(octet&0x1F) - case octet&0xF0 == 0xE0: - w, value = 3, rune(octet&0x0F) - case octet&0xF8 == 0xF0: - w, value = 4, rune(octet&0x07) - } - for k := 1; k < w; k++ { - octet = emitter.buffer[pos+k] - value = (value << 6) + (rune(octet) & 0x3F) - } - pos += w - - // Write the character. - if value < 0x10000 { - var b [2]byte - b[high] = byte(value >> 8) - b[low] = byte(value & 0xFF) - emitter.raw_buffer = append(emitter.raw_buffer, b[0], b[1]) - } else { - // Write the character using a surrogate pair (check "reader.c"). - var b [4]byte - value -= 0x10000 - b[high] = byte(0xD8 + (value >> 18)) - b[low] = byte((value >> 10) & 0xFF) - b[high+2] = byte(0xDC + ((value >> 8) & 0xFF)) - b[low+2] = byte(value & 0xFF) - emitter.raw_buffer = append(emitter.raw_buffer, b[0], b[1], b[2], b[3]) - } - } - - // Write the raw buffer. - if err := emitter.write_handler(emitter, emitter.raw_buffer); err != nil { - return yaml_emitter_set_writer_error(emitter, "write error: "+err.Error()) - } - emitter.buffer_pos = 0 - emitter.raw_buffer = emitter.raw_buffer[:0] - return true -} diff --git a/_beats/dev-tools/vendor/gopkg.in/yaml.v2/yaml.go b/_beats/dev-tools/vendor/gopkg.in/yaml.v2/yaml.go deleted file mode 100644 index 5e3c2daee4..0000000000 --- a/_beats/dev-tools/vendor/gopkg.in/yaml.v2/yaml.go +++ /dev/null @@ -1,357 +0,0 @@ -// Package yaml implements YAML support for the Go language. -// -// Source code and other details for the project are available at GitHub: -// -// https://github.com/go-yaml/yaml -// -package yaml - -import ( - "errors" - "fmt" - "reflect" - "strings" - "sync" -) - -// MapSlice encodes and decodes as a YAML map. -// The order of keys is preserved when encoding and decoding. -type MapSlice []MapItem - -// MapItem is an item in a MapSlice. -type MapItem struct { - Key, Value interface{} -} - -// The Unmarshaler interface may be implemented by types to customize their -// behavior when being unmarshaled from a YAML document. The UnmarshalYAML -// method receives a function that may be called to unmarshal the original -// YAML value into a field or variable. It is safe to call the unmarshal -// function parameter more than once if necessary. -type Unmarshaler interface { - UnmarshalYAML(unmarshal func(interface{}) error) error -} - -// The Marshaler interface may be implemented by types to customize their -// behavior when being marshaled into a YAML document. The returned value -// is marshaled in place of the original value implementing Marshaler. -// -// If an error is returned by MarshalYAML, the marshaling procedure stops -// and returns with the provided error. -type Marshaler interface { - MarshalYAML() (interface{}, error) -} - -// Unmarshal decodes the first document found within the in byte slice -// and assigns decoded values into the out value. -// -// Maps and pointers (to a struct, string, int, etc) are accepted as out -// values. If an internal pointer within a struct is not initialized, -// the yaml package will initialize it if necessary for unmarshalling -// the provided data. The out parameter must not be nil. -// -// The type of the decoded values should be compatible with the respective -// values in out. If one or more values cannot be decoded due to a type -// mismatches, decoding continues partially until the end of the YAML -// content, and a *yaml.TypeError is returned with details for all -// missed values. -// -// Struct fields are only unmarshalled if they are exported (have an -// upper case first letter), and are unmarshalled using the field name -// lowercased as the default key. Custom keys may be defined via the -// "yaml" name in the field tag: the content preceding the first comma -// is used as the key, and the following comma-separated options are -// used to tweak the marshalling process (see Marshal). -// Conflicting names result in a runtime error. -// -// For example: -// -// type T struct { -// F int `yaml:"a,omitempty"` -// B int -// } -// var t T -// yaml.Unmarshal([]byte("a: 1\nb: 2"), &t) -// -// See the documentation of Marshal for the format of tags and a list of -// supported tag options. -// -func Unmarshal(in []byte, out interface{}) (err error) { - return unmarshal(in, out, false) -} - -// UnmarshalStrict is like Unmarshal except that any fields that are found -// in the data that do not have corresponding struct members will result in -// an error. -func UnmarshalStrict(in []byte, out interface{}) (err error) { - return unmarshal(in, out, true) -} - -func unmarshal(in []byte, out interface{}, strict bool) (err error) { - defer handleErr(&err) - d := newDecoder(strict) - p := newParser(in) - defer p.destroy() - node := p.parse() - if node != nil { - v := reflect.ValueOf(out) - if v.Kind() == reflect.Ptr && !v.IsNil() { - v = v.Elem() - } - d.unmarshal(node, v) - } - if len(d.terrors) > 0 { - return &TypeError{d.terrors} - } - return nil -} - -// Marshal serializes the value provided into a YAML document. The structure -// of the generated document will reflect the structure of the value itself. -// Maps and pointers (to struct, string, int, etc) are accepted as the in value. -// -// Struct fields are only unmarshalled if they are exported (have an upper case -// first letter), and are unmarshalled using the field name lowercased as the -// default key. Custom keys may be defined via the "yaml" name in the field -// tag: the content preceding the first comma is used as the key, and the -// following comma-separated options are used to tweak the marshalling process. -// Conflicting names result in a runtime error. -// -// The field tag format accepted is: -// -// `(...) yaml:"[][,[,]]" (...)` -// -// The following flags are currently supported: -// -// omitempty Only include the field if it's not set to the zero -// value for the type or to empty slices or maps. -// Does not apply to zero valued structs. -// -// flow Marshal using a flow style (useful for structs, -// sequences and maps). -// -// inline Inline the field, which must be a struct or a map, -// causing all of its fields or keys to be processed as if -// they were part of the outer struct. For maps, keys must -// not conflict with the yaml keys of other struct fields. -// -// In addition, if the key is "-", the field is ignored. -// -// For example: -// -// type T struct { -// F int `yaml:"a,omitempty"` -// B int -// } -// yaml.Marshal(&T{B: 2}) // Returns "b: 2\n" -// yaml.Marshal(&T{F: 1}} // Returns "a: 1\nb: 0\n" -// -func Marshal(in interface{}) (out []byte, err error) { - defer handleErr(&err) - e := newEncoder() - defer e.destroy() - e.marshal("", reflect.ValueOf(in)) - e.finish() - out = e.out - return -} - -func handleErr(err *error) { - if v := recover(); v != nil { - if e, ok := v.(yamlError); ok { - *err = e.err - } else { - panic(v) - } - } -} - -type yamlError struct { - err error -} - -func fail(err error) { - panic(yamlError{err}) -} - -func failf(format string, args ...interface{}) { - panic(yamlError{fmt.Errorf("yaml: "+format, args...)}) -} - -// A TypeError is returned by Unmarshal when one or more fields in -// the YAML document cannot be properly decoded into the requested -// types. When this error is returned, the value is still -// unmarshaled partially. -type TypeError struct { - Errors []string -} - -func (e *TypeError) Error() string { - return fmt.Sprintf("yaml: unmarshal errors:\n %s", strings.Join(e.Errors, "\n ")) -} - -// -------------------------------------------------------------------------- -// Maintain a mapping of keys to structure field indexes - -// The code in this section was copied from mgo/bson. - -// structInfo holds details for the serialization of fields of -// a given struct. -type structInfo struct { - FieldsMap map[string]fieldInfo - FieldsList []fieldInfo - - // InlineMap is the number of the field in the struct that - // contains an ,inline map, or -1 if there's none. - InlineMap int -} - -type fieldInfo struct { - Key string - Num int - OmitEmpty bool - Flow bool - - // Inline holds the field index if the field is part of an inlined struct. - Inline []int -} - -var structMap = make(map[reflect.Type]*structInfo) -var fieldMapMutex sync.RWMutex - -func getStructInfo(st reflect.Type) (*structInfo, error) { - fieldMapMutex.RLock() - sinfo, found := structMap[st] - fieldMapMutex.RUnlock() - if found { - return sinfo, nil - } - - n := st.NumField() - fieldsMap := make(map[string]fieldInfo) - fieldsList := make([]fieldInfo, 0, n) - inlineMap := -1 - for i := 0; i != n; i++ { - field := st.Field(i) - if field.PkgPath != "" && !field.Anonymous { - continue // Private field - } - - info := fieldInfo{Num: i} - - tag := field.Tag.Get("yaml") - if tag == "" && strings.Index(string(field.Tag), ":") < 0 { - tag = string(field.Tag) - } - if tag == "-" { - continue - } - - inline := false - fields := strings.Split(tag, ",") - if len(fields) > 1 { - for _, flag := range fields[1:] { - switch flag { - case "omitempty": - info.OmitEmpty = true - case "flow": - info.Flow = true - case "inline": - inline = true - default: - return nil, errors.New(fmt.Sprintf("Unsupported flag %q in tag %q of type %s", flag, tag, st)) - } - } - tag = fields[0] - } - - if inline { - switch field.Type.Kind() { - case reflect.Map: - if inlineMap >= 0 { - return nil, errors.New("Multiple ,inline maps in struct " + st.String()) - } - if field.Type.Key() != reflect.TypeOf("") { - return nil, errors.New("Option ,inline needs a map with string keys in struct " + st.String()) - } - inlineMap = info.Num - case reflect.Struct: - sinfo, err := getStructInfo(field.Type) - if err != nil { - return nil, err - } - for _, finfo := range sinfo.FieldsList { - if _, found := fieldsMap[finfo.Key]; found { - msg := "Duplicated key '" + finfo.Key + "' in struct " + st.String() - return nil, errors.New(msg) - } - if finfo.Inline == nil { - finfo.Inline = []int{i, finfo.Num} - } else { - finfo.Inline = append([]int{i}, finfo.Inline...) - } - fieldsMap[finfo.Key] = finfo - fieldsList = append(fieldsList, finfo) - } - default: - //return nil, errors.New("Option ,inline needs a struct value or map field") - return nil, errors.New("Option ,inline needs a struct value field") - } - continue - } - - if tag != "" { - info.Key = tag - } else { - info.Key = strings.ToLower(field.Name) - } - - if _, found = fieldsMap[info.Key]; found { - msg := "Duplicated key '" + info.Key + "' in struct " + st.String() - return nil, errors.New(msg) - } - - fieldsList = append(fieldsList, info) - fieldsMap[info.Key] = info - } - - sinfo = &structInfo{fieldsMap, fieldsList, inlineMap} - - fieldMapMutex.Lock() - structMap[st] = sinfo - fieldMapMutex.Unlock() - return sinfo, nil -} - -func isZero(v reflect.Value) bool { - switch v.Kind() { - case reflect.String: - return len(v.String()) == 0 - case reflect.Interface, reflect.Ptr: - return v.IsNil() - case reflect.Slice: - return v.Len() == 0 - case reflect.Map: - return v.Len() == 0 - case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: - return v.Int() == 0 - case reflect.Float32, reflect.Float64: - return v.Float() == 0 - case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr: - return v.Uint() == 0 - case reflect.Bool: - return !v.Bool() - case reflect.Struct: - vt := v.Type() - for i := v.NumField() - 1; i >= 0; i-- { - if vt.Field(i).PkgPath != "" { - continue // Private field - } - if !isZero(v.Field(i)) { - return false - } - } - return true - } - return false -} diff --git a/_beats/dev-tools/vendor/gopkg.in/yaml.v2/yamlh.go b/_beats/dev-tools/vendor/gopkg.in/yaml.v2/yamlh.go deleted file mode 100644 index 3caeca0491..0000000000 --- a/_beats/dev-tools/vendor/gopkg.in/yaml.v2/yamlh.go +++ /dev/null @@ -1,716 +0,0 @@ -package yaml - -import ( - "io" -) - -// The version directive data. -type yaml_version_directive_t struct { - major int8 // The major version number. - minor int8 // The minor version number. -} - -// The tag directive data. -type yaml_tag_directive_t struct { - handle []byte // The tag handle. - prefix []byte // The tag prefix. -} - -type yaml_encoding_t int - -// The stream encoding. -const ( - // Let the parser choose the encoding. - yaml_ANY_ENCODING yaml_encoding_t = iota - - yaml_UTF8_ENCODING // The default UTF-8 encoding. - yaml_UTF16LE_ENCODING // The UTF-16-LE encoding with BOM. - yaml_UTF16BE_ENCODING // The UTF-16-BE encoding with BOM. -) - -type yaml_break_t int - -// Line break types. -const ( - // Let the parser choose the break type. - yaml_ANY_BREAK yaml_break_t = iota - - yaml_CR_BREAK // Use CR for line breaks (Mac style). - yaml_LN_BREAK // Use LN for line breaks (Unix style). - yaml_CRLN_BREAK // Use CR LN for line breaks (DOS style). -) - -type yaml_error_type_t int - -// Many bad things could happen with the parser and emitter. -const ( - // No error is produced. - yaml_NO_ERROR yaml_error_type_t = iota - - yaml_MEMORY_ERROR // Cannot allocate or reallocate a block of memory. - yaml_READER_ERROR // Cannot read or decode the input stream. - yaml_SCANNER_ERROR // Cannot scan the input stream. - yaml_PARSER_ERROR // Cannot parse the input stream. - yaml_COMPOSER_ERROR // Cannot compose a YAML document. - yaml_WRITER_ERROR // Cannot write to the output stream. - yaml_EMITTER_ERROR // Cannot emit a YAML stream. -) - -// The pointer position. -type yaml_mark_t struct { - index int // The position index. - line int // The position line. - column int // The position column. -} - -// Node Styles - -type yaml_style_t int8 - -type yaml_scalar_style_t yaml_style_t - -// Scalar styles. -const ( - // Let the emitter choose the style. - yaml_ANY_SCALAR_STYLE yaml_scalar_style_t = iota - - yaml_PLAIN_SCALAR_STYLE // The plain scalar style. - yaml_SINGLE_QUOTED_SCALAR_STYLE // The single-quoted scalar style. - yaml_DOUBLE_QUOTED_SCALAR_STYLE // The double-quoted scalar style. - yaml_LITERAL_SCALAR_STYLE // The literal scalar style. - yaml_FOLDED_SCALAR_STYLE // The folded scalar style. -) - -type yaml_sequence_style_t yaml_style_t - -// Sequence styles. -const ( - // Let the emitter choose the style. - yaml_ANY_SEQUENCE_STYLE yaml_sequence_style_t = iota - - yaml_BLOCK_SEQUENCE_STYLE // The block sequence style. - yaml_FLOW_SEQUENCE_STYLE // The flow sequence style. -) - -type yaml_mapping_style_t yaml_style_t - -// Mapping styles. -const ( - // Let the emitter choose the style. - yaml_ANY_MAPPING_STYLE yaml_mapping_style_t = iota - - yaml_BLOCK_MAPPING_STYLE // The block mapping style. - yaml_FLOW_MAPPING_STYLE // The flow mapping style. -) - -// Tokens - -type yaml_token_type_t int - -// Token types. -const ( - // An empty token. - yaml_NO_TOKEN yaml_token_type_t = iota - - yaml_STREAM_START_TOKEN // A STREAM-START token. - yaml_STREAM_END_TOKEN // A STREAM-END token. - - yaml_VERSION_DIRECTIVE_TOKEN // A VERSION-DIRECTIVE token. - yaml_TAG_DIRECTIVE_TOKEN // A TAG-DIRECTIVE token. - yaml_DOCUMENT_START_TOKEN // A DOCUMENT-START token. - yaml_DOCUMENT_END_TOKEN // A DOCUMENT-END token. - - yaml_BLOCK_SEQUENCE_START_TOKEN // A BLOCK-SEQUENCE-START token. - yaml_BLOCK_MAPPING_START_TOKEN // A BLOCK-SEQUENCE-END token. - yaml_BLOCK_END_TOKEN // A BLOCK-END token. - - yaml_FLOW_SEQUENCE_START_TOKEN // A FLOW-SEQUENCE-START token. - yaml_FLOW_SEQUENCE_END_TOKEN // A FLOW-SEQUENCE-END token. - yaml_FLOW_MAPPING_START_TOKEN // A FLOW-MAPPING-START token. - yaml_FLOW_MAPPING_END_TOKEN // A FLOW-MAPPING-END token. - - yaml_BLOCK_ENTRY_TOKEN // A BLOCK-ENTRY token. - yaml_FLOW_ENTRY_TOKEN // A FLOW-ENTRY token. - yaml_KEY_TOKEN // A KEY token. - yaml_VALUE_TOKEN // A VALUE token. - - yaml_ALIAS_TOKEN // An ALIAS token. - yaml_ANCHOR_TOKEN // An ANCHOR token. - yaml_TAG_TOKEN // A TAG token. - yaml_SCALAR_TOKEN // A SCALAR token. -) - -func (tt yaml_token_type_t) String() string { - switch tt { - case yaml_NO_TOKEN: - return "yaml_NO_TOKEN" - case yaml_STREAM_START_TOKEN: - return "yaml_STREAM_START_TOKEN" - case yaml_STREAM_END_TOKEN: - return "yaml_STREAM_END_TOKEN" - case yaml_VERSION_DIRECTIVE_TOKEN: - return "yaml_VERSION_DIRECTIVE_TOKEN" - case yaml_TAG_DIRECTIVE_TOKEN: - return "yaml_TAG_DIRECTIVE_TOKEN" - case yaml_DOCUMENT_START_TOKEN: - return "yaml_DOCUMENT_START_TOKEN" - case yaml_DOCUMENT_END_TOKEN: - return "yaml_DOCUMENT_END_TOKEN" - case yaml_BLOCK_SEQUENCE_START_TOKEN: - return "yaml_BLOCK_SEQUENCE_START_TOKEN" - case yaml_BLOCK_MAPPING_START_TOKEN: - return "yaml_BLOCK_MAPPING_START_TOKEN" - case yaml_BLOCK_END_TOKEN: - return "yaml_BLOCK_END_TOKEN" - case yaml_FLOW_SEQUENCE_START_TOKEN: - return "yaml_FLOW_SEQUENCE_START_TOKEN" - case yaml_FLOW_SEQUENCE_END_TOKEN: - return "yaml_FLOW_SEQUENCE_END_TOKEN" - case yaml_FLOW_MAPPING_START_TOKEN: - return "yaml_FLOW_MAPPING_START_TOKEN" - case yaml_FLOW_MAPPING_END_TOKEN: - return "yaml_FLOW_MAPPING_END_TOKEN" - case yaml_BLOCK_ENTRY_TOKEN: - return "yaml_BLOCK_ENTRY_TOKEN" - case yaml_FLOW_ENTRY_TOKEN: - return "yaml_FLOW_ENTRY_TOKEN" - case yaml_KEY_TOKEN: - return "yaml_KEY_TOKEN" - case yaml_VALUE_TOKEN: - return "yaml_VALUE_TOKEN" - case yaml_ALIAS_TOKEN: - return "yaml_ALIAS_TOKEN" - case yaml_ANCHOR_TOKEN: - return "yaml_ANCHOR_TOKEN" - case yaml_TAG_TOKEN: - return "yaml_TAG_TOKEN" - case yaml_SCALAR_TOKEN: - return "yaml_SCALAR_TOKEN" - } - return "" -} - -// The token structure. -type yaml_token_t struct { - // The token type. - typ yaml_token_type_t - - // The start/end of the token. - start_mark, end_mark yaml_mark_t - - // The stream encoding (for yaml_STREAM_START_TOKEN). - encoding yaml_encoding_t - - // The alias/anchor/scalar value or tag/tag directive handle - // (for yaml_ALIAS_TOKEN, yaml_ANCHOR_TOKEN, yaml_SCALAR_TOKEN, yaml_TAG_TOKEN, yaml_TAG_DIRECTIVE_TOKEN). - value []byte - - // The tag suffix (for yaml_TAG_TOKEN). - suffix []byte - - // The tag directive prefix (for yaml_TAG_DIRECTIVE_TOKEN). - prefix []byte - - // The scalar style (for yaml_SCALAR_TOKEN). - style yaml_scalar_style_t - - // The version directive major/minor (for yaml_VERSION_DIRECTIVE_TOKEN). - major, minor int8 -} - -// Events - -type yaml_event_type_t int8 - -// Event types. -const ( - // An empty event. - yaml_NO_EVENT yaml_event_type_t = iota - - yaml_STREAM_START_EVENT // A STREAM-START event. - yaml_STREAM_END_EVENT // A STREAM-END event. - yaml_DOCUMENT_START_EVENT // A DOCUMENT-START event. - yaml_DOCUMENT_END_EVENT // A DOCUMENT-END event. - yaml_ALIAS_EVENT // An ALIAS event. - yaml_SCALAR_EVENT // A SCALAR event. - yaml_SEQUENCE_START_EVENT // A SEQUENCE-START event. - yaml_SEQUENCE_END_EVENT // A SEQUENCE-END event. - yaml_MAPPING_START_EVENT // A MAPPING-START event. - yaml_MAPPING_END_EVENT // A MAPPING-END event. -) - -// The event structure. -type yaml_event_t struct { - - // The event type. - typ yaml_event_type_t - - // The start and end of the event. - start_mark, end_mark yaml_mark_t - - // The document encoding (for yaml_STREAM_START_EVENT). - encoding yaml_encoding_t - - // The version directive (for yaml_DOCUMENT_START_EVENT). - version_directive *yaml_version_directive_t - - // The list of tag directives (for yaml_DOCUMENT_START_EVENT). - tag_directives []yaml_tag_directive_t - - // The anchor (for yaml_SCALAR_EVENT, yaml_SEQUENCE_START_EVENT, yaml_MAPPING_START_EVENT, yaml_ALIAS_EVENT). - anchor []byte - - // The tag (for yaml_SCALAR_EVENT, yaml_SEQUENCE_START_EVENT, yaml_MAPPING_START_EVENT). - tag []byte - - // The scalar value (for yaml_SCALAR_EVENT). - value []byte - - // Is the document start/end indicator implicit, or the tag optional? - // (for yaml_DOCUMENT_START_EVENT, yaml_DOCUMENT_END_EVENT, yaml_SEQUENCE_START_EVENT, yaml_MAPPING_START_EVENT, yaml_SCALAR_EVENT). - implicit bool - - // Is the tag optional for any non-plain style? (for yaml_SCALAR_EVENT). - quoted_implicit bool - - // The style (for yaml_SCALAR_EVENT, yaml_SEQUENCE_START_EVENT, yaml_MAPPING_START_EVENT). - style yaml_style_t -} - -func (e *yaml_event_t) scalar_style() yaml_scalar_style_t { return yaml_scalar_style_t(e.style) } -func (e *yaml_event_t) sequence_style() yaml_sequence_style_t { return yaml_sequence_style_t(e.style) } -func (e *yaml_event_t) mapping_style() yaml_mapping_style_t { return yaml_mapping_style_t(e.style) } - -// Nodes - -const ( - yaml_NULL_TAG = "tag:yaml.org,2002:null" // The tag !!null with the only possible value: null. - yaml_BOOL_TAG = "tag:yaml.org,2002:bool" // The tag !!bool with the values: true and false. - yaml_STR_TAG = "tag:yaml.org,2002:str" // The tag !!str for string values. - yaml_INT_TAG = "tag:yaml.org,2002:int" // The tag !!int for integer values. - yaml_FLOAT_TAG = "tag:yaml.org,2002:float" // The tag !!float for float values. - yaml_TIMESTAMP_TAG = "tag:yaml.org,2002:timestamp" // The tag !!timestamp for date and time values. - - yaml_SEQ_TAG = "tag:yaml.org,2002:seq" // The tag !!seq is used to denote sequences. - yaml_MAP_TAG = "tag:yaml.org,2002:map" // The tag !!map is used to denote mapping. - - // Not in original libyaml. - yaml_BINARY_TAG = "tag:yaml.org,2002:binary" - yaml_MERGE_TAG = "tag:yaml.org,2002:merge" - - yaml_DEFAULT_SCALAR_TAG = yaml_STR_TAG // The default scalar tag is !!str. - yaml_DEFAULT_SEQUENCE_TAG = yaml_SEQ_TAG // The default sequence tag is !!seq. - yaml_DEFAULT_MAPPING_TAG = yaml_MAP_TAG // The default mapping tag is !!map. -) - -type yaml_node_type_t int - -// Node types. -const ( - // An empty node. - yaml_NO_NODE yaml_node_type_t = iota - - yaml_SCALAR_NODE // A scalar node. - yaml_SEQUENCE_NODE // A sequence node. - yaml_MAPPING_NODE // A mapping node. -) - -// An element of a sequence node. -type yaml_node_item_t int - -// An element of a mapping node. -type yaml_node_pair_t struct { - key int // The key of the element. - value int // The value of the element. -} - -// The node structure. -type yaml_node_t struct { - typ yaml_node_type_t // The node type. - tag []byte // The node tag. - - // The node data. - - // The scalar parameters (for yaml_SCALAR_NODE). - scalar struct { - value []byte // The scalar value. - length int // The length of the scalar value. - style yaml_scalar_style_t // The scalar style. - } - - // The sequence parameters (for YAML_SEQUENCE_NODE). - sequence struct { - items_data []yaml_node_item_t // The stack of sequence items. - style yaml_sequence_style_t // The sequence style. - } - - // The mapping parameters (for yaml_MAPPING_NODE). - mapping struct { - pairs_data []yaml_node_pair_t // The stack of mapping pairs (key, value). - pairs_start *yaml_node_pair_t // The beginning of the stack. - pairs_end *yaml_node_pair_t // The end of the stack. - pairs_top *yaml_node_pair_t // The top of the stack. - style yaml_mapping_style_t // The mapping style. - } - - start_mark yaml_mark_t // The beginning of the node. - end_mark yaml_mark_t // The end of the node. - -} - -// The document structure. -type yaml_document_t struct { - - // The document nodes. - nodes []yaml_node_t - - // The version directive. - version_directive *yaml_version_directive_t - - // The list of tag directives. - tag_directives_data []yaml_tag_directive_t - tag_directives_start int // The beginning of the tag directives list. - tag_directives_end int // The end of the tag directives list. - - start_implicit int // Is the document start indicator implicit? - end_implicit int // Is the document end indicator implicit? - - // The start/end of the document. - start_mark, end_mark yaml_mark_t -} - -// The prototype of a read handler. -// -// The read handler is called when the parser needs to read more bytes from the -// source. The handler should write not more than size bytes to the buffer. -// The number of written bytes should be set to the size_read variable. -// -// [in,out] data A pointer to an application data specified by -// yaml_parser_set_input(). -// [out] buffer The buffer to write the data from the source. -// [in] size The size of the buffer. -// [out] size_read The actual number of bytes read from the source. -// -// On success, the handler should return 1. If the handler failed, -// the returned value should be 0. On EOF, the handler should set the -// size_read to 0 and return 1. -type yaml_read_handler_t func(parser *yaml_parser_t, buffer []byte) (n int, err error) - -// This structure holds information about a potential simple key. -type yaml_simple_key_t struct { - possible bool // Is a simple key possible? - required bool // Is a simple key required? - token_number int // The number of the token. - mark yaml_mark_t // The position mark. -} - -// The states of the parser. -type yaml_parser_state_t int - -const ( - yaml_PARSE_STREAM_START_STATE yaml_parser_state_t = iota - - yaml_PARSE_IMPLICIT_DOCUMENT_START_STATE // Expect the beginning of an implicit document. - yaml_PARSE_DOCUMENT_START_STATE // Expect DOCUMENT-START. - yaml_PARSE_DOCUMENT_CONTENT_STATE // Expect the content of a document. - yaml_PARSE_DOCUMENT_END_STATE // Expect DOCUMENT-END. - yaml_PARSE_BLOCK_NODE_STATE // Expect a block node. - yaml_PARSE_BLOCK_NODE_OR_INDENTLESS_SEQUENCE_STATE // Expect a block node or indentless sequence. - yaml_PARSE_FLOW_NODE_STATE // Expect a flow node. - yaml_PARSE_BLOCK_SEQUENCE_FIRST_ENTRY_STATE // Expect the first entry of a block sequence. - yaml_PARSE_BLOCK_SEQUENCE_ENTRY_STATE // Expect an entry of a block sequence. - yaml_PARSE_INDENTLESS_SEQUENCE_ENTRY_STATE // Expect an entry of an indentless sequence. - yaml_PARSE_BLOCK_MAPPING_FIRST_KEY_STATE // Expect the first key of a block mapping. - yaml_PARSE_BLOCK_MAPPING_KEY_STATE // Expect a block mapping key. - yaml_PARSE_BLOCK_MAPPING_VALUE_STATE // Expect a block mapping value. - yaml_PARSE_FLOW_SEQUENCE_FIRST_ENTRY_STATE // Expect the first entry of a flow sequence. - yaml_PARSE_FLOW_SEQUENCE_ENTRY_STATE // Expect an entry of a flow sequence. - yaml_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_KEY_STATE // Expect a key of an ordered mapping. - yaml_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_VALUE_STATE // Expect a value of an ordered mapping. - yaml_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_END_STATE // Expect the and of an ordered mapping entry. - yaml_PARSE_FLOW_MAPPING_FIRST_KEY_STATE // Expect the first key of a flow mapping. - yaml_PARSE_FLOW_MAPPING_KEY_STATE // Expect a key of a flow mapping. - yaml_PARSE_FLOW_MAPPING_VALUE_STATE // Expect a value of a flow mapping. - yaml_PARSE_FLOW_MAPPING_EMPTY_VALUE_STATE // Expect an empty value of a flow mapping. - yaml_PARSE_END_STATE // Expect nothing. -) - -func (ps yaml_parser_state_t) String() string { - switch ps { - case yaml_PARSE_STREAM_START_STATE: - return "yaml_PARSE_STREAM_START_STATE" - case yaml_PARSE_IMPLICIT_DOCUMENT_START_STATE: - return "yaml_PARSE_IMPLICIT_DOCUMENT_START_STATE" - case yaml_PARSE_DOCUMENT_START_STATE: - return "yaml_PARSE_DOCUMENT_START_STATE" - case yaml_PARSE_DOCUMENT_CONTENT_STATE: - return "yaml_PARSE_DOCUMENT_CONTENT_STATE" - case yaml_PARSE_DOCUMENT_END_STATE: - return "yaml_PARSE_DOCUMENT_END_STATE" - case yaml_PARSE_BLOCK_NODE_STATE: - return "yaml_PARSE_BLOCK_NODE_STATE" - case yaml_PARSE_BLOCK_NODE_OR_INDENTLESS_SEQUENCE_STATE: - return "yaml_PARSE_BLOCK_NODE_OR_INDENTLESS_SEQUENCE_STATE" - case yaml_PARSE_FLOW_NODE_STATE: - return "yaml_PARSE_FLOW_NODE_STATE" - case yaml_PARSE_BLOCK_SEQUENCE_FIRST_ENTRY_STATE: - return "yaml_PARSE_BLOCK_SEQUENCE_FIRST_ENTRY_STATE" - case yaml_PARSE_BLOCK_SEQUENCE_ENTRY_STATE: - return "yaml_PARSE_BLOCK_SEQUENCE_ENTRY_STATE" - case yaml_PARSE_INDENTLESS_SEQUENCE_ENTRY_STATE: - return "yaml_PARSE_INDENTLESS_SEQUENCE_ENTRY_STATE" - case yaml_PARSE_BLOCK_MAPPING_FIRST_KEY_STATE: - return "yaml_PARSE_BLOCK_MAPPING_FIRST_KEY_STATE" - case yaml_PARSE_BLOCK_MAPPING_KEY_STATE: - return "yaml_PARSE_BLOCK_MAPPING_KEY_STATE" - case yaml_PARSE_BLOCK_MAPPING_VALUE_STATE: - return "yaml_PARSE_BLOCK_MAPPING_VALUE_STATE" - case yaml_PARSE_FLOW_SEQUENCE_FIRST_ENTRY_STATE: - return "yaml_PARSE_FLOW_SEQUENCE_FIRST_ENTRY_STATE" - case yaml_PARSE_FLOW_SEQUENCE_ENTRY_STATE: - return "yaml_PARSE_FLOW_SEQUENCE_ENTRY_STATE" - case yaml_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_KEY_STATE: - return "yaml_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_KEY_STATE" - case yaml_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_VALUE_STATE: - return "yaml_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_VALUE_STATE" - case yaml_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_END_STATE: - return "yaml_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_END_STATE" - case yaml_PARSE_FLOW_MAPPING_FIRST_KEY_STATE: - return "yaml_PARSE_FLOW_MAPPING_FIRST_KEY_STATE" - case yaml_PARSE_FLOW_MAPPING_KEY_STATE: - return "yaml_PARSE_FLOW_MAPPING_KEY_STATE" - case yaml_PARSE_FLOW_MAPPING_VALUE_STATE: - return "yaml_PARSE_FLOW_MAPPING_VALUE_STATE" - case yaml_PARSE_FLOW_MAPPING_EMPTY_VALUE_STATE: - return "yaml_PARSE_FLOW_MAPPING_EMPTY_VALUE_STATE" - case yaml_PARSE_END_STATE: - return "yaml_PARSE_END_STATE" - } - return "" -} - -// This structure holds aliases data. -type yaml_alias_data_t struct { - anchor []byte // The anchor. - index int // The node id. - mark yaml_mark_t // The anchor mark. -} - -// The parser structure. -// -// All members are internal. Manage the structure using the -// yaml_parser_ family of functions. -type yaml_parser_t struct { - - // Error handling - - error yaml_error_type_t // Error type. - - problem string // Error description. - - // The byte about which the problem occurred. - problem_offset int - problem_value int - problem_mark yaml_mark_t - - // The error context. - context string - context_mark yaml_mark_t - - // Reader stuff - - read_handler yaml_read_handler_t // Read handler. - - input_file io.Reader // File input data. - input []byte // String input data. - input_pos int - - eof bool // EOF flag - - buffer []byte // The working buffer. - buffer_pos int // The current position of the buffer. - - unread int // The number of unread characters in the buffer. - - raw_buffer []byte // The raw buffer. - raw_buffer_pos int // The current position of the buffer. - - encoding yaml_encoding_t // The input encoding. - - offset int // The offset of the current position (in bytes). - mark yaml_mark_t // The mark of the current position. - - // Scanner stuff - - stream_start_produced bool // Have we started to scan the input stream? - stream_end_produced bool // Have we reached the end of the input stream? - - flow_level int // The number of unclosed '[' and '{' indicators. - - tokens []yaml_token_t // The tokens queue. - tokens_head int // The head of the tokens queue. - tokens_parsed int // The number of tokens fetched from the queue. - token_available bool // Does the tokens queue contain a token ready for dequeueing. - - indent int // The current indentation level. - indents []int // The indentation levels stack. - - simple_key_allowed bool // May a simple key occur at the current position? - simple_keys []yaml_simple_key_t // The stack of simple keys. - - // Parser stuff - - state yaml_parser_state_t // The current parser state. - states []yaml_parser_state_t // The parser states stack. - marks []yaml_mark_t // The stack of marks. - tag_directives []yaml_tag_directive_t // The list of TAG directives. - - // Dumper stuff - - aliases []yaml_alias_data_t // The alias data. - - document *yaml_document_t // The currently parsed document. -} - -// Emitter Definitions - -// The prototype of a write handler. -// -// The write handler is called when the emitter needs to flush the accumulated -// characters to the output. The handler should write @a size bytes of the -// @a buffer to the output. -// -// @param[in,out] data A pointer to an application data specified by -// yaml_emitter_set_output(). -// @param[in] buffer The buffer with bytes to be written. -// @param[in] size The size of the buffer. -// -// @returns On success, the handler should return @c 1. If the handler failed, -// the returned value should be @c 0. -// -type yaml_write_handler_t func(emitter *yaml_emitter_t, buffer []byte) error - -type yaml_emitter_state_t int - -// The emitter states. -const ( - // Expect STREAM-START. - yaml_EMIT_STREAM_START_STATE yaml_emitter_state_t = iota - - yaml_EMIT_FIRST_DOCUMENT_START_STATE // Expect the first DOCUMENT-START or STREAM-END. - yaml_EMIT_DOCUMENT_START_STATE // Expect DOCUMENT-START or STREAM-END. - yaml_EMIT_DOCUMENT_CONTENT_STATE // Expect the content of a document. - yaml_EMIT_DOCUMENT_END_STATE // Expect DOCUMENT-END. - yaml_EMIT_FLOW_SEQUENCE_FIRST_ITEM_STATE // Expect the first item of a flow sequence. - yaml_EMIT_FLOW_SEQUENCE_ITEM_STATE // Expect an item of a flow sequence. - yaml_EMIT_FLOW_MAPPING_FIRST_KEY_STATE // Expect the first key of a flow mapping. - yaml_EMIT_FLOW_MAPPING_KEY_STATE // Expect a key of a flow mapping. - yaml_EMIT_FLOW_MAPPING_SIMPLE_VALUE_STATE // Expect a value for a simple key of a flow mapping. - yaml_EMIT_FLOW_MAPPING_VALUE_STATE // Expect a value of a flow mapping. - yaml_EMIT_BLOCK_SEQUENCE_FIRST_ITEM_STATE // Expect the first item of a block sequence. - yaml_EMIT_BLOCK_SEQUENCE_ITEM_STATE // Expect an item of a block sequence. - yaml_EMIT_BLOCK_MAPPING_FIRST_KEY_STATE // Expect the first key of a block mapping. - yaml_EMIT_BLOCK_MAPPING_KEY_STATE // Expect the key of a block mapping. - yaml_EMIT_BLOCK_MAPPING_SIMPLE_VALUE_STATE // Expect a value for a simple key of a block mapping. - yaml_EMIT_BLOCK_MAPPING_VALUE_STATE // Expect a value of a block mapping. - yaml_EMIT_END_STATE // Expect nothing. -) - -// The emitter structure. -// -// All members are internal. Manage the structure using the @c yaml_emitter_ -// family of functions. -type yaml_emitter_t struct { - - // Error handling - - error yaml_error_type_t // Error type. - problem string // Error description. - - // Writer stuff - - write_handler yaml_write_handler_t // Write handler. - - output_buffer *[]byte // String output data. - output_file io.Writer // File output data. - - buffer []byte // The working buffer. - buffer_pos int // The current position of the buffer. - - raw_buffer []byte // The raw buffer. - raw_buffer_pos int // The current position of the buffer. - - encoding yaml_encoding_t // The stream encoding. - - // Emitter stuff - - canonical bool // If the output is in the canonical style? - best_indent int // The number of indentation spaces. - best_width int // The preferred width of the output lines. - unicode bool // Allow unescaped non-ASCII characters? - line_break yaml_break_t // The preferred line break. - - state yaml_emitter_state_t // The current emitter state. - states []yaml_emitter_state_t // The stack of states. - - events []yaml_event_t // The event queue. - events_head int // The head of the event queue. - - indents []int // The stack of indentation levels. - - tag_directives []yaml_tag_directive_t // The list of tag directives. - - indent int // The current indentation level. - - flow_level int // The current flow level. - - root_context bool // Is it the document root context? - sequence_context bool // Is it a sequence context? - mapping_context bool // Is it a mapping context? - simple_key_context bool // Is it a simple mapping key context? - - line int // The current line. - column int // The current column. - whitespace bool // If the last character was a whitespace? - indention bool // If the last character was an indentation character (' ', '-', '?', ':')? - open_ended bool // If an explicit document end is required? - - // Anchor analysis. - anchor_data struct { - anchor []byte // The anchor value. - alias bool // Is it an alias? - } - - // Tag analysis. - tag_data struct { - handle []byte // The tag handle. - suffix []byte // The tag suffix. - } - - // Scalar analysis. - scalar_data struct { - value []byte // The scalar value. - multiline bool // Does the scalar contain line breaks? - flow_plain_allowed bool // Can the scalar be expessed in the flow plain style? - block_plain_allowed bool // Can the scalar be expressed in the block plain style? - single_quoted_allowed bool // Can the scalar be expressed in the single quoted style? - block_allowed bool // Can the scalar be expressed in the literal or folded styles? - style yaml_scalar_style_t // The output style. - } - - // Dumper stuff - - opened bool // If the stream was already opened? - closed bool // If the stream was already closed? - - // The information associated with the document nodes. - anchors *struct { - references int // The number of references. - anchor int // The anchor id. - serialized bool // If the node has been emitted? - } - - last_anchor_id int // The last assigned anchor id. - - document *yaml_document_t // The currently emitted document. -} diff --git a/_beats/dev-tools/vendor/gopkg.in/yaml.v2/yamlprivateh.go b/_beats/dev-tools/vendor/gopkg.in/yaml.v2/yamlprivateh.go deleted file mode 100644 index 8110ce3c37..0000000000 --- a/_beats/dev-tools/vendor/gopkg.in/yaml.v2/yamlprivateh.go +++ /dev/null @@ -1,173 +0,0 @@ -package yaml - -const ( - // The size of the input raw buffer. - input_raw_buffer_size = 512 - - // The size of the input buffer. - // It should be possible to decode the whole raw buffer. - input_buffer_size = input_raw_buffer_size * 3 - - // The size of the output buffer. - output_buffer_size = 128 - - // The size of the output raw buffer. - // It should be possible to encode the whole output buffer. - output_raw_buffer_size = (output_buffer_size*2 + 2) - - // The size of other stacks and queues. - initial_stack_size = 16 - initial_queue_size = 16 - initial_string_size = 16 -) - -// Check if the character at the specified position is an alphabetical -// character, a digit, '_', or '-'. -func is_alpha(b []byte, i int) bool { - return b[i] >= '0' && b[i] <= '9' || b[i] >= 'A' && b[i] <= 'Z' || b[i] >= 'a' && b[i] <= 'z' || b[i] == '_' || b[i] == '-' -} - -// Check if the character at the specified position is a digit. -func is_digit(b []byte, i int) bool { - return b[i] >= '0' && b[i] <= '9' -} - -// Get the value of a digit. -func as_digit(b []byte, i int) int { - return int(b[i]) - '0' -} - -// Check if the character at the specified position is a hex-digit. -func is_hex(b []byte, i int) bool { - return b[i] >= '0' && b[i] <= '9' || b[i] >= 'A' && b[i] <= 'F' || b[i] >= 'a' && b[i] <= 'f' -} - -// Get the value of a hex-digit. -func as_hex(b []byte, i int) int { - bi := b[i] - if bi >= 'A' && bi <= 'F' { - return int(bi) - 'A' + 10 - } - if bi >= 'a' && bi <= 'f' { - return int(bi) - 'a' + 10 - } - return int(bi) - '0' -} - -// Check if the character is ASCII. -func is_ascii(b []byte, i int) bool { - return b[i] <= 0x7F -} - -// Check if the character at the start of the buffer can be printed unescaped. -func is_printable(b []byte, i int) bool { - return ((b[i] == 0x0A) || // . == #x0A - (b[i] >= 0x20 && b[i] <= 0x7E) || // #x20 <= . <= #x7E - (b[i] == 0xC2 && b[i+1] >= 0xA0) || // #0xA0 <= . <= #xD7FF - (b[i] > 0xC2 && b[i] < 0xED) || - (b[i] == 0xED && b[i+1] < 0xA0) || - (b[i] == 0xEE) || - (b[i] == 0xEF && // #xE000 <= . <= #xFFFD - !(b[i+1] == 0xBB && b[i+2] == 0xBF) && // && . != #xFEFF - !(b[i+1] == 0xBF && (b[i+2] == 0xBE || b[i+2] == 0xBF)))) -} - -// Check if the character at the specified position is NUL. -func is_z(b []byte, i int) bool { - return b[i] == 0x00 -} - -// Check if the beginning of the buffer is a BOM. -func is_bom(b []byte, i int) bool { - return b[0] == 0xEF && b[1] == 0xBB && b[2] == 0xBF -} - -// Check if the character at the specified position is space. -func is_space(b []byte, i int) bool { - return b[i] == ' ' -} - -// Check if the character at the specified position is tab. -func is_tab(b []byte, i int) bool { - return b[i] == '\t' -} - -// Check if the character at the specified position is blank (space or tab). -func is_blank(b []byte, i int) bool { - //return is_space(b, i) || is_tab(b, i) - return b[i] == ' ' || b[i] == '\t' -} - -// Check if the character at the specified position is a line break. -func is_break(b []byte, i int) bool { - return (b[i] == '\r' || // CR (#xD) - b[i] == '\n' || // LF (#xA) - b[i] == 0xC2 && b[i+1] == 0x85 || // NEL (#x85) - b[i] == 0xE2 && b[i+1] == 0x80 && b[i+2] == 0xA8 || // LS (#x2028) - b[i] == 0xE2 && b[i+1] == 0x80 && b[i+2] == 0xA9) // PS (#x2029) -} - -func is_crlf(b []byte, i int) bool { - return b[i] == '\r' && b[i+1] == '\n' -} - -// Check if the character is a line break or NUL. -func is_breakz(b []byte, i int) bool { - //return is_break(b, i) || is_z(b, i) - return ( // is_break: - b[i] == '\r' || // CR (#xD) - b[i] == '\n' || // LF (#xA) - b[i] == 0xC2 && b[i+1] == 0x85 || // NEL (#x85) - b[i] == 0xE2 && b[i+1] == 0x80 && b[i+2] == 0xA8 || // LS (#x2028) - b[i] == 0xE2 && b[i+1] == 0x80 && b[i+2] == 0xA9 || // PS (#x2029) - // is_z: - b[i] == 0) -} - -// Check if the character is a line break, space, or NUL. -func is_spacez(b []byte, i int) bool { - //return is_space(b, i) || is_breakz(b, i) - return ( // is_space: - b[i] == ' ' || - // is_breakz: - b[i] == '\r' || // CR (#xD) - b[i] == '\n' || // LF (#xA) - b[i] == 0xC2 && b[i+1] == 0x85 || // NEL (#x85) - b[i] == 0xE2 && b[i+1] == 0x80 && b[i+2] == 0xA8 || // LS (#x2028) - b[i] == 0xE2 && b[i+1] == 0x80 && b[i+2] == 0xA9 || // PS (#x2029) - b[i] == 0) -} - -// Check if the character is a line break, space, tab, or NUL. -func is_blankz(b []byte, i int) bool { - //return is_blank(b, i) || is_breakz(b, i) - return ( // is_blank: - b[i] == ' ' || b[i] == '\t' || - // is_breakz: - b[i] == '\r' || // CR (#xD) - b[i] == '\n' || // LF (#xA) - b[i] == 0xC2 && b[i+1] == 0x85 || // NEL (#x85) - b[i] == 0xE2 && b[i+1] == 0x80 && b[i+2] == 0xA8 || // LS (#x2028) - b[i] == 0xE2 && b[i+1] == 0x80 && b[i+2] == 0xA9 || // PS (#x2029) - b[i] == 0) -} - -// Determine the width of the character. -func width(b byte) int { - // Don't replace these by a switch without first - // confirming that it is being inlined. - if b&0x80 == 0x00 { - return 1 - } - if b&0xE0 == 0xC0 { - return 2 - } - if b&0xF0 == 0xE0 { - return 3 - } - if b&0xF8 == 0xF0 { - return 4 - } - return 0 - -} diff --git a/_beats/dev-tools/vendor/vendor.json b/_beats/dev-tools/vendor/vendor.json index 55de7c3205..28a187422a 100644 --- a/_beats/dev-tools/vendor/vendor.json +++ b/_beats/dev-tools/vendor/vendor.json @@ -21,10 +21,10 @@ "revisionTime": "2017-01-17T14:01:51Z" }, { - "checksumSHA1": "yPWWiioidIJuDhVSDe+ogjTmJ18=", - "path": "github.com/tsg/gotpl", - "revision": "a4179fb207b3ef8a96681fc9c9b6e20f99a6d2ef", - "revisionTime": "2015-08-11T13:42:54Z" + "checksumSHA1": "nlhGP9VLnwbYrykVzBdJMppDrFs=", + "path": "github.com/tsg/go-daemon", + "revision": "c6e0d1a849861166320520e9bae9bbda5f2ecb03", + "revisionTime": "2016-04-14T21:23:35Z" }, { "checksumSHA1": "TT1rac6kpQp2vz24m5yDGUNQ/QQ=", @@ -75,10 +75,10 @@ "revisionTime": "2017-03-30T16:02:45Z" }, { - "checksumSHA1": "qOmvuDm+F+2nQQecUZBVkZrTn6Y=", - "path": "gopkg.in/yaml.v2", - "revision": "d670f9405373e636a5a2765eea47fac0c9bc91a4", - "revisionTime": "2018-01-09T11:43:31Z" + "checksumSHA1": "DnH0WldhYTUVJnsx3vlNLP0Yh/A=", + "path": "golang.org/x/tools/go/vcs", + "revision": "a5b4c53f6e8bdcafa95a94671bf2d1203365858b", + "revisionTime": "2018-05-20T07:57:22Z" } ], "rootPath": "github.com/elastic/beats/dev-tools" diff --git a/_beats/libbeat/docs/version.asciidoc b/_beats/libbeat/docs/version.asciidoc index dd9b0bd570..a2c0560eac 100644 --- a/_beats/libbeat/docs/version.asciidoc +++ b/_beats/libbeat/docs/version.asciidoc @@ -1,6 +1,6 @@ :stack-version: 7.0.0-alpha1 :doc-branch: master -:go-version: 1.10.2 +:go-version: 1.10.3 :release-state: unreleased :python: 2.7.9 :docker: 1.12 diff --git a/_beats/libbeat/scripts/Makefile b/_beats/libbeat/scripts/Makefile index 2510b9da0a..73e8391796 100755 --- a/_beats/libbeat/scripts/Makefile +++ b/_beats/libbeat/scripts/Makefile @@ -2,7 +2,6 @@ ### Application using libbeat may override the following variables in their Makefile BEAT_NAME?=libbeat## @packaging Name of the binary BEAT_TITLE?=${BEAT_NAME}## @packaging Title of the application -BEAT_DESCRIPTION?=Sends events to Elasticsearch or Logstash ## @packaging Description of the application BEAT_PATH?=github.com/elastic/beats/${BEAT_NAME} BEAT_PACKAGE_NAME?=${BEAT_NAME} BEAT_INDEX_PREFIX?=${BEAT_NAME} @@ -21,6 +20,7 @@ ELASTIC_LICENSE_FILE?=../licenses/ELASTIC-LICENSE.txt SECCOMP_BINARY?=${BEAT_NAME} SECCOMP_BLACKLIST?=${ES_BEATS}/libbeat/common/seccomp/seccomp-profiler-blacklist.txt SECCOMP_ALLOWLIST?=${ES_BEATS}/libbeat/common/seccomp/seccomp-profiler-allow.txt +MAGE_IMPORT_PATH?=github.com/elastic/beats/vendor/github.com/magefile/mage space:=$() # comma:=, @@ -81,16 +81,6 @@ INTEGRATION_TESTS?= FIND=. ${PYTHON_ENV}/bin/activate; find . -type f -not -path "*/vendor/*" -not -path "*/build/*" -not -path "*/.git/*" PERM_EXEC?=$(shell [ `uname -s` = "Darwin" ] && echo "+111" || echo "/a+x") -# Cross compiling targets -CGO?=true ## @building if true, Build with C Go support -TARGETS?="windows/amd64 windows/386 darwin/amd64 linux/arm" ## @building list of platforms/architecture to be built by "make package" -TARGETS_OLD?="linux/amd64 linux/386" ## @building list of Debian6 architecture to be built by "make package" when CGO is true -PACKAGES?=${BEAT_NAME}/deb ${BEAT_NAME}/rpm ${BEAT_NAME}/darwin ${BEAT_NAME}/win ${BEAT_NAME}/bin ## @Building List of OS to be supported by "make package" -PACKAGES_EXPERIMENTAL?=${BEAT_NAME}/arm ## @Building List of experimental OS by "make package". Only build when SNAPSHOT=yes -SNAPSHOT?=yes ## @Building If yes, builds a snapshot version -BEATS_BUILDER_IMAGE?=tudorg/beats-builder ## @Building Name of the docker image to use when packaging the application -BEATS_BUILDER_DEB_IMAGE?=tudorg/beats-builder-deb7 ## @Building Name of the docker image to use when packaging the application for Debian 7 - ifeq ($(DOCKER_CACHE),0) DOCKER_NOCACHE=--no-cache endif @@ -100,11 +90,6 @@ ifeq ($(RACE_DETECTOR),1) RACE=-race endif -# Only build experimental targets for snapshots -ifneq ($(SNAPSHOT),yes) - PACKAGES_EXPERIMENTAL= -endif - ### BUILDING ### @@ -124,7 +109,7 @@ crosscompile: $(GOFILES) gox -output="${BUILD_DIR}/bin/{{.Dir}}-{{.OS}}-{{.Arch}}" -os="$(strip $(GOX_OS))" -osarch="$(strip $(GOX_OSARCH))" ${GOX_FLAGS} .PHONY: check -check: python-env prepare-tests ## @build Checks project and source code if everything is according to standard +check: check-headers python-env prepare-tests ## @build Checks project and source code if everything is according to standard @go vet ${GOPACKAGES} @go get $(GOIMPORTS_REPO) @goimports -local ${GOIMPORTS_LOCAL_PREFIX} -l ${GOFILES_NOVENDOR} | (! grep .) || (echo "Code differs from goimports' style ^" && false) @@ -132,8 +117,22 @@ check: python-env prepare-tests ## @build Checks project and source code if ever @${FIND} -wholename "*tests/system/test_*.py" -perm ${PERM_EXEC} -exec false {} + || (echo "Python test files shouldn't be executable, otherwise nose doesn't find them" && false) @${FIND} -name "*.yml" -perm ${PERM_EXEC} -exec false {} + || (echo "YAML files should not be executable" && false) +.PHONY: check-headers +check-headers: +ifndef CHECK_HEADERS_DISABLED + @go get github.com/elastic/go-licenser + @go-licenser -d +endif + +.PHONY: add-headers +add-headers: +ifndef CHECK_HEADERS_DISABLED + @go get github.com/elastic/go-licenser + @go-licenser +endif + .PHONY: fmt -fmt: python-env ## @build Runs `goimports -l -w` and `autopep8`on the project's source code, modifying any files that do not match its style. +fmt: add-headers python-env ## @build Runs `goimports -l -w` and `autopep8`on the project's source code, modifying any files that do not match its style. @go get $(GOIMPORTS_REPO) @goimports -local ${GOIMPORTS_LOCAL_PREFIX} -l -w ${GOFILES_NOVENDOR} @${FIND} -name *.py -exec ${PYTHON_ENV}/bin/autopep8 --in-place --max-line-length 120 {} \; @@ -149,8 +148,9 @@ clean:: ## @build Cleans up all files generated by the build steps @rm -f docker-compose.yml.lock @rm -f ${BEAT_NAME} ${BEAT_NAME}.test ${BEAT_NAME}.exe ${BEAT_NAME}.test.exe @rm -f _meta/fields.generated.yml fields.yml - @rm -fr $(PWD)/_meta/kibana.generated + @rm -rf $(PWD)/_meta/kibana.generated @rm -f ${BEAT_NAME}.template*.json + @-mage -clean 2> /dev/null .PHONY: ci ci: ## @build Shortcut for continuous integration. This should always run before merging. @@ -305,7 +305,6 @@ coverage-report: .PHONY: fields fields: - echo $(PWD) @go run ${ES_BEATS}/libbeat/scripts/cmd/global_fields/main.go --es_beats_path $(ES_BEATS) --beat_path $(PWD) $(FIELDS_FILE_PATH) @@ -357,7 +356,6 @@ endif docs: ## @build Builds the documents for the beat sh ${ES_BEATS}/script/build_docs.sh ${BEAT_NAME} ${BEAT_PATH}/docs ${BUILD_DIR} - .PHONY: docs-preview docs-preview: ## @build Preview the documents for the beat in the browser PREVIEW=1 $(MAKE) docs @@ -404,152 +402,6 @@ write-environment: env-logs: ${DOCKER_COMPOSE} logs -f - -### Packaging targets #### - -# Installs the files that need to get to the home path on installations -HOME_PREFIX?=/tmp/${BEAT_NAME} -.PHONY: install-home -install-home: - if [ -a ${NOTICE_FILE} ]; then \ - install -m 644 ${NOTICE_FILE} ${HOME_PREFIX}/; \ - fi - if [ -a ${LICENSE_FILE} ]; then \ - install -m 644 ${LICENSE_FILE} ${HOME_PREFIX}/LICENSE.txt; \ - fi - if [ -d _meta/module.generated ]; then \ - install -d -m 755 ${HOME_PREFIX}/module; \ - rsync -av _meta/module.generated/ ${HOME_PREFIX}/module/; \ - chmod -R go-w ${HOME_PREFIX}/module/; \ - fi - if [ -d _meta/kibana.generated ]; then \ - install -d -m 755 ${HOME_PREFIX}/kibana; \ - rsync -av _meta/kibana.generated/ ${HOME_PREFIX}/kibana/; \ - fi - -# Prepares for packaging. Builds binaries and creates homedir data -.PHONY: prepare-package -prepare-package: - # cross compile on ubuntu - docker run --rm \ - -v $(abspath ${ES_BEATS}/dev-tools/packer/xgo-scripts):/scripts \ - -v $(abspath ${PACKER_TEMPLATES_DIR}):/templates \ - -v $(abspath ../):/source \ - -v $(PKG_BUILD_DIR):/build \ - -e PUREGO="yes" \ - -e PACK=${BEAT_NAME} \ - -e BEFORE_BUILD=before_build.sh \ - -e SOURCE=/source \ - -e TARGETS=${TARGETS} \ - -e BUILDID=${BUILDID} \ - -e ES_BEATS=${ES_BEATS} \ - -e BEAT_PATH=${BEAT_PATH} \ - -e BEAT_NAME=${BEAT_NAME} \ - -e LICENSE_FILE=${LICENSE_FILE} \ - -e BEAT_REF_YAML=${BEAT_REF_YAML} \ - ${BEATS_BUILDER_IMAGE} - -# Prepares for packaging. Builds binaries with cgo -.PHONY: prepare-package-cgo -prepare-package-cgo: - - # cross compile on ubuntu - docker run --rm \ - -v $(abspath ${ES_BEATS}/dev-tools/packer/xgo-scripts):/scripts \ - -v $(abspath ${PACKER_TEMPLATES_DIR}):/templates \ - -v $(abspath ../):/source \ - -v $(PKG_BUILD_DIR):/build \ - -e PACK=${BEAT_NAME} \ - -e BEFORE_BUILD=before_build.sh \ - -e SOURCE=/source \ - -e TARGETS=${TARGETS} \ - -e BUILDID=${BUILDID} \ - -e ES_BEATS=${ES_BEATS} \ - -e BEAT_PATH=${BEAT_PATH} \ - -e BEAT_NAME=${BEAT_NAME} \ - -e LICENSE_FILE=${LICENSE_FILE} \ - -e BEAT_REF_YAML=${BEAT_REF_YAML} \ - ${BEATS_BUILDER_IMAGE} - - # linux builds on older debian for compatibility - docker run --rm \ - -v $(abspath ${ES_BEATS}/dev-tools/packer/xgo-scripts):/scripts \ - -v $(abspath ${PACKER_TEMPLATES_DIR}):/templates \ - -v $(abspath ..):/source \ - -v ${PKG_BUILD_DIR}:/build \ - -e PACK=${BEAT_NAME} \ - -e BEFORE_BUILD=before_build.sh \ - -e SOURCE=/source \ - -e TARGETS=${TARGETS_OLD} \ - -e BUILDID=${BUILDID} \ - -e ES_BEATS=${ES_BEATS} \ - -e BEAT_PATH=${BEAT_PATH} \ - -e BEAT_NAME=${BEAT_NAME} \ - -e LICENSE_FILE=${LICENSE_FILE} \ - -e BEAT_REF_YAML=${BEAT_REF_YAML} \ - ${BEATS_BUILDER_DEB_IMAGE} - -# Prepares images for packaging -.PHONY: package-setup -package-setup: - $(MAKE) -C ${ES_BEATS}/dev-tools/packer deps images - -.PHONY: package -package: ## @packaging Create binary packages for the beat. -package: update package-setup - echo "Start building packages for ${BEAT_NAME}" - - rm -rf ${PKG_BUILD_DIR} - mkdir -p ${PKG_BUILD_DIR} - mkdir -p ${PKG_UPLOAD_DIR} - - # Generates the package.yml file with all information needed to create packages - echo "beat_name: ${BEAT_NAME}" > ${PKG_BUILD_DIR}/package.yml - echo "beat_url: ${BEAT_URL}" >> ${PKG_BUILD_DIR}/package.yml - echo "beat_repo: ${BEAT_PATH}" >> ${PKG_BUILD_DIR}/package.yml - echo "beat_pkg_name: ${BEAT_PACKAGE_NAME}" >> ${PKG_BUILD_DIR}/package.yml - echo "beat_pkg_suffix: '${PKG_SUFFIX}'" >> ${PKG_BUILD_DIR}/package.yml - echo "beat_description: ${BEAT_DESCRIPTION}" >> ${PKG_BUILD_DIR}/package.yml - echo "beat_vendor: ${BEAT_VENDOR}" >> ${PKG_BUILD_DIR}/package.yml - echo "beat_license: ${BEAT_LICENSE}" >> ${PKG_BUILD_DIR}/package.yml - echo "beat_doc_url: ${BEAT_DOC_URL}" >> ${PKG_BUILD_DIR}/package.yml - - if [ -a version.yml ]; then \ - cat version.yml >> ${PKG_BUILD_DIR}/package.yml; \ - else \ - cat ${ES_BEATS}/dev-tools/packer/version.yml >> ${PKG_BUILD_DIR}/package.yml; \ - fi - - if [ $(CGO) = true ]; then \ - $(MAKE) prepare-package-cgo; \ - else \ - $(MAKE) prepare-package; \ - fi - - SNAPSHOT=${SNAPSHOT} BUILDID=${BUILDID} BEAT_PATH=${BEAT_PATH} BUILD_DIR=${PKG_BUILD_DIR} UPLOAD_DIR=${PKG_UPLOAD_DIR} $(MAKE) BEAT_REF_YAML=${BEAT_REF_YAML} -C ${ES_BEATS}/dev-tools/packer ${PACKAGES} ${PACKAGES_EXPERIMENTAL} ${BUILD_DIR}/upload/build_id.txt - - $(MAKE) fix-permissions - echo "Finished packages for ${BEAT_NAME}" - -# Packages the Beat without Elastic X-Pack content (OSS only). -.PHONY: package-oss -package-oss: - @$(MAKE) PKG_SUFFIX=-oss package - -# Packages the Beat with Elastic X-Pack content. -.PHONY: package-elastic -package-elastic: - @$(MAKE) BEAT_LICENSE="Elastic License" LICENSE_FILE=$(ELASTIC_LICENSE_FILE) package - -.PHONY: package-all -package-all: package-elastic package-oss - -package-dashboards: package-setup - mkdir -p ${BUILD_DIR} - cp -r _meta/kibana.generated ${BUILD_DIR}/dashboards - # build the dashboards package - BEAT_NAME=${BEAT_NAME} BUILD_DIR=${BUILD_DIR} SNAPSHOT=$(SNAPSHOT) $(MAKE) -C ${ES_BEATS}/dev-tools/packer package-dashboards ${shell pwd}/build/upload/build_id.txt - fix-permissions: # Change ownership of all files inside /build folder from root/root to current user/group docker run -v ${PWD}:/beat alpine:3.4 sh -c "find /beat -user 0 -exec chown -h $(shell id -u):$(shell id -g) {} \;" @@ -585,3 +437,17 @@ seccomp: seccomp-package: SECCOMP_BINARY=build/package/${BEAT_NAME}-linux-386 $(MAKE) seccomp SECCOMP_BINARY=build/package/${BEAT_NAME}-linux-amd64 $(MAKE) seccomp + +### Packaging targets #### + +.PHONY: mage +mage: + @go install ${MAGE_IMPORT_PATH} + +.PHONY: release +release: mage + @mage package + +.PHONY: package +snapshot: mage + @SNAPSHOT=true mage package diff --git a/_beats/libbeat/scripts/cmd/global_fields/main.go b/_beats/libbeat/scripts/cmd/global_fields/main.go index ccee1ffc87..60cd12f460 100644 --- a/_beats/libbeat/scripts/cmd/global_fields/main.go +++ b/_beats/libbeat/scripts/cmd/global_fields/main.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package main import ( diff --git a/_beats/libbeat/scripts/cmd/global_fields/main_test.go b/_beats/libbeat/scripts/cmd/global_fields/main_test.go index 5957e26f82..0c85178b2a 100644 --- a/_beats/libbeat/scripts/cmd/global_fields/main_test.go +++ b/_beats/libbeat/scripts/cmd/global_fields/main_test.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package main import ( diff --git a/_beats/libbeat/scripts/cmd/stress_pipeline/main.go b/_beats/libbeat/scripts/cmd/stress_pipeline/main.go index fb65c3273d..b23ca52f8f 100644 --- a/_beats/libbeat/scripts/cmd/stress_pipeline/main.go +++ b/_beats/libbeat/scripts/cmd/stress_pipeline/main.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package main import ( diff --git a/_beats/libbeat/testing/console.go b/_beats/libbeat/testing/console.go index bf3558f13d..dafc5008e9 100644 --- a/_beats/libbeat/testing/console.go +++ b/_beats/libbeat/testing/console.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package testing import ( diff --git a/_beats/libbeat/testing/console_test.go b/_beats/libbeat/testing/console_test.go index 1b4a262005..ac98465619 100644 --- a/_beats/libbeat/testing/console_test.go +++ b/_beats/libbeat/testing/console_test.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package testing import ( diff --git a/_beats/libbeat/testing/null.go b/_beats/libbeat/testing/null.go index c20945bbfd..8335b65ba1 100644 --- a/_beats/libbeat/testing/null.go +++ b/_beats/libbeat/testing/null.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package testing type nullDriver struct{} diff --git a/_beats/libbeat/testing/testing.go b/_beats/libbeat/testing/testing.go index 7300c3eb3a..559bba777c 100644 --- a/_beats/libbeat/testing/testing.go +++ b/_beats/libbeat/testing/testing.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package testing // Driver for testing, manages test flow and controls output diff --git a/_beats/script/generate_imports.py b/_beats/script/generate_imports.py index 092bb7935a..56bf8644b1 100644 --- a/_beats/script/generate_imports.py +++ b/_beats/script/generate_imports.py @@ -8,13 +8,31 @@ import_line_format = "\t_ \"{beat_path}/{module}/{name}\"" -import_template = """/* +import_template = """// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +// Code generated by 'make imports' - DO NOT EDIT. + +/* {comment} */ package {package} import ( -\t// This list is automatically generated by `make imports` {imports} ) """ diff --git a/_beats/testing/environments/latest.yml b/_beats/testing/environments/latest.yml index 180fa3b916..110eb6a487 100644 --- a/_beats/testing/environments/latest.yml +++ b/_beats/testing/environments/latest.yml @@ -3,8 +3,7 @@ version: '2.1' services: elasticsearch: - # TODO: For 6.3 remove "-platinum". - image: docker.elastic.co/elasticsearch/elasticsearch-platinum:6.2.4 + image: docker.elastic.co/elasticsearch/elasticsearch:6.3.0 healthcheck: test: ["CMD", "curl", "-f", "http://localhost:9200"] retries: 300 @@ -17,17 +16,17 @@ services: - "xpack.security.enabled=false" logstash: - image: docker.elastic.co/logstash/logstash:6.2.4 + image: docker.elastic.co/logstash/logstash:6.3.0 healthcheck: test: ["CMD", "curl", "-f", "http://localhost:9600/_node/stats"] retries: 300 interval: 1s volumes: - - ./docker/logstash/pipeline:/usr/share/logstash/pipeline:ro - - ./docker/logstash/pki:/etc/pki:ro + - ./docker/logstash/pipeline:/usr/share/logstash/pipeline:ro + - ./docker/logstash/pki:/etc/pki:ro kibana: - image: docker.elastic.co/kibana/kibana:6.2.4 + image: docker.elastic.co/kibana/kibana:6.3.0 healthcheck: test: ["CMD", "curl", "-f", "http://localhost:5601"] retries: 300 diff --git a/_beats/vendor/vendor.json b/_beats/vendor/vendor.json index 24cd57e17d..7a07365d12 100644 --- a/_beats/vendor/vendor.json +++ b/_beats/vendor/vendor.json @@ -8,6 +8,14 @@ "revision": "f533f7a102197536779ea3a8cb881d639e21ec5a", "revisionTime": "2017-05-24T00:36:31Z" }, + { + "checksumSHA1": "wshQ6/MnQx8nH6pgufu4kJEX6JI=", + "path": "github.com/OneOfOne/xxhash", + "revision": "6def279d2ce6c81a79dd1c1be580f03bb216fb8a", + "revisionTime": "2018-05-30T13:49:54Z", + "version": "v1.2.2", + "versionExact": "v1.2.2" + }, { "checksumSHA1": "pH1jOw5Kfigc2tteo6KlaU9+JE8=", "origin": "github.com/urso/sarama", @@ -474,44 +482,56 @@ "revisionTime": "2018-05-17T07:14:48Z" }, { - "checksumSHA1": "AaEPt+KMknLXze11YOnBGKzP3aA=", + "checksumSHA1": "BY+a5iQICad7U2AZqwej2SIW9J8=", "path": "github.com/elastic/go-structform", - "revision": "0a66add879601f69f55663f4c913c72988218982", - "revisionTime": "2018-03-09T00:36:09Z", - "version": "v0.0.3", - "versionExact": "v0.0.3" + "revision": "0ea09ff9b43c387dd183a4088f6d573bf823e4ed", + "revisionTime": "2018-06-27T12:43:37Z", + "version": "v0.0.4", + "versionExact": "v0.0.4" }, { "checksumSHA1": "SXsT/tWnjLqR8dBiJGZqxCyuNaY=", "path": "github.com/elastic/go-structform/cborl", - "revision": "0a66add879601f69f55663f4c913c72988218982", - "revisionTime": "2018-03-09T00:36:09Z", - "version": "v0.0.3", - "versionExact": "v0.0.3" + "revision": "0ea09ff9b43c387dd183a4088f6d573bf823e4ed", + "revisionTime": "2018-06-27T12:43:37Z", + "version": "v0.0.4", + "versionExact": "v0.0.4" }, { "checksumSHA1": "LUbWdzbpzhBh+5TizsScD8gTm4M=", "path": "github.com/elastic/go-structform/gotype", - "revision": "0a66add879601f69f55663f4c913c72988218982", - "revisionTime": "2018-03-09T00:36:09Z", - "version": "v0.0.3", - "versionExact": "v0.0.3" + "revision": "0ea09ff9b43c387dd183a4088f6d573bf823e4ed", + "revisionTime": "2018-06-27T12:43:37Z", + "version": "v0.0.4", + "versionExact": "v0.0.4" + }, + { + "path": "github.com/elastic/go-structform/internal/ubjson", + "revision": "v0.0.4", + "version": "v0.0.4", + "versionExact": "v0.0.4" }, { "checksumSHA1": "s7k0vEuuqkoPXU0FtrD6Y0jxd7U=", "path": "github.com/elastic/go-structform/internal/unsafe", - "revision": "0a66add879601f69f55663f4c913c72988218982", - "revisionTime": "2018-03-09T00:36:09Z", - "version": "v0.0.3", - "versionExact": "v0.0.3" + "revision": "0ea09ff9b43c387dd183a4088f6d573bf823e4ed", + "revisionTime": "2018-06-27T12:43:37Z", + "version": "v0.0.4", + "versionExact": "v0.0.4" + }, + { + "path": "github.com/elastic/go-structform/internal/visitors", + "revision": "", + "version": "v0.0.4", + "versionExact": "v0.0.4" }, { - "checksumSHA1": "s5nSu8O8TOv4DZhdbU7OC5x0C50=", + "checksumSHA1": "KTDpLMZRFtSVeUuXdaz5o5ehzfI=", "path": "github.com/elastic/go-structform/json", - "revision": "0a66add879601f69f55663f4c913c72988218982", - "revisionTime": "2018-03-09T00:36:09Z", - "version": "v0.0.3", - "versionExact": "v0.0.3" + "revision": "0ea09ff9b43c387dd183a4088f6d573bf823e4ed", + "revisionTime": "2018-06-27T12:43:37Z", + "version": "v0.0.4", + "versionExact": "v0.0.4" }, { "checksumSHA1": "PDqC4Sh2H2EIxVhWZHdsusBMPB8=", @@ -1094,6 +1114,60 @@ "revision": "1bab8b35b6bb565f92cbc97939610af9369f942a", "revisionTime": "2017-02-10T14:05:23Z" }, + { + "checksumSHA1": "k3e1TD8wrhxfUUG3pQBb10ppNGA=", + "path": "github.com/magefile/mage", + "revision": "5e51f9ad1ed0886c5d06a8c46a09703cfc4d9034", + "revisionTime": "2018-04-12T15:54:34Z" + }, + { + "checksumSHA1": "KODorM0Am1g55qObNz3jVOdRVFs=", + "path": "github.com/magefile/mage/build", + "revision": "5e51f9ad1ed0886c5d06a8c46a09703cfc4d9034", + "revisionTime": "2018-04-12T15:54:34Z" + }, + { + "checksumSHA1": "9yeXUlqhNcsR7MlYMouJTO3AXv0=", + "path": "github.com/magefile/mage/mage", + "revision": "5e51f9ad1ed0886c5d06a8c46a09703cfc4d9034", + "revisionTime": "2018-04-12T15:54:34Z" + }, + { + "checksumSHA1": "TkAemcxaY44gsEjO1BiBxwlEI4A=", + "path": "github.com/magefile/mage/mg", + "revision": "5e51f9ad1ed0886c5d06a8c46a09703cfc4d9034", + "revisionTime": "2018-04-12T15:54:34Z" + }, + { + "checksumSHA1": "b1qY9BFtpJnIZEa8yvpJCRbOhRM=", + "path": "github.com/magefile/mage/parse", + "revision": "5e51f9ad1ed0886c5d06a8c46a09703cfc4d9034", + "revisionTime": "2018-04-12T15:54:34Z" + }, + { + "checksumSHA1": "fEuDveZzYX6oqYOT9jqyZROun/Q=", + "path": "github.com/magefile/mage/parse/srcimporter", + "revision": "5e51f9ad1ed0886c5d06a8c46a09703cfc4d9034", + "revisionTime": "2018-04-12T15:54:34Z" + }, + { + "checksumSHA1": "0/j3qlGc8fsWG42uIDZ5p8tVzPM=", + "path": "github.com/magefile/mage/sh", + "revision": "5e51f9ad1ed0886c5d06a8c46a09703cfc4d9034", + "revisionTime": "2018-04-12T15:54:34Z" + }, + { + "checksumSHA1": "oAjx69UIs6F6hPh+2GQSBMaHAfc=", + "path": "github.com/magefile/mage/target", + "revision": "5e51f9ad1ed0886c5d06a8c46a09703cfc4d9034", + "revisionTime": "2018-04-12T15:54:34Z" + }, + { + "checksumSHA1": "He+VtZO7BsPDCZhZtJ1IkNp629o=", + "path": "github.com/magefile/mage/types", + "revision": "5e51f9ad1ed0886c5d06a8c46a09703cfc4d9034", + "revisionTime": "2018-04-12T15:54:34Z" + }, { "checksumSHA1": "qNkx9+OTwZI6aFv7K9zuFCGODUw=", "path": "github.com/mattn/go-colorable", diff --git a/beater/beater.go b/beater/beater.go index 824acef233..2d2c817bc5 100644 --- a/beater/beater.go +++ b/beater/beater.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package beater import ( diff --git a/beater/beater_test.go b/beater/beater_test.go index 218c3c58ab..cf8d721774 100644 --- a/beater/beater_test.go +++ b/beater/beater_test.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package beater import ( diff --git a/beater/client.go b/beater/client.go index 3027738523..d2759185de 100644 --- a/beater/client.go +++ b/beater/client.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package beater import ( diff --git a/beater/config.go b/beater/config.go index e3c74aa6a0..65275778b9 100644 --- a/beater/config.go +++ b/beater/config.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package beater import ( diff --git a/beater/config_test.go b/beater/config_test.go index df34459bd6..9cc7953c89 100644 --- a/beater/config_test.go +++ b/beater/config_test.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package beater import ( diff --git a/beater/handlers.go b/beater/handlers.go index b2e4ff6152..f301bbb509 100644 --- a/beater/handlers.go +++ b/beater/handlers.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package beater import ( diff --git a/beater/handlers_test.go b/beater/handlers_test.go index 57ecd41306..26074626ab 100644 --- a/beater/handlers_test.go +++ b/beater/handlers_test.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package beater import ( diff --git a/beater/onboarding.go b/beater/onboarding.go index edd3852f6c..6e4a6fca06 100644 --- a/beater/onboarding.go +++ b/beater/onboarding.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package beater import ( diff --git a/beater/onboarding_test.go b/beater/onboarding_test.go index 3a212edc41..b38e99d646 100644 --- a/beater/onboarding_test.go +++ b/beater/onboarding_test.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package beater import ( diff --git a/beater/pub.go b/beater/pub.go index c96dda974c..15a4f1260e 100644 --- a/beater/pub.go +++ b/beater/pub.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package beater import ( diff --git a/beater/server.go b/beater/server.go index c4b902dfb8..d20ba58b89 100644 --- a/beater/server.go +++ b/beater/server.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package beater import ( diff --git a/beater/server_test.go b/beater/server_test.go index 184a769264..153957dd0c 100644 --- a/beater/server_test.go +++ b/beater/server_test.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package beater import ( diff --git a/cmd/root.go b/cmd/root.go index 4579ce1e35..7cdf933165 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package cmd import ( diff --git a/config/config.go b/config/config.go index 8403283b99..fe6790666c 100644 --- a/config/config.go +++ b/config/config.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package config import ( diff --git a/decoder/decoder.go b/decoder/decoder.go index 4877085bbd..60db90118b 100644 --- a/decoder/decoder.go +++ b/decoder/decoder.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package decoder import ( diff --git a/decoder/decoder_test.go b/decoder/decoder_test.go index 2ff5e418fa..dfa6b5ac6a 100644 --- a/decoder/decoder_test.go +++ b/decoder/decoder_test.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package decoder_test import ( diff --git a/docs/version.asciidoc b/docs/version.asciidoc index 166772eae6..fffc318f54 100644 --- a/docs/version.asciidoc +++ b/docs/version.asciidoc @@ -1,7 +1,7 @@ :stack-version: 7.0.0-alpha1 :doc-branch: master :branch: {doc-branch} -:go-version: 1.10.1 +:go-version: 1.10.3 :release-state: unreleased :python: 2.7.9 :docker: 1.12 diff --git a/include/fields.go b/include/fields.go index 0e2835cb38..be7ce68a1e 100644 --- a/include/fields.go +++ b/include/fields.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + // Code generated by beats/dev-tools/cmd/asset/asset.go - DO NOT EDIT. package include @@ -7,7 +24,7 @@ import ( ) func init() { - if err := asset.SetFields("apm-server/fields.yml", Asset); err != nil { + if err := asset.SetFields("apm-server", "fields.yml", Asset); err != nil { panic(err) } } diff --git a/magefile.go b/magefile.go new file mode 100644 index 0000000000..bd3affbad0 --- /dev/null +++ b/magefile.go @@ -0,0 +1,127 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +// +build mage + +package main + +import ( + "fmt" + "time" + + "github.com/magefile/mage/mg" + "github.com/magefile/mage/sh" + + "github.com/elastic/beats/dev-tools/mage" +) + +func init() { + mage.SetElasticBeatsDir("./_beats") + + mage.SetBuildVariableSources(&mage.BuildVariableSources{ + BeatVersion: "vendor/github.com/elastic/beats/libbeat/version/version.go", + GoVersion: ".go-version", + DocBranch: "docs/version.asciidoc", + }) + + mage.BeatDescription = "Elastic APM Server" + mage.BeatURL = "https://www.elastic.co/solutions/apm" + mage.BeatIndexPrefix = "apm" +} + +// Build builds the Beat binary. +func Build() error { + return mage.Build(mage.DefaultBuildArgs()) +} + +// GolangCrossBuild build the Beat binary inside of the golang-builder. +// Do not use directly, use crossBuild instead. +func GolangCrossBuild() error { + return mage.GolangCrossBuild(mage.DefaultGolangCrossBuildArgs()) +} + +// BuildGoDaemon builds the go-daemon binary (use crossBuildGoDaemon). +func BuildGoDaemon() error { + return mage.BuildGoDaemon() +} + +// CrossBuild cross-builds the beat for all target platforms. +func CrossBuild() error { + return mage.CrossBuild() +} + +// CrossBuildGoDaemon cross-builds the go-daemon binary using Docker. +func CrossBuildGoDaemon() error { + return mage.CrossBuildGoDaemon() +} + +// Clean cleans all generated files and build artifacts. +func Clean() error { + return mage.Clean() +} + +// Package packages the Beat for distribution. +// Use SNAPSHOT=true to build snapshots. +// Use PLATFORMS to control the target platforms. +func Package() { + start := time.Now() + defer func() { fmt.Println("package ran for", time.Since(start)) }() + + mage.UseElasticBeatPackaging() + customizePackaging() + + mg.Deps(Update) + mg.Deps(CrossBuild, CrossBuildGoDaemon) + mg.SerialDeps(mage.Package, TestPackages) +} + +// TestPackages tests the generated packages (i.e. file modes, owners, groups). +func TestPackages() error { + return mage.TestPackages() +} + +// Update updates the generated files (aka make update). +func Update() error { + return sh.Run("make", "update") +} + +// ----------------------------------------------------------------------------- +// Customizations specific to apm-server. +// - readme.md.tmpl used in packages is customized. +// - apm-server.reference.yml is not included in packages. + +func customizePackaging() { + var ( + readmeTemplate = mage.PackageFile{ + Mode: 0644, + Template: "package-README.md.tmpl", + } + ) + for _, args := range mage.Packages { + switch args.Types[0] { + case mage.Zip, mage.TarGz: + // Remove the reference config file from packages. + delete(args.Spec.Files, "{{.BeatName}}.reference.yml") + + // Replace the README.md with an APM specific file. + args.Spec.ReplaceFile("README.md", readmeTemplate) + case mage.Deb, mage.RPM: + delete(args.Spec.Files, "/etc/{{.BeatName}}/{{.BeatName}}.reference.yml") + args.Spec.ReplaceFile("/usr/share/{{.BeatName}}/README.md", readmeTemplate) + } + } +} diff --git a/main.go b/main.go index 145d49e94e..36796ebead 100644 --- a/main.go +++ b/main.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package main //go:generate go run script/inline_schemas/inline_schemas.go diff --git a/main_test.go b/main_test.go index 9c3bf18599..08a9a3dfd3 100644 --- a/main_test.go +++ b/main_test.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package main // This file is mandatory as otherwise the apm-server.test binary is not generated correctly. diff --git a/model/context.go b/model/context.go index 33365fa967..c7b3f5f61d 100644 --- a/model/context.go +++ b/model/context.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package model import ( diff --git a/model/context_test.go b/model/context_test.go index 7057350960..f605259d01 100644 --- a/model/context_test.go +++ b/model/context_test.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package model import ( diff --git a/model/process.go b/model/process.go index 6f8f4187ef..12799c40e6 100644 --- a/model/process.go +++ b/model/process.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package model import ( diff --git a/model/process_test.go b/model/process_test.go index 1069567b70..2db79da959 100644 --- a/model/process_test.go +++ b/model/process_test.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package model import ( diff --git a/model/service.go b/model/service.go index 54527f3791..4582976a5c 100644 --- a/model/service.go +++ b/model/service.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package model import ( diff --git a/model/service_test.go b/model/service_test.go index 4ec78e72ae..15321e43b6 100644 --- a/model/service_test.go +++ b/model/service_test.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package model import ( diff --git a/model/stacktrace.go b/model/stacktrace.go index cf88827dcc..160faee534 100644 --- a/model/stacktrace.go +++ b/model/stacktrace.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package model import ( diff --git a/model/stacktrace_frame.go b/model/stacktrace_frame.go index 1eee39e511..4b2f616685 100644 --- a/model/stacktrace_frame.go +++ b/model/stacktrace_frame.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package model import ( diff --git a/model/stacktrace_frame_test.go b/model/stacktrace_frame_test.go index 08bf36bd2e..176303447f 100644 --- a/model/stacktrace_frame_test.go +++ b/model/stacktrace_frame_test.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package model import ( diff --git a/model/stacktrace_test.go b/model/stacktrace_test.go index 590c33fd03..bc75a14d48 100644 --- a/model/stacktrace_test.go +++ b/model/stacktrace_test.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package model import ( diff --git a/model/system.go b/model/system.go index 22bb3a01b2..e78ad18429 100644 --- a/model/system.go +++ b/model/system.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package model import ( diff --git a/model/system_test.go b/model/system_test.go index 88d5430e33..9a3c7020e9 100644 --- a/model/system_test.go +++ b/model/system_test.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package model import ( diff --git a/model/user.go b/model/user.go index eed911282f..0aa3169818 100644 --- a/model/user.go +++ b/model/user.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package model import ( diff --git a/model/user_test.go b/model/user_test.go index 17166c1ce1..f3fc22950a 100644 --- a/model/user_test.go +++ b/model/user_test.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package model import ( diff --git a/package-README.md.tmpl b/package-README.md.tmpl new file mode 100644 index 0000000000..10810e0d0c --- /dev/null +++ b/package-README.md.tmpl @@ -0,0 +1,23 @@ +# Welcome to the Elastic APM Server {{.Version}}{{if .Snapshot}}-SNAPSHOT{{end}} + +{{.Description}} + +## Getting Started + +To get started with APM Server, you need to set up Elasticsearch on your +localhost first. After that, start APM Server with: + + ./{{.BeatName}} -c {{.BeatName}}.yml -e + +This will start APM Server and send the data to your Elasticsearch instance. To +load the dashboards for APM Server into Kibana, run: + + ./{{.BeatName}} setup -e + +For further steps visit the +[Getting started](https://www.elastic.co/guide/en/apm/get-started/{{ beat_doc_branch }}/) guide. + +## Documentation + +Visit [Elastic.co Docs](https://www.elastic.co/guide/en/apm/server/{{ beat_doc_branch }}/) +for the full {{.BeatName}} documentation. diff --git a/pipelistener/doc.go b/pipelistener/doc.go index 79041f5c51..7d1759d899 100644 --- a/pipelistener/doc.go +++ b/pipelistener/doc.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + // Package pipelistener provides a net.Listener using net.Conn, // for in-process communication. diff --git a/pipelistener/listener.go b/pipelistener/listener.go index cffe16fef3..96991ef46e 100644 --- a/pipelistener/listener.go +++ b/pipelistener/listener.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package pipelistener import ( diff --git a/pipelistener/listener_test.go b/pipelistener/listener_test.go index e4fe412a9b..9c8b27bf3b 100644 --- a/pipelistener/listener_test.go +++ b/pipelistener/listener_test.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package pipelistener_test import ( diff --git a/processor/error/event.go b/processor/error/event.go index ce70899d75..0e8c1a1575 100644 --- a/processor/error/event.go +++ b/processor/error/event.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package error import ( diff --git a/processor/error/event_test.go b/processor/error/event_test.go index c199d9c9eb..1bb449b2cc 100644 --- a/processor/error/event_test.go +++ b/processor/error/event_test.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package error import ( diff --git a/processor/error/generated/schema/payload.go b/processor/error/generated/schema/payload.go index 852d1f628a..a19a0d0b69 100644 --- a/processor/error/generated/schema/payload.go +++ b/processor/error/generated/schema/payload.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package schema const PayloadSchema = `{ diff --git a/processor/error/package_tests/attrs_common.go b/processor/error/package_tests/attrs_common.go index 8e9fe9ec8f..8be56ec427 100644 --- a/processor/error/package_tests/attrs_common.go +++ b/processor/error/package_tests/attrs_common.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package package_tests import ( diff --git a/processor/error/package_tests/attrs_test.go b/processor/error/package_tests/attrs_test.go index ad94d87888..48bdc34a5b 100644 --- a/processor/error/package_tests/attrs_test.go +++ b/processor/error/package_tests/attrs_test.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package package_tests import ( diff --git a/processor/error/package_tests/doc.go b/processor/error/package_tests/doc.go index 7bb68418a5..8c684cf768 100644 --- a/processor/error/package_tests/doc.go +++ b/processor/error/package_tests/doc.go @@ -1 +1,18 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package package_tests diff --git a/processor/error/package_tests/processor_test.go b/processor/error/package_tests/processor_test.go index 88a3b054cb..feb6b18186 100644 --- a/processor/error/package_tests/processor_test.go +++ b/processor/error/package_tests/processor_test.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package package_tests import ( diff --git a/processor/error/payload.go b/processor/error/payload.go index 381e99454a..c8ef72d847 100644 --- a/processor/error/payload.go +++ b/processor/error/payload.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package error import ( diff --git a/processor/error/payload_test.go b/processor/error/payload_test.go index 622dd7e894..6d9e95238b 100644 --- a/processor/error/payload_test.go +++ b/processor/error/payload_test.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package error import ( diff --git a/processor/error/processor.go b/processor/error/processor.go index dd4824e283..4669176127 100644 --- a/processor/error/processor.go +++ b/processor/error/processor.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package error import ( diff --git a/processor/error/processor_test.go b/processor/error/processor_test.go index 20708db9a0..a218bdf057 100644 --- a/processor/error/processor_test.go +++ b/processor/error/processor_test.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package error import ( diff --git a/processor/healthcheck/processor.go b/processor/healthcheck/processor.go index 60ffaadc44..ca592dcee1 100644 --- a/processor/healthcheck/processor.go +++ b/processor/healthcheck/processor.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package healthcheck import ( diff --git a/processor/healthcheck/processor_test.go b/processor/healthcheck/processor_test.go index 108aede3ed..a989f89adf 100644 --- a/processor/healthcheck/processor_test.go +++ b/processor/healthcheck/processor_test.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package healthcheck import ( diff --git a/processor/metric/counter.go b/processor/metric/counter.go index 38a46c3db0..9a4d7e5b6e 100644 --- a/processor/metric/counter.go +++ b/processor/metric/counter.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package metric import ( diff --git a/processor/metric/event.go b/processor/metric/event.go index 0bad30a06e..5ca38cb2b1 100644 --- a/processor/metric/event.go +++ b/processor/metric/event.go @@ -1 +1,18 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package metric diff --git a/processor/metric/gauge.go b/processor/metric/gauge.go index 7e77f82df6..5c19c0f12c 100644 --- a/processor/metric/gauge.go +++ b/processor/metric/gauge.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package metric import ( diff --git a/processor/metric/generated/schema/payload.go b/processor/metric/generated/schema/payload.go index 0ca71b6e6a..c313999b30 100644 --- a/processor/metric/generated/schema/payload.go +++ b/processor/metric/generated/schema/payload.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package schema const PayloadSchema = `{ diff --git a/processor/metric/package_tests/json_schema_test.go b/processor/metric/package_tests/json_schema_test.go index 09b13d51a8..9fcbe7e706 100644 --- a/processor/metric/package_tests/json_schema_test.go +++ b/processor/metric/package_tests/json_schema_test.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package package_tests import ( diff --git a/processor/metric/package_tests/processor_test.go b/processor/metric/package_tests/processor_test.go index e46447f645..2bd1b1d9ce 100644 --- a/processor/metric/package_tests/processor_test.go +++ b/processor/metric/package_tests/processor_test.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package package_tests import ( diff --git a/processor/metric/payload.go b/processor/metric/payload.go index edbb2243c6..356d43ddff 100644 --- a/processor/metric/payload.go +++ b/processor/metric/payload.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package metric import ( diff --git a/processor/metric/payload_test.go b/processor/metric/payload_test.go index 66dce1798d..d3dec61963 100644 --- a/processor/metric/payload_test.go +++ b/processor/metric/payload_test.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package metric import ( diff --git a/processor/metric/processor.go b/processor/metric/processor.go index 08ff3b9c2a..0c4aaaec54 100644 --- a/processor/metric/processor.go +++ b/processor/metric/processor.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package metric import ( diff --git a/processor/metric/summary.go b/processor/metric/summary.go index f5694c2e0b..6f96187972 100644 --- a/processor/metric/summary.go +++ b/processor/metric/summary.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package metric import ( diff --git a/processor/processor.go b/processor/processor.go index 640d1de843..5e4fcfb51e 100644 --- a/processor/processor.go +++ b/processor/processor.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package processor import ( diff --git a/processor/sourcemap/generated/schema/payload.go b/processor/sourcemap/generated/schema/payload.go index baf130be26..654207a71f 100644 --- a/processor/sourcemap/generated/schema/payload.go +++ b/processor/sourcemap/generated/schema/payload.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package schema const PayloadSchema = `{ diff --git a/processor/sourcemap/package_tests/attrs_test.go b/processor/sourcemap/package_tests/attrs_test.go index d4c9b6bd5d..722b7381ce 100644 --- a/processor/sourcemap/package_tests/attrs_test.go +++ b/processor/sourcemap/package_tests/attrs_test.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package package_tests import ( diff --git a/processor/sourcemap/package_tests/doc.go b/processor/sourcemap/package_tests/doc.go index 7bb68418a5..8c684cf768 100644 --- a/processor/sourcemap/package_tests/doc.go +++ b/processor/sourcemap/package_tests/doc.go @@ -1 +1,18 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package package_tests diff --git a/processor/sourcemap/package_tests/processor_test.go b/processor/sourcemap/package_tests/processor_test.go index a2c5914bfd..3228db4cf5 100644 --- a/processor/sourcemap/package_tests/processor_test.go +++ b/processor/sourcemap/package_tests/processor_test.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package package_tests import ( diff --git a/processor/sourcemap/payload.go b/processor/sourcemap/payload.go index 924f20de75..c6e058581a 100644 --- a/processor/sourcemap/payload.go +++ b/processor/sourcemap/payload.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package sourcemap import ( diff --git a/processor/sourcemap/payload_test.go b/processor/sourcemap/payload_test.go index 6e8b9731e7..c04be638f6 100644 --- a/processor/sourcemap/payload_test.go +++ b/processor/sourcemap/payload_test.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package sourcemap import ( diff --git a/processor/sourcemap/processor.go b/processor/sourcemap/processor.go index 5b218e9d58..d381acec5e 100644 --- a/processor/sourcemap/processor.go +++ b/processor/sourcemap/processor.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package sourcemap import ( diff --git a/processor/sourcemap/processor_test.go b/processor/sourcemap/processor_test.go index 4a733c840f..f67f344058 100644 --- a/processor/sourcemap/processor_test.go +++ b/processor/sourcemap/processor_test.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package sourcemap import ( diff --git a/processor/transaction/event.go b/processor/transaction/event.go index 748d9bd490..22d5c0c998 100644 --- a/processor/transaction/event.go +++ b/processor/transaction/event.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package transaction import ( diff --git a/processor/transaction/event_test.go b/processor/transaction/event_test.go index c436f9380d..4c02179328 100644 --- a/processor/transaction/event_test.go +++ b/processor/transaction/event_test.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package transaction import ( diff --git a/processor/transaction/generated/schema/payload.go b/processor/transaction/generated/schema/payload.go index 11d8861cc1..6e76bad7a7 100644 --- a/processor/transaction/generated/schema/payload.go +++ b/processor/transaction/generated/schema/payload.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package schema const PayloadSchema = `{ diff --git a/processor/transaction/package_tests/attrs_common.go b/processor/transaction/package_tests/attrs_common.go index 3adfefded1..71f0be0652 100644 --- a/processor/transaction/package_tests/attrs_common.go +++ b/processor/transaction/package_tests/attrs_common.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package package_tests import ( diff --git a/processor/transaction/package_tests/attrs_test.go b/processor/transaction/package_tests/attrs_test.go index b1b1363db0..9676125237 100644 --- a/processor/transaction/package_tests/attrs_test.go +++ b/processor/transaction/package_tests/attrs_test.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package package_tests import ( diff --git a/processor/transaction/package_tests/doc.go b/processor/transaction/package_tests/doc.go index 7bb68418a5..8c684cf768 100644 --- a/processor/transaction/package_tests/doc.go +++ b/processor/transaction/package_tests/doc.go @@ -1 +1,18 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package package_tests diff --git a/processor/transaction/package_tests/processor_test.go b/processor/transaction/package_tests/processor_test.go index c108210fe0..d6666fab17 100644 --- a/processor/transaction/package_tests/processor_test.go +++ b/processor/transaction/package_tests/processor_test.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package package_tests import ( diff --git a/processor/transaction/payload.go b/processor/transaction/payload.go index bb6ffe3f14..2570f87430 100644 --- a/processor/transaction/payload.go +++ b/processor/transaction/payload.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package transaction import ( diff --git a/processor/transaction/payload_test.go b/processor/transaction/payload_test.go index afd51a4cad..7e76f20242 100644 --- a/processor/transaction/payload_test.go +++ b/processor/transaction/payload_test.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package transaction import ( diff --git a/processor/transaction/processor.go b/processor/transaction/processor.go index 124a9e0e58..6a9804c9fd 100644 --- a/processor/transaction/processor.go +++ b/processor/transaction/processor.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package transaction import ( diff --git a/processor/transaction/processor_test.go b/processor/transaction/processor_test.go index a8dade9c08..0c1754f073 100644 --- a/processor/transaction/processor_test.go +++ b/processor/transaction/processor_test.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package transaction import ( diff --git a/processor/transaction/span.go b/processor/transaction/span.go index e497ef90b4..3698d1c94f 100644 --- a/processor/transaction/span.go +++ b/processor/transaction/span.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package transaction import ( diff --git a/processor/transaction/span_context.go b/processor/transaction/span_context.go index 5bf6302124..f7883a510a 100644 --- a/processor/transaction/span_context.go +++ b/processor/transaction/span_context.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package transaction import ( diff --git a/processor/transaction/span_context_test.go b/processor/transaction/span_context_test.go index 401b3cec97..d9d55c694b 100644 --- a/processor/transaction/span_context_test.go +++ b/processor/transaction/span_context_test.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package transaction import ( diff --git a/processor/transaction/span_test.go b/processor/transaction/span_test.go index d780e35b54..1efe07f73c 100644 --- a/processor/transaction/span_test.go +++ b/processor/transaction/span_test.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package transaction import ( diff --git a/processor/validator.go b/processor/validator.go index 3fecc35e17..1c28ff4be8 100644 --- a/processor/validator.go +++ b/processor/validator.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package processor import ( diff --git a/processor/validator_test.go b/processor/validator_test.go index 5fadb38521..51f5d794ac 100644 --- a/processor/validator_test.go +++ b/processor/validator_test.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package processor import ( diff --git a/script/inline_schemas/inline_schemas.go b/script/inline_schemas/inline_schemas.go index a942bd2f75..141d1b0ac5 100644 --- a/script/inline_schemas/inline_schemas.go +++ b/script/inline_schemas/inline_schemas.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package main import ( diff --git a/script/jenkins/ci.ps1 b/script/jenkins/ci.ps1 index b44a90bab1..9693d22c9c 100755 --- a/script/jenkins/ci.ps1 +++ b/script/jenkins/ci.ps1 @@ -18,7 +18,7 @@ $env:PATH = "$env:GOPATH\bin;C:\tools\mingw64\bin;$env:PATH" if (Test-Path -PathType leaf _beats\.go-version) { & gvm --format=powershell $(Get-Content _beats\.go-version) | Invoke-Expression } else { - & gvm --format=powershell 1.10.1 | Invoke-Expression + & gvm --format=powershell 1.10.3 | Invoke-Expression } if (Test-Path "build") { Remove-Item -Recurse -Force build } diff --git a/script/jenkins/ci.sh b/script/jenkins/ci.sh index f5faf6c82e..580b7137b0 100755 --- a/script/jenkins/ci.sh +++ b/script/jenkins/ci.sh @@ -11,7 +11,7 @@ go_file="_beats/.go-version" if [ -f "$go_file" ]; then eval "$(gvm $(cat $go_file))" else - eval "$(gvm 1.10.1)" + eval "$(gvm 1.10.3)" fi # Workaround for Python virtualenv path being too long. diff --git a/script/jenkins/intake.sh b/script/jenkins/intake.sh index 0b748082da..a92ed8e081 100755 --- a/script/jenkins/intake.sh +++ b/script/jenkins/intake.sh @@ -11,7 +11,7 @@ go_file="_beats/.go-version" if [ -f "$go_file" ]; then eval "$(gvm $(cat $go_file))" else - eval "$(gvm 1.10.1)" + eval "$(gvm 1.10.3)" fi # Workaround for Python virtualenv path being too long. diff --git a/script/jenkins/update-beats.sh b/script/jenkins/update-beats.sh index 7a14a8de8f..f58be986c5 100755 --- a/script/jenkins/update-beats.sh +++ b/script/jenkins/update-beats.sh @@ -11,7 +11,7 @@ go_file="_beats/.go-version" if [ -f "$go_file" ]; then eval "$(gvm $(cat $go_file))" else - eval "$(gvm 1.10.1)" + eval "$(gvm 1.10.3)" fi # Workaround for Python virtualenv path being too long. @@ -32,7 +32,7 @@ go_file="_beats/.go-version" if [ -f "$go_file" ]; then eval "$(gvm $(cat $go_file))" else - eval "$(gvm 1.10.1)" + eval "$(gvm 1.10.3)" fi RACE_DETECTOR=1 make clean check testsuite apm-server diff --git a/script/output_data/output_data.go b/script/output_data/output_data.go index 79faf5a4fd..ca7d2aef80 100644 --- a/script/output_data/output_data.go +++ b/script/output_data/output_data.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package main import ( diff --git a/sourcemap/accessor.go b/sourcemap/accessor.go index 7e92e523c6..96e3922803 100644 --- a/sourcemap/accessor.go +++ b/sourcemap/accessor.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package sourcemap import ( diff --git a/sourcemap/accessor_test.go b/sourcemap/accessor_test.go index 6910a7227c..08cfa3a914 100644 --- a/sourcemap/accessor_test.go +++ b/sourcemap/accessor_test.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package sourcemap import ( diff --git a/sourcemap/cache.go b/sourcemap/cache.go index 7debfbb37a..55e9b42af0 100644 --- a/sourcemap/cache.go +++ b/sourcemap/cache.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package sourcemap import ( diff --git a/sourcemap/cache_test.go b/sourcemap/cache_test.go index 586fe499fd..58c992a123 100644 --- a/sourcemap/cache_test.go +++ b/sourcemap/cache_test.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package sourcemap import ( diff --git a/sourcemap/elasticsearch.go b/sourcemap/elasticsearch.go index 56ed6e8131..1804854085 100644 --- a/sourcemap/elasticsearch.go +++ b/sourcemap/elasticsearch.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package sourcemap import ( diff --git a/sourcemap/elasticsearch_test.go b/sourcemap/elasticsearch_test.go index 759bb679df..858aa0069d 100644 --- a/sourcemap/elasticsearch_test.go +++ b/sourcemap/elasticsearch_test.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package sourcemap import ( diff --git a/sourcemap/error.go b/sourcemap/error.go index 7c73c22ea3..d105a166b6 100644 --- a/sourcemap/error.go +++ b/sourcemap/error.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package sourcemap import ( diff --git a/sourcemap/error_test.go b/sourcemap/error_test.go index 22d0f25db1..43969603f8 100644 --- a/sourcemap/error_test.go +++ b/sourcemap/error_test.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package sourcemap import ( diff --git a/sourcemap/id.go b/sourcemap/id.go index a3eba0f633..b5730fb250 100644 --- a/sourcemap/id.go +++ b/sourcemap/id.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package sourcemap import ( diff --git a/sourcemap/id_test.go b/sourcemap/id_test.go index 9b548b11e0..18f71b2aab 100644 --- a/sourcemap/id_test.go +++ b/sourcemap/id_test.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package sourcemap import ( diff --git a/sourcemap/mapper.go b/sourcemap/mapper.go index c8f69241c7..2f38eb77af 100644 --- a/sourcemap/mapper.go +++ b/sourcemap/mapper.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package sourcemap import ( diff --git a/sourcemap/mapper_test.go b/sourcemap/mapper_test.go index 5a9819dd11..1ed3f89161 100644 --- a/sourcemap/mapper_test.go +++ b/sourcemap/mapper_test.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package sourcemap import ( diff --git a/tests/Dockerfile b/tests/Dockerfile index b34c6ae34e..cb88f130f4 100644 --- a/tests/Dockerfile +++ b/tests/Dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.10.1 +FROM golang:1.10.3 MAINTAINER Nicolas Ruflin RUN set -x && \ diff --git a/tests/approvals.go b/tests/approvals.go index 54d28a855e..fff689bfcb 100644 --- a/tests/approvals.go +++ b/tests/approvals.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package tests import ( diff --git a/tests/common.go b/tests/common.go index 05c16a1e6d..9693c276a5 100644 --- a/tests/common.go +++ b/tests/common.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package tests import ( diff --git a/tests/common_bench.go b/tests/common_bench.go index befb36c502..809ae6a794 100644 --- a/tests/common_bench.go +++ b/tests/common_bench.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package tests import ( diff --git a/tests/common_test.go b/tests/common_test.go index 9fcf068f18..80a21ad54c 100644 --- a/tests/common_test.go +++ b/tests/common_test.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package tests import ( diff --git a/tests/fields.go b/tests/fields.go index dc0c2e6f5a..a1b9ae5ee2 100644 --- a/tests/fields.go +++ b/tests/fields.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package tests import ( diff --git a/tests/fields_test.go b/tests/fields_test.go index b4ead56126..f339b173d6 100644 --- a/tests/fields_test.go +++ b/tests/fields_test.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package tests import ( diff --git a/tests/json_schema.go b/tests/json_schema.go index 5d85302fc0..3bad713e21 100644 --- a/tests/json_schema.go +++ b/tests/json_schema.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package tests import ( diff --git a/tests/json_schema_test.go b/tests/json_schema_test.go index ba5e91031a..5c8ada0ba3 100644 --- a/tests/json_schema_test.go +++ b/tests/json_schema_test.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package tests import ( diff --git a/tests/loader/loader.go b/tests/loader/loader.go index acb3f859d3..0bc161f1f3 100644 --- a/tests/loader/loader.go +++ b/tests/loader/loader.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package loader import ( diff --git a/tests/scripts/approvals.go b/tests/scripts/approvals.go index 1211000286..c060cf3a79 100644 --- a/tests/scripts/approvals.go +++ b/tests/scripts/approvals.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package main import ( diff --git a/tests/set.go b/tests/set.go index 4ac4a85507..3a4a2e9f7c 100644 --- a/tests/set.go +++ b/tests/set.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package tests import ( diff --git a/tests/set_test.go b/tests/set_test.go index 06b28943b7..5a525723ca 100644 --- a/tests/set_test.go +++ b/tests/set_test.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package tests import ( diff --git a/utility/common.go b/utility/common.go index 53a30526af..1c43552da1 100644 --- a/utility/common.go +++ b/utility/common.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package utility import ( diff --git a/utility/common_test.go b/utility/common_test.go index dc4d389b2d..efecd26224 100644 --- a/utility/common_test.go +++ b/utility/common_test.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package utility import ( diff --git a/utility/data_fetcher.go b/utility/data_fetcher.go index 5660b16a74..4c063f3ad8 100644 --- a/utility/data_fetcher.go +++ b/utility/data_fetcher.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package utility import ( diff --git a/utility/data_fetcher_test.go b/utility/data_fetcher_test.go index 55438c8493..ceffa8db80 100644 --- a/utility/data_fetcher_test.go +++ b/utility/data_fetcher_test.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package utility import ( diff --git a/utility/forwarded.go b/utility/forwarded.go index 8a8559f04a..f87c108bf6 100644 --- a/utility/forwarded.go +++ b/utility/forwarded.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package utility import ( diff --git a/utility/forwarded_test.go b/utility/forwarded_test.go index 19880a8929..889d1d3393 100644 --- a/utility/forwarded_test.go +++ b/utility/forwarded_test.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package utility_test import ( diff --git a/utility/handlers.go b/utility/handlers.go index c71af47225..08fc2217c2 100644 --- a/utility/handlers.go +++ b/utility/handlers.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package utility import "net/http" diff --git a/utility/ip.go b/utility/ip.go index b72c764c13..01e6617a1a 100644 --- a/utility/ip.go +++ b/utility/ip.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package utility import ( diff --git a/utility/ip_test.go b/utility/ip_test.go index f81f59885d..79bac8e05a 100644 --- a/utility/ip_test.go +++ b/utility/ip_test.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package utility import ( diff --git a/utility/map_str_enhancer.go b/utility/map_str_enhancer.go index 88501af46e..9d4ec41285 100644 --- a/utility/map_str_enhancer.go +++ b/utility/map_str_enhancer.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package utility import ( diff --git a/utility/map_str_enhancer_test.go b/utility/map_str_enhancer_test.go index 6dd7314336..cc267f444b 100644 --- a/utility/map_str_enhancer_test.go +++ b/utility/map_str_enhancer_test.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package utility import ( diff --git a/utility/remoteaddr.go b/utility/remoteaddr.go index e9b5d5ac25..fb589d4c59 100644 --- a/utility/remoteaddr.go +++ b/utility/remoteaddr.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package utility import ( diff --git a/utility/remoteaddr_test.go b/utility/remoteaddr_test.go index 199b9acf1d..be6222c069 100644 --- a/utility/remoteaddr_test.go +++ b/utility/remoteaddr_test.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package utility_test import ( diff --git a/vendor/github.com/elastic/beats/NOTICE.txt b/vendor/github.com/elastic/beats/NOTICE.txt index 9beee5ca77..79c399c92a 100644 --- a/vendor/github.com/elastic/beats/NOTICE.txt +++ b/vendor/github.com/elastic/beats/NOTICE.txt @@ -1,7 +1,7 @@ Elastic Beats Copyright 2014-2018 Elasticsearch BV -This product includes software developed by The Apache Software +This product includes software developed by The Apache Software Foundation (http://www.apache.org/). ========================================================================== @@ -413,8 +413,8 @@ Elasticsearch, B.V. (https://www.elastic.co/). -------------------------------------------------------------------- Dependency: github.com/elastic/go-structform -Version: v0.0.3 -Revision: 0a66add879601f69f55663f4c913c72988218982 +Version: v0.0.4 +Revision: 0ea09ff9b43c387dd183a4088f6d573bf823e4ed License type (autodetected): Apache-2.0 ./vendor/github.com/elastic/go-structform/LICENSE: -------------------------------------------------------------------- @@ -481,14 +481,14 @@ License type (autodetected): Apache-2.0 Apache License 2.0 -------NOTICE----- -Copyright (c) [2009-2011] VMware, Inc. All Rights Reserved. +Copyright (c) [2009-2011] VMware, Inc. All Rights Reserved. -This product is licensed to you under the Apache License, Version 2.0 (the "License"). -You may not use this product except in compliance with the License. +This product is licensed to you under the Apache License, Version 2.0 (the "License"). +You may not use this product except in compliance with the License. This product includes a number of subcomponents with separate copyright notices and license terms. Your use of these -subcomponents is subject to the terms and conditions of the +subcomponents is subject to the terms and conditions of the subcomponent's license, as noted in the LICENSE file. -------------------------------------------------------------------- Dependency: github.com/ericchiang/k8s @@ -720,7 +720,7 @@ Mozilla Public License Version 2.0 means any form of the work other than Source Code Form. 1.7. "Larger Work" - means a work that combines Covered Software with other material, in + means a work that combines Covered Software with other material, in a separate file or files, that is not Covered Software. 1.8. "License" @@ -1396,6 +1396,15 @@ The above copyright notice and this permission notice shall be included in all c THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +-------------------------------------------------------------------- +Dependency: github.com/magefile/mage +Revision: 5e51f9ad1ed0886c5d06a8c46a09703cfc4d9034 +License type (autodetected): Apache-2.0 +./vendor/github.com/magefile/mage/LICENSE: +-------------------------------------------------------------------- +Apache License 2.0 + + -------------------------------------------------------------------- Dependency: github.com/mattn/go-colorable Revision: 941b50ebc6efddf4c41c8e4537a5f68a4e686b24 @@ -1575,6 +1584,16 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +-------------------------------------------------------------------- +Dependency: github.com/OneOfOne/xxhash +Version: v1.2.2 +Revision: 6def279d2ce6c81a79dd1c1be580f03bb216fb8a +License type (autodetected): Apache-2.0 +./vendor/github.com/OneOfOne/xxhash/LICENSE: +-------------------------------------------------------------------- +Apache License 2.0 + + -------------------------------------------------------------------- Dependency: github.com/opencontainers/go-digest Revision: eaa60544f31ccf3b0653b1a118b76d33418ff41b @@ -1612,9 +1631,9 @@ The following is courtesy of our legal counsel: Use and transfer of Docker may be subject to certain restrictions by the -United States and other governments. +United States and other governments. It is your responsibility to ensure that your use and/or transfer does not -violate applicable laws. +violate applicable laws. For more information, please see http://www.bis.doc.gov @@ -1944,8 +1963,8 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------- Dependency: github.com/shirou/gopsutil -Version: v2.18.01 -Revision: c432be29ccce470088d07eea25b3ea7e68a8afbb +Version: v2.18.06 +Revision: 4a180b209f5f494e5923cfce81ea30ba23915877 License type (autodetected): BSD-3-Clause ./vendor/github.com/shirou/gopsutil/LICENSE: -------------------------------------------------------------------- @@ -2177,23 +2196,23 @@ Copyright (c) 2012 - 2013 Mat Ryer and Tyler Bunnell Please consider promoting this project if you find it useful. -Permission is hereby granted, free of charge, to any person -obtaining a copy of this software and associated documentation -files (the "Software"), to deal in the Software without restriction, -including without limitation the rights to use, copy, modify, merge, -publish, distribute, sublicense, and/or sell copies of the Software, -and to permit persons to whom the Software is furnished to do so, +Permission is hereby granted, free of charge, to any person +obtaining a copy of this software and associated documentation +files (the "Software"), to deal in the Software without restriction, +including without limitation the rights to use, copy, modify, merge, +publish, distribute, sublicense, and/or sell copies of the Software, +and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT -OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT +OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------- @@ -2688,13 +2707,13 @@ Copyright (c) 2010-2013 - Gustavo Niemeyer All rights reserved. Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: +modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. + list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. + and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED @@ -2720,13 +2739,13 @@ Copyright (c) 2010-2012 - Gustavo Niemeyer All rights reserved. Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: +modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. + list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. + and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED @@ -2858,13 +2877,13 @@ License type (autodetected): BSD-2-Clause Copyright (c) 2013, Dustin L. Howett. All rights reserved. Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: +modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. + list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. + and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED @@ -2878,7 +2897,7 @@ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. The views and conclusions contained in the software and documentation are those -of the authors and should not be interpreted as representing official policies, +of the authors and should not be interpreted as representing official policies, either expressed or implied, of the FreeBSD Project. -------------------------------------------------------------------------------- diff --git a/vendor/github.com/elastic/beats/dev-tools/generate_notice.py b/vendor/github.com/elastic/beats/dev-tools/generate_notice.py new file mode 100644 index 0000000000..09a4443c96 --- /dev/null +++ b/vendor/github.com/elastic/beats/dev-tools/generate_notice.py @@ -0,0 +1,369 @@ +from __future__ import print_function + +import glob +import os +import datetime +import argparse +import json +import csv +import re + + +def read_file(filename): + + if not os.path.isfile(filename): + print("File not found {}".format(filename)) + return "" + + try: + with open(filename, 'r') as f: + return f.read() + except UnicodeDecodeError: + # try latin-1 + with open(filename, 'r', encoding="ISO-8859-1") as f: + return f.read() + + +def get_library_path(license): + """ + Get the contents up to the vendor folder. + """ + split = license.split(os.sep) + for i, word in reversed(list(enumerate(split))): + if word == "vendor": + return "/".join(split[i + 1:]) + return "/".join(split) + + +def read_versions(vendor): + libs = [] + with open(os.path.join(vendor, "vendor.json")) as f: + govendor = json.load(f) + for package in govendor["package"]: + libs.append(package) + return libs + + +def gather_dependencies(vendor_dirs, overrides=None): + dependencies = {} # lib_path -> [array of lib] + for vendor in vendor_dirs: + libs = read_versions(vendor) + + # walk looking for LICENSE files + for root, dirs, filenames in os.walk(vendor): + licenses = get_licenses(root) + for filename in licenses: + lib_path = get_library_path(root) + lib_search = [l for l in libs if l["path"].startswith(lib_path)] + if len(lib_search) == 0: + print("WARNING: No version information found for: {}".format(lib_path)) + lib = {"path": lib_path} + else: + lib = lib_search[0] + lib["license_file"] = os.path.join(root, filename) + + lib["license_contents"] = read_file(lib["license_file"]) + lib["license_summary"] = detect_license_summary(lib["license_contents"]) + if lib["license_summary"] == "UNKNOWN": + print("WARNING: Unknown license for: {}".format(lib_path)) + + revision = overrides.get(lib_path, {}).get("revision") + if revision: + lib["revision"] = revision + + if lib_path not in dependencies: + dependencies[lib_path] = [lib] + else: + dependencies[lib_path].append(lib) + + # don't walk down into another vendor dir + if "vendor" in dirs: + dirs.remove("vendor") + return dependencies + + +def get_licenses(folder): + """ + Get a list of license files from a given directory. + """ + licenses = [] + for filename in sorted(os.listdir(folder)): + if filename.startswith("LICENSE") and "docs" not in filename: + licenses.append(filename) + elif filename.startswith("APLv2"): # gorhill/cronexpr + licenses.append(filename) + return licenses + + +def has_license(folder): + """ + Checks if a particular repo has a license files. + + There are two cases accepted: + * The folder contains a LICENSE + * The folder only contains subdirectories AND all these + subdirectories contain a LICENSE + """ + if len(get_licenses(folder)) > 0: + return True, "" + + for subdir in os.listdir(folder): + if not os.path.isdir(os.path.join(folder, subdir)): + return False, folder + if len(get_licenses(os.path.join(folder, subdir))) == 0: + return False, os.path.join(folder, subdir) + return True, "" + + +def check_all_have_license_files(vendor_dirs): + """ + Checks that everything in the vendor folders has a license one way + or the other. This doesn't collect the licenses, because the code that + collects the licenses needs to walk the full tree. This one makes sure + that every folder in the `vendor` directories has at least one license. + """ + issues = [] + for vendor in vendor_dirs: + for root, dirs, filenames in os.walk(vendor): + if root.count(os.sep) - vendor.count(os.sep) == 2: # two levels deep + # Two level deep means folders like `github.com/elastic`. + # look for the license in root but also one level up + ok, issue = has_license(root) + if not ok: + print("No license in: {}".format(issue)) + issues.append(issue) + if len(issues) > 0: + raise Exception("I have found licensing issues in the following folders: {}" + .format(issues)) + + +def write_notice_file(f, beat, copyright, dependencies): + + now = datetime.datetime.now() + + # Add header + f.write("{}\n".format(beat)) + f.write("Copyright 2014-{0} {1}\n".format(now.year, copyright)) + f.write("\n") + f.write("This product includes software developed by The Apache Software \n" + + "Foundation (http://www.apache.org/).\n\n") + + # Add licenses for 3rd party libraries + f.write("==========================================================================\n") + f.write("Third party libraries used by the {} project:\n".format(beat)) + f.write("==========================================================================\n\n") + + # Sort licenses by package path, ignore upper / lower case + for key in sorted(dependencies, key=str.lower): + for lib in dependencies[key]: + f.write("\n--------------------------------------------------------------------\n") + f.write("Dependency: {}\n".format(key)) + if "version" in lib: + f.write("Version: {}\n".format(lib["version"])) + if "revision" in lib: + f.write("Revision: {}\n".format(lib["revision"])) + f.write("License type (autodetected): {}\n".format(lib["license_summary"])) + f.write("{}:\n".format(lib["license_file"])) + f.write("--------------------------------------------------------------------\n") + if lib["license_summary"] != "Apache-2.0": + f.write(lib["license_contents"]) + else: + # it's an Apache License, so include only the NOTICE file + f.write("Apache License 2.0\n\n") + + # Skip NOTICE files which are not needed + if os.path.join(os.path.dirname(lib["license_file"])) in SKIP_NOTICE: + continue + + for notice_file in glob.glob(os.path.join(os.path.dirname(lib["license_file"]), "NOTICE*")): + notice_file_hdr = "-------{}-----\n".format(os.path.basename(notice_file)) + f.write(notice_file_hdr) + f.write(read_file(notice_file)) + + +def write_csv_file(csvwriter, dependencies): + csvwriter.writerow(["name", "url", "version", "revision", "license"]) + for key in sorted(dependencies, key=str.lower): + for lib in dependencies[key]: + csvwriter.writerow([key, get_url(key), lib.get("version", ""), lib.get("revision", ""), + lib["license_summary"]]) + + +def get_url(repo): + words = repo.split("/") + if words[0] != "github.com": + return repo + return "https://github.com/{}/{}".format(words[1], words[2]) + + +def create_notice(filename, beat, copyright, vendor_dirs, csvfile, overrides=None): + dependencies = gather_dependencies(vendor_dirs, overrides=overrides) + if not csvfile: + with open(filename, "w+") as f: + write_notice_file(f, beat, copyright, dependencies) + print("Available at {}".format(filename)) + else: + with open(csvfile, "wb") as f: + csvwriter = csv.writer(f) + write_csv_file(csvwriter, dependencies) + print("Available at {}".format(csvfile)) + return dependencies + + +APACHE2_LICENSE_TITLES = [ + "Apache License Version 2.0", + "Apache License, Version 2.0", + re.sub(r"\s+", " ", """Apache License + ============== + + _Version 2.0, January 2004_"""), +] + +MIT_LICENSES = [ + re.sub(r"\s+", " ", """Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + """), + re.sub(r"\s+", " ", """Permission to use, copy, modify, and distribute this software for any +purpose with or without fee is hereby granted, provided that the above +copyright notice and this permission notice appear in all copies."""), +] + +BSD_LICENSE_CONTENTS = [ + re.sub(r"\s+", " ", """Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met:"""), + re.sub(r"\s+", " ", """Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer."""), + re.sub(r"\s+", " ", """Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. +""")] + +BSD_LICENSE_3_CLAUSE = [ + re.sub(r"\s+", " ", """Neither the name of"""), + re.sub(r"\s+", " ", """nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission.""") +] + +BSD_LICENSE_4_CLAUSE = [ + re.sub(r"\s+", " ", """All advertising materials mentioning features or use of this software + must display the following acknowledgement"""), +] + +CC_SA_4_LICENSE_TITLE = [ + "Creative Commons Attribution-ShareAlike 4.0 International" +] + +LGPL_3_LICENSE_TITLE = [ + "GNU LESSER GENERAL PUBLIC LICENSE Version 3" +] + +MPL_LICENSE_TITLES = [ + "Mozilla Public License Version 2.0", + "Mozilla Public License, version 2.0" +] + + +# return SPDX identifiers from https://spdx.org/licenses/ +def detect_license_summary(content): + # replace all white spaces with a single space + content = re.sub(r"\s+", ' ', content) + # replace smart quotes with less intelligent ones + content = content.replace(b'\xe2\x80\x9c', '"').replace(b'\xe2\x80\x9d', '"') + if any(sentence in content[0:1000] for sentence in APACHE2_LICENSE_TITLES): + return "Apache-2.0" + if any(sentence in content[0:1000] for sentence in MIT_LICENSES): + return "MIT" + if all(sentence in content[0:1000] for sentence in BSD_LICENSE_CONTENTS): + if all(sentence in content[0:1000] for sentence in BSD_LICENSE_3_CLAUSE): + if all(sentence in content[0:1000] for sentence in BSD_LICENSE_4_CLAUSE): + return "BSD-4-Clause" + return "BSD-3-Clause" + else: + return "BSD-2-Clause" + if any(sentence in content[0:300] for sentence in MPL_LICENSE_TITLES): + return "MPL-2.0" + if any(sentence in content[0:3000] for sentence in CC_SA_4_LICENSE_TITLE): + return "CC-BY-SA-4.0" + if any(sentence in content[0:3000] for sentence in LGPL_3_LICENSE_TITLE): + return "LGPL-3.0" + + return "UNKNOWN" + + +ACCEPTED_LICENSES = [ + "Apache-2.0", + "MIT", + "BSD-4-Clause", + "BSD-3-Clause", + "BSD-2-Clause", + "MPL-2.0", +] +SKIP_NOTICE = [] + +if __name__ == "__main__": + + parser = argparse.ArgumentParser( + description="Generate the NOTICE file from all vendor directories available in a given directory") + parser.add_argument("vendor", + help="directory where to search for vendor directories") + parser.add_argument("-b", "--beat", default="Elastic Beats", + help="Beat name") + parser.add_argument("-c", "--copyright", default="Elasticsearch BV", + help="copyright owner") + parser.add_argument("--csv", dest="csvfile", + help="Output to a csv file") + parser.add_argument("-e", "--excludes", default=["dev-tools", "build"], + help="List of top directories to exclude") + # no need to be generic for now, no other transitive dependency information available + parser.add_argument("--beats-origin", type=argparse.FileType('r'), + help="path to beats vendor.json") + parser.add_argument("-s", "--skip-notice", default=[], + help="List of NOTICE files to skip") + args = parser.parse_args() + + cwd = os.getcwd() + notice = os.path.join(cwd, "NOTICE.txt") + vendor_dirs = [] + + excludes = args.excludes + if not isinstance(excludes, list): + excludes = [excludes] + SKIP_NOTICE = args.skip_notice + + for root, dirs, files in os.walk(args.vendor): + + # Skips all hidden paths like ".git" + if '/.' in root: + continue + + if 'vendor' in dirs: + vendor_dirs.append(os.path.join(root, 'vendor')) + dirs.remove('vendor') # don't walk down into sub-vendors + + for exclude in excludes: + if exclude in dirs: + dirs.remove(exclude) + + overrides = {} # revision overrides only for now + if args.beats_origin: + govendor = json.load(args.beats_origin) + overrides = {package['path']: package for package in govendor["package"]} + + print("Get the licenses available from {}".format(vendor_dirs)) + check_all_have_license_files(vendor_dirs) + dependencies = create_notice(notice, args.beat, args.copyright, vendor_dirs, args.csvfile, overrides=overrides) + + # check that all licenses are accepted + for _, deps in dependencies.items(): + for dep in deps: + if dep["license_summary"] not in ACCEPTED_LICENSES: + raise Exception("Dependency {} has invalid license {}" + .format(dep["path"], dep["license_summary"])) diff --git a/vendor/github.com/elastic/beats/dev-tools/mage/build.go b/vendor/github.com/elastic/beats/dev-tools/mage/build.go new file mode 100644 index 0000000000..86bd420930 --- /dev/null +++ b/vendor/github.com/elastic/beats/dev-tools/mage/build.go @@ -0,0 +1,144 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package mage + +import ( + "fmt" + "go/build" + "log" + "os" + "path/filepath" + "strings" + + "github.com/magefile/mage/sh" + "github.com/pkg/errors" +) + +// BuildArgs are the arguments used for the "build" target and they define how +// "go build" is invoked. +type BuildArgs struct { + Name string // Name of binary. (On Windows '.exe' is appended.) + OutputDir string + CGO bool + Static bool + Env map[string]string + LDFlags []string + Vars map[string]string // Vars that are passed as -X key=value with the ldflags. + ExtraFlags []string +} + +// DefaultBuildArgs returns the default BuildArgs for use in builds. +func DefaultBuildArgs() BuildArgs { + args := BuildArgs{ + Name: BeatName, + CGO: build.Default.CgoEnabled, + Vars: map[string]string{ + "github.com/elastic/beats/libbeat/version.buildTime": "{{ date }}", + "github.com/elastic/beats/libbeat/version.commit": "{{ commit }}", + }, + } + + repo, err := GetProjectRepoInfo() + if err != nil { + panic(errors.Wrap(err, "failed to determine project repo info")) + } + + if !repo.IsElasticBeats() { + // Assume libbeat is vendored and prefix the variables. + prefix := repo.RootImportPath + "/vendor/" + prefixedVars := map[string]string{} + for k, v := range args.Vars { + prefixedVars[prefix+k] = v + } + args.Vars = prefixedVars + } + + return args +} + +// DefaultGolangCrossBuildArgs returns the default BuildArgs for use in +// cross-builds. +func DefaultGolangCrossBuildArgs() BuildArgs { + args := DefaultBuildArgs() + args.Name += "-" + Platform.GOOS + "-" + Platform.Arch + args.OutputDir = filepath.Join("build", "golang-crossbuild") + if bp, found := BuildPlatforms.Get(Platform.Name); found { + args.CGO = bp.Flags.SupportsCGO() + } + return args +} + +// GolangCrossBuild invokes "go build" inside of the golang-crossbuild Docker +// environment. +func GolangCrossBuild(params BuildArgs) error { + if os.Getenv("GOLANG_CROSSBUILD") != "1" { + return errors.New("Use the crossBuild target. golangCrossBuild can " + + "only be executed within the golang-crossbuild docker environment.") + } + + defer DockerChown(filepath.Join(params.OutputDir, params.Name+binaryExtension(GOOS))) + return Build(params) +} + +// Build invokes "go build" to produce a binary. +func Build(params BuildArgs) error { + fmt.Println(">> build: Building", params.Name) + + binaryName := params.Name + binaryExtension(GOOS) + + if params.OutputDir != "" { + if err := os.MkdirAll(params.OutputDir, 0755); err != nil { + return err + } + } + + // Environment + env := params.Env + if env == nil { + env = map[string]string{} + } + cgoEnabled := "0" + if params.CGO { + cgoEnabled = "1" + } + env["CGO_ENABLED"] = cgoEnabled + + // Spec + args := []string{ + "build", + "-o", + filepath.Join(params.OutputDir, binaryName), + } + args = append(args, params.ExtraFlags...) + + // ldflags + ldflags := params.LDFlags + if params.Static { + ldflags = append(ldflags, `-extldflags '-static'`) + } + for k, v := range params.Vars { + ldflags = append(ldflags, fmt.Sprintf("-X %v=%v", k, v)) + } + if len(ldflags) > 0 { + args = append(args, "-ldflags") + args = append(args, MustExpand(strings.Join(ldflags, " "))) + } + + log.Println("Adding build environment vars:", env) + return sh.RunWith(env, "go", args...) +} diff --git a/vendor/github.com/elastic/beats/dev-tools/mage/clean.go b/vendor/github.com/elastic/beats/dev-tools/mage/clean.go new file mode 100644 index 0000000000..912d372e1d --- /dev/null +++ b/vendor/github.com/elastic/beats/dev-tools/mage/clean.go @@ -0,0 +1,54 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package mage + +import ( + "github.com/magefile/mage/sh" +) + +// DefaultCleanPaths specifies a list of files or paths to recursively delete. +// The values may contain variables and will be expanded at the time of use. +var DefaultCleanPaths = []string{ + "build", + "docker-compose.yml.lock", + "{{.BeatName}}", + "{{.BeatName}}.exe", + "{{.BeatName}}.test", + "{{.BeatName}}.test.exe", + "fields.yml", + "_meta/fields.generated.yml", + "_meta/kibana.generated", + "_meta/kibana/5/index-pattern/{{.BeatName}}.json", + "_meta/kibana/6/index-pattern/{{.BeatName}}.json", +} + +// Clean clean generated build artifacts. +func Clean(pathLists ...[]string) error { + if len(pathLists) == 0 { + pathLists = [][]string{DefaultCleanPaths} + } + for _, paths := range pathLists { + for _, f := range paths { + f = MustExpand(f) + if err := sh.Rm(f); err != nil { + return err + } + } + } + return nil +} diff --git a/vendor/github.com/elastic/beats/dev-tools/mage/common.go b/vendor/github.com/elastic/beats/dev-tools/mage/common.go new file mode 100644 index 0000000000..1ab47d6b5d --- /dev/null +++ b/vendor/github.com/elastic/beats/dev-tools/mage/common.go @@ -0,0 +1,690 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package mage + +import ( + "archive/tar" + "archive/zip" + "bufio" + "bytes" + "compress/gzip" + "context" + "crypto/sha256" + "crypto/sha512" + "encoding/hex" + "encoding/json" + "fmt" + "io" + "io/ioutil" + "log" + "net/http" + "os" + "path/filepath" + "regexp" + "runtime" + "strconv" + "strings" + "sync" + "text/template" + "time" + "unicode" + + "github.com/magefile/mage/sh" + "github.com/magefile/mage/target" + "github.com/magefile/mage/types" + "github.com/pkg/errors" +) + +// Expand expands the given Go text/template string. +func Expand(in string, args ...map[string]interface{}) (string, error) { + return expandTemplate("inline", in, FuncMap, EnvMap(args...)) +} + +// MustExpand expands the given Go text/template string. It panics if there is +// an error. +func MustExpand(in string, args ...map[string]interface{}) string { + out, err := Expand(in, args...) + if err != nil { + panic(err) + } + return out +} + +// ExpandFile expands the Go text/template read from src and writes the output +// to dst. +func ExpandFile(src, dst string, args ...map[string]interface{}) error { + return expandFile(src, dst, EnvMap(args...)) +} + +// MustExpandFile expands the Go text/template read from src and writes the +// output to dst. It panics if there is an error. +func MustExpandFile(src, dst string, args ...map[string]interface{}) { + if err := ExpandFile(src, dst, args...); err != nil { + panic(err) + } +} + +func expandTemplate(name, tmpl string, funcs template.FuncMap, args ...map[string]interface{}) (string, error) { + t := template.New(name).Option("missingkey=error") + if len(funcs) > 0 { + t = t.Funcs(funcs) + } + + t, err := t.Parse(tmpl) + if err != nil { + if name == "inline" { + return "", errors.Wrapf(err, "failed to parse template '%v'", tmpl) + } + return "", errors.Wrap(err, "failed to parse template") + } + + buf := new(bytes.Buffer) + if err := t.Execute(buf, joinMaps(args...)); err != nil { + if name == "inline" { + return "", errors.Wrapf(err, "failed to expand template '%v'", tmpl) + } + return "", errors.Wrap(err, "failed to expand template") + } + + return buf.String(), nil +} + +func joinMaps(args ...map[string]interface{}) map[string]interface{} { + switch len(args) { + case 0: + return nil + case 1: + return args[0] + } + + var out map[string]interface{} + for _, m := range args { + for k, v := range m { + out[k] = v + } + } + return out +} + +func expandFile(src, dst string, args ...map[string]interface{}) error { + tmplData, err := ioutil.ReadFile(src) + if err != nil { + return errors.Wrapf(err, "failed reading from template %v", src) + } + + output, err := expandTemplate(src, string(tmplData), FuncMap, args...) + if err != nil { + return err + } + + dst, err = expandTemplate("inline", dst, FuncMap, args...) + if err != nil { + return err + } + + if err = ioutil.WriteFile(createDir(dst), []byte(output), 0644); err != nil { + return errors.Wrap(err, "failed to write rendered template") + } + + return nil +} + +// CWD return the current working directory. +func CWD() string { + wd, err := os.Getwd() + if err != nil { + panic(errors.Wrap(err, "failed to get the CWD")) + } + return wd +} + +// EnvOr returns the value of the specified environment variable if it is +// non-empty. Otherwise it return def. +func EnvOr(name, def string) string { + s := os.Getenv(name) + if s == "" { + return def + } + return s +} + +var ( + dockerInfoValue *DockerInfo + dockerInfoErr error + dockerInfoOnce sync.Once +) + +// DockerInfo contains information about the docker daemon. +type DockerInfo struct { + OperatingSystem string `json:"OperatingSystem"` + Labels []string `json:"Labels"` + NCPU int `json:"NCPU"` + MemTotal int `json:"MemTotal"` +} + +// IsBoot2Docker returns true if the Docker OS is boot2docker. +func (info *DockerInfo) IsBoot2Docker() bool { + return strings.Contains(strings.ToLower(info.OperatingSystem), "boot2docker") +} + +// HaveDocker returns an error if docker is unavailable. +func HaveDocker() error { + if _, err := GetDockerInfo(); err != nil { + return errors.Wrap(err, "docker is not available") + } + return nil +} + +// GetDockerInfo returns data from the docker info command. +func GetDockerInfo() (*DockerInfo, error) { + dockerInfoOnce.Do(func() { + dockerInfoValue, dockerInfoErr = dockerInfo() + }) + + return dockerInfoValue, dockerInfoErr +} + +func dockerInfo() (*DockerInfo, error) { + data, err := sh.Output("docker", "info", "-f", "{{ json .}}") + if err != nil { + return nil, err + } + + var info DockerInfo + if err = json.Unmarshal([]byte(data), &info); err != nil { + return nil, err + } + + return &info, nil +} + +// FindReplace reads a file, performs a find/replace operation, then writes the +// output to the same file path. +func FindReplace(file string, re *regexp.Regexp, repl string) error { + info, err := os.Stat(file) + if err != nil { + return err + } + + contents, err := ioutil.ReadFile(file) + if err != nil { + return err + } + + out := re.ReplaceAllString(string(contents), repl) + return ioutil.WriteFile(file, []byte(out), info.Mode().Perm()) +} + +// MustFindReplace invokes FindReplace and panics if an error occurs. +func MustFindReplace(file string, re *regexp.Regexp, repl string) { + if err := FindReplace(file, re, repl); err != nil { + panic(errors.Wrap(err, "failed to find and replace")) + } +} + +// Copy copies a file or a directory (recursively) and preserves the permissions. +func Copy(src, dest string) error { + info, err := os.Stat(src) + if err != nil { + return errors.Wrapf(err, "failed to stat source file %v", src) + } + return recursiveCopy(src, dest, info) +} + +func fileCopy(src, dest string, info os.FileInfo) error { + srcFile, err := os.Open(src) + if err != nil { + return err + } + defer srcFile.Close() + + if !info.Mode().IsRegular() { + return errors.Errorf("failed to copy source file because it is not a regular file") + } + + destFile, err := os.OpenFile(createDir(dest), os.O_CREATE|os.O_TRUNC|os.O_WRONLY, info.Mode()&os.ModePerm) + if err != nil { + return err + } + defer destFile.Close() + + if _, err = io.Copy(destFile, srcFile); err != nil { + return err + } + return destFile.Close() +} + +func dirCopy(src, dest string, info os.FileInfo) error { + if err := os.MkdirAll(dest, info.Mode()); err != nil { + return errors.Wrap(err, "failed creating dirs") + } + + contents, err := ioutil.ReadDir(src) + if err != nil { + return errors.Wrapf(err, "failed to read dir %v", src) + } + + for _, info := range contents { + srcFile := filepath.Join(src, info.Name()) + destFile := filepath.Join(dest, info.Name()) + if err = recursiveCopy(srcFile, destFile, info); err != nil { + return errors.Wrapf(err, "failed to copy %v to %v", srcFile, destFile) + } + } + + return nil +} + +func recursiveCopy(src, dest string, info os.FileInfo) error { + if info.IsDir() { + return dirCopy(src, dest, info) + } + return fileCopy(src, dest, info) +} + +// DownloadFile downloads the given URL and writes the file to destinationDir. +// The path to the file is returned. +func DownloadFile(url, destinationDir string) (string, error) { + log.Println("Downloading", url) + + resp, err := http.Get(url) + if err != nil { + return "", errors.Wrap(err, "http get failed") + } + defer resp.Body.Close() + + if resp.StatusCode != http.StatusOK { + return "", errors.Errorf("download failed with http status: %v", resp.StatusCode) + } + + name := filepath.Join(destinationDir, filepath.Base(url)) + f, err := os.Create(createDir(name)) + if err != nil { + return "", errors.Wrap(err, "failed to create output file") + } + defer f.Close() + + if _, err = io.Copy(f, resp.Body); err != nil { + return "", errors.Wrap(err, "failed to write file") + } + + return name, f.Close() +} + +// Extract extracts .zip, .tar.gz, or .tgz files to destinationDir. +func Extract(sourceFile, destinationDir string) error { + ext := filepath.Ext(sourceFile) + switch { + case strings.HasSuffix(sourceFile, ".tar.gz"), ext == ".tgz": + return untar(sourceFile, destinationDir) + case ext == ".zip": + return unzip(sourceFile, destinationDir) + default: + return errors.Errorf("failed to extract %v, unhandled file extension", sourceFile) + } +} + +func unzip(sourceFile, destinationDir string) error { + r, err := zip.OpenReader(sourceFile) + if err != nil { + return err + } + defer r.Close() + + if err = os.MkdirAll(destinationDir, 0755); err != nil { + return err + } + + extractAndWriteFile := func(f *zip.File) error { + innerFile, err := f.Open() + if err != nil { + return err + } + defer innerFile.Close() + + path := filepath.Join(destinationDir, f.Name) + if !strings.HasPrefix(path, destinationDir) { + return errors.Errorf("illegal file path in zip: %v", f.Name) + } + + if f.FileInfo().IsDir() { + return os.MkdirAll(path, f.Mode()) + } + + if err = os.MkdirAll(filepath.Dir(path), 0755); err != nil { + return err + } + + out, err := os.OpenFile(path, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, f.Mode()) + if err != nil { + return err + } + defer out.Close() + + if _, err = io.Copy(out, innerFile); err != nil { + return err + } + + return out.Close() + } + + for _, f := range r.File { + err := extractAndWriteFile(f) + if err != nil { + return err + } + } + + return nil +} + +func untar(sourceFile, destinationDir string) error { + file, err := os.Open(sourceFile) + if err != nil { + return err + } + defer file.Close() + + var fileReader io.ReadCloser = file + + if strings.HasSuffix(sourceFile, ".gz") { + if fileReader, err = gzip.NewReader(file); err != nil { + return err + } + defer fileReader.Close() + } + + tarReader := tar.NewReader(fileReader) + + for { + header, err := tarReader.Next() + if err != nil { + if err == io.EOF { + break + } + return err + } + + path := filepath.Join(destinationDir, header.Name) + if !strings.HasPrefix(path, destinationDir) { + return errors.Errorf("illegal file path in tar: %v", header.Name) + } + + switch header.Typeflag { + case tar.TypeDir: + if err = os.MkdirAll(path, os.FileMode(header.Mode)); err != nil { + return err + } + case tar.TypeReg: + writer, err := os.Create(path) + if err != nil { + return err + } + + if _, err = io.Copy(writer, tarReader); err != nil { + return err + } + + if err = os.Chmod(path, os.FileMode(header.Mode)); err != nil { + return err + } + + if err = writer.Close(); err != nil { + return err + } + default: + return errors.Errorf("unable to untar type=%c in file=%s", header.Typeflag, path) + } + } + + return nil +} + +func isSeparator(r rune) bool { + return unicode.IsSpace(r) || r == ',' || r == ';' +} + +// RunCmds runs the given commands and stops upon the first error. +func RunCmds(cmds ...[]string) error { + for _, cmd := range cmds { + if err := sh.Run(cmd[0], cmd[1:]...); err != nil { + return err + } + } + return nil +} + +var ( + parallelJobsLock sync.Mutex + parallelJobsSemaphore chan int +) + +func parallelJobs() chan int { + parallelJobsLock.Lock() + defer parallelJobsLock.Unlock() + + if parallelJobsSemaphore == nil { + max := numParallel() + parallelJobsSemaphore = make(chan int, max) + log.Println("Max parallel jobs =", max) + } + + return parallelJobsSemaphore +} + +func numParallel() int { + if maxParallel := os.Getenv("MAX_PARALLEL"); maxParallel != "" { + if num, err := strconv.Atoi(maxParallel); err == nil && num > 0 { + return num + } + } + + // To be conservative use the minimum of the number of CPUs between the host + // and the Docker host. + maxParallel := runtime.NumCPU() + + info, err := GetDockerInfo() + if err == nil && info.NCPU < maxParallel { + maxParallel = info.NCPU + } + + return maxParallel +} + +// ParallelCtx runs the given functions in parallel with an upper limit set +// based on GOMAXPROCS. The provided ctx is passed to the functions (if they +// accept it as a param). +func ParallelCtx(ctx context.Context, fns ...interface{}) { + var fnWrappers []func(context.Context) error + for _, f := range fns { + fnWrapper := types.FuncTypeWrap(f) + if fnWrapper == nil { + panic("attempted to add a dep that did not match required function type") + } + fnWrappers = append(fnWrappers, fnWrapper) + } + + var mu sync.Mutex + var errs []string + var wg sync.WaitGroup + + for _, fw := range fnWrappers { + wg.Add(1) + go func(fw func(context.Context) error) { + defer func() { + if v := recover(); v != nil { + mu.Lock() + errs = append(errs, fmt.Sprint(v)) + mu.Unlock() + } + wg.Done() + <-parallelJobs() + }() + waitStart := time.Now() + parallelJobs() <- 1 + log.Println("Parallel job waited", time.Since(waitStart), "before starting.") + if err := fw(ctx); err != nil { + mu.Lock() + errs = append(errs, fmt.Sprint(err)) + mu.Unlock() + } + }(fw) + } + + wg.Wait() + if len(errs) > 0 { + panic(errors.Errorf(strings.Join(errs, "\n"))) + } +} + +// Parallel runs the given functions in parallel with an upper limit set based +// on GOMAXPROCS. +func Parallel(fns ...interface{}) { + ParallelCtx(context.Background(), fns...) +} + +// FindFiles return a list of file matching the given glob patterns. +func FindFiles(globs ...string) ([]string, error) { + var configFiles []string + for _, glob := range globs { + files, err := filepath.Glob(glob) + if err != nil { + return nil, errors.Wrapf(err, "failed on glob %v", glob) + } + configFiles = append(configFiles, files...) + } + return configFiles, nil +} + +// FileConcat concatenates files and writes the output to out. +func FileConcat(out string, perm os.FileMode, files ...string) error { + f, err := os.OpenFile(createDir(out), os.O_CREATE|os.O_TRUNC|os.O_WRONLY, perm) + if err != nil { + return errors.Wrap(err, "failed to create file") + } + defer f.Close() + + w := bufio.NewWriter(f) + + append := func(file string) error { + in, err := os.Open(file) + if err != nil { + return err + } + defer in.Close() + + if _, err := io.Copy(w, in); err != nil { + return err + } + + return nil + } + + for _, in := range files { + if err := append(in); err != nil { + return err + } + } + + if err = w.Flush(); err != nil { + return err + } + return f.Close() +} + +// MustFileConcat invokes FileConcat and panics if an error occurs. +func MustFileConcat(out string, perm os.FileMode, files ...string) { + if err := FileConcat(out, perm, files...); err != nil { + panic(err) + } +} + +// VerifySHA256 reads a file and verifies that its SHA256 sum matches the +// specified hash. +func VerifySHA256(file string, hash string) error { + f, err := os.Open(file) + if err != nil { + return errors.Wrap(err, "failed to open file for sha256 verification") + } + defer f.Close() + + sum := sha256.New() + if _, err := io.Copy(sum, f); err != nil { + return errors.Wrap(err, "failed reading from input file") + } + + computedHash := hex.EncodeToString(sum.Sum(nil)) + expectedHash := strings.TrimSpace(hash) + + if computedHash != expectedHash { + return errors.Errorf("SHA256 verification of %v failed. Expected=%v, "+ + "but computed=%v", f.Name(), expectedHash, computedHash) + } + log.Println("SHA256 OK:", f.Name()) + + return nil +} + +// CreateSHA512File computes the sha512 sum of the specified file the writes +// a sidecar file containing the hash and filename. +func CreateSHA512File(file string) error { + f, err := os.Open(file) + if err != nil { + return errors.Wrap(err, "failed to open file for sha512 summing") + } + defer f.Close() + + sum := sha512.New() + if _, err := io.Copy(sum, f); err != nil { + return errors.Wrap(err, "failed reading from input file") + } + + computedHash := hex.EncodeToString(sum.Sum(nil)) + out := fmt.Sprintf("%v %v", computedHash, filepath.Base(file)) + + return ioutil.WriteFile(file+".sha512", []byte(out), 0644) +} + +// IsUpToDate returns true iff dst exists and is older based on modtime than all +// of the sources. +func IsUpToDate(dst string, sources ...string) bool { + if len(sources) == 0 { + panic("No sources passed to IsUpToDate") + } + execute, err := target.Path(dst, sources...) + return err == nil && !execute +} + +// createDir creates the parent directory for the given file. +func createDir(file string) string { + // Create the output directory. + if dir := filepath.Dir(file); dir != "." { + if err := os.MkdirAll(dir, 0755); err != nil { + panic(errors.Wrapf(err, "failed to create parent dir for %v", file)) + } + } + return file +} + +// binaryExtension returns the appropriate file extension based on GOOS. +func binaryExtension(goos string) string { + if goos == "windows" { + return ".exe" + } + return "" +} diff --git a/vendor/github.com/elastic/beats/dev-tools/mage/crossbuild.go b/vendor/github.com/elastic/beats/dev-tools/mage/crossbuild.go new file mode 100644 index 0000000000..4a41cde080 --- /dev/null +++ b/vendor/github.com/elastic/beats/dev-tools/mage/crossbuild.go @@ -0,0 +1,239 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package mage + +import ( + "fmt" + "log" + "os" + "path/filepath" + "runtime" + "strconv" + "strings" + + "github.com/magefile/mage/mg" + "github.com/magefile/mage/sh" + "github.com/pkg/errors" +) + +const defaultCrossBuildTarget = "golangCrossBuild" + +// Platforms contains the set of target platforms for cross-builds. It can be +// modified at runtime by setting the PLATFORMS environment variable. +// See NewPlatformList for details about platform filtering expressions. +var Platforms = BuildPlatforms.Defaults() + +func init() { + // Allow overriding via PLATFORMS. + if expression := os.Getenv("PLATFORMS"); len(expression) > 0 { + Platforms = NewPlatformList(expression) + } +} + +// CrossBuildOption defines a option to the CrossBuild target. +type CrossBuildOption func(params *crossBuildParams) + +// ForPlatforms filters the platforms based on the given expression. +func ForPlatforms(expr string) func(params *crossBuildParams) { + return func(params *crossBuildParams) { + params.Platforms = params.Platforms.Filter(expr) + } +} + +// WithTarget specifies the mage target to execute inside the golang-crossbuild +// container. +func WithTarget(target string) func(params *crossBuildParams) { + return func(params *crossBuildParams) { + params.Target = target + } +} + +// Serially causes each cross-build target to be executed serially instead of +// in parallel. +func Serially() func(params *crossBuildParams) { + return func(params *crossBuildParams) { + params.Serial = true + } +} + +type crossBuildParams struct { + Platforms BuildPlatformList + Target string + Serial bool +} + +// CrossBuild executes a given build target once for each target platform. +func CrossBuild(options ...CrossBuildOption) error { + params := crossBuildParams{Platforms: Platforms, Target: defaultCrossBuildTarget} + for _, opt := range options { + opt(¶ms) + } + + // Docker is required for this target. + if err := HaveDocker(); err != nil { + return err + } + + if len(params.Platforms) == 0 { + log.Printf("Skipping cross-build of target=%v because platforms list is empty.", params.Target) + return nil + } + + // Build the magefile for Linux so we can run it inside the container. + mg.Deps(buildMage) + + log.Println("crossBuild: Platform list =", params.Platforms) + var deps []interface{} + for _, buildPlatform := range params.Platforms { + if !buildPlatform.Flags.CanCrossBuild() { + return fmt.Errorf("unsupported cross build platform %v", buildPlatform.Name) + } + + builder := GolangCrossBuilder{buildPlatform.Name, params.Target} + if params.Serial { + if err := builder.Build(); err != nil { + return errors.Wrapf(err, "failed cross-building target=%v for platform=%v", + params.Target, buildPlatform.Name) + } + } else { + deps = append(deps, builder.Build) + } + } + + // Each build runs in parallel. + Parallel(deps...) + return nil +} + +// buildMage pre-compiles the magefile to a binary using the native GOOS/GOARCH +// values for Docker. This is required to so that we can later pass GOOS and +// GOARCH to mage for the cross-build. It has the benefit of speeding up the +// build because the mage -compile is done only once rather than in each Docker +// container. +func buildMage() error { + env := map[string]string{ + "GOOS": "linux", + "GOARCH": "amd64", + } + return sh.RunWith(env, "mage", "-f", "-compile", filepath.Join("build", "mage-linux-amd64")) +} + +func crossBuildImage(platform string) (string, error) { + tagSuffix := "main" + + switch { + case strings.HasPrefix(platform, "darwin"): + tagSuffix = "darwin" + case strings.HasPrefix(platform, "linux/arm"): + tagSuffix = "arm" + case strings.HasPrefix(platform, "linux/mips"): + tagSuffix = "mips" + case strings.HasPrefix(platform, "linux/ppc"): + tagSuffix = "ppc" + case platform == "linux/s390x": + tagSuffix = "s390x" + case strings.HasPrefix(platform, "linux"): + // Use an older version of libc to gain greater OS compatibility. + // Debian 7 uses glibc 2.13. + tagSuffix = "main-debian7" + } + + goVersion, err := GoVersion() + if err != nil { + return "", err + } + + return beatsCrossBuildImage + ":" + goVersion + "-" + tagSuffix, nil +} + +// GolangCrossBuilder executes the specified mage target inside of the +// associated golang-crossbuild container image for the platform. +type GolangCrossBuilder struct { + Platform string + Target string +} + +// Build executes the build inside of Docker. +func (b GolangCrossBuilder) Build() error { + fmt.Printf(">> %v: Building for %v\n", b.Target, b.Platform) + + repoInfo, err := GetProjectRepoInfo() + if err != nil { + return errors.Wrap(err, "failed to determine repo root and package sub dir") + } + + mountPoint := filepath.ToSlash(filepath.Join("/go", "src", repoInfo.RootImportPath)) + workDir := mountPoint + if repoInfo.SubDir != "" { + workDir = filepath.ToSlash(filepath.Join(workDir, repoInfo.SubDir)) + } + + dockerRun := sh.RunCmd("docker", "run") + image, err := crossBuildImage(b.Platform) + if err != nil { + return errors.Wrap(err, "failed to determine golang-crossbuild image tag") + } + verbose := "" + if mg.Verbose() { + verbose = "true" + } + var args []string + if runtime.GOOS != "windows" { + args = append(args, + "--env", "EXEC_UID="+strconv.Itoa(os.Getuid()), + "--env", "EXEC_GID="+strconv.Itoa(os.Getgid()), + ) + } + args = append(args, + "--rm", + "--env", "MAGEFILE_VERBOSE="+verbose, + "--env", "MAGEFILE_TIMEOUT="+EnvOr("MAGEFILE_TIMEOUT", ""), + "-v", repoInfo.RootDir+":"+mountPoint, + "-w", workDir, + image, + "--build-cmd", "build/mage-linux-amd64 "+b.Target, + "-p", b.Platform, + ) + + return dockerRun(args...) +} + +// DockerChown chowns files generated during build. EXEC_UID and EXEC_GID must +// be set in the containers environment otherwise this is a noop. +func DockerChown(file string) { + // Chown files generated during build that are root owned. + uid, _ := strconv.Atoi(EnvOr("EXEC_UID", "-1")) + gid, _ := strconv.Atoi(EnvOr("EXEC_GID", "-1")) + if uid > 0 && gid > 0 { + if err := chownPaths(uid, gid, file); err != nil { + log.Println(err) + } + } +} + +// chownPaths will chown the file and all of the dirs specified in the path. +func chownPaths(uid, gid int, file string) error { + pathParts := strings.Split(file, string(filepath.Separator)) + for i := range pathParts { + chownDir := filepath.Join(pathParts[:i+1]...) + if err := os.Chown(chownDir, uid, gid); err != nil { + return errors.Wrapf(err, "failed to chown path=%v", chownDir) + } + } + return nil +} diff --git a/vendor/github.com/elastic/beats/dev-tools/mage/godaemon.go b/vendor/github.com/elastic/beats/dev-tools/mage/godaemon.go new file mode 100644 index 0000000000..0f4cb2c0ec --- /dev/null +++ b/vendor/github.com/elastic/beats/dev-tools/mage/godaemon.go @@ -0,0 +1,72 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package mage + +import ( + "errors" + "log" + "os" +) + +// BuildGoDaemon builds the go-deamon binary. +func BuildGoDaemon() error { + if GOOS != "linux" { + return errors.New("go-daemon only builds for linux") + } + + if os.Getenv("GOLANG_CROSSBUILD") != "1" { + return errors.New("Use the crossBuildGoDaemon target. buildGoDaemon can " + + "only be executed within the golang-crossbuild docker environment.") + } + + // Test if binaries are up-to-date. + output := MustExpand("build/golang-crossbuild/god-{{.Platform.GOOS}}-{{.Platform.Arch}}") + input := MustExpand("{{ elastic_beats_dir }}/dev-tools/vendor/github.com/tsg/go-daemon/god.c") + if IsUpToDate(output, input) { + log.Println(">>> buildGoDaemon is up-to-date for", Platform.Name) + return nil + } + + // Determine what compiler to use based on CC that is set by golang-crossbuild. + cc := os.Getenv("CC") + if cc == "" { + cc = "cc" + } + + compileCmd := []string{ + cc, + input, + "-o", createDir(output), + "-lpthread", "-static", + } + switch Platform.Name { + case "linux/amd64": + compileCmd = append(compileCmd, "-m64") + case "linux/386": + compileCmd = append(compileCmd, "-m32") + } + + defer DockerChown(output) + return RunCmds(compileCmd) +} + +// CrossBuildGoDaemon cross-build the go-daemon binary using the +// golang-crossbuild environment. +func CrossBuildGoDaemon() error { + return CrossBuild(ForPlatforms("linux"), WithTarget("buildGoDaemon")) +} diff --git a/vendor/github.com/elastic/beats/dev-tools/mage/pkg.go b/vendor/github.com/elastic/beats/dev-tools/mage/pkg.go new file mode 100644 index 0000000000..688e5c2211 --- /dev/null +++ b/vendor/github.com/elastic/beats/dev-tools/mage/pkg.go @@ -0,0 +1,108 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package mage + +import ( + "fmt" + "log" + + "github.com/magefile/mage/mg" + "github.com/magefile/mage/sh" + "github.com/pkg/errors" +) + +// Package packages the Beat for distribution. It generates packages based on +// the set of target plaforms and registered packaging specifications. +func Package() error { + if len(Platforms) == 0 { + return errors.New("PLATFORMS environment must be set to a list of " + + "GOOS/Arch values, but Platforms is empty") + } + + if len(Packages) == 0 { + return errors.New("no package specs are registered. Call " + + "UseCommunityBeatPackaging or UseElasticBeatPackaging first.") + } + + var tasks []interface{} + for _, target := range Platforms { + for _, pkg := range Packages { + if pkg.OS != target.GOOS() { + continue + } + + for _, pkgType := range pkg.Types { + packageArch, err := getOSArchName(target, pkgType) + if err != nil { + log.Printf("Skipping arch %v for package type %v: %v", target.Arch(), pkgType, err) + continue + } + + spec := pkg.Spec.Clone() + spec.OS = target.GOOS() + spec.Arch = packageArch + spec.Snapshot = Snapshot + spec.evalContext = map[string]interface{}{ + "GOOS": target.GOOS(), + "GOARCH": target.GOARCH(), + "GOARM": target.GOARM(), + "Platform": target, + "PackageType": pkgType.String(), + "BinaryExt": binaryExtension(target.GOOS()), + } + spec.packageDir = packageStagingDir + "/" + pkgType.AddFileExtension(spec.Name+"-"+target.GOOS()+"-"+target.Arch()) + spec = spec.Evaluate() + + tasks = append(tasks, packageBuilder{target, spec, pkgType}.Build) + } + } + } + + Parallel(tasks...) + return nil +} + +type packageBuilder struct { + Platform BuildPlatform + Spec PackageSpec + Type PackageType +} + +func (b packageBuilder) Build() error { + fmt.Printf(">> package: Building %v type=%v for platform=%v\n", b.Spec.Name, b.Type, b.Platform.Name) + log.Printf("Package spec: %+v", b.Spec) + return errors.Wrapf(b.Type.Build(b.Spec), "failed building %v type=%v for platform=%v", + b.Spec.Name, b.Type, b.Platform.Name) +} + +// TestPackages executes the package tests on the produced binaries. These tests +// inspect things like file ownership and mode. +func TestPackages() error { + fmt.Println(">> Testing package contents") + var args []string + if mg.Verbose() { + args = append(args, "-v") + } + args = append(args, + MustExpand("{{ elastic_beats_dir }}/dev-tools/package_test.go"), + "-files", + MustExpand("{{.PWD}}/build/distributions/*"), + ) + goTest := sh.RunCmd("go", "test") + return goTest(args...) +} diff --git a/vendor/github.com/elastic/beats/dev-tools/mage/pkgspecs.go b/vendor/github.com/elastic/beats/dev-tools/mage/pkgspecs.go new file mode 100644 index 0000000000..ee6c38a025 --- /dev/null +++ b/vendor/github.com/elastic/beats/dev-tools/mage/pkgspecs.go @@ -0,0 +1,100 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package mage + +import ( + "io/ioutil" + "log" + "path/filepath" + + "github.com/pkg/errors" + "gopkg.in/yaml.v2" +) + +const packageSpecFile = "dev-tools/mage/files/packages.yml" + +// Packages defines the set of packages to be built when the package target is +// executed. +var Packages []OSPackageArgs + +// UseCommunityBeatPackaging configures the package target to build packages for +// a community Beat. +func UseCommunityBeatPackaging() { + beatsDir, err := ElasticBeatsDir() + if err != nil { + panic(err) + } + + err = LoadNamedSpec("community_beat", filepath.Join(beatsDir, packageSpecFile)) + if err != nil { + panic(err) + } +} + +// UseElasticBeatPackaging configures the package target to build packages for +// an Elastic Beat. This means it will generate two sets of packages -- one +// that is purely OSS under Apache 2.0 and one that is licensed under the +// Elastic License and may contain additional X-Pack features. +func UseElasticBeatPackaging() { + beatsDir, err := ElasticBeatsDir() + if err != nil { + panic(err) + } + + err = LoadNamedSpec("elastic_beat", filepath.Join(beatsDir, packageSpecFile)) + if err != nil { + panic(err) + } +} + +// LoadNamedSpec loads a packaging specification with the given name from the +// specified YAML file. name should be a sub-key of 'specs'. +func LoadNamedSpec(name, file string) error { + specs, err := LoadSpecs(file) + if err != nil { + return errors.Wrap(err, "failed to load spec file") + } + + packages, found := specs[name] + if !found { + return errors.Errorf("%v not found in package specs", name) + } + + log.Printf("%v package spec loaded from %v", name, file) + Packages = packages + return nil +} + +// LoadSpecs loads the packaging specifications from the specified YAML file. +func LoadSpecs(file string) (map[string][]OSPackageArgs, error) { + data, err := ioutil.ReadFile(file) + if err != nil { + return nil, errors.Wrap(err, "failed to read from spec file") + } + + type PackageYAML struct { + Specs map[string][]OSPackageArgs `yaml:"specs"` + } + + var packages PackageYAML + if err = yaml.Unmarshal(data, &packages); err != nil { + return nil, errors.Wrap(err, "failed to unmarshal spec data") + } + + return packages.Specs, nil +} diff --git a/vendor/github.com/elastic/beats/dev-tools/mage/pkgtypes.go b/vendor/github.com/elastic/beats/dev-tools/mage/pkgtypes.go new file mode 100644 index 0000000000..4cf1533153 --- /dev/null +++ b/vendor/github.com/elastic/beats/dev-tools/mage/pkgtypes.go @@ -0,0 +1,764 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package mage + +import ( + "archive/tar" + "archive/zip" + "bytes" + "compress/gzip" + "fmt" + "io" + "io/ioutil" + "log" + "os" + "path/filepath" + "reflect" + "runtime" + "strconv" + "strings" + + "github.com/magefile/mage/mg" + "github.com/magefile/mage/sh" + "github.com/mitchellh/hashstructure" + "github.com/pkg/errors" +) + +const ( + // distributionsDir is the dir where packages are written. + distributionsDir = "build/distributions" + + // packageStagingDir is the staging directory for any temporary files that + // need to be written to disk for inclusion in a package. + packageStagingDir = "build/package" + + // defaultBinaryName specifies the output file for zip and tar.gz. + defaultBinaryName = "{{.Name}}-{{.Version}}{{if .Snapshot}}-SNAPSHOT{{end}}{{if .OS}}-{{.OS}}{{end}}{{if .Arch}}-{{.Arch}}{{end}}" +) + +// PackageType defines the file format of the package (e.g. zip, rpm, etc). +type PackageType int + +// List of possible package types. +const ( + RPM PackageType = iota + 1 + Deb + Zip + TarGz +) + +// OSPackageArgs define a set of package types to build for an operating +// system using the contained PackageSpec. +type OSPackageArgs struct { + OS string `yaml:"os"` + Types []PackageType `yaml:"types"` + Spec PackageSpec `yaml:"spec"` +} + +// PackageSpec specifies package metadata and the contents of the package. +type PackageSpec struct { + Name string `yaml:"name,omitempty"` + ServiceName string `yaml:"service_name,omitempty"` + OS string `yaml:"os,omitempty"` + Arch string `yaml:"arch,omitempty"` + Vendor string `yaml:"vendor,omitempty"` + Snapshot bool `yaml:"snapshot"` + Version string `yaml:"version,omitempty"` + License string `yaml:"license,omitempty"` + URL string `yaml:"url,omitempty"` + Description string `yaml:"description,omitempty"` + PostInstallScript string `yaml:"post_install_script,omitempty"` + Files map[string]PackageFile `yaml:"files"` + OutputFile string `yaml:"output_file,omitempty"` // Optional + + evalContext map[string]interface{} + packageDir string + localPostInstallScript string +} + +// PackageFile represents a file or directory within a package. +type PackageFile struct { + Source string `yaml:"source,omitempty"` // Regular source file or directory. + Content string `yaml:"content,omitempty"` // Inline template string. + Template string `yaml:"template,omitempty"` // Input template file. + Target string `yaml:"target,omitempty"` // Target location in package. Relative paths are added to a package specific directory (e.g. metricbeat-7.0.0-linux-x86_64). + Mode os.FileMode `yaml:"mode,omitempty"` // Target mode for file. Does not apply when source is a directory. + Config bool `yaml:"config"` // Mark file as config in the package (deb and rpm only). + Dep func(PackageSpec) error `yaml:"-" hash:"-" json:"-"` // Dependency to invoke during Evaluate. +} + +// OSArchNames defines the names of architectures for use in packages. +var OSArchNames = map[string]map[PackageType]map[string]string{ + "windows": map[PackageType]map[string]string{ + Zip: map[string]string{ + "386": "x86", + "amd64": "x86_64", + }, + }, + "darwin": map[PackageType]map[string]string{ + TarGz: map[string]string{ + "386": "x86", + "amd64": "x86_64", + }, + }, + "linux": map[PackageType]map[string]string{ + RPM: map[string]string{ + "386": "i686", + "amd64": "x86_64", + "armv7": "armhfp", + "arm64": "aarch64", + "mipsle": "mipsel", + "mips64le": "mips64el", + "ppc64": "ppc64", + "ppc64le": "ppc64le", + "s390x": "s390x", + }, + // https://www.debian.org/ports/ + Deb: map[string]string{ + "386": "i386", + "amd64": "amd64", + "armv5": "armel", + "armv6": "armel", + "armv7": "armhf", + "arm64": "arm64", + "mips": "mips", + "mipsle": "mipsel", + "mips64le": "mips64el", + "ppc64le": "ppc64el", + "s390x": "s390x", + }, + TarGz: map[string]string{ + "386": "x86", + "amd64": "x86_64", + "armv5": "armv5", + "armv6": "armv6", + "armv7": "armv7", + "arm64": "arm64", + "mips": "mips", + "mipsle": "mipsel", + "mips64": "mips64", + "mips64le": "mips64el", + "ppc64": "ppc64", + "ppc64le": "ppc64le", + "s390x": "s390x", + }, + }, +} + +// getOSArchName returns the architecture name to use in a package. +func getOSArchName(platform BuildPlatform, t PackageType) (string, error) { + names, found := OSArchNames[platform.GOOS()] + if !found { + return "", errors.Errorf("arch names for os=%v are not defined", + platform.GOOS()) + } + + archMap, found := names[t] + if !found { + return "", errors.Errorf("arch names for %v on os=%v are not defined", + t, platform.GOOS()) + } + + arch, found := archMap[platform.Arch()] + if !found { + return "", errors.Errorf("arch name associated with %v for %v on "+ + "os=%v is not defined", platform.Arch(), t, platform.GOOS()) + } + + return arch, nil +} + +// String returns the name of the package type. +func (typ PackageType) String() string { + switch typ { + case RPM: + return "rpm" + case Deb: + return "deb" + case Zip: + return "zip" + case TarGz: + return "tar.gz" + default: + return "invalid" + } +} + +// MarshalText returns the text representation of PackageType. +func (typ PackageType) MarshalText() ([]byte, error) { + return []byte(typ.String()), nil +} + +// UnmarshalText returns a PackageType based on the given text. +func (typ *PackageType) UnmarshalText(text []byte) error { + switch strings.ToLower(string(text)) { + case "rpm": + *typ = RPM + case "deb": + *typ = Deb + case "tar.gz", "tgz", "targz": + *typ = TarGz + case "zip": + *typ = Zip + default: + return errors.Errorf("unknown package type: %v", string(text)) + } + return nil +} + +// AddFileExtension returns a filename with the file extension added. If the +// filename already has the extension then it becomes a pass-through. +func (typ PackageType) AddFileExtension(file string) string { + ext := "." + strings.ToLower(typ.String()) + if !strings.HasSuffix(file, ext) { + return file + ext + } + return file +} + +// Build builds a package based on the provided spec. +func (typ PackageType) Build(spec PackageSpec) error { + switch typ { + case RPM: + return PackageRPM(spec) + case Deb: + return PackageDeb(spec) + case Zip: + return PackageZip(spec) + case TarGz: + return PackageTarGz(spec) + default: + return errors.Errorf("unknown package type: %v", typ) + } +} + +// Clone returns a deep clone of the spec. +func (s PackageSpec) Clone() PackageSpec { + clone := s + clone.Files = make(map[string]PackageFile, len(s.Files)) + for k, v := range s.Files { + clone.Files[k] = v + } + return clone +} + +// ReplaceFile replaces an existing file defined in the spec. The target must +// exist other it will panic. +func (s PackageSpec) ReplaceFile(target string, file PackageFile) { + _, found := s.Files[target] + if !found { + panic(errors.Errorf("failed to ReplaceFile because target=%v does not exist", target)) + } + + s.Files[target] = file +} + +// Expand expands a templated string using data from the spec. +func (s PackageSpec) Expand(in string, args ...map[string]interface{}) (string, error) { + return expandTemplate("inline", in, FuncMap, + EnvMap(append([]map[string]interface{}{s.evalContext, s.toMap()}, args...)...)) +} + +// MustExpand expands a templated string using data from the spec. It panics if +// an error occurs. +func (s PackageSpec) MustExpand(in string, args ...map[string]interface{}) string { + v, err := s.Expand(in, args...) + if err != nil { + panic(err) + } + return v +} + +// ExpandFile expands a template file using data from the spec. +func (s PackageSpec) ExpandFile(src, dst string, args ...map[string]interface{}) error { + return expandFile(src, dst, + EnvMap(append([]map[string]interface{}{s.evalContext, s.toMap()}, args...)...)) +} + +// MustExpandFile expands a template file using data from the spec. It panics if +// an error occurs. +func (s PackageSpec) MustExpandFile(src, dst string, args ...map[string]interface{}) error { + return s.ExpandFile(src, dst, args...) +} + +// Evaluate expands all variables used in the spec definition and writes any +// templated files used in the spec to disk. It panics if there is an error. +func (s PackageSpec) Evaluate(args ...map[string]interface{}) PackageSpec { + args = append([]map[string]interface{}{s.toMap(), s.evalContext}, args...) + mustExpand := func(in string) string { + if in == "" { + return "" + } + return MustExpand(in, args...) + } + + s.Name = mustExpand(s.Name) + s.ServiceName = mustExpand(s.ServiceName) + s.OS = mustExpand(s.OS) + s.Arch = mustExpand(s.Arch) + s.Vendor = mustExpand(s.Vendor) + s.Version = mustExpand(s.Version) + s.License = mustExpand(s.License) + s.URL = mustExpand(s.URL) + s.Description = mustExpand(s.Description) + s.PostInstallScript = mustExpand(s.PostInstallScript) + s.OutputFile = mustExpand(s.OutputFile) + + if s.ServiceName == "" { + s.ServiceName = s.Name + } + + if s.packageDir == "" { + outputFileName := filepath.Base(s.OutputFile) + + if outputFileName != "." { + s.packageDir = filepath.Join(packageStagingDir, outputFileName) + } else { + s.packageDir = filepath.Join(packageStagingDir, strings.Join([]string{s.Name, s.OS, s.Arch, s.hash()}, "-")) + } + } else { + s.packageDir = filepath.Clean(mustExpand(s.packageDir)) + } + if s.evalContext == nil { + s.evalContext = map[string]interface{}{} + } + s.evalContext["PackageDir"] = s.packageDir + + evaluatedFiles := make(map[string]PackageFile, len(s.Files)) + for target, f := range s.Files { + // Execute the dependency if it exists. + if f.Dep != nil { + if err := f.Dep(s); err != nil { + panic(errors.Wrapf(err, "failed executing package file dependency for target=%v", target)) + } + } + + f.Source = s.MustExpand(f.Source) + f.Template = s.MustExpand(f.Template) + f.Target = s.MustExpand(target) + target = f.Target + + // Expand templates. + switch { + case f.Source != "": + case f.Content != "": + content, err := s.Expand(f.Content) + if err != nil { + panic(errors.Wrapf(err, "failed to expand content template for target=%v", target)) + } + + f.Source = filepath.Join(s.packageDir, filepath.Base(f.Target)) + if err = ioutil.WriteFile(createDir(f.Source), []byte(content), 0644); err != nil { + panic(errors.Wrapf(err, "failed to write file containing content for target=%v", target)) + } + case f.Template != "": + f.Source = filepath.Join(s.packageDir, filepath.Base(f.Template)) + if err := s.ExpandFile(createDir(f.Template), f.Source); err != nil { + panic(errors.Wrapf(err, "failed to expand template file for target=%v", target)) + } + default: + panic(errors.Errorf("package file with target=%v must have either source, content, or template", target)) + } + + evaluatedFiles[f.Target] = f + } + // Replace the map instead of modifying the source. + s.Files = evaluatedFiles + + if s.PostInstallScript != "" { + // Copy the inside the build dir so that it's available inside of Docker for FPM. + s.localPostInstallScript = filepath.Join(s.packageDir, filepath.Base(s.PostInstallScript)) + if err := Copy(s.PostInstallScript, s.localPostInstallScript); err != nil { + panic(errors.Wrap(err, "failed to copy post install script to build dir")) + } + } + + return s +} + +func (s PackageSpec) hash() string { + h, err := hashstructure.Hash(s, nil) + if err != nil { + panic(errors.Wrap(err, "failed to compute hash of spec")) + } + + hash := strconv.FormatUint(h, 10) + if len(hash) > 10 { + hash = hash[0:10] + } + return hash +} + +// toMap returns a map containing the exported field names and their values. +func (s PackageSpec) toMap() map[string]interface{} { + out := make(map[string]interface{}) + v := reflect.ValueOf(s) + typ := v.Type() + + for i := 0; i < v.NumField(); i++ { + structField := typ.Field(i) + if !structField.Anonymous && structField.PkgPath == "" { + out[structField.Name] = v.Field(i).Interface() + } + } + + return out +} + +// rootDir returns the name of the root directory contained inside of zip and +// tar.gz packages. +func (s PackageSpec) rootDir() string { + if s.OutputFile != "" { + return filepath.Base(s.OutputFile) + } + + // NOTE: This uses .BeatName instead of .Name because we wanted the internal + // directory to not include "-oss". + return s.MustExpand("{{.BeatName}}-{{.Version}}{{if .Snapshot}}-SNAPSHOT{{end}}{{if .OS}}-{{.OS}}{{end}}{{if .Arch}}-{{.Arch}}{{end}}") +} + +// PackageZip packages a zip file. +func PackageZip(spec PackageSpec) error { + // Create a buffer to write our archive to. + buf := new(bytes.Buffer) + + // Create a new zip archive. + w := zip.NewWriter(buf) + baseDir := spec.rootDir() + + // Add files to zip. + for _, pkgFile := range spec.Files { + if err := addFileToZip(w, baseDir, pkgFile); err != nil { + return errors.Wrapf(err, "failed adding file=%+v to zip", pkgFile) + } + } + + if err := w.Close(); err != nil { + return err + } + + // Output the zip file. + if spec.OutputFile == "" { + outputZip, err := spec.Expand(defaultBinaryName + ".zip") + if err != nil { + return err + } + spec.OutputFile = filepath.Join(distributionsDir, outputZip) + } + spec.OutputFile = Zip.AddFileExtension(spec.OutputFile) + + // Write the zip file. + if err := ioutil.WriteFile(createDir(spec.OutputFile), buf.Bytes(), 0644); err != nil { + return errors.Wrap(err, "failed to write zip file") + } + + // Any packages beginning with "tmp-" are temporary by nature so don't have + // them a .sha512 file. + if strings.HasPrefix(filepath.Base(spec.OutputFile), "tmp-") { + return nil + } + + return errors.Wrap(CreateSHA512File(spec.OutputFile), "failed to create .sha512 file") +} + +// PackageTarGz packages a gzipped tar file. +func PackageTarGz(spec PackageSpec) error { + // Create a buffer to write our archive to. + buf := new(bytes.Buffer) + + // Create a new tar archive. + w := tar.NewWriter(buf) + baseDir := spec.rootDir() + + // Add files to tar. + for _, pkgFile := range spec.Files { + if err := addFileToTar(w, baseDir, pkgFile); err != nil { + return errors.Wrapf(err, "failed adding file=%+v to tar", pkgFile) + } + } + + if err := w.Close(); err != nil { + return err + } + + // Output tar.gz to disk. + if spec.OutputFile == "" { + outputTarGz, err := spec.Expand(defaultBinaryName + ".tar.gz") + if err != nil { + return err + } + spec.OutputFile = filepath.Join(distributionsDir, outputTarGz) + } + spec.OutputFile = TarGz.AddFileExtension(spec.OutputFile) + + // Open the output file. + log.Println("Creating output file at", spec.OutputFile) + outFile, err := os.Create(createDir(spec.OutputFile)) + if err != nil { + return err + } + defer outFile.Close() + + // Gzip compress the data. + gzWriter := gzip.NewWriter(outFile) + if _, err = gzWriter.Write(buf.Bytes()); err != nil { + return err + } + + // Close and flush. + if err = gzWriter.Close(); err != nil { + return err + } + + // Any packages beginning with "tmp-" are temporary by nature so don't have + // them a .sha512 file. + if strings.HasPrefix(filepath.Base(spec.OutputFile), "tmp-") { + return nil + } + + return errors.Wrap(CreateSHA512File(spec.OutputFile), "failed to create .sha512 file") +} + +// PackageDeb packages a deb file. This requires Docker to execute FPM. +func PackageDeb(spec PackageSpec) error { + return runFPM(spec, Deb) +} + +// PackageRPM packages a RPM file. This requires Docker to execute FPM. +func PackageRPM(spec PackageSpec) error { + return runFPM(spec, RPM) +} + +func runFPM(spec PackageSpec, packageType PackageType) error { + var fpmPackageType string + switch packageType { + case RPM, Deb: + fpmPackageType = packageType.String() + default: + return errors.Errorf("unsupported package type=%v for runFPM", fpmPackageType) + } + + if err := HaveDocker(); err != nil { + return fmt.Errorf("packaging %v files requires docker: %v", fpmPackageType, err) + } + + // Build a tar file as the input to FPM. + inputTar := filepath.Join(distributionsDir, "tmp-"+fpmPackageType+"-"+spec.rootDir()+"-"+spec.hash()+".tar.gz") + spec.OutputFile = inputTar + if err := PackageTarGz(spec); err != nil { + return err + } + defer os.Remove(inputTar) + + outputFile, err := spec.Expand("{{.Name}}-{{.Version}}{{if .Snapshot}}-SNAPSHOT{{end}}-{{.Arch}}") + if err != nil { + return err + } + spec.OutputFile = packageType.AddFileExtension(filepath.Join(distributionsDir, outputFile)) + + dockerRun := sh.RunCmd("docker", "run") + var args []string + + args, err = addUidGidEnvArgs(args) + if err != nil { + return err + } + + args = append(args, + "--rm", + "-w", "/app", + "-v", CWD()+":/app", + beatsFPMImage+":"+fpmVersion, + "fpm", "--force", + "--input-type", "tar", + "--output-type", fpmPackageType, + "--name", spec.ServiceName, + "--architecture", spec.Arch, + ) + if spec.Version != "" { + args = append(args, "--version", spec.Version) + } + if spec.Vendor != "" { + args = append(args, "--vendor", spec.Vendor) + } + if spec.License != "" { + args = append(args, "--license", strings.Replace(spec.License, " ", "-", -1)) + } + if spec.Description != "" { + args = append(args, "--description", spec.Description) + } + if spec.URL != "" { + args = append(args, "--url", spec.URL) + } + if spec.localPostInstallScript != "" { + args = append(args, "--after-install", spec.localPostInstallScript) + } + args = append(args, + "-p", spec.OutputFile, + inputTar, + ) + + if err = dockerRun(args...); err != nil { + return errors.Wrap(err, "failed while running FPM in docker") + } + + return errors.Wrap(CreateSHA512File(spec.OutputFile), "failed to create .sha512 file") +} + +func addUidGidEnvArgs(args []string) ([]string, error) { + if runtime.GOOS == "windows" { + return args, nil + } + + info, err := GetDockerInfo() + if err != nil { + return args, errors.Wrap(err, "failed to get docker info") + } + + uid, gid := os.Getuid(), os.Getgid() + if info.IsBoot2Docker() { + // Boot2Docker mounts vboxfs using 1000:50. + uid, gid = 1000, 50 + log.Printf("Boot2Docker is in use. Deploying workaround. "+ + "Using UID=%d GID=%d", uid, gid) + } + + return append(args, + "--env", "EXEC_UID="+strconv.Itoa(uid), + "--env", "EXEC_GID="+strconv.Itoa(gid), + ), nil +} + +// addFileToZip adds a file (or directory) to a zip archive. +func addFileToZip(ar *zip.Writer, baseDir string, pkgFile PackageFile) error { + return filepath.Walk(pkgFile.Source, func(path string, info os.FileInfo, err error) error { + if err != nil { + return err + } + + header, err := zip.FileInfoHeader(info) + if err != nil { + return err + } + + if info.Mode().IsRegular() && pkgFile.Mode > 0 { + header.SetMode(pkgFile.Mode & os.ModePerm) + } else if info.IsDir() { + header.SetMode(0755) + } + + if filepath.IsAbs(pkgFile.Target) { + baseDir = "" + } + + relPath, err := filepath.Rel(pkgFile.Source, path) + if err != nil { + return err + } + + header.Name = filepath.Join(baseDir, pkgFile.Target, relPath) + + if info.IsDir() { + header.Name += string(filepath.Separator) + } else { + header.Method = zip.Deflate + } + + if mg.Verbose() { + log.Println("Adding", header.Mode(), header.Name) + } + + w, err := ar.CreateHeader(header) + if err != nil { + return err + } + + if info.IsDir() { + return nil + } + + file, err := os.Open(path) + if err != nil { + return err + } + defer file.Close() + + if _, err = io.Copy(w, file); err != nil { + return err + } + return file.Close() + }) +} + +// addFileToTar adds a file (or directory) to a tar archive. +func addFileToTar(ar *tar.Writer, baseDir string, pkgFile PackageFile) error { + return filepath.Walk(pkgFile.Source, func(path string, info os.FileInfo, err error) error { + if err != nil { + return err + } + + header, err := tar.FileInfoHeader(info, info.Name()) + if err != nil { + return err + } + header.Uname, header.Gname = "root", "root" + header.Uid, header.Gid = 0, 0 + + if info.Mode().IsRegular() && pkgFile.Mode > 0 { + header.Mode = int64(pkgFile.Mode & os.ModePerm) + } else if info.IsDir() { + header.Mode = int64(0755) + } + + if filepath.IsAbs(pkgFile.Target) { + baseDir = "" + } + + relPath, err := filepath.Rel(pkgFile.Source, path) + if err != nil { + return err + } + + header.Name = filepath.Join(baseDir, pkgFile.Target, relPath) + if info.IsDir() { + header.Name += string(filepath.Separator) + } + + if mg.Verbose() { + log.Println("Adding", os.FileMode(header.Mode), header.Name) + } + if err := ar.WriteHeader(header); err != nil { + return err + } + + if info.IsDir() { + return nil + } + + file, err := os.Open(path) + if err != nil { + return err + } + defer file.Close() + + if _, err = io.Copy(ar, file); err != nil { + return err + } + return file.Close() + }) +} diff --git a/vendor/github.com/elastic/beats/dev-tools/mage/platforms.go b/vendor/github.com/elastic/beats/dev-tools/mage/platforms.go new file mode 100644 index 0000000000..c6039c55ab --- /dev/null +++ b/vendor/github.com/elastic/beats/dev-tools/mage/platforms.go @@ -0,0 +1,464 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package mage + +import ( + "sort" + "strings" + + "github.com/pkg/errors" +) + +// BuildPlatforms is a list of GOOS/GOARCH pairs supported by Go. +// The list originated from 'go tool dist list -json'. +var BuildPlatforms = BuildPlatformList{ + {"android/386", CGOSupported}, + {"android/amd64", CGOSupported}, + {"android/arm", CGOSupported}, + {"android/arm64", CGOSupported}, + {"darwin/386", CGOSupported | CrossBuildSupported}, + {"darwin/amd64", CGOSupported | CrossBuildSupported | Default}, + {"darwin/arm", CGOSupported}, + {"darwin/arm64", CGOSupported}, + {"dragonfly/amd64", CGOSupported}, + {"freebsd/386", CGOSupported}, + {"freebsd/amd64", CGOSupported}, + {"freebsd/arm", 0}, + {"linux/386", CGOSupported | CrossBuildSupported | Default}, + {"linux/amd64", CGOSupported | CrossBuildSupported | Default}, + {"linux/armv5", CGOSupported | CrossBuildSupported}, + {"linux/armv6", CGOSupported | CrossBuildSupported}, + {"linux/armv7", CGOSupported | CrossBuildSupported}, + {"linux/arm64", CGOSupported | CrossBuildSupported}, + {"linux/mips", CGOSupported | CrossBuildSupported}, + {"linux/mips64", CGOSupported | CrossBuildSupported}, + {"linux/mips64le", CGOSupported | CrossBuildSupported}, + {"linux/mipsle", CGOSupported | CrossBuildSupported}, + {"linux/ppc64", CrossBuildSupported}, + {"linux/ppc64le", CGOSupported | CrossBuildSupported}, + {"linux/s390x", CGOSupported | CrossBuildSupported}, + {"nacl/386", 0}, + {"nacl/amd64p32", 0}, + {"nacl/arm", 0}, + {"netbsd/386", CGOSupported}, + {"netbsd/amd64", CGOSupported}, + {"netbsd/arm", CGOSupported}, + {"openbsd/386", CGOSupported}, + {"openbsd/amd64", CGOSupported}, + {"openbsd/arm", 0}, + {"plan9/386", 0}, + {"plan9/amd64", 0}, + {"plan9/arm", 0}, + {"solaris/amd64", CGOSupported}, + {"windows/386", CGOSupported | CrossBuildSupported | Default}, + {"windows/amd64", CGOSupported | CrossBuildSupported | Default}, +} + +// PlatformFeature specifies features that are supported for a platform. +type PlatformFeature uint8 + +// List of PlatformFeature types. +const ( + CGOSupported PlatformFeature = 1 << iota // CGO is supported. + CrossBuildSupported // Cross-build supported by golang-crossbuild. + Default // Built by default on crossBuild and package. +) + +var platformFlagNames = map[PlatformFeature]string{ + CGOSupported: "cgo", + CrossBuildSupported: "xbuild", + Default: "default", +} + +// String returns a string representation of the platform features. +func (f PlatformFeature) String() string { + if f == 0 { + return "none" + } + + var names []string + for value, name := range platformFlagNames { + if f&value > 0 { + names = append(names, name) + } + } + + return strings.Join(names, "|") +} + +// CanCrossBuild returns true if cross-building is supported by +// golang-crossbuild. +func (f PlatformFeature) CanCrossBuild() bool { + return f&CrossBuildSupported > 0 +} + +// SupportsCGO returns true if CGO is supported. +func (f PlatformFeature) SupportsCGO() bool { + return f&CGOSupported > 0 +} + +// BuildPlatform represents a target platform for builds. +type BuildPlatform struct { + Name string + Flags PlatformFeature +} + +// GOOS returns the GOOS value contained in the name. +func (p BuildPlatform) GOOS() string { + idx := strings.IndexByte(p.Name, '/') + if idx == -1 { + return p.Name + } + return p.Name[:idx] +} + +// Arch returns the architecture value contained in the name. +func (p BuildPlatform) Arch() string { + idx := strings.IndexByte(p.Name, '/') + if idx == -1 { + return "" + } + return p.Name[strings.IndexByte(p.Name, '/')+1:] +} + +// GOARCH returns the GOARCH value associated with the architecture contained +// in the name. For ARM the Arch and GOARCH can differ because the GOARM value +// is encoded in the Arch value. +func (p BuildPlatform) GOARCH() string { + // Allow armv7 to be interpreted as GOARCH=arm GOARM=7. + arch := p.Arch() + if strings.HasPrefix(arch, "armv") { + return "arm" + } + return arch +} + +// GOARM returns the ARM version. +func (p BuildPlatform) GOARM() string { + arch := p.Arch() + if strings.HasPrefix(arch, "armv") { + return strings.TrimPrefix(arch, "armv") + } + return "" +} + +// Attributes returns a new PlatformAttributes. +func (p BuildPlatform) Attributes() PlatformAttributes { + return MakePlatformAttributes(p.GOOS(), p.GOARCH(), p.GOARM()) +} + +// PlatformAttributes contains all of the data that can be extracted from a +// BuildPlatform name. +type PlatformAttributes struct { + Name string + GOOS string + GOARCH string + GOARM string + Arch string +} + +// MakePlatformAttributes returns a new PlatformAttributes. +func MakePlatformAttributes(goos, goarch, goarm string) PlatformAttributes { + arch := goarch + if goarch == "arm" && goarm != "" { + arch += "v" + goarm + } + + name := goos + if arch != "" { + name += "/" + arch + } + + return PlatformAttributes{ + Name: name, + GOOS: goos, + GOARCH: goarch, + GOARM: goarm, + Arch: arch, + } +} + +// String returns the string representation of the platform which has the format +// of "GOOS/Arch". +func (p PlatformAttributes) String() string { + return p.Name +} + +// BuildPlatformList is a list of BuildPlatforms that supports filtering. +type BuildPlatformList []BuildPlatform + +// Get returns the BuildPlatform matching the given name. +func (list BuildPlatformList) Get(name string) (BuildPlatform, bool) { + for _, bp := range list { + if bp.Name == name { + return bp, true + } + } + return BuildPlatform{}, false +} + +// Defaults returns the default platforms contained in the list. +func (list BuildPlatformList) Defaults() BuildPlatformList { + return list.filter(func(p BuildPlatform) bool { + return p.Flags&Default > 0 + }) +} + +// CrossBuild returns the platforms that support cross-building. +func (list BuildPlatformList) CrossBuild() BuildPlatformList { + return list.filter(func(p BuildPlatform) bool { + return p.Flags&CrossBuildSupported > 0 + }) +} + +// filter returns the platforms that match the given predicate. +func (list BuildPlatformList) filter(pred func(p BuildPlatform) bool) BuildPlatformList { + var out BuildPlatformList + for _, item := range list { + if pred(item) { + out = append(out, item) + } + } + return out +} + +// Remove returns a copy of list without platforms matching name. +func (list BuildPlatformList) Remove(name string) BuildPlatformList { + attrs := BuildPlatform{Name: name}.Attributes() + + if attrs.Arch == "" { + // Filter by GOOS only. + return list.filter(func(bp BuildPlatform) bool { + return bp.GOOS() != attrs.GOOS + }) + } + + return list.filter(func(bp BuildPlatform) bool { + return !(bp.GOOS() == attrs.GOOS && bp.Arch() == attrs.Arch) + }) +} + +// Select returns a new list containing the platforms that match name. +func (list BuildPlatformList) Select(name string) BuildPlatformList { + attrs := BuildPlatform{Name: name}.Attributes() + + if attrs.Arch == "" { + // Filter by GOOS only. + return list.filter(func(bp BuildPlatform) bool { + return bp.GOOS() == attrs.GOOS + }) + } + + return list.filter(func(bp BuildPlatform) bool { + return bp.GOOS() == attrs.GOOS && bp.Arch() == attrs.Arch + }) +} + +type platformExpression struct { + Add []string + Select []string + SelectCrossBuild bool + Remove []string +} + +func newPlatformExpression(expr string) (*platformExpression, error) { + if strings.TrimSpace(expr) == "" { + return nil, nil + } + + pe := &platformExpression{} + + // Parse the expression. + words := strings.FieldsFunc(expr, isSeparator) + for _, w := range words { + if strings.HasPrefix(w, "+") { + pe.Add = append(pe.Add, strings.TrimPrefix(w, "+")) + } else if strings.HasPrefix(w, "!") { + pe.Remove = append(pe.Remove, strings.TrimPrefix(w, "!")) + } else if w == "xbuild" { + pe.SelectCrossBuild = true + } else { + pe.Select = append(pe.Select, w) + } + } + + // Validate the names used. + checks := make([]string, 0, len(pe.Add)+len(pe.Select)+len(pe.Remove)) + checks = append(checks, pe.Add...) + checks = append(checks, pe.Select...) + checks = append(checks, pe.Remove...) + + for _, name := range checks { + if name == "all" || name == "defaults" { + continue + } + + var valid bool + for _, bp := range BuildPlatforms { + if bp.Name == name || bp.GOOS() == name { + valid = true + break + } + } + + if !valid { + return nil, errors.Errorf("invalid platform in expression: %v", name) + } + } + + return pe, nil +} + +// NewPlatformList returns a new BuildPlatformList based on given expression. +// +// By default the initial set include only the platforms designated as defaults. +// To add additional platforms to list use an addition term that is designated +// with a plug sign (e.g. "+netbsd" or "+linux/armv7"). Or you may use "+all" +// to change the initial set to include all possible platforms then filter +// from there (e.g. "+all linux windows"). +// +// The expression can consists of selections (e.g. "linux") and/or +// removals (e.g."!windows"). Each term can be valid GOOS or a valid GOOS/Arch +// pair. +// +// "xbuild" is a special selection term used to select all platforms that are +// cross-build eligible. +// "defaults" is a special selection or removal term that contains all platforms +// designated as a default. +// "all" is a special addition term for adding all valid GOOS/Arch pairs to the +// set. +func NewPlatformList(expr string) BuildPlatformList { + pe, err := newPlatformExpression(expr) + if err != nil { + panic(err) + } + if pe == nil { + return BuildPlatforms.Defaults() + } + + var out BuildPlatformList + if len(pe.Add) == 0 || (len(pe.Select) == 0 && len(pe.Remove) == 0) { + // Bootstrap list with default platforms when the expression is + // exclusively adds OR exclusively selects and removes. + out = BuildPlatforms.Defaults() + } + + all := BuildPlatforms + for _, name := range pe.Add { + if name == "all" { + out = make(BuildPlatformList, len(all)) + copy(out, all) + break + } + out = append(out, all.Select(name)...) + } + + if len(pe.Select) > 0 { + var selected BuildPlatformList + for _, name := range pe.Select { + selected = append(selected, out.Select(name)...) + } + out = selected + } + + for _, name := range pe.Remove { + if name == "defaults" { + for _, defaultBP := range all.Defaults() { + out = out.Remove(defaultBP.Name) + } + continue + } + out = out.Remove(name) + } + + if pe.SelectCrossBuild { + out = out.CrossBuild() + } + return out.deduplicate() +} + +// Filter creates a new list based on the provided expression. +// +// The expression can consists of selections (e.g. "linux") and/or +// removals (e.g."!windows"). Each term can be valid GOOS or a valid GOOS/Arch +// pair. +// +// "xbuild" is a special selection term used to select all platforms that are +// cross-build eligible. +// "defaults" is a special selection or removal term that contains all platforms +// designated as a default. +func (list BuildPlatformList) Filter(expr string) BuildPlatformList { + pe, err := newPlatformExpression(expr) + if err != nil { + panic(err) + } + if pe == nil { + return list + } + if len(pe.Add) > 0 { + panic(errors.Errorf("adds (%v) cannot be used in filter expressions", + strings.Join(pe.Add, ", "))) + } + + var out BuildPlatformList + if len(pe.Select) == 0 && !pe.SelectCrossBuild { + // Filter is only removals so clone the original list. + out = append(out, list...) + } + + if pe.SelectCrossBuild { + out = append(out, list.CrossBuild()...) + } + for _, name := range pe.Select { + if name == "defaults" { + out = append(out, list.Defaults()...) + continue + } + out = append(out, list.Select(name)...) + } + + for _, name := range pe.Remove { + if name == "defaults" { + for _, defaultBP := range BuildPlatforms.Defaults() { + out = out.Remove(defaultBP.Name) + } + continue + } + out = out.Remove(name) + } + + return out.deduplicate() +} + +// deduplicate removes duplicate platforms and sorts the list. +func (list BuildPlatformList) deduplicate() BuildPlatformList { + set := map[string]BuildPlatform{} + for _, item := range list { + set[item.Name] = item + } + + var out BuildPlatformList + for _, v := range set { + out = append(out, v) + } + + sort.Slice(out, func(i, j int) bool { + return out[i].Name < out[j].Name + }) + return out +} diff --git a/vendor/github.com/elastic/beats/dev-tools/mage/settings.go b/vendor/github.com/elastic/beats/dev-tools/mage/settings.go new file mode 100644 index 0000000000..dc66bdd33e --- /dev/null +++ b/vendor/github.com/elastic/beats/dev-tools/mage/settings.go @@ -0,0 +1,573 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package mage + +import ( + "fmt" + "go/build" + "io/ioutil" + "log" + "os" + "path/filepath" + "regexp" + "strconv" + "strings" + "sync" + "time" + + "github.com/magefile/mage/sh" + "github.com/pkg/errors" + "golang.org/x/tools/go/vcs" +) + +const ( + fpmVersion = "1.10.0" + + // Docker images. See https://github.com/elastic/golang-crossbuild. + beatsFPMImage = "docker.elastic.co/beats-dev/fpm" + beatsCrossBuildImage = "docker.elastic.co/beats-dev/golang-crossbuild" + + elasticBeatsImportPath = "github.com/elastic/beats" +) + +// Common settings with defaults derived from files, CWD, and environment. +var ( + GOOS = build.Default.GOOS + GOARCH = build.Default.GOARCH + GOARM = EnvOr("GOARM", "") + Platform = MakePlatformAttributes(GOOS, GOARCH, GOARM) + BinaryExt = "" + + BeatName = EnvOr("BEAT_NAME", filepath.Base(CWD())) + BeatServiceName = EnvOr("BEAT_SERVICE_NAME", BeatName) + BeatIndexPrefix = EnvOr("BEAT_INDEX_PREFIX", BeatName) + BeatDescription = EnvOr("BEAT_DESCRIPTION", "") + BeatVendor = EnvOr("BEAT_VENDOR", "Elastic") + BeatLicense = EnvOr("BEAT_LICENSE", "ASL 2.0") + BeatURL = EnvOr("BEAT_URL", "https://www.elastic.co/products/beats/"+BeatName) + + Snapshot bool + + FuncMap = map[string]interface{}{ + "beat_doc_branch": BeatDocBranch, + "beat_version": BeatVersion, + "commit": CommitHash, + "date": BuildDate, + "elastic_beats_dir": ElasticBeatsDir, + "go_version": GoVersion, + "repo": GetProjectRepoInfo, + "title": strings.Title, + } +) + +func init() { + if GOOS == "windows" { + BinaryExt = ".exe" + } + + var err error + Snapshot, err = strconv.ParseBool(EnvOr("SNAPSHOT", "false")) + if err != nil { + panic(errors.Errorf("failed to parse SNAPSHOT value", err)) + } +} + +// EnvMap returns map containing the common settings variables and all variables +// from the environment. args are appended to the output prior to adding the +// environment variables (so env vars have the highest precedence). +func EnvMap(args ...map[string]interface{}) map[string]interface{} { + envMap := varMap(args...) + + // Add the environment (highest precedence). + for _, e := range os.Environ() { + env := strings.SplitN(e, "=", 2) + envMap[env[0]] = env[1] + } + + return envMap +} + +func varMap(args ...map[string]interface{}) map[string]interface{} { + data := map[string]interface{}{ + "GOOS": GOOS, + "GOARCH": GOARCH, + "GOARM": GOARM, + "Platform": Platform, + "BinaryExt": BinaryExt, + "BeatName": BeatName, + "BeatServiceName": BeatServiceName, + "BeatIndexPrefix": BeatIndexPrefix, + "BeatDescription": BeatDescription, + "BeatVendor": BeatVendor, + "BeatLicense": BeatLicense, + "BeatURL": BeatURL, + "Snapshot": Snapshot, + } + + // Add the extra args to the map. + for _, m := range args { + for k, v := range m { + data[k] = v + } + } + + return data +} + +func dumpVariables() (string, error) { + var dumpTemplate = `## Variables + +GOOS = {{.GOOS}} +GOARCH = {{.GOARCH}} +GOARM = {{.GOARM}} +Platform = {{.Platform}} +BinaryExt = {{.BinaryExt}} +BeatName = {{.BeatName}} +BeatServiceName = {{.BeatServiceName}} +BeatIndexPrefix = {{.BeatIndexPrefix}} +BeatDescription = {{.BeatDescription}} +BeatVendor = {{.BeatVendor}} +BeatLicense = {{.BeatLicense}} +BeatURL = {{.BeatURL}} + +## Functions + +beat_doc_branch = {{ beat_doc_branch }} +beat_version = {{ beat_version }} +commit = {{ commit }} +date = {{ date }} +elastic_beats_dir = {{ elastic_beats_dir }} +go_version = {{ go_version }} +repo.RootImportPath = {{ repo.RootImportPath }} +repo.RootDir = {{ repo.RootDir }} +repo.ImportPath = {{ repo.ImportPath }} +repo.SubDir = {{ repo.SubDir }} +` + + return Expand(dumpTemplate) +} + +// DumpVariables writes the template variables and values to stdout. +func DumpVariables() error { + out, err := dumpVariables() + if err != nil { + return err + } + + fmt.Println(out) + return nil +} + +var ( + commitHash string + commitHashOnce sync.Once +) + +// CommitHash returns the full length git commit hash. +func CommitHash() (string, error) { + var err error + commitHashOnce.Do(func() { + commitHash, err = sh.Output("git", "rev-parse", "HEAD") + }) + return commitHash, err +} + +var ( + elasticBeatsDirValue string + elasticBeatsDirErr error + elasticBeatsDirLock sync.Mutex +) + +// ElasticBeatsDir returns the path to Elastic beats dir. +func ElasticBeatsDir() (string, error) { + elasticBeatsDirLock.Lock() + defer elasticBeatsDirLock.Unlock() + + if elasticBeatsDirValue != "" || elasticBeatsDirErr != nil { + return elasticBeatsDirValue, elasticBeatsDirErr + } + + elasticBeatsDirValue, elasticBeatsDirErr = findElasticBeatsDir() + if elasticBeatsDirErr == nil { + log.Println("Found Elastic Beats dir at", elasticBeatsDirValue) + } + return elasticBeatsDirValue, elasticBeatsDirErr +} + +// findElasticBeatsDir attempts to find the root of the Elastic Beats directory. +// It checks to see if the current project is elastic/beats, and then if not +// checks the vendor directory. +// +// If your project places the Beats files in a different location (specifically +// the dev-tools/ contents) then you can use SetElasticBeatsDir(). +func findElasticBeatsDir() (string, error) { + repo, err := GetProjectRepoInfo() + if err != nil { + return "", err + } + + if repo.IsElasticBeats() { + return repo.RootDir, nil + } + + const devToolsImportPath = elasticBeatsImportPath + "/dev-tools/mage" + + // Search in project vendor directories. + searchPaths := []string{ + filepath.Join(repo.RootDir, repo.SubDir, "vendor", devToolsImportPath), + filepath.Join(repo.RootDir, "vendor", devToolsImportPath), + } + + for _, path := range searchPaths { + if _, err := os.Stat(path); err == nil { + return filepath.Join(path, "../.."), nil + } + } + + return "", errors.Errorf("failed to find %v in the project's vendor", devToolsImportPath) +} + +// SetElasticBeatsDir explicilty sets the location of the Elastic Beats +// directory. If not set then it will attempt to locate it. +func SetElasticBeatsDir(dir string) { + elasticBeatsDirLock.Lock() + defer elasticBeatsDirLock.Unlock() + + info, err := os.Stat(dir) + if err != nil { + panic(errors.Wrapf(err, "failed to read elastic beats dir at %v", dir)) + } + + if !info.IsDir() { + panic(errors.Errorf("elastic beats dir=%v is not a directory", dir)) + } + + elasticBeatsDirValue = filepath.Clean(dir) +} + +var ( + buildDate = time.Now().UTC().Format(time.RFC3339) +) + +// BuildDate returns the time that the build started. +func BuildDate() string { + return buildDate +} + +var ( + goVersionValue string + goVersionErr error + goVersionOnce sync.Once +) + +// GoVersion returns the version of Go defined in the project's .go-version +// file. +func GoVersion() (string, error) { + goVersionOnce.Do(func() { + goVersionValue = os.Getenv("BEAT_GO_VERSION") + if goVersionValue != "" { + return + } + + goVersionValue, goVersionErr = getBuildVariableSources().GetGoVersion() + }) + + return goVersionValue, goVersionErr +} + +var ( + beatVersionRegex = regexp.MustCompile(`(?m)^const defaultBeatVersion = "(.+)"\r?$`) + beatVersionValue string + beatVersionErr error + beatVersionOnce sync.Once +) + +// BeatVersion returns the Beat's version. The value can be overridden by +// setting BEAT_VERSION in the environment. +func BeatVersion() (string, error) { + beatVersionOnce.Do(func() { + beatVersionValue = os.Getenv("BEAT_VERSION") + if beatVersionValue != "" { + return + } + + beatVersionValue, beatVersionErr = getBuildVariableSources().GetBeatVersion() + }) + + return beatVersionValue, beatVersionErr +} + +var ( + beatDocBranchRegex = regexp.MustCompile(`(?m)doc-branch:\s*([^\s]+)\r?$`) + beatDocBranchValue string + beatDocBranchErr error + beatDocBranchOnce sync.Once +) + +// BeatDocBranch returns the documentation branch name associated with the +// Beat branch. +func BeatDocBranch() (string, error) { + beatDocBranchOnce.Do(func() { + beatDocBranchValue = os.Getenv("BEAT_DOC_BRANCH") + if beatDocBranchValue != "" { + return + } + + beatDocBranchValue, beatDocBranchErr = getBuildVariableSources().GetDocBranch() + }) + + return beatDocBranchValue, beatDocBranchErr +} + +// --- BuildVariableSources + +var ( + // DefaultBeatBuildVariableSources contains the default locations build + // variables are read from by Elastic Beats. + DefaultBeatBuildVariableSources = &BuildVariableSources{ + BeatVersion: "{{ elastic_beats_dir }}/libbeat/version/version.go", + GoVersion: "{{ elastic_beats_dir }}/.go-version", + DocBranch: "{{ elastic_beats_dir }}/libbeat/docs/version.asciidoc", + } + + buildVariableSources *BuildVariableSources + buildVariableSourcesLock sync.Mutex +) + +// SetBuildVariableSources sets the BuildVariableSources that defines where +// certain build data should be sourced from. Community Beats must call this. +func SetBuildVariableSources(s *BuildVariableSources) { + buildVariableSourcesLock.Lock() + defer buildVariableSourcesLock.Unlock() + + buildVariableSources = s +} + +func getBuildVariableSources() *BuildVariableSources { + buildVariableSourcesLock.Lock() + defer buildVariableSourcesLock.Unlock() + + if buildVariableSources != nil { + return buildVariableSources + } + + repo, err := GetProjectRepoInfo() + if err != nil { + panic(err) + } + if repo.IsElasticBeats() { + buildVariableSources = DefaultBeatBuildVariableSources + return buildVariableSources + } + + panic(errors.Errorf("magefile must call mage.SetBuildVariableSources() "+ + "because it is not an elastic beat (repo=%+v)", repo.RootImportPath)) +} + +// BuildVariableSources is used to explicitly define what files contain build +// variables and how to parse the values from that file. This removes ambiguity +// about where the data is sources and allows a degree of customization for +// community Beats. +// +// Default parsers are used if one is not defined. +type BuildVariableSources struct { + // File containing the Beat version. + BeatVersion string + + // Parses the Beat version from the BeatVersion file. + BeatVersionParser func(data []byte) (string, error) + + // File containing the Go version to be used in cross-builds. + GoVersion string + + // Parses the Go version from the GoVersion file. + GoVersionParser func(data []byte) (string, error) + + // File containing the documentation branch. + DocBranch string + + // Parses the documentation branch from the DocBranch file. + DocBranchParser func(data []byte) (string, error) +} + +func (s *BuildVariableSources) expandVar(in string) (string, error) { + return expandTemplate("inline", in, map[string]interface{}{ + "elastic_beats_dir": ElasticBeatsDir, + }) +} + +// GetBeatVersion reads the BeatVersion file and parses the version from it. +func (s *BuildVariableSources) GetBeatVersion() (string, error) { + file, err := s.expandVar(s.BeatVersion) + if err != nil { + return "", err + } + + data, err := ioutil.ReadFile(file) + if err != nil { + return "", errors.Wrapf(err, "failed to read beat version file=%v", file) + } + + if s.BeatVersionParser == nil { + s.BeatVersionParser = parseBeatVersion + } + return s.BeatVersionParser(data) +} + +// GetGoVersion reads the GoVersion file and parses the version from it. +func (s *BuildVariableSources) GetGoVersion() (string, error) { + file, err := s.expandVar(s.GoVersion) + if err != nil { + return "", err + } + + data, err := ioutil.ReadFile(file) + if err != nil { + return "", errors.Wrapf(err, "failed to read go version file=%v", file) + } + + if s.GoVersionParser == nil { + s.GoVersionParser = parseGoVersion + } + return s.GoVersionParser(data) +} + +// GetDocBranch reads the DocBranch file and parses the branch from it. +func (s *BuildVariableSources) GetDocBranch() (string, error) { + file, err := s.expandVar(s.DocBranch) + if err != nil { + return "", err + } + + data, err := ioutil.ReadFile(file) + if err != nil { + return "", errors.Wrapf(err, "failed to read doc branch file=%v", file) + } + + if s.DocBranchParser == nil { + s.DocBranchParser = parseDocBranch + } + return s.DocBranchParser(data) +} + +func parseBeatVersion(data []byte) (string, error) { + matches := beatVersionRegex.FindSubmatch(data) + if len(matches) == 2 { + return string(matches[1]), nil + } + + return "", errors.New("failed to parse beat version file") +} + +func parseGoVersion(data []byte) (string, error) { + return strings.TrimSpace(string(data)), nil +} + +func parseDocBranch(data []byte) (string, error) { + matches := beatDocBranchRegex.FindSubmatch(data) + if len(matches) == 2 { + return string(matches[1]), nil + } + + return "", errors.New("failed to parse beat doc branch") +} + +// --- ProjectRepoInfo + +// ProjectRepoInfo contains information about the project's repo. +type ProjectRepoInfo struct { + RootImportPath string // Import path at the project root. + RootDir string // Root directory of the project. + ImportPath string // Import path of the current directory. + SubDir string // Relative path from the root dir to the current dir. +} + +// IsElasticBeats returns true if the current project is +// github.com/elastic/beats. +func (r *ProjectRepoInfo) IsElasticBeats() bool { + return r.RootImportPath == elasticBeatsImportPath +} + +var ( + repoInfoValue *ProjectRepoInfo + repoInfoErr error + repoInfoOnce sync.Once +) + +// GetProjectRepoInfo returns information about the repo including the root +// import path and the current directory's import path. +func GetProjectRepoInfo() (*ProjectRepoInfo, error) { + repoInfoOnce.Do(func() { + repoInfoValue, repoInfoErr = getProjectRepoInfo() + }) + + return repoInfoValue, repoInfoErr +} + +func getProjectRepoInfo() (*ProjectRepoInfo, error) { + var ( + cwd = CWD() + rootImportPath string + srcDir string + ) + + // Search upward from the CWD to determine the project root based on VCS. + var errs []string + for _, gopath := range filepath.SplitList(build.Default.GOPATH) { + gopath = filepath.Clean(gopath) + + if !strings.HasPrefix(cwd, gopath) { + // Fixes an issue on macOS when /var is actually /private/var. + var err error + gopath, err = filepath.EvalSymlinks(gopath) + if err != nil { + errs = append(errs, err.Error()) + continue + } + } + + srcDir = filepath.Join(gopath, "src") + _, root, err := vcs.FromDir(cwd, srcDir) + if err != nil { + // Try the next gopath. + errs = append(errs, err.Error()) + continue + } + rootImportPath = root + break + } + if rootImportPath == "" { + return nil, errors.Errorf("failed to determine root import path (Did "+ + "you git init?, Is the project in the GOPATH? GOPATH=%v, CWD=%v?): %v", + build.Default.GOPATH, cwd, errs) + } + + rootDir := filepath.Join(srcDir, rootImportPath) + subDir, err := filepath.Rel(rootDir, cwd) + if err != nil { + return nil, errors.Wrap(err, "failed to get relative path to repo root") + } + importPath := filepath.ToSlash(filepath.Join(rootImportPath, subDir)) + + return &ProjectRepoInfo{ + RootImportPath: rootImportPath, + RootDir: rootDir, + SubDir: subDir, + ImportPath: importPath, + }, nil +} diff --git a/vendor/github.com/elastic/beats/libbeat/api/config.go b/vendor/github.com/elastic/beats/libbeat/api/config.go index 4182a61e86..0ba306345c 100644 --- a/vendor/github.com/elastic/beats/libbeat/api/config.go +++ b/vendor/github.com/elastic/beats/libbeat/api/config.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package api type Config struct { diff --git a/vendor/github.com/elastic/beats/libbeat/api/server.go b/vendor/github.com/elastic/beats/libbeat/api/server.go index c38cbf5d5f..5a33b50e05 100644 --- a/vendor/github.com/elastic/beats/libbeat/api/server.go +++ b/vendor/github.com/elastic/beats/libbeat/api/server.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package api import ( diff --git a/vendor/github.com/elastic/beats/libbeat/asset/asset.go b/vendor/github.com/elastic/beats/libbeat/asset/asset.go new file mode 100644 index 0000000000..b1a164f608 --- /dev/null +++ b/vendor/github.com/elastic/beats/libbeat/asset/asset.go @@ -0,0 +1,49 @@ +package asset + +import "text/template" + +var Template = template.Must(template.New("normalizations").Parse(` +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +// Code generated by beats/dev-tools/cmd/asset/asset.go - DO NOT EDIT. + +package {{ .Package }} + +import ( + "github.com/elastic/beats/libbeat/asset" +) + +func init() { + if err := asset.SetFields("{{ .Beat }}", "{{ .Name }}", Asset); err != nil { + panic(err) + } +} + +// Asset returns asset data +func Asset() string { + return "{{ .Data }}" +} + +`)) + +type Data struct { + Beat string + Name string + Data string + Package string +} diff --git a/vendor/github.com/elastic/beats/libbeat/asset/registry.go b/vendor/github.com/elastic/beats/libbeat/asset/registry.go index 23a94d032d..634e4e3878 100644 --- a/vendor/github.com/elastic/beats/libbeat/asset/registry.go +++ b/vendor/github.com/elastic/beats/libbeat/asset/registry.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package asset import ( @@ -11,22 +28,24 @@ import ( // As each entry is an array of bytes multiple fields.yml can be added under one path. // This can become useful as we don't have to generate anymore the fields.yml but can // package each local fields.yml from things like processors. -var FieldsRegistry = map[string][]string{} +var FieldsRegistry = map[string]map[string]string{} -// SetFields sets the fields for a given path -func SetFields(path string, asset func() string) error { +// SetFields sets the fields for a given beat and asset name +func SetFields(beat, name string, asset func() string) error { data := asset() - FieldsRegistry[path] = append(FieldsRegistry[path], data) + if _, ok := FieldsRegistry[beat]; !ok { + FieldsRegistry[beat] = map[string]string{} + } + FieldsRegistry[beat][name] = data return nil } -// GetFields returns a byte array contains all fields for the given path -func GetFields(path string) ([]byte, error) { +// GetFields returns a byte array contains all fields for the given beat +func GetFields(beat string) ([]byte, error) { var fields []byte - for _, data := range FieldsRegistry[path] { - + for _, data := range FieldsRegistry[beat] { output, err := DecodeData(data) if err != nil { return nil, err diff --git a/vendor/github.com/elastic/beats/libbeat/autodiscover/appender.go b/vendor/github.com/elastic/beats/libbeat/autodiscover/appender.go index 9c1a3fd8ba..6bb80aac30 100644 --- a/vendor/github.com/elastic/beats/libbeat/autodiscover/appender.go +++ b/vendor/github.com/elastic/beats/libbeat/autodiscover/appender.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package autodiscover import ( diff --git a/vendor/github.com/elastic/beats/libbeat/autodiscover/autodiscover.go b/vendor/github.com/elastic/beats/libbeat/autodiscover/autodiscover.go index 8c4888fe8d..21d141fa05 100644 --- a/vendor/github.com/elastic/beats/libbeat/autodiscover/autodiscover.go +++ b/vendor/github.com/elastic/beats/libbeat/autodiscover/autodiscover.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package autodiscover import ( diff --git a/vendor/github.com/elastic/beats/libbeat/autodiscover/builder.go b/vendor/github.com/elastic/beats/libbeat/autodiscover/builder.go index f485746ea2..1bf9375525 100644 --- a/vendor/github.com/elastic/beats/libbeat/autodiscover/builder.go +++ b/vendor/github.com/elastic/beats/libbeat/autodiscover/builder.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package autodiscover import ( diff --git a/vendor/github.com/elastic/beats/libbeat/autodiscover/builder/helper.go b/vendor/github.com/elastic/beats/libbeat/autodiscover/builder/helper.go index 7a9be7e8cc..e8a81cfd86 100644 --- a/vendor/github.com/elastic/beats/libbeat/autodiscover/builder/helper.go +++ b/vendor/github.com/elastic/beats/libbeat/autodiscover/builder/helper.go @@ -1,11 +1,31 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package builder import ( + "encoding/json" "fmt" + "sort" "strconv" "strings" "github.com/elastic/beats/libbeat/common" + "github.com/elastic/beats/libbeat/logp" ) // GetContainerID returns the id of a container @@ -51,6 +71,43 @@ func GetHintAsList(hints common.MapStr, key, config string) []string { return nil } +// GetProcessors gets processor definitions from the hints and returns a list of configs as a MapStr +func GetProcessors(hints common.MapStr, key string) []common.MapStr { + rawProcs := GetHintMapStr(hints, key, "processors") + if rawProcs == nil { + return nil + } + + var words, nums []string + + for key := range rawProcs { + if _, err := strconv.Atoi(key); err != nil { + words = append(words, key) + continue + } else { + nums = append(nums, key) + } + } + + sort.Strings(nums) + + var configs []common.MapStr + for _, key := range nums { + rawCfg, _ := rawProcs[key] + if config, ok := rawCfg.(common.MapStr); ok { + configs = append(configs, config) + } + } + + for _, word := range words { + configs = append(configs, common.MapStr{ + word: rawProcs[word], + }) + } + + return configs +} + func getStringAsList(input string) []string { if input == "" { return []string{} @@ -64,6 +121,29 @@ func getStringAsList(input string) []string { return list } +// GetHintAsConfigs can read a hint in the form of a stringified JSON and return a common.MapStr +func GetHintAsConfigs(hints common.MapStr, key string) []common.MapStr { + if str := GetHintString(hints, key, "raw"); str != "" { + // check if it is a single config + if str[0] != '[' { + cfg := common.MapStr{} + if err := json.Unmarshal([]byte(str), &cfg); err != nil { + logp.Debug("autodiscover.builder", "unable to unmarshal json due to error: %v", err) + return nil + } + return []common.MapStr{cfg} + } + + cfg := []common.MapStr{} + if err := json.Unmarshal([]byte(str), &cfg); err != nil { + logp.Debug("autodiscover.builder", "unable to unmarshal json due to error: %v", err) + return nil + } + return cfg + } + return nil +} + // IsNoOp is a big red button to prevent spinning up Runners in case of issues. func IsNoOp(hints common.MapStr, key string) bool { if value, err := hints.GetValue(fmt.Sprintf("%s.disable", key)); err == nil { diff --git a/vendor/github.com/elastic/beats/libbeat/autodiscover/builder/plugin.go b/vendor/github.com/elastic/beats/libbeat/autodiscover/builder/plugin.go index 165b7a62bc..87f33cda3b 100644 --- a/vendor/github.com/elastic/beats/libbeat/autodiscover/builder/plugin.go +++ b/vendor/github.com/elastic/beats/libbeat/autodiscover/builder/plugin.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package builder import ( diff --git a/vendor/github.com/elastic/beats/libbeat/autodiscover/config.go b/vendor/github.com/elastic/beats/libbeat/autodiscover/config.go index 89bbc8b559..5b49eb8644 100644 --- a/vendor/github.com/elastic/beats/libbeat/autodiscover/config.go +++ b/vendor/github.com/elastic/beats/libbeat/autodiscover/config.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package autodiscover import ( diff --git a/vendor/github.com/elastic/beats/libbeat/autodiscover/meta/meta.go b/vendor/github.com/elastic/beats/libbeat/autodiscover/meta/meta.go index 7757bce426..28464dfd9e 100644 --- a/vendor/github.com/elastic/beats/libbeat/autodiscover/meta/meta.go +++ b/vendor/github.com/elastic/beats/libbeat/autodiscover/meta/meta.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package meta import ( diff --git a/vendor/github.com/elastic/beats/libbeat/autodiscover/provider.go b/vendor/github.com/elastic/beats/libbeat/autodiscover/provider.go index 417bee456a..27efcd92cc 100644 --- a/vendor/github.com/elastic/beats/libbeat/autodiscover/provider.go +++ b/vendor/github.com/elastic/beats/libbeat/autodiscover/provider.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package autodiscover import ( diff --git a/vendor/github.com/elastic/beats/libbeat/autodiscover/providers/docker/config.go b/vendor/github.com/elastic/beats/libbeat/autodiscover/providers/docker/config.go index 6c8d000cad..0b76887a10 100644 --- a/vendor/github.com/elastic/beats/libbeat/autodiscover/providers/docker/config.go +++ b/vendor/github.com/elastic/beats/libbeat/autodiscover/providers/docker/config.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package docker import ( diff --git a/vendor/github.com/elastic/beats/libbeat/autodiscover/providers/docker/docker.go b/vendor/github.com/elastic/beats/libbeat/autodiscover/providers/docker/docker.go index af83f3a9fb..4f9478c465 100644 --- a/vendor/github.com/elastic/beats/libbeat/autodiscover/providers/docker/docker.go +++ b/vendor/github.com/elastic/beats/libbeat/autodiscover/providers/docker/docker.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package docker import ( @@ -109,7 +126,6 @@ func (d *Provider) emitContainer(event bus.Event, flag string) { if len(container.IPAddresses) > 0 { host = container.IPAddresses[0] } - labelMap := common.MapStr{} for k, v := range container.Labels { safemapstr.Put(labelMap, k, v) diff --git a/vendor/github.com/elastic/beats/libbeat/autodiscover/providers/jolokia/config.go b/vendor/github.com/elastic/beats/libbeat/autodiscover/providers/jolokia/config.go index 2df5d7edf1..8e2544f476 100644 --- a/vendor/github.com/elastic/beats/libbeat/autodiscover/providers/jolokia/config.go +++ b/vendor/github.com/elastic/beats/libbeat/autodiscover/providers/jolokia/config.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package jolokia import ( diff --git a/vendor/github.com/elastic/beats/libbeat/autodiscover/providers/jolokia/discovery.go b/vendor/github.com/elastic/beats/libbeat/autodiscover/providers/jolokia/discovery.go index 8416cc4192..d702cb947e 100644 --- a/vendor/github.com/elastic/beats/libbeat/autodiscover/providers/jolokia/discovery.go +++ b/vendor/github.com/elastic/beats/libbeat/autodiscover/providers/jolokia/discovery.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package jolokia import ( diff --git a/vendor/github.com/elastic/beats/libbeat/autodiscover/providers/jolokia/jolokia.go b/vendor/github.com/elastic/beats/libbeat/autodiscover/providers/jolokia/jolokia.go index 9e18546431..57f764ae91 100644 --- a/vendor/github.com/elastic/beats/libbeat/autodiscover/providers/jolokia/jolokia.go +++ b/vendor/github.com/elastic/beats/libbeat/autodiscover/providers/jolokia/jolokia.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package jolokia import ( diff --git a/vendor/github.com/elastic/beats/libbeat/autodiscover/providers/kubernetes/config.go b/vendor/github.com/elastic/beats/libbeat/autodiscover/providers/kubernetes/config.go index 038d16889b..5ba5f789f6 100644 --- a/vendor/github.com/elastic/beats/libbeat/autodiscover/providers/kubernetes/config.go +++ b/vendor/github.com/elastic/beats/libbeat/autodiscover/providers/kubernetes/config.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package kubernetes import ( diff --git a/vendor/github.com/elastic/beats/libbeat/autodiscover/providers/kubernetes/kubernetes.go b/vendor/github.com/elastic/beats/libbeat/autodiscover/providers/kubernetes/kubernetes.go index d3b3880ff5..d7fa310075 100644 --- a/vendor/github.com/elastic/beats/libbeat/autodiscover/providers/kubernetes/kubernetes.go +++ b/vendor/github.com/elastic/beats/libbeat/autodiscover/providers/kubernetes/kubernetes.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package kubernetes import ( @@ -119,9 +136,9 @@ func (p *Provider) emit(pod *kubernetes.Pod, flag string) { p.emitEvents(pod, flag, pod.Spec.InitContainers, pod.Status.InitContainerStatuses) } -func (p *Provider) emitEvents(pod *kubernetes.Pod, flag string, containers []kubernetes.Container, - containerstatuses []kubernetes.PodContainerStatus) { - host := pod.Status.PodIP +func (p *Provider) emitEvents(pod *kubernetes.Pod, flag string, containers []*kubernetes.Container, + containerstatuses []*kubernetes.PodContainerStatus) { + host := pod.Status.GetPodIP() // Do not emit events without host (container is still being configured) if host == "" { @@ -132,20 +149,20 @@ func (p *Provider) emitEvents(pod *kubernetes.Pod, flag string, containers []kub containerIDs := map[string]string{} runtimes := map[string]string{} for _, c := range containerstatuses { - cid, runtime := c.GetContainerIDWithRuntime() - containerIDs[c.Name] = cid - runtimes[c.Name] = runtime + cid, runtime := kubernetes.ContainerIDWithRuntime(c) + containerIDs[c.GetName()] = cid + runtimes[c.GetName()] = runtime } // Emit container and port information for _, c := range containers { cmeta := common.MapStr{ - "id": containerIDs[c.Name], - "name": c.Name, - "image": c.Image, - "runtime": runtimes[c.Name], + "id": containerIDs[c.GetName()], + "name": c.GetName(), + "image": c.GetImage(), + "runtime": runtimes[c.GetName()], } - meta := p.metagen.ContainerMetadata(pod, c.Name) + meta := p.metagen.ContainerMetadata(pod, c.GetName()) // Information that can be used in discovering a workload kubemeta := meta.Clone() @@ -175,7 +192,7 @@ func (p *Provider) emitEvents(pod *kubernetes.Pod, flag string, containers []kub event := bus.Event{ flag: true, "host": host, - "port": port.ContainerPort, + "port": port.GetContainerPort(), "kubernetes": kubemeta, "meta": common.MapStr{ "kubernetes": meta, diff --git a/vendor/github.com/elastic/beats/libbeat/autodiscover/registry.go b/vendor/github.com/elastic/beats/libbeat/autodiscover/registry.go index 65bc6ca759..038288fc81 100644 --- a/vendor/github.com/elastic/beats/libbeat/autodiscover/registry.go +++ b/vendor/github.com/elastic/beats/libbeat/autodiscover/registry.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package autodiscover import "sync" diff --git a/vendor/github.com/elastic/beats/libbeat/autodiscover/template/config.go b/vendor/github.com/elastic/beats/libbeat/autodiscover/template/config.go index eee8865907..e6609f6c90 100644 --- a/vendor/github.com/elastic/beats/libbeat/autodiscover/template/config.go +++ b/vendor/github.com/elastic/beats/libbeat/autodiscover/template/config.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package template import ( diff --git a/vendor/github.com/elastic/beats/libbeat/beat/beat.go b/vendor/github.com/elastic/beats/libbeat/beat/beat.go index e25b023ddf..84e8c42880 100644 --- a/vendor/github.com/elastic/beats/libbeat/beat/beat.go +++ b/vendor/github.com/elastic/beats/libbeat/beat/beat.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package beat import ( diff --git a/vendor/github.com/elastic/beats/libbeat/beat/error.go b/vendor/github.com/elastic/beats/libbeat/beat/error.go index 14a74ddd21..ab92b36a05 100644 --- a/vendor/github.com/elastic/beats/libbeat/beat/error.go +++ b/vendor/github.com/elastic/beats/libbeat/beat/error.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package beat import "errors" diff --git a/vendor/github.com/elastic/beats/libbeat/beat/event.go b/vendor/github.com/elastic/beats/libbeat/beat/event.go index c3a71d389d..8b25349eb1 100644 --- a/vendor/github.com/elastic/beats/libbeat/beat/event.go +++ b/vendor/github.com/elastic/beats/libbeat/beat/event.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package beat import ( diff --git a/vendor/github.com/elastic/beats/libbeat/beat/info.go b/vendor/github.com/elastic/beats/libbeat/beat/info.go index 36fe041d1f..5f24c8cdb1 100644 --- a/vendor/github.com/elastic/beats/libbeat/beat/info.go +++ b/vendor/github.com/elastic/beats/libbeat/beat/info.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package beat import "github.com/satori/go.uuid" diff --git a/vendor/github.com/elastic/beats/libbeat/beat/pipeline.go b/vendor/github.com/elastic/beats/libbeat/beat/pipeline.go index 6780df929d..823ae8de20 100644 --- a/vendor/github.com/elastic/beats/libbeat/beat/pipeline.go +++ b/vendor/github.com/elastic/beats/libbeat/beat/pipeline.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package beat import ( diff --git a/vendor/github.com/elastic/beats/libbeat/cfgfile/cfgfile.go b/vendor/github.com/elastic/beats/libbeat/cfgfile/cfgfile.go index 66459e04bf..13407864c0 100644 --- a/vendor/github.com/elastic/beats/libbeat/cfgfile/cfgfile.go +++ b/vendor/github.com/elastic/beats/libbeat/cfgfile/cfgfile.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package cfgfile import ( diff --git a/vendor/github.com/elastic/beats/libbeat/cfgfile/glob_manager.go b/vendor/github.com/elastic/beats/libbeat/cfgfile/glob_manager.go index 95c131f618..0a90357b20 100644 --- a/vendor/github.com/elastic/beats/libbeat/cfgfile/glob_manager.go +++ b/vendor/github.com/elastic/beats/libbeat/cfgfile/glob_manager.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package cfgfile import ( diff --git a/vendor/github.com/elastic/beats/libbeat/cfgfile/glob_watcher.go b/vendor/github.com/elastic/beats/libbeat/cfgfile/glob_watcher.go index d925f05bfa..2aff04adad 100644 --- a/vendor/github.com/elastic/beats/libbeat/cfgfile/glob_watcher.go +++ b/vendor/github.com/elastic/beats/libbeat/cfgfile/glob_watcher.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package cfgfile import ( diff --git a/vendor/github.com/elastic/beats/libbeat/cfgfile/list.go b/vendor/github.com/elastic/beats/libbeat/cfgfile/list.go index 66af059ec9..67417d5653 100644 --- a/vendor/github.com/elastic/beats/libbeat/cfgfile/list.go +++ b/vendor/github.com/elastic/beats/libbeat/cfgfile/list.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package cfgfile import ( diff --git a/vendor/github.com/elastic/beats/libbeat/cfgfile/reload.go b/vendor/github.com/elastic/beats/libbeat/cfgfile/reload.go index 228b4b42cd..e0b4121397 100644 --- a/vendor/github.com/elastic/beats/libbeat/cfgfile/reload.go +++ b/vendor/github.com/elastic/beats/libbeat/cfgfile/reload.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package cfgfile import ( diff --git a/vendor/github.com/elastic/beats/libbeat/cloudid/cloudid.go b/vendor/github.com/elastic/beats/libbeat/cloudid/cloudid.go index fc5b3b6a2d..7efdf468a1 100644 --- a/vendor/github.com/elastic/beats/libbeat/cloudid/cloudid.go +++ b/vendor/github.com/elastic/beats/libbeat/cloudid/cloudid.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + // package cloudid contains functions for parsing the cloud.id and cloud.auth // settings and modifying the configuration to take them into account. package cloudid diff --git a/vendor/github.com/elastic/beats/libbeat/cmd/completion.go b/vendor/github.com/elastic/beats/libbeat/cmd/completion.go index 4f24c5ab3f..47fb7ef248 100644 --- a/vendor/github.com/elastic/beats/libbeat/cmd/completion.go +++ b/vendor/github.com/elastic/beats/libbeat/cmd/completion.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package cmd import ( diff --git a/vendor/github.com/elastic/beats/libbeat/cmd/export.go b/vendor/github.com/elastic/beats/libbeat/cmd/export.go index b4c62741e0..a6bb63f0ee 100644 --- a/vendor/github.com/elastic/beats/libbeat/cmd/export.go +++ b/vendor/github.com/elastic/beats/libbeat/cmd/export.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package cmd import ( diff --git a/vendor/github.com/elastic/beats/libbeat/cmd/export/config.go b/vendor/github.com/elastic/beats/libbeat/cmd/export/config.go index 77b8592d01..6f99b04fff 100644 --- a/vendor/github.com/elastic/beats/libbeat/cmd/export/config.go +++ b/vendor/github.com/elastic/beats/libbeat/cmd/export/config.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package export import ( diff --git a/vendor/github.com/elastic/beats/libbeat/cmd/export/dashboard.go b/vendor/github.com/elastic/beats/libbeat/cmd/export/dashboard.go index d9905117b4..59a6fa04cc 100644 --- a/vendor/github.com/elastic/beats/libbeat/cmd/export/dashboard.go +++ b/vendor/github.com/elastic/beats/libbeat/cmd/export/dashboard.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package export import ( diff --git a/vendor/github.com/elastic/beats/libbeat/cmd/export/template.go b/vendor/github.com/elastic/beats/libbeat/cmd/export/template.go index 2a29c3a268..4cd73525f5 100644 --- a/vendor/github.com/elastic/beats/libbeat/cmd/export/template.go +++ b/vendor/github.com/elastic/beats/libbeat/cmd/export/template.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package export import ( diff --git a/vendor/github.com/elastic/beats/libbeat/cmd/instance/beat.go b/vendor/github.com/elastic/beats/libbeat/cmd/instance/beat.go index f2c97dfddc..f12fdea5bd 100644 --- a/vendor/github.com/elastic/beats/libbeat/cmd/instance/beat.go +++ b/vendor/github.com/elastic/beats/libbeat/cmd/instance/beat.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package instance import ( @@ -175,7 +192,7 @@ func NewBeat(name, indexPrefix, v string) (*Beat, error) { return nil, err } - fields, err := asset.GetFields(name + "/fields.yml") + fields, err := asset.GetFields(name) if err != nil { return nil, err } diff --git a/vendor/github.com/elastic/beats/libbeat/cmd/instance/doc.go b/vendor/github.com/elastic/beats/libbeat/cmd/instance/doc.go index 307fd23267..1819e6d922 100644 --- a/vendor/github.com/elastic/beats/libbeat/cmd/instance/doc.go +++ b/vendor/github.com/elastic/beats/libbeat/cmd/instance/doc.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + /* Package instance provides the functions required to manage the life-cycle of a Beat. It provides the standard mechanism for launching a Beat. It manages diff --git a/vendor/github.com/elastic/beats/libbeat/cmd/instance/metrics.go b/vendor/github.com/elastic/beats/libbeat/cmd/instance/metrics.go index d2d0f53df4..bca0363a80 100644 --- a/vendor/github.com/elastic/beats/libbeat/cmd/instance/metrics.go +++ b/vendor/github.com/elastic/beats/libbeat/cmd/instance/metrics.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + // +build darwin,cgo freebsd,cgo linux windows package instance diff --git a/vendor/github.com/elastic/beats/libbeat/cmd/instance/metrics_common.go b/vendor/github.com/elastic/beats/libbeat/cmd/instance/metrics_common.go index bdec5fe160..d5a3a1e9f0 100644 --- a/vendor/github.com/elastic/beats/libbeat/cmd/instance/metrics_common.go +++ b/vendor/github.com/elastic/beats/libbeat/cmd/instance/metrics_common.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package instance import ( diff --git a/vendor/github.com/elastic/beats/libbeat/cmd/instance/metrics_other.go b/vendor/github.com/elastic/beats/libbeat/cmd/instance/metrics_other.go index f8325bbff1..37e092be4b 100644 --- a/vendor/github.com/elastic/beats/libbeat/cmd/instance/metrics_other.go +++ b/vendor/github.com/elastic/beats/libbeat/cmd/instance/metrics_other.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + // +build !darwin !cgo // +build !freebsd !cgo // +build !linux,!windows diff --git a/vendor/github.com/elastic/beats/libbeat/cmd/instance/setup.go b/vendor/github.com/elastic/beats/libbeat/cmd/instance/setup.go index e1f19193b5..a058100f92 100644 --- a/vendor/github.com/elastic/beats/libbeat/cmd/instance/setup.go +++ b/vendor/github.com/elastic/beats/libbeat/cmd/instance/setup.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package instance type TemplateConfig struct { diff --git a/vendor/github.com/elastic/beats/libbeat/cmd/keystore.go b/vendor/github.com/elastic/beats/libbeat/cmd/keystore.go index d9ab707795..5cdecdb845 100644 --- a/vendor/github.com/elastic/beats/libbeat/cmd/keystore.go +++ b/vendor/github.com/elastic/beats/libbeat/cmd/keystore.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package cmd import ( diff --git a/vendor/github.com/elastic/beats/libbeat/cmd/modules.go b/vendor/github.com/elastic/beats/libbeat/cmd/modules.go index ed117e6d6d..609e40a5e5 100644 --- a/vendor/github.com/elastic/beats/libbeat/cmd/modules.go +++ b/vendor/github.com/elastic/beats/libbeat/cmd/modules.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package cmd import ( diff --git a/vendor/github.com/elastic/beats/libbeat/cmd/root.go b/vendor/github.com/elastic/beats/libbeat/cmd/root.go index 77bf073391..b9512e9bb3 100644 --- a/vendor/github.com/elastic/beats/libbeat/cmd/root.go +++ b/vendor/github.com/elastic/beats/libbeat/cmd/root.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package cmd import ( diff --git a/vendor/github.com/elastic/beats/libbeat/cmd/run.go b/vendor/github.com/elastic/beats/libbeat/cmd/run.go index 00bcb71caf..97e6b47ecb 100644 --- a/vendor/github.com/elastic/beats/libbeat/cmd/run.go +++ b/vendor/github.com/elastic/beats/libbeat/cmd/run.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package cmd import ( diff --git a/vendor/github.com/elastic/beats/libbeat/cmd/setup.go b/vendor/github.com/elastic/beats/libbeat/cmd/setup.go index fa04e97b3c..d8745cf765 100644 --- a/vendor/github.com/elastic/beats/libbeat/cmd/setup.go +++ b/vendor/github.com/elastic/beats/libbeat/cmd/setup.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package cmd import ( diff --git a/vendor/github.com/elastic/beats/libbeat/cmd/test.go b/vendor/github.com/elastic/beats/libbeat/cmd/test.go index b38342b76f..aedc9a97bf 100644 --- a/vendor/github.com/elastic/beats/libbeat/cmd/test.go +++ b/vendor/github.com/elastic/beats/libbeat/cmd/test.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package cmd import ( diff --git a/vendor/github.com/elastic/beats/libbeat/cmd/test/config.go b/vendor/github.com/elastic/beats/libbeat/cmd/test/config.go index 43e55b2e00..6d2423ff01 100644 --- a/vendor/github.com/elastic/beats/libbeat/cmd/test/config.go +++ b/vendor/github.com/elastic/beats/libbeat/cmd/test/config.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package test import ( diff --git a/vendor/github.com/elastic/beats/libbeat/cmd/test/output.go b/vendor/github.com/elastic/beats/libbeat/cmd/test/output.go index 912509c7b6..a94f905389 100644 --- a/vendor/github.com/elastic/beats/libbeat/cmd/test/output.go +++ b/vendor/github.com/elastic/beats/libbeat/cmd/test/output.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package test import ( diff --git a/vendor/github.com/elastic/beats/libbeat/cmd/version.go b/vendor/github.com/elastic/beats/libbeat/cmd/version.go index cdecb5279d..61c11e8e72 100644 --- a/vendor/github.com/elastic/beats/libbeat/cmd/version.go +++ b/vendor/github.com/elastic/beats/libbeat/cmd/version.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package cmd import ( diff --git a/vendor/github.com/elastic/beats/libbeat/common/atomic/atomic.go b/vendor/github.com/elastic/beats/libbeat/common/atomic/atomic.go index 060da41fcc..09e8361418 100644 --- a/vendor/github.com/elastic/beats/libbeat/common/atomic/atomic.go +++ b/vendor/github.com/elastic/beats/libbeat/common/atomic/atomic.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + // Package atomic provides common primitive types with atomic accessors. package atomic diff --git a/vendor/github.com/elastic/beats/libbeat/common/atomic/atomic32.go b/vendor/github.com/elastic/beats/libbeat/common/atomic/atomic32.go index bd3f640a9a..17c41392e6 100644 --- a/vendor/github.com/elastic/beats/libbeat/common/atomic/atomic32.go +++ b/vendor/github.com/elastic/beats/libbeat/common/atomic/atomic32.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + // +build 386 arm mips mipsle package atomic diff --git a/vendor/github.com/elastic/beats/libbeat/common/atomic/atomic64.go b/vendor/github.com/elastic/beats/libbeat/common/atomic/atomic64.go index fc34a8d3bf..5d7de52026 100644 --- a/vendor/github.com/elastic/beats/libbeat/common/atomic/atomic64.go +++ b/vendor/github.com/elastic/beats/libbeat/common/atomic/atomic64.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + // +build amd64 arm64 ppc64 ppc64le mips64 mips64le s390x package atomic diff --git a/vendor/github.com/elastic/beats/libbeat/common/backoff.go b/vendor/github.com/elastic/beats/libbeat/common/backoff.go index d865b0dc0f..575bb333e6 100644 --- a/vendor/github.com/elastic/beats/libbeat/common/backoff.go +++ b/vendor/github.com/elastic/beats/libbeat/common/backoff.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package common import "time" diff --git a/vendor/github.com/elastic/beats/libbeat/common/bus/bus.go b/vendor/github.com/elastic/beats/libbeat/common/bus/bus.go index 259e077cd9..e1a28189bb 100644 --- a/vendor/github.com/elastic/beats/libbeat/common/bus/bus.go +++ b/vendor/github.com/elastic/beats/libbeat/common/bus/bus.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package bus import ( diff --git a/vendor/github.com/elastic/beats/libbeat/common/bytes.go b/vendor/github.com/elastic/beats/libbeat/common/bytes.go index 08d026ed93..a2a7aa390a 100644 --- a/vendor/github.com/elastic/beats/libbeat/common/bytes.go +++ b/vendor/github.com/elastic/beats/libbeat/common/bytes.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package common import ( diff --git a/vendor/github.com/elastic/beats/libbeat/common/cache.go b/vendor/github.com/elastic/beats/libbeat/common/cache.go index 09e6bcc7e5..25f3be7d92 100644 --- a/vendor/github.com/elastic/beats/libbeat/common/cache.go +++ b/vendor/github.com/elastic/beats/libbeat/common/cache.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package common import ( diff --git a/vendor/github.com/elastic/beats/libbeat/common/cfgtype/byte_size.go b/vendor/github.com/elastic/beats/libbeat/common/cfgtype/byte_size.go index b6bc106c94..9667fbaa8f 100644 --- a/vendor/github.com/elastic/beats/libbeat/common/cfgtype/byte_size.go +++ b/vendor/github.com/elastic/beats/libbeat/common/cfgtype/byte_size.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package cfgtype import ( diff --git a/vendor/github.com/elastic/beats/libbeat/common/cfgwarn/cfgwarn.go b/vendor/github.com/elastic/beats/libbeat/common/cfgwarn/cfgwarn.go index 56eb5d6666..f7ef2fba1d 100644 --- a/vendor/github.com/elastic/beats/libbeat/common/cfgwarn/cfgwarn.go +++ b/vendor/github.com/elastic/beats/libbeat/common/cfgwarn/cfgwarn.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package cfgwarn import ( diff --git a/vendor/github.com/elastic/beats/libbeat/common/cfgwarn/removed.go b/vendor/github.com/elastic/beats/libbeat/common/cfgwarn/removed.go index 05a7b82e2b..ba11bcb67c 100644 --- a/vendor/github.com/elastic/beats/libbeat/common/cfgwarn/removed.go +++ b/vendor/github.com/elastic/beats/libbeat/common/cfgwarn/removed.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package cfgwarn import ( diff --git a/vendor/github.com/elastic/beats/libbeat/common/cli/cli.go b/vendor/github.com/elastic/beats/libbeat/common/cli/cli.go index b608f95526..54e0ac8704 100644 --- a/vendor/github.com/elastic/beats/libbeat/common/cli/cli.go +++ b/vendor/github.com/elastic/beats/libbeat/common/cli/cli.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package cli import ( diff --git a/vendor/github.com/elastic/beats/libbeat/common/coerce.go b/vendor/github.com/elastic/beats/libbeat/common/coerce.go index e7d68cec69..ed96ec452b 100644 --- a/vendor/github.com/elastic/beats/libbeat/common/coerce.go +++ b/vendor/github.com/elastic/beats/libbeat/common/coerce.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package common import "strconv" diff --git a/vendor/github.com/elastic/beats/libbeat/common/config.go b/vendor/github.com/elastic/beats/libbeat/common/config.go index 98f8cfaf63..8a647b783d 100644 --- a/vendor/github.com/elastic/beats/libbeat/common/config.go +++ b/vendor/github.com/elastic/beats/libbeat/common/config.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package common import ( diff --git a/vendor/github.com/elastic/beats/libbeat/common/csv.go b/vendor/github.com/elastic/beats/libbeat/common/csv.go index ef42ea2588..9c38ea66bd 100644 --- a/vendor/github.com/elastic/beats/libbeat/common/csv.go +++ b/vendor/github.com/elastic/beats/libbeat/common/csv.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package common import ( diff --git a/vendor/github.com/elastic/beats/libbeat/common/datetime.go b/vendor/github.com/elastic/beats/libbeat/common/datetime.go index f464aa3030..c0eac0cc6f 100644 --- a/vendor/github.com/elastic/beats/libbeat/common/datetime.go +++ b/vendor/github.com/elastic/beats/libbeat/common/datetime.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package common import ( diff --git a/vendor/github.com/elastic/beats/libbeat/common/docker/client.go b/vendor/github.com/elastic/beats/libbeat/common/docker/client.go index 965fbb442c..3470602e2a 100644 --- a/vendor/github.com/elastic/beats/libbeat/common/docker/client.go +++ b/vendor/github.com/elastic/beats/libbeat/common/docker/client.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package docker import ( diff --git a/vendor/github.com/elastic/beats/libbeat/common/docker/watcher.go b/vendor/github.com/elastic/beats/libbeat/common/docker/watcher.go index 5c2e03fea4..def5b5eed7 100644 --- a/vendor/github.com/elastic/beats/libbeat/common/docker/watcher.go +++ b/vendor/github.com/elastic/beats/libbeat/common/docker/watcher.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package docker import ( @@ -76,6 +93,7 @@ type Container struct { // Client for docker interface type Client interface { ContainerList(ctx context.Context, options types.ContainerListOptions) ([]types.Container, error) + ContainerInspect(ctx context.Context, container string) (types.ContainerJSON, error) Events(ctx context.Context, options types.EventsOptions) (<-chan events.Message, <-chan error) } @@ -290,7 +308,20 @@ func (w *watcher) listContainers(options types.ContainerListOptions) ([]*Contain for _, c := range containers { var ipaddresses []string for _, net := range c.NetworkSettings.Networks { - ipaddresses = append(ipaddresses, net.IPAddress) + if net.IPAddress != "" { + ipaddresses = append(ipaddresses, net.IPAddress) + } + } + + // If there are no network interfaces, assume that the container is on host network + // Inspect the container directly and use the hostname as the IP address in order + if len(ipaddresses) == 0 { + info, err := w.client.ContainerInspect(w.ctx, c.ID) + if err == nil { + ipaddresses = append(ipaddresses, info.Config.Hostname) + } else { + logp.Warn("unable to inspect container %s due to error %v", c.ID, err) + } } result = append(result, &Container{ ID: c.ID, diff --git a/vendor/github.com/elastic/beats/libbeat/common/dtfmt/builder.go b/vendor/github.com/elastic/beats/libbeat/common/dtfmt/builder.go index 04cf4f9e4a..935a247840 100644 --- a/vendor/github.com/elastic/beats/libbeat/common/dtfmt/builder.go +++ b/vendor/github.com/elastic/beats/libbeat/common/dtfmt/builder.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package dtfmt type builder struct { diff --git a/vendor/github.com/elastic/beats/libbeat/common/dtfmt/ctx.go b/vendor/github.com/elastic/beats/libbeat/common/dtfmt/ctx.go index b14e1245fd..7b8314f0b1 100644 --- a/vendor/github.com/elastic/beats/libbeat/common/dtfmt/ctx.go +++ b/vendor/github.com/elastic/beats/libbeat/common/dtfmt/ctx.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package dtfmt import ( diff --git a/vendor/github.com/elastic/beats/libbeat/common/dtfmt/doc.go b/vendor/github.com/elastic/beats/libbeat/common/dtfmt/doc.go index 5e43f05f67..a204929f5e 100644 --- a/vendor/github.com/elastic/beats/libbeat/common/dtfmt/doc.go +++ b/vendor/github.com/elastic/beats/libbeat/common/dtfmt/doc.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + // Package dtfmt provides time formatter support with pattern syntax mostly // similar to joda DateTimeFormat. The pattern syntax supported is a subset // (mostly compatible) with joda DateTimeFormat. diff --git a/vendor/github.com/elastic/beats/libbeat/common/dtfmt/dtfmt.go b/vendor/github.com/elastic/beats/libbeat/common/dtfmt/dtfmt.go index 65f3e25b7e..3c35a38175 100644 --- a/vendor/github.com/elastic/beats/libbeat/common/dtfmt/dtfmt.go +++ b/vendor/github.com/elastic/beats/libbeat/common/dtfmt/dtfmt.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package dtfmt import ( diff --git a/vendor/github.com/elastic/beats/libbeat/common/dtfmt/elems.go b/vendor/github.com/elastic/beats/libbeat/common/dtfmt/elems.go index d0eb7a0488..4ffb6cd908 100644 --- a/vendor/github.com/elastic/beats/libbeat/common/dtfmt/elems.go +++ b/vendor/github.com/elastic/beats/libbeat/common/dtfmt/elems.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package dtfmt import ( diff --git a/vendor/github.com/elastic/beats/libbeat/common/dtfmt/fields.go b/vendor/github.com/elastic/beats/libbeat/common/dtfmt/fields.go index 41355d61a3..29fc2a1dc5 100644 --- a/vendor/github.com/elastic/beats/libbeat/common/dtfmt/fields.go +++ b/vendor/github.com/elastic/beats/libbeat/common/dtfmt/fields.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package dtfmt import ( diff --git a/vendor/github.com/elastic/beats/libbeat/common/dtfmt/fmt.go b/vendor/github.com/elastic/beats/libbeat/common/dtfmt/fmt.go index 7103a1d61e..d4ae87a196 100644 --- a/vendor/github.com/elastic/beats/libbeat/common/dtfmt/fmt.go +++ b/vendor/github.com/elastic/beats/libbeat/common/dtfmt/fmt.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package dtfmt import ( diff --git a/vendor/github.com/elastic/beats/libbeat/common/dtfmt/prog.go b/vendor/github.com/elastic/beats/libbeat/common/dtfmt/prog.go index 1ef7962a7d..cee6f3d473 100644 --- a/vendor/github.com/elastic/beats/libbeat/common/dtfmt/prog.go +++ b/vendor/github.com/elastic/beats/libbeat/common/dtfmt/prog.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package dtfmt import ( diff --git a/vendor/github.com/elastic/beats/libbeat/common/dtfmt/util.go b/vendor/github.com/elastic/beats/libbeat/common/dtfmt/util.go index 84dc4bcea7..f6b5a0c48d 100644 --- a/vendor/github.com/elastic/beats/libbeat/common/dtfmt/util.go +++ b/vendor/github.com/elastic/beats/libbeat/common/dtfmt/util.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package dtfmt import ( diff --git a/vendor/github.com/elastic/beats/libbeat/common/endpoint.go b/vendor/github.com/elastic/beats/libbeat/common/endpoint.go index 8150b84de4..70989ba9bd 100644 --- a/vendor/github.com/elastic/beats/libbeat/common/endpoint.go +++ b/vendor/github.com/elastic/beats/libbeat/common/endpoint.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package common // Endpoint represents an endpoint in the communication. diff --git a/vendor/github.com/elastic/beats/libbeat/common/event.go b/vendor/github.com/elastic/beats/libbeat/common/event.go index 65e7a4ce8c..e2c4fe4294 100644 --- a/vendor/github.com/elastic/beats/libbeat/common/event.go +++ b/vendor/github.com/elastic/beats/libbeat/common/event.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package common import ( diff --git a/vendor/github.com/elastic/beats/libbeat/common/field.go b/vendor/github.com/elastic/beats/libbeat/common/field.go index 7681870869..115b05636e 100644 --- a/vendor/github.com/elastic/beats/libbeat/common/field.go +++ b/vendor/github.com/elastic/beats/libbeat/common/field.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package common import ( diff --git a/vendor/github.com/elastic/beats/libbeat/common/file/file_other.go b/vendor/github.com/elastic/beats/libbeat/common/file/file_other.go index 9e1fb96711..1ac4ecb2cd 100644 --- a/vendor/github.com/elastic/beats/libbeat/common/file/file_other.go +++ b/vendor/github.com/elastic/beats/libbeat/common/file/file_other.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + // +build !windows package file diff --git a/vendor/github.com/elastic/beats/libbeat/common/file/file_windows.go b/vendor/github.com/elastic/beats/libbeat/common/file/file_windows.go index dd31ccacd3..98ae70a0c0 100644 --- a/vendor/github.com/elastic/beats/libbeat/common/file/file_windows.go +++ b/vendor/github.com/elastic/beats/libbeat/common/file/file_windows.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package file import ( diff --git a/vendor/github.com/elastic/beats/libbeat/common/file/fileinfo.go b/vendor/github.com/elastic/beats/libbeat/common/file/fileinfo.go index 05e9f2d288..6b3027ad8a 100644 --- a/vendor/github.com/elastic/beats/libbeat/common/file/fileinfo.go +++ b/vendor/github.com/elastic/beats/libbeat/common/file/fileinfo.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package file import ( diff --git a/vendor/github.com/elastic/beats/libbeat/common/file/fileinfo_unix.go b/vendor/github.com/elastic/beats/libbeat/common/file/fileinfo_unix.go index 68d60b1cb8..80f5ccf712 100644 --- a/vendor/github.com/elastic/beats/libbeat/common/file/fileinfo_unix.go +++ b/vendor/github.com/elastic/beats/libbeat/common/file/fileinfo_unix.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + // +build !windows package file diff --git a/vendor/github.com/elastic/beats/libbeat/common/file/fileinfo_windows.go b/vendor/github.com/elastic/beats/libbeat/common/file/fileinfo_windows.go index e6ae54ae35..5d8e3dfa8d 100644 --- a/vendor/github.com/elastic/beats/libbeat/common/file/fileinfo_windows.go +++ b/vendor/github.com/elastic/beats/libbeat/common/file/fileinfo_windows.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package file import ( diff --git a/vendor/github.com/elastic/beats/libbeat/common/file/helper_other.go b/vendor/github.com/elastic/beats/libbeat/common/file/helper_other.go index 43282eb52c..7c9f87667d 100644 --- a/vendor/github.com/elastic/beats/libbeat/common/file/helper_other.go +++ b/vendor/github.com/elastic/beats/libbeat/common/file/helper_other.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + // +build !windows package file diff --git a/vendor/github.com/elastic/beats/libbeat/common/file/helper_windows.go b/vendor/github.com/elastic/beats/libbeat/common/file/helper_windows.go index 43aca36edc..a692242352 100644 --- a/vendor/github.com/elastic/beats/libbeat/common/file/helper_windows.go +++ b/vendor/github.com/elastic/beats/libbeat/common/file/helper_windows.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package file import ( diff --git a/vendor/github.com/elastic/beats/libbeat/common/file/rotator.go b/vendor/github.com/elastic/beats/libbeat/common/file/rotator.go index d208ce07a4..229abcdead 100644 --- a/vendor/github.com/elastic/beats/libbeat/common/file/rotator.go +++ b/vendor/github.com/elastic/beats/libbeat/common/file/rotator.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package file import ( diff --git a/vendor/github.com/elastic/beats/libbeat/common/flags.go b/vendor/github.com/elastic/beats/libbeat/common/flags.go index a78201d6b3..959aef461b 100644 --- a/vendor/github.com/elastic/beats/libbeat/common/flags.go +++ b/vendor/github.com/elastic/beats/libbeat/common/flags.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package common import ( diff --git a/vendor/github.com/elastic/beats/libbeat/common/fmtstr/formatevents.go b/vendor/github.com/elastic/beats/libbeat/common/fmtstr/formatevents.go index 724d66e3f4..da03776457 100644 --- a/vendor/github.com/elastic/beats/libbeat/common/fmtstr/formatevents.go +++ b/vendor/github.com/elastic/beats/libbeat/common/fmtstr/formatevents.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package fmtstr import ( diff --git a/vendor/github.com/elastic/beats/libbeat/common/fmtstr/formatstring.go b/vendor/github.com/elastic/beats/libbeat/common/fmtstr/formatstring.go index ee46a05737..8ed1eb8eac 100644 --- a/vendor/github.com/elastic/beats/libbeat/common/fmtstr/formatstring.go +++ b/vendor/github.com/elastic/beats/libbeat/common/fmtstr/formatstring.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package fmtstr import ( diff --git a/vendor/github.com/elastic/beats/libbeat/common/jsontransform/jsonhelper.go b/vendor/github.com/elastic/beats/libbeat/common/jsontransform/jsonhelper.go index 58f7df6582..98a1da5ef5 100644 --- a/vendor/github.com/elastic/beats/libbeat/common/jsontransform/jsonhelper.go +++ b/vendor/github.com/elastic/beats/libbeat/common/jsontransform/jsonhelper.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package jsontransform import ( diff --git a/vendor/github.com/elastic/beats/libbeat/common/jsontransform/transform.go b/vendor/github.com/elastic/beats/libbeat/common/jsontransform/transform.go index a6d065ee43..dbb2d27c85 100644 --- a/vendor/github.com/elastic/beats/libbeat/common/jsontransform/transform.go +++ b/vendor/github.com/elastic/beats/libbeat/common/jsontransform/transform.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package jsontransform import ( diff --git a/vendor/github.com/elastic/beats/libbeat/common/kubernetes/eventhandler.go b/vendor/github.com/elastic/beats/libbeat/common/kubernetes/eventhandler.go index b651e465e2..a80a7894c6 100644 --- a/vendor/github.com/elastic/beats/libbeat/common/kubernetes/eventhandler.go +++ b/vendor/github.com/elastic/beats/libbeat/common/kubernetes/eventhandler.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package kubernetes // ResourceEventHandler can handle notifications for events that happen to a diff --git a/vendor/github.com/elastic/beats/libbeat/common/kubernetes/metadata.go b/vendor/github.com/elastic/beats/libbeat/common/kubernetes/metadata.go index 2879b7ab2d..321618d77e 100644 --- a/vendor/github.com/elastic/beats/libbeat/common/kubernetes/metadata.go +++ b/vendor/github.com/elastic/beats/libbeat/common/kubernetes/metadata.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package kubernetes import ( @@ -54,29 +71,29 @@ func (g *metaGenerator) PodMetadata(pod *Pod) common.MapStr { annotationsMap := generateMapSubset(pod.Metadata.Annotations, g.IncludeAnnotations) meta := common.MapStr{ "pod": common.MapStr{ - "name": pod.Metadata.Name, + "name": pod.Metadata.GetName(), }, "node": common.MapStr{ - "name": pod.Spec.NodeName, + "name": pod.Spec.GetNodeName(), }, - "namespace": pod.Metadata.Namespace, + "namespace": pod.Metadata.GetNamespace(), } // Add Pod UID metadata if enabled if g.IncludePodUID { - safemapstr.Put(meta, "pod.uid", pod.Metadata.UID) + safemapstr.Put(meta, "pod.uid", pod.Metadata.GetUid()) } // Add controller metadata if present if g.IncludeCreatorMetadata { for _, ref := range pod.Metadata.OwnerReferences { - if ref.Controller { - switch ref.Kind { + if ref.GetController() { + switch ref.GetKind() { // TODO grow this list as we keep adding more `state_*` metricsets case "Deployment", "ReplicaSet", "StatefulSet": - safemapstr.Put(meta, strings.ToLower(ref.Kind)+".name", ref.Name) + safemapstr.Put(meta, strings.ToLower(ref.GetKind())+".name", ref.GetName()) } } } diff --git a/vendor/github.com/elastic/beats/libbeat/common/kubernetes/types.go b/vendor/github.com/elastic/beats/libbeat/common/kubernetes/types.go index efd09728f5..8494ff6338 100644 --- a/vendor/github.com/elastic/beats/libbeat/common/kubernetes/types.go +++ b/vendor/github.com/elastic/beats/libbeat/common/kubernetes/types.go @@ -1,12 +1,29 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package kubernetes import ( - "encoding/json" "strings" "time" "github.com/ericchiang/k8s" "github.com/ericchiang/k8s/apis/core/v1" + metav1 "github.com/ericchiang/k8s/apis/meta/v1" ) func init() { @@ -14,132 +31,47 @@ func init() { k8s.RegisterList("", "v1", "events", true, &v1.EventList{}) } -// Resource is kind of kubernetes resource like pod, event, etc... -// It has a GetMetadata method for getting ObjectMeta which containing useful info like labels -type Resource interface { - GetMetadata() *ObjectMeta -} - -func resourceConverter(k8sObj k8s.Resource, r Resource) Resource { - bytes, _ := json.Marshal(k8sObj) - json.Unmarshal(bytes, r) - return r -} +// Resource data +type Resource = k8s.Resource -type ObjectMeta struct { - Annotations map[string]string `json:"annotations"` - CreationTimestamp string `json:"creationTimestamp"` - DeletionTimestamp string `json:"deletionTimestamp"` - GenerateName string `json:"generateName"` - Labels map[string]string `json:"labels"` - Name string `json:"name"` - Namespace string `json:"namespace"` - OwnerReferences []struct { - APIVersion string `json:"apiVersion"` - Controller bool `json:"controller"` - Kind string `json:"kind"` - Name string `json:"name"` - UID string `json:"uid"` - } `json:"ownerReferences"` - ResourceVersion string `json:"resourceVersion"` - SelfLink string `json:"selfLink"` - UID string `json:"uid"` -} +// ObjectMeta data +type ObjectMeta = metav1.ObjectMeta -type Container struct { - Image string `json:"image"` - ImagePullPolicy string `json:"imagePullPolicy"` - Name string `json:"name"` - Ports []ContainerPort `json:"ports"` - Resources struct{} `json:"resources"` - TerminationMessagePath string `json:"terminationMessagePath"` - VolumeMounts []struct { - MountPath string `json:"mountPath"` - Name string `json:"name"` - ReadOnly bool `json:"readOnly"` - } `json:"volumeMounts"` -} +// Pod data +type Pod = v1.Pod -type ContainerPort struct { - Name string `json:"name"` - ContainerPort int64 `json:"containerPort"` - Protocol string `json:"protocol"` -} +// PodSpec data +type PodSpec = v1.PodSpec -type PodSpec struct { - Containers []Container `json:"containers"` - InitContainers []Container `json:"initContainers"` - DNSPolicy string `json:"dnsPolicy"` - NodeName string `json:"nodeName"` - RestartPolicy string `json:"restartPolicy"` - SecurityContext struct{} `json:"securityContext"` - ServiceAccount string `json:"serviceAccount"` - ServiceAccountName string `json:"serviceAccountName"` - TerminationGracePeriodSeconds int64 `json:"terminationGracePeriodSeconds"` -} +// PodStatus data +type PodStatus = v1.PodStatus -type PodStatusCondition struct { - LastProbeTime interface{} `json:"lastProbeTime"` - LastTransitionTime string `json:"lastTransitionTime"` - Status string `json:"status"` - Type string `json:"type"` -} +// Container data +type Container = v1.Container -type PodContainerStatus struct { - ContainerID string `json:"containerID"` - Image string `json:"image"` - ImageID string `json:"imageID"` - LastState struct { - Terminated struct { - ContainerID string `json:"containerID"` - ExitCode int64 `json:"exitCode"` - FinishedAt string `json:"finishedAt"` - Reason string `json:"reason"` - StartedAt string `json:"startedAt"` - } `json:"terminated"` - } `json:"lastState"` - Name string `json:"name"` - Ready bool `json:"ready"` - RestartCount int64 `json:"restartCount"` - State struct { - Running struct { - StartedAt string `json:"startedAt"` - } `json:"running"` - } `json:"state"` -} +// ContainerPort data +type ContainerPort = v1.ContainerPort -type PodStatus struct { - Conditions []PodStatusCondition `json:"conditions"` - ContainerStatuses []PodContainerStatus `json:"containerStatuses"` - InitContainerStatuses []PodContainerStatus `json:"initContainerStatuses"` - HostIP string `json:"hostIP"` - Phase string `json:"phase"` - PodIP string `json:"podIP"` - StartTime string `json:"startTime"` -} +// Event data +type Event = v1.Event -type Pod struct { - APIVersion string `json:"apiVersion"` - Kind string `json:"kind"` - Metadata ObjectMeta `json:"metadata"` - Spec PodSpec `json:"spec"` - Status PodStatus `json:"status"` -} +// PodContainerStatus data +type PodContainerStatus = v1.ContainerStatus -// GetMetadata implements Resource -func (p *Pod) GetMetadata() *ObjectMeta { - return &p.Metadata +// Time extracts time from k8s.Time type +func Time(t *metav1.Time) time.Time { + return time.Unix(t.GetSeconds(), int64(t.GetNanos())) } -// GetContainerID parses the container ID to get the actual ID string -func (s *PodContainerStatus) GetContainerID() string { - cID, _ := s.GetContainerIDWithRuntime() +// ContainerID parses the container ID to get the actual ID string +func ContainerID(s *PodContainerStatus) string { + cID, _ := ContainerIDWithRuntime(s) return cID } -// GetContainerIDWithRuntime parses the container ID to get the actual ID string -func (s *PodContainerStatus) GetContainerIDWithRuntime() (string, string) { - cID := s.ContainerID +// ContainerIDWithRuntime parses the container ID to get the actual ID string +func ContainerIDWithRuntime(s *PodContainerStatus) (string, string) { + cID := s.GetContainerID() if cID != "" { parts := strings.Split(cID, "://") if len(parts) == 2 { @@ -148,32 +80,3 @@ func (s *PodContainerStatus) GetContainerIDWithRuntime() (string, string) { } return "", "" } - -// Event is kubernetes event -type Event struct { - APIVersion string `json:"apiVersion"` - Count int64 `json:"count"` - FirstTimestamp *time.Time `json:"firstTimestamp"` - InvolvedObject struct { - APIVersion string `json:"apiVersion"` - Kind string `json:"kind"` - Name string `json:"name"` - ResourceVersion string `json:"resourceVersion"` - UID string `json:"uid"` - } `json:"involvedObject"` - Kind string `json:"kind"` - LastTimestamp *time.Time `json:"lastTimestamp"` - Message string `json:"message"` - Metadata ObjectMeta `json:"metadata"` - Reason string `json:"reason"` - Source struct { - Component string `json:"component"` - Host string `json:"host"` - } `json:"source"` - Type string `json:"type"` -} - -// GetMetadata implements Resource -func (e *Event) GetMetadata() *ObjectMeta { - return &e.Metadata -} diff --git a/vendor/github.com/elastic/beats/libbeat/common/kubernetes/util.go b/vendor/github.com/elastic/beats/libbeat/common/kubernetes/util.go index a86c8b45c8..b8e1a0b55b 100644 --- a/vendor/github.com/elastic/beats/libbeat/common/kubernetes/util.go +++ b/vendor/github.com/elastic/beats/libbeat/common/kubernetes/util.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package kubernetes import ( diff --git a/vendor/github.com/elastic/beats/libbeat/common/kubernetes/watcher.go b/vendor/github.com/elastic/beats/libbeat/common/kubernetes/watcher.go index 29b64c25af..3129d0c8a9 100644 --- a/vendor/github.com/elastic/beats/libbeat/common/kubernetes/watcher.go +++ b/vendor/github.com/elastic/beats/libbeat/common/kubernetes/watcher.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package kubernetes import ( @@ -49,7 +66,6 @@ type watcher struct { stop context.CancelFunc resourceList k8s.ResourceList k8sResourceFactory func() k8s.Resource - resourceFactory func() Resource items func() []k8s.Resource handler ResourceEventHandler } @@ -75,7 +91,6 @@ func NewWatcher(client *k8s.Client, resource Resource, options WatchOptions) (Wa list := &v1.PodList{} w.resourceList = list w.k8sResourceFactory = func() k8s.Resource { return &v1.Pod{} } - w.resourceFactory = func() Resource { return &Pod{} } w.items = func() []k8s.Resource { rs := make([]k8s.Resource, 0, len(list.Items)) for _, item := range list.Items { @@ -87,7 +102,6 @@ func NewWatcher(client *k8s.Client, resource Resource, options WatchOptions) (Wa list := &v1.EventList{} w.resourceList = list w.k8sResourceFactory = func() k8s.Resource { return &v1.Event{} } - w.resourceFactory = func() Resource { return &Event{} } w.items = func() []k8s.Resource { rs := make([]k8s.Resource, 0, len(list.Items)) for _, item := range list.Items { @@ -135,16 +149,16 @@ func (w *watcher) sync() error { return nil } -func (w *watcher) onAdd(obj k8s.Resource) { - w.handler.OnAdd(resourceConverter(obj, w.resourceFactory())) +func (w *watcher) onAdd(obj Resource) { + w.handler.OnAdd(obj) } -func (w *watcher) onUpdate(obj k8s.Resource) { - w.handler.OnUpdate(resourceConverter(obj, w.resourceFactory())) +func (w *watcher) onUpdate(obj Resource) { + w.handler.OnUpdate(obj) } -func (w *watcher) onDelete(obj k8s.Resource) { - w.handler.OnDelete(resourceConverter(obj, w.resourceFactory())) +func (w *watcher) onDelete(obj Resource) { + w.handler.OnDelete(obj) } // Start watching pods diff --git a/vendor/github.com/elastic/beats/libbeat/common/mapstr.go b/vendor/github.com/elastic/beats/libbeat/common/mapstr.go index 508bd46c06..0bc2d4b2a1 100644 --- a/vendor/github.com/elastic/beats/libbeat/common/mapstr.go +++ b/vendor/github.com/elastic/beats/libbeat/common/mapstr.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package common import ( diff --git a/vendor/github.com/elastic/beats/libbeat/common/mapstr_pointer.go b/vendor/github.com/elastic/beats/libbeat/common/mapstr_pointer.go index 9042cfd8f9..714abc1f80 100644 --- a/vendor/github.com/elastic/beats/libbeat/common/mapstr_pointer.go +++ b/vendor/github.com/elastic/beats/libbeat/common/mapstr_pointer.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package common import ( diff --git a/vendor/github.com/elastic/beats/libbeat/common/match/cmp.go b/vendor/github.com/elastic/beats/libbeat/common/match/cmp.go index aaef24653a..1b04ac0830 100644 --- a/vendor/github.com/elastic/beats/libbeat/common/match/cmp.go +++ b/vendor/github.com/elastic/beats/libbeat/common/match/cmp.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package match import "regexp/syntax" diff --git a/vendor/github.com/elastic/beats/libbeat/common/match/compile.go b/vendor/github.com/elastic/beats/libbeat/common/match/compile.go index 2cf633cc99..fbdc8fc01b 100644 --- a/vendor/github.com/elastic/beats/libbeat/common/match/compile.go +++ b/vendor/github.com/elastic/beats/libbeat/common/match/compile.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package match import ( diff --git a/vendor/github.com/elastic/beats/libbeat/common/match/matcher.go b/vendor/github.com/elastic/beats/libbeat/common/match/matcher.go index c9577a2bc1..21c50bdc88 100644 --- a/vendor/github.com/elastic/beats/libbeat/common/match/matcher.go +++ b/vendor/github.com/elastic/beats/libbeat/common/match/matcher.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package match import "regexp/syntax" diff --git a/vendor/github.com/elastic/beats/libbeat/common/match/matchers.go b/vendor/github.com/elastic/beats/libbeat/common/match/matchers.go index c62dd85e77..d0c7e8f3eb 100644 --- a/vendor/github.com/elastic/beats/libbeat/common/match/matchers.go +++ b/vendor/github.com/elastic/beats/libbeat/common/match/matchers.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package match import ( diff --git a/vendor/github.com/elastic/beats/libbeat/common/match/optimize.go b/vendor/github.com/elastic/beats/libbeat/common/match/optimize.go index aa757c6a42..891b8847bc 100644 --- a/vendor/github.com/elastic/beats/libbeat/common/match/optimize.go +++ b/vendor/github.com/elastic/beats/libbeat/common/match/optimize.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package match import "regexp/syntax" diff --git a/vendor/github.com/elastic/beats/libbeat/common/math.go b/vendor/github.com/elastic/beats/libbeat/common/math.go index 9c039568da..9200a1bb84 100644 --- a/vendor/github.com/elastic/beats/libbeat/common/math.go +++ b/vendor/github.com/elastic/beats/libbeat/common/math.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package common import "math" diff --git a/vendor/github.com/elastic/beats/libbeat/common/net.go b/vendor/github.com/elastic/beats/libbeat/common/net.go index 0d25804622..6b7517d4c0 100644 --- a/vendor/github.com/elastic/beats/libbeat/common/net.go +++ b/vendor/github.com/elastic/beats/libbeat/common/net.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package common import ( diff --git a/vendor/github.com/elastic/beats/libbeat/common/safemapstr/safemapstr.go b/vendor/github.com/elastic/beats/libbeat/common/safemapstr/safemapstr.go index 80b4268bfd..75afe81226 100644 --- a/vendor/github.com/elastic/beats/libbeat/common/safemapstr/safemapstr.go +++ b/vendor/github.com/elastic/beats/libbeat/common/safemapstr/safemapstr.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package safemapstr import ( diff --git a/vendor/github.com/elastic/beats/libbeat/common/schema/doc.go b/vendor/github.com/elastic/beats/libbeat/common/schema/doc.go index b28885f8fd..b136bf0316 100644 --- a/vendor/github.com/elastic/beats/libbeat/common/schema/doc.go +++ b/vendor/github.com/elastic/beats/libbeat/common/schema/doc.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + /* Package schema contains helper utilities to parse, convert, rename, and reorganize data from the format returned by the various monitored systems to the data model used by diff --git a/vendor/github.com/elastic/beats/libbeat/common/schema/error.go b/vendor/github.com/elastic/beats/libbeat/common/schema/error.go index 31b6b50f45..85e2dfb002 100644 --- a/vendor/github.com/elastic/beats/libbeat/common/schema/error.go +++ b/vendor/github.com/elastic/beats/libbeat/common/schema/error.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package schema import "fmt" diff --git a/vendor/github.com/elastic/beats/libbeat/common/schema/errors.go b/vendor/github.com/elastic/beats/libbeat/common/schema/errors.go index 461e45b4d8..660a691069 100644 --- a/vendor/github.com/elastic/beats/libbeat/common/schema/errors.go +++ b/vendor/github.com/elastic/beats/libbeat/common/schema/errors.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package schema import ( diff --git a/vendor/github.com/elastic/beats/libbeat/common/schema/mapstriface/mapstriface.go b/vendor/github.com/elastic/beats/libbeat/common/schema/mapstriface/mapstriface.go index a903f5c092..91e811e9ec 100644 --- a/vendor/github.com/elastic/beats/libbeat/common/schema/mapstriface/mapstriface.go +++ b/vendor/github.com/elastic/beats/libbeat/common/schema/mapstriface/mapstriface.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + /* Package mapstriface contains utilities for transforming map[string]interface{} objects into metricbeat events. For example, given this input object: diff --git a/vendor/github.com/elastic/beats/libbeat/common/schema/schema.go b/vendor/github.com/elastic/beats/libbeat/common/schema/schema.go index 2516e7ecbd..ecfe760ba0 100644 --- a/vendor/github.com/elastic/beats/libbeat/common/schema/schema.go +++ b/vendor/github.com/elastic/beats/libbeat/common/schema/schema.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package schema import ( diff --git a/vendor/github.com/elastic/beats/libbeat/common/seccomp/policy_linux_386.go b/vendor/github.com/elastic/beats/libbeat/common/seccomp/policy_linux_386.go index ca3a7aa10c..c2c27515a1 100644 --- a/vendor/github.com/elastic/beats/libbeat/common/seccomp/policy_linux_386.go +++ b/vendor/github.com/elastic/beats/libbeat/common/seccomp/policy_linux_386.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package seccomp import ( diff --git a/vendor/github.com/elastic/beats/libbeat/common/seccomp/policy_linux_amd64.go b/vendor/github.com/elastic/beats/libbeat/common/seccomp/policy_linux_amd64.go index 4dce9b5725..00e5353b4f 100644 --- a/vendor/github.com/elastic/beats/libbeat/common/seccomp/policy_linux_amd64.go +++ b/vendor/github.com/elastic/beats/libbeat/common/seccomp/policy_linux_amd64.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package seccomp import ( diff --git a/vendor/github.com/elastic/beats/libbeat/common/seccomp/policy_linux_arm.go b/vendor/github.com/elastic/beats/libbeat/common/seccomp/policy_linux_arm.go index 27558580e3..78a8f68bb7 100644 --- a/vendor/github.com/elastic/beats/libbeat/common/seccomp/policy_linux_arm.go +++ b/vendor/github.com/elastic/beats/libbeat/common/seccomp/policy_linux_arm.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package seccomp import "github.com/elastic/go-seccomp-bpf" diff --git a/vendor/github.com/elastic/beats/libbeat/common/seccomp/seccomp.go b/vendor/github.com/elastic/beats/libbeat/common/seccomp/seccomp.go index fc98ff38da..ff4d682b66 100644 --- a/vendor/github.com/elastic/beats/libbeat/common/seccomp/seccomp.go +++ b/vendor/github.com/elastic/beats/libbeat/common/seccomp/seccomp.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package seccomp import ( diff --git a/vendor/github.com/elastic/beats/libbeat/common/statuses.go b/vendor/github.com/elastic/beats/libbeat/common/statuses.go index 2d5096ae21..33a6e2a86c 100644 --- a/vendor/github.com/elastic/beats/libbeat/common/statuses.go +++ b/vendor/github.com/elastic/beats/libbeat/common/statuses.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package common // standardized status values diff --git a/vendor/github.com/elastic/beats/libbeat/common/streambuf/ascii.go b/vendor/github.com/elastic/beats/libbeat/common/streambuf/ascii.go index b44e3a1806..5e8e443669 100644 --- a/vendor/github.com/elastic/beats/libbeat/common/streambuf/ascii.go +++ b/vendor/github.com/elastic/beats/libbeat/common/streambuf/ascii.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package streambuf // ASCII parsing support diff --git a/vendor/github.com/elastic/beats/libbeat/common/streambuf/io.go b/vendor/github.com/elastic/beats/libbeat/common/streambuf/io.go index b58b87114a..bea8e658c1 100644 --- a/vendor/github.com/elastic/beats/libbeat/common/streambuf/io.go +++ b/vendor/github.com/elastic/beats/libbeat/common/streambuf/io.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package streambuf import ( diff --git a/vendor/github.com/elastic/beats/libbeat/common/streambuf/net.go b/vendor/github.com/elastic/beats/libbeat/common/streambuf/net.go index 38ce9e7901..10ed41336d 100644 --- a/vendor/github.com/elastic/beats/libbeat/common/streambuf/net.go +++ b/vendor/github.com/elastic/beats/libbeat/common/streambuf/net.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package streambuf // read integers in network byte order diff --git a/vendor/github.com/elastic/beats/libbeat/common/streambuf/streambuf.go b/vendor/github.com/elastic/beats/libbeat/common/streambuf/streambuf.go index 949b61892f..fc3a271daa 100644 --- a/vendor/github.com/elastic/beats/libbeat/common/streambuf/streambuf.go +++ b/vendor/github.com/elastic/beats/libbeat/common/streambuf/streambuf.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + // Package streambuf provides helpers for buffering multiple packet payloads // and some general parsing functions. All parsing functions are re-entrant, // that is if a parse function fails due do not having buffered enough bytes yet diff --git a/vendor/github.com/elastic/beats/libbeat/common/string.go b/vendor/github.com/elastic/beats/libbeat/common/string.go index acc1feac53..d9cd6215a2 100644 --- a/vendor/github.com/elastic/beats/libbeat/common/string.go +++ b/vendor/github.com/elastic/beats/libbeat/common/string.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package common // NetString store the byte length of the data that follows, making it easier diff --git a/vendor/github.com/elastic/beats/libbeat/common/stringset.go b/vendor/github.com/elastic/beats/libbeat/common/stringset.go index c95496e20b..f3fcdd5f88 100644 --- a/vendor/github.com/elastic/beats/libbeat/common/stringset.go +++ b/vendor/github.com/elastic/beats/libbeat/common/stringset.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package common type StringSet map[string]struct{} diff --git a/vendor/github.com/elastic/beats/libbeat/common/terminal/terminal.go b/vendor/github.com/elastic/beats/libbeat/common/terminal/terminal.go index 613c851f8b..2579edc299 100644 --- a/vendor/github.com/elastic/beats/libbeat/common/terminal/terminal.go +++ b/vendor/github.com/elastic/beats/libbeat/common/terminal/terminal.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package terminal import ( diff --git a/vendor/github.com/elastic/beats/libbeat/common/transport/tlscommon/config.go b/vendor/github.com/elastic/beats/libbeat/common/transport/tlscommon/config.go index 9e89f2eea3..80530ed750 100644 --- a/vendor/github.com/elastic/beats/libbeat/common/transport/tlscommon/config.go +++ b/vendor/github.com/elastic/beats/libbeat/common/transport/tlscommon/config.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package tlscommon import ( diff --git a/vendor/github.com/elastic/beats/libbeat/common/transport/tlscommon/server_config.go b/vendor/github.com/elastic/beats/libbeat/common/transport/tlscommon/server_config.go index 63b0a4b38c..c2d3e26840 100644 --- a/vendor/github.com/elastic/beats/libbeat/common/transport/tlscommon/server_config.go +++ b/vendor/github.com/elastic/beats/libbeat/common/transport/tlscommon/server_config.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package tlscommon import ( diff --git a/vendor/github.com/elastic/beats/libbeat/common/transport/tlscommon/tls.go b/vendor/github.com/elastic/beats/libbeat/common/transport/tlscommon/tls.go index d90c2500b3..6fe79e8df1 100644 --- a/vendor/github.com/elastic/beats/libbeat/common/transport/tlscommon/tls.go +++ b/vendor/github.com/elastic/beats/libbeat/common/transport/tlscommon/tls.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package tlscommon import ( diff --git a/vendor/github.com/elastic/beats/libbeat/common/transport/tlscommon/tls_config.go b/vendor/github.com/elastic/beats/libbeat/common/transport/tlscommon/tls_config.go index e4d9bca14b..f7bb14188c 100644 --- a/vendor/github.com/elastic/beats/libbeat/common/transport/tlscommon/tls_config.go +++ b/vendor/github.com/elastic/beats/libbeat/common/transport/tlscommon/tls_config.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package tlscommon import ( diff --git a/vendor/github.com/elastic/beats/libbeat/common/transport/tlscommon/types.go b/vendor/github.com/elastic/beats/libbeat/common/transport/tlscommon/types.go index eae535b6e7..d8a58b8279 100644 --- a/vendor/github.com/elastic/beats/libbeat/common/transport/tlscommon/types.go +++ b/vendor/github.com/elastic/beats/libbeat/common/transport/tlscommon/types.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package tlscommon import ( diff --git a/vendor/github.com/elastic/beats/libbeat/common/tuples.go b/vendor/github.com/elastic/beats/libbeat/common/tuples.go index 506bf3254d..9a31c72a60 100644 --- a/vendor/github.com/elastic/beats/libbeat/common/tuples.go +++ b/vendor/github.com/elastic/beats/libbeat/common/tuples.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package common import ( diff --git a/vendor/github.com/elastic/beats/libbeat/common/url.go b/vendor/github.com/elastic/beats/libbeat/common/url.go index 1ac6d14a64..327edeef99 100644 --- a/vendor/github.com/elastic/beats/libbeat/common/url.go +++ b/vendor/github.com/elastic/beats/libbeat/common/url.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package common import ( diff --git a/vendor/github.com/elastic/beats/libbeat/common/version.go b/vendor/github.com/elastic/beats/libbeat/common/version.go index b68154a09f..795eb2b8dd 100644 --- a/vendor/github.com/elastic/beats/libbeat/common/version.go +++ b/vendor/github.com/elastic/beats/libbeat/common/version.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package common import ( diff --git a/vendor/github.com/elastic/beats/libbeat/dashboards/config.go b/vendor/github.com/elastic/beats/libbeat/dashboards/config.go index ce7d09b1e8..bfd4b73d3f 100644 --- a/vendor/github.com/elastic/beats/libbeat/dashboards/config.go +++ b/vendor/github.com/elastic/beats/libbeat/dashboards/config.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package dashboards import "time" diff --git a/vendor/github.com/elastic/beats/libbeat/dashboards/dashboards.go b/vendor/github.com/elastic/beats/libbeat/dashboards/dashboards.go index b22761ddd8..8bda834f03 100644 --- a/vendor/github.com/elastic/beats/libbeat/dashboards/dashboards.go +++ b/vendor/github.com/elastic/beats/libbeat/dashboards/dashboards.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package dashboards import ( diff --git a/vendor/github.com/elastic/beats/libbeat/dashboards/es_loader.go b/vendor/github.com/elastic/beats/libbeat/dashboards/es_loader.go index 4f63821b39..95b0415cd8 100644 --- a/vendor/github.com/elastic/beats/libbeat/dashboards/es_loader.go +++ b/vendor/github.com/elastic/beats/libbeat/dashboards/es_loader.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package dashboards import ( diff --git a/vendor/github.com/elastic/beats/libbeat/dashboards/importer.go b/vendor/github.com/elastic/beats/libbeat/dashboards/importer.go index 7256b3d2fc..481006baa1 100644 --- a/vendor/github.com/elastic/beats/libbeat/dashboards/importer.go +++ b/vendor/github.com/elastic/beats/libbeat/dashboards/importer.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package dashboards import ( diff --git a/vendor/github.com/elastic/beats/libbeat/dashboards/kibana_loader.go b/vendor/github.com/elastic/beats/libbeat/dashboards/kibana_loader.go index 0218c653f2..8a09e72bfa 100644 --- a/vendor/github.com/elastic/beats/libbeat/dashboards/kibana_loader.go +++ b/vendor/github.com/elastic/beats/libbeat/dashboards/kibana_loader.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package dashboards import ( diff --git a/vendor/github.com/elastic/beats/libbeat/dashboards/modify_json.go b/vendor/github.com/elastic/beats/libbeat/dashboards/modify_json.go index 75c9ff1565..be31fa8b84 100644 --- a/vendor/github.com/elastic/beats/libbeat/dashboards/modify_json.go +++ b/vendor/github.com/elastic/beats/libbeat/dashboards/modify_json.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package dashboards import ( diff --git a/vendor/github.com/elastic/beats/libbeat/feature/bundle.go b/vendor/github.com/elastic/beats/libbeat/feature/bundle.go new file mode 100644 index 0000000000..fb85e43af7 --- /dev/null +++ b/vendor/github.com/elastic/beats/libbeat/feature/bundle.go @@ -0,0 +1,62 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package feature + +// Bundleable merges featurable and bundle interface together. +type bundleable interface { + Features() []Featurable +} + +// Bundle defines a list of features available in the current beat. +type Bundle struct { + features []Featurable +} + +// NewBundle creates a new Bundle of feature to be registered. +func NewBundle(features ...Featurable) *Bundle { + return &Bundle{features: features} +} + +// Filter creates a new bundle with only the feature matching the requested stability. +func (b *Bundle) Filter(stabilities ...Stability) *Bundle { + var filtered []Featurable + + for _, feature := range b.features { + for _, stability := range stabilities { + if feature.Stability() == stability { + filtered = append(filtered, feature) + break + } + } + } + return NewBundle(filtered...) +} + +// Features returns the interface features slice so +func (b *Bundle) Features() []Featurable { + return b.features +} + +// MustBundle takes existing bundle or features and create a new Bundle with all the merged Features. +func MustBundle(bundle ...bundleable) *Bundle { + var merged []Featurable + for _, feature := range bundle { + merged = append(merged, feature.Features()...) + } + return NewBundle(merged...) +} diff --git a/vendor/github.com/elastic/beats/libbeat/feature/feature.go b/vendor/github.com/elastic/beats/libbeat/feature/feature.go new file mode 100644 index 0000000000..5dc13c0d5c --- /dev/null +++ b/vendor/github.com/elastic/beats/libbeat/feature/feature.go @@ -0,0 +1,120 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package feature + +import ( + "fmt" +) + +// Registry is the global plugin registry, this variable is meant to be temporary to move all the +// internal factory to receive a context that include the current beat registry. +var Registry = newRegistry() + +// Featurable implements the description of a feature. +type Featurable interface { + bundleable + + // Namespace is the kind of plugin or functionality we want to expose as a feature. + // Examples: Autodiscover's provider, processors, outputs. + Namespace() string + + // Name is the name of the feature, the name must unique by namespace and be a description of the + // actual functionality, it is usually the name of the package. + // Examples: dissect, elasticsearch, redis + Name() string + + // Factory returns the function used to create an instance of the Feature, the signature + // of the method is type checked by the 'FindFactory' of each namespace. + Factory() interface{} + + // Stability is the stability of the Feature, this allow the user to filter embedded functionality + // by their maturity at runtime. + // Example: Beta, Experimental, Stable or Undefined. + Stability() Stability + + String() string +} + +// Feature contains the information for a specific feature +type Feature struct { + namespace string + name string + factory interface{} + stability Stability +} + +// Namespace return the namespace of the feature. +func (f *Feature) Namespace() string { + return f.namespace +} + +// Name returns the name of the feature. +func (f *Feature) Name() string { + return f.name +} + +// Factory returns the factory for the feature. +func (f *Feature) Factory() interface{} { + return f.factory +} + +// Stability returns the stability level of the feature, current: stable, beta, experimental. +func (f *Feature) Stability() Stability { + return f.stability +} + +// Features return the current feature as a slice to be compatible with Bundle merging and filtering. +func (f *Feature) Features() []Featurable { + return []Featurable{f} +} + +// String return the debug information +func (f *Feature) String() string { + return fmt.Sprintf("%s/%s (stability: %s)", f.namespace, f.name, f.stability) +} + +// New returns a new Feature. +func New(namespace, name string, factory interface{}, stability Stability) *Feature { + return &Feature{ + namespace: namespace, + name: name, + factory: factory, + stability: stability, + } +} + +// RegisterBundle registers a bundle of features. +func RegisterBundle(bundle *Bundle) error { + for _, f := range bundle.Features() { + Registry.Register(f) + } + return nil +} + +// Register register a new feature on the global registry. +func Register(feature Featurable) error { + return Registry.Register(feature) +} + +// MustRegister register a new Feature on the global registry and panic on error. +func MustRegister(feature Featurable) { + err := Register(feature) + if err != nil { + panic(err) + } +} diff --git a/vendor/github.com/elastic/beats/libbeat/feature/registry.go b/vendor/github.com/elastic/beats/libbeat/feature/registry.go new file mode 100644 index 0000000000..905f0f5527 --- /dev/null +++ b/vendor/github.com/elastic/beats/libbeat/feature/registry.go @@ -0,0 +1,189 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package feature + +import ( + "fmt" + "reflect" + "strings" + "sync" + + "github.com/elastic/beats/libbeat/logp" +) + +type mapper map[string]map[string]Featurable + +// Registry implements a global registry for any kind of feature in beats. +// feature are grouped by namespace, a namespace is a kind of plugin like outputs, inputs, or queue. +// The feature name must be unique. +type registry struct { + sync.RWMutex + namespaces mapper + log *logp.Logger +} + +// NewRegistry returns a new registry. +func newRegistry() *registry { + return ®istry{ + namespaces: make(mapper), + log: logp.NewLogger("registry"), + } +} + +// Register registers a new feature into a specific namespace, namespace are lazy created. +// Feature name must be unique. +func (r *registry) Register(feature Featurable) error { + r.Lock() + defer r.Unlock() + + ns := normalize(feature.Namespace()) + name := normalize(feature.Name()) + + if feature.Factory() == nil { + return fmt.Errorf("feature '%s' cannot be registered with a nil factory", name) + } + + // Lazy create namespaces + _, found := r.namespaces[ns] + if !found { + r.namespaces[ns] = make(map[string]Featurable) + } + + f, found := r.namespaces[ns][name] + if found { + if featuresEqual(feature, f) { + // Allow both old style and new style of plugin to work together. + r.log.Debugw( + "ignoring, feature '%s' is already registered in the namespace '%s'", + name, + ns, + ) + return nil + } + + return fmt.Errorf( + "could not register new feature '%s' in namespace '%s', feature name must be unique", + name, + ns, + ) + } + + r.log.Debugw( + "registering new feature", + "namespace", + ns, + "name", + name, + ) + + r.namespaces[ns][name] = feature + + return nil +} + +// Unregister removes a feature from the registry. +func (r *registry) Unregister(namespace, name string) error { + r.Lock() + defer r.Unlock() + ns := normalize(namespace) + + v, found := r.namespaces[ns] + if !found { + return fmt.Errorf("unknown namespace named '%s'", ns) + } + + _, found = v[name] + if !found { + return fmt.Errorf("unknown feature '%s' in namespace '%s'", name, ns) + } + + delete(r.namespaces[ns], name) + return nil +} + +// Lookup searches for a Feature by the namespace-name pair. +func (r *registry) Lookup(namespace, name string) (Featurable, error) { + r.RLock() + defer r.RUnlock() + + ns := normalize(namespace) + n := normalize(name) + + v, found := r.namespaces[ns] + if !found { + return nil, fmt.Errorf("unknown namespace named '%s'", ns) + } + + m, found := v[n] + if !found { + return nil, fmt.Errorf("unknown feature '%s' in namespace '%s'", n, ns) + } + + return m, nil +} + +// LookupAll returns all the features for a specific namespace. +func (r *registry) LookupAll(namespace string) ([]Featurable, error) { + r.RLock() + defer r.RUnlock() + + ns := normalize(namespace) + + v, found := r.namespaces[ns] + if !found { + return nil, fmt.Errorf("unknown namespace named '%s'", ns) + } + + list := make([]Featurable, len(v)) + c := 0 + for _, feature := range v { + list[c] = feature + c++ + } + + return list, nil +} + +// Size returns the number of registered features in the registry. +func (r *registry) Size() int { + r.RLock() + defer r.RUnlock() + + c := 0 + for _, namespace := range r.namespaces { + c += len(namespace) + } + + return c +} + +func featuresEqual(f1, f2 Featurable) bool { + // There is no safe way to compare function in go, + // but since the function pointers are global it should be stable. + if f1.Name() == f2.Name() && + f1.Namespace() == f2.Namespace() && + reflect.ValueOf(f1.Factory()).Pointer() == reflect.ValueOf(f2.Factory()).Pointer() { + return true + } + + return false +} + +func normalize(s string) string { + return strings.ToLower(s) +} diff --git a/vendor/github.com/elastic/beats/libbeat/feature/stability.go b/vendor/github.com/elastic/beats/libbeat/feature/stability.go new file mode 100644 index 0000000000..47a38322e1 --- /dev/null +++ b/vendor/github.com/elastic/beats/libbeat/feature/stability.go @@ -0,0 +1,31 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package feature + +//go:generate stringer -type=Stability + +// Stability defines the stability of the feature, this value can be used to filter a bundler. +type Stability int + +// List all the available stability for a feature. +const ( + Undefined Stability = iota + Stable + Beta + Experimental +) diff --git a/vendor/github.com/elastic/beats/libbeat/feature/stability_string.go b/vendor/github.com/elastic/beats/libbeat/feature/stability_string.go new file mode 100644 index 0000000000..459700a9e9 --- /dev/null +++ b/vendor/github.com/elastic/beats/libbeat/feature/stability_string.go @@ -0,0 +1,33 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +// Code generated by "stringer -type=Stability"; DO NOT EDIT. + +package feature + +import "strconv" + +const _Stability_name = "UndefinedStableBetaExperimental" + +var _Stability_index = [...]uint8{0, 9, 15, 19, 31} + +func (i Stability) String() string { + if i < 0 || i >= Stability(len(_Stability_index)-1) { + return "Stability(" + strconv.FormatInt(int64(i), 10) + ")" + } + return _Stability_name[_Stability_index[i]:_Stability_index[i+1]] +} diff --git a/vendor/github.com/elastic/beats/libbeat/generator/fields/fields.go b/vendor/github.com/elastic/beats/libbeat/generator/fields/fields.go index af432ff19b..68365dced9 100644 --- a/vendor/github.com/elastic/beats/libbeat/generator/fields/fields.go +++ b/vendor/github.com/elastic/beats/libbeat/generator/fields/fields.go @@ -1,7 +1,25 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package fields import ( "bufio" + "bytes" "fmt" "io/ioutil" "os" @@ -30,7 +48,7 @@ func collectBeatFiles(beatPath string, fieldFiles []*YmlFile) ([]*YmlFile, error } files := []*YmlFile{ - &YmlFile{ + { Path: commonFields, Indent: 0, }, @@ -47,33 +65,43 @@ func writeGeneratedFieldsYml(beatsPath string, fieldFiles []*YmlFile) error { } defer f.Close() + data, err := GenerateFieldsYml(fieldFiles) + if err != nil { + return err + } fw := bufio.NewWriter(f) + fw.Write(data) + return fw.Flush() +} + +// GenerateFieldsYml generates a fields.yml based on the given files +func GenerateFieldsYml(fieldFiles []*YmlFile) ([]byte, error) { + buf := bytes.NewBufferString("") for _, p := range fieldFiles { - ff, err := os.Open(p.Path) + file, err := os.Open(p.Path) if err != nil { - return err + return nil, err } - defer ff.Close() + defer file.Close() - fs := bufio.NewScanner(ff) + fs := bufio.NewScanner(file) for fs.Scan() { - err = writeIndentedLine(fw, fs.Text()+"\n", p.Indent) + err = writeIndentedLine(buf, fs.Text()+"\n", p.Indent) if err != nil { - return err + return nil, err } - } if err := fs.Err(); err != nil { - return err + return nil, err } } - return nil + return buf.Bytes(), nil } -func writeIndentedLine(fw *bufio.Writer, l string, indent int) error { - ll := strings.Repeat(" ", indent) + l - fmt.Fprint(fw, ll) - return fw.Flush() +func writeIndentedLine(buf *bytes.Buffer, line string, indent int) error { + newLine := strings.Repeat(" ", indent) + line + _, err := buf.WriteString(newLine) + return err } // Generate collects fields.yml files and concatenates them into one global file. @@ -145,5 +173,4 @@ func copyFileWithFlag(in, out string, flag int) error { _, err = output.Write(input) return err - } diff --git a/vendor/github.com/elastic/beats/libbeat/generator/fields/module_fields_collector.go b/vendor/github.com/elastic/beats/libbeat/generator/fields/module_fields_collector.go index 5725678610..1e89b38a58 100644 --- a/vendor/github.com/elastic/beats/libbeat/generator/fields/module_fields_collector.go +++ b/vendor/github.com/elastic/beats/libbeat/generator/fields/module_fields_collector.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package fields import ( @@ -13,17 +30,34 @@ var indentByModule = map[string]int{ "protos": 8, } +// GetModules returns a the list of modules for the given modules directory +func GetModules(modulesDir string) ([]string, error) { + moduleInfos, err := ioutil.ReadDir(modulesDir) + if err != nil { + return nil, err + } + + var names []string + for _, info := range moduleInfos { + if !info.IsDir() { + continue + } + names = append(names, info.Name()) + } + return names, nil +} + // CollectModuleFiles looks for fields.yml files under the -// specified root directory -func CollectModuleFiles(root string) ([]*YmlFile, error) { - modules, err := ioutil.ReadDir(root) +// specified modules directory +func CollectModuleFiles(modulesDir string) ([]*YmlFile, error) { + modules, err := GetModules(modulesDir) if err != nil { return nil, err } var files []*YmlFile for _, m := range modules { - f, err := collectFiles(m, root) + f, err := CollectFiles(m, modulesDir) if err != nil { return nil, err } @@ -33,13 +67,11 @@ func CollectModuleFiles(root string) ([]*YmlFile, error) { return files, nil } -func collectFiles(module os.FileInfo, modulesPath string) ([]*YmlFile, error) { - if !module.IsDir() { - return nil, nil - } +// CollectFiles collects all files for the given module including filesets +func CollectFiles(module string, modulesPath string) ([]*YmlFile, error) { var files []*YmlFile - fieldsYmlPath := filepath.Join(modulesPath, module.Name(), "_meta", "fields.yml") + fieldsYmlPath := filepath.Join(modulesPath, module, "_meta", "fields.yml") if _, err := os.Stat(fieldsYmlPath); !os.IsNotExist(err) { files = append(files, &YmlFile{ Path: fieldsYmlPath, @@ -50,7 +82,7 @@ func collectFiles(module os.FileInfo, modulesPath string) ([]*YmlFile, error) { } modulesRoot := filepath.Base(modulesPath) - sets, err := ioutil.ReadDir(filepath.Join(modulesPath, module.Name())) + sets, err := ioutil.ReadDir(filepath.Join(modulesPath, module)) if err != nil { return nil, err } @@ -59,8 +91,7 @@ func collectFiles(module os.FileInfo, modulesPath string) ([]*YmlFile, error) { if !s.IsDir() { continue } - - fieldsYmlPath = filepath.Join(modulesPath, module.Name(), s.Name(), "_meta", "fields.yml") + fieldsYmlPath = filepath.Join(modulesPath, module, s.Name(), "_meta", "fields.yml") if _, err = os.Stat(fieldsYmlPath); !os.IsNotExist(err) { files = append(files, &YmlFile{ Path: fieldsYmlPath, diff --git a/vendor/github.com/elastic/beats/libbeat/keystore/config.go b/vendor/github.com/elastic/beats/libbeat/keystore/config.go index 6156d33bed..16de2cd4a5 100644 --- a/vendor/github.com/elastic/beats/libbeat/keystore/config.go +++ b/vendor/github.com/elastic/beats/libbeat/keystore/config.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package keystore // Config Define keystore configurable options diff --git a/vendor/github.com/elastic/beats/libbeat/keystore/file_keystore.go b/vendor/github.com/elastic/beats/libbeat/keystore/file_keystore.go index 4ca43ec18b..a7eb7f5261 100644 --- a/vendor/github.com/elastic/beats/libbeat/keystore/file_keystore.go +++ b/vendor/github.com/elastic/beats/libbeat/keystore/file_keystore.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package keystore import ( diff --git a/vendor/github.com/elastic/beats/libbeat/keystore/keystore.go b/vendor/github.com/elastic/beats/libbeat/keystore/keystore.go index b7f29a671a..b7ec982083 100644 --- a/vendor/github.com/elastic/beats/libbeat/keystore/keystore.go +++ b/vendor/github.com/elastic/beats/libbeat/keystore/keystore.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package keystore import ( diff --git a/vendor/github.com/elastic/beats/libbeat/keystore/secure_string.go b/vendor/github.com/elastic/beats/libbeat/keystore/secure_string.go index baa3c3646d..d6f2ce9b55 100644 --- a/vendor/github.com/elastic/beats/libbeat/keystore/secure_string.go +++ b/vendor/github.com/elastic/beats/libbeat/keystore/secure_string.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package keystore // SecureString Initial implementation for a SecureString representation in diff --git a/vendor/github.com/elastic/beats/libbeat/kibana/client.go b/vendor/github.com/elastic/beats/libbeat/kibana/client.go index 2ed12ce39b..69b34700ae 100644 --- a/vendor/github.com/elastic/beats/libbeat/kibana/client.go +++ b/vendor/github.com/elastic/beats/libbeat/kibana/client.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package kibana import ( diff --git a/vendor/github.com/elastic/beats/libbeat/kibana/client_config.go b/vendor/github.com/elastic/beats/libbeat/kibana/client_config.go index c908a8e17d..25af90a810 100644 --- a/vendor/github.com/elastic/beats/libbeat/kibana/client_config.go +++ b/vendor/github.com/elastic/beats/libbeat/kibana/client_config.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package kibana import ( diff --git a/vendor/github.com/elastic/beats/libbeat/kibana/dashboard.go b/vendor/github.com/elastic/beats/libbeat/kibana/dashboard.go index 47ba251a72..6da7f39530 100644 --- a/vendor/github.com/elastic/beats/libbeat/kibana/dashboard.go +++ b/vendor/github.com/elastic/beats/libbeat/kibana/dashboard.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package kibana import ( diff --git a/vendor/github.com/elastic/beats/libbeat/kibana/fields_transformer.go b/vendor/github.com/elastic/beats/libbeat/kibana/fields_transformer.go index 777724b28b..34b0c96093 100644 --- a/vendor/github.com/elastic/beats/libbeat/kibana/fields_transformer.go +++ b/vendor/github.com/elastic/beats/libbeat/kibana/fields_transformer.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package kibana import ( diff --git a/vendor/github.com/elastic/beats/libbeat/kibana/index_pattern_generator.go b/vendor/github.com/elastic/beats/libbeat/kibana/index_pattern_generator.go index 398921ddba..46a1a74175 100644 --- a/vendor/github.com/elastic/beats/libbeat/kibana/index_pattern_generator.go +++ b/vendor/github.com/elastic/beats/libbeat/kibana/index_pattern_generator.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package kibana import ( diff --git a/vendor/github.com/elastic/beats/libbeat/kibana/transformer.go b/vendor/github.com/elastic/beats/libbeat/kibana/transformer.go index 9c32a5f5a7..9c4649e2ce 100644 --- a/vendor/github.com/elastic/beats/libbeat/kibana/transformer.go +++ b/vendor/github.com/elastic/beats/libbeat/kibana/transformer.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package kibana import ( diff --git a/vendor/github.com/elastic/beats/libbeat/logp/config.go b/vendor/github.com/elastic/beats/libbeat/logp/config.go index d2617c7681..7b894e6956 100644 --- a/vendor/github.com/elastic/beats/libbeat/logp/config.go +++ b/vendor/github.com/elastic/beats/libbeat/logp/config.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package logp // Config contains the configuration options for the logger. To create a Config diff --git a/vendor/github.com/elastic/beats/libbeat/logp/configure/logging.go b/vendor/github.com/elastic/beats/libbeat/logp/configure/logging.go index a1699b8b4d..c57acd4b39 100644 --- a/vendor/github.com/elastic/beats/libbeat/logp/configure/logging.go +++ b/vendor/github.com/elastic/beats/libbeat/logp/configure/logging.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package configure import ( diff --git a/vendor/github.com/elastic/beats/libbeat/logp/core.go b/vendor/github.com/elastic/beats/libbeat/logp/core.go index c5e4d61693..f117dc2ef7 100644 --- a/vendor/github.com/elastic/beats/libbeat/logp/core.go +++ b/vendor/github.com/elastic/beats/libbeat/logp/core.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package logp import ( diff --git a/vendor/github.com/elastic/beats/libbeat/logp/encoding.go b/vendor/github.com/elastic/beats/libbeat/logp/encoding.go index 77a4a3b106..9475d9ec0a 100644 --- a/vendor/github.com/elastic/beats/libbeat/logp/encoding.go +++ b/vendor/github.com/elastic/beats/libbeat/logp/encoding.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package logp import ( diff --git a/vendor/github.com/elastic/beats/libbeat/logp/eventlog_unsupported.go b/vendor/github.com/elastic/beats/libbeat/logp/eventlog_unsupported.go index f2b8ab78db..c6473f5c7e 100644 --- a/vendor/github.com/elastic/beats/libbeat/logp/eventlog_unsupported.go +++ b/vendor/github.com/elastic/beats/libbeat/logp/eventlog_unsupported.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + // +build !windows package logp diff --git a/vendor/github.com/elastic/beats/libbeat/logp/eventlog_windows.go b/vendor/github.com/elastic/beats/libbeat/logp/eventlog_windows.go index e83a684105..8a5473a5d4 100644 --- a/vendor/github.com/elastic/beats/libbeat/logp/eventlog_windows.go +++ b/vendor/github.com/elastic/beats/libbeat/logp/eventlog_windows.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package logp import ( diff --git a/vendor/github.com/elastic/beats/libbeat/logp/fields.go b/vendor/github.com/elastic/beats/libbeat/logp/fields.go index bbf3d575d7..d9d1655f25 100644 --- a/vendor/github.com/elastic/beats/libbeat/logp/fields.go +++ b/vendor/github.com/elastic/beats/libbeat/logp/fields.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package logp import ( diff --git a/vendor/github.com/elastic/beats/libbeat/logp/global.go b/vendor/github.com/elastic/beats/libbeat/logp/global.go index 1748104120..cece73591f 100644 --- a/vendor/github.com/elastic/beats/libbeat/logp/global.go +++ b/vendor/github.com/elastic/beats/libbeat/logp/global.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package logp import ( diff --git a/vendor/github.com/elastic/beats/libbeat/logp/level.go b/vendor/github.com/elastic/beats/libbeat/logp/level.go index 56fc8db620..574285347e 100644 --- a/vendor/github.com/elastic/beats/libbeat/logp/level.go +++ b/vendor/github.com/elastic/beats/libbeat/logp/level.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package logp import ( diff --git a/vendor/github.com/elastic/beats/libbeat/logp/logger.go b/vendor/github.com/elastic/beats/libbeat/logp/logger.go index 24cc7ad7ec..19bcb252be 100644 --- a/vendor/github.com/elastic/beats/libbeat/logp/logger.go +++ b/vendor/github.com/elastic/beats/libbeat/logp/logger.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package logp import ( diff --git a/vendor/github.com/elastic/beats/libbeat/logp/options.go b/vendor/github.com/elastic/beats/libbeat/logp/options.go index 34e316a3d2..2ce7989c66 100644 --- a/vendor/github.com/elastic/beats/libbeat/logp/options.go +++ b/vendor/github.com/elastic/beats/libbeat/logp/options.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package logp // Option configures the logp package behavior. diff --git a/vendor/github.com/elastic/beats/libbeat/logp/selective.go b/vendor/github.com/elastic/beats/libbeat/logp/selective.go index 3ac5464e17..a5d6a7a7a0 100644 --- a/vendor/github.com/elastic/beats/libbeat/logp/selective.go +++ b/vendor/github.com/elastic/beats/libbeat/logp/selective.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package logp import ( diff --git a/vendor/github.com/elastic/beats/libbeat/logp/syslog_unix.go b/vendor/github.com/elastic/beats/libbeat/logp/syslog_unix.go index 56f35fe611..45f70ebe47 100644 --- a/vendor/github.com/elastic/beats/libbeat/logp/syslog_unix.go +++ b/vendor/github.com/elastic/beats/libbeat/logp/syslog_unix.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + // +build !windows,!nacl,!plan9 package logp diff --git a/vendor/github.com/elastic/beats/libbeat/logp/syslog_unsupported.go b/vendor/github.com/elastic/beats/libbeat/logp/syslog_unsupported.go index 62d9e465b4..222146cd1c 100644 --- a/vendor/github.com/elastic/beats/libbeat/logp/syslog_unsupported.go +++ b/vendor/github.com/elastic/beats/libbeat/logp/syslog_unsupported.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + // +build windows nacl plan9 package logp diff --git a/vendor/github.com/elastic/beats/libbeat/metric/system/cpu/cpu.go b/vendor/github.com/elastic/beats/libbeat/metric/system/cpu/cpu.go index 229a477df7..0e9b69e5fc 100644 --- a/vendor/github.com/elastic/beats/libbeat/metric/system/cpu/cpu.go +++ b/vendor/github.com/elastic/beats/libbeat/metric/system/cpu/cpu.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + // +build darwin freebsd linux openbsd windows package cpu diff --git a/vendor/github.com/elastic/beats/libbeat/metric/system/cpu/doc.go b/vendor/github.com/elastic/beats/libbeat/metric/system/cpu/doc.go index 51dd3315c5..ce8f92d5dc 100644 --- a/vendor/github.com/elastic/beats/libbeat/metric/system/cpu/doc.go +++ b/vendor/github.com/elastic/beats/libbeat/metric/system/cpu/doc.go @@ -1 +1,18 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package cpu diff --git a/vendor/github.com/elastic/beats/libbeat/metric/system/memory/doc.go b/vendor/github.com/elastic/beats/libbeat/metric/system/memory/doc.go index 05af74b9e7..150cf0788e 100644 --- a/vendor/github.com/elastic/beats/libbeat/metric/system/memory/doc.go +++ b/vendor/github.com/elastic/beats/libbeat/metric/system/memory/doc.go @@ -1 +1,18 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package memory diff --git a/vendor/github.com/elastic/beats/libbeat/metric/system/memory/memory.go b/vendor/github.com/elastic/beats/libbeat/metric/system/memory/memory.go index b31819a080..594fc616c1 100644 --- a/vendor/github.com/elastic/beats/libbeat/metric/system/memory/memory.go +++ b/vendor/github.com/elastic/beats/libbeat/metric/system/memory/memory.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + // +build darwin freebsd linux openbsd windows package memory diff --git a/vendor/github.com/elastic/beats/libbeat/metric/system/process/config.go b/vendor/github.com/elastic/beats/libbeat/metric/system/process/config.go index 391c3a3812..4fd2ba2c50 100644 --- a/vendor/github.com/elastic/beats/libbeat/metric/system/process/config.go +++ b/vendor/github.com/elastic/beats/libbeat/metric/system/process/config.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package process // IncludeTopConfig is the configuration for the "top N processes diff --git a/vendor/github.com/elastic/beats/libbeat/metric/system/process/process.go b/vendor/github.com/elastic/beats/libbeat/metric/system/process/process.go index 66f3387c58..ccec88824f 100644 --- a/vendor/github.com/elastic/beats/libbeat/metric/system/process/process.go +++ b/vendor/github.com/elastic/beats/libbeat/metric/system/process/process.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + // +build darwin freebsd linux windows package process diff --git a/vendor/github.com/elastic/beats/libbeat/metric/system/process/process_linux.go b/vendor/github.com/elastic/beats/libbeat/metric/system/process/process_linux.go index 9400a43d83..6834632367 100644 --- a/vendor/github.com/elastic/beats/libbeat/metric/system/process/process_linux.go +++ b/vendor/github.com/elastic/beats/libbeat/metric/system/process/process_linux.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package process import ( diff --git a/vendor/github.com/elastic/beats/libbeat/metric/system/process/process_other.go b/vendor/github.com/elastic/beats/libbeat/metric/system/process/process_other.go index f829eac144..b0132cdf55 100644 --- a/vendor/github.com/elastic/beats/libbeat/metric/system/process/process_other.go +++ b/vendor/github.com/elastic/beats/libbeat/metric/system/process/process_other.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + // +build !linux package process diff --git a/vendor/github.com/elastic/beats/libbeat/monitoring/adapter/filters.go b/vendor/github.com/elastic/beats/libbeat/monitoring/adapter/filters.go index 7ec431c647..c596a7f876 100644 --- a/vendor/github.com/elastic/beats/libbeat/monitoring/adapter/filters.go +++ b/vendor/github.com/elastic/beats/libbeat/monitoring/adapter/filters.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package adapter import ( diff --git a/vendor/github.com/elastic/beats/libbeat/monitoring/adapter/go-metrics-wrapper.go b/vendor/github.com/elastic/beats/libbeat/monitoring/adapter/go-metrics-wrapper.go index 448d25f888..0f974efd0e 100644 --- a/vendor/github.com/elastic/beats/libbeat/monitoring/adapter/go-metrics-wrapper.go +++ b/vendor/github.com/elastic/beats/libbeat/monitoring/adapter/go-metrics-wrapper.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package adapter import ( diff --git a/vendor/github.com/elastic/beats/libbeat/monitoring/adapter/go-metrics.go b/vendor/github.com/elastic/beats/libbeat/monitoring/adapter/go-metrics.go index 1e2d6e4326..303c169f09 100644 --- a/vendor/github.com/elastic/beats/libbeat/monitoring/adapter/go-metrics.go +++ b/vendor/github.com/elastic/beats/libbeat/monitoring/adapter/go-metrics.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package adapter import ( diff --git a/vendor/github.com/elastic/beats/libbeat/monitoring/metrics.go b/vendor/github.com/elastic/beats/libbeat/monitoring/metrics.go index 0188ce7318..ab0d9d56ec 100644 --- a/vendor/github.com/elastic/beats/libbeat/monitoring/metrics.go +++ b/vendor/github.com/elastic/beats/libbeat/monitoring/metrics.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package monitoring import ( diff --git a/vendor/github.com/elastic/beats/libbeat/monitoring/mode_string.go b/vendor/github.com/elastic/beats/libbeat/monitoring/mode_string.go index 3ede9b2f52..886c8afd2f 100644 --- a/vendor/github.com/elastic/beats/libbeat/monitoring/mode_string.go +++ b/vendor/github.com/elastic/beats/libbeat/monitoring/mode_string.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + // Code generated by "stringer -type=Mode"; DO NOT EDIT package monitoring diff --git a/vendor/github.com/elastic/beats/libbeat/monitoring/monitoring.go b/vendor/github.com/elastic/beats/libbeat/monitoring/monitoring.go index 59e9f379a2..943f4e79e1 100644 --- a/vendor/github.com/elastic/beats/libbeat/monitoring/monitoring.go +++ b/vendor/github.com/elastic/beats/libbeat/monitoring/monitoring.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package monitoring import "errors" diff --git a/vendor/github.com/elastic/beats/libbeat/monitoring/namespace.go b/vendor/github.com/elastic/beats/libbeat/monitoring/namespace.go index d800259709..1cefcb7c95 100644 --- a/vendor/github.com/elastic/beats/libbeat/monitoring/namespace.go +++ b/vendor/github.com/elastic/beats/libbeat/monitoring/namespace.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package monitoring import ( diff --git a/vendor/github.com/elastic/beats/libbeat/monitoring/opts.go b/vendor/github.com/elastic/beats/libbeat/monitoring/opts.go index 46fe38ceb9..d7251a8511 100644 --- a/vendor/github.com/elastic/beats/libbeat/monitoring/opts.go +++ b/vendor/github.com/elastic/beats/libbeat/monitoring/opts.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package monitoring // Option type for passing additional options to NewRegistry. diff --git a/vendor/github.com/elastic/beats/libbeat/monitoring/registry.go b/vendor/github.com/elastic/beats/libbeat/monitoring/registry.go index 8a2bbed0b0..5eb9c86009 100644 --- a/vendor/github.com/elastic/beats/libbeat/monitoring/registry.go +++ b/vendor/github.com/elastic/beats/libbeat/monitoring/registry.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package monitoring import ( diff --git a/vendor/github.com/elastic/beats/libbeat/monitoring/report/elasticsearch/client.go b/vendor/github.com/elastic/beats/libbeat/monitoring/report/elasticsearch/client.go index 93b9943c23..a14f5b7d1e 100644 --- a/vendor/github.com/elastic/beats/libbeat/monitoring/report/elasticsearch/client.go +++ b/vendor/github.com/elastic/beats/libbeat/monitoring/report/elasticsearch/client.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package elasticsearch import ( diff --git a/vendor/github.com/elastic/beats/libbeat/monitoring/report/elasticsearch/config.go b/vendor/github.com/elastic/beats/libbeat/monitoring/report/elasticsearch/config.go index 073a5c7ee9..a6d88a5411 100644 --- a/vendor/github.com/elastic/beats/libbeat/monitoring/report/elasticsearch/config.go +++ b/vendor/github.com/elastic/beats/libbeat/monitoring/report/elasticsearch/config.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package elasticsearch import ( diff --git a/vendor/github.com/elastic/beats/libbeat/monitoring/report/elasticsearch/elasticsearch.go b/vendor/github.com/elastic/beats/libbeat/monitoring/report/elasticsearch/elasticsearch.go index eccedd9e73..f6fe025f6a 100644 --- a/vendor/github.com/elastic/beats/libbeat/monitoring/report/elasticsearch/elasticsearch.go +++ b/vendor/github.com/elastic/beats/libbeat/monitoring/report/elasticsearch/elasticsearch.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package elasticsearch import ( diff --git a/vendor/github.com/elastic/beats/libbeat/monitoring/report/elasticsearch/snapshot.go b/vendor/github.com/elastic/beats/libbeat/monitoring/report/elasticsearch/snapshot.go index 913d5eb78e..62766174c2 100644 --- a/vendor/github.com/elastic/beats/libbeat/monitoring/report/elasticsearch/snapshot.go +++ b/vendor/github.com/elastic/beats/libbeat/monitoring/report/elasticsearch/snapshot.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package elasticsearch import ( diff --git a/vendor/github.com/elastic/beats/libbeat/monitoring/report/elasticsearch/util.go b/vendor/github.com/elastic/beats/libbeat/monitoring/report/elasticsearch/util.go index 102453a0a8..28a2b9dd0c 100644 --- a/vendor/github.com/elastic/beats/libbeat/monitoring/report/elasticsearch/util.go +++ b/vendor/github.com/elastic/beats/libbeat/monitoring/report/elasticsearch/util.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package elasticsearch import "sync" diff --git a/vendor/github.com/elastic/beats/libbeat/monitoring/report/event.go b/vendor/github.com/elastic/beats/libbeat/monitoring/report/event.go index 6082520c38..bdcab64ccc 100644 --- a/vendor/github.com/elastic/beats/libbeat/monitoring/report/event.go +++ b/vendor/github.com/elastic/beats/libbeat/monitoring/report/event.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package report import ( diff --git a/vendor/github.com/elastic/beats/libbeat/monitoring/report/log/config.go b/vendor/github.com/elastic/beats/libbeat/monitoring/report/log/config.go index fbea0e4c7f..4b6425187b 100644 --- a/vendor/github.com/elastic/beats/libbeat/monitoring/report/log/config.go +++ b/vendor/github.com/elastic/beats/libbeat/monitoring/report/log/config.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package log import ( diff --git a/vendor/github.com/elastic/beats/libbeat/monitoring/report/log/log.go b/vendor/github.com/elastic/beats/libbeat/monitoring/report/log/log.go index 34c94aaebe..8a196ab339 100644 --- a/vendor/github.com/elastic/beats/libbeat/monitoring/report/log/log.go +++ b/vendor/github.com/elastic/beats/libbeat/monitoring/report/log/log.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package log import ( diff --git a/vendor/github.com/elastic/beats/libbeat/monitoring/report/report.go b/vendor/github.com/elastic/beats/libbeat/monitoring/report/report.go index 89b50aca51..f5b02d395d 100644 --- a/vendor/github.com/elastic/beats/libbeat/monitoring/report/report.go +++ b/vendor/github.com/elastic/beats/libbeat/monitoring/report/report.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package report import ( diff --git a/vendor/github.com/elastic/beats/libbeat/monitoring/snapshot.go b/vendor/github.com/elastic/beats/libbeat/monitoring/snapshot.go index 49e2c14948..00ca86cbed 100644 --- a/vendor/github.com/elastic/beats/libbeat/monitoring/snapshot.go +++ b/vendor/github.com/elastic/beats/libbeat/monitoring/snapshot.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package monitoring import "strings" diff --git a/vendor/github.com/elastic/beats/libbeat/monitoring/visitor.go b/vendor/github.com/elastic/beats/libbeat/monitoring/visitor.go index 2c8a15d69f..c62d2e1414 100644 --- a/vendor/github.com/elastic/beats/libbeat/monitoring/visitor.go +++ b/vendor/github.com/elastic/beats/libbeat/monitoring/visitor.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package monitoring // Visitor interface supports traversing a monitoring registry diff --git a/vendor/github.com/elastic/beats/libbeat/monitoring/visitor_expvar.go b/vendor/github.com/elastic/beats/libbeat/monitoring/visitor_expvar.go index cdb6738665..130de4bd92 100644 --- a/vendor/github.com/elastic/beats/libbeat/monitoring/visitor_expvar.go +++ b/vendor/github.com/elastic/beats/libbeat/monitoring/visitor_expvar.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package monitoring import ( diff --git a/vendor/github.com/elastic/beats/libbeat/monitoring/visitor_kv.go b/vendor/github.com/elastic/beats/libbeat/monitoring/visitor_kv.go index 32c6dbf3b4..da11503ebe 100644 --- a/vendor/github.com/elastic/beats/libbeat/monitoring/visitor_kv.go +++ b/vendor/github.com/elastic/beats/libbeat/monitoring/visitor_kv.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package monitoring import "strings" diff --git a/vendor/github.com/elastic/beats/libbeat/outputs/backoff.go b/vendor/github.com/elastic/beats/libbeat/outputs/backoff.go index db04a6ccb1..085b1b6c84 100644 --- a/vendor/github.com/elastic/beats/libbeat/outputs/backoff.go +++ b/vendor/github.com/elastic/beats/libbeat/outputs/backoff.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package outputs import ( diff --git a/vendor/github.com/elastic/beats/libbeat/outputs/codec/codec.go b/vendor/github.com/elastic/beats/libbeat/outputs/codec/codec.go index 9de8a68481..790611ddae 100644 --- a/vendor/github.com/elastic/beats/libbeat/outputs/codec/codec.go +++ b/vendor/github.com/elastic/beats/libbeat/outputs/codec/codec.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package codec import "github.com/elastic/beats/libbeat/beat" diff --git a/vendor/github.com/elastic/beats/libbeat/outputs/codec/codec_reg.go b/vendor/github.com/elastic/beats/libbeat/outputs/codec/codec_reg.go index 3512db3dd4..7db8aee58f 100644 --- a/vendor/github.com/elastic/beats/libbeat/outputs/codec/codec_reg.go +++ b/vendor/github.com/elastic/beats/libbeat/outputs/codec/codec_reg.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package codec import ( diff --git a/vendor/github.com/elastic/beats/libbeat/outputs/codec/common.go b/vendor/github.com/elastic/beats/libbeat/outputs/codec/common.go index 7c6885e268..0377af860f 100644 --- a/vendor/github.com/elastic/beats/libbeat/outputs/codec/common.go +++ b/vendor/github.com/elastic/beats/libbeat/outputs/codec/common.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package codec import ( diff --git a/vendor/github.com/elastic/beats/libbeat/outputs/codec/format/format.go b/vendor/github.com/elastic/beats/libbeat/outputs/codec/format/format.go index e26bc269c5..0416222dc2 100644 --- a/vendor/github.com/elastic/beats/libbeat/outputs/codec/format/format.go +++ b/vendor/github.com/elastic/beats/libbeat/outputs/codec/format/format.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package format import ( diff --git a/vendor/github.com/elastic/beats/libbeat/outputs/codec/json/event.go b/vendor/github.com/elastic/beats/libbeat/outputs/codec/json/event.go index e6905d352c..5ea4b42092 100644 --- a/vendor/github.com/elastic/beats/libbeat/outputs/codec/json/event.go +++ b/vendor/github.com/elastic/beats/libbeat/outputs/codec/json/event.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package json import ( diff --git a/vendor/github.com/elastic/beats/libbeat/outputs/codec/json/json.go b/vendor/github.com/elastic/beats/libbeat/outputs/codec/json/json.go index fe9a4367df..15913f5142 100644 --- a/vendor/github.com/elastic/beats/libbeat/outputs/codec/json/json.go +++ b/vendor/github.com/elastic/beats/libbeat/outputs/codec/json/json.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package json import ( @@ -14,18 +31,21 @@ import ( // Encoder for serializing a beat.Event to json. type Encoder struct { - buf bytes.Buffer - folder *gotype.Iterator - pretty bool + buf bytes.Buffer + folder *gotype.Iterator + version string + config config } type config struct { - Pretty bool + Pretty bool + EscapeHTML bool } var defaultConfig = config{ - Pretty: false, + Pretty: false, + EscapeHTML: true, } func init() { @@ -37,19 +57,23 @@ func init() { } } - return New(config.Pretty, info.Version), nil + return New(config.Pretty, config.EscapeHTML, info.Version), nil }) } // New creates a new json Encoder. -func New(pretty bool, version string) *Encoder { - e := &Encoder{pretty: pretty, version: version} +func New(pretty, escapeHTML bool, version string) *Encoder { + e := &Encoder{version: version, config: config{ + Pretty: pretty, + EscapeHTML: escapeHTML, + }} e.reset() return e } func (e *Encoder) reset() { visitor := json.NewVisitor(&e.buf) + visitor.SetEscapeHTML(e.config.EscapeHTML) var err error @@ -76,7 +100,7 @@ func (e *Encoder) Encode(index string, event *beat.Event) ([]byte, error) { } json := e.buf.Bytes() - if !e.pretty { + if !e.config.Pretty { return json, nil } diff --git a/vendor/github.com/elastic/beats/libbeat/outputs/codec/plugin.go b/vendor/github.com/elastic/beats/libbeat/outputs/codec/plugin.go index 0d403d92ae..951bae242c 100644 --- a/vendor/github.com/elastic/beats/libbeat/outputs/codec/plugin.go +++ b/vendor/github.com/elastic/beats/libbeat/outputs/codec/plugin.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package codec import ( diff --git a/vendor/github.com/elastic/beats/libbeat/outputs/console/config.go b/vendor/github.com/elastic/beats/libbeat/outputs/console/config.go index c33c0f90c4..09debf38aa 100644 --- a/vendor/github.com/elastic/beats/libbeat/outputs/console/config.go +++ b/vendor/github.com/elastic/beats/libbeat/outputs/console/config.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package console import "github.com/elastic/beats/libbeat/outputs/codec" diff --git a/vendor/github.com/elastic/beats/libbeat/outputs/console/console.go b/vendor/github.com/elastic/beats/libbeat/outputs/console/console.go index 92dec50d7b..ab02e92aca 100644 --- a/vendor/github.com/elastic/beats/libbeat/outputs/console/console.go +++ b/vendor/github.com/elastic/beats/libbeat/outputs/console/console.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package console import ( @@ -53,7 +70,7 @@ func makeConsole( return outputs.Fail(err) } } else { - enc = json.New(config.Pretty, beat.Version) + enc = json.New(config.Pretty, true, beat.Version) } index := beat.Beat diff --git a/vendor/github.com/elastic/beats/libbeat/outputs/elasticsearch/api.go b/vendor/github.com/elastic/beats/libbeat/outputs/elasticsearch/api.go index 47870230e7..0f08a3a953 100644 --- a/vendor/github.com/elastic/beats/libbeat/outputs/elasticsearch/api.go +++ b/vendor/github.com/elastic/beats/libbeat/outputs/elasticsearch/api.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package elasticsearch import ( diff --git a/vendor/github.com/elastic/beats/libbeat/outputs/elasticsearch/bulkapi.go b/vendor/github.com/elastic/beats/libbeat/outputs/elasticsearch/bulkapi.go index 0eb16f08b4..91eb5a298a 100644 --- a/vendor/github.com/elastic/beats/libbeat/outputs/elasticsearch/bulkapi.go +++ b/vendor/github.com/elastic/beats/libbeat/outputs/elasticsearch/bulkapi.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package elasticsearch import ( diff --git a/vendor/github.com/elastic/beats/libbeat/outputs/elasticsearch/client.go b/vendor/github.com/elastic/beats/libbeat/outputs/elasticsearch/client.go index 93c3522e74..9e7a3b0a68 100644 --- a/vendor/github.com/elastic/beats/libbeat/outputs/elasticsearch/client.go +++ b/vendor/github.com/elastic/beats/libbeat/outputs/elasticsearch/client.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package elasticsearch import ( @@ -49,6 +66,7 @@ type ClientSettings struct { Proxy *url.URL TLS *transport.TLSConfig Username, Password string + EscapeHTML bool Parameters map[string]string Headers map[string]string Index outil.Selector @@ -167,9 +185,9 @@ func NewClient( var encoder bodyEncoder compression := s.CompressionLevel if compression == 0 { - encoder = newJSONEncoder(nil) + encoder = newJSONEncoder(nil, s.EscapeHTML) } else { - encoder, err = newGzipEncoder(compression, nil) + encoder, err = newGzipEncoder(compression, nil, s.EscapeHTML) if err != nil { return nil, err } @@ -300,7 +318,7 @@ func (client *Client) publishEvents( return data, sendErr } - debugf("PublishEvents: %d events have been published to elasticsearch in %v.", + debugf("PublishEvents: %d events have been published to elasticsearch in %v.", len(data), time.Now().Sub(begin)) diff --git a/vendor/github.com/elastic/beats/libbeat/outputs/elasticsearch/config.go b/vendor/github.com/elastic/beats/libbeat/outputs/elasticsearch/config.go index e3e16f6f50..c398f8196c 100644 --- a/vendor/github.com/elastic/beats/libbeat/outputs/elasticsearch/config.go +++ b/vendor/github.com/elastic/beats/libbeat/outputs/elasticsearch/config.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package elasticsearch import ( @@ -16,6 +33,7 @@ type elasticsearchConfig struct { ProxyURL string `config:"proxy_url"` LoadBalance bool `config:"loadbalance"` CompressionLevel int `config:"compression_level" validate:"min=0, max=9"` + EscapeHTML bool `config:"escape_html"` TLS *tlscommon.Config `config:"ssl"` BulkMaxSize int `config:"bulk_max_size"` MaxRetries int `config:"max_retries"` @@ -43,6 +61,7 @@ var ( Timeout: 90 * time.Second, MaxRetries: 3, CompressionLevel: 0, + EscapeHTML: true, TLS: nil, LoadBalance: true, Backoff: Backoff{ diff --git a/vendor/github.com/elastic/beats/libbeat/outputs/elasticsearch/elasticsearch.go b/vendor/github.com/elastic/beats/libbeat/outputs/elasticsearch/elasticsearch.go index 163b79b840..dd50990a9a 100644 --- a/vendor/github.com/elastic/beats/libbeat/outputs/elasticsearch/elasticsearch.go +++ b/vendor/github.com/elastic/beats/libbeat/outputs/elasticsearch/elasticsearch.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package elasticsearch import ( @@ -137,6 +154,7 @@ func makeES( Timeout: config.Timeout, CompressionLevel: config.CompressionLevel, Observer: observer, + EscapeHTML: config.EscapeHTML, }, &connectCallbackRegistry) if err != nil { return outputs.Fail(err) diff --git a/vendor/github.com/elastic/beats/libbeat/outputs/elasticsearch/enc.go b/vendor/github.com/elastic/beats/libbeat/outputs/elasticsearch/enc.go index ec07388041..c8e91a31f6 100644 --- a/vendor/github.com/elastic/beats/libbeat/outputs/elasticsearch/enc.go +++ b/vendor/github.com/elastic/beats/libbeat/outputs/elasticsearch/enc.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package elasticsearch import ( @@ -36,12 +53,16 @@ type bulkWriter interface { type jsonEncoder struct { buf *bytes.Buffer folder *gotype.Iterator + + escapeHTML bool } type gzipEncoder struct { buf *bytes.Buffer gzip *gzip.Writer folder *gotype.Iterator + + escapeHTML bool } type event struct { @@ -49,11 +70,11 @@ type event struct { Fields common.MapStr `struct:",inline"` } -func newJSONEncoder(buf *bytes.Buffer) *jsonEncoder { +func newJSONEncoder(buf *bytes.Buffer, escapeHTML bool) *jsonEncoder { if buf == nil { buf = bytes.NewBuffer(nil) } - e := &jsonEncoder{buf: buf} + e := &jsonEncoder{buf: buf, escapeHTML: escapeHTML} e.resetState() return e } @@ -65,6 +86,8 @@ func (b *jsonEncoder) Reset() { func (b *jsonEncoder) resetState() { var err error visitor := json.NewVisitor(b.buf) + visitor.SetEscapeHTML(b.escapeHTML) + b.folder, err = gotype.NewIterator(visitor, gotype.Folders( codec.MakeTimestampEncoder(), @@ -120,7 +143,7 @@ func (b *jsonEncoder) Add(meta, obj interface{}) error { return nil } -func newGzipEncoder(level int, buf *bytes.Buffer) (*gzipEncoder, error) { +func newGzipEncoder(level int, buf *bytes.Buffer, escapeHTML bool) (*gzipEncoder, error) { if buf == nil { buf = bytes.NewBuffer(nil) } @@ -129,7 +152,7 @@ func newGzipEncoder(level int, buf *bytes.Buffer) (*gzipEncoder, error) { return nil, err } - g := &gzipEncoder{buf: buf, gzip: w} + g := &gzipEncoder{buf: buf, gzip: w, escapeHTML: escapeHTML} g.resetState() return g, nil } @@ -137,6 +160,8 @@ func newGzipEncoder(level int, buf *bytes.Buffer) (*gzipEncoder, error) { func (g *gzipEncoder) resetState() { var err error visitor := json.NewVisitor(g.gzip) + visitor.SetEscapeHTML(g.escapeHTML) + g.folder, err = gotype.NewIterator(visitor, gotype.Folders( codec.MakeTimestampEncoder(), diff --git a/vendor/github.com/elastic/beats/libbeat/outputs/elasticsearch/json_read.go b/vendor/github.com/elastic/beats/libbeat/outputs/elasticsearch/json_read.go index e41d114006..5b205f4c01 100644 --- a/vendor/github.com/elastic/beats/libbeat/outputs/elasticsearch/json_read.go +++ b/vendor/github.com/elastic/beats/libbeat/outputs/elasticsearch/json_read.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package elasticsearch import ( diff --git a/vendor/github.com/elastic/beats/libbeat/outputs/elasticsearch/url.go b/vendor/github.com/elastic/beats/libbeat/outputs/elasticsearch/url.go index 89c9620bc5..1c83419aef 100644 --- a/vendor/github.com/elastic/beats/libbeat/outputs/elasticsearch/url.go +++ b/vendor/github.com/elastic/beats/libbeat/outputs/elasticsearch/url.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package elasticsearch import ( diff --git a/vendor/github.com/elastic/beats/libbeat/outputs/failover.go b/vendor/github.com/elastic/beats/libbeat/outputs/failover.go index dfa9c2dd59..6f24e3a2eb 100644 --- a/vendor/github.com/elastic/beats/libbeat/outputs/failover.go +++ b/vendor/github.com/elastic/beats/libbeat/outputs/failover.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package outputs import ( diff --git a/vendor/github.com/elastic/beats/libbeat/outputs/fileout/config.go b/vendor/github.com/elastic/beats/libbeat/outputs/fileout/config.go index acbb9e5ccd..742334ceed 100644 --- a/vendor/github.com/elastic/beats/libbeat/outputs/fileout/config.go +++ b/vendor/github.com/elastic/beats/libbeat/outputs/fileout/config.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package fileout import ( diff --git a/vendor/github.com/elastic/beats/libbeat/outputs/fileout/file.go b/vendor/github.com/elastic/beats/libbeat/outputs/fileout/file.go index ed140258f2..b30a28733d 100644 --- a/vendor/github.com/elastic/beats/libbeat/outputs/fileout/file.go +++ b/vendor/github.com/elastic/beats/libbeat/outputs/fileout/file.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package fileout import ( diff --git a/vendor/github.com/elastic/beats/libbeat/outputs/hosts.go b/vendor/github.com/elastic/beats/libbeat/outputs/hosts.go index 6b48b19f6f..f8b192dba3 100644 --- a/vendor/github.com/elastic/beats/libbeat/outputs/hosts.go +++ b/vendor/github.com/elastic/beats/libbeat/outputs/hosts.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package outputs import "github.com/elastic/beats/libbeat/common" diff --git a/vendor/github.com/elastic/beats/libbeat/outputs/kafka/client.go b/vendor/github.com/elastic/beats/libbeat/outputs/kafka/client.go index 3126606f95..c20b4bd3f8 100644 --- a/vendor/github.com/elastic/beats/libbeat/outputs/kafka/client.go +++ b/vendor/github.com/elastic/beats/libbeat/outputs/kafka/client.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package kafka import ( diff --git a/vendor/github.com/elastic/beats/libbeat/outputs/kafka/config.go b/vendor/github.com/elastic/beats/libbeat/outputs/kafka/config.go index 4dc4552fe0..2e9a0152d1 100644 --- a/vendor/github.com/elastic/beats/libbeat/outputs/kafka/config.go +++ b/vendor/github.com/elastic/beats/libbeat/outputs/kafka/config.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package kafka import ( diff --git a/vendor/github.com/elastic/beats/libbeat/outputs/kafka/kafka.go b/vendor/github.com/elastic/beats/libbeat/outputs/kafka/kafka.go index 4f135cd440..039d8b8000 100644 --- a/vendor/github.com/elastic/beats/libbeat/outputs/kafka/kafka.go +++ b/vendor/github.com/elastic/beats/libbeat/outputs/kafka/kafka.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package kafka import ( diff --git a/vendor/github.com/elastic/beats/libbeat/outputs/kafka/log.go b/vendor/github.com/elastic/beats/libbeat/outputs/kafka/log.go index 8ab83c6dd2..027f476406 100644 --- a/vendor/github.com/elastic/beats/libbeat/outputs/kafka/log.go +++ b/vendor/github.com/elastic/beats/libbeat/outputs/kafka/log.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package kafka import ( diff --git a/vendor/github.com/elastic/beats/libbeat/outputs/kafka/message.go b/vendor/github.com/elastic/beats/libbeat/outputs/kafka/message.go index 110c96189c..7254c39083 100644 --- a/vendor/github.com/elastic/beats/libbeat/outputs/kafka/message.go +++ b/vendor/github.com/elastic/beats/libbeat/outputs/kafka/message.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package kafka import ( diff --git a/vendor/github.com/elastic/beats/libbeat/outputs/kafka/partition.go b/vendor/github.com/elastic/beats/libbeat/outputs/kafka/partition.go index fb41fa439c..3ce18c247e 100644 --- a/vendor/github.com/elastic/beats/libbeat/outputs/kafka/partition.go +++ b/vendor/github.com/elastic/beats/libbeat/outputs/kafka/partition.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package kafka import ( diff --git a/vendor/github.com/elastic/beats/libbeat/outputs/kafka/version.go b/vendor/github.com/elastic/beats/libbeat/outputs/kafka/version.go index a2bd835575..d171520a10 100644 --- a/vendor/github.com/elastic/beats/libbeat/outputs/kafka/version.go +++ b/vendor/github.com/elastic/beats/libbeat/outputs/kafka/version.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package kafka import "github.com/Shopify/sarama" diff --git a/vendor/github.com/elastic/beats/libbeat/outputs/logstash/async.go b/vendor/github.com/elastic/beats/libbeat/outputs/logstash/async.go index e0816ff824..2d080a50dd 100644 --- a/vendor/github.com/elastic/beats/libbeat/outputs/logstash/async.go +++ b/vendor/github.com/elastic/beats/libbeat/outputs/logstash/async.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package logstash import ( @@ -51,7 +68,7 @@ func newAsyncClient( logp.Warn(`The async Logstash client does not support the "ttl" option`) } - enc := makeLogstashEventEncoder(beat, config.Index) + enc := makeLogstashEventEncoder(beat, config.EscapeHTML, config.Index) queueSize := config.Pipelining - 1 timeout := config.Timeout diff --git a/vendor/github.com/elastic/beats/libbeat/outputs/logstash/config.go b/vendor/github.com/elastic/beats/libbeat/outputs/logstash/config.go index fb95f73778..36e2a61871 100644 --- a/vendor/github.com/elastic/beats/libbeat/outputs/logstash/config.go +++ b/vendor/github.com/elastic/beats/libbeat/outputs/logstash/config.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package logstash import ( @@ -21,6 +38,7 @@ type Config struct { TLS *tlscommon.Config `config:"ssl"` Proxy transport.ProxyConfig `config:",inline"` Backoff Backoff `config:"backoff"` + EscapeHTML bool `config:"escape_html"` } type Backoff struct { @@ -42,6 +60,7 @@ var defaultConfig = Config{ Init: 1 * time.Second, Max: 60 * time.Second, }, + EscapeHTML: true, } func newConfig() *Config { diff --git a/vendor/github.com/elastic/beats/libbeat/outputs/logstash/enc.go b/vendor/github.com/elastic/beats/libbeat/outputs/logstash/enc.go index 6396330065..00cb304c64 100644 --- a/vendor/github.com/elastic/beats/libbeat/outputs/logstash/enc.go +++ b/vendor/github.com/elastic/beats/libbeat/outputs/logstash/enc.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package logstash import ( @@ -5,8 +22,8 @@ import ( "github.com/elastic/beats/libbeat/outputs/codec/json" ) -func makeLogstashEventEncoder(info beat.Info, index string) func(interface{}) ([]byte, error) { - enc := json.New(false, info.Version) +func makeLogstashEventEncoder(info beat.Info, escapeHTML bool, index string) func(interface{}) ([]byte, error) { + enc := json.New(false, escapeHTML, info.Version) return func(event interface{}) ([]byte, error) { return enc.Encode(index, event.(*beat.Event)) } diff --git a/vendor/github.com/elastic/beats/libbeat/outputs/logstash/logstash.go b/vendor/github.com/elastic/beats/libbeat/outputs/logstash/logstash.go index 72165ace65..db9dbebe4e 100644 --- a/vendor/github.com/elastic/beats/libbeat/outputs/logstash/logstash.go +++ b/vendor/github.com/elastic/beats/libbeat/outputs/logstash/logstash.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package logstash import ( diff --git a/vendor/github.com/elastic/beats/libbeat/outputs/logstash/sync.go b/vendor/github.com/elastic/beats/libbeat/outputs/logstash/sync.go index 256e4df619..534aebf60e 100644 --- a/vendor/github.com/elastic/beats/libbeat/outputs/logstash/sync.go +++ b/vendor/github.com/elastic/beats/libbeat/outputs/logstash/sync.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package logstash import ( @@ -40,7 +57,7 @@ func newSyncClient( } var err error - enc := makeLogstashEventEncoder(beat, config.Index) + enc := makeLogstashEventEncoder(beat, config.EscapeHTML, config.Index) c.client, err = v2.NewSyncClientWithConn(conn, v2.JSONEncoder(enc), v2.Timeout(config.Timeout), diff --git a/vendor/github.com/elastic/beats/libbeat/outputs/logstash/window.go b/vendor/github.com/elastic/beats/libbeat/outputs/logstash/window.go index df7ff1cd4d..529efad226 100644 --- a/vendor/github.com/elastic/beats/libbeat/outputs/logstash/window.go +++ b/vendor/github.com/elastic/beats/libbeat/outputs/logstash/window.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package logstash import ( diff --git a/vendor/github.com/elastic/beats/libbeat/outputs/metrics.go b/vendor/github.com/elastic/beats/libbeat/outputs/metrics.go index ae52ff16d1..099e04bf77 100644 --- a/vendor/github.com/elastic/beats/libbeat/outputs/metrics.go +++ b/vendor/github.com/elastic/beats/libbeat/outputs/metrics.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package outputs import "github.com/elastic/beats/libbeat/monitoring" diff --git a/vendor/github.com/elastic/beats/libbeat/outputs/observer.go b/vendor/github.com/elastic/beats/libbeat/outputs/observer.go index e70a1c0bda..2cc4995399 100644 --- a/vendor/github.com/elastic/beats/libbeat/outputs/observer.go +++ b/vendor/github.com/elastic/beats/libbeat/outputs/observer.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package outputs // Observer provides an interface used by outputs to report common events on diff --git a/vendor/github.com/elastic/beats/libbeat/outputs/outil/select.go b/vendor/github.com/elastic/beats/libbeat/outputs/outil/select.go index 3607211b72..cf27f250c9 100644 --- a/vendor/github.com/elastic/beats/libbeat/outputs/outil/select.go +++ b/vendor/github.com/elastic/beats/libbeat/outputs/outil/select.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package outil import ( diff --git a/vendor/github.com/elastic/beats/libbeat/outputs/output_reg.go b/vendor/github.com/elastic/beats/libbeat/outputs/output_reg.go index 72fdc956ef..1e441becf8 100644 --- a/vendor/github.com/elastic/beats/libbeat/outputs/output_reg.go +++ b/vendor/github.com/elastic/beats/libbeat/outputs/output_reg.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package outputs import ( diff --git a/vendor/github.com/elastic/beats/libbeat/outputs/outputs.go b/vendor/github.com/elastic/beats/libbeat/outputs/outputs.go index eead5b6611..2f77104953 100644 --- a/vendor/github.com/elastic/beats/libbeat/outputs/outputs.go +++ b/vendor/github.com/elastic/beats/libbeat/outputs/outputs.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + // Package outputs defines common types and interfaces to be implemented by // output plugins. diff --git a/vendor/github.com/elastic/beats/libbeat/outputs/plugin.go b/vendor/github.com/elastic/beats/libbeat/outputs/plugin.go index 86c600e462..254f93832c 100644 --- a/vendor/github.com/elastic/beats/libbeat/outputs/plugin.go +++ b/vendor/github.com/elastic/beats/libbeat/outputs/plugin.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package outputs import ( diff --git a/vendor/github.com/elastic/beats/libbeat/outputs/redis/client.go b/vendor/github.com/elastic/beats/libbeat/outputs/redis/client.go index e9ec047c55..9b84b6e0fb 100644 --- a/vendor/github.com/elastic/beats/libbeat/outputs/redis/client.go +++ b/vendor/github.com/elastic/beats/libbeat/outputs/redis/client.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package redis import ( diff --git a/vendor/github.com/elastic/beats/libbeat/outputs/redis/config.go b/vendor/github.com/elastic/beats/libbeat/outputs/redis/config.go index a419eb0aee..24005440cb 100644 --- a/vendor/github.com/elastic/beats/libbeat/outputs/redis/config.go +++ b/vendor/github.com/elastic/beats/libbeat/outputs/redis/config.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package redis import ( diff --git a/vendor/github.com/elastic/beats/libbeat/outputs/redis/redis.go b/vendor/github.com/elastic/beats/libbeat/outputs/redis/redis.go index 9fd502ea27..56a9b6dd28 100644 --- a/vendor/github.com/elastic/beats/libbeat/outputs/redis/redis.go +++ b/vendor/github.com/elastic/beats/libbeat/outputs/redis/redis.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package redis import ( diff --git a/vendor/github.com/elastic/beats/libbeat/outputs/tls.go b/vendor/github.com/elastic/beats/libbeat/outputs/tls.go index 5d21ec9036..468a8f6485 100644 --- a/vendor/github.com/elastic/beats/libbeat/outputs/tls.go +++ b/vendor/github.com/elastic/beats/libbeat/outputs/tls.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package outputs import ( diff --git a/vendor/github.com/elastic/beats/libbeat/outputs/transport/client.go b/vendor/github.com/elastic/beats/libbeat/outputs/transport/client.go index 2b3b6f1d3c..d337d5f4d8 100644 --- a/vendor/github.com/elastic/beats/libbeat/outputs/transport/client.go +++ b/vendor/github.com/elastic/beats/libbeat/outputs/transport/client.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package transport import ( diff --git a/vendor/github.com/elastic/beats/libbeat/outputs/transport/proxy.go b/vendor/github.com/elastic/beats/libbeat/outputs/transport/proxy.go index ce75f4e583..95bc7f4d00 100644 --- a/vendor/github.com/elastic/beats/libbeat/outputs/transport/proxy.go +++ b/vendor/github.com/elastic/beats/libbeat/outputs/transport/proxy.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package transport import ( diff --git a/vendor/github.com/elastic/beats/libbeat/outputs/transport/stats.go b/vendor/github.com/elastic/beats/libbeat/outputs/transport/stats.go index a6eb1ff904..56f9776189 100644 --- a/vendor/github.com/elastic/beats/libbeat/outputs/transport/stats.go +++ b/vendor/github.com/elastic/beats/libbeat/outputs/transport/stats.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package transport import ( diff --git a/vendor/github.com/elastic/beats/libbeat/outputs/transport/tcp.go b/vendor/github.com/elastic/beats/libbeat/outputs/transport/tcp.go index 5a741170f1..b87bfb8b0d 100644 --- a/vendor/github.com/elastic/beats/libbeat/outputs/transport/tcp.go +++ b/vendor/github.com/elastic/beats/libbeat/outputs/transport/tcp.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package transport import ( diff --git a/vendor/github.com/elastic/beats/libbeat/outputs/transport/tls.go b/vendor/github.com/elastic/beats/libbeat/outputs/transport/tls.go index dc4976d221..af824602ec 100644 --- a/vendor/github.com/elastic/beats/libbeat/outputs/transport/tls.go +++ b/vendor/github.com/elastic/beats/libbeat/outputs/transport/tls.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package transport import ( diff --git a/vendor/github.com/elastic/beats/libbeat/outputs/transport/transport.go b/vendor/github.com/elastic/beats/libbeat/outputs/transport/transport.go index 14f1f559cd..28367129d1 100644 --- a/vendor/github.com/elastic/beats/libbeat/outputs/transport/transport.go +++ b/vendor/github.com/elastic/beats/libbeat/outputs/transport/transport.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package transport import ( diff --git a/vendor/github.com/elastic/beats/libbeat/outputs/transport/transptest/ca_test.key b/vendor/github.com/elastic/beats/libbeat/outputs/transport/transptest/ca_test.key new file mode 100644 index 0000000000..26b358b929 --- /dev/null +++ b/vendor/github.com/elastic/beats/libbeat/outputs/transport/transptest/ca_test.key @@ -0,0 +1,51 @@ +-----BEGIN RSA PRIVATE KEY----- +MIIJKQIBAAKCAgEAv/PngL9UMxv0SgLoPdySbwg96lYkBH3IE44ed8k7D8LJOlpp +qXkqQ9ho4ZdoAijF2YXA71wqqMLfE7OoZso0GoaFyXW/sgcBJWlIRSMf1GzFhPal +WayfMW5g5Kn3qptmg6h6jG1EI4sx2BHCNjNLDgD9SOnAMGR+qOf0E6cE4fm6/PYm +QEcYuBeJCzGjCPN/hundF/mKOOG1uTHaaBD5cyRozRFPVjqzW+A0G5GABZIcjuRX +wddGeC/r0h0gdIUus7ZuqEWLJoogGk6yerYqEIQiftFszT32zbemFNSb7W3AjRUy +Q7Vtvyasq9lD7IppLny0NYEiEs7e/N5crCHWHePbHii4vlUn1M/yH7loSeYxUn9p +Cr2SoDObzsgq2Mh5K+sPqTyxNPZGJATTktp/0zdenoP9OIcTFsjmB6pNptu3jUIU +7etPrGpA9xRZSXOpxXZ0RVXqZ1LUgMsk2Q0ADueZO5u5+Qw01oHSClEf5ULlLKpF +QejV5hQn6g+iaLUKlyN2+poxCoQIWFXtAru+YUorjWcYtvnUe5oJka3MKaLRvqpt +jnTEmoYcbPRKaYqFCHcVvbV6ks31A8bDiluJmVD1vyN8e0XqFbDOEm6KUqpGr8R5 +IvW25vZiBkB0gf4WpT/Ng1EtApoxiRXe/bQp4+hK0dpTirO4grvH4svYYscCAwEA +AQKCAgBGvgQOvfSxFVdVw3aF/fl1tCrlZzPE9/o5wsHV0bLTnyz8NYAFdmMuN96H +bX5mdVJdVV8CmAwcwBzorOieYV0MfZFm6t9oJA63E/MPj99WMXQmCaRsxSKyXASX +oVBmbvk8AmaPxGE9XDpVcE4MHaFGmvS932/2JcNMSpf4ejBhe+D/A1Sbkdg5WGso +VfXJAbx5I01ZXZ0kU4LeqtHcUo0sczmwgfWkSOP7M0jg9CGja/LccqkpBkaxWq/l +ctiYONE6aDymBWNAI92q9F/wu5wLFDeGV3ZqubBwpoMt4CFLQoyZMjuhGodE0GMI +vny6+1PCTzE3Gs1M8zLZLLYothurqlNKD6m8SpujJhVpq8zw1wwvGJ2yorAvFLKH +SlcIl6DvjRYUfbdiM+Bnls2RcnftNtq5pfaNGJAltga1Di4iC6qdPH+TUJ98R6O4 +oN3Mn27tpimdmW9JA5t84sWBIlVjQIuP2y7kqvGtGAZZoi5ZtPIzbxHtVYpAziwL +Jbw1jOVPmjhx35BbiceEuWcs57Ur96uPmvCub0eR5wbhWxAlb2P/KWv2lmABjzip +WkT1v9XKaFcLuyPeJ5P65fbJpWTPmtjANVxYBp04Vsn1QKUqqQzrM6zJTMWuo5Kd +SlvNwAUGId52yuHUeihHVuOxwa8dMHlWVv6iQrl7jrAiqYUt4QKCAQEA8p+SXv3j +ImL7LxI1UIZL5u5FimFa7pBcywpY4K+gYj5hUHqo2yYfU9E2GGf6OrPJPTsfJ6K3 +691JK733ig+j95qB5j6gTr4Zo+GaOZ+F42rNaVA0vaNBvSC0JM+bx9ADX4GQ9tbx +5bB3UobaaVWKCDQH87vCgr61VpFMzskUGVKlyWyKbnq2VpzHyyYoAfXZVnUyEcnW +sLcP6JVHYF5ubbWPFebKEkRYU8khhyATi/l2fPb//IjSBhXdBYpE/gNj61uyYMDg +CVUFwnr2T5WptXqRRpqX4j8Ktzi905lk8fz5Cjqo1vl3xN2LAIB7i8Kqfh6ghhRJ +f1ESheuMeMU7UQKCAQEAyokovW0vwRgpXk5vX4RtWfKR9O0ctdPJ6YrLOnVOhfJ4 +zL2qAtovuhCq5zmeaTJ2Hzxz+wqFXTPvUTLtG5OeKMyZJvs+NYFQuwgOG4NtgcW5 +mbl447EUfVRm/bUxp8ZjFLO5Mwiy3j+wc4E5ll5MvLZKYR16W/kK+2oa80qkdfSV +5abOP40hCQsg8e2iG0iaeGWWtvRdz6YzObfzaWI8kFJEZyk1c82UZpkH1jL5VtR3 +3rzg/ogb1Tbq3tdGnTWaOs823qUfIdv97ElWSEmpWJpX05WXBqIE6aqPwebuKKKs +zdARGfctOONUVk86cLjkRBWhEmUqO4+orjowQZaGlwKCAQEAnbhD44Jx48mqddgF +Vnpm3xEnnaRaA1lPKSJp0m34+cSJaFLEb+nhVZBb9ROqo/x5pldHknGB1E8+oLPW +NiaitXP4W598gJOtgU5H/ouH8uVb8MkV7+0v7+1Rjdhz8Tl05+IHRZ9HEsRbXQeS +9gSIPXrtbHEzKeElasf7wTUP3sJOSZlIiDc3TyiN7K66NUQHa9+1k8C80pW+PrjD +9I6OhL0Q7fDgjW1madkG9ZtReZ3Ke8PpdtXOiewuiMpwvRuhGb+7PpBDU220188t +TWECOJob1GTstUO8CI1XQTWnXHPRxOeLGGyFgjFuif370kfSozfvrBmGCcC/JNWR +tHSqcQKCAQEAjp54/rLVTs65yrvGt2ckLZOfbe5OKkfBxd/Dbh3OtongwKPKBQop +U4eLIRm0z/UFssc6EIv/D3uTyQTobGPNmoNAUW/YBYtTEvEAJiWtRhW6tWIim4tF +l1+Iypz+I1uSx7Aq+KHmepQ0p5FWwOkUdkqTI8HDOOKs9g9ofOuR1bHun/GPCLdT +jO+2OkYQwc+lXqSCtcBsEt3A8qLzF8FiTmpv2ojtJ+ea2YhnOVFZvOgOpN0yPmoP +11s9lr/W7LsjKMhjpfJ2crxcGTgnNu4P/uFoeQi8eaI7fWNqqar5B8pNjvw2Hqes +w4NpDwHpcBjyPHNSogZ0784ghNdaxcS+bwKCAQAf+nzjNKkrHoNLq9ApVfVD2nqL +CjhIh8m+ljB/+4oZS9/wcx4SEKiKTOaX0LPXMMDTP9oWVmedfn/8Qwnbg2AcM7vR +CI4NL2j49ReTZ6vwgPWpEpvA5VFQBKlE/3F0h9e6raPzZDk7OKVyhfGidc1OI5ps +vy2OWLGggjIrFwaDPJNxWz3RoyICU2DdA3EFf7XGKvKwn1/5VLtp+6YGjv7JXTzI +AorncsM7lVBfL0oGrJ28JP4mA85ohyzvR0emJCnZF6TstNvwfEuo4pGDf5augXEQ +tGFetZd7OEPHxp6QlKJ+wpHWCPwMSmqU20sv5fYBl2NVu+piDUqAuenxmh34 +-----END RSA PRIVATE KEY----- diff --git a/vendor/github.com/elastic/beats/libbeat/outputs/transport/transptest/ca_test.pem b/vendor/github.com/elastic/beats/libbeat/outputs/transport/transptest/ca_test.pem new file mode 100644 index 0000000000..1e47f7fe9c --- /dev/null +++ b/vendor/github.com/elastic/beats/libbeat/outputs/transport/transptest/ca_test.pem @@ -0,0 +1,31 @@ +-----BEGIN CERTIFICATE----- +MIIFXjCCA0agAwIBAgIRAKLWz8tDzPgpOu7jES0jsT4wDQYJKoZIhvcNAQENBQAw +LzELMAkGA1UEBhMCVVMxEDAOBgNVBAoTB2VsYXN0aWMxDjAMBgNVBAsTBWJlYXRz +MB4XDTE2MDMzMTEzMDM1MloXDTI2MDMzMTEzMDM1MlowLzELMAkGA1UEBhMCVVMx +EDAOBgNVBAoTB2VsYXN0aWMxDjAMBgNVBAsTBWJlYXRzMIICIjANBgkqhkiG9w0B +AQEFAAOCAg8AMIICCgKCAgEAv/PngL9UMxv0SgLoPdySbwg96lYkBH3IE44ed8k7 +D8LJOlppqXkqQ9ho4ZdoAijF2YXA71wqqMLfE7OoZso0GoaFyXW/sgcBJWlIRSMf +1GzFhPalWayfMW5g5Kn3qptmg6h6jG1EI4sx2BHCNjNLDgD9SOnAMGR+qOf0E6cE +4fm6/PYmQEcYuBeJCzGjCPN/hundF/mKOOG1uTHaaBD5cyRozRFPVjqzW+A0G5GA +BZIcjuRXwddGeC/r0h0gdIUus7ZuqEWLJoogGk6yerYqEIQiftFszT32zbemFNSb +7W3AjRUyQ7Vtvyasq9lD7IppLny0NYEiEs7e/N5crCHWHePbHii4vlUn1M/yH7lo +SeYxUn9pCr2SoDObzsgq2Mh5K+sPqTyxNPZGJATTktp/0zdenoP9OIcTFsjmB6pN +ptu3jUIU7etPrGpA9xRZSXOpxXZ0RVXqZ1LUgMsk2Q0ADueZO5u5+Qw01oHSClEf +5ULlLKpFQejV5hQn6g+iaLUKlyN2+poxCoQIWFXtAru+YUorjWcYtvnUe5oJka3M +KaLRvqptjnTEmoYcbPRKaYqFCHcVvbV6ks31A8bDiluJmVD1vyN8e0XqFbDOEm6K +UqpGr8R5IvW25vZiBkB0gf4WpT/Ng1EtApoxiRXe/bQp4+hK0dpTirO4grvH4svY +YscCAwEAAaN1MHMwDgYDVR0PAQH/BAQDAgKkMB0GA1UdJQQWMBQGCCsGAQUFBwMC +BggrBgEFBQcDATAPBgNVHRMBAf8EBTADAQH/MA4GA1UdDgQHBAUxMjM0NTAQBgNV +HSMECTAHgAUxMjM0NTAPBgNVHREECDAGhwR/AAABMA0GCSqGSIb3DQEBDQUAA4IC +AQAQRXEZnTVMo1dnI2dMdDOlM3LPL5Pu62yh+oahyy44656SMXwRae0M8qIRg5j6 +2x5XDmD/OeBTXxdVvRv8hndPh66EO1pAkTPdWRs3Zft+6YMCTPEtd1IFD0x0vfx1 +TfjdfznaheTn1md2TH4ArydiQ+G9UP4fdaVJp1+veW3rvx601uVb7EU0csow6g4w +dWsRBNjjqWKsbKPvnyokyDoFyq/dtBXKhisdNX95IRrX182qMVc3I09kXaII3LnQ +nr7NDr2++muKwyZFwXVCNiky2/Cv4AcJvNyzLog+xZEn2KmuCTVYmpBP2kb2xgVm +3dMRlTyuDVjZAi3HL0gV5AOu4hV/3+Oe75U/wINJaUM82Pv3hpK7xOz9jjJokW8d +rijcVvH2fzL49vmdDfA0GwVLidAFLig3RCFucHmfwGgyJ6xesZummRhkE6aTHTCz +NwYpMfxmIQyMJRmBnvw62qm3vcMxhpMvLRAHDSUJIoHZmstyeHjGZgtlySpvFIj2 +9G8ngNnC/YZ0Y2Jdz6Yxn8RDDaienTS+Zucpq0YXXhplWF5w886kPdd4AOZ6KPov +BpKkRdvhHxt0D6wNOCMiaRvLkgc9ad8ykne84iwPYnDoPJtXAB7hnWlJNTyYiG7w +FxmYkoUw9qqnKYq2ps4lyWal1Sv7pVeGtg7HjHgNfYhyKg== +-----END CERTIFICATE----- diff --git a/vendor/github.com/elastic/beats/libbeat/outputs/transport/transptest/testing.go b/vendor/github.com/elastic/beats/libbeat/outputs/transport/transptest/testing.go new file mode 100644 index 0000000000..f657b17327 --- /dev/null +++ b/vendor/github.com/elastic/beats/libbeat/outputs/transport/transptest/testing.go @@ -0,0 +1,328 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package transptest + +import ( + "crypto/rand" + "crypto/rsa" + "crypto/tls" + "crypto/x509" + "crypto/x509/pkix" + "encoding/pem" + "errors" + "math/big" + "net" + "os" + "testing" + "time" + + "github.com/elastic/beats/libbeat/common/transport/tlscommon" + "github.com/elastic/beats/libbeat/outputs/transport" +) + +type MockServer struct { + net.Listener + Timeout time.Duration + Err error + Handshake func(net.Conn) + Transp func() (*transport.Client, error) +} + +type MockServerFactory func(*testing.T, time.Duration, string, *transport.ProxyConfig) *MockServer + +type TransportFactory func(addr string, proxy *transport.ProxyConfig) (*transport.Client, error) + +func (m *MockServer) Addr() string { + return m.Listener.Addr().String() +} + +func (m *MockServer) Accept() net.Conn { + if m.Err != nil { + return nil + } + + client, err := m.Listener.Accept() + m.Err = err + return client +} + +func (m *MockServer) Await() chan net.Conn { + c := make(chan net.Conn, 1) + go func() { + client := m.Accept() + m.Handshake(client) + c <- client + }() + return c +} + +func (m *MockServer) Connect() (*transport.Client, error) { + transp, err := m.Transp() + if err != nil { + return nil, err + } + + err = transp.Connect() + if err != nil { + return nil, err + } + return transp, nil +} + +func (m *MockServer) ConnectPair() (net.Conn, *transport.Client, error) { + transp, err := m.Transp() + if err != nil { + return nil, nil, err + } + + await := m.Await() + err = transp.Connect() + if err != nil { + return nil, nil, err + } + client := <-await + return client, transp, nil +} + +func (m *MockServer) ClientDeadline(client net.Conn, to time.Duration) { + if m.Err == nil { + m.Err = client.SetDeadline(time.Now().Add(to)) + } +} + +func NewMockServerTCP(t *testing.T, to time.Duration, cert string, proxy *transport.ProxyConfig) *MockServer { + tcpListener, err := net.Listen("tcp", "localhost:0") + if err != nil { + t.Fatalf("failed to generate TCP listener") + } + + server := &MockServer{Listener: tcpListener, Timeout: to} + server.Handshake = func(client net.Conn) {} + server.Transp = func() (*transport.Client, error) { + return connectTCP(to)(server.Addr(), proxy) + } + return server +} + +func NewMockServerTLS(t *testing.T, to time.Duration, cert string, proxy *transport.ProxyConfig) *MockServer { + tcpListener, err := net.Listen("tcp", "localhost:0") + if err != nil { + t.Fatalf("failed to generate TCP listener") + } + + tlsConfig, err := tlscommon.LoadTLSConfig(&tlscommon.Config{ + Certificate: tlscommon.CertificateConfig{ + Certificate: cert + ".pem", + Key: cert + ".key", + }, + }) + if err != nil { + t.Fatalf("failed to load certificate") + } + + listener := tls.NewListener(tcpListener, tlsConfig.BuildModuleConfig("")) + + server := &MockServer{Listener: listener, Timeout: to} + server.Handshake = func(client net.Conn) { + if server.Err != nil { + return + } + + server.ClientDeadline(client, server.Timeout) + if server.Err != nil { + return + } + + tlsConn, ok := client.(*tls.Conn) + if !ok { + server.Err = errors.New("no tls connection") + return + } + + server.Err = tlsConn.Handshake() + } + server.Transp = func() (*transport.Client, error) { + return connectTLS(to, cert)(server.Addr(), proxy) + } + + return server +} + +func connectTCP(timeout time.Duration) TransportFactory { + return func(addr string, proxy *transport.ProxyConfig) (*transport.Client, error) { + cfg := transport.Config{ + Proxy: proxy, + Timeout: timeout, + } + return transport.NewClient(&cfg, "tcp", addr, 0) + } +} + +func connectTLS(timeout time.Duration, certName string) TransportFactory { + return func(addr string, proxy *transport.ProxyConfig) (*transport.Client, error) { + tlsConfig, err := tlscommon.LoadTLSConfig(&tlscommon.Config{ + CAs: []string{certName + ".pem"}, + }) + if err != nil { + return nil, err + } + + cfg := transport.Config{ + Proxy: proxy, + TLS: tlsConfig, + Timeout: timeout, + } + return transport.NewClient(&cfg, "tcp", addr, 0) + } +} + +// GenCertForTestingPurpose generates a testing certificate. +// Generated is used for CA, client-auth and server-auth. Use only for testing. +func GenCertForTestingPurpose(t *testing.T, host, name, keyPassword string) error { + capem := name + ".pem" + cakey := name + ".key" + + _, err := os.Stat(capem) + if err == nil { + _, err = os.Stat(cakey) + if err == nil { + return nil + } + } + + serialNumberLimit := new(big.Int).Lsh(big.NewInt(1), 128) + serialNumber, err := rand.Int(rand.Reader, serialNumberLimit) + if err != nil { + t.Fatalf("failed to generate serial number: %s", err) + } + + caTemplate := x509.Certificate{ + SerialNumber: serialNumber, + Subject: pkix.Name{ + Country: []string{"US"}, + Organization: []string{"elastic"}, + OrganizationalUnit: []string{"beats"}, + }, + Issuer: pkix.Name{ + Country: []string{"US"}, + Organization: []string{"elastic"}, + OrganizationalUnit: []string{"beats"}, + Locality: []string{"locality"}, + Province: []string{"province"}, + StreetAddress: []string{"Mainstreet"}, + PostalCode: []string{"12345"}, + SerialNumber: "23", + CommonName: "*", + }, + + SignatureAlgorithm: x509.SHA512WithRSA, + PublicKeyAlgorithm: x509.ECDSA, + NotBefore: time.Now(), + NotAfter: time.Now().AddDate(10, 0, 0), + SubjectKeyId: []byte("12345"), + BasicConstraintsValid: true, + IsCA: true, + ExtKeyUsage: []x509.ExtKeyUsage{ + x509.ExtKeyUsageClientAuth, + x509.ExtKeyUsageServerAuth}, + KeyUsage: x509.KeyUsageKeyEncipherment | + x509.KeyUsageDigitalSignature | + x509.KeyUsageCertSign, + } + //Could be ip or dns format + ip := net.ParseIP(host) + if ip != nil { + caTemplate.IPAddresses = []net.IP{ip} + } else { + caTemplate.DNSNames = []string{host} + } + + pemBlock, err := genPrivatePem(4096, keyPassword) + if err != nil { + t.Fatalf("failed to generate ca private key: %v", err) + } + + // write key file + var keyOut *os.File + keyOut, err = os.OpenFile(cakey, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0600) + if err != nil { + t.Fatalf("failed to open key file for writing: %v", err) + } + pem.Encode(keyOut, pemBlock) + keyOut.Close() + + //Decrypt pem block to add it later to the certificate + if x509.IsEncryptedPEMBlock(pemBlock) { + pemBlock.Bytes, err = x509.DecryptPEMBlock(pemBlock, []byte(keyPassword)) + if err != nil { + t.Fatalf("failed to decrypt private key: %v", err) + } + } + + var priv *rsa.PrivateKey + priv, err = x509.ParsePKCS1PrivateKey(pemBlock.Bytes) + if err != nil { + t.Fatalf("failed to parse pemBlock to private key: %v", err) + return err + } + + pub := &priv.PublicKey + + // generate certificate + caBytes, err := x509.CreateCertificate( + rand.Reader, + &caTemplate, + &caTemplate, + pub, priv) + if err != nil { + t.Fatalf("failed to generate ca certificate: %v", err) + } + + // write certificate + certOut, err := os.Create(capem) + if err != nil { + t.Fatalf("failed to open cert.pem for writing: %s", err) + } + pem.Encode(certOut, &pem.Block{Type: "CERTIFICATE", Bytes: caBytes}) + certOut.Close() + + return nil +} + +func genPrivatePem(bits int, password string) (*pem.Block, error) { + //Generate private key + key, err := rsa.GenerateKey(rand.Reader, bits) + if err != nil { + return nil, err + } + + block := &pem.Block{ + Type: "RSA PRIVATE KEY", + Bytes: x509.MarshalPKCS1PrivateKey(key), + } + + //Encrypt pem block from the given password + if len(password) > 0 { + block, err = x509.EncryptPEMBlock(rand.Reader, block.Type, block.Bytes, []byte(password), x509.PEMCipherAES256) + if err != nil { + return nil, err + } + } + + return block, nil +} diff --git a/vendor/github.com/elastic/beats/libbeat/outputs/transport/util.go b/vendor/github.com/elastic/beats/libbeat/outputs/transport/util.go index 41e4be6d8e..bc9c6f7515 100644 --- a/vendor/github.com/elastic/beats/libbeat/outputs/transport/util.go +++ b/vendor/github.com/elastic/beats/libbeat/outputs/transport/util.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package transport import ( diff --git a/vendor/github.com/elastic/beats/libbeat/outputs/transport/wrap.go b/vendor/github.com/elastic/beats/libbeat/outputs/transport/wrap.go index 350d60db5b..7bde473535 100644 --- a/vendor/github.com/elastic/beats/libbeat/outputs/transport/wrap.go +++ b/vendor/github.com/elastic/beats/libbeat/outputs/transport/wrap.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package transport import "net" diff --git a/vendor/github.com/elastic/beats/libbeat/outputs/util.go b/vendor/github.com/elastic/beats/libbeat/outputs/util.go index dfd517d1b3..15068910f8 100644 --- a/vendor/github.com/elastic/beats/libbeat/outputs/util.go +++ b/vendor/github.com/elastic/beats/libbeat/outputs/util.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package outputs // Fail helper can be used by output factories, to create a failure response when diff --git a/vendor/github.com/elastic/beats/libbeat/paths/paths.go b/vendor/github.com/elastic/beats/libbeat/paths/paths.go index 971aad8549..6e33940dc0 100644 --- a/vendor/github.com/elastic/beats/libbeat/paths/paths.go +++ b/vendor/github.com/elastic/beats/libbeat/paths/paths.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + // Package paths provides a common way to handle paths // configuration for all Beats. // diff --git a/vendor/github.com/elastic/beats/libbeat/plugin/cli.go b/vendor/github.com/elastic/beats/libbeat/plugin/cli.go index 7e7c15ac07..40a356211a 100644 --- a/vendor/github.com/elastic/beats/libbeat/plugin/cli.go +++ b/vendor/github.com/elastic/beats/libbeat/plugin/cli.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + //+build linux,go1.8 darwin,go1.10 //+build cgo diff --git a/vendor/github.com/elastic/beats/libbeat/plugin/cli_stub.go b/vendor/github.com/elastic/beats/libbeat/plugin/cli_stub.go index 6ee9af4338..3be1dc3325 100644 --- a/vendor/github.com/elastic/beats/libbeat/plugin/cli_stub.go +++ b/vendor/github.com/elastic/beats/libbeat/plugin/cli_stub.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + //+build linux,!go1.8 darwin,!go1.10 !linux,!darwin !cgo package plugin diff --git a/vendor/github.com/elastic/beats/libbeat/plugin/load.go b/vendor/github.com/elastic/beats/libbeat/plugin/load.go index d68a118317..f07174309e 100644 --- a/vendor/github.com/elastic/beats/libbeat/plugin/load.go +++ b/vendor/github.com/elastic/beats/libbeat/plugin/load.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + //+build linux,go1.8 darwin,go1.10 //+build cgo diff --git a/vendor/github.com/elastic/beats/libbeat/plugin/load_stub.go b/vendor/github.com/elastic/beats/libbeat/plugin/load_stub.go index d6e917b33a..829292bf13 100644 --- a/vendor/github.com/elastic/beats/libbeat/plugin/load_stub.go +++ b/vendor/github.com/elastic/beats/libbeat/plugin/load_stub.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + //+build linux,!go1.8 darwin,!go1.10 !linux,!darwin !cgo package plugin diff --git a/vendor/github.com/elastic/beats/libbeat/plugin/plugin.go b/vendor/github.com/elastic/beats/libbeat/plugin/plugin.go index 8454c96eaa..82414ec972 100644 --- a/vendor/github.com/elastic/beats/libbeat/plugin/plugin.go +++ b/vendor/github.com/elastic/beats/libbeat/plugin/plugin.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package plugin import "fmt" diff --git a/vendor/github.com/elastic/beats/libbeat/processors/actions/checks.go b/vendor/github.com/elastic/beats/libbeat/processors/actions/checks.go index 651a15fe4a..2800ecef1b 100644 --- a/vendor/github.com/elastic/beats/libbeat/processors/actions/checks.go +++ b/vendor/github.com/elastic/beats/libbeat/processors/actions/checks.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package actions import ( diff --git a/vendor/github.com/elastic/beats/libbeat/processors/actions/decode_json_fields.go b/vendor/github.com/elastic/beats/libbeat/processors/actions/decode_json_fields.go index 9b7ff709ea..d8832858da 100644 --- a/vendor/github.com/elastic/beats/libbeat/processors/actions/decode_json_fields.go +++ b/vendor/github.com/elastic/beats/libbeat/processors/actions/decode_json_fields.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package actions import ( diff --git a/vendor/github.com/elastic/beats/libbeat/processors/actions/drop_event.go b/vendor/github.com/elastic/beats/libbeat/processors/actions/drop_event.go index c59cf7d7bc..b6b735112e 100644 --- a/vendor/github.com/elastic/beats/libbeat/processors/actions/drop_event.go +++ b/vendor/github.com/elastic/beats/libbeat/processors/actions/drop_event.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package actions import ( diff --git a/vendor/github.com/elastic/beats/libbeat/processors/actions/drop_fields.go b/vendor/github.com/elastic/beats/libbeat/processors/actions/drop_fields.go index 76ef347c79..f3c528728f 100644 --- a/vendor/github.com/elastic/beats/libbeat/processors/actions/drop_fields.go +++ b/vendor/github.com/elastic/beats/libbeat/processors/actions/drop_fields.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package actions import ( diff --git a/vendor/github.com/elastic/beats/libbeat/processors/actions/extract_field.go b/vendor/github.com/elastic/beats/libbeat/processors/actions/extract_field.go index 68ee10f3b1..4b03f8f8a5 100644 --- a/vendor/github.com/elastic/beats/libbeat/processors/actions/extract_field.go +++ b/vendor/github.com/elastic/beats/libbeat/processors/actions/extract_field.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package actions import ( diff --git a/vendor/github.com/elastic/beats/libbeat/processors/actions/include_fields.go b/vendor/github.com/elastic/beats/libbeat/processors/actions/include_fields.go index 18a3703dc1..1ce3f23405 100644 --- a/vendor/github.com/elastic/beats/libbeat/processors/actions/include_fields.go +++ b/vendor/github.com/elastic/beats/libbeat/processors/actions/include_fields.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package actions import ( diff --git a/vendor/github.com/elastic/beats/libbeat/processors/actions/rename.go b/vendor/github.com/elastic/beats/libbeat/processors/actions/rename.go index dac988aaca..bae1bd753f 100644 --- a/vendor/github.com/elastic/beats/libbeat/processors/actions/rename.go +++ b/vendor/github.com/elastic/beats/libbeat/processors/actions/rename.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package actions import ( diff --git a/vendor/github.com/elastic/beats/libbeat/processors/add_cloud_metadata/add_cloud_metadata.go b/vendor/github.com/elastic/beats/libbeat/processors/add_cloud_metadata/add_cloud_metadata.go index 9d55e3c99f..c2bdfbc014 100644 --- a/vendor/github.com/elastic/beats/libbeat/processors/add_cloud_metadata/add_cloud_metadata.go +++ b/vendor/github.com/elastic/beats/libbeat/processors/add_cloud_metadata/add_cloud_metadata.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package add_cloud_metadata import ( diff --git a/vendor/github.com/elastic/beats/libbeat/processors/add_cloud_metadata/provider_alibaba_cloud.go b/vendor/github.com/elastic/beats/libbeat/processors/add_cloud_metadata/provider_alibaba_cloud.go index e0425d59b0..2e88107c81 100644 --- a/vendor/github.com/elastic/beats/libbeat/processors/add_cloud_metadata/provider_alibaba_cloud.go +++ b/vendor/github.com/elastic/beats/libbeat/processors/add_cloud_metadata/provider_alibaba_cloud.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package add_cloud_metadata import "github.com/elastic/beats/libbeat/common" diff --git a/vendor/github.com/elastic/beats/libbeat/processors/add_cloud_metadata/provider_aws_ec2.go b/vendor/github.com/elastic/beats/libbeat/processors/add_cloud_metadata/provider_aws_ec2.go index 70293772b9..3b6925c677 100644 --- a/vendor/github.com/elastic/beats/libbeat/processors/add_cloud_metadata/provider_aws_ec2.go +++ b/vendor/github.com/elastic/beats/libbeat/processors/add_cloud_metadata/provider_aws_ec2.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package add_cloud_metadata import ( diff --git a/vendor/github.com/elastic/beats/libbeat/processors/add_cloud_metadata/provider_azure_vm.go b/vendor/github.com/elastic/beats/libbeat/processors/add_cloud_metadata/provider_azure_vm.go index 10193d9cd4..0f7d0239f0 100644 --- a/vendor/github.com/elastic/beats/libbeat/processors/add_cloud_metadata/provider_azure_vm.go +++ b/vendor/github.com/elastic/beats/libbeat/processors/add_cloud_metadata/provider_azure_vm.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package add_cloud_metadata import ( diff --git a/vendor/github.com/elastic/beats/libbeat/processors/add_cloud_metadata/provider_digital_ocean.go b/vendor/github.com/elastic/beats/libbeat/processors/add_cloud_metadata/provider_digital_ocean.go index 9ae262491f..52d17fcec2 100644 --- a/vendor/github.com/elastic/beats/libbeat/processors/add_cloud_metadata/provider_digital_ocean.go +++ b/vendor/github.com/elastic/beats/libbeat/processors/add_cloud_metadata/provider_digital_ocean.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package add_cloud_metadata import ( diff --git a/vendor/github.com/elastic/beats/libbeat/processors/add_cloud_metadata/provider_google_gce.go b/vendor/github.com/elastic/beats/libbeat/processors/add_cloud_metadata/provider_google_gce.go index 442ade463b..fd799ab479 100644 --- a/vendor/github.com/elastic/beats/libbeat/processors/add_cloud_metadata/provider_google_gce.go +++ b/vendor/github.com/elastic/beats/libbeat/processors/add_cloud_metadata/provider_google_gce.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package add_cloud_metadata import ( diff --git a/vendor/github.com/elastic/beats/libbeat/processors/add_cloud_metadata/provider_tencent_cloud.go b/vendor/github.com/elastic/beats/libbeat/processors/add_cloud_metadata/provider_tencent_cloud.go index 4883ea18d8..6fbe60266e 100644 --- a/vendor/github.com/elastic/beats/libbeat/processors/add_cloud_metadata/provider_tencent_cloud.go +++ b/vendor/github.com/elastic/beats/libbeat/processors/add_cloud_metadata/provider_tencent_cloud.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package add_cloud_metadata import "github.com/elastic/beats/libbeat/common" diff --git a/vendor/github.com/elastic/beats/libbeat/processors/add_docker_metadata/add_docker_metadata.go b/vendor/github.com/elastic/beats/libbeat/processors/add_docker_metadata/add_docker_metadata.go index b936b4b2c0..c4af0c848c 100644 --- a/vendor/github.com/elastic/beats/libbeat/processors/add_docker_metadata/add_docker_metadata.go +++ b/vendor/github.com/elastic/beats/libbeat/processors/add_docker_metadata/add_docker_metadata.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package add_docker_metadata import ( diff --git a/vendor/github.com/elastic/beats/libbeat/processors/add_docker_metadata/config.go b/vendor/github.com/elastic/beats/libbeat/processors/add_docker_metadata/config.go index 5755bc07e2..a88caa97d0 100644 --- a/vendor/github.com/elastic/beats/libbeat/processors/add_docker_metadata/config.go +++ b/vendor/github.com/elastic/beats/libbeat/processors/add_docker_metadata/config.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package add_docker_metadata import ( diff --git a/vendor/github.com/elastic/beats/libbeat/processors/add_host_metadata/add_host_metadata.go b/vendor/github.com/elastic/beats/libbeat/processors/add_host_metadata/add_host_metadata.go index f27557e7d1..57bdb43dc5 100644 --- a/vendor/github.com/elastic/beats/libbeat/processors/add_host_metadata/add_host_metadata.go +++ b/vendor/github.com/elastic/beats/libbeat/processors/add_host_metadata/add_host_metadata.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package add_host_metadata import ( diff --git a/vendor/github.com/elastic/beats/libbeat/processors/add_host_metadata/config.go b/vendor/github.com/elastic/beats/libbeat/processors/add_host_metadata/config.go index 5ead35b4c0..30f2e293b6 100644 --- a/vendor/github.com/elastic/beats/libbeat/processors/add_host_metadata/config.go +++ b/vendor/github.com/elastic/beats/libbeat/processors/add_host_metadata/config.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package add_host_metadata // Config for add_host_metadata processor. diff --git a/vendor/github.com/elastic/beats/libbeat/processors/add_kubernetes_metadata/cache.go b/vendor/github.com/elastic/beats/libbeat/processors/add_kubernetes_metadata/cache.go index 279b1aa2ea..156ae38e3b 100644 --- a/vendor/github.com/elastic/beats/libbeat/processors/add_kubernetes_metadata/cache.go +++ b/vendor/github.com/elastic/beats/libbeat/processors/add_kubernetes_metadata/cache.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package add_kubernetes_metadata import ( diff --git a/vendor/github.com/elastic/beats/libbeat/processors/add_kubernetes_metadata/config.go b/vendor/github.com/elastic/beats/libbeat/processors/add_kubernetes_metadata/config.go index ce805f96f8..a4270a5861 100644 --- a/vendor/github.com/elastic/beats/libbeat/processors/add_kubernetes_metadata/config.go +++ b/vendor/github.com/elastic/beats/libbeat/processors/add_kubernetes_metadata/config.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package add_kubernetes_metadata import ( diff --git a/vendor/github.com/elastic/beats/libbeat/processors/add_kubernetes_metadata/indexers.go b/vendor/github.com/elastic/beats/libbeat/processors/add_kubernetes_metadata/indexers.go index 4ada610e63..49e23665b0 100644 --- a/vendor/github.com/elastic/beats/libbeat/processors/add_kubernetes_metadata/indexers.go +++ b/vendor/github.com/elastic/beats/libbeat/processors/add_kubernetes_metadata/indexers.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package add_kubernetes_metadata import ( @@ -43,7 +60,7 @@ type Indexers struct { // IndexerConstructor builds a new indexer from its settings type IndexerConstructor func(config common.Config, metaGen kubernetes.MetaGenerator) (Indexer, error) -// NewIndexers builds indexers object +// NewIndexers builds indexers object func NewIndexers(configs PluginConfig, metaGen kubernetes.MetaGenerator) *Indexers { indexers := []Indexer{} for _, pluginConfigs := range configs { @@ -57,6 +74,7 @@ func NewIndexers(configs PluginConfig, metaGen kubernetes.MetaGenerator) *Indexe indexer, err := indexFunc(pluginConfig, metaGen) if err != nil { logp.Warn("Unable to initialize indexing plugin %s due to error %v", name, err) + continue } indexers = append(indexers, indexer) @@ -96,6 +114,8 @@ func (i *Indexers) GetMetadata(pod *kubernetes.Pod) []MetadataIndex { // Empty returns true if indexers list is empty func (i *Indexers) Empty() bool { + i.RLock() + defer i.RUnlock() if len(i.indexers) == 0 { return true } @@ -118,7 +138,7 @@ func (p *PodNameIndexer) GetMetadata(pod *kubernetes.Pod) []MetadataIndex { data := p.metaGen.PodMetadata(pod) return []MetadataIndex{ { - Index: fmt.Sprintf("%s/%s", pod.Metadata.Namespace, pod.Metadata.Name), + Index: fmt.Sprintf("%s/%s", pod.Metadata.GetNamespace(), pod.Metadata.GetName()), Data: data, }, } @@ -126,7 +146,7 @@ func (p *PodNameIndexer) GetMetadata(pod *kubernetes.Pod) []MetadataIndex { // GetIndexes returns the indexes for the given Pod func (p *PodNameIndexer) GetIndexes(pod *kubernetes.Pod) []string { - return []string{fmt.Sprintf("%s/%s", pod.Metadata.Namespace, pod.Metadata.Name)} + return []string{fmt.Sprintf("%s/%s", pod.Metadata.GetNamespace(), pod.Metadata.GetName())} } // PodUIDIndexer indexes pods based on the pod UID @@ -144,7 +164,7 @@ func (p *PodUIDIndexer) GetMetadata(pod *kubernetes.Pod) []MetadataIndex { data := p.metaGen.PodMetadata(pod) return []MetadataIndex{ { - Index: pod.Metadata.UID, + Index: pod.Metadata.GetUid(), Data: data, }, } @@ -152,7 +172,7 @@ func (p *PodUIDIndexer) GetMetadata(pod *kubernetes.Pod) []MetadataIndex { // GetIndexes returns the indexes for the given Pod func (p *PodUIDIndexer) GetIndexes(pod *kubernetes.Pod) []string { - return []string{pod.Metadata.UID} + return []string{pod.Metadata.GetUid()} } // ContainerIndexer indexes pods based on all their containers IDs @@ -169,13 +189,13 @@ func NewContainerIndexer(_ common.Config, metaGen kubernetes.MetaGenerator) (Ind func (c *ContainerIndexer) GetMetadata(pod *kubernetes.Pod) []MetadataIndex { var metadata []MetadataIndex for _, status := range append(pod.Status.ContainerStatuses, pod.Status.InitContainerStatuses...) { - cID := status.GetContainerID() + cID := kubernetes.ContainerID(status) if cID == "" { continue } metadata = append(metadata, MetadataIndex{ Index: cID, - Data: c.metaGen.ContainerMetadata(pod, status.Name), + Data: c.metaGen.ContainerMetadata(pod, status.GetName()), }) } @@ -186,7 +206,7 @@ func (c *ContainerIndexer) GetMetadata(pod *kubernetes.Pod) []MetadataIndex { func (c *ContainerIndexer) GetIndexes(pod *kubernetes.Pod) []string { var containers []string for _, status := range append(pod.Status.ContainerStatuses, pod.Status.InitContainerStatuses...) { - cID := status.GetContainerID() + cID := kubernetes.ContainerID(status) if cID == "" { continue } @@ -209,23 +229,23 @@ func NewIPPortIndexer(_ common.Config, metaGen kubernetes.MetaGenerator) (Indexe func (h *IPPortIndexer) GetMetadata(pod *kubernetes.Pod) []MetadataIndex { var metadata []MetadataIndex - if pod.Status.PodIP == "" { + if pod.Status.GetPodIP() == "" { return metadata } // Add pod IP metadata = append(metadata, MetadataIndex{ - Index: pod.Status.PodIP, + Index: pod.Status.GetPodIP(), Data: h.metaGen.PodMetadata(pod), }) for _, container := range pod.Spec.Containers { for _, port := range container.Ports { - if port.ContainerPort != int64(0) { + if port.GetContainerPort() != 0 { metadata = append(metadata, MetadataIndex{ - Index: fmt.Sprintf("%s:%d", pod.Status.PodIP, port.ContainerPort), - Data: h.metaGen.ContainerMetadata(pod, container.Name), + Index: fmt.Sprintf("%s:%d", pod.Status.GetPodIP(), port.GetContainerPort()), + Data: h.metaGen.ContainerMetadata(pod, container.GetName()), }) } } @@ -238,19 +258,19 @@ func (h *IPPortIndexer) GetMetadata(pod *kubernetes.Pod) []MetadataIndex { func (h *IPPortIndexer) GetIndexes(pod *kubernetes.Pod) []string { var hostPorts []string - if pod.Status.PodIP == "" { + if pod.Status.GetPodIP() == "" { return hostPorts } // Add pod IP - hostPorts = append(hostPorts, pod.Status.PodIP) + hostPorts = append(hostPorts, pod.Status.GetPodIP()) for _, container := range pod.Spec.Containers { ports := container.Ports for _, port := range ports { - if port.ContainerPort != int64(0) { - hostPorts = append(hostPorts, fmt.Sprintf("%s:%d", pod.Status.PodIP, port.ContainerPort)) + if port.GetContainerPort() != 0 { + hostPorts = append(hostPorts, fmt.Sprintf("%s:%d", pod.Status.GetPodIP(), port.GetContainerPort())) } } } diff --git a/vendor/github.com/elastic/beats/libbeat/processors/add_kubernetes_metadata/indexing.go b/vendor/github.com/elastic/beats/libbeat/processors/add_kubernetes_metadata/indexing.go index 21015b87ba..e5485abe47 100644 --- a/vendor/github.com/elastic/beats/libbeat/processors/add_kubernetes_metadata/indexing.go +++ b/vendor/github.com/elastic/beats/libbeat/processors/add_kubernetes_metadata/indexing.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package add_kubernetes_metadata import ( diff --git a/vendor/github.com/elastic/beats/libbeat/processors/add_kubernetes_metadata/kubernetes.go b/vendor/github.com/elastic/beats/libbeat/processors/add_kubernetes_metadata/kubernetes.go index a14a53447e..4d94870ba1 100644 --- a/vendor/github.com/elastic/beats/libbeat/processors/add_kubernetes_metadata/kubernetes.go +++ b/vendor/github.com/elastic/beats/libbeat/processors/add_kubernetes_metadata/kubernetes.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package add_kubernetes_metadata import ( diff --git a/vendor/github.com/elastic/beats/libbeat/processors/add_kubernetes_metadata/matchers.go b/vendor/github.com/elastic/beats/libbeat/processors/add_kubernetes_metadata/matchers.go index 04dc963912..6159082177 100644 --- a/vendor/github.com/elastic/beats/libbeat/processors/add_kubernetes_metadata/matchers.go +++ b/vendor/github.com/elastic/beats/libbeat/processors/add_kubernetes_metadata/matchers.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package add_kubernetes_metadata import ( @@ -45,6 +62,7 @@ func NewMatchers(configs PluginConfig) *Matchers { matcher, err := matchFunc(pluginConfig) if err != nil { logp.Warn("Unable to initialize matcher plugin %s due to error %v", name, err) + continue } matchers = append(matchers, matcher) @@ -72,6 +90,8 @@ func (m *Matchers) MetadataIndex(event common.MapStr) string { } func (m *Matchers) Empty() bool { + m.RLock() + defer m.RUnlock() if len(m.matchers) == 0 { return true } diff --git a/vendor/github.com/elastic/beats/libbeat/processors/add_kubernetes_metadata/registry.go b/vendor/github.com/elastic/beats/libbeat/processors/add_kubernetes_metadata/registry.go index 4fd66e39bd..7198f48555 100644 --- a/vendor/github.com/elastic/beats/libbeat/processors/add_kubernetes_metadata/registry.go +++ b/vendor/github.com/elastic/beats/libbeat/processors/add_kubernetes_metadata/registry.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package add_kubernetes_metadata import ( diff --git a/vendor/github.com/elastic/beats/libbeat/processors/add_locale/add_locale.go b/vendor/github.com/elastic/beats/libbeat/processors/add_locale/add_locale.go index 77d29d8075..113824ef66 100644 --- a/vendor/github.com/elastic/beats/libbeat/processors/add_locale/add_locale.go +++ b/vendor/github.com/elastic/beats/libbeat/processors/add_locale/add_locale.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package add_locale import ( diff --git a/vendor/github.com/elastic/beats/libbeat/processors/condition.go b/vendor/github.com/elastic/beats/libbeat/processors/condition.go index 0a8c943419..21b936e96a 100644 --- a/vendor/github.com/elastic/beats/libbeat/processors/condition.go +++ b/vendor/github.com/elastic/beats/libbeat/processors/condition.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package processors import ( diff --git a/vendor/github.com/elastic/beats/libbeat/processors/config.go b/vendor/github.com/elastic/beats/libbeat/processors/config.go index b5668dfeab..d738ef5e00 100644 --- a/vendor/github.com/elastic/beats/libbeat/processors/config.go +++ b/vendor/github.com/elastic/beats/libbeat/processors/config.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package processors import ( diff --git a/vendor/github.com/elastic/beats/libbeat/processors/dissect/config.go b/vendor/github.com/elastic/beats/libbeat/processors/dissect/config.go index 1a61fbc4e2..e3051497e0 100644 --- a/vendor/github.com/elastic/beats/libbeat/processors/dissect/config.go +++ b/vendor/github.com/elastic/beats/libbeat/processors/dissect/config.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package dissect type config struct { diff --git a/vendor/github.com/elastic/beats/libbeat/processors/dissect/const.go b/vendor/github.com/elastic/beats/libbeat/processors/dissect/const.go index 079aa16560..78be837256 100644 --- a/vendor/github.com/elastic/beats/libbeat/processors/dissect/const.go +++ b/vendor/github.com/elastic/beats/libbeat/processors/dissect/const.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package dissect import ( diff --git a/vendor/github.com/elastic/beats/libbeat/processors/dissect/delimiter.go b/vendor/github.com/elastic/beats/libbeat/processors/dissect/delimiter.go index b60978fb97..197c354815 100644 --- a/vendor/github.com/elastic/beats/libbeat/processors/dissect/delimiter.go +++ b/vendor/github.com/elastic/beats/libbeat/processors/dissect/delimiter.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package dissect import ( diff --git a/vendor/github.com/elastic/beats/libbeat/processors/dissect/dissect.go b/vendor/github.com/elastic/beats/libbeat/processors/dissect/dissect.go index 74e096bb4b..12dcbd7c74 100644 --- a/vendor/github.com/elastic/beats/libbeat/processors/dissect/dissect.go +++ b/vendor/github.com/elastic/beats/libbeat/processors/dissect/dissect.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package dissect import "fmt" @@ -101,7 +118,8 @@ func (d *Dissector) extract(s string) (positions, error) { dl = dl.Next() } - if offset < len(s) { + // If we have remaining contents and have not captured all the requested fields + if offset < len(s) && i < len(d.parser.fields) { positions[i] = position{start: offset, end: len(s)} } return positions, nil diff --git a/vendor/github.com/elastic/beats/libbeat/processors/dissect/field.go b/vendor/github.com/elastic/beats/libbeat/processors/dissect/field.go index 06b428688a..73a3b492d1 100644 --- a/vendor/github.com/elastic/beats/libbeat/processors/dissect/field.go +++ b/vendor/github.com/elastic/beats/libbeat/processors/dissect/field.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package dissect import ( diff --git a/vendor/github.com/elastic/beats/libbeat/processors/dissect/parser.go b/vendor/github.com/elastic/beats/libbeat/processors/dissect/parser.go index 40237e4286..d8d4d23d12 100644 --- a/vendor/github.com/elastic/beats/libbeat/processors/dissect/parser.go +++ b/vendor/github.com/elastic/beats/libbeat/processors/dissect/parser.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package dissect import ( diff --git a/vendor/github.com/elastic/beats/libbeat/processors/dissect/processor.go b/vendor/github.com/elastic/beats/libbeat/processors/dissect/processor.go index e408296840..613ea38dc1 100644 --- a/vendor/github.com/elastic/beats/libbeat/processors/dissect/processor.go +++ b/vendor/github.com/elastic/beats/libbeat/processors/dissect/processor.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package dissect import ( diff --git a/vendor/github.com/elastic/beats/libbeat/processors/namespace.go b/vendor/github.com/elastic/beats/libbeat/processors/namespace.go index d86b8ae797..0cba00ec16 100644 --- a/vendor/github.com/elastic/beats/libbeat/processors/namespace.go +++ b/vendor/github.com/elastic/beats/libbeat/processors/namespace.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package processors import ( diff --git a/vendor/github.com/elastic/beats/libbeat/processors/processor.go b/vendor/github.com/elastic/beats/libbeat/processors/processor.go index b40bdaf7c2..f530d01e36 100644 --- a/vendor/github.com/elastic/beats/libbeat/processors/processor.go +++ b/vendor/github.com/elastic/beats/libbeat/processors/processor.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package processors import ( diff --git a/vendor/github.com/elastic/beats/libbeat/processors/registry.go b/vendor/github.com/elastic/beats/libbeat/processors/registry.go index 487c09091d..ca5947fa40 100644 --- a/vendor/github.com/elastic/beats/libbeat/processors/registry.go +++ b/vendor/github.com/elastic/beats/libbeat/processors/registry.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package processors import ( diff --git a/vendor/github.com/elastic/beats/libbeat/publisher/event.go b/vendor/github.com/elastic/beats/libbeat/publisher/event.go index 4f5dbedd23..dfcd930ee1 100644 --- a/vendor/github.com/elastic/beats/libbeat/publisher/event.go +++ b/vendor/github.com/elastic/beats/libbeat/publisher/event.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package publisher import ( diff --git a/vendor/github.com/elastic/beats/libbeat/publisher/includes/includes.go b/vendor/github.com/elastic/beats/libbeat/publisher/includes/includes.go index 99b65e0984..c66b307a6f 100644 --- a/vendor/github.com/elastic/beats/libbeat/publisher/includes/includes.go +++ b/vendor/github.com/elastic/beats/libbeat/publisher/includes/includes.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package includes import ( diff --git a/vendor/github.com/elastic/beats/libbeat/publisher/pipeline/acker.go b/vendor/github.com/elastic/beats/libbeat/publisher/pipeline/acker.go index 231d85e4f7..1d4155677a 100644 --- a/vendor/github.com/elastic/beats/libbeat/publisher/pipeline/acker.go +++ b/vendor/github.com/elastic/beats/libbeat/publisher/pipeline/acker.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package pipeline import ( diff --git a/vendor/github.com/elastic/beats/libbeat/publisher/pipeline/batch.go b/vendor/github.com/elastic/beats/libbeat/publisher/pipeline/batch.go index 8d5ffaef9d..7ce87bd77a 100644 --- a/vendor/github.com/elastic/beats/libbeat/publisher/pipeline/batch.go +++ b/vendor/github.com/elastic/beats/libbeat/publisher/pipeline/batch.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package pipeline import ( diff --git a/vendor/github.com/elastic/beats/libbeat/publisher/pipeline/client.go b/vendor/github.com/elastic/beats/libbeat/publisher/pipeline/client.go index 313a71587b..9901fa207c 100644 --- a/vendor/github.com/elastic/beats/libbeat/publisher/pipeline/client.go +++ b/vendor/github.com/elastic/beats/libbeat/publisher/pipeline/client.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package pipeline import ( diff --git a/vendor/github.com/elastic/beats/libbeat/publisher/pipeline/client_ack.go b/vendor/github.com/elastic/beats/libbeat/publisher/pipeline/client_ack.go index a9dfd6e7e3..123a1c6ffa 100644 --- a/vendor/github.com/elastic/beats/libbeat/publisher/pipeline/client_ack.go +++ b/vendor/github.com/elastic/beats/libbeat/publisher/pipeline/client_ack.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package pipeline import ( diff --git a/vendor/github.com/elastic/beats/libbeat/publisher/pipeline/config.go b/vendor/github.com/elastic/beats/libbeat/publisher/pipeline/config.go index 1c002cbb8e..6aa1de5457 100644 --- a/vendor/github.com/elastic/beats/libbeat/publisher/pipeline/config.go +++ b/vendor/github.com/elastic/beats/libbeat/publisher/pipeline/config.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package pipeline import ( diff --git a/vendor/github.com/elastic/beats/libbeat/publisher/pipeline/consumer.go b/vendor/github.com/elastic/beats/libbeat/publisher/pipeline/consumer.go index 391824cfff..cb1aec86b6 100644 --- a/vendor/github.com/elastic/beats/libbeat/publisher/pipeline/consumer.go +++ b/vendor/github.com/elastic/beats/libbeat/publisher/pipeline/consumer.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package pipeline import ( diff --git a/vendor/github.com/elastic/beats/libbeat/publisher/pipeline/controller.go b/vendor/github.com/elastic/beats/libbeat/publisher/pipeline/controller.go index 7595a0cd88..303792adb9 100644 --- a/vendor/github.com/elastic/beats/libbeat/publisher/pipeline/controller.go +++ b/vendor/github.com/elastic/beats/libbeat/publisher/pipeline/controller.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package pipeline import ( diff --git a/vendor/github.com/elastic/beats/libbeat/publisher/pipeline/module.go b/vendor/github.com/elastic/beats/libbeat/publisher/pipeline/module.go index 6bcefa0a28..4d3c8bd9ca 100644 --- a/vendor/github.com/elastic/beats/libbeat/publisher/pipeline/module.go +++ b/vendor/github.com/elastic/beats/libbeat/publisher/pipeline/module.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package pipeline import ( diff --git a/vendor/github.com/elastic/beats/libbeat/publisher/pipeline/monitoring.go b/vendor/github.com/elastic/beats/libbeat/publisher/pipeline/monitoring.go index 8ba2ad3734..4fbf3ff8da 100644 --- a/vendor/github.com/elastic/beats/libbeat/publisher/pipeline/monitoring.go +++ b/vendor/github.com/elastic/beats/libbeat/publisher/pipeline/monitoring.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package pipeline import "github.com/elastic/beats/libbeat/monitoring" diff --git a/vendor/github.com/elastic/beats/libbeat/publisher/pipeline/output.go b/vendor/github.com/elastic/beats/libbeat/publisher/pipeline/output.go index 7995f8dbfe..4a7b59c9f0 100644 --- a/vendor/github.com/elastic/beats/libbeat/publisher/pipeline/output.go +++ b/vendor/github.com/elastic/beats/libbeat/publisher/pipeline/output.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package pipeline import ( diff --git a/vendor/github.com/elastic/beats/libbeat/publisher/pipeline/pipeline.go b/vendor/github.com/elastic/beats/libbeat/publisher/pipeline/pipeline.go index 8ffa191180..9fd41fd01d 100644 --- a/vendor/github.com/elastic/beats/libbeat/publisher/pipeline/pipeline.go +++ b/vendor/github.com/elastic/beats/libbeat/publisher/pipeline/pipeline.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + // Package pipeline combines all publisher functionality (processors, queue, // outputs) to create instances of complete publisher pipelines, beats can // connect to publish events to. diff --git a/vendor/github.com/elastic/beats/libbeat/publisher/pipeline/pipeline_ack.go b/vendor/github.com/elastic/beats/libbeat/publisher/pipeline/pipeline_ack.go index 1fd39f411e..d0cea240c0 100644 --- a/vendor/github.com/elastic/beats/libbeat/publisher/pipeline/pipeline_ack.go +++ b/vendor/github.com/elastic/beats/libbeat/publisher/pipeline/pipeline_ack.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package pipeline import ( diff --git a/vendor/github.com/elastic/beats/libbeat/publisher/pipeline/processor.go b/vendor/github.com/elastic/beats/libbeat/publisher/pipeline/processor.go index 5f058cdde8..e2dcb7c73c 100644 --- a/vendor/github.com/elastic/beats/libbeat/publisher/pipeline/processor.go +++ b/vendor/github.com/elastic/beats/libbeat/publisher/pipeline/processor.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package pipeline import ( @@ -278,7 +295,7 @@ func debugPrintProcessor(info beat.Info) *processorFn { // beat.Client is shared between multiple go-routines by accident) var mux sync.Mutex - encoder := json.New(true, info.Version) + encoder := json.New(true, false, info.Version) return newProcessor("debugPrint", func(event *beat.Event) (*beat.Event, error) { mux.Lock() defer mux.Unlock() diff --git a/vendor/github.com/elastic/beats/libbeat/publisher/pipeline/retry.go b/vendor/github.com/elastic/beats/libbeat/publisher/pipeline/retry.go index d2a40b0fdc..250713b03a 100644 --- a/vendor/github.com/elastic/beats/libbeat/publisher/pipeline/retry.go +++ b/vendor/github.com/elastic/beats/libbeat/publisher/pipeline/retry.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package pipeline import ( diff --git a/vendor/github.com/elastic/beats/libbeat/publisher/pipeline/util.go b/vendor/github.com/elastic/beats/libbeat/publisher/pipeline/util.go index 8b9949e4bb..db656f4ae9 100644 --- a/vendor/github.com/elastic/beats/libbeat/publisher/pipeline/util.go +++ b/vendor/github.com/elastic/beats/libbeat/publisher/pipeline/util.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package pipeline import "sync" diff --git a/vendor/github.com/elastic/beats/libbeat/publisher/queue/memqueue/ackloop.go b/vendor/github.com/elastic/beats/libbeat/publisher/queue/memqueue/ackloop.go index 21af8bf95c..1fbd4d0957 100644 --- a/vendor/github.com/elastic/beats/libbeat/publisher/queue/memqueue/ackloop.go +++ b/vendor/github.com/elastic/beats/libbeat/publisher/queue/memqueue/ackloop.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package memqueue // ackLoop implements the brokers asynchronous ACK worker. diff --git a/vendor/github.com/elastic/beats/libbeat/publisher/queue/memqueue/batchbuf.go b/vendor/github.com/elastic/beats/libbeat/publisher/queue/memqueue/batchbuf.go index 41ff0e2081..d84c8717ac 100644 --- a/vendor/github.com/elastic/beats/libbeat/publisher/queue/memqueue/batchbuf.go +++ b/vendor/github.com/elastic/beats/libbeat/publisher/queue/memqueue/batchbuf.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package memqueue import "github.com/elastic/beats/libbeat/publisher" diff --git a/vendor/github.com/elastic/beats/libbeat/publisher/queue/memqueue/broker.go b/vendor/github.com/elastic/beats/libbeat/publisher/queue/memqueue/broker.go index 4f02e38ae9..d3103f060f 100644 --- a/vendor/github.com/elastic/beats/libbeat/publisher/queue/memqueue/broker.go +++ b/vendor/github.com/elastic/beats/libbeat/publisher/queue/memqueue/broker.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package memqueue import ( @@ -5,10 +22,14 @@ import ( "time" "github.com/elastic/beats/libbeat/common" + "github.com/elastic/beats/libbeat/feature" "github.com/elastic/beats/libbeat/logp" "github.com/elastic/beats/libbeat/publisher/queue" ) +// Feature exposes a memory queue. +var Feature = queue.Feature("mem", create, feature.Stable) + type Broker struct { done chan struct{} diff --git a/vendor/github.com/elastic/beats/libbeat/publisher/queue/memqueue/buf.go b/vendor/github.com/elastic/beats/libbeat/publisher/queue/memqueue/buf.go index b180473ad0..bca06d9bd0 100644 --- a/vendor/github.com/elastic/beats/libbeat/publisher/queue/memqueue/buf.go +++ b/vendor/github.com/elastic/beats/libbeat/publisher/queue/memqueue/buf.go @@ -1 +1,18 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package memqueue diff --git a/vendor/github.com/elastic/beats/libbeat/publisher/queue/memqueue/config.go b/vendor/github.com/elastic/beats/libbeat/publisher/queue/memqueue/config.go index 54da7aeb8f..a86db9c159 100644 --- a/vendor/github.com/elastic/beats/libbeat/publisher/queue/memqueue/config.go +++ b/vendor/github.com/elastic/beats/libbeat/publisher/queue/memqueue/config.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package memqueue import ( diff --git a/vendor/github.com/elastic/beats/libbeat/publisher/queue/memqueue/consume.go b/vendor/github.com/elastic/beats/libbeat/publisher/queue/memqueue/consume.go index 3f1f75c89c..013642eadc 100644 --- a/vendor/github.com/elastic/beats/libbeat/publisher/queue/memqueue/consume.go +++ b/vendor/github.com/elastic/beats/libbeat/publisher/queue/memqueue/consume.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package memqueue import ( diff --git a/vendor/github.com/elastic/beats/libbeat/publisher/queue/memqueue/doc.go b/vendor/github.com/elastic/beats/libbeat/publisher/queue/memqueue/doc.go index 159c2ba7fe..333fe04b9d 100644 --- a/vendor/github.com/elastic/beats/libbeat/publisher/queue/memqueue/doc.go +++ b/vendor/github.com/elastic/beats/libbeat/publisher/queue/memqueue/doc.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + // Package memqueue provides an in-memory queue.Queue implementation for // use with the publisher pipeline. // The queue implementation is registered as queue type "mem". diff --git a/vendor/github.com/elastic/beats/libbeat/publisher/queue/memqueue/eventloop.go b/vendor/github.com/elastic/beats/libbeat/publisher/queue/memqueue/eventloop.go index e3f6a5291d..9c01bd3d60 100644 --- a/vendor/github.com/elastic/beats/libbeat/publisher/queue/memqueue/eventloop.go +++ b/vendor/github.com/elastic/beats/libbeat/publisher/queue/memqueue/eventloop.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package memqueue import ( diff --git a/vendor/github.com/elastic/beats/libbeat/publisher/queue/memqueue/internal_api.go b/vendor/github.com/elastic/beats/libbeat/publisher/queue/memqueue/internal_api.go index 13d7bbd61d..c73260c215 100644 --- a/vendor/github.com/elastic/beats/libbeat/publisher/queue/memqueue/internal_api.go +++ b/vendor/github.com/elastic/beats/libbeat/publisher/queue/memqueue/internal_api.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package memqueue import "github.com/elastic/beats/libbeat/publisher" diff --git a/vendor/github.com/elastic/beats/libbeat/publisher/queue/memqueue/log.go b/vendor/github.com/elastic/beats/libbeat/publisher/queue/memqueue/log.go index 8d17b56d00..b85c2a0ff4 100644 --- a/vendor/github.com/elastic/beats/libbeat/publisher/queue/memqueue/log.go +++ b/vendor/github.com/elastic/beats/libbeat/publisher/queue/memqueue/log.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package memqueue type logger interface { diff --git a/vendor/github.com/elastic/beats/libbeat/publisher/queue/memqueue/produce.go b/vendor/github.com/elastic/beats/libbeat/publisher/queue/memqueue/produce.go index a10a2e7e8b..ee841ec1a2 100644 --- a/vendor/github.com/elastic/beats/libbeat/publisher/queue/memqueue/produce.go +++ b/vendor/github.com/elastic/beats/libbeat/publisher/queue/memqueue/produce.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package memqueue import ( diff --git a/vendor/github.com/elastic/beats/libbeat/publisher/queue/memqueue/ringbuf.go b/vendor/github.com/elastic/beats/libbeat/publisher/queue/memqueue/ringbuf.go index 5f8b99037d..24af319c28 100644 --- a/vendor/github.com/elastic/beats/libbeat/publisher/queue/memqueue/ringbuf.go +++ b/vendor/github.com/elastic/beats/libbeat/publisher/queue/memqueue/ringbuf.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package memqueue import ( diff --git a/vendor/github.com/elastic/beats/libbeat/publisher/queue/queue.go b/vendor/github.com/elastic/beats/libbeat/publisher/queue/queue.go index a7da768ff3..201af049b9 100644 --- a/vendor/github.com/elastic/beats/libbeat/publisher/queue/queue.go +++ b/vendor/github.com/elastic/beats/libbeat/publisher/queue/queue.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package queue import ( diff --git a/vendor/github.com/elastic/beats/libbeat/publisher/queue/queue_reg.go b/vendor/github.com/elastic/beats/libbeat/publisher/queue/queue_reg.go index b445c6424b..38bf36a29c 100644 --- a/vendor/github.com/elastic/beats/libbeat/publisher/queue/queue_reg.go +++ b/vendor/github.com/elastic/beats/libbeat/publisher/queue/queue_reg.go @@ -1,26 +1,54 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package queue import ( "fmt" "github.com/elastic/beats/libbeat/common" + "github.com/elastic/beats/libbeat/feature" ) +// Namespace is the feature namespace for queue definition. +var Namespace = "libbeat.queue" + // Global queue type registry for configuring and loading a queue instance // via common.Config var queueReg = map[string]Factory{} // RegisterType registers a new queue type. -func RegisterType(name string, f Factory) { - if queueReg[name] != nil { - panic(fmt.Errorf("queue type '%v' exists already", name)) - } - queueReg[name] = f +func RegisterType(name string, fn Factory) { + f := feature.New(Namespace, name, fn, feature.Undefined) + feature.MustRegister(f) } // FindFactory retrieves a queue types constructor. Returns nil if queue type is unknown func FindFactory(name string) Factory { - return queueReg[name] + f, err := feature.Registry.Lookup(Namespace, name) + if err != nil { + return nil + } + factory, ok := f.Factory().(Factory) + if !ok { + return nil + } + + return factory } // Load instantiates a new queue. @@ -36,3 +64,8 @@ func Load(eventer Eventer, config common.ConfigNamespace) (Queue, error) { } return factory(eventer, cfg) } + +// Feature creates a new type of queue. +func Feature(name string, factory Factory, stability feature.Stability) *feature.Feature { + return feature.New(Namespace, name, factory, stability) +} diff --git a/vendor/github.com/elastic/beats/libbeat/publisher/queue/spool/codec.go b/vendor/github.com/elastic/beats/libbeat/publisher/queue/spool/codec.go index 051ae656ca..db0a354298 100644 --- a/vendor/github.com/elastic/beats/libbeat/publisher/queue/spool/codec.go +++ b/vendor/github.com/elastic/beats/libbeat/publisher/queue/spool/codec.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package spool import ( diff --git a/vendor/github.com/elastic/beats/libbeat/publisher/queue/spool/config.go b/vendor/github.com/elastic/beats/libbeat/publisher/queue/spool/config.go index 48d569578d..acff07f77d 100644 --- a/vendor/github.com/elastic/beats/libbeat/publisher/queue/spool/config.go +++ b/vendor/github.com/elastic/beats/libbeat/publisher/queue/spool/config.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package spool import ( diff --git a/vendor/github.com/elastic/beats/libbeat/publisher/queue/spool/consume.go b/vendor/github.com/elastic/beats/libbeat/publisher/queue/spool/consume.go index 5e543fc2f7..a8f55775cb 100644 --- a/vendor/github.com/elastic/beats/libbeat/publisher/queue/spool/consume.go +++ b/vendor/github.com/elastic/beats/libbeat/publisher/queue/spool/consume.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package spool import ( diff --git a/vendor/github.com/elastic/beats/libbeat/publisher/queue/spool/inbroker.go b/vendor/github.com/elastic/beats/libbeat/publisher/queue/spool/inbroker.go index a3fcc8d3b7..a7472ab38a 100644 --- a/vendor/github.com/elastic/beats/libbeat/publisher/queue/spool/inbroker.go +++ b/vendor/github.com/elastic/beats/libbeat/publisher/queue/spool/inbroker.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package spool import ( diff --git a/vendor/github.com/elastic/beats/libbeat/publisher/queue/spool/internal_api.go b/vendor/github.com/elastic/beats/libbeat/publisher/queue/spool/internal_api.go index 28a1a99a58..e4a38b317d 100644 --- a/vendor/github.com/elastic/beats/libbeat/publisher/queue/spool/internal_api.go +++ b/vendor/github.com/elastic/beats/libbeat/publisher/queue/spool/internal_api.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package spool import ( diff --git a/vendor/github.com/elastic/beats/libbeat/publisher/queue/spool/log.go b/vendor/github.com/elastic/beats/libbeat/publisher/queue/spool/log.go index 5dd1704806..f85bc035ec 100644 --- a/vendor/github.com/elastic/beats/libbeat/publisher/queue/spool/log.go +++ b/vendor/github.com/elastic/beats/libbeat/publisher/queue/spool/log.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package spool import ( diff --git a/vendor/github.com/elastic/beats/libbeat/publisher/queue/spool/module.go b/vendor/github.com/elastic/beats/libbeat/publisher/queue/spool/module.go index 78930f8b1c..912417c0dc 100644 --- a/vendor/github.com/elastic/beats/libbeat/publisher/queue/spool/module.go +++ b/vendor/github.com/elastic/beats/libbeat/publisher/queue/spool/module.go @@ -1,13 +1,34 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package spool import ( "github.com/elastic/beats/libbeat/common" "github.com/elastic/beats/libbeat/common/cfgwarn" + "github.com/elastic/beats/libbeat/feature" "github.com/elastic/beats/libbeat/paths" "github.com/elastic/beats/libbeat/publisher/queue" "github.com/elastic/go-txfile" ) +// Feature exposes a spooling to disk queue. +var Feature = queue.Feature("spool", create, feature.Beta) + func init() { queue.RegisterType("spool", create) } diff --git a/vendor/github.com/elastic/beats/libbeat/publisher/queue/spool/outbroker.go b/vendor/github.com/elastic/beats/libbeat/publisher/queue/spool/outbroker.go index cc4d74feaa..247a5d7325 100644 --- a/vendor/github.com/elastic/beats/libbeat/publisher/queue/spool/outbroker.go +++ b/vendor/github.com/elastic/beats/libbeat/publisher/queue/spool/outbroker.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package spool import ( diff --git a/vendor/github.com/elastic/beats/libbeat/publisher/queue/spool/produce.go b/vendor/github.com/elastic/beats/libbeat/publisher/queue/spool/produce.go index 839dac06d7..04cdbfdc2f 100644 --- a/vendor/github.com/elastic/beats/libbeat/publisher/queue/spool/produce.go +++ b/vendor/github.com/elastic/beats/libbeat/publisher/queue/spool/produce.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package spool import ( diff --git a/vendor/github.com/elastic/beats/libbeat/publisher/queue/spool/spool.go b/vendor/github.com/elastic/beats/libbeat/publisher/queue/spool/spool.go index 222b903414..643c9fd664 100644 --- a/vendor/github.com/elastic/beats/libbeat/publisher/queue/spool/spool.go +++ b/vendor/github.com/elastic/beats/libbeat/publisher/queue/spool/spool.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package spool import ( diff --git a/vendor/github.com/elastic/beats/libbeat/publisher/queue/spool/timer.go b/vendor/github.com/elastic/beats/libbeat/publisher/queue/spool/timer.go index 8c4650b596..9f08dcfc69 100644 --- a/vendor/github.com/elastic/beats/libbeat/publisher/queue/spool/timer.go +++ b/vendor/github.com/elastic/beats/libbeat/publisher/queue/spool/timer.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package spool import ( diff --git a/vendor/github.com/elastic/beats/libbeat/publisher/testing/testing.go b/vendor/github.com/elastic/beats/libbeat/publisher/testing/testing.go index 3eb7c1ce54..87a1ac2c0b 100644 --- a/vendor/github.com/elastic/beats/libbeat/publisher/testing/testing.go +++ b/vendor/github.com/elastic/beats/libbeat/publisher/testing/testing.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package testing // ChanClient implements Client interface, forwarding published events to some diff --git a/vendor/github.com/elastic/beats/libbeat/service/service.go b/vendor/github.com/elastic/beats/libbeat/service/service.go index b05d20c22a..f98eb831d0 100644 --- a/vendor/github.com/elastic/beats/libbeat/service/service.go +++ b/vendor/github.com/elastic/beats/libbeat/service/service.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package service import ( diff --git a/vendor/github.com/elastic/beats/libbeat/service/service_unix.go b/vendor/github.com/elastic/beats/libbeat/service/service_unix.go index 5e80ca461f..7c6bfb4d08 100644 --- a/vendor/github.com/elastic/beats/libbeat/service/service_unix.go +++ b/vendor/github.com/elastic/beats/libbeat/service/service_unix.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + // +build !windows package service diff --git a/vendor/github.com/elastic/beats/libbeat/service/service_windows.go b/vendor/github.com/elastic/beats/libbeat/service/service_windows.go index a358c1c988..db5b09e8dc 100644 --- a/vendor/github.com/elastic/beats/libbeat/service/service_windows.go +++ b/vendor/github.com/elastic/beats/libbeat/service/service_windows.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package service import ( diff --git a/vendor/github.com/elastic/beats/libbeat/template/config.go b/vendor/github.com/elastic/beats/libbeat/template/config.go index ab5834121d..77e93d7201 100644 --- a/vendor/github.com/elastic/beats/libbeat/template/config.go +++ b/vendor/github.com/elastic/beats/libbeat/template/config.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package template import "github.com/elastic/beats/libbeat/common" diff --git a/vendor/github.com/elastic/beats/libbeat/template/load.go b/vendor/github.com/elastic/beats/libbeat/template/load.go index baa91bdcaf..f063def8f1 100644 --- a/vendor/github.com/elastic/beats/libbeat/template/load.go +++ b/vendor/github.com/elastic/beats/libbeat/template/load.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package template import ( diff --git a/vendor/github.com/elastic/beats/libbeat/template/processor.go b/vendor/github.com/elastic/beats/libbeat/template/processor.go index 2b71d43b42..d87c2348d6 100644 --- a/vendor/github.com/elastic/beats/libbeat/template/processor.go +++ b/vendor/github.com/elastic/beats/libbeat/template/processor.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package template import ( diff --git a/vendor/github.com/elastic/beats/libbeat/template/template.go b/vendor/github.com/elastic/beats/libbeat/template/template.go index e329b79900..49e274f372 100644 --- a/vendor/github.com/elastic/beats/libbeat/template/template.go +++ b/vendor/github.com/elastic/beats/libbeat/template/template.go @@ -1,7 +1,25 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package template import ( "fmt" + "sync" "time" "github.com/elastic/beats/libbeat/beat" @@ -24,6 +42,7 @@ var ( ) type Template struct { + sync.Mutex name string pattern string beatVersion common.Version @@ -97,6 +116,13 @@ func New(beatVersion string, beatName string, esVersion string, config TemplateC func (t *Template) load(fields common.Fields) (common.MapStr, error) { + // Locking to make sure dynamicTemplates and defaultFields is not accessed in parallel + t.Lock() + defer t.Unlock() + + dynamicTemplates = nil + defaultFields = nil + var err error if len(t.config.AppendFields) > 0 { cfgwarn.Experimental("append_fields is used.") diff --git a/vendor/github.com/elastic/beats/libbeat/testing/console.go b/vendor/github.com/elastic/beats/libbeat/testing/console.go index bf3558f13d..dafc5008e9 100644 --- a/vendor/github.com/elastic/beats/libbeat/testing/console.go +++ b/vendor/github.com/elastic/beats/libbeat/testing/console.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package testing import ( diff --git a/vendor/github.com/elastic/beats/libbeat/testing/null.go b/vendor/github.com/elastic/beats/libbeat/testing/null.go index c20945bbfd..8335b65ba1 100644 --- a/vendor/github.com/elastic/beats/libbeat/testing/null.go +++ b/vendor/github.com/elastic/beats/libbeat/testing/null.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package testing type nullDriver struct{} diff --git a/vendor/github.com/elastic/beats/libbeat/testing/testing.go b/vendor/github.com/elastic/beats/libbeat/testing/testing.go index 7300c3eb3a..559bba777c 100644 --- a/vendor/github.com/elastic/beats/libbeat/testing/testing.go +++ b/vendor/github.com/elastic/beats/libbeat/testing/testing.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package testing // Driver for testing, manages test flow and controls output diff --git a/vendor/github.com/elastic/beats/libbeat/version/helper.go b/vendor/github.com/elastic/beats/libbeat/version/helper.go index b34ed5a2ea..13e4be0c50 100644 --- a/vendor/github.com/elastic/beats/libbeat/version/helper.go +++ b/vendor/github.com/elastic/beats/libbeat/version/helper.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package version import "time" diff --git a/vendor/github.com/elastic/beats/libbeat/version/version.go b/vendor/github.com/elastic/beats/libbeat/version/version.go index 80ac328aad..63e1c2020b 100644 --- a/vendor/github.com/elastic/beats/libbeat/version/version.go +++ b/vendor/github.com/elastic/beats/libbeat/version/version.go @@ -1,3 +1,20 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + // Code generated by dev-tools/set_version package version diff --git a/vendor/github.com/magefile/mage/CONTRIBUTING.md b/vendor/github.com/magefile/mage/CONTRIBUTING.md new file mode 100644 index 0000000000..e1394d2045 --- /dev/null +++ b/vendor/github.com/magefile/mage/CONTRIBUTING.md @@ -0,0 +1,42 @@ +# Contributing + +Of course, contributions are more than welcome. Please read these guidelines for +making the process as painless as possible. + +## Discussion + +Development discussion should take place on the #mage channel of [gopher +slack](https://gophers.slack.com/). + +There is a separate #mage-dev channel that has the github app to post github +activity to the channel, to make it easy to follow. + +## Issues + +If there's an issue you'd like to work on, please comment on it, so we can +discuss approach, etc. and make sure no one else is currently working on that +issue. + +Please always create an issue before sending a PR unless it's an obvious typo +or other trivial change. + +## Dependency Management + +Currently mage has no dependencies(!) outside the standard libary. Let's keep +it that way. Since it's likely that mage will be vendored into a project, +adding dependencies to mage adds dependencies to every project that uses mage. + +## Versions + +Please avoid using features of go and the stdlib that prevent mage from being +buildable with older versions of Go. The CI tests currently check that mage is +buildable with go 1.7 and later. You may build with whatever version you like, +but CI has the final say. + +## Testing + +Please write tests for any new features. Tests must use the normal go testing +package. + +Tests must pass the race detector (run `go test -race ./...`). + diff --git a/vendor/github.com/magefile/mage/Gopkg.lock b/vendor/github.com/magefile/mage/Gopkg.lock new file mode 100644 index 0000000000..bef2d0092e --- /dev/null +++ b/vendor/github.com/magefile/mage/Gopkg.lock @@ -0,0 +1,9 @@ +# This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'. + + +[solve-meta] + analyzer-name = "dep" + analyzer-version = 1 + inputs-digest = "ab4fef131ee828e96ba67d31a7d690bd5f2f42040c6766b1b12fe856f87e0ff7" + solver-name = "gps-cdcl" + solver-version = 1 diff --git a/vendor/github.com/magefile/mage/Gopkg.toml b/vendor/github.com/magefile/mage/Gopkg.toml new file mode 100644 index 0000000000..9425a54296 --- /dev/null +++ b/vendor/github.com/magefile/mage/Gopkg.toml @@ -0,0 +1,22 @@ + +# Gopkg.toml example +# +# Refer to https://github.com/golang/dep/blob/master/docs/Gopkg.toml.md +# for detailed Gopkg.toml documentation. +# +# required = ["github.com/user/thing/cmd/thing"] +# ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"] +# +# [[constraint]] +# name = "github.com/user/project" +# version = "1.0.0" +# +# [[constraint]] +# name = "github.com/user/project2" +# branch = "dev" +# source = "github.com/myfork/project2" +# +# [[override]] +# name = "github.com/x/y" +# version = "2.4.0" + diff --git a/_beats/dev-tools/vendor/gopkg.in/yaml.v2/LICENSE b/vendor/github.com/magefile/mage/LICENSE similarity index 100% rename from _beats/dev-tools/vendor/gopkg.in/yaml.v2/LICENSE rename to vendor/github.com/magefile/mage/LICENSE diff --git a/vendor/github.com/magefile/mage/README.md b/vendor/github.com/magefile/mage/README.md new file mode 100644 index 0000000000..63826bb710 --- /dev/null +++ b/vendor/github.com/magefile/mage/README.md @@ -0,0 +1,61 @@ +

+ +## About [![Build Status](https://travis-ci.org/magefile/mage.svg?branch=master)](https://travis-ci.org/magefile/mage) + +Mage is a make/rake-like build tool using Go. You write plain-old go functions, +and Mage automatically uses them as Makefile-like runnable targets. + +## Installation + +Mage has no dependencies outside the Go standard library, and builds with Go 1.7 +and above (possibly even lower versions, but they're not regularly tested). + +Install mage by running + +``` +go get -u -d github.com/magefile/mage +cd $GOPATH/src/github.com/magefile/mage +go run bootstrap.go +``` + +This will download the code into your GOPATH, and then run the bootstrap script +to build mage with version infomation embedded in it. A normal `go get` +(without -d) will build the binary correctly, but no version info will be +embedded. If you've done this, no worries, just go to +$GOPATH/src/github.com/magefile/mage and run `mage install` or `go run +bootstrap.go` and a new binary will be created with the correct version +information. + +The mage binary will be created in your $GOPATH/bin directory. + +You may also install a binary release from our +[releases](https://github.com/magefile/mage/releases) page. + +## Demo + +[![Mage Demo](https://img.youtube.com/vi/GOqbD0lF-iA/maxresdefault.jpg)](https://www.youtube.com/watch?v=GOqbD0lF-iA) + +## Discussion + +Join the `#mage` channel on [gophers slack](https://gophers.slack.com/messages/general/) for discussion of usage, development, etc. + +# Documentation + +see [magefile.org](https://magefile.org) for full docs + +see [godoc.org/github.com/magefile/mage/mage](https://godoc.org/github.com/magefile/mage/mage) for how to use mage as a library. + +# Why? + +Makefiles are hard to read and hard to write. Mostly because makefiles are essentially fancy bash scripts with significant white space and additional make-related syntax. + +Mage lets you have multiple magefiles, name your magefiles whatever you +want, and they're easy to customize for multiple operating systems. Mage has no +dependencies (aside from go) and runs just fine on all major operating systems, whereas make generally uses bash which is not well supported on Windows. +Go is superior to bash for any non-trivial task involving branching, looping, anything that's not just straight line execution of commands. And if your project is written in Go, why introduce another +language as idiosyncratic as bash? Why not use the language your contributors +are already comfortable with? + +# TODO + +* File conversion tasks diff --git a/vendor/github.com/magefile/mage/bootstrap.go b/vendor/github.com/magefile/mage/bootstrap.go new file mode 100644 index 0000000000..c37f6fc8a5 --- /dev/null +++ b/vendor/github.com/magefile/mage/bootstrap.go @@ -0,0 +1,19 @@ +//+build ignore + +package main + +import ( + "os" + + "github.com/magefile/mage/mage" +) + +// This is a bootstrap builder, to build mage when you don't already *have* mage. +// Run it like +// go run bootstrap.go +// and it will install mage with all the right flags created for you. + +func main() { + os.Args = []string{os.Args[0], "-v", "install"} + os.Exit(mage.Main()) +} diff --git a/vendor/github.com/magefile/mage/build/build.go b/vendor/github.com/magefile/mage/build/build.go new file mode 100644 index 0000000000..64198e6711 --- /dev/null +++ b/vendor/github.com/magefile/mage/build/build.go @@ -0,0 +1,1655 @@ +// 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. + +package build + +import ( + "bytes" + "errors" + "fmt" + "go/ast" + "go/doc" + "go/parser" + "go/token" + "io" + "io/ioutil" + "log" + "os" + pathpkg "path" + "path/filepath" + "runtime" + "sort" + "strconv" + "strings" + "unicode" + "unicode/utf8" +) + +// A Context specifies the supporting context for a build. +type Context struct { + GOARCH string // target architecture + GOOS string // target operating system + GOROOT string // Go root + GOPATH string // Go path + CgoEnabled bool // whether cgo can be used + UseAllFiles bool // use files regardless of +build lines, file names + Compiler string // compiler to assume when computing target paths + + // RequiredTags lists tags that the must exist in a build tag in order for + // the file to be included in the build. If RequiredTags is empty, no tags + // are required. Note that this is mostly useful in filtering the list of + // files in a single directory. Using required tags across an entire + // compile step will likely exclude much, if not all of the standard library + // files. + RequiredTags []string + + // The build and release tags specify build constraints + // that should be considered satisfied when processing +build lines. + // Clients creating a new context may customize BuildTags, which + // defaults to empty, but it is usually an error to customize ReleaseTags, + // which defaults to the list of Go releases the current release is compatible with. + // In addition to the BuildTags and ReleaseTags, build constraints + // consider the values of GOARCH and GOOS as satisfied tags. + BuildTags []string + ReleaseTags []string + + // The install suffix specifies a suffix to use in the name of the installation + // directory. By default it is empty, but custom builds that need to keep + // their outputs separate can set InstallSuffix to do so. For example, when + // using the race detector, the go command uses InstallSuffix = "race", so + // that on a Linux/386 system, packages are written to a directory named + // "linux_386_race" instead of the usual "linux_386". + InstallSuffix string + + // By default, Import uses the operating system's file system calls + // to read directories and files. To read from other sources, + // callers can set the following functions. They all have default + // behaviors that use the local file system, so clients need only set + // the functions whose behaviors they wish to change. + + // JoinPath joins the sequence of path fragments into a single path. + // If JoinPath is nil, Import uses filepath.Join. + JoinPath func(elem ...string) string + + // SplitPathList splits the path list into a slice of individual paths. + // If SplitPathList is nil, Import uses filepath.SplitList. + SplitPathList func(list string) []string + + // IsAbsPath reports whether path is an absolute path. + // If IsAbsPath is nil, Import uses filepath.IsAbs. + IsAbsPath func(path string) bool + + // IsDir reports whether the path names a directory. + // If IsDir is nil, Import calls os.Stat and uses the result's IsDir method. + IsDir func(path string) bool + + // HasSubdir reports whether dir is lexically a subdirectory of + // root, perhaps multiple levels below. It does not try to check + // whether dir exists. + // If so, HasSubdir sets rel to a slash-separated path that + // can be joined to root to produce a path equivalent to dir. + // If HasSubdir is nil, Import uses an implementation built on + // filepath.EvalSymlinks. + HasSubdir func(root, dir string) (rel string, ok bool) + + // ReadDir returns a slice of os.FileInfo, sorted by Name, + // describing the content of the named directory. + // If ReadDir is nil, Import uses ioutil.ReadDir. + ReadDir func(dir string) ([]os.FileInfo, error) + + // OpenFile opens a file (not a directory) for reading. + // If OpenFile is nil, Import uses os.Open. + OpenFile func(path string) (io.ReadCloser, error) +} + +// joinPath calls ctxt.JoinPath (if not nil) or else filepath.Join. +func (ctxt *Context) joinPath(elem ...string) string { + if f := ctxt.JoinPath; f != nil { + return f(elem...) + } + return filepath.Join(elem...) +} + +// splitPathList calls ctxt.SplitPathList (if not nil) or else filepath.SplitList. +func (ctxt *Context) splitPathList(s string) []string { + if f := ctxt.SplitPathList; f != nil { + return f(s) + } + return filepath.SplitList(s) +} + +// isAbsPath calls ctxt.IsAbsPath (if not nil) or else filepath.IsAbs. +func (ctxt *Context) isAbsPath(path string) bool { + if f := ctxt.IsAbsPath; f != nil { + return f(path) + } + return filepath.IsAbs(path) +} + +// isDir calls ctxt.IsDir (if not nil) or else uses os.Stat. +func (ctxt *Context) isDir(path string) bool { + if f := ctxt.IsDir; f != nil { + return f(path) + } + fi, err := os.Stat(path) + return err == nil && fi.IsDir() +} + +// hasSubdir calls ctxt.HasSubdir (if not nil) or else uses +// the local file system to answer the question. +func (ctxt *Context) hasSubdir(root, dir string) (rel string, ok bool) { + if f := ctxt.HasSubdir; f != nil { + return f(root, dir) + } + + // Try using paths we received. + if rel, ok = hasSubdir(root, dir); ok { + return rel, ok + } + + // Try expanding symlinks and comparing + // expanded against unexpanded and + // expanded against expanded. + rootSym, _ := filepath.EvalSymlinks(root) + dirSym, _ := filepath.EvalSymlinks(dir) + + if rel, ok = hasSubdir(rootSym, dir); ok { + return rel, ok + } + if rel, ok = hasSubdir(root, dirSym); ok { + return rel, ok + } + return hasSubdir(rootSym, dirSym) +} + +// hasSubdir reports if dir is within root by performing lexical analysis only. +func hasSubdir(root, dir string) (rel string, ok bool) { + const sep = string(filepath.Separator) + root = filepath.Clean(root) + if !strings.HasSuffix(root, sep) { + root += sep + } + dir = filepath.Clean(dir) + if !strings.HasPrefix(dir, root) { + return "", false + } + return filepath.ToSlash(dir[len(root):]), true +} + +// readDir calls ctxt.ReadDir (if not nil) or else ioutil.ReadDir. +func (ctxt *Context) readDir(path string) ([]os.FileInfo, error) { + if f := ctxt.ReadDir; f != nil { + return f(path) + } + return ioutil.ReadDir(path) +} + +// openFile calls ctxt.OpenFile (if not nil) or else os.Open. +func (ctxt *Context) openFile(path string) (io.ReadCloser, error) { + if fn := ctxt.OpenFile; fn != nil { + return fn(path) + } + + f, err := os.Open(path) + if err != nil { + return nil, err // nil interface + } + return f, nil +} + +// isFile determines whether path is a file by trying to open it. +// It reuses openFile instead of adding another function to the +// list in Context. +func (ctxt *Context) isFile(path string) bool { + f, err := ctxt.openFile(path) + if err != nil { + return false + } + f.Close() + return true +} + +// gopath returns the list of Go path directories. +func (ctxt *Context) gopath() []string { + var all []string + for _, p := range ctxt.splitPathList(ctxt.GOPATH) { + if p == "" || p == ctxt.GOROOT { + // Empty paths are uninteresting. + // If the path is the GOROOT, ignore it. + // People sometimes set GOPATH=$GOROOT. + // Do not get confused by this common mistake. + continue + } + if strings.HasPrefix(p, "~") { + // Path segments starting with ~ on Unix are almost always + // users who have incorrectly quoted ~ while setting GOPATH, + // preventing it from expanding to $HOME. + // The situation is made more confusing by the fact that + // bash allows quoted ~ in $PATH (most shells do not). + // Do not get confused by this, and do not try to use the path. + // It does not exist, and printing errors about it confuses + // those users even more, because they think "sure ~ exists!". + // The go command diagnoses this situation and prints a + // useful error. + // On Windows, ~ is used in short names, such as c:\progra~1 + // for c:\program files. + continue + } + all = append(all, p) + } + return all +} + +// SrcDirs returns a list of package source root directories. +// It draws from the current Go root and Go path but omits directories +// that do not exist. +func (ctxt *Context) SrcDirs() []string { + var all []string + if ctxt.GOROOT != "" { + dir := ctxt.joinPath(ctxt.GOROOT, "src") + if ctxt.isDir(dir) { + all = append(all, dir) + } + } + for _, p := range ctxt.gopath() { + dir := ctxt.joinPath(p, "src") + if ctxt.isDir(dir) { + all = append(all, dir) + } + } + return all +} + +// Default is the default Context for builds. +// It uses the GOARCH, GOOS, GOROOT, and GOPATH environment variables +// if set, or else the compiled code's GOARCH, GOOS, and GOROOT. +var Default Context = defaultContext() + +func defaultGOPATH() string { + env := "HOME" + if runtime.GOOS == "windows" { + env = "USERPROFILE" + } else if runtime.GOOS == "plan9" { + env = "home" + } + if home := os.Getenv(env); home != "" { + def := filepath.Join(home, "go") + if filepath.Clean(def) == filepath.Clean(runtime.GOROOT()) { + // Don't set the default GOPATH to GOROOT, + // as that will trigger warnings from the go tool. + return "" + } + return def + } + return "" +} + +func defaultContext() Context { + var c Context + + c.GOARCH = envOr("GOARCH", runtime.GOARCH) + c.GOOS = envOr("GOOS", runtime.GOOS) + c.GOROOT = pathpkg.Clean(runtime.GOROOT()) + c.GOPATH = envOr("GOPATH", defaultGOPATH()) + c.Compiler = runtime.Compiler + + // Each major Go release in the Go 1.x series should add a tag here. + // Old tags should not be removed. That is, the go1.x tag is present + // in all releases >= Go 1.x. Code that requires Go 1.x or later should + // say "+build go1.x", and code that should only be built before Go 1.x + // (perhaps it is the stub to use in that case) should say "+build !go1.x". + // NOTE: If you add to this list, also update the doc comment in doc.go. + c.ReleaseTags = []string{"go1.1", "go1.2", "go1.3", "go1.4", "go1.5", "go1.6", "go1.7", "go1.8", "go1.9"} + + env := os.Getenv("CGO_ENABLED") + if env == "" { + env = defaultCGO_ENABLED + } + switch env { + case "1": + c.CgoEnabled = true + case "0": + c.CgoEnabled = false + default: + // cgo must be explicitly enabled for cross compilation builds + if runtime.GOARCH == c.GOARCH && runtime.GOOS == c.GOOS { + c.CgoEnabled = cgoEnabled[c.GOOS+"/"+c.GOARCH] + break + } + c.CgoEnabled = false + } + + return c +} + +func envOr(name, def string) string { + s := os.Getenv(name) + if s == "" { + return def + } + return s +} + +// An ImportMode controls the behavior of the Import method. +type ImportMode uint + +const ( + // If FindOnly is set, Import stops after locating the directory + // that should contain the sources for a package. It does not + // read any files in the directory. + FindOnly ImportMode = 1 << iota + + // If AllowBinary is set, Import can be satisfied by a compiled + // package object without corresponding sources. + // + // Deprecated: + // The supported way to create a compiled-only package is to + // write source code containing a //go:binary-only-package comment at + // the top of the file. Such a package will be recognized + // regardless of this flag setting (because it has source code) + // and will have BinaryOnly set to true in the returned Package. + AllowBinary + + // If ImportComment is set, parse import comments on package statements. + // Import returns an error if it finds a comment it cannot understand + // or finds conflicting comments in multiple source files. + // See golang.org/s/go14customimport for more information. + ImportComment + + // By default, Import searches vendor directories + // that apply in the given source directory before searching + // the GOROOT and GOPATH roots. + // If an Import finds and returns a package using a vendor + // directory, the resulting ImportPath is the complete path + // to the package, including the path elements leading up + // to and including "vendor". + // For example, if Import("y", "x/subdir", 0) finds + // "x/vendor/y", the returned package's ImportPath is "x/vendor/y", + // not plain "y". + // See golang.org/s/go15vendor for more information. + // + // Setting IgnoreVendor ignores vendor directories. + // + // In contrast to the package's ImportPath, + // the returned package's Imports, TestImports, and XTestImports + // are always the exact import paths from the source files: + // Import makes no attempt to resolve or check those paths. + IgnoreVendor +) + +// A Package describes the Go package found in a directory. +type Package struct { + Dir string // directory containing package sources + Name string // package name + ImportComment string // path in import comment on package statement + Doc string // documentation synopsis + ImportPath string // import path of package ("" if unknown) + Root string // root of Go tree where this package lives + SrcRoot string // package source root directory ("" if unknown) + PkgRoot string // package install root directory ("" if unknown) + PkgTargetRoot string // architecture dependent install root directory ("" if unknown) + BinDir string // command install directory ("" if unknown) + Goroot bool // package found in Go root + PkgObj string // installed .a file + AllTags []string // tags that can influence file selection in this directory + ConflictDir string // this directory shadows Dir in $GOPATH + BinaryOnly bool // cannot be rebuilt from source (has //go:binary-only-package comment) + + // Source files + GoFiles []string // .go source files (excluding CgoFiles, TestGoFiles, XTestGoFiles) + CgoFiles []string // .go source files that import "C" + IgnoredGoFiles []string // .go source files ignored for this build + InvalidGoFiles []string // .go source files with detected problems (parse error, wrong package name, and so on) + CFiles []string // .c source files + CXXFiles []string // .cc, .cpp and .cxx source files + MFiles []string // .m (Objective-C) source files + HFiles []string // .h, .hh, .hpp and .hxx source files + FFiles []string // .f, .F, .for and .f90 Fortran source files + SFiles []string // .s source files + SwigFiles []string // .swig files + SwigCXXFiles []string // .swigcxx files + SysoFiles []string // .syso system object files to add to archive + + // Cgo directives + CgoCFLAGS []string // Cgo CFLAGS directives + CgoCPPFLAGS []string // Cgo CPPFLAGS directives + CgoCXXFLAGS []string // Cgo CXXFLAGS directives + CgoFFLAGS []string // Cgo FFLAGS directives + CgoLDFLAGS []string // Cgo LDFLAGS directives + CgoPkgConfig []string // Cgo pkg-config directives + + // Dependency information + Imports []string // import paths from GoFiles, CgoFiles + ImportPos map[string][]token.Position // line information for Imports + + // Test information + TestGoFiles []string // _test.go files in package + TestImports []string // import paths from TestGoFiles + TestImportPos map[string][]token.Position // line information for TestImports + XTestGoFiles []string // _test.go files outside package + XTestImports []string // import paths from XTestGoFiles + XTestImportPos map[string][]token.Position // line information for XTestImports +} + +// IsCommand reports whether the package is considered a +// command to be installed (not just a library). +// Packages named "main" are treated as commands. +func (p *Package) IsCommand() bool { + return p.Name == "main" +} + +// ImportDir is like Import but processes the Go package found in +// the named directory. +func (ctxt *Context) ImportDir(dir string, mode ImportMode) (*Package, error) { + return ctxt.Import(".", dir, mode) +} + +// NoGoError is the error used by Import to describe a directory +// containing no buildable Go source files. (It may still contain +// test files, files hidden by build tags, and so on.) +type NoGoError struct { + Dir string +} + +func (e *NoGoError) Error() string { + return "no buildable Go source files in " + e.Dir +} + +// MultiplePackageError describes a directory containing +// multiple buildable Go source files for multiple packages. +type MultiplePackageError struct { + Dir string // directory containing files + Packages []string // package names found + Files []string // corresponding files: Files[i] declares package Packages[i] +} + +func (e *MultiplePackageError) Error() string { + // Error string limited to two entries for compatibility. + return fmt.Sprintf("found packages %s (%s) and %s (%s) in %s", e.Packages[0], e.Files[0], e.Packages[1], e.Files[1], e.Dir) +} + +func nameExt(name string) string { + i := strings.LastIndex(name, ".") + if i < 0 { + return "" + } + return name[i:] +} + +// Import returns details about the Go package named by the import path, +// interpreting local import paths relative to the srcDir directory. +// If the path is a local import path naming a package that can be imported +// using a standard import path, the returned package will set p.ImportPath +// to that path. +// +// In the directory containing the package, .go, .c, .h, and .s files are +// considered part of the package except for: +// +// - .go files in package documentation +// - files starting with _ or . (likely editor temporary files) +// - files with build constraints not satisfied by the context +// +// If an error occurs, Import returns a non-nil error and a non-nil +// *Package containing partial information. +// +func (ctxt *Context) Import(path string, srcDir string, mode ImportMode) (*Package, error) { + p := &Package{ + ImportPath: path, + } + if path == "" { + return p, fmt.Errorf("import %q: invalid import path", path) + } + + var pkgtargetroot string + var pkga string + var pkgerr error + suffix := "" + if ctxt.InstallSuffix != "" { + suffix = "_" + ctxt.InstallSuffix + } + switch ctxt.Compiler { + case "gccgo": + pkgtargetroot = "pkg/gccgo_" + ctxt.GOOS + "_" + ctxt.GOARCH + suffix + case "gc": + pkgtargetroot = "pkg/" + ctxt.GOOS + "_" + ctxt.GOARCH + suffix + default: + // Save error for end of function. + pkgerr = fmt.Errorf("import %q: unknown compiler %q", path, ctxt.Compiler) + } + setPkga := func() { + switch ctxt.Compiler { + case "gccgo": + dir, elem := pathpkg.Split(p.ImportPath) + pkga = pkgtargetroot + "/" + dir + "lib" + elem + ".a" + case "gc": + pkga = pkgtargetroot + "/" + p.ImportPath + ".a" + } + } + setPkga() + + binaryOnly := false + if IsLocalImport(path) { + pkga = "" // local imports have no installed path + if srcDir == "" { + return p, fmt.Errorf("import %q: import relative to unknown directory", path) + } + if !ctxt.isAbsPath(path) { + p.Dir = ctxt.joinPath(srcDir, path) + } + // p.Dir directory may or may not exist. Gather partial information first, check if it exists later. + // Determine canonical import path, if any. + // Exclude results where the import path would include /testdata/. + inTestdata := func(sub string) bool { + return strings.Contains(sub, "/testdata/") || strings.HasSuffix(sub, "/testdata") || strings.HasPrefix(sub, "testdata/") || sub == "testdata" + } + if ctxt.GOROOT != "" { + root := ctxt.joinPath(ctxt.GOROOT, "src") + if sub, ok := ctxt.hasSubdir(root, p.Dir); ok && !inTestdata(sub) { + p.Goroot = true + p.ImportPath = sub + p.Root = ctxt.GOROOT + goto Found + } + } + all := ctxt.gopath() + for i, root := range all { + rootsrc := ctxt.joinPath(root, "src") + if sub, ok := ctxt.hasSubdir(rootsrc, p.Dir); ok && !inTestdata(sub) { + // We found a potential import path for dir, + // but check that using it wouldn't find something + // else first. + if ctxt.GOROOT != "" { + if dir := ctxt.joinPath(ctxt.GOROOT, "src", sub); ctxt.isDir(dir) { + p.ConflictDir = dir + goto Found + } + } + for _, earlyRoot := range all[:i] { + if dir := ctxt.joinPath(earlyRoot, "src", sub); ctxt.isDir(dir) { + p.ConflictDir = dir + goto Found + } + } + + // sub would not name some other directory instead of this one. + // Record it. + p.ImportPath = sub + p.Root = root + goto Found + } + } + // It's okay that we didn't find a root containing dir. + // Keep going with the information we have. + } else { + if strings.HasPrefix(path, "/") { + return p, fmt.Errorf("import %q: cannot import absolute path", path) + } + + // tried records the location of unsuccessful package lookups + var tried struct { + vendor []string + goroot string + gopath []string + } + gopath := ctxt.gopath() + + // Vendor directories get first chance to satisfy import. + if mode&IgnoreVendor == 0 && srcDir != "" { + searchVendor := func(root string, isGoroot bool) bool { + sub, ok := ctxt.hasSubdir(root, srcDir) + if !ok || !strings.HasPrefix(sub, "src/") || strings.Contains(sub, "/testdata/") { + return false + } + for { + vendor := ctxt.joinPath(root, sub, "vendor") + if ctxt.isDir(vendor) { + dir := ctxt.joinPath(vendor, path) + if ctxt.isDir(dir) && hasGoFiles(ctxt, dir) { + p.Dir = dir + p.ImportPath = strings.TrimPrefix(pathpkg.Join(sub, "vendor", path), "src/") + p.Goroot = isGoroot + p.Root = root + setPkga() // p.ImportPath changed + return true + } + tried.vendor = append(tried.vendor, dir) + } + i := strings.LastIndex(sub, "/") + if i < 0 { + break + } + sub = sub[:i] + } + return false + } + if searchVendor(ctxt.GOROOT, true) { + goto Found + } + for _, root := range gopath { + if searchVendor(root, false) { + goto Found + } + } + } + + // Determine directory from import path. + if ctxt.GOROOT != "" { + dir := ctxt.joinPath(ctxt.GOROOT, "src", path) + isDir := ctxt.isDir(dir) + binaryOnly = !isDir && mode&AllowBinary != 0 && pkga != "" && ctxt.isFile(ctxt.joinPath(ctxt.GOROOT, pkga)) + if isDir || binaryOnly { + p.Dir = dir + p.Goroot = true + p.Root = ctxt.GOROOT + goto Found + } + tried.goroot = dir + } + for _, root := range gopath { + dir := ctxt.joinPath(root, "src", path) + isDir := ctxt.isDir(dir) + binaryOnly = !isDir && mode&AllowBinary != 0 && pkga != "" && ctxt.isFile(ctxt.joinPath(root, pkga)) + if isDir || binaryOnly { + p.Dir = dir + p.Root = root + goto Found + } + tried.gopath = append(tried.gopath, dir) + } + + // package was not found + var paths []string + format := "\t%s (vendor tree)" + for _, dir := range tried.vendor { + paths = append(paths, fmt.Sprintf(format, dir)) + format = "\t%s" + } + if tried.goroot != "" { + paths = append(paths, fmt.Sprintf("\t%s (from $GOROOT)", tried.goroot)) + } else { + paths = append(paths, "\t($GOROOT not set)") + } + format = "\t%s (from $GOPATH)" + for _, dir := range tried.gopath { + paths = append(paths, fmt.Sprintf(format, dir)) + format = "\t%s" + } + if len(tried.gopath) == 0 { + paths = append(paths, "\t($GOPATH not set. For more details see: 'go help gopath')") + } + return p, fmt.Errorf("cannot find package %q in any of:\n%s", path, strings.Join(paths, "\n")) + } + +Found: + if p.Root != "" { + p.SrcRoot = ctxt.joinPath(p.Root, "src") + p.PkgRoot = ctxt.joinPath(p.Root, "pkg") + p.BinDir = ctxt.joinPath(p.Root, "bin") + if pkga != "" { + p.PkgTargetRoot = ctxt.joinPath(p.Root, pkgtargetroot) + p.PkgObj = ctxt.joinPath(p.Root, pkga) + } + } + + // If it's a local import path, by the time we get here, we still haven't checked + // that p.Dir directory exists. This is the right time to do that check. + // We can't do it earlier, because we want to gather partial information for the + // non-nil *Package returned when an error occurs. + // We need to do this before we return early on FindOnly flag. + if IsLocalImport(path) && !ctxt.isDir(p.Dir) { + // package was not found + return p, fmt.Errorf("cannot find package %q in:\n\t%s", path, p.Dir) + } + + if mode&FindOnly != 0 { + return p, pkgerr + } + if binaryOnly && (mode&AllowBinary) != 0 { + return p, pkgerr + } + + dirs, err := ctxt.readDir(p.Dir) + if err != nil { + return p, err + } + + var badGoError error + var Sfiles []string // files with ".S" (capital S) + var firstFile, firstCommentFile string + imported := make(map[string][]token.Position) + testImported := make(map[string][]token.Position) + xTestImported := make(map[string][]token.Position) + allTags := make(map[string]bool) + fset := token.NewFileSet() + for _, d := range dirs { + if d.IsDir() { + continue + } + + name := d.Name() + ext := nameExt(name) + + badFile := func(err error) { + if badGoError == nil { + badGoError = err + } + p.InvalidGoFiles = append(p.InvalidGoFiles, name) + } + + match, data, filename, err := ctxt.matchFile(p.Dir, name, allTags, &p.BinaryOnly) + if err != nil { + badFile(err) + continue + } + if !match { + if ext == ".go" { + p.IgnoredGoFiles = append(p.IgnoredGoFiles, name) + } + continue + } + + // Going to save the file. For non-Go files, can stop here. + switch ext { + case ".c": + p.CFiles = append(p.CFiles, name) + continue + case ".cc", ".cpp", ".cxx": + p.CXXFiles = append(p.CXXFiles, name) + continue + case ".m": + p.MFiles = append(p.MFiles, name) + continue + case ".h", ".hh", ".hpp", ".hxx": + p.HFiles = append(p.HFiles, name) + continue + case ".f", ".F", ".for", ".f90": + p.FFiles = append(p.FFiles, name) + continue + case ".s": + p.SFiles = append(p.SFiles, name) + continue + case ".S": + Sfiles = append(Sfiles, name) + continue + case ".swig": + p.SwigFiles = append(p.SwigFiles, name) + continue + case ".swigcxx": + p.SwigCXXFiles = append(p.SwigCXXFiles, name) + continue + case ".syso": + // binary objects to add to package archive + // Likely of the form foo_windows.syso, but + // the name was vetted above with goodOSArchFile. + p.SysoFiles = append(p.SysoFiles, name) + continue + } + + pf, err := parser.ParseFile(fset, filename, data, parser.ImportsOnly|parser.ParseComments) + if err != nil { + badFile(err) + continue + } + + pkg := pf.Name.Name + if pkg == "documentation" { + p.IgnoredGoFiles = append(p.IgnoredGoFiles, name) + continue + } + + isTest := strings.HasSuffix(name, "_test.go") + isXTest := false + if isTest && strings.HasSuffix(pkg, "_test") { + isXTest = true + pkg = pkg[:len(pkg)-len("_test")] + } + + if p.Name == "" { + p.Name = pkg + firstFile = name + } else if pkg != p.Name { + badFile(&MultiplePackageError{ + Dir: p.Dir, + Packages: []string{p.Name, pkg}, + Files: []string{firstFile, name}, + }) + p.InvalidGoFiles = append(p.InvalidGoFiles, name) + } + if pf.Doc != nil && p.Doc == "" { + p.Doc = doc.Synopsis(pf.Doc.Text()) + } + + if mode&ImportComment != 0 { + qcom, line := findImportComment(data) + if line != 0 { + com, err := strconv.Unquote(qcom) + if err != nil { + badFile(fmt.Errorf("%s:%d: cannot parse import comment", filename, line)) + } else if p.ImportComment == "" { + p.ImportComment = com + firstCommentFile = name + } else if p.ImportComment != com { + badFile(fmt.Errorf("found import comments %q (%s) and %q (%s) in %s", p.ImportComment, firstCommentFile, com, name, p.Dir)) + } + } + } + + // Record imports and information about cgo. + isCgo := false + for _, decl := range pf.Decls { + d, ok := decl.(*ast.GenDecl) + if !ok { + continue + } + for _, dspec := range d.Specs { + spec, ok := dspec.(*ast.ImportSpec) + if !ok { + continue + } + quoted := spec.Path.Value + path, err := strconv.Unquote(quoted) + if err != nil { + log.Panicf("%s: parser returned invalid quoted string: <%s>", filename, quoted) + } + if isXTest { + xTestImported[path] = append(xTestImported[path], fset.Position(spec.Pos())) + } else if isTest { + testImported[path] = append(testImported[path], fset.Position(spec.Pos())) + } else { + imported[path] = append(imported[path], fset.Position(spec.Pos())) + } + if path == "C" { + if isTest { + badFile(fmt.Errorf("use of cgo in test %s not supported", filename)) + } else { + cg := spec.Doc + if cg == nil && len(d.Specs) == 1 { + cg = d.Doc + } + if cg != nil { + if err := ctxt.saveCgo(filename, p, cg); err != nil { + badFile(err) + } + } + isCgo = true + } + } + } + } + if isCgo { + allTags["cgo"] = true + if ctxt.CgoEnabled { + p.CgoFiles = append(p.CgoFiles, name) + } else { + p.IgnoredGoFiles = append(p.IgnoredGoFiles, name) + } + } else if isXTest { + p.XTestGoFiles = append(p.XTestGoFiles, name) + } else if isTest { + p.TestGoFiles = append(p.TestGoFiles, name) + } else { + p.GoFiles = append(p.GoFiles, name) + } + } + if badGoError != nil { + return p, badGoError + } + if len(p.GoFiles)+len(p.CgoFiles)+len(p.TestGoFiles)+len(p.XTestGoFiles) == 0 { + return p, &NoGoError{p.Dir} + } + + for tag := range allTags { + p.AllTags = append(p.AllTags, tag) + } + sort.Strings(p.AllTags) + + p.Imports, p.ImportPos = cleanImports(imported) + p.TestImports, p.TestImportPos = cleanImports(testImported) + p.XTestImports, p.XTestImportPos = cleanImports(xTestImported) + + // add the .S files only if we are using cgo + // (which means gcc will compile them). + // The standard assemblers expect .s files. + if len(p.CgoFiles) > 0 { + p.SFiles = append(p.SFiles, Sfiles...) + sort.Strings(p.SFiles) + } + + return p, pkgerr +} + +// hasGoFiles reports whether dir contains any files with names ending in .go. +// For a vendor check we must exclude directories that contain no .go files. +// Otherwise it is not possible to vendor just a/b/c and still import the +// non-vendored a/b. See golang.org/issue/13832. +func hasGoFiles(ctxt *Context, dir string) bool { + ents, _ := ctxt.readDir(dir) + for _, ent := range ents { + if !ent.IsDir() && strings.HasSuffix(ent.Name(), ".go") { + return true + } + } + return false +} + +func findImportComment(data []byte) (s string, line int) { + // expect keyword package + word, data := parseWord(data) + if string(word) != "package" { + return "", 0 + } + + // expect package name + _, data = parseWord(data) + + // now ready for import comment, a // or /* */ comment + // beginning and ending on the current line. + for len(data) > 0 && (data[0] == ' ' || data[0] == '\t' || data[0] == '\r') { + data = data[1:] + } + + var comment []byte + switch { + case bytes.HasPrefix(data, slashSlash): + i := bytes.Index(data, newline) + if i < 0 { + i = len(data) + } + comment = data[2:i] + case bytes.HasPrefix(data, slashStar): + data = data[2:] + i := bytes.Index(data, starSlash) + if i < 0 { + // malformed comment + return "", 0 + } + comment = data[:i] + if bytes.Contains(comment, newline) { + return "", 0 + } + } + comment = bytes.TrimSpace(comment) + + // split comment into `import`, `"pkg"` + word, arg := parseWord(comment) + if string(word) != "import" { + return "", 0 + } + + line = 1 + bytes.Count(data[:cap(data)-cap(arg)], newline) + return strings.TrimSpace(string(arg)), line +} + +var ( + slashSlash = []byte("//") + slashStar = []byte("/*") + starSlash = []byte("*/") + newline = []byte("\n") +) + +// skipSpaceOrComment returns data with any leading spaces or comments removed. +func skipSpaceOrComment(data []byte) []byte { + for len(data) > 0 { + switch data[0] { + case ' ', '\t', '\r', '\n': + data = data[1:] + continue + case '/': + if bytes.HasPrefix(data, slashSlash) { + i := bytes.Index(data, newline) + if i < 0 { + return nil + } + data = data[i+1:] + continue + } + if bytes.HasPrefix(data, slashStar) { + data = data[2:] + i := bytes.Index(data, starSlash) + if i < 0 { + return nil + } + data = data[i+2:] + continue + } + } + break + } + return data +} + +// parseWord skips any leading spaces or comments in data +// and then parses the beginning of data as an identifier or keyword, +// returning that word and what remains after the word. +func parseWord(data []byte) (word, rest []byte) { + data = skipSpaceOrComment(data) + + // Parse past leading word characters. + rest = data + for { + r, size := utf8.DecodeRune(rest) + if unicode.IsLetter(r) || '0' <= r && r <= '9' || r == '_' { + rest = rest[size:] + continue + } + break + } + + word = data[:len(data)-len(rest)] + if len(word) == 0 { + return nil, nil + } + + return word, rest +} + +// MatchFile reports whether the file with the given name in the given directory +// matches the context and would be included in a Package created by ImportDir +// of that directory. +// +// MatchFile considers the name of the file and may use ctxt.OpenFile to +// read some or all of the file's content. +func (ctxt *Context) MatchFile(dir, name string) (match bool, err error) { + match, _, _, err = ctxt.matchFile(dir, name, nil, nil) + return match, err + +} + +// matchFile determines whether the file with the given name in the given directory +// should be included in the package being constructed. +// It returns the data read from the file. +// If name denotes a Go program, matchFile reads until the end of the +// imports (and returns that data) even though it only considers text +// until the first non-comment. +// If allTags is non-nil, matchFile records any encountered build tag +// by setting allTags[tag] = true. +func (ctxt *Context) matchFile(dir, name string, allTags map[string]bool, binaryOnly *bool) (match bool, data []byte, filename string, err error) { + if strings.HasPrefix(name, "_") || + strings.HasPrefix(name, ".") { + return match, data, filename, err + } + + i := strings.LastIndex(name, ".") + if i < 0 { + i = len(name) + } + ext := name[i:] + + if !ctxt.goodOSArchFile(name, allTags) && !ctxt.UseAllFiles { + return match, data, filename, err + } + + switch ext { + case ".go", ".c", ".cc", ".cxx", ".cpp", ".m", ".s", ".h", ".hh", ".hpp", ".hxx", ".f", ".F", ".f90", ".S", ".swig", ".swigcxx": + // tentatively okay - read to make sure + case ".syso": + // binary, no reading + match = true + return match, data, filename, err + default: + // skip + return match, data, filename, err + } + + filename = ctxt.joinPath(dir, name) + f, err := ctxt.openFile(filename) + if err != nil { + return match, data, filename, err + } + + if strings.HasSuffix(filename, ".go") { + data, err = readImports(f, false, nil) + if strings.HasSuffix(filename, "_test.go") { + binaryOnly = nil // ignore //go:binary-only-package comments in _test.go files + } + } else { + binaryOnly = nil // ignore //go:binary-only-package comments in non-Go sources + data, err = readComments(f) + } + f.Close() + if err != nil { + err = fmt.Errorf("read %s: %v", filename, err) + return match, data, filename, err + } + + // Look for +build comments to accept or reject the file. + var sawBinaryOnly bool + if !ctxt.shouldBuild(data, allTags, &sawBinaryOnly) && !ctxt.UseAllFiles { + return match, data, filename, err + } + + if binaryOnly != nil && sawBinaryOnly { + *binaryOnly = true + } + match = true + return match, data, filename, err +} + +func cleanImports(m map[string][]token.Position) ([]string, map[string][]token.Position) { + all := make([]string, 0, len(m)) + for path := range m { + all = append(all, path) + } + sort.Strings(all) + return all, m +} + +// Import is shorthand for Default.Import. +func Import(path, srcDir string, mode ImportMode) (*Package, error) { + return Default.Import(path, srcDir, mode) +} + +// ImportDir is shorthand for Default.ImportDir. +func ImportDir(dir string, mode ImportMode) (*Package, error) { + return Default.ImportDir(dir, mode) +} + +var slashslash = []byte("//") + +// Special comment denoting a binary-only package. +// See https://golang.org/design/2775-binary-only-packages +// for more about the design of binary-only packages. +var binaryOnlyComment = []byte("//go:binary-only-package") + +// shouldBuild reports whether it is okay to use this file, +// The rule is that in the file's leading run of // comments +// and blank lines, which must be followed by a blank line +// (to avoid including a Go package clause doc comment), +// lines beginning with '// +build' are taken as build directives. +// +// The file is accepted only if each such line lists something +// matching the file. For example: +// +// // +build windows linux +// +// marks the file as applicable only on Windows and Linux. +// +// If shouldBuild finds a //go:binary-only-package comment in the file, +// it sets *binaryOnly to true. Otherwise it does not change *binaryOnly. +// +func (ctxt *Context) shouldBuild(content []byte, allTags map[string]bool, binaryOnly *bool) bool { + sawBinaryOnly := false + + // Pass 1. Identify leading run of // comments and blank lines, + // which must be followed by a blank line. + end := 0 + p := content + for len(p) > 0 { + line := p + if i := bytes.IndexByte(line, '\n'); i >= 0 { + line, p = line[:i], p[i+1:] + } else { + p = p[len(p):] + } + line = bytes.TrimSpace(line) + if len(line) == 0 { // Blank line + end = len(content) - len(p) + continue + } + if !bytes.HasPrefix(line, slashslash) { // Not comment line + break + } + } + content = content[:end] + + // Pass 2. Process each line in the run. + p = content + hasReq := len(ctxt.RequiredTags) > 0 + allok := !hasReq + for len(p) > 0 { + line := p + if i := bytes.IndexByte(line, '\n'); i >= 0 { + line, p = line[:i], p[i+1:] + } else { + p = p[len(p):] + } + line = bytes.TrimSpace(line) + if bytes.HasPrefix(line, slashslash) { + if bytes.Equal(line, binaryOnlyComment) { + sawBinaryOnly = true + } + line = bytes.TrimSpace(line[len(slashslash):]) + if len(line) > 0 && line[0] == '+' { + // Looks like a comment +line. + f := strings.Fields(string(line)) + if f[0] == "+build" { + ok := false + for _, tok := range f[1:] { + tags := map[string]bool{} + if ctxt.match(tok, tags) { + if containsAll(tags, ctxt.RequiredTags) { + ok = true + } + } + merge(allTags, tags) + } + if !hasReq { + if !ok { + allok = false + } + } else { + if ok { + allok = true + } + } + } + } + } + } + + if binaryOnly != nil && sawBinaryOnly { + *binaryOnly = true + } + + return allok +} + +func merge(to, from map[string]bool) { + if to == nil { + return + } + for k, v := range from { + to[k] = v + } +} + +func containsAll(m map[string]bool, vals []string) bool { + // yes this is N^2, but N is small. + for _, v := range vals { + if !m[v] { + return false + } + } + return true +} + +func contains(list []string, s string) bool { + for _, l := range list { + if l == s { + return true + } + } + return false +} + +// saveCgo saves the information from the #cgo lines in the import "C" comment. +// These lines set CFLAGS, CPPFLAGS, CXXFLAGS and LDFLAGS and pkg-config directives +// that affect the way cgo's C code is built. +func (ctxt *Context) saveCgo(filename string, di *Package, cg *ast.CommentGroup) error { + text := cg.Text() + for _, line := range strings.Split(text, "\n") { + orig := line + + // Line is + // #cgo [GOOS/GOARCH...] LDFLAGS: stuff + // + line = strings.TrimSpace(line) + if len(line) < 5 || line[:4] != "#cgo" || (line[4] != ' ' && line[4] != '\t') { + continue + } + + // Split at colon. + line = strings.TrimSpace(line[4:]) + i := strings.Index(line, ":") + if i < 0 { + return fmt.Errorf("%s: invalid #cgo line: %s", filename, orig) + } + line, argstr := line[:i], line[i+1:] + + // Parse GOOS/GOARCH stuff. + f := strings.Fields(line) + if len(f) < 1 { + return fmt.Errorf("%s: invalid #cgo line: %s", filename, orig) + } + + cond, verb := f[:len(f)-1], f[len(f)-1] + if len(cond) > 0 { + ok := false + for _, c := range cond { + if ctxt.match(c, nil) { + ok = true + break + } + } + if !ok { + continue + } + } + + args, err := splitQuoted(argstr) + if err != nil { + return fmt.Errorf("%s: invalid #cgo line: %s", filename, orig) + } + var ok bool + for i, arg := range args { + if arg, ok = expandSrcDir(arg, di.Dir); !ok { + return fmt.Errorf("%s: malformed #cgo argument: %s", filename, arg) + } + args[i] = arg + } + + switch verb { + case "CFLAGS", "CPPFLAGS", "CXXFLAGS", "FFLAGS", "LDFLAGS": + // Change relative paths to absolute. + ctxt.makePathsAbsolute(args, di.Dir) + } + + switch verb { + case "CFLAGS": + di.CgoCFLAGS = append(di.CgoCFLAGS, args...) + case "CPPFLAGS": + di.CgoCPPFLAGS = append(di.CgoCPPFLAGS, args...) + case "CXXFLAGS": + di.CgoCXXFLAGS = append(di.CgoCXXFLAGS, args...) + case "FFLAGS": + di.CgoFFLAGS = append(di.CgoFFLAGS, args...) + case "LDFLAGS": + di.CgoLDFLAGS = append(di.CgoLDFLAGS, args...) + case "pkg-config": + di.CgoPkgConfig = append(di.CgoPkgConfig, args...) + default: + return fmt.Errorf("%s: invalid #cgo verb: %s", filename, orig) + } + } + return nil +} + +// expandSrcDir expands any occurrence of ${SRCDIR}, making sure +// the result is safe for the shell. +func expandSrcDir(str string, srcdir string) (string, bool) { + // "\" delimited paths cause safeCgoName to fail + // so convert native paths with a different delimiter + // to "/" before starting (eg: on windows). + srcdir = filepath.ToSlash(srcdir) + + chunks := strings.Split(str, "${SRCDIR}") + if len(chunks) < 2 { + return str, safeCgoName(str) + } + ok := true + for _, chunk := range chunks { + ok = ok && (chunk == "" || safeCgoName(chunk)) + } + ok = ok && (srcdir == "" || safeCgoName(srcdir)) + res := strings.Join(chunks, srcdir) + return res, ok && res != "" +} + +// makePathsAbsolute looks for compiler options that take paths and +// makes them absolute. We do this because through the 1.8 release we +// ran the compiler in the package directory, so any relative -I or -L +// options would be relative to that directory. In 1.9 we changed to +// running the compiler in the build directory, to get consistent +// build results (issue #19964). To keep builds working, we change any +// relative -I or -L options to be absolute. +// +// Using filepath.IsAbs and filepath.Join here means the results will be +// different on different systems, but that's OK: -I and -L options are +// inherently system-dependent. +func (ctxt *Context) makePathsAbsolute(args []string, srcDir string) { + nextPath := false + for i, arg := range args { + if nextPath { + if !filepath.IsAbs(arg) { + args[i] = filepath.Join(srcDir, arg) + } + nextPath = false + } else if strings.HasPrefix(arg, "-I") || strings.HasPrefix(arg, "-L") { + if len(arg) == 2 { + nextPath = true + } else { + if !filepath.IsAbs(arg[2:]) { + args[i] = arg[:2] + filepath.Join(srcDir, arg[2:]) + } + } + } + } +} + +// NOTE: $ is not safe for the shell, but it is allowed here because of linker options like -Wl,$ORIGIN. +// We never pass these arguments to a shell (just to programs we construct argv for), so this should be okay. +// See golang.org/issue/6038. +// The @ is for OS X. See golang.org/issue/13720. +// The % is for Jenkins. See golang.org/issue/16959. +const safeString = "+-.,/0123456789=ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz:$@% " + +func safeCgoName(s string) bool { + if s == "" { + return false + } + for i := 0; i < len(s); i++ { + if c := s[i]; c < utf8.RuneSelf && strings.IndexByte(safeString, c) < 0 { + return false + } + } + return true +} + +// splitQuoted splits the string s around each instance of one or more consecutive +// white space characters while taking into account quotes and escaping, and +// returns an array of substrings of s or an empty list if s contains only white space. +// Single quotes and double quotes are recognized to prevent splitting within the +// quoted region, and are removed from the resulting substrings. If a quote in s +// isn't closed err will be set and r will have the unclosed argument as the +// last element. The backslash is used for escaping. +// +// For example, the following string: +// +// a b:"c d" 'e''f' "g\"" +// +// Would be parsed as: +// +// []string{"a", "b:c d", "ef", `g"`} +// +func splitQuoted(s string) (r []string, err error) { + var args []string + arg := make([]rune, len(s)) + escaped := false + quoted := false + quote := '\x00' + i := 0 + for _, rune := range s { + switch { + case escaped: + escaped = false + case rune == '\\': + escaped = true + continue + case quote != '\x00': + if rune == quote { + quote = '\x00' + continue + } + case rune == '"' || rune == '\'': + quoted = true + quote = rune + continue + case unicode.IsSpace(rune): + if quoted || i > 0 { + quoted = false + args = append(args, string(arg[:i])) + i = 0 + } + continue + } + arg[i] = rune + i++ + } + if quoted || i > 0 { + args = append(args, string(arg[:i])) + } + if quote != 0 { + err = errors.New("unclosed quote") + } else if escaped { + err = errors.New("unfinished escaping") + } + return args, err +} + +// match reports whether the name is one of: +// +// $GOOS +// $GOARCH +// cgo (if cgo is enabled) +// !cgo (if cgo is disabled) +// ctxt.Compiler +// !ctxt.Compiler +// tag (if tag is listed in ctxt.BuildTags or ctxt.ReleaseTags) +// !tag (if tag is not listed in ctxt.BuildTags or ctxt.ReleaseTags) +// a comma-separated list of any of these +// +func (ctxt *Context) match(name string, allTags map[string]bool) bool { + if name == "" { + if allTags != nil { + allTags[name] = true + } + return false + } + if i := strings.Index(name, ","); i >= 0 { + // comma-separated list + ok1 := ctxt.match(name[:i], allTags) + ok2 := ctxt.match(name[i+1:], allTags) + return ok1 && ok2 + } + if strings.HasPrefix(name, "!!") { // bad syntax, reject always + return false + } + if strings.HasPrefix(name, "!") { // negation + return len(name) > 1 && !ctxt.match(name[1:], allTags) + } + + if allTags != nil { + allTags[name] = true + } + + // Tags must be letters, digits, underscores or dots. + // Unlike in Go identifiers, all digits are fine (e.g., "386"). + for _, c := range name { + if !unicode.IsLetter(c) && !unicode.IsDigit(c) && c != '_' && c != '.' { + return false + } + } + + // special tags + if ctxt.CgoEnabled && name == "cgo" { + return true + } + if name == ctxt.GOOS || name == ctxt.GOARCH || name == ctxt.Compiler { + return true + } + if ctxt.GOOS == "android" && name == "linux" { + return true + } + + // other tags + for _, tag := range ctxt.BuildTags { + if tag == name { + return true + } + } + for _, tag := range ctxt.ReleaseTags { + if tag == name { + return true + } + } + + return false +} + +// goodOSArchFile returns false if the name contains a $GOOS or $GOARCH +// suffix which does not match the current system. +// The recognized name formats are: +// +// name_$(GOOS).* +// name_$(GOARCH).* +// name_$(GOOS)_$(GOARCH).* +// name_$(GOOS)_test.* +// name_$(GOARCH)_test.* +// name_$(GOOS)_$(GOARCH)_test.* +// +// An exception: if GOOS=android, then files with GOOS=linux are also matched. +func (ctxt *Context) goodOSArchFile(name string, allTags map[string]bool) bool { + if dot := strings.Index(name, "."); dot != -1 { + name = name[:dot] + } + + // Before Go 1.4, a file called "linux.go" would be equivalent to having a + // build tag "linux" in that file. For Go 1.4 and beyond, we require this + // auto-tagging to apply only to files with a non-empty prefix, so + // "foo_linux.go" is tagged but "linux.go" is not. This allows new operating + // systems, such as android, to arrive without breaking existing code with + // innocuous source code in "android.go". The easiest fix: cut everything + // in the name before the initial _. + i := strings.Index(name, "_") + if i < 0 { + return true + } + name = name[i:] // ignore everything before first _ + + l := strings.Split(name, "_") + if n := len(l); n > 0 && l[n-1] == "test" { + l = l[:n-1] + } + n := len(l) + if n >= 2 && knownOS[l[n-2]] && knownArch[l[n-1]] { + if allTags != nil { + allTags[l[n-2]] = true + allTags[l[n-1]] = true + } + if l[n-1] != ctxt.GOARCH { + return false + } + if ctxt.GOOS == "android" && l[n-2] == "linux" { + return true + } + return l[n-2] == ctxt.GOOS + } + if n >= 1 && knownOS[l[n-1]] { + if allTags != nil { + allTags[l[n-1]] = true + } + if ctxt.GOOS == "android" && l[n-1] == "linux" { + return true + } + return l[n-1] == ctxt.GOOS + } + if n >= 1 && knownArch[l[n-1]] { + if allTags != nil { + allTags[l[n-1]] = true + } + return l[n-1] == ctxt.GOARCH + } + return true +} + +var knownOS = make(map[string]bool) +var knownArch = make(map[string]bool) + +func init() { + for _, v := range strings.Fields(goosList) { + knownOS[v] = true + } + for _, v := range strings.Fields(goarchList) { + knownArch[v] = true + } +} + +// ToolDir is the directory containing build tools. +var ToolDir = filepath.Join(runtime.GOROOT(), "pkg/tool/"+runtime.GOOS+"_"+runtime.GOARCH) + +// IsLocalImport reports whether the import path is +// a local import path, like ".", "..", "./foo", or "../foo". +func IsLocalImport(path string) bool { + return path == "." || path == ".." || + strings.HasPrefix(path, "./") || strings.HasPrefix(path, "../") +} + +// ArchChar returns "?" and an error. +// In earlier versions of Go, the returned string was used to derive +// the compiler and linker tool names, the default object file suffix, +// and the default linker output name. As of Go 1.5, those strings +// no longer vary by architecture; they are compile, link, .o, and a.out, respectively. +func ArchChar(goarch string) (string, error) { + return "?", errors.New("architecture letter no longer used") +} diff --git a/vendor/github.com/magefile/mage/build/doc.go b/vendor/github.com/magefile/mage/build/doc.go new file mode 100644 index 0000000000..422e1a5ffd --- /dev/null +++ b/vendor/github.com/magefile/mage/build/doc.go @@ -0,0 +1,166 @@ +// 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. + +// Package build gathers information about Go packages. +// +// Go Path +// +// The Go path is a list of directory trees containing Go source code. +// It is consulted to resolve imports that cannot be found in the standard +// Go tree. The default path is the value of the GOPATH environment +// variable, interpreted as a path list appropriate to the operating system +// (on Unix, the variable is a colon-separated string; +// on Windows, a semicolon-separated string; +// on Plan 9, a list). +// +// Each directory listed in the Go path must have a prescribed structure: +// +// The src/ directory holds source code. The path below 'src' determines +// the import path or executable name. +// +// The pkg/ directory holds installed package objects. +// As in the Go tree, each target operating system and +// architecture pair has its own subdirectory of pkg +// (pkg/GOOS_GOARCH). +// +// If DIR is a directory listed in the Go path, a package with +// source in DIR/src/foo/bar can be imported as "foo/bar" and +// has its compiled form installed to "DIR/pkg/GOOS_GOARCH/foo/bar.a" +// (or, for gccgo, "DIR/pkg/gccgo/foo/libbar.a"). +// +// The bin/ directory holds compiled commands. +// Each command is named for its source directory, but only +// using the final element, not the entire path. That is, the +// command with source in DIR/src/foo/quux is installed into +// DIR/bin/quux, not DIR/bin/foo/quux. The foo/ is stripped +// so that you can add DIR/bin to your PATH to get at the +// installed commands. +// +// Here's an example directory layout: +// +// GOPATH=/home/user/gocode +// +// /home/user/gocode/ +// src/ +// foo/ +// bar/ (go code in package bar) +// x.go +// quux/ (go code in package main) +// y.go +// bin/ +// quux (installed command) +// pkg/ +// linux_amd64/ +// foo/ +// bar.a (installed package object) +// +// Build Constraints +// +// A build constraint, also known as a build tag, is a line comment that begins +// +// // +build +// +// that lists the conditions under which a file should be included in the package. +// Constraints may appear in any kind of source file (not just Go), but +// they must appear near the top of the file, preceded +// only by blank lines and other line comments. These rules mean that in Go +// files a build constraint must appear before the package clause. +// +// To distinguish build constraints from package documentation, a series of +// build constraints must be followed by a blank line. +// +// A build constraint is evaluated as the OR of space-separated options; +// each option evaluates as the AND of its comma-separated terms; +// and each term is an alphanumeric word or, preceded by !, its negation. +// That is, the build constraint: +// +// // +build linux,386 darwin,!cgo +// +// corresponds to the boolean formula: +// +// (linux AND 386) OR (darwin AND (NOT cgo)) +// +// A file may have multiple build constraints. The overall constraint is the AND +// of the individual constraints. That is, the build constraints: +// +// // +build linux darwin +// // +build 386 +// +// corresponds to the boolean formula: +// +// (linux OR darwin) AND 386 +// +// During a particular build, the following words are satisfied: +// +// - the target operating system, as spelled by runtime.GOOS +// - the target architecture, as spelled by runtime.GOARCH +// - the compiler being used, either "gc" or "gccgo" +// - "cgo", if ctxt.CgoEnabled is true +// - "go1.1", from Go version 1.1 onward +// - "go1.2", from Go version 1.2 onward +// - "go1.3", from Go version 1.3 onward +// - "go1.4", from Go version 1.4 onward +// - "go1.5", from Go version 1.5 onward +// - "go1.6", from Go version 1.6 onward +// - "go1.7", from Go version 1.7 onward +// - "go1.8", from Go version 1.8 onward +// - "go1.9", from Go version 1.9 onward +// - any additional words listed in ctxt.BuildTags +// +// If a file's name, after stripping the extension and a possible _test suffix, +// matches any of the following patterns: +// *_GOOS +// *_GOARCH +// *_GOOS_GOARCH +// (example: source_windows_amd64.go) where GOOS and GOARCH represent +// any known operating system and architecture values respectively, then +// the file is considered to have an implicit build constraint requiring +// those terms (in addition to any explicit constraints in the file). +// +// To keep a file from being considered for the build: +// +// // +build ignore +// +// (any other unsatisfied word will work as well, but ``ignore'' is conventional.) +// +// To build a file only when using cgo, and only on Linux and OS X: +// +// // +build linux,cgo darwin,cgo +// +// Such a file is usually paired with another file implementing the +// default functionality for other systems, which in this case would +// carry the constraint: +// +// // +build !linux,!darwin !cgo +// +// Naming a file dns_windows.go will cause it to be included only when +// building the package for Windows; similarly, math_386.s will be included +// only when building the package for 32-bit x86. +// +// Using GOOS=android matches build tags and files as for GOOS=linux +// in addition to android tags and files. +// +// Binary-Only Packages +// +// It is possible to distribute packages in binary form without including the +// source code used for compiling the package. To do this, the package must +// be distributed with a source file not excluded by build constraints and +// containing a "//go:binary-only-package" comment. +// Like a build constraint, this comment must appear near the top of the file, +// preceded only by blank lines and other line comments and with a blank line +// following the comment, to separate it from the package documentation. +// Unlike build constraints, this comment is only recognized in non-test +// Go source files. +// +// The minimal source code for a binary-only package is therefore: +// +// //go:binary-only-package +// +// package mypkg +// +// The source code may include additional Go code. That code is never compiled +// but will be processed by tools like godoc and might be useful as end-user +// documentation. +// +package build diff --git a/vendor/github.com/magefile/mage/build/read.go b/vendor/github.com/magefile/mage/build/read.go new file mode 100644 index 0000000000..29b8cdc786 --- /dev/null +++ b/vendor/github.com/magefile/mage/build/read.go @@ -0,0 +1,247 @@ +// Copyright 2012 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. + +package build + +import ( + "bufio" + "errors" + "io" + "unicode/utf8" +) + +type importReader struct { + b *bufio.Reader + buf []byte + peek byte + err error + eof bool + nerr int +} + +func isIdent(c byte) bool { + return 'A' <= c && c <= 'Z' || 'a' <= c && c <= 'z' || '0' <= c && c <= '9' || c == '_' || c >= utf8.RuneSelf +} + +var ( + errSyntax = errors.New("syntax error") + errNUL = errors.New("unexpected NUL in input") +) + +// syntaxError records a syntax error, but only if an I/O error has not already been recorded. +func (r *importReader) syntaxError() { + if r.err == nil { + r.err = errSyntax + } +} + +// readByte reads the next byte from the input, saves it in buf, and returns it. +// If an error occurs, readByte records the error in r.err and returns 0. +func (r *importReader) readByte() byte { + c, err := r.b.ReadByte() + if err == nil { + r.buf = append(r.buf, c) + if c == 0 { + err = errNUL + } + } + if err != nil { + if err == io.EOF { + r.eof = true + } else if r.err == nil { + r.err = err + } + c = 0 + } + return c +} + +// peekByte returns the next byte from the input reader but does not advance beyond it. +// If skipSpace is set, peekByte skips leading spaces and comments. +func (r *importReader) peekByte(skipSpace bool) byte { + if r.err != nil { + if r.nerr++; r.nerr > 10000 { + panic("go/build: import reader looping") + } + return 0 + } + + // Use r.peek as first input byte. + // Don't just return r.peek here: it might have been left by peekByte(false) + // and this might be peekByte(true). + c := r.peek + if c == 0 { + c = r.readByte() + } + for r.err == nil && !r.eof { + if skipSpace { + // For the purposes of this reader, semicolons are never necessary to + // understand the input and are treated as spaces. + switch c { + case ' ', '\f', '\t', '\r', '\n', ';': + c = r.readByte() + continue + + case '/': + c = r.readByte() + if c == '/' { + for c != '\n' && r.err == nil && !r.eof { + c = r.readByte() + } + } else if c == '*' { + var c1 byte + for (c != '*' || c1 != '/') && r.err == nil { + if r.eof { + r.syntaxError() + } + c, c1 = c1, r.readByte() + } + } else { + r.syntaxError() + } + c = r.readByte() + continue + } + } + break + } + r.peek = c + return r.peek +} + +// nextByte is like peekByte but advances beyond the returned byte. +func (r *importReader) nextByte(skipSpace bool) byte { + c := r.peekByte(skipSpace) + r.peek = 0 + return c +} + +// readKeyword reads the given keyword from the input. +// If the keyword is not present, readKeyword records a syntax error. +func (r *importReader) readKeyword(kw string) { + r.peekByte(true) + for i := 0; i < len(kw); i++ { + if r.nextByte(false) != kw[i] { + r.syntaxError() + return + } + } + if isIdent(r.peekByte(false)) { + r.syntaxError() + } +} + +// readIdent reads an identifier from the input. +// If an identifier is not present, readIdent records a syntax error. +func (r *importReader) readIdent() { + c := r.peekByte(true) + if !isIdent(c) { + r.syntaxError() + return + } + for isIdent(r.peekByte(false)) { + r.peek = 0 + } +} + +// readString reads a quoted string literal from the input. +// If an identifier is not present, readString records a syntax error. +func (r *importReader) readString(save *[]string) { + switch r.nextByte(true) { + case '`': + start := len(r.buf) - 1 + for r.err == nil { + if r.nextByte(false) == '`' { + if save != nil { + *save = append(*save, string(r.buf[start:])) + } + break + } + if r.eof { + r.syntaxError() + } + } + case '"': + start := len(r.buf) - 1 + for r.err == nil { + c := r.nextByte(false) + if c == '"' { + if save != nil { + *save = append(*save, string(r.buf[start:])) + } + break + } + if r.eof || c == '\n' { + r.syntaxError() + } + if c == '\\' { + r.nextByte(false) + } + } + default: + r.syntaxError() + } +} + +// readImport reads an import clause - optional identifier followed by quoted string - +// from the input. +func (r *importReader) readImport(imports *[]string) { + c := r.peekByte(true) + if c == '.' { + r.peek = 0 + } else if isIdent(c) { + r.readIdent() + } + r.readString(imports) +} + +// readComments is like ioutil.ReadAll, except that it only reads the leading +// block of comments in the file. +func readComments(f io.Reader) ([]byte, error) { + r := &importReader{b: bufio.NewReader(f)} + r.peekByte(true) + if r.err == nil && !r.eof { + // Didn't reach EOF, so must have found a non-space byte. Remove it. + r.buf = r.buf[:len(r.buf)-1] + } + return r.buf, r.err +} + +// readImports is like ioutil.ReadAll, except that it expects a Go file as input +// and stops reading the input once the imports have completed. +func readImports(f io.Reader, reportSyntaxError bool, imports *[]string) ([]byte, error) { + r := &importReader{b: bufio.NewReader(f)} + + r.readKeyword("package") + r.readIdent() + for r.peekByte(true) == 'i' { + r.readKeyword("import") + if r.peekByte(true) == '(' { + r.nextByte(false) + for r.peekByte(true) != ')' && r.err == nil { + r.readImport(imports) + } + r.nextByte(false) + } else { + r.readImport(imports) + } + } + + // If we stopped successfully before EOF, we read a byte that told us we were done. + // Return all but that last byte, which would cause a syntax error if we let it through. + if r.err == nil && !r.eof { + return r.buf[:len(r.buf)-1], nil + } + + // If we stopped for a syntax error, consume the whole file so that + // we are sure we don't change the errors that go/parser returns. + if r.err == errSyntax && !reportSyntaxError { + r.err = nil + for r.err == nil && !r.eof { + r.readByte() + } + } + + return r.buf, r.err +} diff --git a/vendor/github.com/magefile/mage/build/syslist.go b/vendor/github.com/magefile/mage/build/syslist.go new file mode 100644 index 0000000000..73fdbe6c85 --- /dev/null +++ b/vendor/github.com/magefile/mage/build/syslist.go @@ -0,0 +1,8 @@ +// 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. + +package build + +const goosList = "android darwin dragonfly freebsd linux nacl netbsd openbsd plan9 solaris windows zos " +const goarchList = "386 amd64 amd64p32 arm armbe arm64 arm64be ppc64 ppc64le mips mipsle mips64 mips64le mips64p32 mips64p32le ppc s390 s390x sparc sparc64 " diff --git a/vendor/github.com/magefile/mage/build/zcgo.go b/vendor/github.com/magefile/mage/build/zcgo.go new file mode 100644 index 0000000000..86e2a2d973 --- /dev/null +++ b/vendor/github.com/magefile/mage/build/zcgo.go @@ -0,0 +1,37 @@ +// auto generated by go tool dist + +package build + +const defaultCGO_ENABLED = "" + +var cgoEnabled = map[string]bool{ + "android/386": true, + "android/amd64": true, + "android/arm": true, + "android/arm64": true, + "darwin/386": true, + "darwin/amd64": true, + "darwin/arm": true, + "darwin/arm64": true, + "dragonfly/amd64": true, + "freebsd/386": true, + "freebsd/amd64": true, + "linux/386": true, + "linux/amd64": true, + "linux/arm": true, + "linux/arm64": true, + "linux/mips": true, + "linux/mips64": true, + "linux/mips64le": true, + "linux/mipsle": true, + "linux/ppc64le": true, + "linux/s390x": true, + "netbsd/386": true, + "netbsd/amd64": true, + "netbsd/arm": true, + "openbsd/386": true, + "openbsd/amd64": true, + "solaris/amd64": true, + "windows/386": true, + "windows/amd64": true, +} diff --git a/vendor/github.com/magefile/mage/mage/command_string.go b/vendor/github.com/magefile/mage/mage/command_string.go new file mode 100644 index 0000000000..fcdaf9f949 --- /dev/null +++ b/vendor/github.com/magefile/mage/mage/command_string.go @@ -0,0 +1,16 @@ +// Code generated by "stringer -type=Command"; DO NOT EDIT. + +package mage + +import "strconv" + +const _Command_name = "NoneVersionInitCleanCompileStatic" + +var _Command_index = [...]uint8{0, 4, 11, 15, 20, 33} + +func (i Command) String() string { + if i < 0 || i >= Command(len(_Command_index)-1) { + return "Command(" + strconv.FormatInt(int64(i), 10) + ")" + } + return _Command_name[_Command_index[i]:_Command_index[i+1]] +} diff --git a/vendor/github.com/magefile/mage/mage/magefile_tmpl.go b/vendor/github.com/magefile/mage/mage/magefile_tmpl.go new file mode 100644 index 0000000000..01b8786006 --- /dev/null +++ b/vendor/github.com/magefile/mage/mage/magefile_tmpl.go @@ -0,0 +1,46 @@ +package mage + +var mageTpl = `// +build mage + +package main + +import ( + "fmt" + "os" + "os/exec" + + "github.com/magefile/mage/mg" // mg contains helpful utility functions, like Deps +) + +// Default target to run when none is specified +// If not set, running mage will list available targets +// var Default = Build + +// A build step that requires additional params, or platform specific steps for example +func Build() error { + mg.Deps(InstallDeps) + fmt.Println("Building...") + cmd := exec.Command("go", "build", "-o", "MyApp", ".") + return cmd.Run() +} + +// A custom install step if you need your bin someplace other than go/bin +func Install() error { + mg.Deps(Build) + fmt.Println("Installing...") + return os.Rename("./MyApp", "/usr/bin/MyApp") +} + +// Manage your deps, or running package managers. +func InstallDeps() error { + fmt.Println("Installing Deps...") + cmd := exec.Command("go", "get", "github.com/stretchr/piglatin") + return cmd.Run() +} + +// Clean up after yourself +func Clean() { + fmt.Println("Cleaning...") + os.RemoveAll("MyApp") +} +` diff --git a/vendor/github.com/magefile/mage/mage/main.go b/vendor/github.com/magefile/mage/mage/main.go new file mode 100644 index 0000000000..4617650342 --- /dev/null +++ b/vendor/github.com/magefile/mage/mage/main.go @@ -0,0 +1,476 @@ +package mage + +import ( + "crypto/sha1" + "errors" + "flag" + "fmt" + "io" + "io/ioutil" + "log" + "os" + "os/exec" + "path/filepath" + "runtime" + "sort" + "strconv" + "strings" + "text/template" + "time" + "unicode" + + "github.com/magefile/mage/build" + "github.com/magefile/mage/mg" + "github.com/magefile/mage/parse" + "github.com/magefile/mage/sh" +) + +// magicRebuildKey is used when hashing the output binary to ensure that we get +// a new binary even if nothing in the input files or generated mainfile has +// changed. This can be used when we change how we parse files, or otherwise +// change the inputs to the compiling process. +const magicRebuildKey = "v0.3" + +var output = template.Must(template.New("").Funcs(map[string]interface{}{ + "lower": strings.ToLower, + "lowerfirst": func(s string) string { + r := []rune(s) + return string(unicode.ToLower(r[0])) + string(r[1:]) + }, +}).Parse(tpl)) +var initOutput = template.Must(template.New("").Parse(mageTpl)) + +const mainfile = "mage_output_file.go" +const initFile = "magefile.go" + +// set by ldflags when you "mage build" +var ( + commitHash string + timestamp string + gitTag = "v2" +) + +//go:generate stringer -type=Command + +// Command tracks invocations of mage that run without targets or other flags. +type Command int + +const ( + None Command = iota + Version // report the current version of mage + Init // create a starting template for mage + Clean // clean out old compiled mage binaries from the cache + CompileStatic // compile a static binary of the current directory +) + +// Main is the entrypoint for running mage. It exists external to mage's main +// function to allow it to be used from other programs, specifically so you can +// go run a simple file that run's mage's Main. +func Main() int { + return ParseAndRun(".", os.Stdout, os.Stderr, os.Stdin, os.Args[1:]) +} + +// Invocation contains the args for invoking a run of Mage. +type Invocation struct { + Dir string // directory to read magefiles from + Force bool // forces recreation of the compiled binary + Verbose bool // tells the magefile to print out log statements + List bool // tells the magefile to print out a list of targets + Help bool // tells the magefile to print out help for a specific target + Keep bool // tells mage to keep the generated main file after compiling + Timeout time.Duration // tells mage to set a timeout to running the targets + CompileOut string // tells mage to compile a static binary to this path, but not execute + Stdout io.Writer // writer to write stdout messages to + Stderr io.Writer // writer to write stderr messages to + Stdin io.Reader // reader to read stdin from + Args []string // args to pass to the compiled binary +} + +// ParseAndRun parses the command line, and then compiles and runs the mage +// files in the given directory with the given args (do not include the command +// name in the args). +func ParseAndRun(dir string, stdout, stderr io.Writer, stdin io.Reader, args []string) int { + log := log.New(stderr, "", 0) + inv, cmd, err := Parse(stdout, args) + inv.Dir = dir + inv.Stderr = stderr + inv.Stdin = stdin + if err == flag.ErrHelp { + return 0 + } + if err != nil { + log.Println("Error:", err) + return 2 + } + + switch cmd { + case Version: + if timestamp == "" { + timestamp = "" + } + if commitHash == "" { + commitHash = "" + } + log.Println("Mage Build Tool", gitTag) + log.Println("Build Date:", timestamp) + log.Println("Commit:", commitHash) + return 0 + case Init: + if err := generateInit(dir); err != nil { + log.Println("Error:", err) + return 1 + } + log.Println(initFile, "created") + return 0 + case Clean: + dir := mg.CacheDir() + if err := removeContents(dir); err != nil { + log.Println("Error:", err) + return 1 + } + log.Println(dir, "cleaned") + return 0 + case CompileStatic: + return Invoke(inv) + case None: + return Invoke(inv) + default: + panic(fmt.Errorf("Unknown command type: %v", cmd)) + } +} + +// Parse parses the given args and returns structured data. If parse returns +// flag.ErrHelp, the calling process should exit with code 0. +func Parse(stdout io.Writer, args []string) (inv Invocation, cmd Command, err error) { + inv.Stdout = stdout + fs := flag.FlagSet{} + fs.SetOutput(stdout) + fs.BoolVar(&inv.Force, "f", false, "force recreation of compiled magefile") + fs.BoolVar(&inv.Verbose, "v", false, "show verbose output when running mage targets") + fs.BoolVar(&inv.List, "l", false, "list mage targets in this directory") + fs.BoolVar(&inv.Help, "h", false, "show this help") + fs.DurationVar(&inv.Timeout, "t", 0, "timeout in duration parsable format (e.g. 5m30s)") + fs.BoolVar(&inv.Keep, "keep", false, "keep intermediate mage files around after running") + var showVersion bool + fs.BoolVar(&showVersion, "version", false, "show version info for the mage binary") + var mageInit bool + fs.BoolVar(&mageInit, "init", false, "create a starting template if no mage files exist") + var clean bool + fs.BoolVar(&clean, "clean", false, "clean out old generated binaries from CACHE_DIR") + var compileOutPath string + fs.StringVar(&compileOutPath, "compile", "", "path to which to output a static binary") + + fs.Usage = func() { + fmt.Fprintln(stdout, "mage [options] [target]") + fmt.Fprintln(stdout, "Options:") + fs.PrintDefaults() + } + err = fs.Parse(args) + if err == flag.ErrHelp { + // parse will have already called fs.Usage() + return inv, cmd, err + } + if err == nil && inv.Help && len(fs.Args()) == 0 { + fs.Usage() + // tell upstream, to just exit + return inv, cmd, flag.ErrHelp + } + + numFlags := 0 + switch { + case mageInit: + numFlags++ + cmd = Init + case compileOutPath != "": + numFlags++ + cmd = CompileStatic + inv.CompileOut = compileOutPath + inv.Force = true + case showVersion: + numFlags++ + cmd = Version + case clean: + numFlags++ + cmd = Clean + if fs.NArg() > 0 || fs.NFlag() > 1 { + // Temporary dupe of below check until we refactor the other commands to use this check + return inv, cmd, errors.New("-h, -init, -clean, -compile and -version cannot be used simultaneously") + + } + } + if inv.Help { + numFlags++ + } + + // If verbose is still false, we're going to peek at the environment variable to see if + // MAGE_VERBOSE has been set. If so, we're going to use it for the value of MAGE_VERBOSE. + if inv.Verbose == false { + envVerbose, err := strconv.ParseBool(os.Getenv("MAGE_VERBOSE")) + if err == nil { + inv.Verbose = envVerbose + } + } + + if numFlags > 1 { + return inv, cmd, errors.New("-h, -init, -clean, -compile and -version cannot be used simultaneously") + } + + inv.Args = fs.Args() + if inv.Help && len(inv.Args) > 1 { + return inv, cmd, errors.New("-h can only show help for a single target") + } + + return inv, cmd, err +} + +// Invoke runs Mage with the given arguments. +func Invoke(inv Invocation) int { + log := log.New(inv.Stderr, "", 0) + + files, err := Magefiles(inv.Dir) + if err != nil { + log.Println("Error:", err) + return 1 + } + + if len(files) == 0 { + log.Println("No .go files marked with the mage build tag in this directory.") + return 1 + } + + exePath, err := ExeName(files) + if err != nil { + log.Println("Error:", err) + return 1 + } + if inv.CompileOut != "" { + exePath = inv.CompileOut + } + + if !inv.Force { + if _, err := os.Stat(exePath); err == nil { + return RunCompiled(inv, exePath) + } + } + + // parse wants dir + filenames... arg + fnames := make([]string, 0, len(files)) + for i := range files { + fnames = append(fnames, filepath.Base(files[i])) + } + + info, err := parse.Package(inv.Dir, fnames) + if err != nil { + log.Println("Error:", err) + return 1 + } + + hasDupes, names := CheckDupes(info) + if hasDupes { + log.Println("Build targets must be case insensitive, thus the follow targets conflict:") + for _, v := range names { + if len(v) > 1 { + log.Println(" " + strings.Join(v, ", ")) + } + } + return 1 + } + + main := filepath.Join(inv.Dir, mainfile) + if err := GenerateMainfile(main, info); err != nil { + log.Println("Error:", err) + return 1 + } + if !inv.Keep { + defer os.Remove(main) + } + files = append(files, main) + if err := Compile(exePath, inv.Stdout, inv.Stderr, files); err != nil { + log.Println("Error:", err) + return 1 + } + if !inv.Keep { + // remove this file before we run the compiled version, in case the + // compiled file screws things up. Yes this doubles up with the above + // defer, that's ok. + os.Remove(main) + } + + if inv.CompileOut != "" { + return 0 + } + + return RunCompiled(inv, exePath) +} + +// CheckDupes checks a package for duplicate target names. +func CheckDupes(info *parse.PkgInfo) (hasDupes bool, names map[string][]string) { + names = map[string][]string{} + lowers := map[string]bool{} + for _, f := range info.Funcs { + low := strings.ToLower(f.Name) + if lowers[low] { + hasDupes = true + } + lowers[low] = true + names[low] = append(names[low], f.Name) + } + return hasDupes, names +} + +type data struct { + Funcs []parse.Function + DefaultError bool + Default string + DefaultFunc parse.Function + Aliases map[string]string +} + +// Magefiles returns the list of magefiles in dir. +func Magefiles(dir string) ([]string, error) { + ctx := build.Default + ctx.RequiredTags = []string{"mage"} + ctx.BuildTags = []string{"mage"} + p, err := ctx.ImportDir(dir, 0) + if err != nil { + if _, ok := err.(*build.NoGoError); ok { + return []string{}, nil + } + return nil, err + } + for i := range p.GoFiles { + p.GoFiles[i] = filepath.Join(dir, p.GoFiles[i]) + } + return p.GoFiles, nil +} + +// Compile uses the go tool to compile the files into an executable at path. +func Compile(path string, stdout, stderr io.Writer, gofiles []string) error { + c := exec.Command("go", append([]string{"build", "-o", path}, gofiles...)...) + c.Env = os.Environ() + c.Stderr = stderr + c.Stdout = stdout + err := c.Run() + if err != nil { + return errors.New("error compiling magefiles") + } + if _, err := os.Stat(path); err != nil { + return errors.New("failed to find compiled magefile") + } + return nil +} + +// GenerateMainfile creates the mainfile at path with the info from +func GenerateMainfile(path string, info *parse.PkgInfo) error { + f, err := os.Create(path) + if err != nil { + return fmt.Errorf("can't create mainfile: %v", err) + } + defer f.Close() + + data := data{ + Funcs: info.Funcs, + Default: info.DefaultName, + DefaultFunc: info.DefaultFunc, + Aliases: info.Aliases, + } + + data.DefaultError = info.DefaultIsError + + if err := output.Execute(f, data); err != nil { + return fmt.Errorf("can't execute mainfile template: %v", err) + } + return nil +} + +// ExeName reports the executable filename that this version of Mage would +// create for the given magefiles. +func ExeName(files []string) (string, error) { + var hashes []string + for _, s := range files { + h, err := hashFile(s) + if err != nil { + return "", err + } + hashes = append(hashes, h) + } + // hash the mainfile template to ensure if it gets updated, we make a new + // binary. + hashes = append(hashes, fmt.Sprintf("%x", sha1.Sum([]byte(tpl)))) + sort.Strings(hashes) + hash := sha1.Sum([]byte(strings.Join(hashes, "") + magicRebuildKey)) + filename := fmt.Sprintf("%x", hash) + + out := filepath.Join(mg.CacheDir(), filename) + if runtime.GOOS == "windows" { + out += ".exe" + } + return out, nil +} + +func hashFile(fn string) (string, error) { + f, err := os.Open(fn) + if err != nil { + return "", fmt.Errorf("can't open input file: %v", err) + } + defer f.Close() + + h := sha1.New() + if _, err := io.Copy(h, f); err != nil { + return "", fmt.Errorf("can't write data to hash: %v", err) + } + return fmt.Sprintf("%x", h.Sum(nil)), nil +} + +func generateInit(dir string) error { + f, err := os.Create(filepath.Join(dir, initFile)) + if err != nil { + return fmt.Errorf("could not create mage template: %v", err) + } + defer f.Close() + + if err := initOutput.Execute(f, nil); err != nil { + return fmt.Errorf("can't execute magefile template: %v", err) + } + + return nil +} + +// RunCompiled runs an already-compiled mage command with the given args, +func RunCompiled(inv Invocation, exePath string) int { + c := exec.Command(exePath, inv.Args...) + c.Stderr = inv.Stderr + c.Stdout = inv.Stdout + c.Stdin = inv.Stdin + c.Env = os.Environ() + if inv.Verbose { + c.Env = append(c.Env, "MAGEFILE_VERBOSE=1") + } + if inv.List { + c.Env = append(c.Env, "MAGEFILE_LIST=1") + } + if inv.Help { + c.Env = append(c.Env, "MAGEFILE_HELP=1") + } + if inv.Timeout > 0 { + c.Env = append(c.Env, fmt.Sprintf("MAGEFILE_TIMEOUT=%s", inv.Timeout.String())) + } + return sh.ExitStatus(c.Run()) +} + +func removeContents(dir string) error { + files, err := ioutil.ReadDir(dir) + if err != nil { + return err + } + for _, f := range files { + if f.IsDir() { + continue + } + err = os.Remove(filepath.Join(dir, f.Name())) + if err != nil { + return err + } + } + return nil +} diff --git a/vendor/github.com/magefile/mage/mage/template.go b/vendor/github.com/magefile/mage/mage/template.go new file mode 100644 index 0000000000..9b75be792c --- /dev/null +++ b/vendor/github.com/magefile/mage/mage/template.go @@ -0,0 +1,202 @@ +package mage + +// var only for tests +var tpl = `// +build ignore + +package main + +import ( + "context" + "fmt" + "io/ioutil" + "log" + "os" + "strings" + "text/tabwriter" + "time" +) + +func main() { + // These functions are local variables to avoid name conflicts with + // magefiles. + list := func() error { + {{- $default := .Default}} + w := tabwriter.NewWriter(os.Stdout, 0, 4, 4, ' ', 0) + fmt.Println("Targets:") + {{- range .Funcs}} + fmt.Fprintln(w, " {{lowerfirst .Name}}{{if eq .Name $default}}*{{end}}\t" + {{printf "%q" .Synopsis}}) + {{- end}} + err := w.Flush() + {{- if .Default}} + if err == nil { + fmt.Println("\n* default target") + } + {{- end}} + return err + } + + var ctx context.Context + var ctxCancel func() + + getContext := func() (context.Context, func()) { + if ctx != nil { + return ctx, ctxCancel + } + + if os.Getenv("MAGEFILE_TIMEOUT") != "" { + timeout, err := time.ParseDuration(os.Getenv("MAGEFILE_TIMEOUT")) + if err != nil { + fmt.Printf("timeout error: %v\n", err) + os.Exit(1) + } + + ctx, ctxCancel = context.WithTimeout(context.Background(), timeout) + } else { + ctx = context.Background() + ctxCancel = func() {} + } + return ctx, ctxCancel + } + + runTarget := func(fn func(context.Context) error) interface{} { + var err interface{} + ctx, cancel := getContext() + d := make(chan interface{}) + go func() { + defer func() { + err := recover() + d <- err + }() + err := fn(ctx) + d <- err + }() + select { + case <-ctx.Done(): + cancel() + e := ctx.Err() + fmt.Printf("ctx err: %v\n", e) + return e + case err = <-d: + cancel() + return err + } + } + // This is necessary in case there aren't any targets, to avoid an unused + // variable error. + _ = runTarget + + handleError := func(logger *log.Logger, err interface{}) { + if err != nil { + logger.Printf("Error: %v\n", err) + type code interface { + ExitStatus() int + } + if c, ok := err.(code); ok { + os.Exit(c.ExitStatus()) + } + os.Exit(1) + } + } + _ = handleError + + log.SetFlags(0) + if os.Getenv("MAGEFILE_VERBOSE") == "" { + log.SetOutput(ioutil.Discard) + } + logger := log.New(os.Stderr, "", 0) + if os.Getenv("MAGEFILE_LIST") != "" { + if err := list(); err != nil { + log.Println(err) + os.Exit(1) + } + return + } + + targets := map[string]bool { + {{range $alias, $funci := .Aliases}}"{{lower $alias}}": true, + {{end}} + {{range .Funcs}}"{{lower .Name}}": true, + {{end}} + } + + var unknown []string + for _, arg := range os.Args[1:] { + if !targets[strings.ToLower(arg)] { + unknown = append(unknown, arg) + } + } + if len(unknown) == 1 { + logger.Println("Unknown target specified:", unknown[0]) + os.Exit(2) + } + if len(unknown) > 1 { + logger.Println("Unknown targets specified:", strings.Join(unknown, ", ")) + os.Exit(2) + } + + if os.Getenv("MAGEFILE_HELP") != "" { + if len(os.Args) < 2 { + logger.Println("no target specified") + os.Exit(1) + } + switch strings.ToLower(os.Args[1]) { + {{range .Funcs}}case "{{lower .Name}}": + fmt.Print("mage {{lower .Name}}:\n\n") + {{if ne .Comment ""}}fmt.Println({{printf "%q" .Comment}}){{end}} + var aliases []string + {{- $name := .Name -}} + {{range $alias, $func := $.Aliases}} + {{if eq $name $func}}aliases = append(aliases, "{{$alias}}"){{end -}} + {{- end}} + if len(aliases) > 0 { + fmt.Printf("Aliases: %s\n\n", strings.Join(aliases, ", ")) + } + return + {{end}} + default: + logger.Printf("Unknown target: %q\n", os.Args[1]) + os.Exit(1) + } + } + + if len(os.Args) < 2 { + {{- if .Default}} + {{.DefaultFunc.TemplateString}} + handleError(logger, err) + return + {{- else}} + if err := list(); err != nil { + logger.Println("Error:", err) + os.Exit(1) + } + return + {{- end}} + } + for _, target := range os.Args[1:] { + switch strings.ToLower(target) { + {{range $alias, $func := .Aliases}} + case "{{lower $alias}}": + target = "{{$func}}" + {{- end}} + } + switch strings.ToLower(target) { + {{range .Funcs }} + case "{{lower .Name}}": + if os.Getenv("MAGEFILE_VERBOSE") != "" { + logger.Println("Running target:", "{{.Name}}") + } + {{.TemplateString}} + handleError(logger, err) + {{- end}} + default: + // should be impossible since we check this above. + logger.Printf("Unknown target: %q\n", os.Args[1]) + os.Exit(1) + } + } +} + + + + +` diff --git a/vendor/github.com/magefile/mage/magefile.go b/vendor/github.com/magefile/mage/magefile.go new file mode 100644 index 0000000000..2bb3ace6fe --- /dev/null +++ b/vendor/github.com/magefile/mage/magefile.go @@ -0,0 +1,94 @@ +//+build mage + +package main + +import ( + "errors" + "fmt" + "os" + "path/filepath" + "runtime" + "strings" + "time" + + "github.com/magefile/mage/sh" +) + +// Runs "go install" for mage. This generates the version info the binary. +func Install() error { + ldf, err := flags() + if err != nil { + return err + } + + name := "mage" + if runtime.GOOS == "windows" { + name += ".exe" + } + gopath, err := sh.Output("go", "env", "GOPATH") + if err != nil { + return fmt.Errorf("can't determine GOPATH: %v", err) + } + paths := strings.Split(gopath, string([]rune{os.PathListSeparator})) + bin := filepath.Join(paths[0], "bin") + // specifically don't mkdirall, if you have an invalid gopath in the first + // place, that's not on us to fix. + if err := os.Mkdir(bin, 0700); err != nil && !os.IsExist(err) { + return fmt.Errorf("failed to create %q: %v", bin, err) + } + path := filepath.Join(bin, name) + + // we use go build here because if someone built with go get, then `go + // install` turns into a no-op, and `go install -a` fails on people's + // machines that have go installed in a non-writeable directory (such as + // normal OS installs in /usr/bin) + return sh.RunV("go", "build", "-o", path, "-ldflags="+ldf, "github.com/magefile/mage") +} + +// Generates a new release. Expects the TAG environment variable to be set, +// which will create a new tag with that name. +func Release() (err error) { + if os.Getenv("TAG") == "" { + return errors.New("MSG and TAG environment variables are required") + } + if err := sh.RunV("git", "tag", "-a", "$TAG"); err != nil { + return err + } + if err := sh.RunV("git", "push", "origin", "$TAG"); err != nil { + return err + } + defer func() { + if err != nil { + sh.RunV("git", "tag", "--delete", "$TAG") + sh.RunV("git", "push", "--delete", "origin", "$TAG") + } + }() + return sh.RunV("goreleaser") +} + +// Remove the temporarily generated files from Release. +func Clean() error { + return sh.Rm("dist") +} + +func flags() (string, error) { + timestamp := time.Now().Format(time.RFC3339) + hash := hash() + tag := tag() + if tag == "" { + tag = "dev" + } + return fmt.Sprintf(`-X "github.com/magefile/mage/mage.timestamp=%s" -X "github.com/magefile/mage/mage.commitHash=%s" -X "github.com/magefile/mage/mage.gitTag=%s"`, timestamp, hash, tag), nil +} + +// tag returns the git tag for the current branch or "" if none. +func tag() string { + s, _ := sh.Output("git", "describe", "--tags") + return s +} + +// hash returns the git hash for the current repo or "" if none. +func hash() string { + hash, _ := sh.Output("git", "rev-parse", "--short", "HEAD") + return hash +} diff --git a/vendor/github.com/magefile/mage/main.go b/vendor/github.com/magefile/mage/main.go new file mode 100644 index 0000000000..d596ac7f06 --- /dev/null +++ b/vendor/github.com/magefile/mage/main.go @@ -0,0 +1,11 @@ +package main + +import ( + "os" + + "github.com/magefile/mage/mage" +) + +func main() { + os.Exit(mage.Main()) +} diff --git a/vendor/github.com/magefile/mage/mg/deps.go b/vendor/github.com/magefile/mage/mg/deps.go new file mode 100644 index 0000000000..30d6edc419 --- /dev/null +++ b/vendor/github.com/magefile/mage/mg/deps.go @@ -0,0 +1,166 @@ +package mg + +import ( + "context" + "fmt" + "reflect" + "runtime" + "strings" + "sync" + + "github.com/magefile/mage/types" +) + +type onceMap struct { + mu *sync.Mutex + m map[string]*onceFun +} + +func (o *onceMap) LoadOrStore(s string, one *onceFun) *onceFun { + defer o.mu.Unlock() + o.mu.Lock() + + existing, ok := o.m[s] + if ok { + return existing + } + o.m[s] = one + return one +} + +var onces = &onceMap{ + mu: &sync.Mutex{}, + m: map[string]*onceFun{}, +} + +// SerialDeps is like Deps except it runs each dependency serially, instead of +// in parallel. This can be useful for resource intensive dependencies that +// shouldn't be run at the same time. +func SerialDeps(fns ...interface{}) { + checkFns(fns) + ctx := context.Background() + for _, f := range fns { + runDeps(ctx, f) + } +} + +// SerialCtxDeps is like CtxDeps except it runs each dependency serially, +// instead of in parallel. This can be useful for resource intensive +// dependencies that shouldn't be run at the same time. +func SerialCtxDeps(ctx context.Context, fns ...interface{}) { + checkFns(fns) + for _, f := range fns { + runDeps(ctx, f) + } +} + +// CtxDeps runs the given functions as dependencies of the calling function. +// Dependencies must only be of type: github.com/magefile/mage/types.FuncType. +// The function calling Deps is guaranteed that all dependent functions will be +// run exactly once when Deps returns. Dependent functions may in turn declare +// their own dependencies using Deps. Each dependency is run in their own +// goroutines. Each function is given the context provided if the function +// prototype allows for it. +func CtxDeps(ctx context.Context, fns ...interface{}) { + checkFns(fns) + runDeps(ctx, fns...) +} + +// runDeps assumes you've already called checkFns. +func runDeps(ctx context.Context, fns ...interface{}) { + mu := &sync.Mutex{} + var errs []string + var exit int + wg := &sync.WaitGroup{} + for _, f := range fns { + fn := addDep(ctx, f) + wg.Add(1) + go func() { + defer func() { + if v := recover(); v != nil { + mu.Lock() + if err, ok := v.(error); ok { + exit = changeExit(exit, ExitStatus(err)) + } else { + exit = changeExit(exit, 1) + } + errs = append(errs, fmt.Sprint(v)) + mu.Unlock() + } + wg.Done() + }() + if err := fn.run(); err != nil { + mu.Lock() + errs = append(errs, fmt.Sprint(err)) + exit = changeExit(exit, ExitStatus(err)) + mu.Unlock() + } + }() + } + + wg.Wait() + if len(errs) > 0 { + panic(Fatal(exit, strings.Join(errs, "\n"))) + } +} + +func checkFns(fns []interface{}) { + for _, f := range fns { + if err := types.FuncCheck(f); err != nil { + panic(err) + } + } +} + +// Deps runs the given functions with the default runtime context +func Deps(fns ...interface{}) { + CtxDeps(context.Background(), fns...) +} + +func changeExit(old, new int) int { + if new == 0 { + return old + } + if old == 0 { + return new + } + if old == new { + return old + } + // both different and both non-zero, just set + // exit to 1. Nothing more we can do. + return 1 +} + +func addDep(ctx context.Context, f interface{}) *onceFun { + var fn func(context.Context) error + if fn = types.FuncTypeWrap(f); fn == nil { + // should be impossible, since we already checked this + panic("attempted to add a dep that did not match required type") + } + + n := name(f) + of := onces.LoadOrStore(n, &onceFun{ + fn: fn, + ctx: ctx, + }) + return of +} + +func name(i interface{}) string { + return runtime.FuncForPC(reflect.ValueOf(i).Pointer()).Name() +} + +type onceFun struct { + once sync.Once + fn func(context.Context) error + ctx context.Context +} + +func (o *onceFun) run() error { + var err error + o.once.Do(func() { + err = o.fn(o.ctx) + }) + return err +} diff --git a/vendor/github.com/magefile/mage/mg/errors.go b/vendor/github.com/magefile/mage/mg/errors.go new file mode 100644 index 0000000000..06a869086c --- /dev/null +++ b/vendor/github.com/magefile/mage/mg/errors.go @@ -0,0 +1,51 @@ +package mg + +import ( + "errors" + "fmt" +) + +type fatalErr struct { + code int + error +} + +func (f fatalErr) ExitStatus() int { + return f.code +} + +type exitStatus interface { + ExitStatus() int +} + +// Fatal returns an error that will cause mage to print out the +// given args and exit with the given exit code. +func Fatal(code int, args ...interface{}) error { + return fatalErr{ + code: code, + error: errors.New(fmt.Sprint(args...)), + } +} + +// Fatalf returns an error that will cause mage to print out the +// given message and exit with an exit code of 1. +func Fatalf(code int, format string, args ...interface{}) error { + return fatalErr{ + code: code, + error: fmt.Errorf(format, args...), + } +} + +// ExitStatus queries the error for an exit status. If the error is nil, it +// returns 0. If the error does not implement ExitStatus() int, it returns 1. +// Otherwise it retiurns the value from ExitStatus(). +func ExitStatus(err error) int { + if err == nil { + return 0 + } + exit, ok := err.(exitStatus) + if !ok { + return 1 + } + return exit.ExitStatus() +} diff --git a/vendor/github.com/magefile/mage/mg/runtime.go b/vendor/github.com/magefile/mage/mg/runtime.go new file mode 100644 index 0000000000..8b99613d69 --- /dev/null +++ b/vendor/github.com/magefile/mage/mg/runtime.go @@ -0,0 +1,36 @@ +package mg + +import ( + "os" + "path/filepath" + "runtime" +) + +// CacheEnv is the environment variable that users may set to change the +// location where mage stores its compiled binaries. +const CacheEnv = "MAGEFILE_CACHE" + +// verboseEnv is the environment variable that indicates the user requested +// verbose mode when running a magefile. +const verboseEnv = "MAGEFILE_VERBOSE" + +// Verbose reports whether a magefile was run with the verbose flag. +func Verbose() bool { + return os.Getenv(verboseEnv) != "" +} + +// CacheDir returns the directory where mage caches compiled binaries. It +// defaults to $HOME/.magefile, but may be overridden by the MAGEFILE_CACHE +// environment variable. +func CacheDir() string { + d := os.Getenv(CacheEnv) + if d != "" { + return d + } + switch runtime.GOOS { + case "windows": + return filepath.Join(os.Getenv("HOMEDRIVE"), os.Getenv("HOMEPATH"), "magefile") + default: + return filepath.Join(os.Getenv("HOME"), ".magefile") + } +} diff --git a/vendor/github.com/magefile/mage/parse/import_go1.9.go b/vendor/github.com/magefile/mage/parse/import_go1.9.go new file mode 100644 index 0000000000..9b5c71212b --- /dev/null +++ b/vendor/github.com/magefile/mage/parse/import_go1.9.go @@ -0,0 +1,13 @@ +// +build go1.9 + +package parse + +import ( + "go/importer" + "go/token" + "go/types" +) + +func getImporter(*token.FileSet) types.Importer { + return importer.For("source", nil) +} diff --git a/vendor/github.com/magefile/mage/parse/import_not_go1.9.go b/vendor/github.com/magefile/mage/parse/import_not_go1.9.go new file mode 100644 index 0000000000..ed4e951ed3 --- /dev/null +++ b/vendor/github.com/magefile/mage/parse/import_not_go1.9.go @@ -0,0 +1,15 @@ +// +build !go1.9 + +package parse + +import ( + "go/build" + "go/token" + "go/types" + + "github.com/magefile/mage/parse/srcimporter" +) + +func getImporter(fset *token.FileSet) types.Importer { + return srcimporter.New(&build.Default, fset, make(map[string]*types.Package)) +} diff --git a/vendor/github.com/magefile/mage/parse/parse.go b/vendor/github.com/magefile/mage/parse/parse.go new file mode 100644 index 0000000000..0522629017 --- /dev/null +++ b/vendor/github.com/magefile/mage/parse/parse.go @@ -0,0 +1,341 @@ +package parse + +import ( + "fmt" + "go/ast" + "go/build" + "go/doc" + "go/parser" + "go/token" + "go/types" + "log" + "os" + "os/exec" + "strings" + + mgTypes "github.com/magefile/mage/types" +) + +type PkgInfo struct { + Funcs []Function + DefaultIsError bool + DefaultIsContext bool + DefaultName string + DefaultFunc Function + Aliases map[string]string +} + +// Function represented a job function from a mage file +type Function struct { + Name string + IsError bool + IsContext bool + Synopsis string + Comment string +} + +// TemplateString returns code for the template switch to run the target. +// It wraps each target call to match the func(context.Context) error that +// runTarget requires. +func (f Function) TemplateString() string { + if f.IsContext && f.IsError { + out := `wrapFn := func(ctx context.Context) error { + return %s(ctx) + } + err := runTarget(wrapFn)` + return fmt.Sprintf(out, f.Name) + } + if f.IsContext && !f.IsError { + out := `wrapFn := func(ctx context.Context) error { + %s(ctx) + return nil + } + err := runTarget(wrapFn)` + return fmt.Sprintf(out, f.Name) + } + if !f.IsContext && f.IsError { + out := `wrapFn := func(ctx context.Context) error { + return %s() + } + err := runTarget(wrapFn)` + return fmt.Sprintf(out, f.Name) + } + if !f.IsContext && !f.IsError { + out := `wrapFn := func(ctx context.Context) error { + %s() + return nil + } + err := runTarget(wrapFn)` + return fmt.Sprintf(out, f.Name) + } + return `fmt.Printf("Error formatting job code\n") + os.Exit(1)` +} + +// Package parses a package +func Package(path string, files []string) (*PkgInfo, error) { + fset := token.NewFileSet() + + pkg, err := getPackage(path, files, fset) + if err != nil { + return nil, err + } + + info, err := makeInfo(path, fset, pkg.Files) + if err != nil { + return nil, err + } + + pi := &PkgInfo{} + + p := doc.New(pkg, "./", 0) + for _, f := range p.Funcs { + if f.Recv != "" { + // skip methods + continue + } + if !ast.IsExported(f.Name) { + // skip non-exported functions + continue + } + if typ := voidOrError(f.Decl.Type, info); typ != mgTypes.InvalidType { + pi.Funcs = append(pi.Funcs, Function{ + Name: f.Name, + Comment: f.Doc, + Synopsis: sanitizeSynopsis(f), + IsError: typ == mgTypes.ErrorType || typ == mgTypes.ContextErrorType, + IsContext: typ == mgTypes.ContextVoidType || typ == mgTypes.ContextErrorType, + }) + } + } + + setDefault(p, pi, info) + setAliases(p, pi, info) + + return pi, nil +} + +// sanitizeSynopsis sanitizes function Doc to create a summary. +func sanitizeSynopsis(f *doc.Func) string { + synopsis := doc.Synopsis(f.Doc) + + // If the synopsis begins with the function name, remove it. This is done to + // not repeat the text. + // From: + // clean Clean removes the temporarily generated files + // To: + // clean removes the temporarily generated files + if syns := strings.Split(synopsis, " "); strings.EqualFold(f.Name, syns[0]) { + return strings.Join(syns[1:], " ") + } + + return synopsis +} + +func setDefault(p *doc.Package, pi *PkgInfo, info types.Info) { + for _, v := range p.Vars { + for x, name := range v.Names { + if name != "Default" { + continue + } + spec := v.Decl.Specs[x].(*ast.ValueSpec) + if len(spec.Values) != 1 { + log.Println("warning: default declaration has multiple values") + } + id, ok := spec.Values[0].(*ast.Ident) + if !ok { + log.Println("warning: default declaration is not a function name") + } + for _, f := range pi.Funcs { + if f.Name == id.Name { + pi.DefaultName = f.Name + pi.DefaultIsError = f.IsError + pi.DefaultIsContext = f.IsContext + pi.DefaultFunc = f + return + } + } + log.Println("warning: default declaration does not reference a mage target") + } + } +} + +func setAliases(p *doc.Package, pi *PkgInfo, info types.Info) { + for _, v := range p.Vars { + for x, name := range v.Names { + if name != "Aliases" { + continue + } + spec, ok := v.Decl.Specs[x].(*ast.ValueSpec) + if !ok { + log.Println("warning: aliases declaration is not a value") + return + } + if len(spec.Values) != 1 { + log.Println("warning: aliases declaration has multiple values") + } + comp, ok := spec.Values[0].(*ast.CompositeLit) + if !ok { + log.Println("warning: aliases declaration is not a map") + return + } + pi.Aliases = make(map[string]string) + for _, elem := range comp.Elts { + kv, ok := elem.(*ast.KeyValueExpr) + if !ok { + log.Println("warning: alias declaration is not a map element") + return + } + k, ok := kv.Key.(*ast.BasicLit) + if !ok || k.Kind != token.STRING { + log.Println("warning: alias is not a string") + return + } + v, ok := kv.Value.(*ast.Ident) + if !ok { + log.Println("warning: alias target is not a function") + return + } + alias := strings.Trim(k.Value, "\"") + valid := false + for _, f := range pi.Funcs { + valid = valid || f.Name == v.Name + } + if !valid { + log.Printf("warning: alias declaration (%s) does not reference a mage target", alias) + } + pi.Aliases[alias] = v.Name + } + return + } + } +} + +// getPackage returns the non-test package at the given path. +func getPackage(path string, files []string, fset *token.FileSet) (*ast.Package, error) { + fm := make(map[string]bool, len(files)) + for _, f := range files { + fm[f] = true + } + + filter := func(f os.FileInfo) bool { + return fm[f.Name()] + } + + pkgs, err := parser.ParseDir(fset, path, filter, parser.ParseComments) + if err != nil { + return nil, fmt.Errorf("failed to parse directory: %v", err) + } + + for name, pkg := range pkgs { + if !strings.HasSuffix(name, "_test") { + return pkg, nil + } + } + return nil, fmt.Errorf("no non-test packages found in %s", path) +} + +func makeInfo(dir string, fset *token.FileSet, files map[string]*ast.File) (types.Info, error) { + goroot := os.Getenv("GOROOT") + if goroot == "" { + c := exec.Command("go", "env", "GOROOT") + b, err := c.Output() + if err != nil { + return types.Info{}, fmt.Errorf("failed to get GOROOT from 'go env': %v", err) + } + goroot = strings.TrimSpace(string(b)) + if goroot == "" { + return types.Info{}, fmt.Errorf("could not determine GOROOT") + } + } + + build.Default.GOROOT = goroot + + cfg := types.Config{ + Importer: getImporter(fset), + } + + info := types.Info{ + Types: make(map[ast.Expr]types.TypeAndValue), + Defs: make(map[*ast.Ident]types.Object), + Uses: make(map[*ast.Ident]types.Object), + } + + fs := make([]*ast.File, 0, len(files)) + for _, v := range files { + fs = append(fs, v) + } + + _, err := cfg.Check(dir, fset, fs, &info) + if err != nil { + return info, fmt.Errorf("failed to check types in directory: %v", err) + } + return info, nil +} + +// errorOrVoid filters the list of functions to only those that return only an +// error or have no return value, and have no parameters. +func errorOrVoid(fns []*ast.FuncDecl, info types.Info) []*ast.FuncDecl { + fds := []*ast.FuncDecl{} + + for _, fn := range fns { + if voidOrError(fn.Type, info) != mgTypes.InvalidType { + fds = append(fds, fn) + } + } + return fds +} + +func hasContextParam(ft *ast.FuncType, info types.Info) bool { + if ft.Params.NumFields() == 1 { + ret := ft.Params.List[0] + t := info.TypeOf(ret.Type) + if t != nil && t.String() == "context.Context" { + return true + } + } + return false +} + +func hasVoidReturn(ft *ast.FuncType, info types.Info) bool { + res := ft.Results + if res.NumFields() == 0 { + return true + } + return false +} + +func hasErrorReturn(ft *ast.FuncType, info types.Info) bool { + res := ft.Results + if res.NumFields() == 1 { + ret := res.List[0] + if len(ret.Names) > 1 { + return false + } + t := info.TypeOf(ret.Type) + if t != nil && t.String() == "error" { + return true + } + } + return false +} + +func voidOrError(ft *ast.FuncType, info types.Info) mgTypes.FuncType { + if hasContextParam(ft, info) { + if hasVoidReturn(ft, info) { + return mgTypes.ContextVoidType + } + if hasErrorReturn(ft, info) { + return mgTypes.ContextErrorType + } + } + if ft.Params.NumFields() == 0 { + if hasVoidReturn(ft, info) { + return mgTypes.VoidType + } + if hasErrorReturn(ft, info) { + return mgTypes.ErrorType + } + } + return mgTypes.InvalidType +} diff --git a/vendor/github.com/magefile/mage/parse/srcimporter/sizes.go b/vendor/github.com/magefile/mage/parse/srcimporter/sizes.go new file mode 100644 index 0000000000..a9e1b329a0 --- /dev/null +++ b/vendor/github.com/magefile/mage/parse/srcimporter/sizes.go @@ -0,0 +1,40 @@ +// +build !go1.9 + +package srcimporter + +import "go/types" + +// common architecture word sizes and alignments +var gcArchSizes = map[string]*types.StdSizes{ + "386": {4, 4}, + "arm": {4, 4}, + "arm64": {8, 8}, + "amd64": {8, 8}, + "amd64p32": {4, 8}, + "mips": {4, 4}, + "mipsle": {4, 4}, + "mips64": {8, 8}, + "mips64le": {8, 8}, + "ppc64": {8, 8}, + "ppc64le": {8, 8}, + "s390x": {8, 8}, + // When adding more architectures here, + // update the doc string of SizesFor below. +} + +// SizesFor returns the Sizes used by a compiler for an architecture. +// The result is nil if a compiler/architecture pair is not known. +// +// Supported architectures for compiler "gc": +// "386", "arm", "arm64", "amd64", "amd64p32", "mips", "mipsle", +// "mips64", "mips64le", "ppc64", "ppc64le", "s390x". +func SizesFor(compiler, arch string) types.Sizes { + if compiler != "gc" { + return nil + } + s, ok := gcArchSizes[arch] + if !ok { + return nil + } + return s +} diff --git a/vendor/github.com/magefile/mage/parse/srcimporter/srcimporter.go b/vendor/github.com/magefile/mage/parse/srcimporter/srcimporter.go new file mode 100644 index 0000000000..a488a990c7 --- /dev/null +++ b/vendor/github.com/magefile/mage/parse/srcimporter/srcimporter.go @@ -0,0 +1,213 @@ +// +build !go1.9 + +// Copyright 2017 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. + +// Package srcimporter implements importing directly +// from source files rather than installed packages. +package srcimporter + +import ( + "fmt" + "go/ast" + "go/build" + "go/parser" + "go/token" + "go/types" + "path/filepath" + "sync" +) + +// An Importer provides the context for importing packages from source code. +type Importer struct { + ctxt *build.Context + fset *token.FileSet + sizes types.Sizes + packages map[string]*types.Package +} + +// NewImporter returns a new Importer for the given context, file set, and map +// of packages. The context is used to resolve import paths to package paths, +// and identifying the files belonging to the package. If the context provides +// non-nil file system functions, they are used instead of the regular package +// os functions. The file set is used to track position information of package +// files; and imported packages are added to the packages map. +func New(ctxt *build.Context, fset *token.FileSet, packages map[string]*types.Package) *Importer { + return &Importer{ + ctxt: ctxt, + fset: fset, + sizes: SizesFor(ctxt.Compiler, ctxt.GOARCH), // uses go/types default if GOARCH not found + packages: packages, + } +} + +// Importing is a sentinel taking the place in Importer.packages +// for a package that is in the process of being imported. +var importing types.Package + +// Import(path) is a shortcut for ImportFrom(path, "", 0). +func (p *Importer) Import(path string) (*types.Package, error) { + return p.ImportFrom(path, "", 0) +} + +// ImportFrom imports the package with the given import path resolved from the given srcDir, +// adds the new package to the set of packages maintained by the importer, and returns the +// package. Package path resolution and file system operations are controlled by the context +// maintained with the importer. The import mode must be zero but is otherwise ignored. +// Packages that are not comprised entirely of pure Go files may fail to import because the +// type checker may not be able to determine all exported entities (e.g. due to cgo dependencies). +func (p *Importer) ImportFrom(path, srcDir string, mode types.ImportMode) (*types.Package, error) { + if mode != 0 { + panic("non-zero import mode") + } + + // determine package path (do vendor resolution) + var bp *build.Package + var err error + switch { + default: + if abs, err := p.absPath(srcDir); err == nil { // see issue #14282 + srcDir = abs + } + bp, err = p.ctxt.Import(path, srcDir, build.FindOnly) + + case build.IsLocalImport(path): + // "./x" -> "srcDir/x" + bp, err = p.ctxt.ImportDir(filepath.Join(srcDir, path), build.FindOnly) + + case p.isAbsPath(path): + return nil, fmt.Errorf("invalid absolute import path %q", path) + } + if err != nil { + return nil, err // err may be *build.NoGoError - return as is + } + + // package unsafe is known to the type checker + if bp.ImportPath == "unsafe" { + return types.Unsafe, nil + } + + // no need to re-import if the package was imported completely before + pkg := p.packages[bp.ImportPath] + if pkg != nil { + if pkg == &importing { + return nil, fmt.Errorf("import cycle through package %q", bp.ImportPath) + } + if !pkg.Complete() { + // Package exists but is not complete - we cannot handle this + // at the moment since the source importer replaces the package + // wholesale rather than augmenting it (see #19337 for details). + // Return incomplete package with error (see #16088). + return pkg, fmt.Errorf("reimported partially imported package %q", bp.ImportPath) + } + return pkg, nil + } + + p.packages[bp.ImportPath] = &importing + defer func() { + // clean up in case of error + // TODO(gri) Eventually we may want to leave a (possibly empty) + // package in the map in all cases (and use that package to + // identify cycles). See also issue 16088. + if p.packages[bp.ImportPath] == &importing { + p.packages[bp.ImportPath] = nil + } + }() + + // collect package files + bp, err = p.ctxt.ImportDir(bp.Dir, 0) + if err != nil { + return nil, err // err may be *build.NoGoError - return as is + } + var filenames []string + filenames = append(filenames, bp.GoFiles...) + filenames = append(filenames, bp.CgoFiles...) + + files, err := p.parseFiles(bp.Dir, filenames) + if err != nil { + return nil, err + } + + // type-check package files + conf := types.Config{ + IgnoreFuncBodies: true, + FakeImportC: true, + Importer: p, + Sizes: p.sizes, + } + pkg, err = conf.Check(bp.ImportPath, p.fset, files, nil) + if err != nil { + // Type-checking stops after the first error (types.Config.Error is not set), + // so the returned package is very likely incomplete. Don't return it since + // we don't know its condition: It's very likely unsafe to use and it's also + // not added to p.packages which may cause further problems (issue #20837). + return nil, fmt.Errorf("type-checking package %q failed (%v)", bp.ImportPath, err) + } + + p.packages[bp.ImportPath] = pkg + return pkg, nil +} + +func (p *Importer) parseFiles(dir string, filenames []string) ([]*ast.File, error) { + open := p.ctxt.OpenFile // possibly nil + + files := make([]*ast.File, len(filenames)) + errors := make([]error, len(filenames)) + + var wg sync.WaitGroup + wg.Add(len(filenames)) + for i, filename := range filenames { + go func(i int, filepath string) { + defer wg.Done() + if open != nil { + src, err := open(filepath) + if err != nil { + errors[i] = fmt.Errorf("opening package file %s failed (%v)", filepath, err) + return + } + files[i], errors[i] = parser.ParseFile(p.fset, filepath, src, 0) + src.Close() // ignore Close error - parsing may have succeeded which is all we need + } else { + // Special-case when ctxt doesn't provide a custom OpenFile and use the + // parser's file reading mechanism directly. This appears to be quite a + // bit faster than opening the file and providing an io.ReaderCloser in + // both cases. + // TODO(gri) investigate performance difference (issue #19281) + files[i], errors[i] = parser.ParseFile(p.fset, filepath, nil, 0) + } + }(i, p.joinPath(dir, filename)) + } + wg.Wait() + + // if there are errors, return the first one for deterministic results + for _, err := range errors { + if err != nil { + return nil, err + } + } + + return files, nil +} + +// context-controlled file system operations + +func (p *Importer) absPath(path string) (string, error) { + // TODO(gri) This should be using p.ctxt.AbsPath which doesn't + // exist but probably should. See also issue #14282. + return filepath.Abs(path) +} + +func (p *Importer) isAbsPath(path string) bool { + if f := p.ctxt.IsAbsPath; f != nil { + return f(path) + } + return filepath.IsAbs(path) +} + +func (p *Importer) joinPath(elem ...string) string { + if f := p.ctxt.JoinPath; f != nil { + return f(elem...) + } + return filepath.Join(elem...) +} diff --git a/vendor/github.com/magefile/mage/sh/cmd.go b/vendor/github.com/magefile/mage/sh/cmd.go new file mode 100644 index 0000000000..23fc37228e --- /dev/null +++ b/vendor/github.com/magefile/mage/sh/cmd.go @@ -0,0 +1,165 @@ +package sh + +import ( + "bytes" + "fmt" + "io" + "log" + "os" + "os/exec" + "strings" + + "github.com/magefile/mage/mg" +) + +// RunCmd returns a function that will call Run with the given command. This is +// useful for creating command aliases to make your scripts easier to read, like +// this: +// +// // in a helper file somewhere +// var g0 = sh.RunCmd("go") // go is a keyword :( +// +// // somewhere in your main code +// if err := g0("install", "github.com/gohugo/hugo"); err != nil { +// return err +// } +// +// Args passed to command get baked in as args to the command when you run it. +// Any args passed in when you run the returned function will be appended to the +// original args. For example, this is equivalent to the above: +// +// var goInstall = sh.RunCmd("go", "install") goInstall("github.com/gohugo/hugo") +// +// RunCmd uses Exec underneath, so see those docs for more details. +func RunCmd(cmd string, args ...string) func(args ...string) error { + return func(args2 ...string) error { + return Run(cmd, append(args, args2...)...) + } +} + +// OutCmd is like RunCmd except the command returns the output of the +// command. +func OutCmd(cmd string, args ...string) func(args ...string) (string, error) { + return func(args2 ...string) (string, error) { + return Output(cmd, append(args, args2...)...) + } +} + +// Run is like RunWith, but doesn't specify any environment variables. +func Run(cmd string, args ...string) error { + return RunWith(nil, cmd, args...) +} + +// RunV is like Run, but always sends the command's stdout to os.Stdout. +func RunV(cmd string, args ...string) error { + _, err := Exec(nil, os.Stdout, os.Stderr, cmd, args...) + return err +} + +// RunWith runs the given command, directing stderr to this program's stderr and +// printing stdout to stdout if mage was run with -v. It adds adds env to the +// environment variables for the command being run. Environment variables should +// be in the format name=value. +func RunWith(env map[string]string, cmd string, args ...string) error { + var output io.Writer + if mg.Verbose() { + output = os.Stdout + } + _, err := Exec(env, output, os.Stderr, cmd, args...) + return err +} + +// Output runs the command and returns the text from stdout. +func Output(cmd string, args ...string) (string, error) { + buf := &bytes.Buffer{} + _, err := Exec(nil, buf, os.Stderr, cmd, args...) + return strings.TrimSuffix(buf.String(), "\n"), err +} + +// OutputWith is like RunWith, ubt returns what is written to stdout. +func OutputWith(env map[string]string, cmd string, args ...string) (string, error) { + buf := &bytes.Buffer{} + _, err := Exec(env, buf, os.Stderr, cmd, args...) + return strings.TrimSuffix(buf.String(), "\n"), err +} + +// Exec executes the command, piping its stderr to mage's stderr and +// piping its stdout to the given writer. If the command fails, it will return +// an error that, if returned from a target or mg.Deps call, will cause mage to +// exit with the same code as the command failed with. Env is a list of +// environment variables to set when running the command, these override the +// current environment variables set (which are also passed to the command). cmd +// and args may include references to environment variables in $FOO format, in +// which case these will be expanded before the command is run. +// +// Ran reports if the command ran (rather than was not found or not executable). +// Code reports the exit code the command returned if it ran. If err == nil, ran +// is always true and code is always 0. +func Exec(env map[string]string, stdout, stderr io.Writer, cmd string, args ...string) (ran bool, err error) { + expand := func(s string) string { + s2, ok := env[s] + if ok { + return s2 + } + return os.Getenv(s) + } + cmd = os.Expand(cmd, expand) + for i := range args { + args[i] = os.Expand(args[i], expand) + } + ran, code, err := run(env, stdout, stderr, cmd, args...) + if err == nil { + return true, nil + } + if ran { + return ran, mg.Fatalf(code, `running "%s %s" failed with exit code %d`, cmd, strings.Join(args, " "), code) + } + return ran, fmt.Errorf(`failed to run "%s %s: %v"`, cmd, strings.Join(args, " "), err) +} + +func run(env map[string]string, stdout, stderr io.Writer, cmd string, args ...string) (ran bool, code int, err error) { + c := exec.Command(cmd, args...) + c.Env = os.Environ() + for k, v := range env { + c.Env = append(c.Env, k+"="+v) + } + c.Stderr = stderr + c.Stdout = stdout + c.Stdin = os.Stdin + log.Println("exec:", cmd, strings.Join(args, " ")) + err = c.Run() + return cmdRan(err), ExitStatus(err), err +} + +func cmdRan(err error) bool { + if err == nil { + return true + } + ee, ok := err.(*exec.ExitError) + if ok { + return ee.Exited() + } + return false +} + +type exitStatus interface { + ExitStatus() int +} + +// ExitStatus returns the exit status of the error if it is an exec.ExitError +// or if it implements ExitStatus() int. +// 0 if it is nil or 1 if it is a different error. +func ExitStatus(err error) int { + if err == nil { + return 0 + } + if e, ok := err.(exitStatus); ok { + return e.ExitStatus() + } + if e, ok := err.(*exec.ExitError); ok { + if ex, ok := e.Sys().(exitStatus); ok { + return ex.ExitStatus() + } + } + return 1 +} diff --git a/vendor/github.com/magefile/mage/sh/helpers.go b/vendor/github.com/magefile/mage/sh/helpers.go new file mode 100644 index 0000000000..86b075ef2c --- /dev/null +++ b/vendor/github.com/magefile/mage/sh/helpers.go @@ -0,0 +1,16 @@ +package sh + +import ( + "fmt" + "os" +) + +// Rm removes the given file or directory even if non-empty. It will not return +// an error if the target doesn't exist, only if the target cannot be removed. +func Rm(path string) error { + err := os.RemoveAll(path) + if err == nil || os.IsNotExist(err) { + return nil + } + return fmt.Errorf(`failed to remove %s: %v`, path, err) +} diff --git a/vendor/github.com/magefile/mage/target/target.go b/vendor/github.com/magefile/mage/target/target.go new file mode 100644 index 0000000000..a2866e92fa --- /dev/null +++ b/vendor/github.com/magefile/mage/target/target.go @@ -0,0 +1,122 @@ +package target + +import ( + "os" + "path/filepath" + "time" +) + +// Path reports if any of the sources have been modified more recently +// than the destination. Path does not descend into directories, it literally +// just checks the modtime of each thing you pass to it. +func Path(dst string, sources ...string) (bool, error) { + stat, err := os.Stat(dst) + if err != nil { + return false, err + } + srcTime := stat.ModTime() + dt, err := loadTargets(sources) + if err != nil { + return false, err + } + t := dt.modTime() + if t.After(srcTime) { + return true, nil + } + return false, nil +} + +// Dir reports whether any of the sources have been modified +// more recently than the destination. If a source or destination is +// a directory, modtimes of files under those directories are compared +// instead. +func Dir(dst string, sources ...string) (bool, error) { + stat, err := os.Stat(dst) + if err != nil { + return false, err + } + srcTime := stat.ModTime() + if stat.IsDir() { + srcTime, err = calDirModTimeRecursive(stat) + if err != nil { + return false, err + } + } + dt, err := loadTargets(sources) + if err != nil { + return false, err + } + t, err := dt.modTimeDir() + if err != nil { + return false, err + } + if t.After(srcTime) { + return true, nil + } + return false, nil +} + +func calDirModTimeRecursive(dir os.FileInfo) (time.Time, error) { + t := dir.ModTime() + ferr := filepath.Walk(dir.Name(), func(path string, info os.FileInfo, err error) error { + if err != nil { + return err + } + if info.ModTime().After(t) { + t = info.ModTime() + } + return nil + }) + if ferr != nil { + return time.Time{}, ferr + } + return t, nil +} + +type depTargets struct { + src []os.FileInfo + hasdir bool + latest time.Time +} + +func loadTargets(targets []string) (*depTargets, error) { + d := &depTargets{} + for _, v := range targets { + stat, err := os.Stat(v) + if err != nil { + return nil, err + } + if stat.IsDir() { + d.hasdir = true + } + d.src = append(d.src, stat) + if stat.ModTime().After(d.latest) { + d.latest = stat.ModTime() + } + } + return d, nil +} + +func (d *depTargets) modTime() time.Time { + return d.latest +} + +func (d *depTargets) modTimeDir() (time.Time, error) { + if !d.hasdir { + return d.latest, nil + } + var err error + for _, i := range d.src { + t := i.ModTime() + if i.IsDir() { + t, err = calDirModTimeRecursive(i) + if err != nil { + return time.Time{}, err + } + } + if t.After(d.latest) { + d.latest = t + } + } + return d.latest, nil +} diff --git a/vendor/github.com/magefile/mage/types/funcs.go b/vendor/github.com/magefile/mage/types/funcs.go new file mode 100644 index 0000000000..9e2e1331b3 --- /dev/null +++ b/vendor/github.com/magefile/mage/types/funcs.go @@ -0,0 +1,58 @@ +package types + +import ( + "context" + "fmt" +) + +// FuncType indicates a prototype of build job function +type FuncType int + +// FuncTypes +const ( + InvalidType FuncType = iota + VoidType + ErrorType + ContextVoidType + ContextErrorType +) + +// FuncCheck tests if a function is one of FuncType +func FuncCheck(fn interface{}) error { + switch fn.(type) { + case func(): + return nil + case func() error: + return nil + case func(context.Context): + return nil + case func(context.Context) error: + return nil + } + return fmt.Errorf("Invalid type for dependent function: %T. Dependencies must be func(), func() error, func(context.Context) or func(context.Context) error", fn) +} + +// FuncTypeWrap wraps a valid FuncType to FuncContextError +func FuncTypeWrap(fn interface{}) func(context.Context) error { + if FuncCheck(fn) == nil { + switch f := fn.(type) { + case func(): + return func(context.Context) error { + f() + return nil + } + case func() error: + return func(context.Context) error { + return f() + } + case func(context.Context): + return func(ctx context.Context) error { + f(ctx) + return nil + } + case func(context.Context) error: + return f + } + } + return nil +} diff --git a/vendor/golang.org/x/tools/LICENSE b/vendor/golang.org/x/tools/LICENSE new file mode 100644 index 0000000000..6a66aea5ea --- /dev/null +++ b/vendor/golang.org/x/tools/LICENSE @@ -0,0 +1,27 @@ +Copyright (c) 2009 The Go Authors. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the following disclaimer +in the documentation and/or other materials provided with the +distribution. + * Neither the name of Google Inc. nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/vendor/golang.org/x/tools/PATENTS b/vendor/golang.org/x/tools/PATENTS new file mode 100644 index 0000000000..733099041f --- /dev/null +++ b/vendor/golang.org/x/tools/PATENTS @@ -0,0 +1,22 @@ +Additional IP Rights Grant (Patents) + +"This implementation" means the copyrightable works distributed by +Google as part of the Go project. + +Google hereby grants to You a perpetual, worldwide, non-exclusive, +no-charge, royalty-free, irrevocable (except as stated in this section) +patent license to make, have made, use, offer to sell, sell, import, +transfer and otherwise run, modify and propagate the contents of this +implementation of Go, where such license applies only to those patent +claims, both currently owned or controlled by Google and acquired in +the future, licensable by Google that are necessarily infringed by this +implementation of Go. This grant does not include claims that would be +infringed only as a consequence of further modification of this +implementation. If you or your agent or exclusive licensee institute or +order or agree to the institution of patent litigation against any +entity (including a cross-claim or counterclaim in a lawsuit) alleging +that this implementation of Go or any code incorporated within this +implementation of Go constitutes direct or contributory patent +infringement, or inducement of patent infringement, then any patent +rights granted to you under this License for this implementation of Go +shall terminate as of the date such litigation is filed. diff --git a/vendor/golang.org/x/tools/go/vcs/discovery.go b/vendor/golang.org/x/tools/go/vcs/discovery.go new file mode 100644 index 0000000000..f431dc1c5b --- /dev/null +++ b/vendor/golang.org/x/tools/go/vcs/discovery.go @@ -0,0 +1,76 @@ +// Copyright 2012 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. + +package vcs + +import ( + "encoding/xml" + "fmt" + "io" + "strings" +) + +// charsetReader returns a reader for the given charset. Currently +// it only supports UTF-8 and ASCII. Otherwise, it returns a meaningful +// error which is printed by go get, so the user can find why the package +// wasn't downloaded if the encoding is not supported. Note that, in +// order to reduce potential errors, ASCII is treated as UTF-8 (i.e. characters +// greater than 0x7f are not rejected). +func charsetReader(charset string, input io.Reader) (io.Reader, error) { + switch strings.ToLower(charset) { + case "ascii": + return input, nil + default: + return nil, fmt.Errorf("can't decode XML document using charset %q", charset) + } +} + +// parseMetaGoImports returns meta imports from the HTML in r. +// Parsing ends at the end of the section or the beginning of the . +func parseMetaGoImports(r io.Reader) (imports []metaImport, err error) { + d := xml.NewDecoder(r) + d.CharsetReader = charsetReader + d.Strict = false + var t xml.Token + for { + t, err = d.Token() + if err != nil { + if err == io.EOF || len(imports) > 0 { + err = nil + } + return + } + if e, ok := t.(xml.StartElement); ok && strings.EqualFold(e.Name.Local, "body") { + return + } + if e, ok := t.(xml.EndElement); ok && strings.EqualFold(e.Name.Local, "head") { + return + } + e, ok := t.(xml.StartElement) + if !ok || !strings.EqualFold(e.Name.Local, "meta") { + continue + } + if attrValue(e.Attr, "name") != "go-import" { + continue + } + if f := strings.Fields(attrValue(e.Attr, "content")); len(f) == 3 { + imports = append(imports, metaImport{ + Prefix: f[0], + VCS: f[1], + RepoRoot: f[2], + }) + } + } +} + +// attrValue returns the attribute value for the case-insensitive key +// `name', or the empty string if nothing is found. +func attrValue(attrs []xml.Attr, name string) string { + for _, a := range attrs { + if strings.EqualFold(a.Name.Local, name) { + return a.Value + } + } + return "" +} diff --git a/vendor/golang.org/x/tools/go/vcs/env.go b/vendor/golang.org/x/tools/go/vcs/env.go new file mode 100644 index 0000000000..e846f5b3b8 --- /dev/null +++ b/vendor/golang.org/x/tools/go/vcs/env.go @@ -0,0 +1,39 @@ +// Copyright 2013 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. + +package vcs + +import ( + "os" + "strings" +) + +// envForDir returns a copy of the environment +// suitable for running in the given directory. +// The environment is the current process's environment +// but with an updated $PWD, so that an os.Getwd in the +// child will be faster. +func envForDir(dir string) []string { + env := os.Environ() + // Internally we only use rooted paths, so dir is rooted. + // Even if dir is not rooted, no harm done. + return mergeEnvLists([]string{"PWD=" + dir}, env) +} + +// mergeEnvLists merges the two environment lists such that +// variables with the same name in "in" replace those in "out". +func mergeEnvLists(in, out []string) []string { +NextVar: + for _, inkv := range in { + k := strings.SplitAfterN(inkv, "=", 2)[0] + for i, outkv := range out { + if strings.HasPrefix(outkv, k) { + out[i] = inkv + continue NextVar + } + } + out = append(out, inkv) + } + return out +} diff --git a/vendor/golang.org/x/tools/go/vcs/http.go b/vendor/golang.org/x/tools/go/vcs/http.go new file mode 100644 index 0000000000..96188185cb --- /dev/null +++ b/vendor/golang.org/x/tools/go/vcs/http.go @@ -0,0 +1,80 @@ +// Copyright 2012 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. + +package vcs + +import ( + "fmt" + "io" + "io/ioutil" + "log" + "net/http" + "net/url" +) + +// httpClient is the default HTTP client, but a variable so it can be +// changed by tests, without modifying http.DefaultClient. +var httpClient = http.DefaultClient + +// httpGET returns the data from an HTTP GET request for the given URL. +func httpGET(url string) ([]byte, error) { + resp, err := httpClient.Get(url) + if err != nil { + return nil, err + } + defer resp.Body.Close() + if resp.StatusCode != 200 { + return nil, fmt.Errorf("%s: %s", url, resp.Status) + } + b, err := ioutil.ReadAll(resp.Body) + if err != nil { + return nil, fmt.Errorf("%s: %v", url, err) + } + return b, nil +} + +// httpsOrHTTP returns the body of either the importPath's +// https resource or, if unavailable, the http resource. +func httpsOrHTTP(importPath string) (urlStr string, body io.ReadCloser, err error) { + fetch := func(scheme string) (urlStr string, res *http.Response, err error) { + u, err := url.Parse(scheme + "://" + importPath) + if err != nil { + return "", nil, err + } + u.RawQuery = "go-get=1" + urlStr = u.String() + if Verbose { + log.Printf("Fetching %s", urlStr) + } + res, err = httpClient.Get(urlStr) + return + } + closeBody := func(res *http.Response) { + if res != nil { + res.Body.Close() + } + } + urlStr, res, err := fetch("https") + if err != nil || res.StatusCode != 200 { + if Verbose { + if err != nil { + log.Printf("https fetch failed.") + } else { + log.Printf("ignoring https fetch with status code %d", res.StatusCode) + } + } + closeBody(res) + urlStr, res, err = fetch("http") + } + if err != nil { + closeBody(res) + return "", nil, err + } + // Note: accepting a non-200 OK here, so people can serve a + // meta import in their http 404 page. + if Verbose { + log.Printf("Parsing meta tags from %s (status code %d)", urlStr, res.StatusCode) + } + return urlStr, res.Body, nil +} diff --git a/vendor/golang.org/x/tools/go/vcs/vcs.go b/vendor/golang.org/x/tools/go/vcs/vcs.go new file mode 100644 index 0000000000..114665aad0 --- /dev/null +++ b/vendor/golang.org/x/tools/go/vcs/vcs.go @@ -0,0 +1,768 @@ +// Copyright 2012 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. + +// Package vcs exposes functions for resolving import paths +// and using version control systems, which can be used to +// implement behavior similar to the standard "go get" command. +// +// This package is a copy of internal code in package cmd/go/internal/get, +// modified to make the identifiers exported. It's provided here +// for developers who want to write tools with similar semantics. +// It needs to be manually kept in sync with upstream when changes are +// made to cmd/go/internal/get; see https://golang.org/issues/11490. +// +package vcs // import "golang.org/x/tools/go/vcs" + +import ( + "bytes" + "encoding/json" + "errors" + "fmt" + "log" + "net/url" + "os" + "os/exec" + "path/filepath" + "regexp" + "strconv" + "strings" +) + +// Verbose enables verbose operation logging. +var Verbose bool + +// ShowCmd controls whether VCS commands are printed. +var ShowCmd bool + +// A Cmd describes how to use a version control system +// like Mercurial, Git, or Subversion. +type Cmd struct { + Name string + Cmd string // name of binary to invoke command + + CreateCmd string // command to download a fresh copy of a repository + DownloadCmd string // command to download updates into an existing repository + + TagCmd []TagCmd // commands to list tags + TagLookupCmd []TagCmd // commands to lookup tags before running tagSyncCmd + TagSyncCmd string // command to sync to specific tag + TagSyncDefault string // command to sync to default tag + + LogCmd string // command to list repository changelogs in an XML format + + Scheme []string + PingCmd string +} + +// A TagCmd describes a command to list available tags +// that can be passed to Cmd.TagSyncCmd. +type TagCmd struct { + Cmd string // command to list tags + Pattern string // regexp to extract tags from list +} + +// vcsList lists the known version control systems +var vcsList = []*Cmd{ + vcsHg, + vcsGit, + vcsSvn, + vcsBzr, +} + +// ByCmd returns the version control system for the given +// command name (hg, git, svn, bzr). +func ByCmd(cmd string) *Cmd { + for _, vcs := range vcsList { + if vcs.Cmd == cmd { + return vcs + } + } + return nil +} + +// vcsHg describes how to use Mercurial. +var vcsHg = &Cmd{ + Name: "Mercurial", + Cmd: "hg", + + CreateCmd: "clone -U {repo} {dir}", + DownloadCmd: "pull", + + // We allow both tag and branch names as 'tags' + // for selecting a version. This lets people have + // a go.release.r60 branch and a go1 branch + // and make changes in both, without constantly + // editing .hgtags. + TagCmd: []TagCmd{ + {"tags", `^(\S+)`}, + {"branches", `^(\S+)`}, + }, + TagSyncCmd: "update -r {tag}", + TagSyncDefault: "update default", + + LogCmd: "log --encoding=utf-8 --limit={limit} --template={template}", + + Scheme: []string{"https", "http", "ssh"}, + PingCmd: "identify {scheme}://{repo}", +} + +// vcsGit describes how to use Git. +var vcsGit = &Cmd{ + Name: "Git", + Cmd: "git", + + CreateCmd: "clone {repo} {dir}", + DownloadCmd: "pull --ff-only", + + TagCmd: []TagCmd{ + // tags/xxx matches a git tag named xxx + // origin/xxx matches a git branch named xxx on the default remote repository + {"show-ref", `(?:tags|origin)/(\S+)$`}, + }, + TagLookupCmd: []TagCmd{ + {"show-ref tags/{tag} origin/{tag}", `((?:tags|origin)/\S+)$`}, + }, + TagSyncCmd: "checkout {tag}", + TagSyncDefault: "checkout master", + + Scheme: []string{"git", "https", "http", "git+ssh"}, + PingCmd: "ls-remote {scheme}://{repo}", +} + +// vcsBzr describes how to use Bazaar. +var vcsBzr = &Cmd{ + Name: "Bazaar", + Cmd: "bzr", + + CreateCmd: "branch {repo} {dir}", + + // Without --overwrite bzr will not pull tags that changed. + // Replace by --overwrite-tags after http://pad.lv/681792 goes in. + DownloadCmd: "pull --overwrite", + + TagCmd: []TagCmd{{"tags", `^(\S+)`}}, + TagSyncCmd: "update -r {tag}", + TagSyncDefault: "update -r revno:-1", + + Scheme: []string{"https", "http", "bzr", "bzr+ssh"}, + PingCmd: "info {scheme}://{repo}", +} + +// vcsSvn describes how to use Subversion. +var vcsSvn = &Cmd{ + Name: "Subversion", + Cmd: "svn", + + CreateCmd: "checkout {repo} {dir}", + DownloadCmd: "update", + + // There is no tag command in subversion. + // The branch information is all in the path names. + + LogCmd: "log --xml --limit={limit}", + + Scheme: []string{"https", "http", "svn", "svn+ssh"}, + PingCmd: "info {scheme}://{repo}", +} + +func (v *Cmd) String() string { + return v.Name +} + +// run runs the command line cmd in the given directory. +// keyval is a list of key, value pairs. run expands +// instances of {key} in cmd into value, but only after +// splitting cmd into individual arguments. +// If an error occurs, run prints the command line and the +// command's combined stdout+stderr to standard error. +// Otherwise run discards the command's output. +func (v *Cmd) run(dir string, cmd string, keyval ...string) error { + _, err := v.run1(dir, cmd, keyval, true) + return err +} + +// runVerboseOnly is like run but only generates error output to standard error in verbose mode. +func (v *Cmd) runVerboseOnly(dir string, cmd string, keyval ...string) error { + _, err := v.run1(dir, cmd, keyval, false) + return err +} + +// runOutput is like run but returns the output of the command. +func (v *Cmd) runOutput(dir string, cmd string, keyval ...string) ([]byte, error) { + return v.run1(dir, cmd, keyval, true) +} + +// run1 is the generalized implementation of run and runOutput. +func (v *Cmd) run1(dir string, cmdline string, keyval []string, verbose bool) ([]byte, error) { + m := make(map[string]string) + for i := 0; i < len(keyval); i += 2 { + m[keyval[i]] = keyval[i+1] + } + args := strings.Fields(cmdline) + for i, arg := range args { + args[i] = expand(m, arg) + } + + _, err := exec.LookPath(v.Cmd) + if err != nil { + fmt.Fprintf(os.Stderr, + "go: missing %s command. See http://golang.org/s/gogetcmd\n", + v.Name) + return nil, err + } + + cmd := exec.Command(v.Cmd, args...) + cmd.Dir = dir + cmd.Env = envForDir(cmd.Dir) + if ShowCmd { + fmt.Printf("cd %s\n", dir) + fmt.Printf("%s %s\n", v.Cmd, strings.Join(args, " ")) + } + var buf bytes.Buffer + cmd.Stdout = &buf + cmd.Stderr = &buf + err = cmd.Run() + out := buf.Bytes() + if err != nil { + if verbose || Verbose { + fmt.Fprintf(os.Stderr, "# cd %s; %s %s\n", dir, v.Cmd, strings.Join(args, " ")) + os.Stderr.Write(out) + } + return nil, err + } + return out, nil +} + +// Ping pings the repo to determine if scheme used is valid. +// This repo must be pingable with this scheme and VCS. +func (v *Cmd) Ping(scheme, repo string) error { + return v.runVerboseOnly(".", v.PingCmd, "scheme", scheme, "repo", repo) +} + +// Create creates a new copy of repo in dir. +// The parent of dir must exist; dir must not. +func (v *Cmd) Create(dir, repo string) error { + return v.run(".", v.CreateCmd, "dir", dir, "repo", repo) +} + +// CreateAtRev creates a new copy of repo in dir at revision rev. +// The parent of dir must exist; dir must not. +// rev must be a valid revision in repo. +func (v *Cmd) CreateAtRev(dir, repo, rev string) error { + if err := v.Create(dir, repo); err != nil { + return err + } + return v.run(dir, v.TagSyncCmd, "tag", rev) +} + +// Download downloads any new changes for the repo in dir. +// dir must be a valid VCS repo compatible with v. +func (v *Cmd) Download(dir string) error { + return v.run(dir, v.DownloadCmd) +} + +// Tags returns the list of available tags for the repo in dir. +// dir must be a valid VCS repo compatible with v. +func (v *Cmd) Tags(dir string) ([]string, error) { + var tags []string + for _, tc := range v.TagCmd { + out, err := v.runOutput(dir, tc.Cmd) + if err != nil { + return nil, err + } + re := regexp.MustCompile(`(?m-s)` + tc.Pattern) + for _, m := range re.FindAllStringSubmatch(string(out), -1) { + tags = append(tags, m[1]) + } + } + return tags, nil +} + +// TagSync syncs the repo in dir to the named tag, which is either a +// tag returned by Tags or the empty string (the default tag). +// dir must be a valid VCS repo compatible with v and the tag must exist. +func (v *Cmd) TagSync(dir, tag string) error { + if v.TagSyncCmd == "" { + return nil + } + if tag != "" { + for _, tc := range v.TagLookupCmd { + out, err := v.runOutput(dir, tc.Cmd, "tag", tag) + if err != nil { + return err + } + re := regexp.MustCompile(`(?m-s)` + tc.Pattern) + m := re.FindStringSubmatch(string(out)) + if len(m) > 1 { + tag = m[1] + break + } + } + } + if tag == "" && v.TagSyncDefault != "" { + return v.run(dir, v.TagSyncDefault) + } + return v.run(dir, v.TagSyncCmd, "tag", tag) +} + +// Log logs the changes for the repo in dir. +// dir must be a valid VCS repo compatible with v. +func (v *Cmd) Log(dir, logTemplate string) ([]byte, error) { + if err := v.Download(dir); err != nil { + return []byte{}, err + } + + const N = 50 // how many revisions to grab + return v.runOutput(dir, v.LogCmd, "limit", strconv.Itoa(N), "template", logTemplate) +} + +// LogAtRev logs the change for repo in dir at the rev revision. +// dir must be a valid VCS repo compatible with v. +// rev must be a valid revision for the repo in dir. +func (v *Cmd) LogAtRev(dir, rev, logTemplate string) ([]byte, error) { + if err := v.Download(dir); err != nil { + return []byte{}, err + } + + // Append revision flag to LogCmd. + logAtRevCmd := v.LogCmd + " --rev=" + rev + return v.runOutput(dir, logAtRevCmd, "limit", strconv.Itoa(1), "template", logTemplate) +} + +// A vcsPath describes how to convert an import path into a +// version control system and repository name. +type vcsPath struct { + prefix string // prefix this description applies to + re string // pattern for import path + repo string // repository to use (expand with match of re) + vcs string // version control system to use (expand with match of re) + check func(match map[string]string) error // additional checks + ping bool // ping for scheme to use to download repo + + regexp *regexp.Regexp // cached compiled form of re +} + +// FromDir inspects dir and its parents to determine the +// version control system and code repository to use. +// On return, root is the import path +// corresponding to the root of the repository. +func FromDir(dir, srcRoot string) (vcs *Cmd, root string, err error) { + // Clean and double-check that dir is in (a subdirectory of) srcRoot. + dir = filepath.Clean(dir) + srcRoot = filepath.Clean(srcRoot) + if len(dir) <= len(srcRoot) || dir[len(srcRoot)] != filepath.Separator { + return nil, "", fmt.Errorf("directory %q is outside source root %q", dir, srcRoot) + } + + var vcsRet *Cmd + var rootRet string + + origDir := dir + for len(dir) > len(srcRoot) { + for _, vcs := range vcsList { + if _, err := os.Stat(filepath.Join(dir, "."+vcs.Cmd)); err == nil { + root := filepath.ToSlash(dir[len(srcRoot)+1:]) + // Record first VCS we find, but keep looking, + // to detect mistakes like one kind of VCS inside another. + if vcsRet == nil { + vcsRet = vcs + rootRet = root + continue + } + // Allow .git inside .git, which can arise due to submodules. + if vcsRet == vcs && vcs.Cmd == "git" { + continue + } + // Otherwise, we have one VCS inside a different VCS. + return nil, "", fmt.Errorf("directory %q uses %s, but parent %q uses %s", + filepath.Join(srcRoot, rootRet), vcsRet.Cmd, filepath.Join(srcRoot, root), vcs.Cmd) + } + } + + // Move to parent. + ndir := filepath.Dir(dir) + if len(ndir) >= len(dir) { + // Shouldn't happen, but just in case, stop. + break + } + dir = ndir + } + + if vcsRet != nil { + return vcsRet, rootRet, nil + } + + return nil, "", fmt.Errorf("directory %q is not using a known version control system", origDir) +} + +// RepoRoot represents a version control system, a repo, and a root of +// where to put it on disk. +type RepoRoot struct { + VCS *Cmd + + // Repo is the repository URL, including scheme. + Repo string + + // Root is the import path corresponding to the root of the + // repository. + Root string +} + +// RepoRootForImportPath analyzes importPath to determine the +// version control system, and code repository to use. +func RepoRootForImportPath(importPath string, verbose bool) (*RepoRoot, error) { + rr, err := RepoRootForImportPathStatic(importPath, "") + if err == errUnknownSite { + rr, err = RepoRootForImportDynamic(importPath, verbose) + + // RepoRootForImportDynamic returns error detail + // that is irrelevant if the user didn't intend to use a + // dynamic import in the first place. + // Squelch it. + if err != nil { + if Verbose { + log.Printf("import %q: %v", importPath, err) + } + err = fmt.Errorf("unrecognized import path %q", importPath) + } + } + + if err == nil && strings.Contains(importPath, "...") && strings.Contains(rr.Root, "...") { + // Do not allow wildcards in the repo root. + rr = nil + err = fmt.Errorf("cannot expand ... in %q", importPath) + } + return rr, err +} + +var errUnknownSite = errors.New("dynamic lookup required to find mapping") + +// RepoRootForImportPathStatic attempts to map importPath to a +// RepoRoot using the commonly-used VCS hosting sites in vcsPaths +// (github.com/user/dir), or from a fully-qualified importPath already +// containing its VCS type (foo.com/repo.git/dir) +// +// If scheme is non-empty, that scheme is forced. +func RepoRootForImportPathStatic(importPath, scheme string) (*RepoRoot, error) { + if strings.Contains(importPath, "://") { + return nil, fmt.Errorf("invalid import path %q", importPath) + } + for _, srv := range vcsPaths { + if !strings.HasPrefix(importPath, srv.prefix) { + continue + } + m := srv.regexp.FindStringSubmatch(importPath) + if m == nil { + if srv.prefix != "" { + return nil, fmt.Errorf("invalid %s import path %q", srv.prefix, importPath) + } + continue + } + + // Build map of named subexpression matches for expand. + match := map[string]string{ + "prefix": srv.prefix, + "import": importPath, + } + for i, name := range srv.regexp.SubexpNames() { + if name != "" && match[name] == "" { + match[name] = m[i] + } + } + if srv.vcs != "" { + match["vcs"] = expand(match, srv.vcs) + } + if srv.repo != "" { + match["repo"] = expand(match, srv.repo) + } + if srv.check != nil { + if err := srv.check(match); err != nil { + return nil, err + } + } + vcs := ByCmd(match["vcs"]) + if vcs == nil { + return nil, fmt.Errorf("unknown version control system %q", match["vcs"]) + } + if srv.ping { + if scheme != "" { + match["repo"] = scheme + "://" + match["repo"] + } else { + for _, scheme := range vcs.Scheme { + if vcs.Ping(scheme, match["repo"]) == nil { + match["repo"] = scheme + "://" + match["repo"] + break + } + } + } + } + rr := &RepoRoot{ + VCS: vcs, + Repo: match["repo"], + Root: match["root"], + } + return rr, nil + } + return nil, errUnknownSite +} + +// RepoRootForImportDynamic finds a *RepoRoot for a custom domain that's not +// statically known by RepoRootForImportPathStatic. +// +// This handles custom import paths like "name.tld/pkg/foo" or just "name.tld". +func RepoRootForImportDynamic(importPath string, verbose bool) (*RepoRoot, error) { + slash := strings.Index(importPath, "/") + if slash < 0 { + slash = len(importPath) + } + host := importPath[:slash] + if !strings.Contains(host, ".") { + return nil, errors.New("import path doesn't contain a hostname") + } + urlStr, body, err := httpsOrHTTP(importPath) + if err != nil { + return nil, fmt.Errorf("http/https fetch: %v", err) + } + defer body.Close() + imports, err := parseMetaGoImports(body) + if err != nil { + return nil, fmt.Errorf("parsing %s: %v", importPath, err) + } + metaImport, err := matchGoImport(imports, importPath) + if err != nil { + if err != errNoMatch { + return nil, fmt.Errorf("parse %s: %v", urlStr, err) + } + return nil, fmt.Errorf("parse %s: no go-import meta tags", urlStr) + } + if verbose { + log.Printf("get %q: found meta tag %#v at %s", importPath, metaImport, urlStr) + } + // If the import was "uni.edu/bob/project", which said the + // prefix was "uni.edu" and the RepoRoot was "evilroot.com", + // make sure we don't trust Bob and check out evilroot.com to + // "uni.edu" yet (possibly overwriting/preempting another + // non-evil student). Instead, first verify the root and see + // if it matches Bob's claim. + if metaImport.Prefix != importPath { + if verbose { + log.Printf("get %q: verifying non-authoritative meta tag", importPath) + } + urlStr0 := urlStr + urlStr, body, err = httpsOrHTTP(metaImport.Prefix) + if err != nil { + return nil, fmt.Errorf("fetch %s: %v", urlStr, err) + } + imports, err := parseMetaGoImports(body) + if err != nil { + return nil, fmt.Errorf("parsing %s: %v", importPath, err) + } + if len(imports) == 0 { + return nil, fmt.Errorf("fetch %s: no go-import meta tag", urlStr) + } + metaImport2, err := matchGoImport(imports, importPath) + if err != nil || metaImport != metaImport2 { + return nil, fmt.Errorf("%s and %s disagree about go-import for %s", urlStr0, urlStr, metaImport.Prefix) + } + } + + if err := validateRepoRoot(metaImport.RepoRoot); err != nil { + return nil, fmt.Errorf("%s: invalid repo root %q: %v", urlStr, metaImport.RepoRoot, err) + } + rr := &RepoRoot{ + VCS: ByCmd(metaImport.VCS), + Repo: metaImport.RepoRoot, + Root: metaImport.Prefix, + } + if rr.VCS == nil { + return nil, fmt.Errorf("%s: unknown vcs %q", urlStr, metaImport.VCS) + } + return rr, nil +} + +// validateRepoRoot returns an error if repoRoot does not seem to be +// a valid URL with scheme. +func validateRepoRoot(repoRoot string) error { + url, err := url.Parse(repoRoot) + if err != nil { + return err + } + if url.Scheme == "" { + return errors.New("no scheme") + } + return nil +} + +// metaImport represents the parsed tags from HTML files. +type metaImport struct { + Prefix, VCS, RepoRoot string +} + +// errNoMatch is returned from matchGoImport when there's no applicable match. +var errNoMatch = errors.New("no import match") + +// pathPrefix reports whether sub is a prefix of s, +// only considering entire path components. +func pathPrefix(s, sub string) bool { + // strings.HasPrefix is necessary but not sufficient. + if !strings.HasPrefix(s, sub) { + return false + } + // The remainder after the prefix must either be empty or start with a slash. + rem := s[len(sub):] + return rem == "" || rem[0] == '/' +} + +// matchGoImport returns the metaImport from imports matching importPath. +// An error is returned if there are multiple matches. +// errNoMatch is returned if none match. +func matchGoImport(imports []metaImport, importPath string) (_ metaImport, err error) { + match := -1 + for i, im := range imports { + if !pathPrefix(importPath, im.Prefix) { + continue + } + + if match != -1 { + err = fmt.Errorf("multiple meta tags match import path %q", importPath) + return + } + match = i + } + if match == -1 { + err = errNoMatch + return + } + return imports[match], nil +} + +// expand rewrites s to replace {k} with match[k] for each key k in match. +func expand(match map[string]string, s string) string { + for k, v := range match { + s = strings.Replace(s, "{"+k+"}", v, -1) + } + return s +} + +// vcsPaths lists the known vcs paths. +var vcsPaths = []*vcsPath{ + // go.googlesource.com + { + prefix: "go.googlesource.com", + re: `^(?Pgo\.googlesource\.com/[A-Za-z0-9_.\-]+/?)$`, + vcs: "git", + repo: "https://{root}", + check: noVCSSuffix, + }, + + // Github + { + prefix: "github.com/", + re: `^(?Pgithub\.com/[A-Za-z0-9_.\-]+/[A-Za-z0-9_.\-]+)(/[\p{L}0-9_.\-]+)*$`, + vcs: "git", + repo: "https://{root}", + check: noVCSSuffix, + }, + + // Bitbucket + { + prefix: "bitbucket.org/", + re: `^(?Pbitbucket\.org/(?P[A-Za-z0-9_.\-]+/[A-Za-z0-9_.\-]+))(/[A-Za-z0-9_.\-]+)*$`, + repo: "https://{root}", + check: bitbucketVCS, + }, + + // Launchpad + { + prefix: "launchpad.net/", + re: `^(?Plaunchpad\.net/((?P[A-Za-z0-9_.\-]+)(?P/[A-Za-z0-9_.\-]+)?|~[A-Za-z0-9_.\-]+/(\+junk|[A-Za-z0-9_.\-]+)/[A-Za-z0-9_.\-]+))(/[A-Za-z0-9_.\-]+)*$`, + vcs: "bzr", + repo: "https://{root}", + check: launchpadVCS, + }, + + // Git at OpenStack + { + prefix: "git.openstack.org", + re: `^(?Pgit\.openstack\.org/[A-Za-z0-9_.\-]+/[A-Za-z0-9_.\-]+)(\.git)?(/[A-Za-z0-9_.\-]+)*$`, + vcs: "git", + repo: "https://{root}", + check: noVCSSuffix, + }, + + // General syntax for any server. + { + re: `^(?P(?P([a-z0-9.\-]+\.)+[a-z0-9.\-]+(:[0-9]+)?/[A-Za-z0-9_.\-/]*?)\.(?Pbzr|git|hg|svn))(/[A-Za-z0-9_.\-]+)*$`, + ping: true, + }, +} + +func init() { + // fill in cached regexps. + // Doing this eagerly discovers invalid regexp syntax + // without having to run a command that needs that regexp. + for _, srv := range vcsPaths { + srv.regexp = regexp.MustCompile(srv.re) + } +} + +// noVCSSuffix checks that the repository name does not +// end in .foo for any version control system foo. +// The usual culprit is ".git". +func noVCSSuffix(match map[string]string) error { + repo := match["repo"] + for _, vcs := range vcsList { + if strings.HasSuffix(repo, "."+vcs.Cmd) { + return fmt.Errorf("invalid version control suffix in %s path", match["prefix"]) + } + } + return nil +} + +// bitbucketVCS determines the version control system for a +// Bitbucket repository, by using the Bitbucket API. +func bitbucketVCS(match map[string]string) error { + if err := noVCSSuffix(match); err != nil { + return err + } + + var resp struct { + SCM string `json:"scm"` + } + url := expand(match, "https://api.bitbucket.org/1.0/repositories/{bitname}") + data, err := httpGET(url) + if err != nil { + return err + } + if err := json.Unmarshal(data, &resp); err != nil { + return fmt.Errorf("decoding %s: %v", url, err) + } + + if ByCmd(resp.SCM) != nil { + match["vcs"] = resp.SCM + if resp.SCM == "git" { + match["repo"] += ".git" + } + return nil + } + + return fmt.Errorf("unable to detect version control system for bitbucket.org/ path") +} + +// launchpadVCS solves the ambiguity for "lp.net/project/foo". In this case, +// "foo" could be a series name registered in Launchpad with its own branch, +// and it could also be the name of a directory within the main project +// branch one level up. +func launchpadVCS(match map[string]string) error { + if match["project"] == "" || match["series"] == "" { + return nil + } + _, err := httpGET(expand(match, "https://code.launchpad.net/{project}{series}/.bzr/branch-format")) + if err != nil { + match["root"] = expand(match, "launchpad.net/{project}") + match["repo"] = expand(match, "https://{root}") + } + return nil +} diff --git a/vendor/vendor.json b/vendor/vendor.json index 80c6400c71..da5258af06 100644 --- a/vendor/vendor.json +++ b/vendor/vendor.json @@ -6,22 +6,22 @@ "checksumSHA1": "AzjRkOQtVBTwIw4RJLTygFhJs3s=", "origin": "github.com/elastic/beats/vendor/github.com/Microsoft/go-winio", "path": "github.com/Microsoft/go-winio", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z" + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z" }, { "checksumSHA1": "bFZjImadCCzrjKSGjlg/HZpMqT4=", "origin": "github.com/elastic/beats/vendor/github.com/Shopify/sarama", "path": "github.com/Shopify/sarama", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z" + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z" }, { "checksumSHA1": "DYv6Q1+VfnUVxMwvk5IshAClLvw=", "origin": "github.com/elastic/beats/vendor/github.com/Sirupsen/logrus", "path": "github.com/Sirupsen/logrus", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z" + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z" }, { "checksumSHA1": "qtjd74+bErubh+qyv3s+lWmn9wc=", @@ -33,197 +33,197 @@ "checksumSHA1": "dvabztWVQX8f6oMLRyv4dLH+TGY=", "origin": "github.com/elastic/beats/vendor/github.com/davecgh/go-spew/spew", "path": "github.com/davecgh/go-spew/spew", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z" + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z" }, { "checksumSHA1": "Gj+xR1VgFKKmFXYOJMnAczC3Znk=", "origin": "github.com/elastic/beats/vendor/github.com/docker/distribution/digestset", "path": "github.com/docker/distribution/digestset", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z" + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z" }, { "checksumSHA1": "2Fe4D6PGaVE2he4fUeenLmhC1lE=", "origin": "github.com/elastic/beats/vendor/github.com/docker/distribution/reference", "path": "github.com/docker/distribution/reference", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z" + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z" }, { "checksumSHA1": "UL2NF1EGiSsQoEfvycnuZIcUbZY=", "origin": "github.com/elastic/beats/vendor/github.com/docker/docker/api", "path": "github.com/docker/docker/api", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z" + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z" }, { "checksumSHA1": "KMFpbV3mlrbc41d2DYnq05QYpSc=", "origin": "github.com/elastic/beats/vendor/github.com/docker/docker/api/types", "path": "github.com/docker/docker/api/types", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z" + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z" }, { "checksumSHA1": "jVJDbe0IcyjoKc2xbohwzQr+FF0=", "origin": "github.com/elastic/beats/vendor/github.com/docker/docker/api/types/blkiodev", "path": "github.com/docker/docker/api/types/blkiodev", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z" + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z" }, { "checksumSHA1": "AeSC0BOu1uapkGqfSXtfVSpwJzs=", "origin": "github.com/elastic/beats/vendor/github.com/docker/docker/api/types/container", "path": "github.com/docker/docker/api/types/container", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z" + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z" }, { "checksumSHA1": "4XuWn5+wgYwUsw604jvYMklq4Hc=", "origin": "github.com/elastic/beats/vendor/github.com/docker/docker/api/types/events", "path": "github.com/docker/docker/api/types/events", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z" + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z" }, { "checksumSHA1": "J2OKngfI3vgswudr9PZVUFcRRu0=", "origin": "github.com/elastic/beats/vendor/github.com/docker/docker/api/types/filters", "path": "github.com/docker/docker/api/types/filters", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z" + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z" }, { "checksumSHA1": "yeB781yxPhnN6OXQ9/qSsyih3ek=", "origin": "github.com/elastic/beats/vendor/github.com/docker/docker/api/types/image", "path": "github.com/docker/docker/api/types/image", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z" + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z" }, { "checksumSHA1": "UK+VdM648oWzyqE4OqttgmPqjoA=", "origin": "github.com/elastic/beats/vendor/github.com/docker/docker/api/types/mount", "path": "github.com/docker/docker/api/types/mount", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z" + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z" }, { "checksumSHA1": "Gskp+nvbVe8Gk1xPLHylZvNmqTg=", "origin": "github.com/elastic/beats/vendor/github.com/docker/docker/api/types/network", "path": "github.com/docker/docker/api/types/network", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z" + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z" }, { "checksumSHA1": "r2vWq7Uc3ExKzMqYgH0b4AKjLKY=", "origin": "github.com/elastic/beats/vendor/github.com/docker/docker/api/types/registry", "path": "github.com/docker/docker/api/types/registry", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z" + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z" }, { "checksumSHA1": "VTxWyFud/RedrpllGdQonVtGM/A=", "origin": "github.com/elastic/beats/vendor/github.com/docker/docker/api/types/strslice", "path": "github.com/docker/docker/api/types/strslice", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z" + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z" }, { "checksumSHA1": "ZaizCpJ3eBcfR9ywpLaJd4AhM9k=", "origin": "github.com/elastic/beats/vendor/github.com/docker/docker/api/types/swarm", "path": "github.com/docker/docker/api/types/swarm", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z" + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z" }, { "checksumSHA1": "B7ZwKzrv3t3Vlox6/bYMHhMjsM8=", "origin": "github.com/elastic/beats/vendor/github.com/docker/docker/api/types/time", "path": "github.com/docker/docker/api/types/time", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z" + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z" }, { "checksumSHA1": "uDPQ3nHsrvGQc9tg/J9OSC4N5dQ=", "origin": "github.com/elastic/beats/vendor/github.com/docker/docker/api/types/versions", "path": "github.com/docker/docker/api/types/versions", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z" + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z" }, { "checksumSHA1": "IBJy2zPEnYmcFJ3lM1eiRWnCxTA=", "origin": "github.com/elastic/beats/vendor/github.com/docker/docker/api/types/volume", "path": "github.com/docker/docker/api/types/volume", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z" + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z" }, { "checksumSHA1": "c6OyeEvpQDvVLhrJSxgjEZv1tF8=", "origin": "github.com/elastic/beats/vendor/github.com/docker/docker/client", "path": "github.com/docker/docker/client", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z" + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z" }, { "checksumSHA1": "jmo/t2zXAxirEPoFucNPXA/1SEc=", "origin": "github.com/elastic/beats/vendor/github.com/docker/docker/pkg/ioutils", "path": "github.com/docker/docker/pkg/ioutils", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z" + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z" }, { "checksumSHA1": "ndnAFCfsGC3upNQ6jAEwzxcurww=", "origin": "github.com/elastic/beats/vendor/github.com/docker/docker/pkg/longpath", "path": "github.com/docker/docker/pkg/longpath", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z" + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z" }, { "checksumSHA1": "kr46EAa+FsUcWxOq6edyX6BUzE4=", "origin": "github.com/elastic/beats/vendor/github.com/docker/docker/pkg/system", "path": "github.com/docker/docker/pkg/system", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z" + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z" }, { "checksumSHA1": "8I0Ez+aUYGpsDEVZ8wN/Ztf6Zqs=", "origin": "github.com/elastic/beats/vendor/github.com/docker/docker/pkg/tlsconfig", "path": "github.com/docker/docker/pkg/tlsconfig", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z" + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z" }, { "checksumSHA1": "JbiWTzH699Sqz25XmDlsARpMN9w=", "origin": "github.com/elastic/beats/vendor/github.com/docker/go-connections/nat", "path": "github.com/docker/go-connections/nat", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z" + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z" }, { "checksumSHA1": "jUfDG3VQsA2UZHvvIXncgiddpYA=", "origin": "github.com/elastic/beats/vendor/github.com/docker/go-connections/sockets", "path": "github.com/docker/go-connections/sockets", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z" + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z" }, { "checksumSHA1": "tuSzlS1UQ03+5Fvtqr5hI5sLLhA=", "origin": "github.com/elastic/beats/vendor/github.com/docker/go-connections/tlsconfig", "path": "github.com/docker/go-connections/tlsconfig", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z" + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z" }, { "checksumSHA1": "ambe8F4AofPxChCJssXXwWphQQ8=", "origin": "github.com/elastic/beats/vendor/github.com/docker/go-units", "path": "github.com/docker/go-units", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z" + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z" }, { "checksumSHA1": "sNAU9ojYVUhO6dVXey6T3JhRQpw=", "origin": "github.com/elastic/beats/vendor/github.com/docker/libtrust", "path": "github.com/docker/libtrust", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z" + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z" }, { "checksumSHA1": "tJd2T/eyW6ejAev7WzGxTeUVOPQ=", @@ -235,22 +235,22 @@ "checksumSHA1": "y2Kh4iPlgCPXSGTCcFpzePYdzzg=", "origin": "github.com/elastic/beats/vendor/github.com/eapache/go-resiliency/breaker", "path": "github.com/eapache/go-resiliency/breaker", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z" + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z" }, { "checksumSHA1": "WHl96RVZlOOdF4Lb1OOadMpw8ls=", "origin": "github.com/elastic/beats/vendor/github.com/eapache/go-xerial-snappy", "path": "github.com/eapache/go-xerial-snappy", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z" + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z" }, { "checksumSHA1": "oCCs6kDanizatplM5e/hX76busE=", "origin": "github.com/elastic/beats/vendor/github.com/eapache/queue", "path": "github.com/eapache/queue", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z" + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z" }, { "checksumSHA1": "iS7awdGQOMgYrHf2XvIiT5w6weA=", @@ -357,322 +357,336 @@ "versionExact": "v0.4.0" }, { - "checksumSHA1": "1ehnSD4NWvAj66S6kqtSiFENecM=", + "checksumSHA1": "L2zyst1TWHCaLzB0kg2rmi+WRBU=", + "path": "github.com/elastic/beats/dev-tools/mage", + "revision": "af1638c90567274690c8111d47e3c5f12c396558", + "revisionTime": "2018-07-02T08:06:33Z" + }, + { + "checksumSHA1": "Dvdr9g4Whhfaym7yRl8YFI3e7Ak=", "path": "github.com/elastic/beats/libbeat/api", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z", + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z", "version": "master", "versionExact": "master" }, { - "checksumSHA1": "IfZBCp1ci/ZlKhcgiByt+cOBIYw=", + "checksumSHA1": "6Qq4YWxaWK1E9tW1IgKAZGlGj7w=", "path": "github.com/elastic/beats/libbeat/asset", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z", + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z", "version": "master", "versionExact": "master" }, { - "checksumSHA1": "BQEsA6lOb32HlEzCqOW/A67YNB4=", + "checksumSHA1": "XbhIiunn5eZfKAl9WReLTq3HRUY=", "path": "github.com/elastic/beats/libbeat/autodiscover", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z", + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z", "version": "master", "versionExact": "master" }, { - "checksumSHA1": "1kB/tsDeGhaOVKcmci2aAC6sN+w=", + "checksumSHA1": "pW/XBpb2BIceplyuoqvwTtowH7c=", "path": "github.com/elastic/beats/libbeat/autodiscover/builder", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z", + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z", "version": "master", "versionExact": "master" }, { - "checksumSHA1": "mvMbWi8jMCS5ZDCiWv+GkUzsmEw=", + "checksumSHA1": "IifZH9hzzPymGV2XQfQ/tFR4uSE=", "path": "github.com/elastic/beats/libbeat/autodiscover/meta", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z", + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z", "version": "master", "versionExact": "master" }, { - "checksumSHA1": "W+FPNgqITXjGiLYWhnETTzbrfM8=", + "checksumSHA1": "ZcmRnVuYkeSqQZbV5gi7z9PR3I8=", "path": "github.com/elastic/beats/libbeat/autodiscover/providers/docker", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z", + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z", "version": "master", "versionExact": "master" }, { - "checksumSHA1": "/TIhDClhghdkP6iRwKPs7S9vjkA=", + "checksumSHA1": "zlx6WSFNdf6miWv8beG3HueX49c=", "path": "github.com/elastic/beats/libbeat/autodiscover/providers/jolokia", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z", + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z", "version": "master", "versionExact": "master" }, { - "checksumSHA1": "+RhByAKx2iEmJT1UqqfFd41ywiQ=", + "checksumSHA1": "8s5j0/VbYvFNV48LdJTtkBEjLbQ=", "path": "github.com/elastic/beats/libbeat/autodiscover/providers/kubernetes", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z", + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z", "version": "master", "versionExact": "master" }, { - "checksumSHA1": "1jESfeLQBUHMWV7Ue6+bKINWnhM=", + "checksumSHA1": "iXJ7qUXezd+E3Sr6CLUkFICAspc=", "path": "github.com/elastic/beats/libbeat/autodiscover/template", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z", + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z", "version": "master", "versionExact": "master" }, { - "checksumSHA1": "cKB02Mx38M6uo+gUN/NMWgV29Uc=", + "checksumSHA1": "Oj2NCArxKbamqSMcTt/0Jq9HSx4=", "path": "github.com/elastic/beats/libbeat/beat", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z", + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z", "version": "master", "versionExact": "master" }, { - "checksumSHA1": "2ArJRZ7LhxbekMlTwifjlk6nGhM=", + "checksumSHA1": "UkvFltjIEYVRUBGZLecI3sfvxpY=", "path": "github.com/elastic/beats/libbeat/cfgfile", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z", + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z", "version": "master", "versionExact": "master" }, { - "checksumSHA1": "kcJBPeHVyLhstApfy7Smi6fcxrg=", + "checksumSHA1": "NP63NO+chtAOIPaeiIlSXmzWits=", "path": "github.com/elastic/beats/libbeat/cloudid", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z", + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z", "version": "master", "versionExact": "master" }, { - "checksumSHA1": "wmJT0bHzE070pvlmvhH7I4OhJX4=", + "checksumSHA1": "TG/hgh+oZ9SmOUrbkqM2qHt4Rv0=", "path": "github.com/elastic/beats/libbeat/cmd", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z", + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z", "version": "master", "versionExact": "master" }, { - "checksumSHA1": "MJhGFC6zQ8gDg4BE6ZHhBXcL32s=", + "checksumSHA1": "FC7ToRnGzD/3VIxiTF7DJc98rX8=", "path": "github.com/elastic/beats/libbeat/cmd/export", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z", + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z", "version": "master", "versionExact": "master" }, { - "checksumSHA1": "XSe9/0b2rTtCmdLflWGMHKAVx4U=", + "checksumSHA1": "RlK9/o1OmhBACQbGKJUooonmdIE=", "path": "github.com/elastic/beats/libbeat/cmd/instance", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z", + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z", "version": "master", "versionExact": "master" }, { - "checksumSHA1": "hnrALZ/owH5lcue6u3G9p0/K4ag=", + "checksumSHA1": "TGW7SUpyY5XCLRjLW2n62yDKqBk=", "path": "github.com/elastic/beats/libbeat/cmd/test", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z", + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z", "version": "master", "versionExact": "master" }, { - "checksumSHA1": "oHeqQVPnyChULaqluFrf++zav60=", + "checksumSHA1": "TKHInfVsZLDE7dh9F2mbZWke0YI=", "path": "github.com/elastic/beats/libbeat/common", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z", + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z", "version": "master", "versionExact": "master" }, { - "checksumSHA1": "/d9OH1zlHQck1QRHUyrl28xl2fM=", + "checksumSHA1": "lFYRu/M9CL6/povZOeBYui9/laI=", "path": "github.com/elastic/beats/libbeat/common/atomic", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z", + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z", "version": "master", "versionExact": "master" }, { - "checksumSHA1": "I5ABLC2bPeiBbL2fKqLsQNe4DSQ=", + "checksumSHA1": "D1rvRGmNzRcbBBpRgbBZGc7lkOU=", "path": "github.com/elastic/beats/libbeat/common/bus", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z", + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z", "version": "master", "versionExact": "master" }, { - "checksumSHA1": "FhJSOKSTJHrfTMOxwWNjT2BFcgc=", + "checksumSHA1": "zRpP/UzB/wFQNLceGdVgC4QqviM=", "path": "github.com/elastic/beats/libbeat/common/cfgtype", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z", + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z", "version": "master", "versionExact": "master" }, { - "checksumSHA1": "5Y5WqKnrBD4VBRXCRn2JgFDvMV8=", + "checksumSHA1": "JW9FjfvZn4rawSFC4UCCK3zjxQI=", "path": "github.com/elastic/beats/libbeat/common/cfgwarn", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z", + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z", "version": "master", "versionExact": "master" }, { - "checksumSHA1": "OSXtQFu0+JoGUcWYpcFkXuvhRO4=", + "checksumSHA1": "Xe8ezkUIrqnG2wRIAgrtIei2E5E=", "path": "github.com/elastic/beats/libbeat/common/cli", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z", + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z", "version": "master", "versionExact": "master" }, { - "checksumSHA1": "6VSpBdjb2UYME3Rv6LlxTWKzjZw=", + "checksumSHA1": "eyiP8rHNLiUp9DDyhw7timgmCgo=", "path": "github.com/elastic/beats/libbeat/common/docker", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z", + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z", "version": "master", "versionExact": "master" }, { - "checksumSHA1": "7bGcM14M5R8BuQLqKdWfbbQaKEM=", + "checksumSHA1": "Gxdi0z5FpIG68TQBD+zho4pEBlU=", "path": "github.com/elastic/beats/libbeat/common/dtfmt", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z", + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z", "version": "master", "versionExact": "master" }, { - "checksumSHA1": "GUO/I9H/meC4CKx6GADL4b82Ngg=", + "checksumSHA1": "spkArUdXWAHhSzLSCO+FU0ol/Bs=", "path": "github.com/elastic/beats/libbeat/common/file", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z", + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z", "version": "master", "versionExact": "master" }, { - "checksumSHA1": "7WSOY58klc0crUF/5UZx/pLFIR0=", + "checksumSHA1": "OOSKD9x3xg+Gie3yrqkwKVRNQ+k=", "path": "github.com/elastic/beats/libbeat/common/fmtstr", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z", + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z", "version": "master", "versionExact": "master" }, { - "checksumSHA1": "pdFJ+DF0STunSGRopAMwn9n9ZlY=", + "checksumSHA1": "K8hsg9OHpVHm7A43uq+TdX5DRc4=", "path": "github.com/elastic/beats/libbeat/common/jsontransform", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z", + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z", "version": "master", "versionExact": "master" }, { - "checksumSHA1": "pOEHIgr+TBLt2M86VrN0f5WtTX0=", + "checksumSHA1": "qR9NZtgwq+Ka/BJkKL7IasHldMg=", "path": "github.com/elastic/beats/libbeat/common/kubernetes", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z", + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z", "version": "master", "versionExact": "master" }, { - "checksumSHA1": "43jcD3PFE0qBsP40iA4kb/g94MU=", + "checksumSHA1": "tX/nsD/KEE0KCWECoPyx5CHNPdc=", "path": "github.com/elastic/beats/libbeat/common/match", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z", + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z", "version": "master", "versionExact": "master" }, { - "checksumSHA1": "ZVSXt7kvNZA3mVDwoGFv/8IDDys=", + "checksumSHA1": "uMo9yaQAFfFG9iOsmdhQokffvpc=", "path": "github.com/elastic/beats/libbeat/common/safemapstr", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z", + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z", "version": "master", "versionExact": "master" }, { - "checksumSHA1": "XFFI1jhD1bXSJGNOq3Ef48sGP/0=", + "checksumSHA1": "UXrqkAUlVj0By5jytRZhT8r1h4k=", "path": "github.com/elastic/beats/libbeat/common/schema", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z", + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z", "version": "master", "versionExact": "master" }, { - "checksumSHA1": "U9kadFhZbCKziYV/Yx9GsX5WzoI=", + "checksumSHA1": "kopPyGoZYO1QWKuQmHbv7eI9Rz4=", "path": "github.com/elastic/beats/libbeat/common/schema/mapstriface", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z", + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z", "version": "master", "versionExact": "master" }, { - "checksumSHA1": "NDPOrg8lg+DbBC29rP3Cca/B6iQ=", + "checksumSHA1": "yU4kvU65qUWsFs4aq+KjplWCX94=", "path": "github.com/elastic/beats/libbeat/common/seccomp", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z", + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z", "version": "master", "versionExact": "master" }, { - "checksumSHA1": "zi4xMJ43/IzPCPNXs8iBc0WI2sE=", + "checksumSHA1": "bfwgWh6tuDRh6ukgJyS/1qF/cyk=", "path": "github.com/elastic/beats/libbeat/common/streambuf", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z", + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z", "version": "master", "versionExact": "master" }, { - "checksumSHA1": "1k581NuOkCx0xoGSrGV0vD6i+PA=", + "checksumSHA1": "/sJHf4Kin0RIGRVR3h6L1i6eR80=", "path": "github.com/elastic/beats/libbeat/common/terminal", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z", + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z", "version": "master", "versionExact": "master" }, { - "checksumSHA1": "IojMdy09gnr36zzi5jlf5Ih96rw=", + "checksumSHA1": "whZDcc0DXktMrMnISOGBLkoJpe8=", "path": "github.com/elastic/beats/libbeat/common/transport/tlscommon", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z", + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z", "version": "master", "versionExact": "master" }, { - "checksumSHA1": "MWXvu6KNCrFcOj2Jie/IUZ4B8xE=", + "checksumSHA1": "v1uglELtgBUQ35dH1IOH8ZSeNaw=", "path": "github.com/elastic/beats/libbeat/dashboards", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z", + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z", + "version": "master", + "versionExact": "master" + }, + { + "checksumSHA1": "i/7M5crL7LrHAkyBLBzaj3LLV08=", + "path": "github.com/elastic/beats/libbeat/feature", + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z", "version": "master", "versionExact": "master" }, { - "checksumSHA1": "eOCIv34+OqkdqUtXaEyPahZzJ3I=", + "checksumSHA1": "NzJlDvYwC+pBb9mr5jV/UG8LZbU=", "path": "github.com/elastic/beats/libbeat/generator/fields", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z", + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z", "version": "master", "versionExact": "master" }, { - "checksumSHA1": "Ie2zbuch+Jx2IrpjstO1jJeiV8o=", + "checksumSHA1": "zaVz+mn51zGScQ4fK6LllgEOVX0=", "path": "github.com/elastic/beats/libbeat/keystore", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z", + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z", "version": "master", "versionExact": "master" }, { - "checksumSHA1": "qvEIXyVWTKlnGyG9szrqH6SdO9w=", + "checksumSHA1": "QFon+IhYQiBDXzV9TBPN5Un6FsE=", "path": "github.com/elastic/beats/libbeat/kibana", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z", + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z", "version": "master", "versionExact": "master" }, @@ -685,322 +699,330 @@ "versionExact": "master" }, { - "checksumSHA1": "o43GjmYyneJqJaevwdy6tBX4vLA=", + "checksumSHA1": "DB+yZpfgh3DD6JPEvQB0WL0ifo8=", "path": "github.com/elastic/beats/libbeat/logp", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z", + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z", "version": "master", "versionExact": "master" }, { - "checksumSHA1": "/fSZH8iFO9jqRiSSxzM593zMS4Y=", + "checksumSHA1": "bM+Zvy63NmXBfPQZYZmWBCo/UIk=", "path": "github.com/elastic/beats/libbeat/logp/configure", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z", + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z", "version": "master", "versionExact": "master" }, { - "checksumSHA1": "3rCxbiMynIdSdQe7h95cuTKEXbY=", + "checksumSHA1": "MSyq72f9tKHQwATZXZyRC4JrSV0=", "path": "github.com/elastic/beats/libbeat/metric/system/cpu", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z", + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z", "version": "master", "versionExact": "master" }, { - "checksumSHA1": "z7V8OR3yB8TYRVYkckzIl17wuYQ=", + "checksumSHA1": "AeCEL+vyIBE0WH16IaR4ygy+6IA=", "path": "github.com/elastic/beats/libbeat/metric/system/memory", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z", + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z", "version": "master", "versionExact": "master" }, { - "checksumSHA1": "B0sjyYQEXlhHRQQ0/lqWBY4sKCQ=", + "checksumSHA1": "S1S4qG9c+A5PJ7Ua/Mj+q9aAm68=", "path": "github.com/elastic/beats/libbeat/metric/system/process", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z", + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z", "version": "master", "versionExact": "master" }, { - "checksumSHA1": "fg8wOSztIPVawPmpGpDBZ6qlQeY=", + "checksumSHA1": "qmEwlEsGt9C7/yGuyCQhA30xJyk=", "path": "github.com/elastic/beats/libbeat/monitoring", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z", + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z", "version": "master", "versionExact": "master" }, { - "checksumSHA1": "tRfILb+3nS9S5xf1GTqyGVbvGnU=", + "checksumSHA1": "7DdIn1PxWmHIUpwBbgCl3avLHj4=", "path": "github.com/elastic/beats/libbeat/monitoring/adapter", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z", + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z", "version": "master", "versionExact": "master" }, { - "checksumSHA1": "9OgsegLCw7fQSbzm92h5SSLJSqo=", + "checksumSHA1": "L2JLxzFvSCOjJ268kNfnPS1BAeI=", "path": "github.com/elastic/beats/libbeat/monitoring/report", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z", + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z", "version": "master", "versionExact": "master" }, { - "checksumSHA1": "11EpRZ+eNJac2X1nbyM0vUO3rs4=", + "checksumSHA1": "TbxqeKX/o7l7RW9/YeMW2NRIkvU=", "path": "github.com/elastic/beats/libbeat/monitoring/report/elasticsearch", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z", + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z", "version": "master", "versionExact": "master" }, { - "checksumSHA1": "O0mqYi92UChneQIZItpvDf+egYM=", + "checksumSHA1": "NIdJCMcoHBoqaAMqaZ4Ul/SHU3E=", "path": "github.com/elastic/beats/libbeat/monitoring/report/log", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z", + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z", "version": "master", "versionExact": "master" }, { - "checksumSHA1": "pi+bW2uHkZ0IH9fDcCWNt8dzyqQ=", + "checksumSHA1": "cHevaTeVVh4RGq5LxTJzwjZKZBA=", "path": "github.com/elastic/beats/libbeat/outputs", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z", + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z", "version": "master", "versionExact": "master" }, { - "checksumSHA1": "lRSwiGVO2pp69QtoR2Fa8CP3O8I=", + "checksumSHA1": "a2kloD1x12fBRXViCIXm+ebyUYI=", "path": "github.com/elastic/beats/libbeat/outputs/codec", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z", + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z", "version": "master", "versionExact": "master" }, { - "checksumSHA1": "vjVLDyWbKmCR6e2OayNshujneSI=", + "checksumSHA1": "dO9pXcIpo6PH5yxMbJUSb/BYbkc=", "path": "github.com/elastic/beats/libbeat/outputs/codec/format", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z", + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z", "version": "master", "versionExact": "master" }, { - "checksumSHA1": "Fsj11NCCIR55lFMYxRDbEbRfd3k=", + "checksumSHA1": "UFgGetFoHnYBYUc09y8+MJar4dQ=", "path": "github.com/elastic/beats/libbeat/outputs/codec/json", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z", + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z", "version": "master", "versionExact": "master" }, { - "checksumSHA1": "JGP5bMcL1KyJRJCR1kW11gZhPhk=", + "checksumSHA1": "QezZ6ewDQx90l2dmhEuZN0feBLc=", "path": "github.com/elastic/beats/libbeat/outputs/console", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z", + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z", "version": "master", "versionExact": "master" }, { - "checksumSHA1": "NyKADYkpW7O19K9QjQsPBmd7kYk=", + "checksumSHA1": "ZABc/CnOmqgZCt82BkKI1T0ICKA=", "path": "github.com/elastic/beats/libbeat/outputs/elasticsearch", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z", + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z", "version": "master", "versionExact": "master" }, { - "checksumSHA1": "S1nJaQZExaATn2Xpin4eY7Oyr34=", + "checksumSHA1": "Yb9RJi6o7q/1IiydWfoJhYvnd7I=", "path": "github.com/elastic/beats/libbeat/outputs/fileout", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z", + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z", "version": "master", "versionExact": "master" }, { - "checksumSHA1": "aD50ZHjy8VMfE+DOlx52vWHDh/E=", + "checksumSHA1": "eeG0BAf2lSQJdcdcN8mTBlcaTO0=", "path": "github.com/elastic/beats/libbeat/outputs/kafka", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z", + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z", "version": "master", "versionExact": "master" }, { - "checksumSHA1": "os15BbOJ2JvB4isIRr4Lkrje7/8=", + "checksumSHA1": "gK4mKPDnPET3jfzhyS22TngM0aE=", "path": "github.com/elastic/beats/libbeat/outputs/logstash", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z", + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z", "version": "master", "versionExact": "master" }, { - "checksumSHA1": "UEGH5mAXdKBysIjODuTxHKlzqsY=", + "checksumSHA1": "LEu6yegfMCErX+nHZyKGvflrci0=", "path": "github.com/elastic/beats/libbeat/outputs/outil", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z", + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z", "version": "master", "versionExact": "master" }, { - "checksumSHA1": "pibHALL2/V+rGu0aTT2Dq9i7vgM=", + "checksumSHA1": "5xgDt2rHHDBcwEevhFDbKM8J3wU=", "path": "github.com/elastic/beats/libbeat/outputs/redis", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z", + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z", "version": "master", "versionExact": "master" }, { - "checksumSHA1": "eOzCBcDGbJflX4wkqW2fNTGaV+M=", + "checksumSHA1": "jdIx6KShDI9mR4Ossf7ueWyrRKU=", "path": "github.com/elastic/beats/libbeat/outputs/transport", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z", + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z", "version": "master", "versionExact": "master" }, { - "checksumSHA1": "d5b9Ra0zcwznwemxEJmyW28FZJ0=", + "checksumSHA1": "72qBNCQrGrvLZFMGD2AqxxKQMsw=", + "path": "github.com/elastic/beats/libbeat/outputs/transport/transptest", + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z", + "version": "master", + "versionExact": "master" + }, + { + "checksumSHA1": "hb8M4qSLzgDXpQmdQfEyB7aChhI=", "path": "github.com/elastic/beats/libbeat/paths", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z", + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z", "version": "master", "versionExact": "master" }, { - "checksumSHA1": "H+5T9ru9pqZxsXX739UwIH561nc=", + "checksumSHA1": "MnBepwK6hFumvOtA+c3JGACMZdM=", "path": "github.com/elastic/beats/libbeat/plugin", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z", + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z", "version": "master", "versionExact": "master" }, { - "checksumSHA1": "3jjj6+V4ge9NzgAookjiC8yuTUg=", + "checksumSHA1": "U72CtC2jOW1Q+ZaF+u3fE9F71XU=", "path": "github.com/elastic/beats/libbeat/processors", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z", + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z", "version": "master", "versionExact": "master" }, { - "checksumSHA1": "VOCx+tRwUAAkIFUbWPmik8MyKlI=", + "checksumSHA1": "5ZQPiCpwZWQyAQmr7wwWGT2ROsw=", "path": "github.com/elastic/beats/libbeat/processors/actions", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z", + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z", "version": "master", "versionExact": "master" }, { - "checksumSHA1": "rI+RcxALfhqftyApiHM1AgSjQ8U=", + "checksumSHA1": "0w12Qe9n8IgAWf98HN2xJk49fW8=", "path": "github.com/elastic/beats/libbeat/processors/add_cloud_metadata", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z", + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z", "version": "master", "versionExact": "master" }, { - "checksumSHA1": "bJALxMP7ohe+6RcLkChwweME0jQ=", + "checksumSHA1": "O0CSXnFDU69TzhCkboDUtQQWxkg=", "path": "github.com/elastic/beats/libbeat/processors/add_docker_metadata", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z", + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z", "version": "master", "versionExact": "master" }, { - "checksumSHA1": "/mCbjskMrPfIPg0lH0cD2lk/PlM=", + "checksumSHA1": "P4tVTSmoD/HQdrk/OcR9pZ6wTNE=", "path": "github.com/elastic/beats/libbeat/processors/add_host_metadata", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z", + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z", "version": "master", "versionExact": "master" }, { - "checksumSHA1": "QtczFavHgk0uKduSMTfhKc74rmQ=", + "checksumSHA1": "qyTroY++dZSEpklOKFZsS47zBQM=", "path": "github.com/elastic/beats/libbeat/processors/add_kubernetes_metadata", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z", + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z", "version": "master", "versionExact": "master" }, { - "checksumSHA1": "UCfWJFoOVRzY1nQ+mAHT+mpGYv4=", + "checksumSHA1": "Gq+gEFL9CgrhQZOMYj0tfvyNIZs=", "path": "github.com/elastic/beats/libbeat/processors/add_locale", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z", + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z", "version": "master", "versionExact": "master" }, { - "checksumSHA1": "bFOdAL7Pve6+vCQzQHvy/BAGeL4=", + "checksumSHA1": "g/RwqHqNkrsabBoq0Zw1TGEyp9E=", "path": "github.com/elastic/beats/libbeat/processors/dissect", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z", + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z", "version": "master", "versionExact": "master" }, { - "checksumSHA1": "3kyV9PwlSwcLnK9SWKX97Gh7c00=", + "checksumSHA1": "7kYMLJJXmsDd9GyXgq9Z9eJdqrk=", "path": "github.com/elastic/beats/libbeat/publisher", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z", + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z", "version": "master", "versionExact": "master" }, { - "checksumSHA1": "1o8H8N6gEznJwpTwmtlgDu9o+/A=", + "checksumSHA1": "X8cgQCH4iuEYK+xHRIxSL+4XFvw=", "path": "github.com/elastic/beats/libbeat/publisher/includes", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z", + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z", "version": "master", "versionExact": "master" }, { - "checksumSHA1": "R7t+F4ptdZLZsOgq9dT/8bANNxE=", + "checksumSHA1": "xg+XLip6+PSB+988Tydsq/fAZ4Y=", "path": "github.com/elastic/beats/libbeat/publisher/pipeline", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z", + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z", "version": "master", "versionExact": "master" }, { - "checksumSHA1": "k/1pxNUislJBfsjb/yZVG7+YP28=", + "checksumSHA1": "DbcMU2i1+n00kcxLi2p/OpJZrUw=", "path": "github.com/elastic/beats/libbeat/publisher/queue", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z", + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z", "version": "master", "versionExact": "master" }, { - "checksumSHA1": "dWDK9p/Axnnr9A/kM4qhsh2arhQ=", + "checksumSHA1": "MzWPsoESFxMm/rba5+ZBy1MfCGs=", "path": "github.com/elastic/beats/libbeat/publisher/queue/memqueue", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z", + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z", "version": "master", "versionExact": "master" }, { - "checksumSHA1": "WBGat3DLazDLWWhh+kkbl+HXId8=", + "checksumSHA1": "yps/KKBCri9bScyQpf3WNh/Kqd0=", "path": "github.com/elastic/beats/libbeat/publisher/queue/spool", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z", + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z", "version": "master", "versionExact": "master" }, { - "checksumSHA1": "OZKgeedHl9I4WOMR+7ROvCJR9pU=", + "checksumSHA1": "fZ5S9LEZUcy5JlhwpHBn4MGNjOg=", "path": "github.com/elastic/beats/libbeat/publisher/testing", - "revision": "15d95395dd87cdbde0b622a770d48103141362e4", - "revisionTime": "2018-05-10T09:30:25Z", + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z", "version": "master", "versionExact": "master" }, { - "checksumSHA1": "AQpIjVClosTUbCL9bFO0onlxr9Y=", + "checksumSHA1": "6fUK+ATQJiNqlA8QnB6iM6xn/ME=", "path": "github.com/elastic/beats/libbeat/service", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z", + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z", "version": "master", "versionExact": "master" }, @@ -1013,26 +1035,26 @@ "versionExact": "master" }, { - "checksumSHA1": "f+1pt1fadxpvNWqkN/Fd7aPSMo4=", + "checksumSHA1": "X5Zy0zc8WczySOZedIzR3Eb6XS0=", "path": "github.com/elastic/beats/libbeat/template", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z", + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z", "version": "master", "versionExact": "master" }, { - "checksumSHA1": "p+um0Jv/tT4q7+rCQS7dxq50Ws0=", + "checksumSHA1": "cUaub8fyxT3TmLTy5mUA1qZ5lJc=", "path": "github.com/elastic/beats/libbeat/testing", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z", + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z", "version": "master", "versionExact": "master" }, { - "checksumSHA1": "70PCkIykADgatq8ExOSFudQ2U90=", + "checksumSHA1": "Z4Su3+qWumYRW/okmo/VAi762Ys=", "path": "github.com/elastic/beats/libbeat/version", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z", + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z", "version": "master", "versionExact": "master" }, @@ -1040,29 +1062,29 @@ "checksumSHA1": "3jizmlZPCyo6FAZY8Trk9jA8NH4=", "origin": "github.com/elastic/beats/vendor/github.com/elastic/go-lumber/client/v2", "path": "github.com/elastic/go-lumber/client/v2", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z" + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z" }, { "checksumSHA1": "m6HLKpDAZlkTTQMqabf3aT6TQ/s=", "origin": "github.com/elastic/beats/vendor/github.com/elastic/go-lumber/protocol/v2", "path": "github.com/elastic/go-lumber/protocol/v2", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z" + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z" }, { "checksumSHA1": "TatpgVf9fhQp1GtNwSyNw5cgVKM=", "origin": "github.com/elastic/beats/vendor/github.com/elastic/go-seccomp-bpf", "path": "github.com/elastic/go-seccomp-bpf", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z" + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z" }, { "checksumSHA1": "qTs7QT+GC2Dr4aFoLFHCkAOoVeU=", "origin": "github.com/elastic/beats/vendor/github.com/elastic/go-seccomp-bpf/arch", "path": "github.com/elastic/go-seccomp-bpf/arch", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z" + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z" }, { "checksumSHA1": "BY+a5iQICad7U2AZqwej2SIW9J8=", @@ -1188,43 +1210,43 @@ "checksumSHA1": "61XUpyQ3zWnJ7Tlj0xLsHtnzwJY=", "origin": "github.com/elastic/beats/vendor/github.com/elastic/go-ucfg", "path": "github.com/elastic/go-ucfg", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z" + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z" }, { "checksumSHA1": "8cr5YhslUMgpvF2JebYvKC+Ezr4=", "origin": "github.com/elastic/beats/vendor/github.com/elastic/go-ucfg/cfgutil", "path": "github.com/elastic/go-ucfg/cfgutil", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z" + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z" }, { "checksumSHA1": "Q2qrc/nI9d1tNzWTmfrkWvBNqsc=", "origin": "github.com/elastic/beats/vendor/github.com/elastic/go-ucfg/flag", "path": "github.com/elastic/go-ucfg/flag", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z" + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z" }, { "checksumSHA1": "uOrhvj7stlb0foxGZ5vbC1XJeto=", "origin": "github.com/elastic/beats/vendor/github.com/elastic/go-ucfg/internal/parse", "path": "github.com/elastic/go-ucfg/internal/parse", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z" + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z" }, { "checksumSHA1": "sMBM95+VYBPhwtNVHqqN1yrvk1o=", "origin": "github.com/elastic/beats/vendor/github.com/elastic/go-ucfg/json", "path": "github.com/elastic/go-ucfg/json", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z" + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z" }, { "checksumSHA1": "qvzj0KzxrWvYhHIbo+FwBxUNDFw=", "origin": "github.com/elastic/beats/vendor/github.com/elastic/go-ucfg/yaml", "path": "github.com/elastic/go-ucfg/yaml", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z" + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z" }, { "checksumSHA1": "yu/X+qHftvfQlAnjPdYLwrDn2nI=", @@ -1236,218 +1258,218 @@ "checksumSHA1": "RPOLNUpw00QUUaA/U4YbPVf6WlA=", "origin": "github.com/elastic/beats/vendor/github.com/elastic/gosigar", "path": "github.com/elastic/gosigar", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z" + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z" }, { "checksumSHA1": "TX9y4oPL5YmT4Gb/OU4GIPTdQB4=", "origin": "github.com/elastic/beats/vendor/github.com/elastic/gosigar/cgroup", "path": "github.com/elastic/gosigar/cgroup", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z" + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z" }, { "checksumSHA1": "hPqGM3DENaGfipEODoyZ4mKogTQ=", "origin": "github.com/elastic/beats/vendor/github.com/elastic/gosigar/sys", "path": "github.com/elastic/gosigar/sys", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z" + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z" }, { "checksumSHA1": "mLq5lOyD0ZU39ysXuf1ETOLJ+f0=", "origin": "github.com/elastic/beats/vendor/github.com/elastic/gosigar/sys/linux", "path": "github.com/elastic/gosigar/sys/linux", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z" + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z" }, { "checksumSHA1": "qDsgp2kAeI9nhj565HUScaUyjU4=", "origin": "github.com/elastic/beats/vendor/github.com/elastic/gosigar/sys/windows", "path": "github.com/elastic/gosigar/sys/windows", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z" + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z" }, { "checksumSHA1": "hTxFrbA619JCHysWjXHa9U6bfto=", "origin": "github.com/elastic/beats/vendor/github.com/ericchiang/k8s", "path": "github.com/ericchiang/k8s", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z" + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z" }, { "checksumSHA1": "y8fNiBLSoGojnUsGDsdLlsJYyqQ=", "origin": "github.com/elastic/beats/vendor/github.com/ericchiang/k8s/apis/apiextensions/v1beta1", "path": "github.com/ericchiang/k8s/apis/apiextensions/v1beta1", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z" + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z" }, { "checksumSHA1": "JxQ/zEWQSrncYNKifCuMctq+Tsw=", "origin": "github.com/elastic/beats/vendor/github.com/ericchiang/k8s/apis/apps/v1beta1", "path": "github.com/ericchiang/k8s/apis/apps/v1beta1", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z" + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z" }, { "checksumSHA1": "bjklGt/pc6kWOZewAw87Hchw5oY=", "origin": "github.com/elastic/beats/vendor/github.com/ericchiang/k8s/apis/authentication/v1", "path": "github.com/ericchiang/k8s/apis/authentication/v1", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z" + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z" }, { "checksumSHA1": "LExhnM9Vn0LQoLQWszQ7aIxDxb4=", "origin": "github.com/elastic/beats/vendor/github.com/ericchiang/k8s/apis/authentication/v1beta1", "path": "github.com/ericchiang/k8s/apis/authentication/v1beta1", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z" + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z" }, { "checksumSHA1": "GM+PzOiBoq3cxx4h5RKVUb3UH60=", "origin": "github.com/elastic/beats/vendor/github.com/ericchiang/k8s/apis/authorization/v1", "path": "github.com/ericchiang/k8s/apis/authorization/v1", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z" + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z" }, { "checksumSHA1": "zfr5oUVjbWRfvXi2LJiGMfFeDQY=", "origin": "github.com/elastic/beats/vendor/github.com/ericchiang/k8s/apis/authorization/v1beta1", "path": "github.com/ericchiang/k8s/apis/authorization/v1beta1", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z" + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z" }, { "checksumSHA1": "izkXNDp5a5WP45jU0hSfTrwyfvM=", "origin": "github.com/elastic/beats/vendor/github.com/ericchiang/k8s/apis/autoscaling/v1", "path": "github.com/ericchiang/k8s/apis/autoscaling/v1", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z" + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z" }, { "checksumSHA1": "FryZuAxWn4Ig8zc913w9BdfYzvs=", "origin": "github.com/elastic/beats/vendor/github.com/ericchiang/k8s/apis/batch/v1", "path": "github.com/ericchiang/k8s/apis/batch/v1", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z" + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z" }, { "checksumSHA1": "ylo7Z8wyJD+tmICB7wsOVIBpO+U=", "origin": "github.com/elastic/beats/vendor/github.com/ericchiang/k8s/apis/batch/v2alpha1", "path": "github.com/ericchiang/k8s/apis/batch/v2alpha1", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z" + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z" }, { "checksumSHA1": "+d8+mSdkdcPWQIpczXDZZW0lrjg=", "origin": "github.com/elastic/beats/vendor/github.com/ericchiang/k8s/apis/certificates/v1beta1", "path": "github.com/ericchiang/k8s/apis/certificates/v1beta1", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z" + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z" }, { "checksumSHA1": "S7AvxmCe/+WoFP/v9lZr0Mv66qg=", "origin": "github.com/elastic/beats/vendor/github.com/ericchiang/k8s/apis/core/v1", "path": "github.com/ericchiang/k8s/apis/core/v1", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z" + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z" }, { "checksumSHA1": "cWPoP6XZN7WMnEVMPcgPgg3Aw9Q=", "origin": "github.com/elastic/beats/vendor/github.com/ericchiang/k8s/apis/extensions/v1beta1", "path": "github.com/ericchiang/k8s/apis/extensions/v1beta1", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z" + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z" }, { "checksumSHA1": "vaNrBPcGWeDd1rXl8+uN08uxWhE=", "origin": "github.com/elastic/beats/vendor/github.com/ericchiang/k8s/apis/imagepolicy/v1alpha1", "path": "github.com/ericchiang/k8s/apis/imagepolicy/v1alpha1", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z" + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z" }, { "checksumSHA1": "UNTTH+Ppu4vImnF+bPkG3/NR3gg=", "origin": "github.com/elastic/beats/vendor/github.com/ericchiang/k8s/apis/meta/v1", "path": "github.com/ericchiang/k8s/apis/meta/v1", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z" + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z" }, { "checksumSHA1": "Mmyg9Wh+FCVR6fV8MGEKRxvqZ2k=", "origin": "github.com/elastic/beats/vendor/github.com/ericchiang/k8s/apis/policy/v1beta1", "path": "github.com/ericchiang/k8s/apis/policy/v1beta1", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z" + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z" }, { "checksumSHA1": "bvwYS/wrBkyAfvCjzMbi/vKamrQ=", "origin": "github.com/elastic/beats/vendor/github.com/ericchiang/k8s/apis/rbac/v1alpha1", "path": "github.com/ericchiang/k8s/apis/rbac/v1alpha1", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z" + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z" }, { "checksumSHA1": "m1Tde18NwewnvJoOYL3uykNcBuM=", "origin": "github.com/elastic/beats/vendor/github.com/ericchiang/k8s/apis/rbac/v1beta1", "path": "github.com/ericchiang/k8s/apis/rbac/v1beta1", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z" + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z" }, { "checksumSHA1": "JirJkoeIkWJRNrbprsQvqwisxds=", "origin": "github.com/elastic/beats/vendor/github.com/ericchiang/k8s/apis/resource", "path": "github.com/ericchiang/k8s/apis/resource", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z" + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z" }, { "checksumSHA1": "rQZ69PjEClQQ+PGEHRKzkGVVQyw=", "origin": "github.com/elastic/beats/vendor/github.com/ericchiang/k8s/apis/settings/v1alpha1", "path": "github.com/ericchiang/k8s/apis/settings/v1alpha1", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z" + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z" }, { "checksumSHA1": "pp0AetmPoKy7Rz0zNhBwUpExkbc=", "origin": "github.com/elastic/beats/vendor/github.com/ericchiang/k8s/apis/storage/v1", "path": "github.com/ericchiang/k8s/apis/storage/v1", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z" + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z" }, { "checksumSHA1": "WeACcIrS4EkeBm8TTftwuVniaWk=", "origin": "github.com/elastic/beats/vendor/github.com/ericchiang/k8s/apis/storage/v1beta1", "path": "github.com/ericchiang/k8s/apis/storage/v1beta1", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z" + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z" }, { "checksumSHA1": "Su6wSR8V8HL2QZsF8icJ0R9AFq8=", "origin": "github.com/elastic/beats/vendor/github.com/ericchiang/k8s/runtime", "path": "github.com/ericchiang/k8s/runtime", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z" + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z" }, { "checksumSHA1": "8ETrRvIaXPfD21N7fa8kdbumL00=", "origin": "github.com/elastic/beats/vendor/github.com/ericchiang/k8s/runtime/schema", "path": "github.com/ericchiang/k8s/runtime/schema", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z" + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z" }, { "checksumSHA1": "cMk3HE8/81ExHuEs0F5sZCclOFs=", "origin": "github.com/elastic/beats/vendor/github.com/ericchiang/k8s/util/intstr", "path": "github.com/ericchiang/k8s/util/intstr", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z" + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z" }, { "checksumSHA1": "fobEKiMk5D7IGvCSwh4HdG1o98c=", "origin": "github.com/elastic/beats/vendor/github.com/ericchiang/k8s/watch/versioned", "path": "github.com/ericchiang/k8s/watch/versioned", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z" + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z" }, { "checksumSHA1": "AANTVr9CVVyzsgviODY6Wi2thuM=", @@ -1459,22 +1481,22 @@ "checksumSHA1": "2UmMbNHc8FBr98mJFN1k8ISOIHk=", "origin": "github.com/elastic/beats/vendor/github.com/garyburd/redigo/internal", "path": "github.com/garyburd/redigo/internal", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z" + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z" }, { "checksumSHA1": "507OiSqTxfGCje7xDT5eq9CCaNQ=", "origin": "github.com/elastic/beats/vendor/github.com/garyburd/redigo/redis", "path": "github.com/garyburd/redigo/redis", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z" + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z" }, { "checksumSHA1": "ImX1uv6O09ggFeBPUJJ2nu7MPSA=", "origin": "github.com/elastic/beats/vendor/github.com/ghodss/yaml", "path": "github.com/ghodss/yaml", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z" + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z" }, { "checksumSHA1": "gxV/cPPLkByTdY8y172t7v4qcZA=", @@ -1504,15 +1526,15 @@ "checksumSHA1": "kBeNcaKk56FguvPSUCEaH6AxpRc=", "origin": "github.com/elastic/beats/vendor/github.com/golang/protobuf/proto", "path": "github.com/golang/protobuf/proto", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z" + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z" }, { "checksumSHA1": "p/8vSviYF91gFflhrt5vkyksroo=", "origin": "github.com/elastic/beats/vendor/github.com/golang/snappy", "path": "github.com/golang/snappy", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z" + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z" }, { "checksumSHA1": "d9PxF1XQGLMJZRct2R8qVM/eYlE=", @@ -1536,8 +1558,8 @@ "checksumSHA1": "l9wW52CYGbmO/NGwYZ/Op2QTmaA=", "origin": "github.com/elastic/beats/vendor/github.com/joeshaw/multierror", "path": "github.com/joeshaw/multierror", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z" + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z" }, { "checksumSHA1": "pa+ZwMzIv+u+BlL8Q2xgL9cQtJg=", @@ -1549,29 +1571,83 @@ "checksumSHA1": "+CqJGh7NIDMnHgScq9sl9tPrnVM=", "origin": "github.com/elastic/beats/vendor/github.com/klauspost/compress/flate", "path": "github.com/klauspost/compress/flate", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z" + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z" }, { "checksumSHA1": "+azPXaZpPF14YHRghNAer13ThQU=", "origin": "github.com/elastic/beats/vendor/github.com/klauspost/compress/zlib", "path": "github.com/klauspost/compress/zlib", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z" + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z" }, { "checksumSHA1": "iKPMvbAueGfdyHcWCgzwKzm8WVo=", "origin": "github.com/elastic/beats/vendor/github.com/klauspost/cpuid", "path": "github.com/klauspost/cpuid", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z" + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z" }, { "checksumSHA1": "BM6ZlNJmtKy3GBoWwg2X55gnZ4A=", "origin": "github.com/elastic/beats/vendor/github.com/klauspost/crc32", "path": "github.com/klauspost/crc32", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z" + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z" + }, + { + "checksumSHA1": "k3e1TD8wrhxfUUG3pQBb10ppNGA=", + "path": "github.com/magefile/mage", + "revision": "5e51f9ad1ed0886c5d06a8c46a09703cfc4d9034", + "revisionTime": "2018-04-12T15:54:34Z" + }, + { + "checksumSHA1": "KODorM0Am1g55qObNz3jVOdRVFs=", + "path": "github.com/magefile/mage/build", + "revision": "5e51f9ad1ed0886c5d06a8c46a09703cfc4d9034", + "revisionTime": "2018-04-12T15:54:34Z" + }, + { + "checksumSHA1": "9yeXUlqhNcsR7MlYMouJTO3AXv0=", + "path": "github.com/magefile/mage/mage", + "revision": "5e51f9ad1ed0886c5d06a8c46a09703cfc4d9034", + "revisionTime": "2018-04-12T15:54:34Z" + }, + { + "checksumSHA1": "TkAemcxaY44gsEjO1BiBxwlEI4A=", + "path": "github.com/magefile/mage/mg", + "revision": "5e51f9ad1ed0886c5d06a8c46a09703cfc4d9034", + "revisionTime": "2018-04-12T15:54:34Z" + }, + { + "checksumSHA1": "b1qY9BFtpJnIZEa8yvpJCRbOhRM=", + "path": "github.com/magefile/mage/parse", + "revision": "5e51f9ad1ed0886c5d06a8c46a09703cfc4d9034", + "revisionTime": "2018-04-12T15:54:34Z" + }, + { + "checksumSHA1": "fEuDveZzYX6oqYOT9jqyZROun/Q=", + "path": "github.com/magefile/mage/parse/srcimporter", + "revision": "5e51f9ad1ed0886c5d06a8c46a09703cfc4d9034", + "revisionTime": "2018-04-12T15:54:34Z" + }, + { + "checksumSHA1": "0/j3qlGc8fsWG42uIDZ5p8tVzPM=", + "path": "github.com/magefile/mage/sh", + "revision": "5e51f9ad1ed0886c5d06a8c46a09703cfc4d9034", + "revisionTime": "2018-04-12T15:54:34Z" + }, + { + "checksumSHA1": "oAjx69UIs6F6hPh+2GQSBMaHAfc=", + "path": "github.com/magefile/mage/target", + "revision": "5e51f9ad1ed0886c5d06a8c46a09703cfc4d9034", + "revisionTime": "2018-04-12T15:54:34Z" + }, + { + "checksumSHA1": "He+VtZO7BsPDCZhZtJ1IkNp629o=", + "path": "github.com/magefile/mage/types", + "revision": "5e51f9ad1ed0886c5d06a8c46a09703cfc4d9034", + "revisionTime": "2018-04-12T15:54:34Z" }, { "checksumSHA1": "bfGiF5iraNvFHCCK3KVvITsPCok=", @@ -1589,29 +1665,29 @@ "checksumSHA1": "sWdAYPKyaT4SW8hNQNpRS0sU4lU=", "origin": "github.com/elastic/beats/vendor/github.com/mitchellh/hashstructure", "path": "github.com/mitchellh/hashstructure", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z" + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z" }, { "checksumSHA1": "2AyUkWjutec6p+470tgio8mYOxI=", "origin": "github.com/elastic/beats/vendor/github.com/opencontainers/go-digest", "path": "github.com/opencontainers/go-digest", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z" + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z" }, { "checksumSHA1": "eOMCORUm8KxiGSy0hBuQsMsxauo=", "origin": "github.com/elastic/beats/vendor/github.com/opencontainers/image-spec/specs-go", "path": "github.com/opencontainers/image-spec/specs-go", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z" + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z" }, { "checksumSHA1": "9YujSsJjiLGkQMzwWycsjqR340k=", "origin": "github.com/elastic/beats/vendor/github.com/opencontainers/image-spec/specs-go/v1", "path": "github.com/opencontainers/image-spec/specs-go/v1", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z" + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z" }, { "checksumSHA1": "JVGDxPn66bpe6xEiexs1r+y6jF0=", @@ -1623,22 +1699,22 @@ "checksumSHA1": "WmrPO1ovmQ7t7hs9yZGbr2SAoM4=", "origin": "github.com/elastic/beats/vendor/github.com/pierrec/lz4", "path": "github.com/pierrec/lz4", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z" + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z" }, { "checksumSHA1": "IT4sX58d+e8osXHV5U6YCSdB/uE=", "origin": "github.com/elastic/beats/vendor/github.com/pierrec/xxHash/xxHash32", "path": "github.com/pierrec/xxHash/xxHash32", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z" + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z" }, { "checksumSHA1": "PdQm3s8DoVJ17Vk8n7o5iPa7PK0=", "origin": "github.com/elastic/beats/vendor/github.com/pkg/errors", "path": "github.com/pkg/errors", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z" + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z" }, { "checksumSHA1": "LuFv4/jlrmFNnDb/5SCSEPAM9vU=", @@ -1676,8 +1752,8 @@ "checksumSHA1": "KAzbLjI9MzW2tjfcAsK75lVRp6I=", "origin": "github.com/elastic/beats/vendor/github.com/rcrowley/go-metrics", "path": "github.com/rcrowley/go-metrics", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z" + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z" }, { "checksumSHA1": "6JP37UqrI0H80Gpk0Y2P+KXgn5M=", @@ -1725,8 +1801,8 @@ "checksumSHA1": "zmC8/3V4ls53DJlNTKDZwPSC/dA=", "origin": "github.com/elastic/beats/vendor/github.com/satori/go.uuid", "path": "github.com/satori/go.uuid", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z" + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z" }, { "checksumSHA1": "v7C+aJ1D/z3MEeCte6bxvpoGjM4=", @@ -1867,29 +1943,29 @@ "checksumSHA1": "dr5+PfIRzXeN+l1VG+s0lea9qz8=", "origin": "github.com/elastic/beats/vendor/golang.org/x/net/context", "path": "golang.org/x/net/context", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z" + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z" }, { "checksumSHA1": "WHc3uByvGaMcnSoI21fhzYgbOgg=", "origin": "github.com/elastic/beats/vendor/golang.org/x/net/context/ctxhttp", "path": "golang.org/x/net/context/ctxhttp", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z" + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z" }, { "checksumSHA1": "TWcqN2+KUWtdqnu18rruwn14UEQ=", "origin": "github.com/elastic/beats/vendor/golang.org/x/net/http2", "path": "golang.org/x/net/http2", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z" + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z" }, { "checksumSHA1": "ezWhc7n/FtqkLDQKeU2JbW+80tE=", "origin": "github.com/elastic/beats/vendor/golang.org/x/net/http2/hpack", "path": "golang.org/x/net/http2/hpack", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z" + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z" }, { "checksumSHA1": "RcrB7tgYS/GMW4QrwVdMOTNqIU8=", @@ -1901,8 +1977,8 @@ "checksumSHA1": "3xyuaSNmClqG4YWC7g0isQIbUTc=", "origin": "github.com/elastic/beats/vendor/golang.org/x/net/lex/httplex", "path": "golang.org/x/net/lex/httplex", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z" + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z" }, { "checksumSHA1": "whCSspa9pYarl527EuhPz91cbUE=", @@ -1914,8 +1990,8 @@ "checksumSHA1": "QEm/dePZ0lOnyOs+m22KjXfJ/IU=", "origin": "github.com/elastic/beats/vendor/golang.org/x/net/proxy", "path": "golang.org/x/net/proxy", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z" + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z" }, { "checksumSHA1": "S0DP7Pn7sZUmXc55IzZnNvERu6s=", @@ -1927,15 +2003,15 @@ "checksumSHA1": "CNHEeGnucEUlTHJrLS2kHtfNbws=", "origin": "github.com/elastic/beats/vendor/golang.org/x/sys/unix", "path": "golang.org/x/sys/unix", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z" + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z" }, { "checksumSHA1": "eQq+ZoTWPjyizS9XalhZwfGjQao=", "origin": "github.com/elastic/beats/vendor/golang.org/x/sys/windows", "path": "golang.org/x/sys/windows", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z" + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z" }, { "checksumSHA1": "ZdFZFaXmCgEEaEhVPkyXrnhKhsg=", @@ -1947,15 +2023,15 @@ "checksumSHA1": "VNlkHemg81Ba7ElHfKKUU1h+U1U=", "origin": "github.com/elastic/beats/vendor/golang.org/x/sys/windows/svc", "path": "golang.org/x/sys/windows/svc", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z" + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z" }, { "checksumSHA1": "lZi+t2ilFyYSpqL1ThwNf8ot3WQ=", "origin": "github.com/elastic/beats/vendor/golang.org/x/sys/windows/svc/debug", "path": "golang.org/x/sys/windows/svc/debug", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z" + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z" }, { "checksumSHA1": "uVlUSSKplihZG7N+QJ6fzDZ4Kh8=", @@ -1993,12 +2069,18 @@ "revision": "8be79e1e0910c292df4e79c241bb7e8f7e725959", "revisionTime": "2017-04-24T23:28:54Z" }, + { + "checksumSHA1": "iF6AIRhNvnaONazwHIJkBVG6kXU=", + "path": "golang.org/x/tools/go/vcs", + "revision": "1c99e1239a0c8b0e59c34000995c4e319b7702ca", + "revisionTime": "2018-06-27T20:58:43Z" + }, { "checksumSHA1": "fALlQNY1fM99NesfLJ50KguWsio=", "origin": "github.com/elastic/beats/vendor/gopkg.in/yaml.v2", "path": "gopkg.in/yaml.v2", - "revision": "c941a3d38792137bfc53a3a121f40cebf20b5512", - "revisionTime": "2018-06-13T21:14:35Z" + "revision": "64e6a72f19e37b2a46155ff293835e2494424655", + "revisionTime": "2018-06-29T13:51:07Z" }, { "checksumSHA1": "tFDvoOebIC12z/m4GKPqrE7BrUM=",