diff --git a/vendor.conf b/vendor.conf index 6f22a350..aa19b3da 100644 --- a/vendor.conf +++ b/vendor.conf @@ -3,3 +3,4 @@ github.com/rancher/types github.com/pkg/errors v0.8.0 github.com/rancher/norman 1d24e0fc0b0a92dfc48012e82219e0d584cb8b0b transitive=true +github.com/coreos/prometheus-operator v0.25.0 diff --git a/vendor/github.com/PuerkitoBio/purell/.gitignore b/vendor/github.com/PuerkitoBio/purell/.gitignore new file mode 100644 index 00000000..748e4c80 --- /dev/null +++ b/vendor/github.com/PuerkitoBio/purell/.gitignore @@ -0,0 +1,5 @@ +*.sublime-* +.DS_Store +*.swp +*.swo +tags diff --git a/vendor/github.com/PuerkitoBio/purell/.travis.yml b/vendor/github.com/PuerkitoBio/purell/.travis.yml new file mode 100644 index 00000000..facfc91c --- /dev/null +++ b/vendor/github.com/PuerkitoBio/purell/.travis.yml @@ -0,0 +1,7 @@ +language: go + +go: + - 1.4 + - 1.5 + - 1.6 + - tip diff --git a/vendor/github.com/PuerkitoBio/purell/LICENSE b/vendor/github.com/PuerkitoBio/purell/LICENSE new file mode 100644 index 00000000..4b9986de --- /dev/null +++ b/vendor/github.com/PuerkitoBio/purell/LICENSE @@ -0,0 +1,12 @@ +Copyright (c) 2012, Martin Angers +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 the author 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 HOLDER 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/github.com/PuerkitoBio/purell/README.md b/vendor/github.com/PuerkitoBio/purell/README.md new file mode 100644 index 00000000..a78a3df6 --- /dev/null +++ b/vendor/github.com/PuerkitoBio/purell/README.md @@ -0,0 +1,185 @@ +# Purell + +Purell is a tiny Go library to normalize URLs. It returns a pure URL. Pure-ell. Sanitizer and all. Yeah, I know... + +Based on the [wikipedia paper][wiki] and the [RFC 3986 document][rfc]. + +[![build status](https://secure.travis-ci.org/PuerkitoBio/purell.png)](http://travis-ci.org/PuerkitoBio/purell) + +## Install + +`go get github.com/PuerkitoBio/purell` + +## Changelog + +* **2016-07-27 (v1.0.0)** : Normalize IDN to ASCII (thanks to @zenovich). +* **2015-02-08** : Add fix for relative paths issue ([PR #5][pr5]) and add fix for unnecessary encoding of reserved characters ([see issue #7][iss7]). +* **v0.2.0** : Add benchmarks, Attempt IDN support. +* **v0.1.0** : Initial release. + +## Examples + +From `example_test.go` (note that in your code, you would import "github.com/PuerkitoBio/purell", and would prefix references to its methods and constants with "purell."): + +```go +package purell + +import ( + "fmt" + "net/url" +) + +func ExampleNormalizeURLString() { + if normalized, err := NormalizeURLString("hTTp://someWEBsite.com:80/Amazing%3f/url/", + FlagLowercaseScheme|FlagLowercaseHost|FlagUppercaseEscapes); err != nil { + panic(err) + } else { + fmt.Print(normalized) + } + // Output: http://somewebsite.com:80/Amazing%3F/url/ +} + +func ExampleMustNormalizeURLString() { + normalized := MustNormalizeURLString("hTTpS://someWEBsite.com:443/Amazing%fa/url/", + FlagsUnsafeGreedy) + fmt.Print(normalized) + + // Output: http://somewebsite.com/Amazing%FA/url +} + +func ExampleNormalizeURL() { + if u, err := url.Parse("Http://SomeUrl.com:8080/a/b/.././c///g?c=3&a=1&b=9&c=0#target"); err != nil { + panic(err) + } else { + normalized := NormalizeURL(u, FlagsUsuallySafeGreedy|FlagRemoveDuplicateSlashes|FlagRemoveFragment) + fmt.Print(normalized) + } + + // Output: http://someurl.com:8080/a/c/g?c=3&a=1&b=9&c=0 +} +``` + +## API + +As seen in the examples above, purell offers three methods, `NormalizeURLString(string, NormalizationFlags) (string, error)`, `MustNormalizeURLString(string, NormalizationFlags) (string)` and `NormalizeURL(*url.URL, NormalizationFlags) (string)`. They all normalize the provided URL based on the specified flags. Here are the available flags: + +```go +const ( + // Safe normalizations + FlagLowercaseScheme NormalizationFlags = 1 << iota // HTTP://host -> http://host, applied by default in Go1.1 + FlagLowercaseHost // http://HOST -> http://host + FlagUppercaseEscapes // http://host/t%ef -> http://host/t%EF + FlagDecodeUnnecessaryEscapes // http://host/t%41 -> http://host/tA + FlagEncodeNecessaryEscapes // http://host/!"#$ -> http://host/%21%22#$ + FlagRemoveDefaultPort // http://host:80 -> http://host + FlagRemoveEmptyQuerySeparator // http://host/path? -> http://host/path + + // Usually safe normalizations + FlagRemoveTrailingSlash // http://host/path/ -> http://host/path + FlagAddTrailingSlash // http://host/path -> http://host/path/ (should choose only one of these add/remove trailing slash flags) + FlagRemoveDotSegments // http://host/path/./a/b/../c -> http://host/path/a/c + + // Unsafe normalizations + FlagRemoveDirectoryIndex // http://host/path/index.html -> http://host/path/ + FlagRemoveFragment // http://host/path#fragment -> http://host/path + FlagForceHTTP // https://host -> http://host + FlagRemoveDuplicateSlashes // http://host/path//a///b -> http://host/path/a/b + FlagRemoveWWW // http://www.host/ -> http://host/ + FlagAddWWW // http://host/ -> http://www.host/ (should choose only one of these add/remove WWW flags) + FlagSortQuery // http://host/path?c=3&b=2&a=1&b=1 -> http://host/path?a=1&b=1&b=2&c=3 + + // Normalizations not in the wikipedia article, required to cover tests cases + // submitted by jehiah + FlagDecodeDWORDHost // http://1113982867 -> http://66.102.7.147 + FlagDecodeOctalHost // http://0102.0146.07.0223 -> http://66.102.7.147 + FlagDecodeHexHost // http://0x42660793 -> http://66.102.7.147 + FlagRemoveUnnecessaryHostDots // http://.host../path -> http://host/path + FlagRemoveEmptyPortSeparator // http://host:/path -> http://host/path + + // Convenience set of safe normalizations + FlagsSafe NormalizationFlags = FlagLowercaseHost | FlagLowercaseScheme | FlagUppercaseEscapes | FlagDecodeUnnecessaryEscapes | FlagEncodeNecessaryEscapes | FlagRemoveDefaultPort | FlagRemoveEmptyQuerySeparator + + // For convenience sets, "greedy" uses the "remove trailing slash" and "remove www. prefix" flags, + // while "non-greedy" uses the "add (or keep) the trailing slash" and "add www. prefix". + + // Convenience set of usually safe normalizations (includes FlagsSafe) + FlagsUsuallySafeGreedy NormalizationFlags = FlagsSafe | FlagRemoveTrailingSlash | FlagRemoveDotSegments + FlagsUsuallySafeNonGreedy NormalizationFlags = FlagsSafe | FlagAddTrailingSlash | FlagRemoveDotSegments + + // Convenience set of unsafe normalizations (includes FlagsUsuallySafe) + FlagsUnsafeGreedy NormalizationFlags = FlagsUsuallySafeGreedy | FlagRemoveDirectoryIndex | FlagRemoveFragment | FlagForceHTTP | FlagRemoveDuplicateSlashes | FlagRemoveWWW | FlagSortQuery + FlagsUnsafeNonGreedy NormalizationFlags = FlagsUsuallySafeNonGreedy | FlagRemoveDirectoryIndex | FlagRemoveFragment | FlagForceHTTP | FlagRemoveDuplicateSlashes | FlagAddWWW | FlagSortQuery + + // Convenience set of all available flags + FlagsAllGreedy = FlagsUnsafeGreedy | FlagDecodeDWORDHost | FlagDecodeOctalHost | FlagDecodeHexHost | FlagRemoveUnnecessaryHostDots | FlagRemoveEmptyPortSeparator + FlagsAllNonGreedy = FlagsUnsafeNonGreedy | FlagDecodeDWORDHost | FlagDecodeOctalHost | FlagDecodeHexHost | FlagRemoveUnnecessaryHostDots | FlagRemoveEmptyPortSeparator +) +``` + +For convenience, the set of flags `FlagsSafe`, `FlagsUsuallySafe[Greedy|NonGreedy]`, `FlagsUnsafe[Greedy|NonGreedy]` and `FlagsAll[Greedy|NonGreedy]` are provided for the similarly grouped normalizations on [wikipedia's URL normalization page][wiki]. You can add (using the bitwise OR `|` operator) or remove (using the bitwise AND NOT `&^` operator) individual flags from the sets if required, to build your own custom set. + +The [full godoc reference is available on gopkgdoc][godoc]. + +Some things to note: + +* `FlagDecodeUnnecessaryEscapes`, `FlagEncodeNecessaryEscapes`, `FlagUppercaseEscapes` and `FlagRemoveEmptyQuerySeparator` are always implicitly set, because internally, the URL string is parsed as an URL object, which automatically decodes unnecessary escapes, uppercases and encodes necessary ones, and removes empty query separators (an unnecessary `?` at the end of the url). So this operation cannot **not** be done. For this reason, `FlagRemoveEmptyQuerySeparator` (as well as the other three) has been included in the `FlagsSafe` convenience set, instead of `FlagsUnsafe`, where Wikipedia puts it. + +* The `FlagDecodeUnnecessaryEscapes` decodes the following escapes (*from -> to*): + - %24 -> $ + - %26 -> & + - %2B-%3B -> +,-./0123456789:; + - %3D -> = + - %40-%5A -> @ABCDEFGHIJKLMNOPQRSTUVWXYZ + - %5F -> _ + - %61-%7A -> abcdefghijklmnopqrstuvwxyz + - %7E -> ~ + + +* When the `NormalizeURL` function is used (passing an URL object), this source URL object is modified (that is, after the call, the URL object will be modified to reflect the normalization). + +* The *replace IP with domain name* normalization (`http://208.77.188.166/ → http://www.example.com/`) is obviously not possible for a library without making some network requests. This is not implemented in purell. + +* The *remove unused query string parameters* and *remove default query parameters* are also not implemented, since this is a very case-specific normalization, and it is quite trivial to do with an URL object. + +### Safe vs Usually Safe vs Unsafe + +Purell allows you to control the level of risk you take while normalizing an URL. You can aggressively normalize, play it totally safe, or anything in between. + +Consider the following URL: + +`HTTPS://www.RooT.com/toto/t%45%1f///a/./b/../c/?z=3&w=2&a=4&w=1#invalid` + +Normalizing with the `FlagsSafe` gives: + +`https://www.root.com/toto/tE%1F///a/./b/../c/?z=3&w=2&a=4&w=1#invalid` + +With the `FlagsUsuallySafeGreedy`: + +`https://www.root.com/toto/tE%1F///a/c?z=3&w=2&a=4&w=1#invalid` + +And with `FlagsUnsafeGreedy`: + +`http://root.com/toto/tE%1F/a/c?a=4&w=1&w=2&z=3` + +## TODOs + +* Add a class/default instance to allow specifying custom directory index names? At the moment, removing directory index removes `(^|/)((?:default|index)\.\w{1,4})$`. + +## Thanks / Contributions + +@rogpeppe +@jehiah +@opennota +@pchristopher1275 +@zenovich + +## License + +The [BSD 3-Clause license][bsd]. + +[bsd]: http://opensource.org/licenses/BSD-3-Clause +[wiki]: http://en.wikipedia.org/wiki/URL_normalization +[rfc]: http://tools.ietf.org/html/rfc3986#section-6 +[godoc]: http://go.pkgdoc.org/github.com/PuerkitoBio/purell +[pr5]: https://github.com/PuerkitoBio/purell/pull/5 +[iss7]: https://github.com/PuerkitoBio/purell/issues/7 diff --git a/vendor/github.com/PuerkitoBio/purell/purell.go b/vendor/github.com/PuerkitoBio/purell/purell.go new file mode 100644 index 00000000..b79da64b --- /dev/null +++ b/vendor/github.com/PuerkitoBio/purell/purell.go @@ -0,0 +1,375 @@ +/* +Package purell offers URL normalization as described on the wikipedia page: +http://en.wikipedia.org/wiki/URL_normalization +*/ +package purell + +import ( + "bytes" + "fmt" + "net/url" + "regexp" + "sort" + "strconv" + "strings" + + "github.com/PuerkitoBio/urlesc" + "golang.org/x/net/idna" + "golang.org/x/text/secure/precis" + "golang.org/x/text/unicode/norm" +) + +// A set of normalization flags determines how a URL will +// be normalized. +type NormalizationFlags uint + +const ( + // Safe normalizations + FlagLowercaseScheme NormalizationFlags = 1 << iota // HTTP://host -> http://host, applied by default in Go1.1 + FlagLowercaseHost // http://HOST -> http://host + FlagUppercaseEscapes // http://host/t%ef -> http://host/t%EF + FlagDecodeUnnecessaryEscapes // http://host/t%41 -> http://host/tA + FlagEncodeNecessaryEscapes // http://host/!"#$ -> http://host/%21%22#$ + FlagRemoveDefaultPort // http://host:80 -> http://host + FlagRemoveEmptyQuerySeparator // http://host/path? -> http://host/path + + // Usually safe normalizations + FlagRemoveTrailingSlash // http://host/path/ -> http://host/path + FlagAddTrailingSlash // http://host/path -> http://host/path/ (should choose only one of these add/remove trailing slash flags) + FlagRemoveDotSegments // http://host/path/./a/b/../c -> http://host/path/a/c + + // Unsafe normalizations + FlagRemoveDirectoryIndex // http://host/path/index.html -> http://host/path/ + FlagRemoveFragment // http://host/path#fragment -> http://host/path + FlagForceHTTP // https://host -> http://host + FlagRemoveDuplicateSlashes // http://host/path//a///b -> http://host/path/a/b + FlagRemoveWWW // http://www.host/ -> http://host/ + FlagAddWWW // http://host/ -> http://www.host/ (should choose only one of these add/remove WWW flags) + FlagSortQuery // http://host/path?c=3&b=2&a=1&b=1 -> http://host/path?a=1&b=1&b=2&c=3 + + // Normalizations not in the wikipedia article, required to cover tests cases + // submitted by jehiah + FlagDecodeDWORDHost // http://1113982867 -> http://66.102.7.147 + FlagDecodeOctalHost // http://0102.0146.07.0223 -> http://66.102.7.147 + FlagDecodeHexHost // http://0x42660793 -> http://66.102.7.147 + FlagRemoveUnnecessaryHostDots // http://.host../path -> http://host/path + FlagRemoveEmptyPortSeparator // http://host:/path -> http://host/path + + // Convenience set of safe normalizations + FlagsSafe NormalizationFlags = FlagLowercaseHost | FlagLowercaseScheme | FlagUppercaseEscapes | FlagDecodeUnnecessaryEscapes | FlagEncodeNecessaryEscapes | FlagRemoveDefaultPort | FlagRemoveEmptyQuerySeparator + + // For convenience sets, "greedy" uses the "remove trailing slash" and "remove www. prefix" flags, + // while "non-greedy" uses the "add (or keep) the trailing slash" and "add www. prefix". + + // Convenience set of usually safe normalizations (includes FlagsSafe) + FlagsUsuallySafeGreedy NormalizationFlags = FlagsSafe | FlagRemoveTrailingSlash | FlagRemoveDotSegments + FlagsUsuallySafeNonGreedy NormalizationFlags = FlagsSafe | FlagAddTrailingSlash | FlagRemoveDotSegments + + // Convenience set of unsafe normalizations (includes FlagsUsuallySafe) + FlagsUnsafeGreedy NormalizationFlags = FlagsUsuallySafeGreedy | FlagRemoveDirectoryIndex | FlagRemoveFragment | FlagForceHTTP | FlagRemoveDuplicateSlashes | FlagRemoveWWW | FlagSortQuery + FlagsUnsafeNonGreedy NormalizationFlags = FlagsUsuallySafeNonGreedy | FlagRemoveDirectoryIndex | FlagRemoveFragment | FlagForceHTTP | FlagRemoveDuplicateSlashes | FlagAddWWW | FlagSortQuery + + // Convenience set of all available flags + FlagsAllGreedy = FlagsUnsafeGreedy | FlagDecodeDWORDHost | FlagDecodeOctalHost | FlagDecodeHexHost | FlagRemoveUnnecessaryHostDots | FlagRemoveEmptyPortSeparator + FlagsAllNonGreedy = FlagsUnsafeNonGreedy | FlagDecodeDWORDHost | FlagDecodeOctalHost | FlagDecodeHexHost | FlagRemoveUnnecessaryHostDots | FlagRemoveEmptyPortSeparator +) + +const ( + defaultHttpPort = ":80" + defaultHttpsPort = ":443" +) + +// Regular expressions used by the normalizations +var rxPort = regexp.MustCompile(`(:\d+)/?$`) +var rxDirIndex = regexp.MustCompile(`(^|/)((?:default|index)\.\w{1,4})$`) +var rxDupSlashes = regexp.MustCompile(`/{2,}`) +var rxDWORDHost = regexp.MustCompile(`^(\d+)((?:\.+)?(?:\:\d*)?)$`) +var rxOctalHost = regexp.MustCompile(`^(0\d*)\.(0\d*)\.(0\d*)\.(0\d*)((?:\.+)?(?:\:\d*)?)$`) +var rxHexHost = regexp.MustCompile(`^0x([0-9A-Fa-f]+)((?:\.+)?(?:\:\d*)?)$`) +var rxHostDots = regexp.MustCompile(`^(.+?)(:\d+)?$`) +var rxEmptyPort = regexp.MustCompile(`:+$`) + +// Map of flags to implementation function. +// FlagDecodeUnnecessaryEscapes has no action, since it is done automatically +// by parsing the string as an URL. Same for FlagUppercaseEscapes and FlagRemoveEmptyQuerySeparator. + +// Since maps have undefined traversing order, make a slice of ordered keys +var flagsOrder = []NormalizationFlags{ + FlagLowercaseScheme, + FlagLowercaseHost, + FlagRemoveDefaultPort, + FlagRemoveDirectoryIndex, + FlagRemoveDotSegments, + FlagRemoveFragment, + FlagForceHTTP, // Must be after remove default port (because https=443/http=80) + FlagRemoveDuplicateSlashes, + FlagRemoveWWW, + FlagAddWWW, + FlagSortQuery, + FlagDecodeDWORDHost, + FlagDecodeOctalHost, + FlagDecodeHexHost, + FlagRemoveUnnecessaryHostDots, + FlagRemoveEmptyPortSeparator, + FlagRemoveTrailingSlash, // These two (add/remove trailing slash) must be last + FlagAddTrailingSlash, +} + +// ... and then the map, where order is unimportant +var flags = map[NormalizationFlags]func(*url.URL){ + FlagLowercaseScheme: lowercaseScheme, + FlagLowercaseHost: lowercaseHost, + FlagRemoveDefaultPort: removeDefaultPort, + FlagRemoveDirectoryIndex: removeDirectoryIndex, + FlagRemoveDotSegments: removeDotSegments, + FlagRemoveFragment: removeFragment, + FlagForceHTTP: forceHTTP, + FlagRemoveDuplicateSlashes: removeDuplicateSlashes, + FlagRemoveWWW: removeWWW, + FlagAddWWW: addWWW, + FlagSortQuery: sortQuery, + FlagDecodeDWORDHost: decodeDWORDHost, + FlagDecodeOctalHost: decodeOctalHost, + FlagDecodeHexHost: decodeHexHost, + FlagRemoveUnnecessaryHostDots: removeUnncessaryHostDots, + FlagRemoveEmptyPortSeparator: removeEmptyPortSeparator, + FlagRemoveTrailingSlash: removeTrailingSlash, + FlagAddTrailingSlash: addTrailingSlash, +} + +// MustNormalizeURLString returns the normalized string, and panics if an error occurs. +// It takes an URL string as input, as well as the normalization flags. +func MustNormalizeURLString(u string, f NormalizationFlags) string { + result, e := NormalizeURLString(u, f) + if e != nil { + panic(e) + } + return result +} + +// NormalizeURLString returns the normalized string, or an error if it can't be parsed into an URL object. +// It takes an URL string as input, as well as the normalization flags. +func NormalizeURLString(u string, f NormalizationFlags) (string, error) { + if parsed, e := url.Parse(u); e != nil { + return "", e + } else { + options := make([]precis.Option, 1, 3) + options[0] = precis.IgnoreCase + if f&FlagLowercaseHost == FlagLowercaseHost { + options = append(options, precis.FoldCase()) + } + options = append(options, precis.Norm(norm.NFC)) + profile := precis.NewFreeform(options...) + if parsed.Host, e = idna.ToASCII(profile.NewTransformer().String(parsed.Host)); e != nil { + return "", e + } + return NormalizeURL(parsed, f), nil + } + panic("Unreachable code.") +} + +// NormalizeURL returns the normalized string. +// It takes a parsed URL object as input, as well as the normalization flags. +func NormalizeURL(u *url.URL, f NormalizationFlags) string { + for _, k := range flagsOrder { + if f&k == k { + flags[k](u) + } + } + return urlesc.Escape(u) +} + +func lowercaseScheme(u *url.URL) { + if len(u.Scheme) > 0 { + u.Scheme = strings.ToLower(u.Scheme) + } +} + +func lowercaseHost(u *url.URL) { + if len(u.Host) > 0 { + u.Host = strings.ToLower(u.Host) + } +} + +func removeDefaultPort(u *url.URL) { + if len(u.Host) > 0 { + scheme := strings.ToLower(u.Scheme) + u.Host = rxPort.ReplaceAllStringFunc(u.Host, func(val string) string { + if (scheme == "http" && val == defaultHttpPort) || (scheme == "https" && val == defaultHttpsPort) { + return "" + } + return val + }) + } +} + +func removeTrailingSlash(u *url.URL) { + if l := len(u.Path); l > 0 { + if strings.HasSuffix(u.Path, "/") { + u.Path = u.Path[:l-1] + } + } else if l = len(u.Host); l > 0 { + if strings.HasSuffix(u.Host, "/") { + u.Host = u.Host[:l-1] + } + } +} + +func addTrailingSlash(u *url.URL) { + if l := len(u.Path); l > 0 { + if !strings.HasSuffix(u.Path, "/") { + u.Path += "/" + } + } else if l = len(u.Host); l > 0 { + if !strings.HasSuffix(u.Host, "/") { + u.Host += "/" + } + } +} + +func removeDotSegments(u *url.URL) { + if len(u.Path) > 0 { + var dotFree []string + var lastIsDot bool + + sections := strings.Split(u.Path, "/") + for _, s := range sections { + if s == ".." { + if len(dotFree) > 0 { + dotFree = dotFree[:len(dotFree)-1] + } + } else if s != "." { + dotFree = append(dotFree, s) + } + lastIsDot = (s == "." || s == "..") + } + // Special case if host does not end with / and new path does not begin with / + u.Path = strings.Join(dotFree, "/") + if u.Host != "" && !strings.HasSuffix(u.Host, "/") && !strings.HasPrefix(u.Path, "/") { + u.Path = "/" + u.Path + } + // Special case if the last segment was a dot, make sure the path ends with a slash + if lastIsDot && !strings.HasSuffix(u.Path, "/") { + u.Path += "/" + } + } +} + +func removeDirectoryIndex(u *url.URL) { + if len(u.Path) > 0 { + u.Path = rxDirIndex.ReplaceAllString(u.Path, "$1") + } +} + +func removeFragment(u *url.URL) { + u.Fragment = "" +} + +func forceHTTP(u *url.URL) { + if strings.ToLower(u.Scheme) == "https" { + u.Scheme = "http" + } +} + +func removeDuplicateSlashes(u *url.URL) { + if len(u.Path) > 0 { + u.Path = rxDupSlashes.ReplaceAllString(u.Path, "/") + } +} + +func removeWWW(u *url.URL) { + if len(u.Host) > 0 && strings.HasPrefix(strings.ToLower(u.Host), "www.") { + u.Host = u.Host[4:] + } +} + +func addWWW(u *url.URL) { + if len(u.Host) > 0 && !strings.HasPrefix(strings.ToLower(u.Host), "www.") { + u.Host = "www." + u.Host + } +} + +func sortQuery(u *url.URL) { + q := u.Query() + + if len(q) > 0 { + arKeys := make([]string, len(q)) + i := 0 + for k, _ := range q { + arKeys[i] = k + i++ + } + sort.Strings(arKeys) + buf := new(bytes.Buffer) + for _, k := range arKeys { + sort.Strings(q[k]) + for _, v := range q[k] { + if buf.Len() > 0 { + buf.WriteRune('&') + } + buf.WriteString(fmt.Sprintf("%s=%s", k, urlesc.QueryEscape(v))) + } + } + + // Rebuild the raw query string + u.RawQuery = buf.String() + } +} + +func decodeDWORDHost(u *url.URL) { + if len(u.Host) > 0 { + if matches := rxDWORDHost.FindStringSubmatch(u.Host); len(matches) > 2 { + var parts [4]int64 + + dword, _ := strconv.ParseInt(matches[1], 10, 0) + for i, shift := range []uint{24, 16, 8, 0} { + parts[i] = dword >> shift & 0xFF + } + u.Host = fmt.Sprintf("%d.%d.%d.%d%s", parts[0], parts[1], parts[2], parts[3], matches[2]) + } + } +} + +func decodeOctalHost(u *url.URL) { + if len(u.Host) > 0 { + if matches := rxOctalHost.FindStringSubmatch(u.Host); len(matches) > 5 { + var parts [4]int64 + + for i := 1; i <= 4; i++ { + parts[i-1], _ = strconv.ParseInt(matches[i], 8, 0) + } + u.Host = fmt.Sprintf("%d.%d.%d.%d%s", parts[0], parts[1], parts[2], parts[3], matches[5]) + } + } +} + +func decodeHexHost(u *url.URL) { + if len(u.Host) > 0 { + if matches := rxHexHost.FindStringSubmatch(u.Host); len(matches) > 2 { + // Conversion is safe because of regex validation + parsed, _ := strconv.ParseInt(matches[1], 16, 0) + // Set host as DWORD (base 10) encoded host + u.Host = fmt.Sprintf("%d%s", parsed, matches[2]) + // The rest is the same as decoding a DWORD host + decodeDWORDHost(u) + } + } +} + +func removeUnncessaryHostDots(u *url.URL) { + if len(u.Host) > 0 { + if matches := rxHostDots.FindStringSubmatch(u.Host); len(matches) > 1 { + // Trim the leading and trailing dots + u.Host = strings.Trim(matches[1], ".") + if len(matches) > 2 { + u.Host += matches[2] + } + } + } +} + +func removeEmptyPortSeparator(u *url.URL) { + if len(u.Host) > 0 { + u.Host = rxEmptyPort.ReplaceAllString(u.Host, "") + } +} diff --git a/vendor/github.com/PuerkitoBio/urlesc/.travis.yml b/vendor/github.com/PuerkitoBio/urlesc/.travis.yml new file mode 100644 index 00000000..478630e5 --- /dev/null +++ b/vendor/github.com/PuerkitoBio/urlesc/.travis.yml @@ -0,0 +1,11 @@ +language: go + +go: + - 1.4 + - tip + +install: + - go build . + +script: + - go test -v diff --git a/vendor/github.com/PuerkitoBio/urlesc/LICENSE b/vendor/github.com/PuerkitoBio/urlesc/LICENSE new file mode 100644 index 00000000..74487567 --- /dev/null +++ b/vendor/github.com/PuerkitoBio/urlesc/LICENSE @@ -0,0 +1,27 @@ +Copyright (c) 2012 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/github.com/PuerkitoBio/urlesc/README.md b/vendor/github.com/PuerkitoBio/urlesc/README.md new file mode 100644 index 00000000..bebe305e --- /dev/null +++ b/vendor/github.com/PuerkitoBio/urlesc/README.md @@ -0,0 +1,16 @@ +urlesc [![Build Status](https://travis-ci.org/PuerkitoBio/urlesc.png?branch=master)](https://travis-ci.org/PuerkitoBio/urlesc) [![GoDoc](http://godoc.org/github.com/PuerkitoBio/urlesc?status.svg)](http://godoc.org/github.com/PuerkitoBio/urlesc) +====== + +Package urlesc implements query escaping as per RFC 3986. + +It contains some parts of the net/url package, modified so as to allow +some reserved characters incorrectly escaped by net/url (see [issue 5684](https://github.com/golang/go/issues/5684)). + +## Install + + go get github.com/PuerkitoBio/urlesc + +## License + +Go license (BSD-3-Clause) + diff --git a/vendor/github.com/PuerkitoBio/urlesc/urlesc.go b/vendor/github.com/PuerkitoBio/urlesc/urlesc.go new file mode 100644 index 00000000..1b846245 --- /dev/null +++ b/vendor/github.com/PuerkitoBio/urlesc/urlesc.go @@ -0,0 +1,180 @@ +// Copyright 2009 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Package urlesc implements query escaping as per RFC 3986. +// It contains some parts of the net/url package, modified so as to allow +// some reserved characters incorrectly escaped by net/url. +// See https://github.com/golang/go/issues/5684 +package urlesc + +import ( + "bytes" + "net/url" + "strings" +) + +type encoding int + +const ( + encodePath encoding = 1 + iota + encodeUserPassword + encodeQueryComponent + encodeFragment +) + +// Return true if the specified character should be escaped when +// appearing in a URL string, according to RFC 3986. +func shouldEscape(c byte, mode encoding) bool { + // §2.3 Unreserved characters (alphanum) + if 'A' <= c && c <= 'Z' || 'a' <= c && c <= 'z' || '0' <= c && c <= '9' { + return false + } + + switch c { + case '-', '.', '_', '~': // §2.3 Unreserved characters (mark) + return false + + // §2.2 Reserved characters (reserved) + case ':', '/', '?', '#', '[', ']', '@', // gen-delims + '!', '$', '&', '\'', '(', ')', '*', '+', ',', ';', '=': // sub-delims + // Different sections of the URL allow a few of + // the reserved characters to appear unescaped. + switch mode { + case encodePath: // §3.3 + // The RFC allows sub-delims and : @. + // '/', '[' and ']' can be used to assign meaning to individual path + // segments. This package only manipulates the path as a whole, + // so we allow those as well. That leaves only ? and # to escape. + return c == '?' || c == '#' + + case encodeUserPassword: // §3.2.1 + // The RFC allows : and sub-delims in + // userinfo. The parsing of userinfo treats ':' as special so we must escape + // all the gen-delims. + return c == ':' || c == '/' || c == '?' || c == '#' || c == '[' || c == ']' || c == '@' + + case encodeQueryComponent: // §3.4 + // The RFC allows / and ?. + return c != '/' && c != '?' + + case encodeFragment: // §4.1 + // The RFC text is silent but the grammar allows + // everything, so escape nothing but # + return c == '#' + } + } + + // Everything else must be escaped. + return true +} + +// QueryEscape escapes the string so it can be safely placed +// inside a URL query. +func QueryEscape(s string) string { + return escape(s, encodeQueryComponent) +} + +func escape(s string, mode encoding) string { + spaceCount, hexCount := 0, 0 + for i := 0; i < len(s); i++ { + c := s[i] + if shouldEscape(c, mode) { + if c == ' ' && mode == encodeQueryComponent { + spaceCount++ + } else { + hexCount++ + } + } + } + + if spaceCount == 0 && hexCount == 0 { + return s + } + + t := make([]byte, len(s)+2*hexCount) + j := 0 + for i := 0; i < len(s); i++ { + switch c := s[i]; { + case c == ' ' && mode == encodeQueryComponent: + t[j] = '+' + j++ + case shouldEscape(c, mode): + t[j] = '%' + t[j+1] = "0123456789ABCDEF"[c>>4] + t[j+2] = "0123456789ABCDEF"[c&15] + j += 3 + default: + t[j] = s[i] + j++ + } + } + return string(t) +} + +var uiReplacer = strings.NewReplacer( + "%21", "!", + "%27", "'", + "%28", "(", + "%29", ")", + "%2A", "*", +) + +// unescapeUserinfo unescapes some characters that need not to be escaped as per RFC3986. +func unescapeUserinfo(s string) string { + return uiReplacer.Replace(s) +} + +// Escape reassembles the URL into a valid URL string. +// The general form of the result is one of: +// +// scheme:opaque +// scheme://userinfo@host/path?query#fragment +// +// If u.Opaque is non-empty, String uses the first form; +// otherwise it uses the second form. +// +// In the second form, the following rules apply: +// - if u.Scheme is empty, scheme: is omitted. +// - if u.User is nil, userinfo@ is omitted. +// - if u.Host is empty, host/ is omitted. +// - if u.Scheme and u.Host are empty and u.User is nil, +// the entire scheme://userinfo@host/ is omitted. +// - if u.Host is non-empty and u.Path begins with a /, +// the form host/path does not add its own /. +// - if u.RawQuery is empty, ?query is omitted. +// - if u.Fragment is empty, #fragment is omitted. +func Escape(u *url.URL) string { + var buf bytes.Buffer + if u.Scheme != "" { + buf.WriteString(u.Scheme) + buf.WriteByte(':') + } + if u.Opaque != "" { + buf.WriteString(u.Opaque) + } else { + if u.Scheme != "" || u.Host != "" || u.User != nil { + buf.WriteString("//") + if ui := u.User; ui != nil { + buf.WriteString(unescapeUserinfo(ui.String())) + buf.WriteByte('@') + } + if h := u.Host; h != "" { + buf.WriteString(h) + } + } + if u.Path != "" && u.Path[0] != '/' && u.Host != "" { + buf.WriteByte('/') + } + buf.WriteString(escape(u.Path, encodePath)) + } + if u.RawQuery != "" { + buf.WriteByte('?') + buf.WriteString(u.RawQuery) + } + if u.Fragment != "" { + buf.WriteByte('#') + buf.WriteString(escape(u.Fragment, encodeFragment)) + } + return buf.String() +} diff --git a/vendor/github.com/coreos/prometheus-operator/.editorconfig b/vendor/github.com/coreos/prometheus-operator/.editorconfig new file mode 100644 index 00000000..a5ac5696 --- /dev/null +++ b/vendor/github.com/coreos/prometheus-operator/.editorconfig @@ -0,0 +1,14 @@ +root = true + +[*.py] +indent_style = space +end_of_line = lf +insert_final_newline = true +max_line_length = 100 +trim_trailing_whitespace = true +indent_size = 4 + +[*.yaml] +indent_style = space +indent_size = 2 +trim_trailing_whitespace = true diff --git a/vendor/github.com/coreos/prometheus-operator/.gitignore b/vendor/github.com/coreos/prometheus-operator/.gitignore new file mode 100644 index 00000000..dabe0024 --- /dev/null +++ b/vendor/github.com/coreos/prometheus-operator/.gitignore @@ -0,0 +1,19 @@ +/operator +prometheus-config-reloader +.build/ +*~ +*.tgz +requirements.lock +.idea +*.iml +.DS_Store +__pycache__ +.env/ +.history/ +.vscode/ +tmp + +# These are empty target files, created on every docker build. Their sole +# purpose is to track the last target execution time to evalualte, whether the +# container needds to be rebuild +hack/*-image diff --git a/vendor/github.com/coreos/prometheus-operator/.header b/vendor/github.com/coreos/prometheus-operator/.header new file mode 100644 index 00000000..7e8b2fb8 --- /dev/null +++ b/vendor/github.com/coreos/prometheus-operator/.header @@ -0,0 +1,13 @@ +// Copyright 2018 The prometheus-operator Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. diff --git a/vendor/github.com/coreos/prometheus-operator/.promu.yml b/vendor/github.com/coreos/prometheus-operator/.promu.yml new file mode 100644 index 00000000..b23b5618 --- /dev/null +++ b/vendor/github.com/coreos/prometheus-operator/.promu.yml @@ -0,0 +1,36 @@ +repository: + path: github.com/coreos/prometheus-operator +build: + flags: -a -tags netgo + binaries: + - name: operator + path: ./cmd/operator +tarball: + files: + - LICENSE + - NOTICE +crossbuild: + platforms: + - linux/amd64 + #- linux/386 + #- darwin/amd64 + #- darwin/386 + #- windows/amd64 + #- windows/386 + #- freebsd/amd64 + #- freebsd/386 + #- openbsd/amd64 + #- openbsd/386 + #- netbsd/amd64 + #- netbsd/386 + #- dragonfly/amd64 + #- linux/arm + #- linux/arm64 + #- freebsd/arm + #- openbsd/arm + #- linux/mips64 + #- linux/mips64le + #- netbsd/arm + #- linux/ppc64 + #- linux/ppc64le + diff --git a/vendor/github.com/coreos/prometheus-operator/.travis.yml b/vendor/github.com/coreos/prometheus-operator/.travis.yml new file mode 100644 index 00000000..d2c906c1 --- /dev/null +++ b/vendor/github.com/coreos/prometheus-operator/.travis.yml @@ -0,0 +1,35 @@ +sudo: required +language: go +go: +- "1.11" +services: +- docker +before_install: + - pip install --user awscli + - export PATH=$PATH:$HOME/.local/bin +jobs: + include: + - stage: Sanity check and tests + # Check generated contents are up to date and code is formatted. + script: make --always-make format generate-in-docker && git diff --exit-code + - script: cd contrib/kube-prometheus && make test-in-docker + # Build Prometheus Operator rule config map to rule file crds cli tool + - script: cd cmd/po-rule-migration && go install + # Ensure vendor folder matches vendor.json + - script: ./scripts/golang-dep-ensure.sh + # Unit tests + - script: make test-unit + # E2e tests + - script: ./scripts/travis-e2e.sh + - script: ./scripts/travis-e2e-helm.sh + + - stage: deploy + script: skip + deploy: + provider: script + script: make helm-sync-s3 + on: + branch: master + + - stage: push-docker-image + script: ./scripts/travis-push-docker-image.sh diff --git a/vendor/github.com/coreos/prometheus-operator/CHANGELOG.md b/vendor/github.com/coreos/prometheus-operator/CHANGELOG.md new file mode 100644 index 00000000..4b14f0ad --- /dev/null +++ b/vendor/github.com/coreos/prometheus-operator/CHANGELOG.md @@ -0,0 +1,390 @@ +## 0.25.0 / 2018-10-24 + +* [FEATURE] Allow passing additional alert relabel configs in Prometheus custom resource (#2022) +* [FEATURE] Add ability to mount custom ConfigMaps into Alertmanager and Prometheus (#2028) + +## 0.24.0 / 2018-10-11 + +This release has a breaking changes for `prometheus_operator_.*` metrics. + +`prometheus_operator_alertmanager_reconcile_errors_total` and `prometheus_operator_prometheus_reconcile_errors_total` +are now combined and called `prometheus_operator_reconcile_errors_total`. +Instead the metric has a "controller" label which indicates the errors from the Prometheus or Alertmanager controller. + +The same happened with `prometheus_operator_alertmanager_spec_replicas` and `prometheus_operator_prometheus_spec_replicas` +which is now called `prometheus_operator_spec_replicas` and also has the "controller" label. + +The `prometheus_operator_triggered_total` metric now has a "controller" label as well and finally instruments the +Alertmanager controller. + +For a full description see: https://github.com/coreos/prometheus-operator/pull/1984#issue-221139702 + +In order to support multiple namespaces, the `--namespace` flag changed to `--namespaces` +and accepts and comma-separated list of namespaces as a string. + +* [CHANGE] Default to Node Exporter v0.16.0 (#1812) +* [CHANGE] Update to Go 1.11 (#1855) +* [CHANGE] Default to Prometheus v2.4.3 (#1929) (#1983) +* [CHANGE] Default to Thanos v0.1.0 (#1954) +* [CHANGE] Overhaul metrics while adding triggerBy metric for Alertmanager (#1984) +* [CHANGE] Add multi namespace support (#1813) +* [FEATURE] Add SHA field to Prometheus, Alertmanager and Thanos for images (#1847) (#1854) +* [FEATURE] Add configuration for priority class to be assigned to Pods (#1875) +* [FEATURE] Configure sampleLimit per ServiceMonitor (#1895) +* [FEATURE] Add additionalPeers to Alertmanager (#1878) +* [FEATURE] Add podTargetLabels to ServiceMonitors (#1880) +* [FEATURE] Relabel target name for Pods (#1896) +* [FEATURE] Allow configuration of relabel_configs per ServiceMonitor (#1879) +* [FEATURE] Add illegal update reconciliation by deleting StatefulSet (#1931) +* [ENHANCEMENT] Set Thanos cluster and grpc ip from pod.ip (#1836) +* [BUGFIX] Add square brackets around pod IPs for IPv6 support (#1881) +* [BUGFIX] Allow periods in secret name (#1907) +* [BUGFIX] Add BearerToken in generateRemoteReadConfig (#1956) + +## 0.23.2 / 2018-08-23 + +* [BUGFIX] Do not abort kubelet endpoints update due to nodes without IP addresses defined (#1816) + +## 0.23.1 / 2018-08-13 + +* [BUGFIX] Fix high CPU usage of Prometheus Operator when annotating Prometheus resource (#1785) + +## 0.23.0 / 2018-08-06 + +* [CHANGE] Deprecate specification of Prometheus rules via ConfigMaps in favor of `PrometheusRule` CRDs +* [FEATURE] Introduce new flag to control logging format (#1475) +* [FEATURE] Ensure Prometheus Operator container runs as `nobody` user by default (#1393) +* [BUGFIX] Fix reconciliation of Prometheus StatefulSets due to ServiceMonitors and PrometheusRules changes when a single namespace is being watched (#1749) + +## 0.22.2 / 2018-07-24 + +[BUGFIX] Do not migrate rule config map for Prometheus statefulset on rule config map to PrometheusRule migration (#1679) + +## 0.22.1 / 2018-07-19 + +* [ENHANCEMENT] Enable operation when CRDs are created externally (#1640) +* [BUGFIX] Do not watch for new namespaces if a specific namespace has been selected (#1640) + +## 0.22.0 / 2018-07-09 + +* [FEATURE] Allow setting volume name via volumetemplateclaimtemplate in prom and alertmanager (#1538) +* [FEATURE] Allow setting custom tags of container images (#1584) +* [ENHANCEMENT] Update default Thanos to v0.1.0-rc.2 (#1585) +* [ENHANCEMENT] Split rule config map mounted into Prometheus if it exceeds Kubernetes config map limit (#1562) +* [BUGFIX] Mount Prometheus data volume into Thanos sidecar & pass correct path to Thanos sidecar (#1583) + +## 0.21.0 / 2018-06-28 + +* [CHANGE] Default to Prometheus v2.3.1. +* [CHANGE] Default to Alertmanager v0.15.0. +* [FEATURE] Make remote write queue configurations configurable. +* [FEATURE] Add Thanos integration (experimental). +* [BUGFIX] Fix usage of console templates and libraries. + +## 0.20.0 / 2018-06-05 + +With this release we introduce a new Custom Resource Definition - the +`PrometheusRule` CRD. It addresses the need for rule syntax validation and rule +selection across namespaces. `PrometheusRule` replaces the configuration of +Prometheus rules via K8s ConfigMaps. There are two migration paths: + +1. Automated live migration: If the Prometheus Operator finds Kubernetes + ConfigMaps that match the `RuleSelector` in a `Prometheus` specification, it + will convert them to matching `PrometheusRule` resources. + +2. Manual migration: We provide a basic CLI tool to convert Kubernetes + ConfigMaps to `PrometheusRule` resources. + +```bash +go get -u github.com/coreos/prometheus-operator/cmd/po-rule-migration +po-rule-migration \ +--rule-config-map= \ +--rule-crds-destination= +``` + +* [FEATURE] Add leveled logging to Prometheus Operator (#1277) +* [FEATURE] Allow additional Alertmanager configuration in Prometheus CRD (#1338) +* [FEATURE] Introduce `PrometheusRule` Custom Resource Definition (#1333) +* [ENHANCEMENT] Allow Prometheus to consider all namespaces to find ServiceMonitors (#1278) +* [BUGFIX] Do not attempt to set default memory request for Prometheus 2.0 (#1275) + +## 0.19.0 / 2018-04-25 + +* [FEATURE] Allow specifying additional Prometheus scrape configs via secret (#1246) +* [FEATURE] Enable Thanos sidecar (#1219) +* [FEATURE] Make AM log level configurable (#1192) +* [ENHANCEMENT] Enable Prometheus to select Service Monitors outside own namespace (#1227) +* [ENHANCEMENT] Enrich Prometheus operator CRD registration error handling (#1208) +* [BUGFIX] Allow up to 10m for Prometheus pod on startup for data recovery (#1232) + +## 0.18.1 / 2018-04-09 + +* [BUGFIX] Fix alertmanager >=0.15.0 cluster gossip communication (#1193) + +## 0.18.0 / 2018-03-04 + +From this release onwards only Kubernetes versions v1.8 and higher are supported. If you have an older version of Kubernetes and the Prometheus Operator running, we recommend upgrading Kubernetes first and then the Prometheus Operator. + +While multiple validation issues have been fixed, it will remain a beta feature in this release. If you want to update validations, you need to either apply the CustomResourceDefinitions located in `example/prometheus-operator-crd` or delete all CRDs and restart the Prometheus Operator. + +Some changes cause Prometheus and Alertmanager clusters to be redeployed. If you do not have persistent storage backing your data, this means you will loose the amount of data equal to your retention time. + +* [CHANGE] Use canonical `/prometheus` and `/alertmanager` as data dirs in containers. +* [FEATURE] Allow configuring Prometheus and Alertmanager servers to listen on loopback interface, allowing proxies to be the ingress point of those Pods. +* [FEATURE] Allow configuring additional containers in Prometheus and Alertmanager Pods. +* [FEATURE] Add ability to whitelist Kubernetes labels to become Prometheus labels. +* [FEATURE] Allow specifying additional secrets for Alertmanager Pods to mount. +* [FEATURE] Allow specifying `bearer_token_file` for Alertmanger configurations of Prometheus objects in order to authenticate with Alertmanager. +* [FEATURE] Allow specifying TLS configuration for Alertmanger configurations of Prometheus objects. +* [FEATURE] Add metrics for reconciliation errors: `prometheus_operator_alertmanager_reconcile_errors_total` and `prometheus_operator_prometheus_reconcile_errors_total`. +* [FEATURE] Support `read_recent` and `required_matchers` fields for remote read configurations. +* [FEATURE] Allow disabling any defaults of `SecurityContext` fields of Pods. +* [BUGFIX] Handle Alertmanager >=v0.15.0 breaking changes correctly. +* [BUGFIX] Fix invalid validations for metric relabeling fields. +* [BUGFIX] Fix validations for `AlertingSpec`. +* [BUGFIX] Fix validations for deprecated storage fields. +* [BUGFIX] Fix remote read and write basic auth support. +* [BUGFIX] Fix properly propagate errors of Prometheus config reloader. + +## 0.17.0 / 2018-02-15 + +This release adds validations as a beta feature. It will only be installed on new clusters, existing CRD definitions will not be updated, this will be done in a future release. Please try out this feature and give us feedback! + +* [CHANGE] Default Prometheus version v2.2.0-rc.0. +* [CHANGE] Default Alertmanager version v0.14.0. +* [FEATURE] Generate and add CRD validations. +* [FEATURE] Add ability to set `serviceAccountName` for Alertmanager Pods. +* [FEATURE] Add ability to specify custom `securityContext` for Alertmanager Pods. +* [ENHANCEMENT] Default to non-root security context for Alertmanager Pods. + +## 0.16.1 / 2018-01-16 + +* [CHANGE] Default to Alertmanager v0.13.0. +* [BUGFIX] Alertmanager flags must be double dashed starting v0.13.0. + +## 0.16.0 / 2018-01-11 + +* [FEATURE] Add support for specifying remote storage configurations. +* [FEATURE] Add ability to specify log level. +* [FEATURE] Add support for dropping metrics at scrape time. +* [ENHANCEMENT] Ensure that resource limit can't make Pods unschedulable. +* [ENHANCEMENT] Allow configuring emtpyDir volumes +* [BUGFIX] Use `--storage.tsdb.no-lockfile` for Prometheus 2.0. +* [BUGFIX] Fix Alertmanager default storage.path. + +## 0.15.0 / 2017-11-22 + +* [CHANGE] Default Prometheus version v2.0.0 +* [BUGFIX] Generate ExternalLabels deterministically +* [BUGFIX] Fix incorrect mount path of Alertmanager data volume +* [EXPERIMENTAL] Add ability to specify CRD Kind name + +## 0.14.1 / 2017-11-01 + +* [BUGFIX] Ignore illegal change of PodManagementPolicy to StatefulSet. + +## 0.14.0 / 2017-10-19 + +* [CHANGE] Default Prometheus version v2.0.0-rc.1. +* [CHANGE] Default Alertmanager version v0.9.1. +* [BUGFIX] Set StatefulSet replicas to 0 if 0 is specified in Alertmanager/Prometheus object. +* [BUGFIX] Glob for all files in a ConfigMap as rule files. +* [FEATURE] Add ability to run Prometheus Operator for a single namespace. +* [FEATURE] Add ability to specify CRD api group. +* [FEATURE] Use readiness and health endpoints of Prometheus 1.8+. +* [ENHANCEMENT] Add OwnerReferences to managed objects. +* [ENHANCEMENT] Use parallel pod creation strategy for Prometheus StatefulSets. + +## 0.13.0 / 2017-09-21 + +After a long period of not having broken any functionality in the Prometheus Operator, we have decided to promote the status of this project to beta. + +Compatibility guarantees and migration strategies continue to be the same as for the `v0.12.0` release. + +* [CHANGE] Remove analytics collection. +* [BUGFIX] Fix memory leak in kubelet endpoints sync. +* [FEATURE] Allow setting global default `scrape_interval`. +* [FEATURE] Allow setting Pod objectmeta to Prometheus and Alertmanger objects. +* [FEATURE] Allow setting tolerations and affinity for Prometheus and Alertmanager objects. + +## 0.12.0 / 2017-08-24 + +Starting with this release only Kubernetes `v1.7.x` and up is supported as CustomResourceDefinitions are a requirement for the Prometheus Operator and are only available from those versions and up. + +Additionally all objects have been promoted from `v1alpha1` to `v1`. On start up of this version of the Prometheus Operator the previously used `ThirdPartyResource`s and the associated `v1alpha1` objects will be automatically migrated to their `v1` equivalent `CustomResourceDefinition`. + +* [CHANGE] All manifests created and used by the Prometheus Operator have been promoted from `v1alpha1` to `v1`. +* [CHANGE] Use Kubernetes `CustomResourceDefinition`s instead of `ThirdPartyResource`s. +* [FEATURE] Add ability to set scrape timeout to `ServiceMonitor`. +* [ENHANCEMENT] Use `StatefulSet` rolling deployments. +* [ENHANCEMENT] Properly set `SecurityContext` for Prometheus 2.0 deployments. +* [ENHANCEMENT] Enable web lifecycle APIs for Prometheus 2.0 deployments. + +## 0.11.2 / 2017-09-21 + +* [BUGFIX] Fix memory leak in kubelet endpoints sync. + +## 0.11.1 / 2017-07-28 + +* [ENHANCEMENT] Add profiling endpoints. +* [BUGFIX] Adapt Alertmanager storage usage to not use deprecated storage definition. + +## 0.11.0 / 2017-07-20 + +Warning: This release deprecates the previously used storage definition in favor of upstream PersistentVolumeClaim templates. While this should not have an immediate effect on a running cluster, Prometheus object definitions that have storage configured need to be adapted. The previously existing fields are still there, but have no effect anymore. + +* [FEATURE] Add Prometheus 2.0 alpha3 support. +* [FEATURE] Use PVC templates instead of custom storage definition. +* [FEATURE] Add cAdvisor port to kubelet sync. +* [FEATURE] Allow default base images to be configurable. +* [FEATURE] Configure Prometheus to only use necessary namespaces. +* [ENHANCEMENT] Improve rollout detection for Alertmanager clusters. +* [BUGFIX] Fix targetPort relabeling. + +## 0.10.2 / 2017-06-21 + +* [BUGFIX] Use computed route prefix instead of directly from manifest. + +## 0.10.1 / 2017-06-13 + +Attention: if the basic auth feature was previously used, the `key` and `name` +fields need to be switched. This was not intentional, and the bug is not fixed, +but causes this change. + +* [CHANGE] Prometheus default version v1.7.1. +* [CHANGE] Alertmanager default version v0.7.1. +* [BUGFIX] Fix basic auth secret key selector `key` and `name` switched. +* [BUGFIX] Fix route prefix flag not always being set for Prometheus. +* [BUGFIX] Fix nil panic on replica metrics. +* [FEATURE] Add ability to specify Alertmanager path prefix for Prometheus. + +## 0.10.0 / 2017-06-09 + +* [CHANGE] Prometheus route prefix defaults to root. +* [CHANGE] Default to Prometheus v1.7.0. +* [CHANGE] Default to Alertmanager v0.7.0. +* [FEATURE] Add route prefix support to Alertmanager resource. +* [FEATURE] Add metrics on expected replicas. +* [FEATURE] Support for runing Alertmanager v0.7.0. +* [BUGFIX] Fix sensitive rollout triggering. + +## 0.9.1 / 2017-05-18 + +* [FEATURE] Add experimental Prometheus 2.0 support. +* [FEATURE] Add support for setting Prometheus external labels. +* [BUGFIX] Fix non-deterministic config generation. + +## 0.9.0 / 2017-05-09 + +* [CHANGE] The `kubelet-object` flag has been renamed to `kubelet-service`. +* [CHANGE] Remove automatic relabelling of Pod and Service labels onto targets. +* [CHANGE] Remove "non-namespaced" alpha annotation in favor of `honor_labels`. +* [FEATURE] Add ability make use of the Prometheus `honor_labels` configuration option. +* [FEATURE] Add ability to specify image pull secrets for Prometheus and Alertmanager pods. +* [FEATURE] Add basic auth configuration option through ServiceMonitor. +* [ENHANCEMENT] Add liveness and readiness probes to Prometheus and Alertmanger pods. +* [ENHANCEMENT] Add default resource requests for Alertmanager pods. +* [ENHANCEMENT] Fallback to ExternalIPs when InternalIPs are not available in kubelet sync. +* [ENHANCEMENT] Improved change detection to trigger Prometheus rollout. +* [ENHANCEMENT] Do not delete unmanaged Prometheus configuration Secret. + +## 0.8.2 / 2017-04-20 + +* [ENHANCEMENT] Use new Prometheus 1.6 storage flags and make it default. + +## 0.8.1 / 2017-04-13 + +* [ENHANCEMENT] Include kubelet insecure port in kubelet Enpdoints object. + +## 0.8.0 / 2017-04-07 + +* [FEATURE] Add ability to mount custom secrets into Prometheus Pods. Note that + secrets cannot be modified after creation, if the list if modified after + creation it will not effect the Prometheus Pods. +* [FEATURE] Attach pod and service name as labels to Pod targets. + +## 0.7.0 / 2017-03-17 + +This release introduces breaking changes to the generated StatefulSet's +PodTemplate, which cannot be modified for StatefulSets. The Prometheus and +Alertmanager objects have to be deleted and recreated for the StatefulSets to +be created properly. + +* [CHANGE] Use Secrets instead of ConfigMaps for configurations. +* [FEATURE] Allow ConfigMaps containing rules to be selected via label selector. +* [FEATURE] `nodeSelector` added to the Alertmanager kind. +* [ENHANCEMENT] Use Prometheus v2 chunk encoding by default. +* [BUGFIX] Fix Alertmanager cluster mesh initialization. + +## 0.6.0 / 2017-02-28 + +* [FEATURE] Allow not tagging targets with the `namespace` label. +* [FEATURE] Allow specifying `ServiceAccountName` to be used by Prometheus pods. +* [ENHANCEMENT] Label governing services to uniquely identify them. +* [ENHANCEMENT] Reconcile Serive and Endpoints objects. +* [ENHANCEMENT] General stability improvements. +* [BUGFIX] Hostname cannot be fqdn when syncing kubelets into Endpoints object. + +## 0.5.1 / 2017-02-17 + +* [BUGFIX] Use correct governing `Service` for Prometheus `StatefulSet`. + +## 0.5.0 / 2017-02-15 + +* [FEATURE] Allow synchronizing kubelets into an `Endpoints` object. +* [FEATURE] Allow specifying custom configmap-reload image + +## 0.4.0 / 2017-02-02 + +* [CHANGE] Split endpoint and job in separate labels instead of a single + concatenated one. +* [BUGFIX] Properly exit on errors communicating with the apiserver. + +## 0.3.0 / 2017-01-31 + +This release introduces breaking changes to the underlying naming schemes. It +is recommended to destroy existing Prometheus and Alertmanager objects and +recreate them with new namings. + +With this release support for `v1.4.x` clusters is dropped. Changes will not be +backported to the `0.1.x` release series anymore. + +* [CHANGE] Prefixed StatefulSet namings based on managing resource +* [FEATURE] Pass labels and annotations through to StatefulSets +* [FEATURE] Add tls config to use for Prometheus target scraping +* [FEATURE] Add configurable `routePrefix` for Prometheus +* [FEATURE] Add node selector to Prometheus TPR +* [ENHANCEMENT] Stability improvements + +## 0.2.3 / 2017-01-05 + +* [BUGFIX] Fix config reloading when using external url. + +## 0.1.3 / 2017-01-05 + +The `0.1.x` releases are backport releases with Kubernetes `v1.4.x` compatibility. + +* [BUGFIX] Fix config reloading when using external url. + +## 0.2.2 / 2017-01-03 + +* [FEATURE] Add ability to set the external url the Prometheus/Alertmanager instances will be available under. + +## 0.1.2 / 2017-01-03 + +The `0.1.x` releases are backport releases with Kubernetes `v1.4.x` compatibility. + +* [FEATURE] Add ability to set the external url the Prometheus/Alertmanager instances will be available under. + +## 0.2.1 / 2016-12-23 + +* [BUGFIX] Fix `subPath` behavior when not using storage provisioning + +## 0.2.0 / 2016-12-20 + +This release requires a Kubernetes cluster >=1.5.0. See the readme for +instructions on how to upgrade if you are currently running on a lower version +with the operator. + +* [CHANGE] Use StatefulSet instead of PetSet +* [BUGFIX] Fix Prometheus config generation for labels containing "-" diff --git a/vendor/github.com/coreos/prometheus-operator/CONTRIBUTING.md b/vendor/github.com/coreos/prometheus-operator/CONTRIBUTING.md new file mode 100644 index 00000000..0551ed53 --- /dev/null +++ b/vendor/github.com/coreos/prometheus-operator/CONTRIBUTING.md @@ -0,0 +1,77 @@ +# How to Contribute + +CoreOS projects are [Apache 2.0 licensed](LICENSE) and accept contributions via +GitHub pull requests. This document outlines some of the conventions on +development workflow, commit message formatting, contact points and other +resources to make it easier to get your contribution accepted. + +# Certificate of Origin + +By contributing to this project you agree to the Developer Certificate of +Origin (DCO). This document was created by the Linux Kernel community and is a +simple statement that you, as a contributor, have the legal right to make the +contribution. See the [DCO](DCO) file for details. + +# Email and Chat + +The project currently uses the general CoreOS email list and IRC channel: +- Email: [coreos-dev](https://groups.google.com/forum/#!forum/coreos-dev) +- IRC: #[coreos](irc://irc.freenode.org:6667/#coreos) IRC channel on freenode.org + +Please avoid emailing maintainers found in the MAINTAINERS file directly. They +are very busy and read the mailing lists. + +## Getting Started + +- Fork the repository on GitHub +- Read the [README](README.md) for build and test instructions +- Play with the project, submit bugs, submit patches! + +## Contribution Flow + +This is a rough outline of what a contributor's workflow looks like: + +- Create a topic branch from where you want to base your work (usually master). +- Make commits of logical units. +- Make sure your commit messages are in the proper format (see below). +- Push your changes to a topic branch in your fork of the repository. +- Make sure the tests pass, and add any new tests as appropriate. +- Submit a pull request to the original repository. + +Thanks for your contributions! + +### Coding Style + +CoreOS projects written in Go follow a set of style guidelines that we've documented +[here](https://github.com/coreos/docs/tree/master/golang). Please follow them when +working on your contributions. + +### Format of the Commit Message + +We follow a rough convention for commit messages that is designed to answer two +questions: what changed and why. The subject line should feature the what and +the body of the commit should describe the why. + +``` +scripts: add the test-cluster command + +this uses tmux to setup a test cluster that you can easily kill and +start for debugging. + +Fixes #38 +``` + +The format can be described more formally as follows: + +``` +: + + + +