├── .config.json ├── .gitignore ├── .travis.yml ├── CHANGELOG.md ├── CONTRIBUTING.md ├── Gopkg.lock ├── Gopkg.toml ├── LICENSE ├── Makefile ├── README.md ├── cmd └── matterpoll-emoji │ └── main.go ├── matterpoll-emoji.png ├── poll ├── conf.go ├── conf_test.go ├── poll_func.go ├── poll_func_test.go ├── poll_request.go └── poll_request_test.go ├── testdata ├── sample_conf.json ├── sample_conf_error.json ├── sample_conf_error_no_host.json ├── sample_conf_error_no_listen.json ├── sample_conf_error_no_token.json ├── sample_conf_error_no_user.json ├── sample_conf_error_no_user_id.json ├── sample_conf_error_no_user_password.json └── sample_conf_error_wrong_token_length.json └── vendor ├── github.com ├── davecgh │ └── go-spew │ │ ├── LICENSE │ │ └── spew │ │ ├── bypass.go │ │ ├── bypasssafe.go │ │ ├── common.go │ │ ├── config.go │ │ ├── doc.go │ │ ├── dump.go │ │ ├── format.go │ │ └── spew.go ├── google │ └── uuid │ │ ├── CONTRIBUTORS │ │ ├── LICENSE │ │ ├── dce.go │ │ ├── doc.go │ │ ├── hash.go │ │ ├── marshal.go │ │ ├── node.go │ │ ├── node_js.go │ │ ├── node_net.go │ │ ├── sql.go │ │ ├── time.go │ │ ├── util.go │ │ ├── uuid.go │ │ ├── version1.go │ │ └── version4.go ├── gorilla │ └── websocket │ │ ├── AUTHORS │ │ ├── LICENSE │ │ ├── client.go │ │ ├── client_clone.go │ │ ├── client_clone_legacy.go │ │ ├── compression.go │ │ ├── conn.go │ │ ├── conn_write.go │ │ ├── conn_write_legacy.go │ │ ├── doc.go │ │ ├── json.go │ │ ├── mask.go │ │ ├── mask_safe.go │ │ ├── prepared.go │ │ ├── proxy.go │ │ ├── server.go │ │ ├── trace.go │ │ ├── trace_17.go │ │ ├── util.go │ │ └── x_net_proxy.go ├── mattermost │ └── mattermost-server │ │ ├── LICENSE.txt │ │ ├── NOTICE.txt │ │ ├── mlog │ │ ├── default.go │ │ ├── global.go │ │ ├── log.go │ │ ├── stdlog.go │ │ └── sugar.go │ │ ├── model │ │ ├── access.go │ │ ├── analytics_row.go │ │ ├── audit.go │ │ ├── audits.go │ │ ├── authorize.go │ │ ├── builtin.go │ │ ├── bundle_info.go │ │ ├── channel.go │ │ ├── channel_count.go │ │ ├── channel_data.go │ │ ├── channel_list.go │ │ ├── channel_member.go │ │ ├── channel_member_history.go │ │ ├── channel_member_history_result.go │ │ ├── channel_mentions.go │ │ ├── channel_search.go │ │ ├── channel_stats.go │ │ ├── channel_view.go │ │ ├── client4.go │ │ ├── cluster_discovery.go │ │ ├── cluster_info.go │ │ ├── cluster_message.go │ │ ├── cluster_stats.go │ │ ├── command.go │ │ ├── command_args.go │ │ ├── command_response.go │ │ ├── command_webhook.go │ │ ├── compliance.go │ │ ├── compliance_post.go │ │ ├── config.go │ │ ├── data_retention_policy.go │ │ ├── emoji.go │ │ ├── emoji_data.go │ │ ├── emoji_search.go │ │ ├── file.go │ │ ├── file_info.go │ │ ├── gitlab.go │ │ ├── incoming_webhook.go │ │ ├── initial_load.go │ │ ├── job.go │ │ ├── ldap.go │ │ ├── license.go │ │ ├── manifest.go │ │ ├── message_export.go │ │ ├── mfa_secret.go │ │ ├── migration.go │ │ ├── oauth.go │ │ ├── outgoing_webhook.go │ │ ├── permission.go │ │ ├── plugin_key_value.go │ │ ├── plugin_status.go │ │ ├── plugins_response.go │ │ ├── post.go │ │ ├── post_list.go │ │ ├── post_search_results.go │ │ ├── preference.go │ │ ├── preferences.go │ │ ├── push_notification.go │ │ ├── push_response.go │ │ ├── reaction.go │ │ ├── role.go │ │ ├── saml.go │ │ ├── scheduled_task.go │ │ ├── scheme.go │ │ ├── search_params.go │ │ ├── security_bulletin.go │ │ ├── session.go │ │ ├── slack_attachment.go │ │ ├── status.go │ │ ├── suggest_command.go │ │ ├── switch_request.go │ │ ├── system.go │ │ ├── team.go │ │ ├── team_member.go │ │ ├── team_search.go │ │ ├── team_stats.go │ │ ├── terms_of_service.go │ │ ├── timezone.go │ │ ├── token.go │ │ ├── user.go │ │ ├── user_access_token.go │ │ ├── user_access_token_search.go │ │ ├── user_autocomplete.go │ │ ├── user_search.go │ │ ├── users_stats.go │ │ ├── utils.go │ │ ├── version.go │ │ ├── webrtc.go │ │ ├── websocket_client.go │ │ ├── websocket_message.go │ │ └── websocket_request.go │ │ ├── scripts │ │ └── license-check.sh │ │ └── utils │ │ ├── jsonutils │ │ └── json.go │ │ └── markdown │ │ ├── autolink.go │ │ ├── block_quote.go │ │ ├── blocks.go │ │ ├── document.go │ │ ├── fenced_code.go │ │ ├── html.go │ │ ├── html_entities.go │ │ ├── indented_code.go │ │ ├── inlines.go │ │ ├── inspect.go │ │ ├── lines.go │ │ ├── links.go │ │ ├── list.go │ │ ├── markdown.go │ │ ├── paragraph.go │ │ └── reference_definition.go ├── nicksnyder │ └── go-i18n │ │ ├── LICENSE │ │ └── i18n │ │ ├── bundle │ │ └── bundle.go │ │ ├── i18n.go │ │ ├── language │ │ ├── language.go │ │ ├── operands.go │ │ ├── plural.go │ │ ├── pluralspec.go │ │ └── pluralspec_gen.go │ │ └── translation │ │ ├── plural_translation.go │ │ ├── single_translation.go │ │ ├── template.go │ │ └── translation.go ├── pborman │ └── uuid │ │ ├── CONTRIBUTORS │ │ ├── LICENSE │ │ ├── dce.go │ │ ├── doc.go │ │ ├── hash.go │ │ ├── marshal.go │ │ ├── node.go │ │ ├── sql.go │ │ ├── time.go │ │ ├── util.go │ │ ├── uuid.go │ │ ├── version1.go │ │ └── version4.go ├── pelletier │ └── go-toml │ │ ├── LICENSE │ │ ├── doc.go │ │ ├── fuzz.go │ │ ├── keysparsing.go │ │ ├── lexer.go │ │ ├── marshal.go │ │ ├── parser.go │ │ ├── position.go │ │ ├── token.go │ │ ├── toml.go │ │ ├── tomltree_create.go │ │ └── tomltree_write.go ├── pkg │ └── errors │ │ ├── LICENSE │ │ ├── errors.go │ │ └── stack.go ├── pmezard │ └── go-difflib │ │ ├── LICENSE │ │ └── difflib │ │ └── difflib.go └── stretchr │ └── testify │ ├── LICENSE │ ├── assert │ ├── assertion_format.go │ ├── assertion_forward.go │ ├── assertions.go │ ├── doc.go │ ├── errors.go │ ├── forward_assertions.go │ └── http_assertions.go │ └── require │ ├── doc.go │ ├── forward_requirements.go │ ├── require.go │ ├── require_forward.go │ └── requirements.go ├── go.uber.org ├── atomic │ ├── LICENSE.txt │ ├── atomic.go │ └── string.go ├── multierr │ ├── LICENSE.txt │ └── error.go └── zap │ ├── LICENSE.txt │ ├── array.go │ ├── buffer │ ├── buffer.go │ └── pool.go │ ├── config.go │ ├── doc.go │ ├── encoder.go │ ├── error.go │ ├── field.go │ ├── flag.go │ ├── global.go │ ├── http_handler.go │ ├── internal │ ├── bufferpool │ │ └── bufferpool.go │ ├── color │ │ └── color.go │ └── exit │ │ └── exit.go │ ├── level.go │ ├── logger.go │ ├── options.go │ ├── sink.go │ ├── stacktrace.go │ ├── sugar.go │ ├── time.go │ ├── writer.go │ └── zapcore │ ├── console_encoder.go │ ├── core.go │ ├── doc.go │ ├── encoder.go │ ├── entry.go │ ├── error.go │ ├── field.go │ ├── hook.go │ ├── json_encoder.go │ ├── level.go │ ├── level_strings.go │ ├── marshaler.go │ ├── memory_encoder.go │ ├── sampler.go │ ├── tee.go │ └── write_syncer.go ├── golang.org └── x │ └── crypto │ ├── AUTHORS │ ├── CONTRIBUTORS │ ├── LICENSE │ ├── PATENTS │ ├── bcrypt │ ├── base64.go │ └── bcrypt.go │ └── blowfish │ ├── block.go │ ├── cipher.go │ └── const.go └── gopkg.in ├── natefinch └── lumberjack.v2 │ ├── LICENSE │ ├── chown.go │ ├── chown_linux.go │ └── lumberjack.go └── yaml.v2 ├── LICENSE ├── LICENSE.libyaml ├── NOTICE ├── apic.go ├── decode.go ├── emitterc.go ├── encode.go ├── parserc.go ├── readerc.go ├── resolve.go ├── scannerc.go ├── sorter.go ├── writerc.go ├── yaml.go ├── yamlh.go └── yamlprivateh.go /.config.json: -------------------------------------------------------------------------------- 1 | { 2 | "host": "http://mattermost.example.com:8065", 3 | "listen": "localhost:8505", 4 | "token": "9jrxak1ykxrmnaed9cps9i4cim", 5 | "user": { 6 | "id": "bot", 7 | "password": "botbot" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /dist 2 | /config.json 3 | /coverage.txt 4 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | sudo: false 2 | notifications: 3 | email: false 4 | 5 | language: go 6 | go: 7 | - "1.11.x" 8 | 9 | install: 10 | - make install-tools 11 | 12 | script: 13 | - make check-style 14 | - make coverage 15 | 16 | after_success: 17 | - bash <(curl -s https://codecov.io/bash) 18 | 19 | before_deploy: 20 | - make dist 21 | 22 | deploy: 23 | provider: releases 24 | skip_cleanup: true 25 | api_key: 26 | secure: CGZyAB5k8e/VzO93yXCCmM9fv6GYeRgvKK7DsiSSUH2jXjRIo7DXHZaKAgNa9oSf3+/oSuoopW6YLfJrQ/clL4WpiW3M/F1DznUMIIlnk5VAslqfi2kRDfX3n6DGty/JNZh7A6n1QA40dSCHMtKmPP7pmNjpyvxVtRZEUuMDZxSmiyLjlrwSAE6HTaRHALmVAPpIjf+5ubzEXgAfeKLp/oKFlzrxLYfgCJDvhNm8XuJSoEdgH9Mxi3GDfwf4uSF7ABjH4ItOWpkC9reKuHKSY3/p6iSwHCN0UmotdJaEktd6fXDWWBoxxKu4eQ6Emkmwex2udIxGJaNtEZs7FA3qR0Y7iJz0dXYFp468HO9NNkTSO0nA0doHw4ZvDSy8V2o3WvFbezBwPzOuc3qkdiH/NqS6y06SWc+0pghZGR6SPvuMTkvskTxN2dOmT4YiVK/sdOC1gYPwKa8boGxFOIPEv9Png/lRo8+0hwQF3h9GCWQVmXG2ZPH27HkJDU6Hkq50WtCctzt0W6KOPfWqIp2UAC7jdTBlCV3JpXTr2jHbLITu2DBlRHbMEYb9Mu4a5SeR51RgueNiAiwg9NOVuRy4D+yOWlggYNgw9o76FF1uTMvqz9FUGO2mkw0WPfyKkW8a9LpgVfkwz5ylXdeM2QGH/7GovbXECRjgjQbXqgT63S0= 27 | file_glob: true 28 | file: 'dist/*.{tar.gz,zip}' 29 | on: 30 | repo: matterpoll/matterpoll-emoji 31 | tags: true 32 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | All notable changes to this project will be documented in this file. 3 | 4 | ## 0.2.0 - 2018-10-23 5 | ### Changed 6 | - Transfer ownership from `kaakaa` to `matterpoll` 7 | ### Fixed 8 | - Updated dependencies 9 | 10 | ## 0.1.1 – 2018-01-06 11 | ### Fixed 12 | - Set content type to `application/json`([#89](https://github.com/matterpoll/matterpoll-emoji/pull/89)) 13 | - Updated dependencies 14 | 15 | ## 0.1.0 – 2017-08-28 16 | ### Breaking changes 17 | - You need add two config parameter to `config.json`: 18 | - `listen` defines the ip address and port Matterpoll will listen for requests. Default is `localhost:8505` 19 | - `token` is the mattermost token. You should copy it from Integration > Slash Commands at your Mattermost server. 20 | - Removed `-p` option. Choosing the port is now done via `config.json` 21 | 22 | ### Added 23 | - Polls are posted as a bot user 24 | - You can use single and double quotation instead of backticks 25 | - We now verify the Mattermost token to make sure requests are valid 26 | - The ip address Matterpoll should listen for request can now we configured via `config.json` 27 | - You can choose the config file via `-c` option 28 | - Go 1.7 to 1.9 are now supported 29 | 30 | ### Changed 31 | - A lot of unittests were added 32 | - Moved from Mattermost APIv3 to APIv4 33 | 34 | ### Fixed 35 | - Removed dependency of glide 36 | - Mattermost warning about empty message 37 | 38 | ## 0.0.2 – 2017-04-19 39 | ### Added 40 | - Ci builds via travis 41 | 42 | ### Changed 43 | - Use 8505 as default port 44 | 45 | ### Fixed 46 | - Fixed setup documentation 47 | 48 | ## 0.0.1 – 2017-04-02 49 | - First Version 50 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | We welcome pull requests from everyone. 4 | 5 | Fork, then clone the repo: 6 | 7 | git clone https://github.com/matterpoll/matterpoll-emoji.git 8 | 9 | Make sure the tests pass: 10 | 11 | make check-style test 12 | 13 | Make your change. Add tests for your change. Make the tests pass: 14 | 15 | make check-style test 16 | 17 | Push to your fork and [submit a pull request](https://github.com/matterpoll/matterpoll-emoji/compare/) 18 | 19 | ## TIPS 20 | 21 | * You'd better set git pre-commit hook for doing formating go code. 22 | * [misc/git/pre-commit - The Go Programming Language](https://tip.golang.org/misc/git/pre-commit) 23 | -------------------------------------------------------------------------------- /Gopkg.toml: -------------------------------------------------------------------------------- 1 | [prune] 2 | unused-packages = true 3 | non-go = true 4 | go-tests = true 5 | 6 | [[constraint]] 7 | name = "github.com/mattermost/mattermost-server" 8 | version = "~5.4.0" 9 | 10 | [[constraint]] 11 | name = "github.com/stretchr/testify" 12 | version = "~1.2.0" 13 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Yusuke Nemoto 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | NAME := matterpoll-emoji 2 | VERSION := v0.2.0 3 | REVISION := $(shell git rev-parse --short HEAD) 4 | 5 | LDFLAGS := -ldflags="-s -w -X \"main.Version=$(VERSION)\" -X \"main.Revision=$(REVISION)\" -extldflags \"-static\"" 6 | DIST_DIRS := find * -type d -exec 7 | 8 | .PHONY: run clean test coverage install-tools update-deps check-style cross-build dist 9 | 10 | all: test 11 | 12 | run: 13 | go run cmd/matterpoll-emoji/main.go 14 | 15 | clean: 16 | rm -rf bin/* 17 | rm -rf vendor/* 18 | rm -rf dist/* 19 | 20 | test: 21 | go test ./poll/ 22 | 23 | coverage: 24 | go test -coverprofile=coverage.txt -covermode=atomic ./poll/ 25 | go tool cover -html=coverage.txt 26 | 27 | install-tools: 28 | go get -u golang.org/x/lint/golint 29 | 30 | update-deps: 31 | dep ensure 32 | dep ensure -update 33 | 34 | check-style: 35 | $(eval DIRECTORIES_NOVENDOR_FULLPATH := $(shell go list ./... | grep -v /vendor/)) 36 | $(eval GOFILES_NOVENDOR := $(shell find . -type f -name '*.go' -not -path './vendor/*')) 37 | 38 | @echo running gofmt 39 | $(eval GOFMT_OUTPUT := $(shell gofmt -l -s $(GOFILES_NOVENDOR) 2>&1)) 40 | @if [ ! "$(GOFMT_OUTPUT)" ]; then \ 41 | echo "gofmt success\n"; \ 42 | else \ 43 | echo "gofmt failure. Please run:"; \ 44 | echo " gofmt -w -s $(GOFMT_OUTPUT)"; \ 45 | exit 1; \ 46 | fi 47 | 48 | 49 | @echo running go vet 50 | $(eval GO_VET_OUTPUT := $(shell go vet $(DIRECTORIES_NOVENDOR_FULLPATH) 2>&1)) 51 | @if [ ! "$(GO_VET_OUTPUT)" ]; then \ 52 | echo "go vet success\n"; \ 53 | else \ 54 | echo "go vet failure. You need to fix these errors:"; \ 55 | go vet $(DIRECTORIES_NOVENDOR_FULLPATH); \ 56 | fi 57 | 58 | @echo running golint 59 | $(eval GOLINT_OUTPUT := $(shell golint $(DIRECTORIES_NOVENDOR_FULLPATH) 2>&1)) 60 | @if [ ! "$(GOLINT_OUTPUT)" ]; then \ 61 | echo "golint success"; \ 62 | else \ 63 | echo "golint failure. You might want to fix these errors:"; \ 64 | golint $(DIRECTORIES_NOVENDOR_FULLPATH); \ 65 | fi 66 | 67 | cross-build: 68 | for os in darwin linux windows; do \ 69 | GOOS=$$os GOARCH=386 CGO_ENABLED=0 go build -a -tags netgo -installsuffix netgo $(LDFLAGS) -o dist/$$os-i686/$(NAME) cmd/matterpoll-emoji/main.go; \ 70 | done 71 | for os in darwin linux windows; do \ 72 | GOOS=$$os GOARCH=amd64 CGO_ENABLED=0 go build -a -tags netgo -installsuffix netgo $(LDFLAGS) -o dist/$$os-x86_64/$(NAME) cmd/matterpoll-emoji/main.go; \ 73 | done 74 | 75 | dist: cross-build 76 | cd dist && \ 77 | $(DIST_DIRS) cp ../LICENSE {} \; && \ 78 | $(DIST_DIRS) cp ../README.md {} \; && \ 79 | $(DIST_DIRS) cp ../.config.json {}/config.json \; && \ 80 | $(DIST_DIRS) tar -zcf $(NAME)-$(VERSION)-{}.tar.gz {} \; && \ 81 | cd .. 82 | -------------------------------------------------------------------------------- /cmd/matterpoll-emoji/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "flag" 5 | "log" 6 | "net/http" 7 | 8 | "github.com/matterpoll/matterpoll-emoji/poll" 9 | ) 10 | 11 | var config = flag.String("c", "config.json", "optional path to the config file") 12 | 13 | func main() { 14 | log.SetFlags(log.Ldate | log.Ltime | log.Lshortfile) 15 | 16 | c, err := poll.LoadConf(*config) 17 | if err != nil { 18 | log.Fatal(err) 19 | } 20 | ps := poll.Server{Conf: c} 21 | http.HandleFunc("/poll", ps.Cmd) 22 | if err := http.ListenAndServe(c.Listen, nil); err != nil { 23 | log.Fatal(err) 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /matterpoll-emoji.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matterpoll/matterpoll-emoji/c1ae602c53c92ec83940556f10264b50c29c011d/matterpoll-emoji.png -------------------------------------------------------------------------------- /poll/conf.go: -------------------------------------------------------------------------------- 1 | package poll 2 | 3 | import ( 4 | "encoding/json" 5 | "fmt" 6 | "io/ioutil" 7 | ) 8 | 9 | // Conf represents the login credentials of a mattermost user 10 | type Conf struct { 11 | Host string `json:"host"` 12 | Listen string `json:"listen"` 13 | Token string `json:"token"` 14 | User User `json:"user"` 15 | } 16 | 17 | // User represents the login credentials of a mattermost user 18 | type User struct { 19 | ID string `json:"id"` 20 | Password string `json:"password"` 21 | } 22 | 23 | // LoadConf loads a configuration file located at path and parse it to a Conf struct 24 | func LoadConf(path string) (*Conf, error) { 25 | b, err := ioutil.ReadFile(path) 26 | if err != nil { 27 | return nil, err 28 | } 29 | var p Conf 30 | if err := json.Unmarshal(b, &p); err != nil { 31 | return nil, err 32 | } 33 | if err := p.validate(); err != nil { 34 | return nil, err 35 | } 36 | return &p, nil 37 | } 38 | 39 | func (c *Conf) validate() error { 40 | if len(c.Host) == 0 { 41 | return fmt.Errorf("Config `host` is missing") 42 | } 43 | if len(c.Listen) == 0 { 44 | return fmt.Errorf("Config `listen` is missing") 45 | } 46 | if len(c.Token) == 0 { 47 | return fmt.Errorf("Config `token` is missing") 48 | } 49 | if len(c.Token) != 26 { 50 | return fmt.Errorf("Invalid token length. Check you config.json") 51 | } 52 | if len(c.User.ID) == 0 { 53 | return fmt.Errorf("Config `user.id` is missing") 54 | } 55 | if len(c.User.Password) == 0 { 56 | return fmt.Errorf("Config `user.password` is missing") 57 | } 58 | return nil 59 | } 60 | -------------------------------------------------------------------------------- /poll/conf_test.go: -------------------------------------------------------------------------------- 1 | package poll_test 2 | 3 | import ( 4 | "os" 5 | "path/filepath" 6 | "testing" 7 | 8 | "github.com/matterpoll/matterpoll-emoji/poll" 9 | "github.com/stretchr/testify/assert" 10 | "github.com/stretchr/testify/require" 11 | ) 12 | 13 | func TestReadConf(t *testing.T) { 14 | assert := assert.New(t) 15 | require := require.New(t) 16 | p, err := getTestFilePath("sample_conf.json") 17 | assert.Nil(err) 18 | require.NotNil(p) 19 | 20 | c, err := poll.LoadConf(p) 21 | assert.Nil(err) 22 | require.NotNil(c) 23 | 24 | assert.Equal(c.Host, "http://localhost:8065") 25 | assert.Equal(c.Token, "9jrxak1ykxrmnaed9cps9i4cim") 26 | assert.Equal(c.User.ID, "bot") 27 | assert.Equal(c.User.Password, "botbot") 28 | } 29 | 30 | func TestValidate(t *testing.T) { 31 | assert := assert.New(t) 32 | require := require.New(t) 33 | tests := []struct { 34 | Filename string 35 | ShouldError bool 36 | }{ 37 | {"sample_conf.json", false}, 38 | {"sample_conf_error.json", true}, 39 | {"sample_conf_error_no_host.json", true}, 40 | {"sample_conf_error_no_listen.json", true}, 41 | {"sample_conf_error_no_token.json", true}, 42 | {"sample_conf_error_wrong_token_length.json", true}, 43 | {"sample_conf_error_no_user.json", true}, 44 | {"sample_conf_error_no_user_id.json", true}, 45 | {"sample_conf_error_no_user_password.json", true}, 46 | } 47 | for _, test := range tests { 48 | p, err := getTestFilePath(test.Filename) 49 | assert.Nil(err) 50 | require.NotNil(p) 51 | 52 | c, err := poll.LoadConf(p) 53 | if test.ShouldError { 54 | assert.NotNil(err) 55 | assert.Nil(c) 56 | } else { 57 | assert.Nil(err) 58 | assert.NotNil(c) 59 | } 60 | } 61 | } 62 | 63 | func TestReadConfNotExistsError(t *testing.T) { 64 | assert := assert.New(t) 65 | require := require.New(t) 66 | p, err := getTestFilePath("not_exists.json") 67 | assert.Nil(err) 68 | require.NotNil(p) 69 | 70 | c, err := poll.LoadConf(p) 71 | assert.NotNil(err) 72 | assert.Nil(c) 73 | } 74 | 75 | func getTestFilePath(path string) (string, error) { 76 | d, err := os.Getwd() 77 | if err != nil { 78 | return "", err 79 | } 80 | return filepath.Join(d, "..", "testdata", path), nil 81 | } 82 | -------------------------------------------------------------------------------- /testdata/sample_conf.json: -------------------------------------------------------------------------------- 1 | { 2 | "host": "http://localhost:8065", 3 | "listen": ":8505", 4 | "token": "9jrxak1ykxrmnaed9cps9i4cim", 5 | "user": { 6 | "id": "bot", 7 | "password": "botbot" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /testdata/sample_conf_error.json: -------------------------------------------------------------------------------- 1 | { 2 | "host": 9999, 3 | "listen": "string", 4 | "token": 1234, 5 | "user": { 6 | "id": "bot", 7 | "password": "botbot" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /testdata/sample_conf_error_no_host.json: -------------------------------------------------------------------------------- 1 | { 2 | "token": "9jrxak1ykxrmnaed9cps9i4cim", 3 | "listen": ":8505", 4 | "user": { 5 | "id": "bot", 6 | "password": "botbot" 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /testdata/sample_conf_error_no_listen.json: -------------------------------------------------------------------------------- 1 | { 2 | "token": "9jrxak1ykxrmnaed9cps9i4cim", 3 | "host": "http://localhost:8065", 4 | "user": { 5 | "id": "bot", 6 | "password": "botbot" 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /testdata/sample_conf_error_no_token.json: -------------------------------------------------------------------------------- 1 | { 2 | "host": "http://localhost:8065", 3 | "listen": ":8505", 4 | "user": { 5 | "id": "bot", 6 | "password": "botbot" 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /testdata/sample_conf_error_no_user.json: -------------------------------------------------------------------------------- 1 | { 2 | "host": "http://localhost:8065", 3 | "listen": ":8505", 4 | "token": "9jrxak1ykxrmnaed9cps9i4cim" 5 | } 6 | -------------------------------------------------------------------------------- /testdata/sample_conf_error_no_user_id.json: -------------------------------------------------------------------------------- 1 | { 2 | "host": "http://localhost:8065", 3 | "listen": ":8505", 4 | "token": "9jrxak1ykxrmnaed9cps9i4cim", 5 | "user": { 6 | "password": "botbot" 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /testdata/sample_conf_error_no_user_password.json: -------------------------------------------------------------------------------- 1 | { 2 | "host": "http://localhost:8065", 3 | "listen": ":8505", 4 | "token": "9jrxak1ykxrmnaed9cps9i4cim", 5 | "user": { 6 | "id": "bot" 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /testdata/sample_conf_error_wrong_token_length.json: -------------------------------------------------------------------------------- 1 | { 2 | "host": "http://localhost:8065", 3 | "listen": ":8505", 4 | "token": "9jrxak1ykxrmnaed9cps9i4c", 5 | "user": { 6 | "id": "bot", 7 | "password": "botbot" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /vendor/github.com/davecgh/go-spew/LICENSE: -------------------------------------------------------------------------------- 1 | ISC License 2 | 3 | Copyright (c) 2012-2016 Dave Collins 4 | 5 | Permission to use, copy, modify, and/or distribute this software for any 6 | purpose with or without fee is hereby granted, provided that the above 7 | copyright notice and this permission notice appear in all copies. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 10 | WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 11 | MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 12 | ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 13 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 14 | ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 15 | OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 16 | -------------------------------------------------------------------------------- /vendor/github.com/davecgh/go-spew/spew/bypasssafe.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2016 Dave Collins 2 | // 3 | // Permission to use, copy, modify, and distribute this software for any 4 | // purpose with or without fee is hereby granted, provided that the above 5 | // copyright notice and this permission notice appear in all copies. 6 | // 7 | // THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 8 | // WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 9 | // MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 10 | // ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 11 | // WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 12 | // ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 13 | // OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 14 | 15 | // NOTE: Due to the following build constraints, this file will only be compiled 16 | // when the code is running on Google App Engine, compiled by GopherJS, or 17 | // "-tags safe" is added to the go build command line. The "disableunsafe" 18 | // tag is deprecated and thus should not be used. 19 | // +build js appengine safe disableunsafe !go1.4 20 | 21 | package spew 22 | 23 | import "reflect" 24 | 25 | const ( 26 | // UnsafeDisabled is a build-time constant which specifies whether or 27 | // not access to the unsafe package is available. 28 | UnsafeDisabled = true 29 | ) 30 | 31 | // unsafeReflectValue typically converts the passed reflect.Value into a one 32 | // that bypasses the typical safety restrictions preventing access to 33 | // unaddressable and unexported data. However, doing this relies on access to 34 | // the unsafe package. This is a stub version which simply returns the passed 35 | // reflect.Value when the unsafe package is not available. 36 | func unsafeReflectValue(v reflect.Value) reflect.Value { 37 | return v 38 | } 39 | -------------------------------------------------------------------------------- /vendor/github.com/google/uuid/CONTRIBUTORS: -------------------------------------------------------------------------------- 1 | Paul Borman 2 | bmatsuo 3 | shawnps 4 | theory 5 | jboverfelt 6 | dsymonds 7 | cd1 8 | wallclockbuilder 9 | dansouza 10 | -------------------------------------------------------------------------------- /vendor/github.com/google/uuid/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2009,2014 Google Inc. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are 5 | met: 6 | 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above 10 | copyright notice, this list of conditions and the following disclaimer 11 | in the documentation and/or other materials provided with the 12 | distribution. 13 | * Neither the name of Google Inc. nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /vendor/github.com/google/uuid/dce.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 Google Inc. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package uuid 6 | 7 | import ( 8 | "encoding/binary" 9 | "fmt" 10 | "os" 11 | ) 12 | 13 | // A Domain represents a Version 2 domain 14 | type Domain byte 15 | 16 | // Domain constants for DCE Security (Version 2) UUIDs. 17 | const ( 18 | Person = Domain(0) 19 | Group = Domain(1) 20 | Org = Domain(2) 21 | ) 22 | 23 | // NewDCESecurity returns a DCE Security (Version 2) UUID. 24 | // 25 | // The domain should be one of Person, Group or Org. 26 | // On a POSIX system the id should be the users UID for the Person 27 | // domain and the users GID for the Group. The meaning of id for 28 | // the domain Org or on non-POSIX systems is site defined. 29 | // 30 | // For a given domain/id pair the same token may be returned for up to 31 | // 7 minutes and 10 seconds. 32 | func NewDCESecurity(domain Domain, id uint32) (UUID, error) { 33 | uuid, err := NewUUID() 34 | if err == nil { 35 | uuid[6] = (uuid[6] & 0x0f) | 0x20 // Version 2 36 | uuid[9] = byte(domain) 37 | binary.BigEndian.PutUint32(uuid[0:], id) 38 | } 39 | return uuid, err 40 | } 41 | 42 | // NewDCEPerson returns a DCE Security (Version 2) UUID in the person 43 | // domain with the id returned by os.Getuid. 44 | // 45 | // NewDCESecurity(Person, uint32(os.Getuid())) 46 | func NewDCEPerson() (UUID, error) { 47 | return NewDCESecurity(Person, uint32(os.Getuid())) 48 | } 49 | 50 | // NewDCEGroup returns a DCE Security (Version 2) UUID in the group 51 | // domain with the id returned by os.Getgid. 52 | // 53 | // NewDCESecurity(Group, uint32(os.Getgid())) 54 | func NewDCEGroup() (UUID, error) { 55 | return NewDCESecurity(Group, uint32(os.Getgid())) 56 | } 57 | 58 | // Domain returns the domain for a Version 2 UUID. Domains are only defined 59 | // for Version 2 UUIDs. 60 | func (uuid UUID) Domain() Domain { 61 | return Domain(uuid[9]) 62 | } 63 | 64 | // ID returns the id for a Version 2 UUID. IDs are only defined for Version 2 65 | // UUIDs. 66 | func (uuid UUID) ID() uint32 { 67 | return binary.BigEndian.Uint32(uuid[0:4]) 68 | } 69 | 70 | func (d Domain) String() string { 71 | switch d { 72 | case Person: 73 | return "Person" 74 | case Group: 75 | return "Group" 76 | case Org: 77 | return "Org" 78 | } 79 | return fmt.Sprintf("Domain%d", int(d)) 80 | } 81 | -------------------------------------------------------------------------------- /vendor/github.com/google/uuid/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 Google Inc. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Package uuid generates and inspects UUIDs. 6 | // 7 | // UUIDs are based on RFC 4122 and DCE 1.1: Authentication and Security 8 | // Services. 9 | // 10 | // A UUID is a 16 byte (128 bit) array. UUIDs may be used as keys to 11 | // maps or compared directly. 12 | package uuid 13 | -------------------------------------------------------------------------------- /vendor/github.com/google/uuid/hash.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 Google Inc. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package uuid 6 | 7 | import ( 8 | "crypto/md5" 9 | "crypto/sha1" 10 | "hash" 11 | ) 12 | 13 | // Well known namespace IDs and UUIDs 14 | var ( 15 | NameSpaceDNS = Must(Parse("6ba7b810-9dad-11d1-80b4-00c04fd430c8")) 16 | NameSpaceURL = Must(Parse("6ba7b811-9dad-11d1-80b4-00c04fd430c8")) 17 | NameSpaceOID = Must(Parse("6ba7b812-9dad-11d1-80b4-00c04fd430c8")) 18 | NameSpaceX500 = Must(Parse("6ba7b814-9dad-11d1-80b4-00c04fd430c8")) 19 | Nil UUID // empty UUID, all zeros 20 | ) 21 | 22 | // NewHash returns a new UUID derived from the hash of space concatenated with 23 | // data generated by h. The hash should be at least 16 byte in length. The 24 | // first 16 bytes of the hash are used to form the UUID. The version of the 25 | // UUID will be the lower 4 bits of version. NewHash is used to implement 26 | // NewMD5 and NewSHA1. 27 | func NewHash(h hash.Hash, space UUID, data []byte, version int) UUID { 28 | h.Reset() 29 | h.Write(space[:]) 30 | h.Write(data) 31 | s := h.Sum(nil) 32 | var uuid UUID 33 | copy(uuid[:], s) 34 | uuid[6] = (uuid[6] & 0x0f) | uint8((version&0xf)<<4) 35 | uuid[8] = (uuid[8] & 0x3f) | 0x80 // RFC 4122 variant 36 | return uuid 37 | } 38 | 39 | // NewMD5 returns a new MD5 (Version 3) UUID based on the 40 | // supplied name space and data. It is the same as calling: 41 | // 42 | // NewHash(md5.New(), space, data, 3) 43 | func NewMD5(space UUID, data []byte) UUID { 44 | return NewHash(md5.New(), space, data, 3) 45 | } 46 | 47 | // NewSHA1 returns a new SHA1 (Version 5) UUID based on the 48 | // supplied name space and data. It is the same as calling: 49 | // 50 | // NewHash(sha1.New(), space, data, 5) 51 | func NewSHA1(space UUID, data []byte) UUID { 52 | return NewHash(sha1.New(), space, data, 5) 53 | } 54 | -------------------------------------------------------------------------------- /vendor/github.com/google/uuid/marshal.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 Google Inc. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package uuid 6 | 7 | import "fmt" 8 | 9 | // MarshalText implements encoding.TextMarshaler. 10 | func (uuid UUID) MarshalText() ([]byte, error) { 11 | var js [36]byte 12 | encodeHex(js[:], uuid) 13 | return js[:], nil 14 | } 15 | 16 | // UnmarshalText implements encoding.TextUnmarshaler. 17 | func (uuid *UUID) UnmarshalText(data []byte) error { 18 | id, err := ParseBytes(data) 19 | if err == nil { 20 | *uuid = id 21 | } 22 | return err 23 | } 24 | 25 | // MarshalBinary implements encoding.BinaryMarshaler. 26 | func (uuid UUID) MarshalBinary() ([]byte, error) { 27 | return uuid[:], nil 28 | } 29 | 30 | // UnmarshalBinary implements encoding.BinaryUnmarshaler. 31 | func (uuid *UUID) UnmarshalBinary(data []byte) error { 32 | if len(data) != 16 { 33 | return fmt.Errorf("invalid UUID (got %d bytes)", len(data)) 34 | } 35 | copy(uuid[:], data) 36 | return nil 37 | } 38 | -------------------------------------------------------------------------------- /vendor/github.com/google/uuid/node.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 Google Inc. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package uuid 6 | 7 | import ( 8 | "sync" 9 | ) 10 | 11 | var ( 12 | nodeMu sync.Mutex 13 | ifname string // name of interface being used 14 | nodeID [6]byte // hardware for version 1 UUIDs 15 | zeroID [6]byte // nodeID with only 0's 16 | ) 17 | 18 | // NodeInterface returns the name of the interface from which the NodeID was 19 | // derived. The interface "user" is returned if the NodeID was set by 20 | // SetNodeID. 21 | func NodeInterface() string { 22 | defer nodeMu.Unlock() 23 | nodeMu.Lock() 24 | return ifname 25 | } 26 | 27 | // SetNodeInterface selects the hardware address to be used for Version 1 UUIDs. 28 | // If name is "" then the first usable interface found will be used or a random 29 | // Node ID will be generated. If a named interface cannot be found then false 30 | // is returned. 31 | // 32 | // SetNodeInterface never fails when name is "". 33 | func SetNodeInterface(name string) bool { 34 | defer nodeMu.Unlock() 35 | nodeMu.Lock() 36 | return setNodeInterface(name) 37 | } 38 | 39 | func setNodeInterface(name string) bool { 40 | iname, addr := getHardwareInterface(name) // null implementation for js 41 | if iname != "" && addr != nil { 42 | ifname = iname 43 | copy(nodeID[:], addr) 44 | return true 45 | } 46 | 47 | // We found no interfaces with a valid hardware address. If name 48 | // does not specify a specific interface generate a random Node ID 49 | // (section 4.1.6) 50 | if name == "" { 51 | randomBits(nodeID[:]) 52 | return true 53 | } 54 | return false 55 | } 56 | 57 | // NodeID returns a slice of a copy of the current Node ID, setting the Node ID 58 | // if not already set. 59 | func NodeID() []byte { 60 | defer nodeMu.Unlock() 61 | nodeMu.Lock() 62 | if nodeID == zeroID { 63 | setNodeInterface("") 64 | } 65 | nid := nodeID 66 | return nid[:] 67 | } 68 | 69 | // SetNodeID sets the Node ID to be used for Version 1 UUIDs. The first 6 bytes 70 | // of id are used. If id is less than 6 bytes then false is returned and the 71 | // Node ID is not set. 72 | func SetNodeID(id []byte) bool { 73 | if len(id) < 6 { 74 | return false 75 | } 76 | defer nodeMu.Unlock() 77 | nodeMu.Lock() 78 | copy(nodeID[:], id) 79 | ifname = "user" 80 | return true 81 | } 82 | 83 | // NodeID returns the 6 byte node id encoded in uuid. It returns nil if uuid is 84 | // not valid. The NodeID is only well defined for version 1 and 2 UUIDs. 85 | func (uuid UUID) NodeID() []byte { 86 | var node [6]byte 87 | copy(node[:], uuid[10:]) 88 | return node[:] 89 | } 90 | -------------------------------------------------------------------------------- /vendor/github.com/google/uuid/node_js.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Google Inc. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build js 6 | 7 | package uuid 8 | 9 | // getHardwareInterface returns nil values for the JS version of the code. 10 | // This remvoves the "net" dependency, because it is not used in the browser. 11 | // Using the "net" library inflates the size of the transpiled JS code by 673k bytes. 12 | func getHardwareInterface(name string) (string, []byte) { return "", nil } 13 | -------------------------------------------------------------------------------- /vendor/github.com/google/uuid/node_net.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Google Inc. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !js 6 | 7 | package uuid 8 | 9 | import "net" 10 | 11 | var interfaces []net.Interface // cached list of interfaces 12 | 13 | // getHardwareInterface returns the name and hardware address of interface name. 14 | // If name is "" then the name and hardware address of one of the system's 15 | // interfaces is returned. If no interfaces are found (name does not exist or 16 | // there are no interfaces) then "", nil is returned. 17 | // 18 | // Only addresses of at least 6 bytes are returned. 19 | func getHardwareInterface(name string) (string, []byte) { 20 | if interfaces == nil { 21 | var err error 22 | interfaces, err = net.Interfaces() 23 | if err != nil { 24 | return "", nil 25 | } 26 | } 27 | for _, ifs := range interfaces { 28 | if len(ifs.HardwareAddr) >= 6 && (name == "" || name == ifs.Name) { 29 | return ifs.Name, ifs.HardwareAddr 30 | } 31 | } 32 | return "", nil 33 | } 34 | -------------------------------------------------------------------------------- /vendor/github.com/google/uuid/sql.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 Google Inc. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package uuid 6 | 7 | import ( 8 | "database/sql/driver" 9 | "fmt" 10 | ) 11 | 12 | // Scan implements sql.Scanner so UUIDs can be read from databases transparently 13 | // Currently, database types that map to string and []byte are supported. Please 14 | // consult database-specific driver documentation for matching types. 15 | func (uuid *UUID) Scan(src interface{}) error { 16 | switch src := src.(type) { 17 | case nil: 18 | return nil 19 | 20 | case string: 21 | // if an empty UUID comes from a table, we return a null UUID 22 | if src == "" { 23 | return nil 24 | } 25 | 26 | // see Parse for required string format 27 | u, err := Parse(src) 28 | if err != nil { 29 | return fmt.Errorf("Scan: %v", err) 30 | } 31 | 32 | *uuid = u 33 | 34 | case []byte: 35 | // if an empty UUID comes from a table, we return a null UUID 36 | if len(src) == 0 { 37 | return nil 38 | } 39 | 40 | // assumes a simple slice of bytes if 16 bytes 41 | // otherwise attempts to parse 42 | if len(src) != 16 { 43 | return uuid.Scan(string(src)) 44 | } 45 | copy((*uuid)[:], src) 46 | 47 | default: 48 | return fmt.Errorf("Scan: unable to scan type %T into UUID", src) 49 | } 50 | 51 | return nil 52 | } 53 | 54 | // Value implements sql.Valuer so that UUIDs can be written to databases 55 | // transparently. Currently, UUIDs map to strings. Please consult 56 | // database-specific driver documentation for matching types. 57 | func (uuid UUID) Value() (driver.Value, error) { 58 | return uuid.String(), nil 59 | } 60 | -------------------------------------------------------------------------------- /vendor/github.com/google/uuid/util.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 Google Inc. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package uuid 6 | 7 | import ( 8 | "io" 9 | ) 10 | 11 | // randomBits completely fills slice b with random data. 12 | func randomBits(b []byte) { 13 | if _, err := io.ReadFull(rander, b); err != nil { 14 | panic(err.Error()) // rand should never fail 15 | } 16 | } 17 | 18 | // xvalues returns the value of a byte as a hexadecimal digit or 255. 19 | var xvalues = [256]byte{ 20 | 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 21 | 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 22 | 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 23 | 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 255, 255, 255, 255, 255, 255, 24 | 255, 10, 11, 12, 13, 14, 15, 255, 255, 255, 255, 255, 255, 255, 255, 255, 25 | 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 26 | 255, 10, 11, 12, 13, 14, 15, 255, 255, 255, 255, 255, 255, 255, 255, 255, 27 | 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 28 | 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 29 | 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 30 | 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 31 | 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 32 | 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 33 | 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 34 | 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 35 | 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 36 | } 37 | 38 | // xtob converts hex characters x1 and x2 into a byte. 39 | func xtob(x1, x2 byte) (byte, bool) { 40 | b1 := xvalues[x1] 41 | b2 := xvalues[x2] 42 | return (b1 << 4) | b2, b1 != 255 && b2 != 255 43 | } 44 | -------------------------------------------------------------------------------- /vendor/github.com/google/uuid/version1.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 Google Inc. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package uuid 6 | 7 | import ( 8 | "encoding/binary" 9 | ) 10 | 11 | // NewUUID returns a Version 1 UUID based on the current NodeID and clock 12 | // sequence, and the current time. If the NodeID has not been set by SetNodeID 13 | // or SetNodeInterface then it will be set automatically. If the NodeID cannot 14 | // be set NewUUID returns nil. If clock sequence has not been set by 15 | // SetClockSequence then it will be set automatically. If GetTime fails to 16 | // return the current NewUUID returns nil and an error. 17 | // 18 | // In most cases, New should be used. 19 | func NewUUID() (UUID, error) { 20 | nodeMu.Lock() 21 | if nodeID == zeroID { 22 | setNodeInterface("") 23 | } 24 | nodeMu.Unlock() 25 | 26 | var uuid UUID 27 | now, seq, err := GetTime() 28 | if err != nil { 29 | return uuid, err 30 | } 31 | 32 | timeLow := uint32(now & 0xffffffff) 33 | timeMid := uint16((now >> 32) & 0xffff) 34 | timeHi := uint16((now >> 48) & 0x0fff) 35 | timeHi |= 0x1000 // Version 1 36 | 37 | binary.BigEndian.PutUint32(uuid[0:], timeLow) 38 | binary.BigEndian.PutUint16(uuid[4:], timeMid) 39 | binary.BigEndian.PutUint16(uuid[6:], timeHi) 40 | binary.BigEndian.PutUint16(uuid[8:], seq) 41 | copy(uuid[10:], nodeID[:]) 42 | 43 | return uuid, nil 44 | } 45 | -------------------------------------------------------------------------------- /vendor/github.com/google/uuid/version4.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 Google Inc. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package uuid 6 | 7 | import "io" 8 | 9 | // New creates a new random UUID or panics. New is equivalent to 10 | // the expression 11 | // 12 | // uuid.Must(uuid.NewRandom()) 13 | func New() UUID { 14 | return Must(NewRandom()) 15 | } 16 | 17 | // NewRandom returns a Random (Version 4) UUID. 18 | // 19 | // The strength of the UUIDs is based on the strength of the crypto/rand 20 | // package. 21 | // 22 | // A note about uniqueness derived from the UUID Wikipedia entry: 23 | // 24 | // Randomly generated UUIDs have 122 random bits. One's annual risk of being 25 | // hit by a meteorite is estimated to be one chance in 17 billion, that 26 | // means the probability is about 0.00000000006 (6 × 10−11), 27 | // equivalent to the odds of creating a few tens of trillions of UUIDs in a 28 | // year and having one duplicate. 29 | func NewRandom() (UUID, error) { 30 | var uuid UUID 31 | _, err := io.ReadFull(rander, uuid[:]) 32 | if err != nil { 33 | return Nil, err 34 | } 35 | uuid[6] = (uuid[6] & 0x0f) | 0x40 // Version 4 36 | uuid[8] = (uuid[8] & 0x3f) | 0x80 // Variant is 10 37 | return uuid, nil 38 | } 39 | -------------------------------------------------------------------------------- /vendor/github.com/gorilla/websocket/AUTHORS: -------------------------------------------------------------------------------- 1 | # This is the official list of Gorilla WebSocket authors for copyright 2 | # purposes. 3 | # 4 | # Please keep the list sorted. 5 | 6 | Gary Burd 7 | Google LLC (https://opensource.google.com/) 8 | Joachim Bauch 9 | 10 | -------------------------------------------------------------------------------- /vendor/github.com/gorilla/websocket/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2013 The Gorilla WebSocket Authors. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are met: 5 | 6 | Redistributions of source code must retain the above copyright notice, this 7 | list of conditions and the following disclaimer. 8 | 9 | Redistributions in binary form must reproduce the above copyright notice, 10 | this list of conditions and the following disclaimer in the documentation 11 | and/or other materials provided with the distribution. 12 | 13 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 14 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 15 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 16 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 17 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 19 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 20 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 21 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 22 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 23 | -------------------------------------------------------------------------------- /vendor/github.com/gorilla/websocket/client_clone.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Gorilla WebSocket Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build go1.8 6 | 7 | package websocket 8 | 9 | import "crypto/tls" 10 | 11 | func cloneTLSConfig(cfg *tls.Config) *tls.Config { 12 | if cfg == nil { 13 | return &tls.Config{} 14 | } 15 | return cfg.Clone() 16 | } 17 | -------------------------------------------------------------------------------- /vendor/github.com/gorilla/websocket/client_clone_legacy.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Gorilla WebSocket Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !go1.8 6 | 7 | package websocket 8 | 9 | import "crypto/tls" 10 | 11 | // cloneTLSConfig clones all public fields except the fields 12 | // SessionTicketsDisabled and SessionTicketKey. This avoids copying the 13 | // sync.Mutex in the sync.Once and makes it safe to call cloneTLSConfig on a 14 | // config in active use. 15 | func cloneTLSConfig(cfg *tls.Config) *tls.Config { 16 | if cfg == nil { 17 | return &tls.Config{} 18 | } 19 | return &tls.Config{ 20 | Rand: cfg.Rand, 21 | Time: cfg.Time, 22 | Certificates: cfg.Certificates, 23 | NameToCertificate: cfg.NameToCertificate, 24 | GetCertificate: cfg.GetCertificate, 25 | RootCAs: cfg.RootCAs, 26 | NextProtos: cfg.NextProtos, 27 | ServerName: cfg.ServerName, 28 | ClientAuth: cfg.ClientAuth, 29 | ClientCAs: cfg.ClientCAs, 30 | InsecureSkipVerify: cfg.InsecureSkipVerify, 31 | CipherSuites: cfg.CipherSuites, 32 | PreferServerCipherSuites: cfg.PreferServerCipherSuites, 33 | ClientSessionCache: cfg.ClientSessionCache, 34 | MinVersion: cfg.MinVersion, 35 | MaxVersion: cfg.MaxVersion, 36 | CurvePreferences: cfg.CurvePreferences, 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /vendor/github.com/gorilla/websocket/conn_write.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Gorilla WebSocket Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build go1.8 6 | 7 | package websocket 8 | 9 | import "net" 10 | 11 | func (c *Conn) writeBufs(bufs ...[]byte) error { 12 | b := net.Buffers(bufs) 13 | _, err := b.WriteTo(c.conn) 14 | return err 15 | } 16 | -------------------------------------------------------------------------------- /vendor/github.com/gorilla/websocket/conn_write_legacy.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Gorilla WebSocket Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !go1.8 6 | 7 | package websocket 8 | 9 | func (c *Conn) writeBufs(bufs ...[]byte) error { 10 | for _, buf := range bufs { 11 | if len(buf) > 0 { 12 | if _, err := c.conn.Write(buf); err != nil { 13 | return err 14 | } 15 | } 16 | } 17 | return nil 18 | } 19 | -------------------------------------------------------------------------------- /vendor/github.com/gorilla/websocket/json.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Gorilla WebSocket Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package websocket 6 | 7 | import ( 8 | "encoding/json" 9 | "io" 10 | ) 11 | 12 | // WriteJSON writes the JSON encoding of v as a message. 13 | // 14 | // Deprecated: Use c.WriteJSON instead. 15 | func WriteJSON(c *Conn, v interface{}) error { 16 | return c.WriteJSON(v) 17 | } 18 | 19 | // WriteJSON writes the JSON encoding of v as a message. 20 | // 21 | // See the documentation for encoding/json Marshal for details about the 22 | // conversion of Go values to JSON. 23 | func (c *Conn) WriteJSON(v interface{}) error { 24 | w, err := c.NextWriter(TextMessage) 25 | if err != nil { 26 | return err 27 | } 28 | err1 := json.NewEncoder(w).Encode(v) 29 | err2 := w.Close() 30 | if err1 != nil { 31 | return err1 32 | } 33 | return err2 34 | } 35 | 36 | // ReadJSON reads the next JSON-encoded message from the connection and stores 37 | // it in the value pointed to by v. 38 | // 39 | // Deprecated: Use c.ReadJSON instead. 40 | func ReadJSON(c *Conn, v interface{}) error { 41 | return c.ReadJSON(v) 42 | } 43 | 44 | // ReadJSON reads the next JSON-encoded message from the connection and stores 45 | // it in the value pointed to by v. 46 | // 47 | // See the documentation for the encoding/json Unmarshal function for details 48 | // about the conversion of JSON to a Go value. 49 | func (c *Conn) ReadJSON(v interface{}) error { 50 | _, r, err := c.NextReader() 51 | if err != nil { 52 | return err 53 | } 54 | err = json.NewDecoder(r).Decode(v) 55 | if err == io.EOF { 56 | // One value is expected in the message. 57 | err = io.ErrUnexpectedEOF 58 | } 59 | return err 60 | } 61 | -------------------------------------------------------------------------------- /vendor/github.com/gorilla/websocket/mask.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Gorilla WebSocket Authors. All rights reserved. Use of 2 | // this source code is governed by a BSD-style license that can be found in the 3 | // LICENSE file. 4 | 5 | // +build !appengine 6 | 7 | package websocket 8 | 9 | import "unsafe" 10 | 11 | const wordSize = int(unsafe.Sizeof(uintptr(0))) 12 | 13 | func maskBytes(key [4]byte, pos int, b []byte) int { 14 | // Mask one byte at a time for small buffers. 15 | if len(b) < 2*wordSize { 16 | for i := range b { 17 | b[i] ^= key[pos&3] 18 | pos++ 19 | } 20 | return pos & 3 21 | } 22 | 23 | // Mask one byte at a time to word boundary. 24 | if n := int(uintptr(unsafe.Pointer(&b[0]))) % wordSize; n != 0 { 25 | n = wordSize - n 26 | for i := range b[:n] { 27 | b[i] ^= key[pos&3] 28 | pos++ 29 | } 30 | b = b[n:] 31 | } 32 | 33 | // Create aligned word size key. 34 | var k [wordSize]byte 35 | for i := range k { 36 | k[i] = key[(pos+i)&3] 37 | } 38 | kw := *(*uintptr)(unsafe.Pointer(&k)) 39 | 40 | // Mask one word at a time. 41 | n := (len(b) / wordSize) * wordSize 42 | for i := 0; i < n; i += wordSize { 43 | *(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&b[0])) + uintptr(i))) ^= kw 44 | } 45 | 46 | // Mask one byte at a time for remaining bytes. 47 | b = b[n:] 48 | for i := range b { 49 | b[i] ^= key[pos&3] 50 | pos++ 51 | } 52 | 53 | return pos & 3 54 | } 55 | -------------------------------------------------------------------------------- /vendor/github.com/gorilla/websocket/mask_safe.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Gorilla WebSocket Authors. All rights reserved. Use of 2 | // this source code is governed by a BSD-style license that can be found in the 3 | // LICENSE file. 4 | 5 | // +build appengine 6 | 7 | package websocket 8 | 9 | func maskBytes(key [4]byte, pos int, b []byte) int { 10 | for i := range b { 11 | b[i] ^= key[pos&3] 12 | pos++ 13 | } 14 | return pos & 3 15 | } 16 | -------------------------------------------------------------------------------- /vendor/github.com/gorilla/websocket/proxy.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Gorilla WebSocket Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package websocket 6 | 7 | import ( 8 | "bufio" 9 | "encoding/base64" 10 | "errors" 11 | "net" 12 | "net/http" 13 | "net/url" 14 | "strings" 15 | ) 16 | 17 | type netDialerFunc func(network, addr string) (net.Conn, error) 18 | 19 | func (fn netDialerFunc) Dial(network, addr string) (net.Conn, error) { 20 | return fn(network, addr) 21 | } 22 | 23 | func init() { 24 | proxy_RegisterDialerType("http", func(proxyURL *url.URL, forwardDialer proxy_Dialer) (proxy_Dialer, error) { 25 | return &httpProxyDialer{proxyURL: proxyURL, fowardDial: forwardDialer.Dial}, nil 26 | }) 27 | } 28 | 29 | type httpProxyDialer struct { 30 | proxyURL *url.URL 31 | fowardDial func(network, addr string) (net.Conn, error) 32 | } 33 | 34 | func (hpd *httpProxyDialer) Dial(network string, addr string) (net.Conn, error) { 35 | hostPort, _ := hostPortNoPort(hpd.proxyURL) 36 | conn, err := hpd.fowardDial(network, hostPort) 37 | if err != nil { 38 | return nil, err 39 | } 40 | 41 | connectHeader := make(http.Header) 42 | if user := hpd.proxyURL.User; user != nil { 43 | proxyUser := user.Username() 44 | if proxyPassword, passwordSet := user.Password(); passwordSet { 45 | credential := base64.StdEncoding.EncodeToString([]byte(proxyUser + ":" + proxyPassword)) 46 | connectHeader.Set("Proxy-Authorization", "Basic "+credential) 47 | } 48 | } 49 | 50 | connectReq := &http.Request{ 51 | Method: "CONNECT", 52 | URL: &url.URL{Opaque: addr}, 53 | Host: addr, 54 | Header: connectHeader, 55 | } 56 | 57 | if err := connectReq.Write(conn); err != nil { 58 | conn.Close() 59 | return nil, err 60 | } 61 | 62 | // Read response. It's OK to use and discard buffered reader here becaue 63 | // the remote server does not speak until spoken to. 64 | br := bufio.NewReader(conn) 65 | resp, err := http.ReadResponse(br, connectReq) 66 | if err != nil { 67 | conn.Close() 68 | return nil, err 69 | } 70 | 71 | if resp.StatusCode != 200 { 72 | conn.Close() 73 | f := strings.SplitN(resp.Status, " ", 2) 74 | return nil, errors.New(f[1]) 75 | } 76 | return conn, nil 77 | } 78 | -------------------------------------------------------------------------------- /vendor/github.com/gorilla/websocket/trace.go: -------------------------------------------------------------------------------- 1 | // +build go1.8 2 | 3 | package websocket 4 | 5 | import ( 6 | "crypto/tls" 7 | "net/http/httptrace" 8 | ) 9 | 10 | func doHandshakeWithTrace(trace *httptrace.ClientTrace, tlsConn *tls.Conn, cfg *tls.Config) error { 11 | if trace.TLSHandshakeStart != nil { 12 | trace.TLSHandshakeStart() 13 | } 14 | err := doHandshake(tlsConn, cfg) 15 | if trace.TLSHandshakeDone != nil { 16 | trace.TLSHandshakeDone(tlsConn.ConnectionState(), err) 17 | } 18 | return err 19 | } 20 | -------------------------------------------------------------------------------- /vendor/github.com/gorilla/websocket/trace_17.go: -------------------------------------------------------------------------------- 1 | // +build !go1.8 2 | 3 | package websocket 4 | 5 | import ( 6 | "crypto/tls" 7 | "net/http/httptrace" 8 | ) 9 | 10 | func doHandshakeWithTrace(trace *httptrace.ClientTrace, tlsConn *tls.Conn, cfg *tls.Config) error { 11 | return doHandshake(tlsConn, cfg) 12 | } 13 | -------------------------------------------------------------------------------- /vendor/github.com/mattermost/mattermost-server/mlog/default.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. 2 | // See License.txt for license information. 3 | 4 | package mlog 5 | 6 | import ( 7 | "encoding/json" 8 | "fmt" 9 | ) 10 | 11 | // defaultLog manually encodes the log to STDOUT, providing a basic, default logging implementation 12 | // before mlog is fully configured. 13 | func defaultLog(level, msg string, fields ...Field) { 14 | log := struct { 15 | Level string `json:"level"` 16 | Message string `json:"msg"` 17 | Fields []Field `json:"fields,omitempty"` 18 | }{ 19 | level, 20 | msg, 21 | fields, 22 | } 23 | 24 | if b, err := json.Marshal(log); err != nil { 25 | fmt.Printf(`{"level":"error","msg":"failed to encode log message"}%s`, "\n") 26 | } else { 27 | fmt.Printf("%s\n", b) 28 | } 29 | } 30 | 31 | func defaultDebugLog(msg string, fields ...Field) { 32 | defaultLog("debug", msg, fields...) 33 | } 34 | 35 | func defaultInfoLog(msg string, fields ...Field) { 36 | defaultLog("info", msg, fields...) 37 | } 38 | 39 | func defaultWarnLog(msg string, fields ...Field) { 40 | defaultLog("warn", msg, fields...) 41 | } 42 | 43 | func defaultErrorLog(msg string, fields ...Field) { 44 | defaultLog("error", msg, fields...) 45 | } 46 | 47 | func defaultCriticalLog(msg string, fields ...Field) { 48 | // We map critical to error in zap, so be consistent. 49 | defaultLog("error", msg, fields...) 50 | } 51 | -------------------------------------------------------------------------------- /vendor/github.com/mattermost/mattermost-server/mlog/global.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. 2 | // See License.txt for license information. 3 | 4 | package mlog 5 | 6 | import ( 7 | "go.uber.org/zap" 8 | "go.uber.org/zap/zapcore" 9 | ) 10 | 11 | var globalLogger *Logger 12 | 13 | func InitGlobalLogger(logger *Logger) { 14 | glob := *logger 15 | glob.zap = glob.zap.WithOptions(zap.AddCallerSkip(1)) 16 | globalLogger = &glob 17 | Debug = globalLogger.Debug 18 | Info = globalLogger.Info 19 | Warn = globalLogger.Warn 20 | Error = globalLogger.Error 21 | Critical = globalLogger.Critical 22 | } 23 | 24 | func RedirectStdLog(logger *Logger) { 25 | zap.RedirectStdLogAt(logger.zap.With(zap.String("source", "stdlog")).WithOptions(zap.AddCallerSkip(-2)), zapcore.ErrorLevel) 26 | } 27 | 28 | type LogFunc func(string, ...Field) 29 | 30 | // DON'T USE THIS Modify the level on the app logger 31 | func GloballyDisableDebugLogForTest() { 32 | globalLogger.consoleLevel.SetLevel(zapcore.ErrorLevel) 33 | } 34 | 35 | // DON'T USE THIS Modify the level on the app logger 36 | func GloballyEnableDebugLogForTest() { 37 | globalLogger.consoleLevel.SetLevel(zapcore.DebugLevel) 38 | } 39 | 40 | var Debug LogFunc = defaultDebugLog 41 | var Info LogFunc = defaultInfoLog 42 | var Warn LogFunc = defaultWarnLog 43 | var Error LogFunc = defaultErrorLog 44 | var Critical LogFunc = defaultCriticalLog 45 | -------------------------------------------------------------------------------- /vendor/github.com/mattermost/mattermost-server/mlog/sugar.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. 2 | // See LICENSE.txt for license information. 3 | 4 | package mlog 5 | 6 | import "go.uber.org/zap" 7 | 8 | // Made for the plugin interface, use the regular logger for other uses 9 | type SugarLogger struct { 10 | wrappedLogger *Logger 11 | zapSugar *zap.SugaredLogger 12 | } 13 | 14 | func (l *SugarLogger) Debug(msg string, keyValuePairs ...interface{}) { 15 | l.zapSugar.Debugw(msg, keyValuePairs...) 16 | } 17 | 18 | func (l *SugarLogger) Info(msg string, keyValuePairs ...interface{}) { 19 | l.zapSugar.Infow(msg, keyValuePairs...) 20 | } 21 | 22 | func (l *SugarLogger) Error(msg string, keyValuePairs ...interface{}) { 23 | l.zapSugar.Errorw(msg, keyValuePairs...) 24 | } 25 | 26 | func (l *SugarLogger) Warn(msg string, keyValuePairs ...interface{}) { 27 | l.zapSugar.Warnw(msg, keyValuePairs...) 28 | } 29 | -------------------------------------------------------------------------------- /vendor/github.com/mattermost/mattermost-server/model/analytics_row.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. 2 | // See License.txt for license information. 3 | 4 | package model 5 | 6 | import ( 7 | "encoding/json" 8 | "io" 9 | ) 10 | 11 | type AnalyticsRow struct { 12 | Name string `json:"name"` 13 | Value float64 `json:"value"` 14 | } 15 | 16 | type AnalyticsRows []*AnalyticsRow 17 | 18 | func (me *AnalyticsRow) ToJson() string { 19 | b, _ := json.Marshal(me) 20 | return string(b) 21 | } 22 | 23 | func AnalyticsRowFromJson(data io.Reader) *AnalyticsRow { 24 | var me *AnalyticsRow 25 | json.NewDecoder(data).Decode(&me) 26 | return me 27 | } 28 | 29 | func (me AnalyticsRows) ToJson() string { 30 | if b, err := json.Marshal(me); err != nil { 31 | return "[]" 32 | } else { 33 | return string(b) 34 | } 35 | } 36 | 37 | func AnalyticsRowsFromJson(data io.Reader) AnalyticsRows { 38 | var me AnalyticsRows 39 | json.NewDecoder(data).Decode(&me) 40 | return me 41 | } 42 | -------------------------------------------------------------------------------- /vendor/github.com/mattermost/mattermost-server/model/audit.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. 2 | // See License.txt for license information. 3 | 4 | package model 5 | 6 | import ( 7 | "encoding/json" 8 | "io" 9 | ) 10 | 11 | type Audit struct { 12 | Id string `json:"id"` 13 | CreateAt int64 `json:"create_at"` 14 | UserId string `json:"user_id"` 15 | Action string `json:"action"` 16 | ExtraInfo string `json:"extra_info"` 17 | IpAddress string `json:"ip_address"` 18 | SessionId string `json:"session_id"` 19 | } 20 | 21 | func (o *Audit) ToJson() string { 22 | b, _ := json.Marshal(o) 23 | return string(b) 24 | } 25 | 26 | func AuditFromJson(data io.Reader) *Audit { 27 | var o *Audit 28 | json.NewDecoder(data).Decode(&o) 29 | return o 30 | } 31 | -------------------------------------------------------------------------------- /vendor/github.com/mattermost/mattermost-server/model/audits.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. 2 | // See License.txt for license information. 3 | 4 | package model 5 | 6 | import ( 7 | "encoding/json" 8 | "io" 9 | ) 10 | 11 | type Audits []Audit 12 | 13 | func (o Audits) Etag() string { 14 | if len(o) > 0 { 15 | // the first in the list is always the most current 16 | return Etag(o[0].CreateAt) 17 | } else { 18 | return "" 19 | } 20 | } 21 | 22 | func (o Audits) ToJson() string { 23 | if b, err := json.Marshal(o); err != nil { 24 | return "[]" 25 | } else { 26 | return string(b) 27 | } 28 | } 29 | 30 | func AuditsFromJson(data io.Reader) Audits { 31 | var o Audits 32 | json.NewDecoder(data).Decode(&o) 33 | return o 34 | } 35 | -------------------------------------------------------------------------------- /vendor/github.com/mattermost/mattermost-server/model/builtin.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. 2 | // See License.txt for license information. 3 | 4 | package model 5 | 6 | func NewBool(b bool) *bool { return &b } 7 | func NewInt(n int) *int { return &n } 8 | func NewInt64(n int64) *int64 { return &n } 9 | func NewString(s string) *string { return &s } 10 | -------------------------------------------------------------------------------- /vendor/github.com/mattermost/mattermost-server/model/bundle_info.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. 2 | // See License.txt for license information. 3 | 4 | package model 5 | 6 | import "github.com/mattermost/mattermost-server/mlog" 7 | 8 | type BundleInfo struct { 9 | Path string 10 | 11 | Manifest *Manifest 12 | ManifestPath string 13 | ManifestError error 14 | } 15 | 16 | func (b *BundleInfo) WrapLogger(logger *mlog.Logger) *mlog.Logger { 17 | if b.Manifest != nil { 18 | return logger.With(mlog.String("plugin_id", b.Manifest.Id)) 19 | } 20 | return logger.With(mlog.String("plugin_path", b.Path)) 21 | } 22 | 23 | // Returns bundle info for the given path. The return value is never nil. 24 | func BundleInfoForPath(path string) *BundleInfo { 25 | m, mpath, err := FindManifest(path) 26 | return &BundleInfo{ 27 | Path: path, 28 | Manifest: m, 29 | ManifestPath: mpath, 30 | ManifestError: err, 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /vendor/github.com/mattermost/mattermost-server/model/channel_count.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. 2 | // See License.txt for license information. 3 | 4 | package model 5 | 6 | import ( 7 | "crypto/md5" 8 | "encoding/json" 9 | "fmt" 10 | "io" 11 | "sort" 12 | "strconv" 13 | ) 14 | 15 | type ChannelCounts struct { 16 | Counts map[string]int64 `json:"counts"` 17 | UpdateTimes map[string]int64 `json:"update_times"` 18 | } 19 | 20 | func (o *ChannelCounts) Etag() string { 21 | 22 | ids := []string{} 23 | for id := range o.Counts { 24 | ids = append(ids, id) 25 | } 26 | sort.Strings(ids) 27 | 28 | str := "" 29 | for _, id := range ids { 30 | str += id + strconv.FormatInt(o.Counts[id], 10) 31 | } 32 | 33 | md5Counts := fmt.Sprintf("%x", md5.Sum([]byte(str))) 34 | 35 | var update int64 = 0 36 | for _, u := range o.UpdateTimes { 37 | if u > update { 38 | update = u 39 | } 40 | } 41 | 42 | return Etag(md5Counts, update) 43 | } 44 | 45 | func (o *ChannelCounts) ToJson() string { 46 | b, _ := json.Marshal(o) 47 | return string(b) 48 | } 49 | 50 | func ChannelCountsFromJson(data io.Reader) *ChannelCounts { 51 | var o *ChannelCounts 52 | json.NewDecoder(data).Decode(&o) 53 | return o 54 | } 55 | -------------------------------------------------------------------------------- /vendor/github.com/mattermost/mattermost-server/model/channel_data.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. 2 | // See License.txt for license information. 3 | 4 | package model 5 | 6 | import ( 7 | "encoding/json" 8 | "io" 9 | ) 10 | 11 | type ChannelData struct { 12 | Channel *Channel `json:"channel"` 13 | Member *ChannelMember `json:"member"` 14 | } 15 | 16 | func (o *ChannelData) Etag() string { 17 | var mt int64 = 0 18 | if o.Member != nil { 19 | mt = o.Member.LastUpdateAt 20 | } 21 | 22 | return Etag(o.Channel.Id, o.Channel.UpdateAt, o.Channel.LastPostAt, mt) 23 | } 24 | 25 | func (o *ChannelData) ToJson() string { 26 | b, _ := json.Marshal(o) 27 | return string(b) 28 | } 29 | 30 | func ChannelDataFromJson(data io.Reader) *ChannelData { 31 | var o *ChannelData 32 | json.NewDecoder(data).Decode(&o) 33 | return o 34 | } 35 | -------------------------------------------------------------------------------- /vendor/github.com/mattermost/mattermost-server/model/channel_list.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. 2 | // See License.txt for license information. 3 | 4 | package model 5 | 6 | import ( 7 | "encoding/json" 8 | "io" 9 | ) 10 | 11 | type ChannelList []*Channel 12 | 13 | func (o *ChannelList) ToJson() string { 14 | if b, err := json.Marshal(o); err != nil { 15 | return "[]" 16 | } else { 17 | return string(b) 18 | } 19 | } 20 | 21 | func (o *ChannelList) Etag() string { 22 | 23 | id := "0" 24 | var t int64 = 0 25 | var delta int64 = 0 26 | 27 | for _, v := range *o { 28 | if v.LastPostAt > t { 29 | t = v.LastPostAt 30 | id = v.Id 31 | } 32 | 33 | if v.UpdateAt > t { 34 | t = v.UpdateAt 35 | id = v.Id 36 | } 37 | 38 | } 39 | 40 | return Etag(id, t, delta, len(*o)) 41 | } 42 | 43 | func ChannelListFromJson(data io.Reader) *ChannelList { 44 | var o *ChannelList 45 | json.NewDecoder(data).Decode(&o) 46 | return o 47 | } 48 | 49 | func ChannelSliceFromJson(data io.Reader) []*Channel { 50 | var o []*Channel 51 | json.NewDecoder(data).Decode(&o) 52 | return o 53 | } 54 | -------------------------------------------------------------------------------- /vendor/github.com/mattermost/mattermost-server/model/channel_member_history.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2017-present Mattermost, Inc. All Rights Reserved. 2 | // See License.txt for license information. 3 | 4 | package model 5 | 6 | type ChannelMemberHistory struct { 7 | ChannelId string 8 | UserId string 9 | JoinTime int64 10 | LeaveTime *int64 11 | } 12 | -------------------------------------------------------------------------------- /vendor/github.com/mattermost/mattermost-server/model/channel_member_history_result.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2017-present Mattermost, Inc. All Rights Reserved. 2 | // See License.txt for license information. 3 | 4 | package model 5 | 6 | type ChannelMemberHistoryResult struct { 7 | ChannelId string 8 | UserId string 9 | JoinTime int64 10 | LeaveTime *int64 11 | 12 | // these two fields are never set in the database - when we SELECT, we join on Users to get them 13 | UserEmail string `db:"Email"` 14 | Username string 15 | } 16 | -------------------------------------------------------------------------------- /vendor/github.com/mattermost/mattermost-server/model/channel_mentions.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. 2 | // See License.txt for license information. 3 | 4 | package model 5 | 6 | import ( 7 | "regexp" 8 | "strings" 9 | ) 10 | 11 | var channelMentionRegexp = regexp.MustCompile(`\B~[a-zA-Z0-9\-_]+`) 12 | 13 | func ChannelMentions(message string) []string { 14 | var names []string 15 | 16 | if strings.Contains(message, "~") { 17 | alreadyMentioned := make(map[string]bool) 18 | for _, match := range channelMentionRegexp.FindAllString(message, -1) { 19 | name := match[1:] 20 | if !alreadyMentioned[name] { 21 | names = append(names, name) 22 | alreadyMentioned[name] = true 23 | } 24 | } 25 | } 26 | 27 | return names 28 | } 29 | -------------------------------------------------------------------------------- /vendor/github.com/mattermost/mattermost-server/model/channel_search.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved. 2 | // See License.txt for license information. 3 | 4 | package model 5 | 6 | import ( 7 | "encoding/json" 8 | "io" 9 | ) 10 | 11 | type ChannelSearch struct { 12 | Term string `json:"term"` 13 | } 14 | 15 | // ToJson convert a Channel to a json string 16 | func (c *ChannelSearch) ToJson() string { 17 | b, _ := json.Marshal(c) 18 | return string(b) 19 | } 20 | 21 | // ChannelSearchFromJson will decode the input and return a Channel 22 | func ChannelSearchFromJson(data io.Reader) *ChannelSearch { 23 | var cs *ChannelSearch 24 | json.NewDecoder(data).Decode(&cs) 25 | return cs 26 | } 27 | -------------------------------------------------------------------------------- /vendor/github.com/mattermost/mattermost-server/model/channel_stats.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. 2 | // See License.txt for license information. 3 | 4 | package model 5 | 6 | import ( 7 | "encoding/json" 8 | "io" 9 | ) 10 | 11 | type ChannelStats struct { 12 | ChannelId string `json:"channel_id"` 13 | MemberCount int64 `json:"member_count"` 14 | } 15 | 16 | func (o *ChannelStats) ToJson() string { 17 | b, _ := json.Marshal(o) 18 | return string(b) 19 | } 20 | 21 | func ChannelStatsFromJson(data io.Reader) *ChannelStats { 22 | var o *ChannelStats 23 | json.NewDecoder(data).Decode(&o) 24 | return o 25 | } 26 | -------------------------------------------------------------------------------- /vendor/github.com/mattermost/mattermost-server/model/channel_view.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved. 2 | // See License.txt for license information. 3 | 4 | package model 5 | 6 | import ( 7 | "encoding/json" 8 | "io" 9 | ) 10 | 11 | type ChannelView struct { 12 | ChannelId string `json:"channel_id"` 13 | PrevChannelId string `json:"prev_channel_id"` 14 | } 15 | 16 | func (o *ChannelView) ToJson() string { 17 | b, _ := json.Marshal(o) 18 | return string(b) 19 | } 20 | 21 | func ChannelViewFromJson(data io.Reader) *ChannelView { 22 | var o *ChannelView 23 | json.NewDecoder(data).Decode(&o) 24 | return o 25 | } 26 | 27 | type ChannelViewResponse struct { 28 | Status string `json:"status"` 29 | LastViewedAtTimes map[string]int64 `json:"last_viewed_at_times"` 30 | } 31 | 32 | func (o *ChannelViewResponse) ToJson() string { 33 | b, _ := json.Marshal(o) 34 | return string(b) 35 | } 36 | 37 | func ChannelViewResponseFromJson(data io.Reader) *ChannelViewResponse { 38 | var o *ChannelViewResponse 39 | json.NewDecoder(data).Decode(&o) 40 | return o 41 | } 42 | -------------------------------------------------------------------------------- /vendor/github.com/mattermost/mattermost-server/model/cluster_info.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. 2 | // See License.txt for license information. 3 | 4 | package model 5 | 6 | import ( 7 | "encoding/json" 8 | "io" 9 | ) 10 | 11 | type ClusterInfo struct { 12 | Id string `json:"id"` 13 | Version string `json:"version"` 14 | ConfigHash string `json:"config_hash"` 15 | IpAddress string `json:"ipaddress"` 16 | Hostname string `json:"hostname"` 17 | } 18 | 19 | func (me *ClusterInfo) ToJson() string { 20 | b, _ := json.Marshal(me) 21 | return string(b) 22 | } 23 | 24 | func ClusterInfoFromJson(data io.Reader) *ClusterInfo { 25 | var me *ClusterInfo 26 | json.NewDecoder(data).Decode(&me) 27 | return me 28 | } 29 | 30 | func ClusterInfosToJson(objmap []*ClusterInfo) string { 31 | b, _ := json.Marshal(objmap) 32 | return string(b) 33 | } 34 | 35 | func ClusterInfosFromJson(data io.Reader) []*ClusterInfo { 36 | decoder := json.NewDecoder(data) 37 | 38 | var objmap []*ClusterInfo 39 | if err := decoder.Decode(&objmap); err != nil { 40 | return make([]*ClusterInfo, 0) 41 | } else { 42 | return objmap 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /vendor/github.com/mattermost/mattermost-server/model/cluster_message.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved. 2 | // See License.txt for license information. 3 | 4 | package model 5 | 6 | import ( 7 | "encoding/json" 8 | "io" 9 | ) 10 | 11 | const ( 12 | CLUSTER_EVENT_PUBLISH = "publish" 13 | CLUSTER_EVENT_UPDATE_STATUS = "update_status" 14 | CLUSTER_EVENT_INVALIDATE_ALL_CACHES = "inv_all_caches" 15 | CLUSTER_EVENT_INVALIDATE_CACHE_FOR_REACTIONS = "inv_reactions" 16 | CLUSTER_EVENT_INVALIDATE_CACHE_FOR_WEBHOOK = "inv_webhook" 17 | CLUSTER_EVENT_INVALIDATE_CACHE_FOR_CHANNEL_POSTS = "inv_channel_posts" 18 | CLUSTER_EVENT_INVALIDATE_CACHE_FOR_CHANNEL_MEMBERS_NOTIFY_PROPS = "inv_channel_members_notify_props" 19 | CLUSTER_EVENT_INVALIDATE_CACHE_FOR_CHANNEL_MEMBERS = "inv_channel_members" 20 | CLUSTER_EVENT_INVALIDATE_CACHE_FOR_CHANNEL_BY_NAME = "inv_channel_name" 21 | CLUSTER_EVENT_INVALIDATE_CACHE_FOR_CHANNEL = "inv_channel" 22 | CLUSTER_EVENT_INVALIDATE_CACHE_FOR_USER = "inv_user" 23 | CLUSTER_EVENT_CLEAR_SESSION_CACHE_FOR_USER = "clear_session_user" 24 | CLUSTER_EVENT_INVALIDATE_CACHE_FOR_ROLES = "inv_roles" 25 | CLUSTER_EVENT_INVALIDATE_CACHE_FOR_SCHEMES = "inv_schemes" 26 | 27 | CLUSTER_SEND_BEST_EFFORT = "best_effort" 28 | CLUSTER_SEND_RELIABLE = "reliable" 29 | ) 30 | 31 | type ClusterMessage struct { 32 | Event string `json:"event"` 33 | SendType string `json:"-"` 34 | WaitForAllToSend bool `json:"-"` 35 | Data string `json:"data,omitempty"` 36 | Props map[string]string `json:"props,omitempty"` 37 | } 38 | 39 | func (o *ClusterMessage) ToJson() string { 40 | b, _ := json.Marshal(o) 41 | return string(b) 42 | } 43 | 44 | func ClusterMessageFromJson(data io.Reader) *ClusterMessage { 45 | var o *ClusterMessage 46 | json.NewDecoder(data).Decode(&o) 47 | return o 48 | } 49 | -------------------------------------------------------------------------------- /vendor/github.com/mattermost/mattermost-server/model/cluster_stats.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. 2 | // See License.txt for license information. 3 | 4 | package model 5 | 6 | import ( 7 | "encoding/json" 8 | "io" 9 | ) 10 | 11 | type ClusterStats struct { 12 | Id string `json:"id"` 13 | TotalWebsocketConnections int `json:"total_websocket_connections"` 14 | TotalReadDbConnections int `json:"total_read_db_connections"` 15 | TotalMasterDbConnections int `json:"total_master_db_connections"` 16 | } 17 | 18 | func (me *ClusterStats) ToJson() string { 19 | b, _ := json.Marshal(me) 20 | return string(b) 21 | } 22 | 23 | func ClusterStatsFromJson(data io.Reader) *ClusterStats { 24 | var me *ClusterStats 25 | json.NewDecoder(data).Decode(&me) 26 | return me 27 | } 28 | -------------------------------------------------------------------------------- /vendor/github.com/mattermost/mattermost-server/model/command_args.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved. 2 | // See License.txt for license information. 3 | 4 | package model 5 | 6 | import ( 7 | "encoding/json" 8 | "io" 9 | 10 | goi18n "github.com/nicksnyder/go-i18n/i18n" 11 | ) 12 | 13 | type CommandArgs struct { 14 | UserId string `json:"user_id"` 15 | ChannelId string `json:"channel_id"` 16 | TeamId string `json:"team_id"` 17 | RootId string `json:"root_id"` 18 | ParentId string `json:"parent_id"` 19 | Command string `json:"command"` 20 | SiteURL string `json:"-"` 21 | T goi18n.TranslateFunc `json:"-"` 22 | Session Session `json:"-"` 23 | } 24 | 25 | func (o *CommandArgs) ToJson() string { 26 | b, _ := json.Marshal(o) 27 | return string(b) 28 | } 29 | 30 | func CommandArgsFromJson(data io.Reader) *CommandArgs { 31 | var o *CommandArgs 32 | json.NewDecoder(data).Decode(&o) 33 | return o 34 | } 35 | -------------------------------------------------------------------------------- /vendor/github.com/mattermost/mattermost-server/model/command_response.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved. 2 | // See License.txt for license information. 3 | 4 | package model 5 | 6 | import ( 7 | "encoding/json" 8 | "io" 9 | "io/ioutil" 10 | "strings" 11 | 12 | "github.com/mattermost/mattermost-server/utils/jsonutils" 13 | ) 14 | 15 | const ( 16 | COMMAND_RESPONSE_TYPE_IN_CHANNEL = "in_channel" 17 | COMMAND_RESPONSE_TYPE_EPHEMERAL = "ephemeral" 18 | ) 19 | 20 | type CommandResponse struct { 21 | ResponseType string `json:"response_type"` 22 | Text string `json:"text"` 23 | Username string `json:"username"` 24 | IconURL string `json:"icon_url"` 25 | Type string `json:"type"` 26 | Props StringInterface `json:"props"` 27 | GotoLocation string `json:"goto_location"` 28 | Attachments []*SlackAttachment `json:"attachments"` 29 | } 30 | 31 | func (o *CommandResponse) ToJson() string { 32 | b, _ := json.Marshal(o) 33 | return string(b) 34 | } 35 | 36 | func CommandResponseFromHTTPBody(contentType string, body io.Reader) (*CommandResponse, error) { 37 | if strings.TrimSpace(strings.Split(contentType, ";")[0]) == "application/json" { 38 | return CommandResponseFromJson(body) 39 | } 40 | if b, err := ioutil.ReadAll(body); err == nil { 41 | return CommandResponseFromPlainText(string(b)), nil 42 | } 43 | return nil, nil 44 | } 45 | 46 | func CommandResponseFromPlainText(text string) *CommandResponse { 47 | return &CommandResponse{ 48 | Text: text, 49 | } 50 | } 51 | 52 | func CommandResponseFromJson(data io.Reader) (*CommandResponse, error) { 53 | b, err := ioutil.ReadAll(data) 54 | if err != nil { 55 | return nil, err 56 | } 57 | 58 | var o CommandResponse 59 | err = json.Unmarshal(b, &o) 60 | if err != nil { 61 | return nil, jsonutils.HumanizeJsonError(err, b) 62 | } 63 | 64 | o.Attachments = StringifySlackFieldValue(o.Attachments) 65 | 66 | return &o, nil 67 | } 68 | -------------------------------------------------------------------------------- /vendor/github.com/mattermost/mattermost-server/model/command_webhook.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2017-present Mattermost, Inc. All Rights Reserved. 2 | // See License.txt for license information. 3 | 4 | package model 5 | 6 | import ( 7 | "net/http" 8 | ) 9 | 10 | type CommandWebhook struct { 11 | Id string 12 | CreateAt int64 13 | CommandId string 14 | UserId string 15 | ChannelId string 16 | RootId string 17 | ParentId string 18 | UseCount int 19 | } 20 | 21 | const ( 22 | COMMAND_WEBHOOK_LIFETIME = 1000 * 60 * 30 23 | ) 24 | 25 | func (o *CommandWebhook) PreSave() { 26 | if o.Id == "" { 27 | o.Id = NewId() 28 | } 29 | 30 | if o.CreateAt == 0 { 31 | o.CreateAt = GetMillis() 32 | } 33 | } 34 | 35 | func (o *CommandWebhook) IsValid() *AppError { 36 | if len(o.Id) != 26 { 37 | return NewAppError("CommandWebhook.IsValid", "model.command_hook.id.app_error", nil, "", http.StatusBadRequest) 38 | } 39 | 40 | if o.CreateAt == 0 { 41 | return NewAppError("CommandWebhook.IsValid", "model.command_hook.create_at.app_error", nil, "id="+o.Id, http.StatusBadRequest) 42 | } 43 | 44 | if len(o.CommandId) != 26 { 45 | return NewAppError("CommandWebhook.IsValid", "model.command_hook.command_id.app_error", nil, "", http.StatusBadRequest) 46 | } 47 | 48 | if len(o.UserId) != 26 { 49 | return NewAppError("CommandWebhook.IsValid", "model.command_hook.user_id.app_error", nil, "", http.StatusBadRequest) 50 | } 51 | 52 | if len(o.ChannelId) != 26 { 53 | return NewAppError("CommandWebhook.IsValid", "model.command_hook.channel_id.app_error", nil, "", http.StatusBadRequest) 54 | } 55 | 56 | if len(o.RootId) != 0 && len(o.RootId) != 26 { 57 | return NewAppError("CommandWebhook.IsValid", "model.command_hook.root_id.app_error", nil, "", http.StatusBadRequest) 58 | } 59 | 60 | if len(o.ParentId) != 0 && len(o.ParentId) != 26 { 61 | return NewAppError("CommandWebhook.IsValid", "model.command_hook.parent_id.app_error", nil, "", http.StatusBadRequest) 62 | } 63 | 64 | return nil 65 | } 66 | -------------------------------------------------------------------------------- /vendor/github.com/mattermost/mattermost-server/model/data_retention_policy.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2017-present Mattermost, Inc. All Rights Reserved. 2 | // See License.txt for license information. 3 | 4 | package model 5 | 6 | import ( 7 | "encoding/json" 8 | "io" 9 | ) 10 | 11 | type DataRetentionPolicy struct { 12 | MessageDeletionEnabled bool `json:"message_deletion_enabled"` 13 | FileDeletionEnabled bool `json:"file_deletion_enabled"` 14 | MessageRetentionCutoff int64 `json:"message_retention_cutoff"` 15 | FileRetentionCutoff int64 `json:"file_retention_cutoff"` 16 | } 17 | 18 | func (me *DataRetentionPolicy) ToJson() string { 19 | b, _ := json.Marshal(me) 20 | return string(b) 21 | } 22 | 23 | func DataRetentionPolicyFromJson(data io.Reader) *DataRetentionPolicy { 24 | var me *DataRetentionPolicy 25 | json.NewDecoder(data).Decode(&me) 26 | return me 27 | } 28 | -------------------------------------------------------------------------------- /vendor/github.com/mattermost/mattermost-server/model/emoji.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved. 2 | // See License.txt for license information. 3 | 4 | package model 5 | 6 | import ( 7 | "encoding/json" 8 | "io" 9 | "net/http" 10 | ) 11 | 12 | const ( 13 | EMOJI_NAME_MAX_LENGTH = 64 14 | EMOJI_SORT_BY_NAME = "name" 15 | ) 16 | 17 | type Emoji struct { 18 | Id string `json:"id"` 19 | CreateAt int64 `json:"create_at"` 20 | UpdateAt int64 `json:"update_at"` 21 | DeleteAt int64 `json:"delete_at"` 22 | CreatorId string `json:"creator_id"` 23 | Name string `json:"name"` 24 | } 25 | 26 | func inSystemEmoji(emojiName string) bool { 27 | _, ok := SystemEmojis[emojiName] 28 | return ok 29 | } 30 | 31 | func (emoji *Emoji) IsValid() *AppError { 32 | if len(emoji.Id) != 26 { 33 | return NewAppError("Emoji.IsValid", "model.emoji.id.app_error", nil, "", http.StatusBadRequest) 34 | } 35 | 36 | if emoji.CreateAt == 0 { 37 | return NewAppError("Emoji.IsValid", "model.emoji.create_at.app_error", nil, "id="+emoji.Id, http.StatusBadRequest) 38 | } 39 | 40 | if emoji.UpdateAt == 0 { 41 | return NewAppError("Emoji.IsValid", "model.emoji.update_at.app_error", nil, "id="+emoji.Id, http.StatusBadRequest) 42 | } 43 | 44 | if len(emoji.CreatorId) > 26 { 45 | return NewAppError("Emoji.IsValid", "model.emoji.user_id.app_error", nil, "", http.StatusBadRequest) 46 | } 47 | 48 | return IsValidEmojiName(emoji.Name) 49 | } 50 | 51 | func IsValidEmojiName(name string) *AppError { 52 | if len(name) == 0 || len(name) > EMOJI_NAME_MAX_LENGTH || !IsValidAlphaNumHyphenUnderscore(name, false) || inSystemEmoji(name) { 53 | return NewAppError("Emoji.IsValid", "model.emoji.name.app_error", nil, "", http.StatusBadRequest) 54 | } 55 | 56 | return nil 57 | } 58 | 59 | func (emoji *Emoji) PreSave() { 60 | if emoji.Id == "" { 61 | emoji.Id = NewId() 62 | } 63 | 64 | emoji.CreateAt = GetMillis() 65 | emoji.UpdateAt = emoji.CreateAt 66 | } 67 | 68 | func (emoji *Emoji) ToJson() string { 69 | b, _ := json.Marshal(emoji) 70 | return string(b) 71 | } 72 | 73 | func EmojiFromJson(data io.Reader) *Emoji { 74 | var emoji *Emoji 75 | json.NewDecoder(data).Decode(&emoji) 76 | return emoji 77 | } 78 | 79 | func EmojiListToJson(emojiList []*Emoji) string { 80 | b, _ := json.Marshal(emojiList) 81 | return string(b) 82 | } 83 | 84 | func EmojiListFromJson(data io.Reader) []*Emoji { 85 | var emojiList []*Emoji 86 | json.NewDecoder(data).Decode(&emojiList) 87 | return emojiList 88 | } 89 | -------------------------------------------------------------------------------- /vendor/github.com/mattermost/mattermost-server/model/emoji_search.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2018-present Mattermost, Inc. All Rights Reserved. 2 | // See License.txt for license information. 3 | 4 | package model 5 | 6 | import ( 7 | "encoding/json" 8 | "io" 9 | ) 10 | 11 | type EmojiSearch struct { 12 | Term string `json:"term"` 13 | PrefixOnly bool `json:"prefix_only"` 14 | } 15 | 16 | func (es *EmojiSearch) ToJson() string { 17 | b, _ := json.Marshal(es) 18 | return string(b) 19 | } 20 | 21 | func EmojiSearchFromJson(data io.Reader) *EmojiSearch { 22 | var es *EmojiSearch 23 | json.NewDecoder(data).Decode(&es) 24 | return es 25 | } 26 | -------------------------------------------------------------------------------- /vendor/github.com/mattermost/mattermost-server/model/file.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. 2 | // See License.txt for license information. 3 | 4 | package model 5 | 6 | import ( 7 | "encoding/json" 8 | "io" 9 | ) 10 | 11 | const ( 12 | MaxImageSize = 6048 * 4032 // 24 megapixels, roughly 36MB as a raw image 13 | ) 14 | 15 | var ( 16 | IMAGE_EXTENSIONS = [5]string{".jpg", ".jpeg", ".gif", ".bmp", ".png"} 17 | IMAGE_MIME_TYPES = map[string]string{".jpg": "image/jpeg", ".jpeg": "image/jpeg", ".gif": "image/gif", ".bmp": "image/bmp", ".png": "image/png", ".tiff": "image/tiff"} 18 | ) 19 | 20 | type FileUploadResponse struct { 21 | FileInfos []*FileInfo `json:"file_infos"` 22 | ClientIds []string `json:"client_ids"` 23 | } 24 | 25 | func FileUploadResponseFromJson(data io.Reader) *FileUploadResponse { 26 | var o *FileUploadResponse 27 | json.NewDecoder(data).Decode(&o) 28 | return o 29 | } 30 | 31 | func (o *FileUploadResponse) ToJson() string { 32 | b, _ := json.Marshal(o) 33 | return string(b) 34 | } 35 | -------------------------------------------------------------------------------- /vendor/github.com/mattermost/mattermost-server/model/gitlab.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. 2 | // See License.txt for license information. 3 | 4 | package model 5 | 6 | const ( 7 | USER_AUTH_SERVICE_GITLAB = "gitlab" 8 | ) 9 | -------------------------------------------------------------------------------- /vendor/github.com/mattermost/mattermost-server/model/initial_load.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved. 2 | // See License.txt for license information. 3 | 4 | package model 5 | 6 | import ( 7 | "encoding/json" 8 | "io" 9 | ) 10 | 11 | type InitialLoad struct { 12 | User *User `json:"user"` 13 | TeamMembers []*TeamMember `json:"team_members"` 14 | Teams []*Team `json:"teams"` 15 | Preferences Preferences `json:"preferences"` 16 | ClientCfg map[string]string `json:"client_cfg"` 17 | LicenseCfg map[string]string `json:"license_cfg"` 18 | NoAccounts bool `json:"no_accounts"` 19 | } 20 | 21 | func (me *InitialLoad) ToJson() string { 22 | b, _ := json.Marshal(me) 23 | return string(b) 24 | } 25 | 26 | func InitialLoadFromJson(data io.Reader) *InitialLoad { 27 | var o *InitialLoad 28 | json.NewDecoder(data).Decode(&o) 29 | return o 30 | } 31 | -------------------------------------------------------------------------------- /vendor/github.com/mattermost/mattermost-server/model/ldap.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved. 2 | // See License.txt for license information. 3 | 4 | package model 5 | 6 | const ( 7 | USER_AUTH_SERVICE_LDAP = "ldap" 8 | ) 9 | -------------------------------------------------------------------------------- /vendor/github.com/mattermost/mattermost-server/model/message_export.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2017-present Mattermost, Inc. All Rights Reserved. 2 | // See License.txt for license information. 3 | 4 | package model 5 | 6 | type MessageExport struct { 7 | TeamId *string 8 | TeamName *string 9 | TeamDisplayName *string 10 | 11 | ChannelId *string 12 | ChannelName *string 13 | ChannelDisplayName *string 14 | ChannelType *string 15 | 16 | UserId *string 17 | UserEmail *string 18 | Username *string 19 | 20 | PostId *string 21 | PostCreateAt *int64 22 | PostMessage *string 23 | PostType *string 24 | PostRootId *string 25 | PostOriginalId *string 26 | PostFileIds StringArray 27 | } 28 | -------------------------------------------------------------------------------- /vendor/github.com/mattermost/mattermost-server/model/mfa_secret.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2017-present Mattermost, Inc. All Rights Reserved. 2 | // See License.txt for license information. 3 | 4 | package model 5 | 6 | import ( 7 | "encoding/json" 8 | "io" 9 | ) 10 | 11 | type MfaSecret struct { 12 | Secret string `json:"secret"` 13 | QRCode string `json:"qr_code"` 14 | } 15 | 16 | func (me *MfaSecret) ToJson() string { 17 | b, _ := json.Marshal(me) 18 | return string(b) 19 | } 20 | 21 | func MfaSecretFromJson(data io.Reader) *MfaSecret { 22 | var me *MfaSecret 23 | json.NewDecoder(data).Decode(&me) 24 | return me 25 | } 26 | -------------------------------------------------------------------------------- /vendor/github.com/mattermost/mattermost-server/model/migration.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2018-present Mattermost, Inc. All Rights Reserved. 2 | // See License.txt for license information. 3 | 4 | package model 5 | 6 | const ( 7 | MIGRATION_KEY_ADVANCED_PERMISSIONS_PHASE_2 = "migration_advanced_permissions_phase_2" 8 | ) 9 | -------------------------------------------------------------------------------- /vendor/github.com/mattermost/mattermost-server/model/plugin_key_value.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2017-present Mattermost, Inc. All Rights Reserved. 2 | // See License.txt for license information. 3 | 4 | package model 5 | 6 | import ( 7 | "net/http" 8 | "unicode/utf8" 9 | ) 10 | 11 | const ( 12 | KEY_VALUE_PLUGIN_ID_MAX_RUNES = 190 13 | KEY_VALUE_KEY_MAX_RUNES = 50 14 | ) 15 | 16 | type PluginKeyValue struct { 17 | PluginId string `json:"plugin_id"` 18 | Key string `json:"key" db:"PKey"` 19 | Value []byte `json:"value" db:"PValue"` 20 | } 21 | 22 | func (kv *PluginKeyValue) IsValid() *AppError { 23 | if len(kv.PluginId) == 0 || utf8.RuneCountInString(kv.PluginId) > KEY_VALUE_PLUGIN_ID_MAX_RUNES { 24 | return NewAppError("PluginKeyValue.IsValid", "model.plugin_key_value.is_valid.plugin_id.app_error", map[string]interface{}{"Max": KEY_VALUE_KEY_MAX_RUNES, "Min": 0}, "key="+kv.Key, http.StatusBadRequest) 25 | } 26 | 27 | if len(kv.Key) == 0 || utf8.RuneCountInString(kv.Key) > KEY_VALUE_KEY_MAX_RUNES { 28 | return NewAppError("PluginKeyValue.IsValid", "model.plugin_key_value.is_valid.key.app_error", map[string]interface{}{"Max": KEY_VALUE_KEY_MAX_RUNES, "Min": 0}, "key="+kv.Key, http.StatusBadRequest) 29 | } 30 | 31 | return nil 32 | } 33 | -------------------------------------------------------------------------------- /vendor/github.com/mattermost/mattermost-server/model/plugin_status.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. 2 | // See LICENSE.txt for license information. 3 | 4 | package model 5 | 6 | import ( 7 | "encoding/json" 8 | "io" 9 | ) 10 | 11 | const ( 12 | PluginStateNotRunning = 0 13 | PluginStateStarting = 1 // unused by server 14 | PluginStateRunning = 2 15 | PluginStateFailedToStart = 3 16 | PluginStateFailedToStayRunning = 4 // unused by server 17 | PluginStateStopping = 5 // unused by server 18 | ) 19 | 20 | // PluginStatus provides a cluster-aware view of installed plugins. 21 | type PluginStatus struct { 22 | PluginId string `json:"plugin_id"` 23 | ClusterId string `json:"cluster_id"` 24 | PluginPath string `json:"plugin_path"` 25 | State int `json:"state"` 26 | Name string `json:"name"` 27 | Description string `json:"description"` 28 | Version string `json:"version"` 29 | } 30 | 31 | type PluginStatuses []*PluginStatus 32 | 33 | func (m *PluginStatuses) ToJson() string { 34 | b, _ := json.Marshal(m) 35 | return string(b) 36 | } 37 | 38 | func PluginStatusesFromJson(data io.Reader) PluginStatuses { 39 | var m PluginStatuses 40 | json.NewDecoder(data).Decode(&m) 41 | return m 42 | } 43 | -------------------------------------------------------------------------------- /vendor/github.com/mattermost/mattermost-server/model/plugins_response.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. 2 | // See License.txt for license information. 3 | 4 | package model 5 | 6 | import ( 7 | "encoding/json" 8 | "io" 9 | ) 10 | 11 | type PluginInfo struct { 12 | Manifest 13 | } 14 | 15 | type PluginsResponse struct { 16 | Active []*PluginInfo `json:"active"` 17 | Inactive []*PluginInfo `json:"inactive"` 18 | } 19 | 20 | func (m *PluginsResponse) ToJson() string { 21 | b, _ := json.Marshal(m) 22 | return string(b) 23 | } 24 | 25 | func PluginsResponseFromJson(data io.Reader) *PluginsResponse { 26 | var m *PluginsResponse 27 | json.NewDecoder(data).Decode(&m) 28 | return m 29 | } 30 | -------------------------------------------------------------------------------- /vendor/github.com/mattermost/mattermost-server/model/post_search_results.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. 2 | // See License.txt for license information. 3 | 4 | package model 5 | 6 | import ( 7 | "encoding/json" 8 | "io" 9 | ) 10 | 11 | type PostSearchMatches map[string][]string 12 | 13 | type PostSearchResults struct { 14 | *PostList 15 | Matches PostSearchMatches `json:"matches"` 16 | } 17 | 18 | func MakePostSearchResults(posts *PostList, matches PostSearchMatches) *PostSearchResults { 19 | return &PostSearchResults{ 20 | posts, 21 | matches, 22 | } 23 | } 24 | 25 | func (o *PostSearchResults) ToJson() string { 26 | copy := *o 27 | copy.PostList.StripActionIntegrations() 28 | b, err := json.Marshal(©) 29 | if err != nil { 30 | return "" 31 | } else { 32 | return string(b) 33 | } 34 | } 35 | 36 | func PostSearchResultsFromJson(data io.Reader) *PostSearchResults { 37 | var o *PostSearchResults 38 | json.NewDecoder(data).Decode(&o) 39 | return o 40 | } 41 | -------------------------------------------------------------------------------- /vendor/github.com/mattermost/mattermost-server/model/preferences.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. 2 | // See License.txt for license information. 3 | 4 | package model 5 | 6 | import ( 7 | "encoding/json" 8 | "io" 9 | ) 10 | 11 | type Preferences []Preference 12 | 13 | func (o *Preferences) ToJson() string { 14 | b, _ := json.Marshal(o) 15 | return string(b) 16 | } 17 | 18 | func PreferencesFromJson(data io.Reader) (Preferences, error) { 19 | decoder := json.NewDecoder(data) 20 | var o Preferences 21 | err := decoder.Decode(&o) 22 | if err == nil { 23 | return o, nil 24 | } else { 25 | return nil, err 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /vendor/github.com/mattermost/mattermost-server/model/push_notification.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. 2 | // See License.txt for license information. 3 | 4 | package model 5 | 6 | import ( 7 | "encoding/json" 8 | "io" 9 | "strings" 10 | ) 11 | 12 | const ( 13 | PUSH_NOTIFY_APPLE = "apple" 14 | PUSH_NOTIFY_ANDROID = "android" 15 | PUSH_NOTIFY_APPLE_REACT_NATIVE = "apple_rn" 16 | PUSH_NOTIFY_ANDROID_REACT_NATIVE = "android_rn" 17 | 18 | PUSH_TYPE_MESSAGE = "message" 19 | PUSH_TYPE_CLEAR = "clear" 20 | PUSH_MESSAGE_V2 = "v2" 21 | 22 | // The category is set to handle a set of interactive Actions 23 | // with the push notifications 24 | CATEGORY_CAN_REPLY = "CAN_REPLY" 25 | 26 | MHPNS = "https://push.mattermost.com" 27 | ) 28 | 29 | type PushNotification struct { 30 | Platform string `json:"platform"` 31 | ServerId string `json:"server_id"` 32 | DeviceId string `json:"device_id"` 33 | Category string `json:"category"` 34 | Sound string `json:"sound"` 35 | Message string `json:"message"` 36 | Badge int `json:"badge"` 37 | ContentAvailable int `json:"cont_ava"` 38 | TeamId string `json:"team_id"` 39 | ChannelId string `json:"channel_id"` 40 | PostId string `json:"post_id"` 41 | RootId string `json:"root_id"` 42 | ChannelName string `json:"channel_name"` 43 | Type string `json:"type"` 44 | SenderId string `json:"sender_id"` 45 | OverrideUsername string `json:"override_username"` 46 | OverrideIconUrl string `json:"override_icon_url"` 47 | FromWebhook string `json:"from_webhook"` 48 | Version string `json:"version"` 49 | } 50 | 51 | func (me *PushNotification) ToJson() string { 52 | b, _ := json.Marshal(me) 53 | return string(b) 54 | } 55 | 56 | func (me *PushNotification) SetDeviceIdAndPlatform(deviceId string) { 57 | 58 | index := strings.Index(deviceId, ":") 59 | 60 | if index > -1 { 61 | me.Platform = deviceId[:index] 62 | me.DeviceId = deviceId[index+1:] 63 | } 64 | } 65 | 66 | func PushNotificationFromJson(data io.Reader) *PushNotification { 67 | var me *PushNotification 68 | json.NewDecoder(data).Decode(&me) 69 | return me 70 | } 71 | -------------------------------------------------------------------------------- /vendor/github.com/mattermost/mattermost-server/model/push_response.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. 2 | // See License.txt for license information. 3 | 4 | package model 5 | 6 | import ( 7 | "encoding/json" 8 | "io" 9 | ) 10 | 11 | const ( 12 | PUSH_STATUS = "status" 13 | PUSH_STATUS_OK = "OK" 14 | PUSH_STATUS_FAIL = "FAIL" 15 | PUSH_STATUS_REMOVE = "REMOVE" 16 | PUSH_STATUS_ERROR_MSG = "error" 17 | ) 18 | 19 | type PushResponse map[string]string 20 | 21 | func NewOkPushResponse() PushResponse { 22 | m := make(map[string]string) 23 | m[PUSH_STATUS] = PUSH_STATUS_OK 24 | return m 25 | } 26 | 27 | func NewRemovePushResponse() PushResponse { 28 | m := make(map[string]string) 29 | m[PUSH_STATUS] = PUSH_STATUS_REMOVE 30 | return m 31 | } 32 | 33 | func NewErrorPushResponse(message string) PushResponse { 34 | m := make(map[string]string) 35 | m[PUSH_STATUS] = PUSH_STATUS_FAIL 36 | m[PUSH_STATUS_ERROR_MSG] = message 37 | return m 38 | } 39 | 40 | func (me *PushResponse) ToJson() string { 41 | b, _ := json.Marshal(me) 42 | return string(b) 43 | } 44 | 45 | func PushResponseFromJson(data io.Reader) PushResponse { 46 | decoder := json.NewDecoder(data) 47 | 48 | var objmap PushResponse 49 | if err := decoder.Decode(&objmap); err != nil { 50 | return make(map[string]string) 51 | } else { 52 | return objmap 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /vendor/github.com/mattermost/mattermost-server/model/reaction.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved. 2 | // See License.txt for license information. 3 | 4 | package model 5 | 6 | import ( 7 | "encoding/json" 8 | "io" 9 | "net/http" 10 | "regexp" 11 | ) 12 | 13 | type Reaction struct { 14 | UserId string `json:"user_id"` 15 | PostId string `json:"post_id"` 16 | EmojiName string `json:"emoji_name"` 17 | CreateAt int64 `json:"create_at"` 18 | } 19 | 20 | func (o *Reaction) ToJson() string { 21 | b, _ := json.Marshal(o) 22 | return string(b) 23 | } 24 | 25 | func ReactionFromJson(data io.Reader) *Reaction { 26 | var o Reaction 27 | 28 | if err := json.NewDecoder(data).Decode(&o); err != nil { 29 | return nil 30 | } else { 31 | return &o 32 | } 33 | } 34 | 35 | func ReactionsToJson(o []*Reaction) string { 36 | b, _ := json.Marshal(o) 37 | return string(b) 38 | } 39 | 40 | func ReactionsFromJson(data io.Reader) []*Reaction { 41 | var o []*Reaction 42 | 43 | if err := json.NewDecoder(data).Decode(&o); err != nil { 44 | return nil 45 | } else { 46 | return o 47 | } 48 | } 49 | 50 | func (o *Reaction) IsValid() *AppError { 51 | if len(o.UserId) != 26 { 52 | return NewAppError("Reaction.IsValid", "model.reaction.is_valid.user_id.app_error", nil, "user_id="+o.UserId, http.StatusBadRequest) 53 | } 54 | 55 | if len(o.PostId) != 26 { 56 | return NewAppError("Reaction.IsValid", "model.reaction.is_valid.post_id.app_error", nil, "post_id="+o.PostId, http.StatusBadRequest) 57 | } 58 | 59 | validName := regexp.MustCompile(`^[a-zA-Z0-9\-\+_]+$`) 60 | 61 | if len(o.EmojiName) == 0 || len(o.EmojiName) > EMOJI_NAME_MAX_LENGTH || !validName.MatchString(o.EmojiName) { 62 | return NewAppError("Reaction.IsValid", "model.reaction.is_valid.emoji_name.app_error", nil, "emoji_name="+o.EmojiName, http.StatusBadRequest) 63 | } 64 | 65 | if o.CreateAt == 0 { 66 | return NewAppError("Reaction.IsValid", "model.reaction.is_valid.create_at.app_error", nil, "", http.StatusBadRequest) 67 | } 68 | 69 | return nil 70 | } 71 | 72 | func (o *Reaction) PreSave() { 73 | if o.CreateAt == 0 { 74 | o.CreateAt = GetMillis() 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /vendor/github.com/mattermost/mattermost-server/model/saml.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved. 2 | // See License.txt for license information. 3 | 4 | package model 5 | 6 | import ( 7 | "encoding/json" 8 | "io" 9 | ) 10 | 11 | const ( 12 | USER_AUTH_SERVICE_SAML = "saml" 13 | USER_AUTH_SERVICE_SAML_TEXT = "With SAML" 14 | ) 15 | 16 | type SamlAuthRequest struct { 17 | Base64AuthRequest string 18 | URL string 19 | RelayState string 20 | } 21 | 22 | type SamlCertificateStatus struct { 23 | IdpCertificateFile bool `json:"idp_certificate_file"` 24 | PrivateKeyFile bool `json:"private_key_file"` 25 | PublicCertificateFile bool `json:"public_certificate_file"` 26 | } 27 | 28 | func (s *SamlCertificateStatus) ToJson() string { 29 | b, _ := json.Marshal(s) 30 | return string(b) 31 | } 32 | 33 | func SamlCertificateStatusFromJson(data io.Reader) *SamlCertificateStatus { 34 | var status *SamlCertificateStatus 35 | json.NewDecoder(data).Decode(&status) 36 | return status 37 | } 38 | -------------------------------------------------------------------------------- /vendor/github.com/mattermost/mattermost-server/model/scheduled_task.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved. 2 | // See License.txt for license information. 3 | 4 | package model 5 | 6 | import ( 7 | "fmt" 8 | "time" 9 | ) 10 | 11 | type TaskFunc func() 12 | 13 | type ScheduledTask struct { 14 | Name string `json:"name"` 15 | Interval time.Duration `json:"interval"` 16 | Recurring bool `json:"recurring"` 17 | function func() 18 | cancel chan struct{} 19 | cancelled chan struct{} 20 | } 21 | 22 | func CreateTask(name string, function TaskFunc, timeToExecution time.Duration) *ScheduledTask { 23 | return createTask(name, function, timeToExecution, false) 24 | } 25 | 26 | func CreateRecurringTask(name string, function TaskFunc, interval time.Duration) *ScheduledTask { 27 | return createTask(name, function, interval, true) 28 | } 29 | 30 | func createTask(name string, function TaskFunc, interval time.Duration, recurring bool) *ScheduledTask { 31 | task := &ScheduledTask{ 32 | Name: name, 33 | Interval: interval, 34 | Recurring: recurring, 35 | function: function, 36 | cancel: make(chan struct{}), 37 | cancelled: make(chan struct{}), 38 | } 39 | 40 | go func() { 41 | defer close(task.cancelled) 42 | 43 | ticker := time.NewTicker(interval) 44 | defer func() { 45 | ticker.Stop() 46 | }() 47 | 48 | for { 49 | select { 50 | case <-ticker.C: 51 | function() 52 | case <-task.cancel: 53 | return 54 | } 55 | 56 | if !task.Recurring { 57 | break 58 | } 59 | } 60 | }() 61 | 62 | return task 63 | } 64 | 65 | func (task *ScheduledTask) Cancel() { 66 | close(task.cancel) 67 | <-task.cancelled 68 | } 69 | 70 | func (task *ScheduledTask) String() string { 71 | return fmt.Sprintf( 72 | "%s\nInterval: %s\nRecurring: %t\n", 73 | task.Name, 74 | task.Interval.String(), 75 | task.Recurring, 76 | ) 77 | } 78 | -------------------------------------------------------------------------------- /vendor/github.com/mattermost/mattermost-server/model/security_bulletin.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. 2 | // See License.txt for license information. 3 | 4 | package model 5 | 6 | import ( 7 | "encoding/json" 8 | "io" 9 | ) 10 | 11 | type SecurityBulletin struct { 12 | Id string `json:"id"` 13 | AppliesToVersion string `json:"applies_to_version"` 14 | } 15 | 16 | type SecurityBulletins []SecurityBulletin 17 | 18 | func (me *SecurityBulletin) ToJson() string { 19 | b, _ := json.Marshal(me) 20 | return string(b) 21 | } 22 | 23 | func SecurityBulletinFromJson(data io.Reader) *SecurityBulletin { 24 | var o *SecurityBulletin 25 | json.NewDecoder(data).Decode(&o) 26 | return o 27 | } 28 | 29 | func (me SecurityBulletins) ToJson() string { 30 | if b, err := json.Marshal(me); err != nil { 31 | return "[]" 32 | } else { 33 | return string(b) 34 | } 35 | } 36 | 37 | func SecurityBulletinsFromJson(data io.Reader) SecurityBulletins { 38 | var o SecurityBulletins 39 | json.NewDecoder(data).Decode(&o) 40 | return o 41 | } 42 | -------------------------------------------------------------------------------- /vendor/github.com/mattermost/mattermost-server/model/status.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved. 2 | // See License.txt for license information. 3 | 4 | package model 5 | 6 | import ( 7 | "encoding/json" 8 | "io" 9 | ) 10 | 11 | const ( 12 | STATUS_OUT_OF_OFFICE = "ooo" 13 | STATUS_OFFLINE = "offline" 14 | STATUS_AWAY = "away" 15 | STATUS_DND = "dnd" 16 | STATUS_ONLINE = "online" 17 | STATUS_CACHE_SIZE = SESSION_CACHE_SIZE 18 | STATUS_CHANNEL_TIMEOUT = 20000 // 20 seconds 19 | STATUS_MIN_UPDATE_TIME = 120000 // 2 minutes 20 | ) 21 | 22 | type Status struct { 23 | UserId string `json:"user_id"` 24 | Status string `json:"status"` 25 | Manual bool `json:"manual"` 26 | LastActivityAt int64 `json:"last_activity_at"` 27 | ActiveChannel string `json:"active_channel,omitempty" db:"-"` 28 | } 29 | 30 | func (o *Status) ToJson() string { 31 | tempChannelId := o.ActiveChannel 32 | o.ActiveChannel = "" 33 | b, _ := json.Marshal(o) 34 | o.ActiveChannel = tempChannelId 35 | return string(b) 36 | } 37 | 38 | func (o *Status) ToClusterJson() string { 39 | b, _ := json.Marshal(o) 40 | return string(b) 41 | } 42 | 43 | func StatusFromJson(data io.Reader) *Status { 44 | var o *Status 45 | json.NewDecoder(data).Decode(&o) 46 | return o 47 | } 48 | 49 | func StatusListToJson(u []*Status) string { 50 | activeChannels := make([]string, len(u)) 51 | for index, s := range u { 52 | activeChannels[index] = s.ActiveChannel 53 | s.ActiveChannel = "" 54 | } 55 | 56 | b, _ := json.Marshal(u) 57 | 58 | for index, s := range u { 59 | s.ActiveChannel = activeChannels[index] 60 | } 61 | 62 | return string(b) 63 | } 64 | 65 | func StatusListFromJson(data io.Reader) []*Status { 66 | var statuses []*Status 67 | json.NewDecoder(data).Decode(&statuses) 68 | return statuses 69 | } 70 | 71 | func StatusMapToInterfaceMap(statusMap map[string]*Status) map[string]interface{} { 72 | interfaceMap := map[string]interface{}{} 73 | for _, s := range statusMap { 74 | // Omitted statues mean offline 75 | if s.Status != STATUS_OFFLINE { 76 | interfaceMap[s.UserId] = s.Status 77 | } 78 | } 79 | return interfaceMap 80 | } 81 | -------------------------------------------------------------------------------- /vendor/github.com/mattermost/mattermost-server/model/suggest_command.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. 2 | // See License.txt for license information. 3 | 4 | package model 5 | 6 | import ( 7 | "encoding/json" 8 | "io" 9 | ) 10 | 11 | type SuggestCommand struct { 12 | Suggestion string `json:"suggestion"` 13 | Description string `json:"description"` 14 | } 15 | 16 | func (o *SuggestCommand) ToJson() string { 17 | b, _ := json.Marshal(o) 18 | return string(b) 19 | } 20 | 21 | func SuggestCommandFromJson(data io.Reader) *SuggestCommand { 22 | var o *SuggestCommand 23 | json.NewDecoder(data).Decode(&o) 24 | return o 25 | } 26 | -------------------------------------------------------------------------------- /vendor/github.com/mattermost/mattermost-server/model/switch_request.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2017-present Mattermost, Inc. All Rights Reserved. 2 | // See License.txt for license information. 3 | 4 | package model 5 | 6 | import ( 7 | "encoding/json" 8 | "io" 9 | ) 10 | 11 | type SwitchRequest struct { 12 | CurrentService string `json:"current_service"` 13 | NewService string `json:"new_service"` 14 | Email string `json:"email"` 15 | Password string `json:"password"` 16 | NewPassword string `json:"new_password"` 17 | MfaCode string `json:"mfa_code"` 18 | LdapLoginId string `json:"ldap_id"` 19 | } 20 | 21 | func (o *SwitchRequest) ToJson() string { 22 | b, _ := json.Marshal(o) 23 | return string(b) 24 | } 25 | 26 | func SwitchRequestFromJson(data io.Reader) *SwitchRequest { 27 | var o *SwitchRequest 28 | json.NewDecoder(data).Decode(&o) 29 | return o 30 | } 31 | 32 | func (o *SwitchRequest) EmailToOAuth() bool { 33 | return o.CurrentService == USER_AUTH_SERVICE_EMAIL && 34 | (o.NewService == USER_AUTH_SERVICE_SAML || 35 | o.NewService == USER_AUTH_SERVICE_GITLAB || 36 | o.NewService == SERVICE_GOOGLE || 37 | o.NewService == SERVICE_OFFICE365) 38 | } 39 | 40 | func (o *SwitchRequest) OAuthToEmail() bool { 41 | return (o.CurrentService == USER_AUTH_SERVICE_SAML || 42 | o.CurrentService == USER_AUTH_SERVICE_GITLAB || 43 | o.CurrentService == SERVICE_GOOGLE || 44 | o.CurrentService == SERVICE_OFFICE365) && o.NewService == USER_AUTH_SERVICE_EMAIL 45 | } 46 | 47 | func (o *SwitchRequest) EmailToLdap() bool { 48 | return o.CurrentService == USER_AUTH_SERVICE_EMAIL && o.NewService == USER_AUTH_SERVICE_LDAP 49 | } 50 | 51 | func (o *SwitchRequest) LdapToEmail() bool { 52 | return o.CurrentService == USER_AUTH_SERVICE_LDAP && o.NewService == USER_AUTH_SERVICE_EMAIL 53 | } 54 | -------------------------------------------------------------------------------- /vendor/github.com/mattermost/mattermost-server/model/system.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. 2 | // See License.txt for license information. 3 | 4 | package model 5 | 6 | import ( 7 | "encoding/json" 8 | "io" 9 | "math/big" 10 | ) 11 | 12 | const ( 13 | SYSTEM_DIAGNOSTIC_ID = "DiagnosticId" 14 | SYSTEM_RAN_UNIT_TESTS = "RanUnitTests" 15 | SYSTEM_LAST_SECURITY_TIME = "LastSecurityTime" 16 | SYSTEM_ACTIVE_LICENSE_ID = "ActiveLicenseId" 17 | SYSTEM_LAST_COMPLIANCE_TIME = "LastComplianceTime" 18 | SYSTEM_ASYMMETRIC_SIGNING_KEY = "AsymmetricSigningKey" 19 | SYSTEM_INSTALLATION_DATE_KEY = "InstallationDate" 20 | ) 21 | 22 | type System struct { 23 | Name string `json:"name"` 24 | Value string `json:"value"` 25 | } 26 | 27 | func (o *System) ToJson() string { 28 | b, _ := json.Marshal(o) 29 | return string(b) 30 | } 31 | 32 | func SystemFromJson(data io.Reader) *System { 33 | var o *System 34 | json.NewDecoder(data).Decode(&o) 35 | return o 36 | } 37 | 38 | type SystemAsymmetricSigningKey struct { 39 | ECDSAKey *SystemECDSAKey `json:"ecdsa_key,omitempty"` 40 | } 41 | 42 | type SystemECDSAKey struct { 43 | Curve string `json:"curve"` 44 | X *big.Int `json:"x"` 45 | Y *big.Int `json:"y"` 46 | D *big.Int `json:"d,omitempty"` 47 | } 48 | -------------------------------------------------------------------------------- /vendor/github.com/mattermost/mattermost-server/model/team_search.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved. 2 | // See License.txt for license information. 3 | 4 | package model 5 | 6 | import ( 7 | "encoding/json" 8 | "io" 9 | ) 10 | 11 | type TeamSearch struct { 12 | Term string `json:"term"` 13 | } 14 | 15 | // ToJson convert a TeamSearch to json string 16 | func (c *TeamSearch) ToJson() string { 17 | b, err := json.Marshal(c) 18 | if err != nil { 19 | return "" 20 | } 21 | 22 | return string(b) 23 | } 24 | 25 | // TeamSearchFromJson decodes the input and returns a TeamSearch 26 | func TeamSearchFromJson(data io.Reader) *TeamSearch { 27 | decoder := json.NewDecoder(data) 28 | var cs TeamSearch 29 | err := decoder.Decode(&cs) 30 | if err == nil { 31 | return &cs 32 | } 33 | 34 | return nil 35 | } 36 | -------------------------------------------------------------------------------- /vendor/github.com/mattermost/mattermost-server/model/team_stats.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved. 2 | // See License.txt for license information. 3 | 4 | package model 5 | 6 | import ( 7 | "encoding/json" 8 | "io" 9 | ) 10 | 11 | type TeamStats struct { 12 | TeamId string `json:"team_id"` 13 | TotalMemberCount int64 `json:"total_member_count"` 14 | ActiveMemberCount int64 `json:"active_member_count"` 15 | } 16 | 17 | func (o *TeamStats) ToJson() string { 18 | b, _ := json.Marshal(o) 19 | return string(b) 20 | } 21 | 22 | func TeamStatsFromJson(data io.Reader) *TeamStats { 23 | var o *TeamStats 24 | json.NewDecoder(data).Decode(&o) 25 | return o 26 | } 27 | -------------------------------------------------------------------------------- /vendor/github.com/mattermost/mattermost-server/model/terms_of_service.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. 2 | // See License.txt for license information. 3 | 4 | package model 5 | 6 | import ( 7 | "encoding/json" 8 | "fmt" 9 | "io" 10 | "net/http" 11 | "unicode/utf8" 12 | ) 13 | 14 | // we only ever need the latest version of terms of service 15 | const TERMS_OF_SERVICE_CACHE_SIZE = 1 16 | 17 | type TermsOfService struct { 18 | Id string `json:"id"` 19 | CreateAt int64 `json:"create_at"` 20 | UserId string `json:"user_id"` 21 | Text string `json:"text"` 22 | } 23 | 24 | func (t *TermsOfService) IsValid() *AppError { 25 | if len(t.Id) != 26 { 26 | return InvalidTermsOfServiceError("id", "") 27 | } 28 | 29 | if t.CreateAt == 0 { 30 | return InvalidTermsOfServiceError("create_at", t.Id) 31 | } 32 | 33 | if len(t.UserId) != 26 { 34 | return InvalidTermsOfServiceError("user_id", t.Id) 35 | } 36 | 37 | if utf8.RuneCountInString(t.Text) > POST_MESSAGE_MAX_RUNES_V2 { 38 | return InvalidTermsOfServiceError("text", t.Id) 39 | } 40 | 41 | return nil 42 | } 43 | 44 | func (t *TermsOfService) ToJson() string { 45 | b, _ := json.Marshal(t) 46 | return string(b) 47 | } 48 | 49 | func TermsOfServiceFromJson(data io.Reader) *TermsOfService { 50 | var termsOfService *TermsOfService 51 | json.NewDecoder(data).Decode(&termsOfService) 52 | return termsOfService 53 | } 54 | 55 | func InvalidTermsOfServiceError(fieldName string, termsOfServiceId string) *AppError { 56 | id := fmt.Sprintf("model.terms_of_service.is_valid.%s.app_error", fieldName) 57 | details := "" 58 | if termsOfServiceId != "" { 59 | details = "terms_of_service_id=" + termsOfServiceId 60 | } 61 | return NewAppError("TermsOfServiceStore.IsValid", id, map[string]interface{}{"MaxLength": POST_MESSAGE_MAX_RUNES_V2}, details, http.StatusBadRequest) 62 | } 63 | 64 | func (t *TermsOfService) PreSave() { 65 | if t.Id == "" { 66 | t.Id = NewId() 67 | } 68 | 69 | t.CreateAt = GetMillis() 70 | } 71 | -------------------------------------------------------------------------------- /vendor/github.com/mattermost/mattermost-server/model/token.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2017-present Mattermost, Inc. All Rights Reserved. 2 | // See License.txt for license information. 3 | 4 | package model 5 | 6 | import "net/http" 7 | 8 | const ( 9 | TOKEN_SIZE = 64 10 | MAX_TOKEN_EXIPRY_TIME = 1000 * 60 * 60 * 24 // 24 hour 11 | TOKEN_TYPE_OAUTH = "oauth" 12 | ) 13 | 14 | type Token struct { 15 | Token string 16 | CreateAt int64 17 | Type string 18 | Extra string 19 | } 20 | 21 | func NewToken(tokentype, extra string) *Token { 22 | return &Token{ 23 | Token: NewRandomString(TOKEN_SIZE), 24 | CreateAt: GetMillis(), 25 | Type: tokentype, 26 | Extra: extra, 27 | } 28 | } 29 | 30 | func (t *Token) IsValid() *AppError { 31 | if len(t.Token) != TOKEN_SIZE { 32 | return NewAppError("Token.IsValid", "model.token.is_valid.size", nil, "", http.StatusInternalServerError) 33 | } 34 | 35 | if t.CreateAt == 0 { 36 | return NewAppError("Token.IsValid", "model.token.is_valid.expiry", nil, "", http.StatusInternalServerError) 37 | } 38 | 39 | return nil 40 | } 41 | -------------------------------------------------------------------------------- /vendor/github.com/mattermost/mattermost-server/model/user_access_token.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2017-present Mattermost, Inc. All Rights Reserved. 2 | // See License.txt for license information. 3 | 4 | package model 5 | 6 | import ( 7 | "encoding/json" 8 | "io" 9 | "net/http" 10 | ) 11 | 12 | type UserAccessToken struct { 13 | Id string `json:"id"` 14 | Token string `json:"token,omitempty"` 15 | UserId string `json:"user_id"` 16 | Description string `json:"description"` 17 | IsActive bool `json:"is_active"` 18 | } 19 | 20 | func (t *UserAccessToken) IsValid() *AppError { 21 | if len(t.Id) != 26 { 22 | return NewAppError("UserAccessToken.IsValid", "model.user_access_token.is_valid.id.app_error", nil, "", http.StatusBadRequest) 23 | } 24 | 25 | if len(t.Token) != 26 { 26 | return NewAppError("UserAccessToken.IsValid", "model.user_access_token.is_valid.token.app_error", nil, "", http.StatusBadRequest) 27 | } 28 | 29 | if len(t.UserId) != 26 { 30 | return NewAppError("UserAccessToken.IsValid", "model.user_access_token.is_valid.user_id.app_error", nil, "", http.StatusBadRequest) 31 | } 32 | 33 | if len(t.Description) > 255 { 34 | return NewAppError("UserAccessToken.IsValid", "model.user_access_token.is_valid.description.app_error", nil, "", http.StatusBadRequest) 35 | } 36 | 37 | return nil 38 | } 39 | 40 | func (t *UserAccessToken) PreSave() { 41 | t.Id = NewId() 42 | t.IsActive = true 43 | } 44 | 45 | func (t *UserAccessToken) ToJson() string { 46 | b, _ := json.Marshal(t) 47 | return string(b) 48 | } 49 | 50 | func UserAccessTokenFromJson(data io.Reader) *UserAccessToken { 51 | var t *UserAccessToken 52 | json.NewDecoder(data).Decode(&t) 53 | return t 54 | } 55 | 56 | func UserAccessTokenListToJson(t []*UserAccessToken) string { 57 | b, _ := json.Marshal(t) 58 | return string(b) 59 | } 60 | 61 | func UserAccessTokenListFromJson(data io.Reader) []*UserAccessToken { 62 | var t []*UserAccessToken 63 | json.NewDecoder(data).Decode(&t) 64 | return t 65 | } 66 | -------------------------------------------------------------------------------- /vendor/github.com/mattermost/mattermost-server/model/user_access_token_search.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved. 2 | // See License.txt for license information. 3 | 4 | package model 5 | 6 | import ( 7 | "encoding/json" 8 | "io" 9 | ) 10 | 11 | type UserAccessTokenSearch struct { 12 | Term string `json:"term"` 13 | } 14 | 15 | // ToJson convert a UserAccessTokenSearch to json string 16 | func (c *UserAccessTokenSearch) ToJson() string { 17 | b, err := json.Marshal(c) 18 | if err != nil { 19 | return "" 20 | } 21 | 22 | return string(b) 23 | } 24 | 25 | // UserAccessTokenSearchJson decodes the input and returns a UserAccessTokenSearch 26 | func UserAccessTokenSearchFromJson(data io.Reader) *UserAccessTokenSearch { 27 | decoder := json.NewDecoder(data) 28 | var cs UserAccessTokenSearch 29 | err := decoder.Decode(&cs) 30 | if err == nil { 31 | return &cs 32 | } 33 | 34 | return nil 35 | } 36 | -------------------------------------------------------------------------------- /vendor/github.com/mattermost/mattermost-server/model/user_autocomplete.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved. 2 | // See License.txt for license information. 3 | 4 | package model 5 | 6 | import ( 7 | "encoding/json" 8 | "io" 9 | ) 10 | 11 | type UserAutocompleteInChannel struct { 12 | InChannel []*User `json:"in_channel"` 13 | OutOfChannel []*User `json:"out_of_channel"` 14 | } 15 | 16 | type UserAutocompleteInTeam struct { 17 | InTeam []*User `json:"in_team"` 18 | } 19 | 20 | type UserAutocomplete struct { 21 | Users []*User `json:"users"` 22 | OutOfChannel []*User `json:"out_of_channel,omitempty"` 23 | } 24 | 25 | func (o *UserAutocomplete) ToJson() string { 26 | b, _ := json.Marshal(o) 27 | return string(b) 28 | } 29 | 30 | func UserAutocompleteFromJson(data io.Reader) *UserAutocomplete { 31 | decoder := json.NewDecoder(data) 32 | autocomplete := new(UserAutocomplete) 33 | err := decoder.Decode(&autocomplete) 34 | if err == nil { 35 | return autocomplete 36 | } else { 37 | return nil 38 | } 39 | } 40 | 41 | func (o *UserAutocompleteInChannel) ToJson() string { 42 | b, _ := json.Marshal(o) 43 | return string(b) 44 | } 45 | 46 | func UserAutocompleteInChannelFromJson(data io.Reader) *UserAutocompleteInChannel { 47 | var o *UserAutocompleteInChannel 48 | json.NewDecoder(data).Decode(&o) 49 | return o 50 | } 51 | 52 | func (o *UserAutocompleteInTeam) ToJson() string { 53 | b, _ := json.Marshal(o) 54 | return string(b) 55 | } 56 | 57 | func UserAutocompleteInTeamFromJson(data io.Reader) *UserAutocompleteInTeam { 58 | var o *UserAutocompleteInTeam 59 | json.NewDecoder(data).Decode(&o) 60 | return o 61 | } 62 | -------------------------------------------------------------------------------- /vendor/github.com/mattermost/mattermost-server/model/user_search.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved. 2 | // See License.txt for license information. 3 | 4 | package model 5 | 6 | import ( 7 | "encoding/json" 8 | "io" 9 | ) 10 | 11 | type UserSearch struct { 12 | Term string `json:"term"` 13 | TeamId string `json:"team_id"` 14 | NotInTeamId string `json:"not_in_team_id"` 15 | InChannelId string `json:"in_channel_id"` 16 | NotInChannelId string `json:"not_in_channel_id"` 17 | AllowInactive bool `json:"allow_inactive"` 18 | WithoutTeam bool `json:"without_team"` 19 | } 20 | 21 | // ToJson convert a User to a json string 22 | func (u *UserSearch) ToJson() string { 23 | b, _ := json.Marshal(u) 24 | return string(b) 25 | } 26 | 27 | // UserSearchFromJson will decode the input and return a User 28 | func UserSearchFromJson(data io.Reader) *UserSearch { 29 | var us *UserSearch 30 | json.NewDecoder(data).Decode(&us) 31 | return us 32 | } 33 | -------------------------------------------------------------------------------- /vendor/github.com/mattermost/mattermost-server/model/users_stats.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved. 2 | // See License.txt for license information. 3 | 4 | package model 5 | 6 | import ( 7 | "encoding/json" 8 | "io" 9 | ) 10 | 11 | type UsersStats struct { 12 | TotalUsersCount int64 `json:"total_users_count"` 13 | } 14 | 15 | func (o *UsersStats) ToJson() string { 16 | b, _ := json.Marshal(o) 17 | return string(b) 18 | } 19 | 20 | func UsersStatsFromJson(data io.Reader) *UsersStats { 21 | var o *UsersStats 22 | json.NewDecoder(data).Decode(&o) 23 | return o 24 | } 25 | -------------------------------------------------------------------------------- /vendor/github.com/mattermost/mattermost-server/model/webrtc.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2017 Mattermost, Inc. All Rights Reserved. 2 | // See License.txt for license information. 3 | 4 | package model 5 | 6 | import ( 7 | "encoding/json" 8 | "io" 9 | ) 10 | 11 | type WebrtcInfoResponse struct { 12 | Token string `json:"token"` 13 | GatewayUrl string `json:"gateway_url"` 14 | StunUri string `json:"stun_uri,omitempty"` 15 | TurnUri string `json:"turn_uri,omitempty"` 16 | TurnPassword string `json:"turn_password,omitempty"` 17 | TurnUsername string `json:"turn_username,omitempty"` 18 | } 19 | 20 | type GatewayResponse struct { 21 | Status string `json:"janus"` 22 | } 23 | 24 | func GatewayResponseFromJson(data io.Reader) *GatewayResponse { 25 | var o *GatewayResponse 26 | json.NewDecoder(data).Decode(&o) 27 | return o 28 | } 29 | 30 | func (o *WebrtcInfoResponse) ToJson() string { 31 | b, _ := json.Marshal(o) 32 | return string(b) 33 | } 34 | 35 | func WebrtcInfoResponseFromJson(data io.Reader) *WebrtcInfoResponse { 36 | var o *WebrtcInfoResponse 37 | json.NewDecoder(data).Decode(&o) 38 | return o 39 | } 40 | -------------------------------------------------------------------------------- /vendor/github.com/mattermost/mattermost-server/model/websocket_request.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved. 2 | // See License.txt for license information. 3 | 4 | package model 5 | 6 | import ( 7 | "encoding/json" 8 | "io" 9 | 10 | goi18n "github.com/nicksnyder/go-i18n/i18n" 11 | ) 12 | 13 | type WebSocketRequest struct { 14 | // Client-provided fields 15 | Seq int64 `json:"seq"` 16 | Action string `json:"action"` 17 | Data map[string]interface{} `json:"data"` 18 | 19 | // Server-provided fields 20 | Session Session `json:"-"` 21 | T goi18n.TranslateFunc `json:"-"` 22 | Locale string `json:"-"` 23 | } 24 | 25 | func (o *WebSocketRequest) ToJson() string { 26 | b, _ := json.Marshal(o) 27 | return string(b) 28 | } 29 | 30 | func WebSocketRequestFromJson(data io.Reader) *WebSocketRequest { 31 | var o *WebSocketRequest 32 | json.NewDecoder(data).Decode(&o) 33 | return o 34 | } 35 | -------------------------------------------------------------------------------- /vendor/github.com/mattermost/mattermost-server/scripts/license-check.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -e 3 | IFS=$'\n' 4 | count=0 5 | for fileType in GoFiles; do 6 | for file in `go list -f $'{{range .GoFiles}}{{$.Dir}}/{{.}}\n{{end}}' "$@"`; do 7 | case $file in 8 | */utils/lru.go|*/store/storetest/mocks/*|*/services/*/mocks/*|*/app/plugin/jira/plugin_*|*/plugin/plugintest/*|*/app/plugin/zoom/plugin_*) 9 | # Third-party, doesn't require a header. 10 | ;; 11 | *) 12 | if ! grep 'Mattermost, Inc. All Rights Reserved.' $file -q; then 13 | >&2 echo "FAIL: $file is missing a license header." 14 | ((count++)) 15 | fi 16 | esac 17 | done 18 | done 19 | if [ $count -eq 0 ]; then 20 | exit 0 21 | fi 22 | 23 | if [ $count -gt 1 ]; then 24 | >&2 echo "$count files are missing license headers." 25 | else 26 | >&2 echo "$count file is missing a license header." 27 | fi 28 | exit 1 29 | -------------------------------------------------------------------------------- /vendor/github.com/mattermost/mattermost-server/utils/jsonutils/json.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. 2 | // See License.txt for license information. 3 | 4 | package jsonutils 5 | 6 | import ( 7 | "bytes" 8 | "encoding/json" 9 | 10 | "github.com/pkg/errors" 11 | ) 12 | 13 | type HumanizedJsonError struct { 14 | Err error 15 | Line int 16 | Character int 17 | } 18 | 19 | func (e *HumanizedJsonError) Error() string { 20 | return e.Err.Error() 21 | } 22 | 23 | // HumanizeJsonError extracts error offsets and annotates the error with useful context 24 | func HumanizeJsonError(err error, data []byte) error { 25 | if syntaxError, ok := err.(*json.SyntaxError); ok { 26 | return NewHumanizedJsonError(syntaxError, data, syntaxError.Offset) 27 | } else if unmarshalError, ok := err.(*json.UnmarshalTypeError); ok { 28 | return NewHumanizedJsonError(unmarshalError, data, unmarshalError.Offset) 29 | } else { 30 | return err 31 | } 32 | } 33 | 34 | func NewHumanizedJsonError(err error, data []byte, offset int64) *HumanizedJsonError { 35 | if err == nil { 36 | return nil 37 | } 38 | 39 | if offset < 0 || offset > int64(len(data)) { 40 | return &HumanizedJsonError{ 41 | Err: errors.Wrapf(err, "invalid offset %d", offset), 42 | } 43 | } 44 | 45 | lineSep := []byte{'\n'} 46 | 47 | line := bytes.Count(data[:offset], lineSep) + 1 48 | lastLineOffset := bytes.LastIndex(data[:offset], lineSep) 49 | character := int(offset) - (lastLineOffset + 1) + 1 50 | 51 | return &HumanizedJsonError{ 52 | Line: line, 53 | Character: character, 54 | Err: errors.Wrapf(err, "parsing error at line %d, character %d", line, character), 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /vendor/github.com/mattermost/mattermost-server/utils/markdown/block_quote.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2017-present Mattermost, Inc. All Rights Reserved. 2 | // See License.txt for license information. 3 | 4 | package markdown 5 | 6 | type BlockQuote struct { 7 | blockBase 8 | markdown string 9 | 10 | Children []Block 11 | } 12 | 13 | func (b *BlockQuote) Continuation(indentation int, r Range) *continuation { 14 | if indentation > 3 { 15 | return nil 16 | } 17 | s := b.markdown[r.Position:r.End] 18 | if s == "" || s[0] != '>' { 19 | return nil 20 | } 21 | remaining := Range{r.Position + 1, r.End} 22 | indentation, indentationBytes := countIndentation(b.markdown, remaining) 23 | if indentation > 0 { 24 | indentation-- 25 | } 26 | return &continuation{ 27 | Indentation: indentation, 28 | Remaining: Range{remaining.Position + indentationBytes, remaining.End}, 29 | } 30 | } 31 | 32 | func (b *BlockQuote) AddChild(openBlocks []Block) []Block { 33 | b.Children = append(b.Children, openBlocks[0]) 34 | return openBlocks 35 | } 36 | 37 | func blockQuoteStart(markdown string, indent int, r Range, matchedBlocks, unmatchedBlocks []Block) []Block { 38 | if indent > 3 { 39 | return nil 40 | } 41 | s := markdown[r.Position:r.End] 42 | if s == "" || s[0] != '>' { 43 | return nil 44 | } 45 | 46 | block := &BlockQuote{ 47 | markdown: markdown, 48 | } 49 | r.Position++ 50 | if len(s) > 1 && s[1] == ' ' { 51 | r.Position++ 52 | } 53 | 54 | indent, bytes := countIndentation(markdown, r) 55 | 56 | ret := []Block{block} 57 | if descendants := blockStartOrParagraph(markdown, indent, Range{r.Position + bytes, r.End}, nil, nil); descendants != nil { 58 | block.Children = append(block.Children, descendants[0]) 59 | ret = append(ret, descendants...) 60 | } 61 | return ret 62 | } 63 | -------------------------------------------------------------------------------- /vendor/github.com/mattermost/mattermost-server/utils/markdown/document.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2017-present Mattermost, Inc. All Rights Reserved. 2 | // See License.txt for license information. 3 | 4 | package markdown 5 | 6 | type Document struct { 7 | blockBase 8 | 9 | Children []Block 10 | } 11 | 12 | func (b *Document) Continuation(indentation int, r Range) *continuation { 13 | return &continuation{ 14 | Indentation: indentation, 15 | Remaining: r, 16 | } 17 | } 18 | 19 | func (b *Document) AddChild(openBlocks []Block) []Block { 20 | b.Children = append(b.Children, openBlocks[0]) 21 | return openBlocks 22 | } 23 | -------------------------------------------------------------------------------- /vendor/github.com/mattermost/mattermost-server/utils/markdown/indented_code.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2017-present Mattermost, Inc. All Rights Reserved. 2 | // See License.txt for license information. 3 | 4 | package markdown 5 | 6 | import ( 7 | "strings" 8 | ) 9 | 10 | type IndentedCodeLine struct { 11 | Indentation int 12 | Range Range 13 | } 14 | 15 | type IndentedCode struct { 16 | blockBase 17 | markdown string 18 | 19 | RawCode []IndentedCodeLine 20 | } 21 | 22 | func (b *IndentedCode) Code() (result string) { 23 | for _, code := range b.RawCode { 24 | result += strings.Repeat(" ", code.Indentation) + b.markdown[code.Range.Position:code.Range.End] 25 | } 26 | return 27 | } 28 | 29 | func (b *IndentedCode) Continuation(indentation int, r Range) *continuation { 30 | if indentation >= 4 { 31 | return &continuation{ 32 | Indentation: indentation - 4, 33 | Remaining: r, 34 | } 35 | } 36 | s := b.markdown[r.Position:r.End] 37 | if strings.TrimSpace(s) == "" { 38 | return &continuation{ 39 | Remaining: r, 40 | } 41 | } 42 | return nil 43 | } 44 | 45 | func (b *IndentedCode) AddLine(indentation int, r Range) bool { 46 | b.RawCode = append(b.RawCode, IndentedCodeLine{ 47 | Indentation: indentation, 48 | Range: r, 49 | }) 50 | return true 51 | } 52 | 53 | func (b *IndentedCode) Close() { 54 | for { 55 | last := b.RawCode[len(b.RawCode)-1] 56 | s := b.markdown[last.Range.Position:last.Range.End] 57 | if strings.TrimRight(s, "\r\n") == "" { 58 | b.RawCode = b.RawCode[:len(b.RawCode)-1] 59 | } else { 60 | break 61 | } 62 | } 63 | } 64 | 65 | func (b *IndentedCode) AllowsBlockStarts() bool { 66 | return false 67 | } 68 | 69 | func indentedCodeStart(markdown string, indentation int, r Range, matchedBlocks, unmatchedBlocks []Block) []Block { 70 | if len(unmatchedBlocks) > 0 { 71 | if _, ok := unmatchedBlocks[len(unmatchedBlocks)-1].(*Paragraph); ok { 72 | return nil 73 | } 74 | } else if len(matchedBlocks) > 0 { 75 | if _, ok := matchedBlocks[len(matchedBlocks)-1].(*Paragraph); ok { 76 | return nil 77 | } 78 | } 79 | 80 | if indentation < 4 { 81 | return nil 82 | } 83 | 84 | s := markdown[r.Position:r.End] 85 | if strings.TrimSpace(s) == "" { 86 | return nil 87 | } 88 | 89 | return []Block{ 90 | &IndentedCode{ 91 | markdown: markdown, 92 | RawCode: []IndentedCodeLine{{ 93 | Indentation: indentation - 4, 94 | Range: r, 95 | }}, 96 | }, 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /vendor/github.com/mattermost/mattermost-server/utils/markdown/inspect.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2017-present Mattermost, Inc. All Rights Reserved. 2 | // See License.txt for license information. 3 | 4 | package markdown 5 | 6 | // Inspect traverses the markdown tree in depth-first order. If f returns true, Inspect invokes f 7 | // recursively for each child of the block or inline, followed by a call of f(nil). 8 | func Inspect(markdown string, f func(interface{}) bool) { 9 | document, referenceDefinitions := Parse(markdown) 10 | InspectBlock(document, func(block Block) bool { 11 | if !f(block) { 12 | return false 13 | } 14 | switch v := block.(type) { 15 | case *Paragraph: 16 | for _, inline := range MergeInlineText(v.ParseInlines(referenceDefinitions)) { 17 | InspectInline(inline, func(inline Inline) bool { 18 | return f(inline) 19 | }) 20 | } 21 | } 22 | return true 23 | }) 24 | } 25 | 26 | // InspectBlock traverses the blocks in depth-first order, starting with block. If f returns true, 27 | // InspectBlock invokes f recursively for each child of the block, followed by a call of f(nil). 28 | func InspectBlock(block Block, f func(Block) bool) { 29 | if !f(block) { 30 | return 31 | } 32 | switch v := block.(type) { 33 | case *Document: 34 | for _, child := range v.Children { 35 | InspectBlock(child, f) 36 | } 37 | case *List: 38 | for _, child := range v.Children { 39 | InspectBlock(child, f) 40 | } 41 | case *ListItem: 42 | for _, child := range v.Children { 43 | InspectBlock(child, f) 44 | } 45 | case *BlockQuote: 46 | for _, child := range v.Children { 47 | InspectBlock(child, f) 48 | } 49 | } 50 | f(nil) 51 | } 52 | 53 | // InspectInline traverses the blocks in depth-first order, starting with block. If f returns true, 54 | // InspectInline invokes f recursively for each child of the block, followed by a call of f(nil). 55 | func InspectInline(inline Inline, f func(Inline) bool) { 56 | if !f(inline) { 57 | return 58 | } 59 | switch v := inline.(type) { 60 | case *InlineImage: 61 | for _, child := range v.Children { 62 | InspectInline(child, f) 63 | } 64 | case *InlineLink: 65 | for _, child := range v.Children { 66 | InspectInline(child, f) 67 | } 68 | case *ReferenceImage: 69 | for _, child := range v.Children { 70 | InspectInline(child, f) 71 | } 72 | case *ReferenceLink: 73 | for _, child := range v.Children { 74 | InspectInline(child, f) 75 | } 76 | } 77 | f(nil) 78 | } 79 | -------------------------------------------------------------------------------- /vendor/github.com/mattermost/mattermost-server/utils/markdown/lines.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2017-present Mattermost, Inc. All Rights Reserved. 2 | // See License.txt for license information. 3 | 4 | package markdown 5 | 6 | type Line struct { 7 | Range 8 | } 9 | 10 | func ParseLines(markdown string) (lines []Line) { 11 | lineStartPosition := 0 12 | isAfterCarriageReturn := false 13 | for position, r := range markdown { 14 | if r == '\n' { 15 | lines = append(lines, Line{Range{lineStartPosition, position + 1}}) 16 | lineStartPosition = position + 1 17 | } else if isAfterCarriageReturn { 18 | lines = append(lines, Line{Range{lineStartPosition, position}}) 19 | lineStartPosition = position 20 | } 21 | isAfterCarriageReturn = r == '\r' 22 | } 23 | if lineStartPosition < len(markdown) { 24 | lines = append(lines, Line{Range{lineStartPosition, len(markdown)}}) 25 | } 26 | return 27 | } 28 | -------------------------------------------------------------------------------- /vendor/github.com/mattermost/mattermost-server/utils/markdown/paragraph.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2017-present Mattermost, Inc. All Rights Reserved. 2 | // See License.txt for license information. 3 | 4 | package markdown 5 | 6 | import ( 7 | "strings" 8 | ) 9 | 10 | type Paragraph struct { 11 | blockBase 12 | markdown string 13 | 14 | Text []Range 15 | ReferenceDefinitions []*ReferenceDefinition 16 | } 17 | 18 | func (b *Paragraph) ParseInlines(referenceDefinitions []*ReferenceDefinition) []Inline { 19 | return ParseInlines(b.markdown, b.Text, referenceDefinitions) 20 | } 21 | 22 | func (b *Paragraph) Continuation(indentation int, r Range) *continuation { 23 | s := b.markdown[r.Position:r.End] 24 | if strings.TrimSpace(s) == "" { 25 | return nil 26 | } 27 | return &continuation{ 28 | Indentation: indentation, 29 | Remaining: r, 30 | } 31 | } 32 | 33 | func (b *Paragraph) Close() { 34 | for { 35 | for i := 0; i < len(b.Text); i++ { 36 | b.Text[i] = trimLeftSpace(b.markdown, b.Text[i]) 37 | if b.Text[i].Position < b.Text[i].End { 38 | break 39 | } 40 | } 41 | 42 | if len(b.Text) == 0 || b.Text[0].Position < b.Text[0].End && b.markdown[b.Text[0].Position] != '[' { 43 | break 44 | } 45 | 46 | definition, remaining := parseReferenceDefinition(b.markdown, b.Text) 47 | if definition == nil { 48 | break 49 | } 50 | b.ReferenceDefinitions = append(b.ReferenceDefinitions, definition) 51 | b.Text = remaining 52 | } 53 | 54 | for i := len(b.Text) - 1; i >= 0; i-- { 55 | b.Text[i] = trimRightSpace(b.markdown, b.Text[i]) 56 | if b.Text[i].Position < b.Text[i].End { 57 | break 58 | } 59 | } 60 | } 61 | 62 | func newParagraph(markdown string, r Range) *Paragraph { 63 | s := markdown[r.Position:r.End] 64 | if strings.TrimSpace(s) == "" { 65 | return nil 66 | } 67 | return &Paragraph{ 68 | markdown: markdown, 69 | Text: []Range{r}, 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /vendor/github.com/mattermost/mattermost-server/utils/markdown/reference_definition.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2017-present Mattermost, Inc. All Rights Reserved. 2 | // See License.txt for license information. 3 | 4 | package markdown 5 | 6 | type ReferenceDefinition struct { 7 | RawDestination Range 8 | 9 | markdown string 10 | rawLabel string 11 | rawTitle string 12 | } 13 | 14 | func (d *ReferenceDefinition) Destination() string { 15 | return Unescape(d.markdown[d.RawDestination.Position:d.RawDestination.End]) 16 | } 17 | 18 | func (d *ReferenceDefinition) Label() string { 19 | return d.rawLabel 20 | } 21 | 22 | func (d *ReferenceDefinition) Title() string { 23 | return Unescape(d.rawTitle) 24 | } 25 | 26 | func parseReferenceDefinition(markdown string, ranges []Range) (*ReferenceDefinition, []Range) { 27 | raw := "" 28 | for _, r := range ranges { 29 | raw += markdown[r.Position:r.End] 30 | } 31 | 32 | label, next, ok := parseLinkLabel(raw, 0) 33 | if !ok { 34 | return nil, nil 35 | } 36 | position := next 37 | 38 | if position >= len(raw) || raw[position] != ':' { 39 | return nil, nil 40 | } 41 | position++ 42 | 43 | destination, next, ok := parseLinkDestination(raw, nextNonWhitespace(raw, position)) 44 | if !ok { 45 | return nil, nil 46 | } 47 | position = next 48 | 49 | absoluteDestination := relativeToAbsolutePosition(ranges, destination.Position) 50 | ret := &ReferenceDefinition{ 51 | RawDestination: Range{absoluteDestination, absoluteDestination + destination.End - destination.Position}, 52 | markdown: markdown, 53 | rawLabel: raw[label.Position:label.End], 54 | } 55 | 56 | if position < len(raw) && isWhitespaceByte(raw[position]) { 57 | title, next, ok := parseLinkTitle(raw, nextNonWhitespace(raw, position)) 58 | if !ok { 59 | if nextLine, skippedNonWhitespace := nextLine(raw, position); !skippedNonWhitespace { 60 | return ret, trimBytesFromRanges(ranges, nextLine) 61 | } 62 | return nil, nil 63 | } 64 | if nextLine, skippedNonWhitespace := nextLine(raw, next); !skippedNonWhitespace { 65 | ret.rawTitle = raw[title.Position:title.End] 66 | return ret, trimBytesFromRanges(ranges, nextLine) 67 | } 68 | } 69 | 70 | if nextLine, skippedNonWhitespace := nextLine(raw, position); !skippedNonWhitespace { 71 | return ret, trimBytesFromRanges(ranges, nextLine) 72 | } 73 | 74 | return nil, nil 75 | } 76 | -------------------------------------------------------------------------------- /vendor/github.com/nicksnyder/go-i18n/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2014 Nick Snyder https://github.com/nicksnyder 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. 20 | -------------------------------------------------------------------------------- /vendor/github.com/nicksnyder/go-i18n/i18n/language/plural.go: -------------------------------------------------------------------------------- 1 | package language 2 | 3 | import ( 4 | "fmt" 5 | ) 6 | 7 | // Plural represents a language pluralization form as defined here: 8 | // http://cldr.unicode.org/index/cldr-spec/plural-rules 9 | type Plural string 10 | 11 | // All defined plural categories. 12 | const ( 13 | Invalid Plural = "invalid" 14 | Zero = "zero" 15 | One = "one" 16 | Two = "two" 17 | Few = "few" 18 | Many = "many" 19 | Other = "other" 20 | ) 21 | 22 | // NewPlural returns src as a Plural 23 | // or Invalid and a non-nil error if src is not a valid Plural. 24 | func NewPlural(src string) (Plural, error) { 25 | switch src { 26 | case "zero": 27 | return Zero, nil 28 | case "one": 29 | return One, nil 30 | case "two": 31 | return Two, nil 32 | case "few": 33 | return Few, nil 34 | case "many": 35 | return Many, nil 36 | case "other": 37 | return Other, nil 38 | } 39 | return Invalid, fmt.Errorf("invalid plural category %s", src) 40 | } 41 | -------------------------------------------------------------------------------- /vendor/github.com/nicksnyder/go-i18n/i18n/language/pluralspec.go: -------------------------------------------------------------------------------- 1 | package language 2 | 3 | import "strings" 4 | 5 | // PluralSpec defines the CLDR plural rules for a language. 6 | // http://www.unicode.org/cldr/charts/latest/supplemental/language_plural_rules.html 7 | // http://unicode.org/reports/tr35/tr35-numbers.html#Operands 8 | type PluralSpec struct { 9 | Plurals map[Plural]struct{} 10 | PluralFunc func(*Operands) Plural 11 | } 12 | 13 | var pluralSpecs = make(map[string]*PluralSpec) 14 | 15 | func normalizePluralSpecID(id string) string { 16 | id = strings.Replace(id, "_", "-", -1) 17 | id = strings.ToLower(id) 18 | return id 19 | } 20 | 21 | // RegisterPluralSpec registers a new plural spec for the language ids. 22 | func RegisterPluralSpec(ids []string, ps *PluralSpec) { 23 | for _, id := range ids { 24 | id = normalizePluralSpecID(id) 25 | pluralSpecs[id] = ps 26 | } 27 | } 28 | 29 | // Plural returns the plural category for number as defined by 30 | // the language's CLDR plural rules. 31 | func (ps *PluralSpec) Plural(number interface{}) (Plural, error) { 32 | ops, err := newOperands(number) 33 | if err != nil { 34 | return Invalid, err 35 | } 36 | return ps.PluralFunc(ops), nil 37 | } 38 | 39 | // GetPluralSpec returns the PluralSpec that matches the longest prefix of tag. 40 | // It returns nil if no PluralSpec matches tag. 41 | func GetPluralSpec(tag string) *PluralSpec { 42 | tag = NormalizeTag(tag) 43 | subtag := tag 44 | for { 45 | if spec := pluralSpecs[subtag]; spec != nil { 46 | return spec 47 | } 48 | end := strings.LastIndex(subtag, "-") 49 | if end == -1 { 50 | return nil 51 | } 52 | subtag = subtag[:end] 53 | } 54 | } 55 | 56 | func newPluralSet(plurals ...Plural) map[Plural]struct{} { 57 | set := make(map[Plural]struct{}, len(plurals)) 58 | for _, plural := range plurals { 59 | set[plural] = struct{}{} 60 | } 61 | return set 62 | } 63 | 64 | func intInRange(i, from, to int64) bool { 65 | return from <= i && i <= to 66 | } 67 | 68 | func intEqualsAny(i int64, any ...int64) bool { 69 | for _, a := range any { 70 | if i == a { 71 | return true 72 | } 73 | } 74 | return false 75 | } 76 | -------------------------------------------------------------------------------- /vendor/github.com/nicksnyder/go-i18n/i18n/translation/plural_translation.go: -------------------------------------------------------------------------------- 1 | package translation 2 | 3 | import ( 4 | "github.com/nicksnyder/go-i18n/i18n/language" 5 | ) 6 | 7 | type pluralTranslation struct { 8 | id string 9 | templates map[language.Plural]*template 10 | } 11 | 12 | func (pt *pluralTranslation) MarshalInterface() interface{} { 13 | return map[string]interface{}{ 14 | "id": pt.id, 15 | "translation": pt.templates, 16 | } 17 | } 18 | 19 | func (pt *pluralTranslation) MarshalFlatInterface() interface{} { 20 | return pt.templates 21 | } 22 | 23 | func (pt *pluralTranslation) ID() string { 24 | return pt.id 25 | } 26 | 27 | func (pt *pluralTranslation) Template(pc language.Plural) *template { 28 | return pt.templates[pc] 29 | } 30 | 31 | func (pt *pluralTranslation) UntranslatedCopy() Translation { 32 | return &pluralTranslation{pt.id, make(map[language.Plural]*template)} 33 | } 34 | 35 | func (pt *pluralTranslation) Normalize(l *language.Language) Translation { 36 | // Delete plural categories that don't belong to this language. 37 | for pc := range pt.templates { 38 | if _, ok := l.Plurals[pc]; !ok { 39 | delete(pt.templates, pc) 40 | } 41 | } 42 | // Create map entries for missing valid categories. 43 | for pc := range l.Plurals { 44 | if _, ok := pt.templates[pc]; !ok { 45 | pt.templates[pc] = mustNewTemplate("") 46 | } 47 | } 48 | return pt 49 | } 50 | 51 | func (pt *pluralTranslation) Backfill(src Translation) Translation { 52 | for pc, t := range pt.templates { 53 | if (t == nil || t.src == "") && src != nil { 54 | pt.templates[pc] = src.Template(language.Other) 55 | } 56 | } 57 | return pt 58 | } 59 | 60 | func (pt *pluralTranslation) Merge(t Translation) Translation { 61 | other, ok := t.(*pluralTranslation) 62 | if !ok || pt.ID() != t.ID() { 63 | return t 64 | } 65 | for pluralCategory, template := range other.templates { 66 | if template != nil && template.src != "" { 67 | pt.templates[pluralCategory] = template 68 | } 69 | } 70 | return pt 71 | } 72 | 73 | func (pt *pluralTranslation) Incomplete(l *language.Language) bool { 74 | for pc := range l.Plurals { 75 | if t := pt.templates[pc]; t == nil || t.src == "" { 76 | return true 77 | } 78 | } 79 | return false 80 | } 81 | 82 | var _ = Translation(&pluralTranslation{}) 83 | -------------------------------------------------------------------------------- /vendor/github.com/nicksnyder/go-i18n/i18n/translation/single_translation.go: -------------------------------------------------------------------------------- 1 | package translation 2 | 3 | import ( 4 | "github.com/nicksnyder/go-i18n/i18n/language" 5 | ) 6 | 7 | type singleTranslation struct { 8 | id string 9 | template *template 10 | } 11 | 12 | func (st *singleTranslation) MarshalInterface() interface{} { 13 | return map[string]interface{}{ 14 | "id": st.id, 15 | "translation": st.template, 16 | } 17 | } 18 | 19 | func (st *singleTranslation) MarshalFlatInterface() interface{} { 20 | return map[string]interface{}{"other": st.template} 21 | } 22 | 23 | func (st *singleTranslation) ID() string { 24 | return st.id 25 | } 26 | 27 | func (st *singleTranslation) Template(pc language.Plural) *template { 28 | return st.template 29 | } 30 | 31 | func (st *singleTranslation) UntranslatedCopy() Translation { 32 | return &singleTranslation{st.id, mustNewTemplate("")} 33 | } 34 | 35 | func (st *singleTranslation) Normalize(language *language.Language) Translation { 36 | return st 37 | } 38 | 39 | func (st *singleTranslation) Backfill(src Translation) Translation { 40 | if (st.template == nil || st.template.src == "") && src != nil { 41 | st.template = src.Template(language.Other) 42 | } 43 | return st 44 | } 45 | 46 | func (st *singleTranslation) Merge(t Translation) Translation { 47 | other, ok := t.(*singleTranslation) 48 | if !ok || st.ID() != t.ID() { 49 | return t 50 | } 51 | if other.template != nil && other.template.src != "" { 52 | st.template = other.template 53 | } 54 | return st 55 | } 56 | 57 | func (st *singleTranslation) Incomplete(l *language.Language) bool { 58 | return st.template == nil || st.template.src == "" 59 | } 60 | 61 | var _ = Translation(&singleTranslation{}) 62 | -------------------------------------------------------------------------------- /vendor/github.com/nicksnyder/go-i18n/i18n/translation/template.go: -------------------------------------------------------------------------------- 1 | package translation 2 | 3 | import ( 4 | "bytes" 5 | "encoding" 6 | "strings" 7 | gotemplate "text/template" 8 | ) 9 | 10 | type template struct { 11 | tmpl *gotemplate.Template 12 | src string 13 | } 14 | 15 | func newTemplate(src string) (*template, error) { 16 | if src == "" { 17 | return new(template), nil 18 | } 19 | 20 | var tmpl template 21 | err := tmpl.parseTemplate(src) 22 | return &tmpl, err 23 | } 24 | 25 | func mustNewTemplate(src string) *template { 26 | t, err := newTemplate(src) 27 | if err != nil { 28 | panic(err) 29 | } 30 | return t 31 | } 32 | 33 | func (t *template) String() string { 34 | return t.src 35 | } 36 | 37 | func (t *template) Execute(args interface{}) string { 38 | if t.tmpl == nil { 39 | return t.src 40 | } 41 | var buf bytes.Buffer 42 | if err := t.tmpl.Execute(&buf, args); err != nil { 43 | return err.Error() 44 | } 45 | return buf.String() 46 | } 47 | 48 | func (t *template) MarshalText() ([]byte, error) { 49 | return []byte(t.src), nil 50 | } 51 | 52 | func (t *template) UnmarshalText(src []byte) error { 53 | return t.parseTemplate(string(src)) 54 | } 55 | 56 | func (t *template) parseTemplate(src string) (err error) { 57 | t.src = src 58 | if strings.Contains(src, "{{") { 59 | t.tmpl, err = gotemplate.New(src).Parse(src) 60 | } 61 | return 62 | } 63 | 64 | var _ = encoding.TextMarshaler(&template{}) 65 | var _ = encoding.TextUnmarshaler(&template{}) 66 | -------------------------------------------------------------------------------- /vendor/github.com/pborman/uuid/CONTRIBUTORS: -------------------------------------------------------------------------------- 1 | Paul Borman 2 | -------------------------------------------------------------------------------- /vendor/github.com/pborman/uuid/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2009,2014 Google Inc. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are 5 | met: 6 | 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above 10 | copyright notice, this list of conditions and the following disclaimer 11 | in the documentation and/or other materials provided with the 12 | distribution. 13 | * Neither the name of Google Inc. nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /vendor/github.com/pborman/uuid/dce.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 Google Inc. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package uuid 6 | 7 | import ( 8 | "encoding/binary" 9 | "fmt" 10 | "os" 11 | ) 12 | 13 | // A Domain represents a Version 2 domain 14 | type Domain byte 15 | 16 | // Domain constants for DCE Security (Version 2) UUIDs. 17 | const ( 18 | Person = Domain(0) 19 | Group = Domain(1) 20 | Org = Domain(2) 21 | ) 22 | 23 | // NewDCESecurity returns a DCE Security (Version 2) UUID. 24 | // 25 | // The domain should be one of Person, Group or Org. 26 | // On a POSIX system the id should be the users UID for the Person 27 | // domain and the users GID for the Group. The meaning of id for 28 | // the domain Org or on non-POSIX systems is site defined. 29 | // 30 | // For a given domain/id pair the same token may be returned for up to 31 | // 7 minutes and 10 seconds. 32 | func NewDCESecurity(domain Domain, id uint32) UUID { 33 | uuid := NewUUID() 34 | if uuid != nil { 35 | uuid[6] = (uuid[6] & 0x0f) | 0x20 // Version 2 36 | uuid[9] = byte(domain) 37 | binary.BigEndian.PutUint32(uuid[0:], id) 38 | } 39 | return uuid 40 | } 41 | 42 | // NewDCEPerson returns a DCE Security (Version 2) UUID in the person 43 | // domain with the id returned by os.Getuid. 44 | // 45 | // NewDCEPerson(Person, uint32(os.Getuid())) 46 | func NewDCEPerson() UUID { 47 | return NewDCESecurity(Person, uint32(os.Getuid())) 48 | } 49 | 50 | // NewDCEGroup returns a DCE Security (Version 2) UUID in the group 51 | // domain with the id returned by os.Getgid. 52 | // 53 | // NewDCEGroup(Group, uint32(os.Getgid())) 54 | func NewDCEGroup() UUID { 55 | return NewDCESecurity(Group, uint32(os.Getgid())) 56 | } 57 | 58 | // Domain returns the domain for a Version 2 UUID or false. 59 | func (uuid UUID) Domain() (Domain, bool) { 60 | if v, _ := uuid.Version(); v != 2 { 61 | return 0, false 62 | } 63 | return Domain(uuid[9]), true 64 | } 65 | 66 | // Id returns the id for a Version 2 UUID or false. 67 | func (uuid UUID) Id() (uint32, bool) { 68 | if v, _ := uuid.Version(); v != 2 { 69 | return 0, false 70 | } 71 | return binary.BigEndian.Uint32(uuid[0:4]), true 72 | } 73 | 74 | func (d Domain) String() string { 75 | switch d { 76 | case Person: 77 | return "Person" 78 | case Group: 79 | return "Group" 80 | case Org: 81 | return "Org" 82 | } 83 | return fmt.Sprintf("Domain%d", int(d)) 84 | } 85 | -------------------------------------------------------------------------------- /vendor/github.com/pborman/uuid/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 Google Inc. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // The uuid package generates and inspects UUIDs. 6 | // 7 | // UUIDs are based on RFC 4122 and DCE 1.1: Authentication and Security 8 | // Services. 9 | // 10 | // This package is a partial wrapper around the github.com/google/uuid package. 11 | // This package represents a UUID as []byte while github.com/google/uuid 12 | // represents a UUID as [16]byte. 13 | package uuid 14 | -------------------------------------------------------------------------------- /vendor/github.com/pborman/uuid/hash.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 Google Inc. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package uuid 6 | 7 | import ( 8 | "crypto/md5" 9 | "crypto/sha1" 10 | "hash" 11 | ) 12 | 13 | // Well known Name Space IDs and UUIDs 14 | var ( 15 | NameSpace_DNS = Parse("6ba7b810-9dad-11d1-80b4-00c04fd430c8") 16 | NameSpace_URL = Parse("6ba7b811-9dad-11d1-80b4-00c04fd430c8") 17 | NameSpace_OID = Parse("6ba7b812-9dad-11d1-80b4-00c04fd430c8") 18 | NameSpace_X500 = Parse("6ba7b814-9dad-11d1-80b4-00c04fd430c8") 19 | NIL = Parse("00000000-0000-0000-0000-000000000000") 20 | ) 21 | 22 | // NewHash returns a new UUID derived from the hash of space concatenated with 23 | // data generated by h. The hash should be at least 16 byte in length. The 24 | // first 16 bytes of the hash are used to form the UUID. The version of the 25 | // UUID will be the lower 4 bits of version. NewHash is used to implement 26 | // NewMD5 and NewSHA1. 27 | func NewHash(h hash.Hash, space UUID, data []byte, version int) UUID { 28 | h.Reset() 29 | h.Write(space) 30 | h.Write([]byte(data)) 31 | s := h.Sum(nil) 32 | uuid := make([]byte, 16) 33 | copy(uuid, s) 34 | uuid[6] = (uuid[6] & 0x0f) | uint8((version&0xf)<<4) 35 | uuid[8] = (uuid[8] & 0x3f) | 0x80 // RFC 4122 variant 36 | return uuid 37 | } 38 | 39 | // NewMD5 returns a new MD5 (Version 3) UUID based on the 40 | // supplied name space and data. 41 | // 42 | // NewHash(md5.New(), space, data, 3) 43 | func NewMD5(space UUID, data []byte) UUID { 44 | return NewHash(md5.New(), space, data, 3) 45 | } 46 | 47 | // NewSHA1 returns a new SHA1 (Version 5) UUID based on the 48 | // supplied name space and data. 49 | // 50 | // NewHash(sha1.New(), space, data, 5) 51 | func NewSHA1(space UUID, data []byte) UUID { 52 | return NewHash(sha1.New(), space, data, 5) 53 | } 54 | -------------------------------------------------------------------------------- /vendor/github.com/pborman/uuid/marshal.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 Google Inc. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package uuid 6 | 7 | import ( 8 | "errors" 9 | "fmt" 10 | 11 | guuid "github.com/google/uuid" 12 | ) 13 | 14 | // MarshalText implements encoding.TextMarshaler. 15 | func (u UUID) MarshalText() ([]byte, error) { 16 | if len(u) != 16 { 17 | return nil, nil 18 | } 19 | var js [36]byte 20 | encodeHex(js[:], u) 21 | return js[:], nil 22 | } 23 | 24 | // UnmarshalText implements encoding.TextUnmarshaler. 25 | func (u *UUID) UnmarshalText(data []byte) error { 26 | if len(data) == 0 { 27 | return nil 28 | } 29 | id := Parse(string(data)) 30 | if id == nil { 31 | return errors.New("invalid UUID") 32 | } 33 | *u = id 34 | return nil 35 | } 36 | 37 | // MarshalBinary implements encoding.BinaryMarshaler. 38 | func (u UUID) MarshalBinary() ([]byte, error) { 39 | return u[:], nil 40 | } 41 | 42 | // UnmarshalBinary implements encoding.BinaryUnmarshaler. 43 | func (u *UUID) UnmarshalBinary(data []byte) error { 44 | if len(data) == 0 { 45 | return nil 46 | } 47 | if len(data) != 16 { 48 | return fmt.Errorf("invalid UUID (got %d bytes)", len(data)) 49 | } 50 | var id [16]byte 51 | copy(id[:], data) 52 | *u = id[:] 53 | return nil 54 | } 55 | 56 | // MarshalText implements encoding.TextMarshaler. 57 | func (u Array) MarshalText() ([]byte, error) { 58 | var js [36]byte 59 | encodeHex(js[:], u[:]) 60 | return js[:], nil 61 | } 62 | 63 | // UnmarshalText implements encoding.TextUnmarshaler. 64 | func (u *Array) UnmarshalText(data []byte) error { 65 | id, err := guuid.ParseBytes(data) 66 | if err != nil { 67 | return err 68 | } 69 | *u = Array(id) 70 | return nil 71 | } 72 | 73 | // MarshalBinary implements encoding.BinaryMarshaler. 74 | func (u Array) MarshalBinary() ([]byte, error) { 75 | return u[:], nil 76 | } 77 | 78 | // UnmarshalBinary implements encoding.BinaryUnmarshaler. 79 | func (u *Array) UnmarshalBinary(data []byte) error { 80 | if len(data) != 16 { 81 | return fmt.Errorf("invalid UUID (got %d bytes)", len(data)) 82 | } 83 | copy(u[:], data) 84 | return nil 85 | } 86 | -------------------------------------------------------------------------------- /vendor/github.com/pborman/uuid/node.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 Google Inc. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package uuid 6 | 7 | import ( 8 | guuid "github.com/google/uuid" 9 | ) 10 | 11 | // NodeInterface returns the name of the interface from which the NodeID was 12 | // derived. The interface "user" is returned if the NodeID was set by 13 | // SetNodeID. 14 | func NodeInterface() string { 15 | return guuid.NodeInterface() 16 | } 17 | 18 | // SetNodeInterface selects the hardware address to be used for Version 1 UUIDs. 19 | // If name is "" then the first usable interface found will be used or a random 20 | // Node ID will be generated. If a named interface cannot be found then false 21 | // is returned. 22 | // 23 | // SetNodeInterface never fails when name is "". 24 | func SetNodeInterface(name string) bool { 25 | return guuid.SetNodeInterface(name) 26 | } 27 | 28 | // NodeID returns a slice of a copy of the current Node ID, setting the Node ID 29 | // if not already set. 30 | func NodeID() []byte { 31 | return guuid.NodeID() 32 | } 33 | 34 | // SetNodeID sets the Node ID to be used for Version 1 UUIDs. The first 6 bytes 35 | // of id are used. If id is less than 6 bytes then false is returned and the 36 | // Node ID is not set. 37 | func SetNodeID(id []byte) bool { 38 | return guuid.SetNodeID(id) 39 | } 40 | 41 | // NodeID returns the 6 byte node id encoded in uuid. It returns nil if uuid is 42 | // not valid. The NodeID is only well defined for version 1 and 2 UUIDs. 43 | func (uuid UUID) NodeID() []byte { 44 | if len(uuid) != 16 { 45 | return nil 46 | } 47 | node := make([]byte, 6) 48 | copy(node, uuid[10:]) 49 | return node 50 | } 51 | -------------------------------------------------------------------------------- /vendor/github.com/pborman/uuid/sql.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 Google Inc. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package uuid 6 | 7 | import ( 8 | "database/sql/driver" 9 | "errors" 10 | "fmt" 11 | ) 12 | 13 | // Scan implements sql.Scanner so UUIDs can be read from databases transparently 14 | // Currently, database types that map to string and []byte are supported. Please 15 | // consult database-specific driver documentation for matching types. 16 | func (uuid *UUID) Scan(src interface{}) error { 17 | switch src.(type) { 18 | case string: 19 | // if an empty UUID comes from a table, we return a null UUID 20 | if src.(string) == "" { 21 | return nil 22 | } 23 | 24 | // see uuid.Parse for required string format 25 | parsed := Parse(src.(string)) 26 | 27 | if parsed == nil { 28 | return errors.New("Scan: invalid UUID format") 29 | } 30 | 31 | *uuid = parsed 32 | case []byte: 33 | b := src.([]byte) 34 | 35 | // if an empty UUID comes from a table, we return a null UUID 36 | if len(b) == 0 { 37 | return nil 38 | } 39 | 40 | // assumes a simple slice of bytes if 16 bytes 41 | // otherwise attempts to parse 42 | if len(b) == 16 { 43 | parsed := make([]byte, 16) 44 | copy(parsed, b) 45 | *uuid = UUID(parsed) 46 | } else { 47 | u := Parse(string(b)) 48 | 49 | if u == nil { 50 | return errors.New("Scan: invalid UUID format") 51 | } 52 | 53 | *uuid = u 54 | } 55 | 56 | default: 57 | return fmt.Errorf("Scan: unable to scan type %T into UUID", src) 58 | } 59 | 60 | return nil 61 | } 62 | 63 | // Value implements sql.Valuer so that UUIDs can be written to databases 64 | // transparently. Currently, UUIDs map to strings. Please consult 65 | // database-specific driver documentation for matching types. 66 | func (uuid UUID) Value() (driver.Value, error) { 67 | return uuid.String(), nil 68 | } 69 | -------------------------------------------------------------------------------- /vendor/github.com/pborman/uuid/time.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 Google Inc. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package uuid 6 | 7 | import ( 8 | "encoding/binary" 9 | 10 | guuid "github.com/google/uuid" 11 | ) 12 | 13 | // A Time represents a time as the number of 100's of nanoseconds since 15 Oct 14 | // 1582. 15 | type Time = guuid.Time 16 | 17 | // GetTime returns the current Time (100s of nanoseconds since 15 Oct 1582) and 18 | // clock sequence as well as adjusting the clock sequence as needed. An error 19 | // is returned if the current time cannot be determined. 20 | func GetTime() (Time, uint16, error) { return guuid.GetTime() } 21 | 22 | // ClockSequence returns the current clock sequence, generating one if not 23 | // already set. The clock sequence is only used for Version 1 UUIDs. 24 | // 25 | // The uuid package does not use global static storage for the clock sequence or 26 | // the last time a UUID was generated. Unless SetClockSequence a new random 27 | // clock sequence is generated the first time a clock sequence is requested by 28 | // ClockSequence, GetTime, or NewUUID. (section 4.2.1.1) sequence is generated 29 | // for 30 | func ClockSequence() int { return guuid.ClockSequence() } 31 | 32 | // SetClockSeq sets the clock sequence to the lower 14 bits of seq. Setting to 33 | // -1 causes a new sequence to be generated. 34 | func SetClockSequence(seq int) { guuid.SetClockSequence(seq) } 35 | 36 | // Time returns the time in 100s of nanoseconds since 15 Oct 1582 encoded in 37 | // uuid. It returns false if uuid is not valid. The time is only well defined 38 | // for version 1 and 2 UUIDs. 39 | func (uuid UUID) Time() (Time, bool) { 40 | if len(uuid) != 16 { 41 | return 0, false 42 | } 43 | time := int64(binary.BigEndian.Uint32(uuid[0:4])) 44 | time |= int64(binary.BigEndian.Uint16(uuid[4:6])) << 32 45 | time |= int64(binary.BigEndian.Uint16(uuid[6:8])&0xfff) << 48 46 | return Time(time), true 47 | } 48 | 49 | // ClockSequence returns the clock sequence encoded in uuid. It returns false 50 | // if uuid is not valid. The clock sequence is only well defined for version 1 51 | // and 2 UUIDs. 52 | func (uuid UUID) ClockSequence() (int, bool) { 53 | if len(uuid) != 16 { 54 | return 0, false 55 | } 56 | return int(binary.BigEndian.Uint16(uuid[8:10])) & 0x3fff, true 57 | } 58 | -------------------------------------------------------------------------------- /vendor/github.com/pborman/uuid/util.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 Google Inc. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package uuid 6 | 7 | // xvalues returns the value of a byte as a hexadecimal digit or 255. 8 | var xvalues = [256]byte{ 9 | 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 10 | 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 11 | 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 12 | 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 255, 255, 255, 255, 255, 255, 13 | 255, 10, 11, 12, 13, 14, 15, 255, 255, 255, 255, 255, 255, 255, 255, 255, 14 | 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 15 | 255, 10, 11, 12, 13, 14, 15, 255, 255, 255, 255, 255, 255, 255, 255, 255, 16 | 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 17 | 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 18 | 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 19 | 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 20 | 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 21 | 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 22 | 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 23 | 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 24 | 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 25 | } 26 | 27 | // xtob converts the the first two hex bytes of x into a byte. 28 | func xtob(x string) (byte, bool) { 29 | b1 := xvalues[x[0]] 30 | b2 := xvalues[x[1]] 31 | return (b1 << 4) | b2, b1 != 255 && b2 != 255 32 | } 33 | -------------------------------------------------------------------------------- /vendor/github.com/pborman/uuid/version1.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 Google Inc. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package uuid 6 | 7 | import ( 8 | guuid "github.com/google/uuid" 9 | ) 10 | 11 | // NewUUID returns a Version 1 UUID based on the current NodeID and clock 12 | // sequence, and the current time. If the NodeID has not been set by SetNodeID 13 | // or SetNodeInterface then it will be set automatically. If the NodeID cannot 14 | // be set NewUUID returns nil. If clock sequence has not been set by 15 | // SetClockSequence then it will be set automatically. If GetTime fails to 16 | // return the current NewUUID returns nil. 17 | func NewUUID() UUID { 18 | gu, err := guuid.NewUUID() 19 | if err == nil { 20 | return UUID(gu[:]) 21 | } 22 | return nil 23 | } 24 | -------------------------------------------------------------------------------- /vendor/github.com/pborman/uuid/version4.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 Google Inc. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package uuid 6 | 7 | import guuid "github.com/google/uuid" 8 | 9 | // Random returns a Random (Version 4) UUID or panics. 10 | // 11 | // The strength of the UUIDs is based on the strength of the crypto/rand 12 | // package. 13 | // 14 | // A note about uniqueness derived from the UUID Wikipedia entry: 15 | // 16 | // Randomly generated UUIDs have 122 random bits. One's annual risk of being 17 | // hit by a meteorite is estimated to be one chance in 17 billion, that 18 | // means the probability is about 0.00000000006 (6 × 10−11), 19 | // equivalent to the odds of creating a few tens of trillions of UUIDs in a 20 | // year and having one duplicate. 21 | func NewRandom() UUID { 22 | if gu, err := guuid.NewRandom(); err == nil { 23 | return UUID(gu[:]) 24 | } 25 | return nil 26 | } 27 | -------------------------------------------------------------------------------- /vendor/github.com/pelletier/go-toml/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2013 - 2017 Thomas Pelletier, Eric Anderton 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /vendor/github.com/pelletier/go-toml/doc.go: -------------------------------------------------------------------------------- 1 | // Package toml is a TOML parser and manipulation library. 2 | // 3 | // This version supports the specification as described in 4 | // https://github.com/toml-lang/toml/blob/master/versions/en/toml-v0.4.0.md 5 | // 6 | // Marshaling 7 | // 8 | // Go-toml can marshal and unmarshal TOML documents from and to data 9 | // structures. 10 | // 11 | // TOML document as a tree 12 | // 13 | // Go-toml can operate on a TOML document as a tree. Use one of the Load* 14 | // functions to parse TOML data and obtain a Tree instance, then one of its 15 | // methods to manipulate the tree. 16 | // 17 | // JSONPath-like queries 18 | // 19 | // The package github.com/pelletier/go-toml/query implements a system 20 | // similar to JSONPath to quickly retrieve elements of a TOML document using a 21 | // single expression. See the package documentation for more information. 22 | // 23 | package toml 24 | -------------------------------------------------------------------------------- /vendor/github.com/pelletier/go-toml/fuzz.go: -------------------------------------------------------------------------------- 1 | // +build gofuzz 2 | 3 | package toml 4 | 5 | func Fuzz(data []byte) int { 6 | tree, err := LoadBytes(data) 7 | if err != nil { 8 | if tree != nil { 9 | panic("tree must be nil if there is an error") 10 | } 11 | return 0 12 | } 13 | 14 | str, err := tree.ToTomlString() 15 | if err != nil { 16 | if str != "" { 17 | panic(`str must be "" if there is an error`) 18 | } 19 | panic(err) 20 | } 21 | 22 | tree, err = Load(str) 23 | if err != nil { 24 | if tree != nil { 25 | panic("tree must be nil if there is an error") 26 | } 27 | return 0 28 | } 29 | 30 | return 1 31 | } 32 | -------------------------------------------------------------------------------- /vendor/github.com/pelletier/go-toml/keysparsing.go: -------------------------------------------------------------------------------- 1 | // Parsing keys handling both bare and quoted keys. 2 | 3 | package toml 4 | 5 | import ( 6 | "bytes" 7 | "errors" 8 | "fmt" 9 | "unicode" 10 | ) 11 | 12 | // Convert the bare key group string to an array. 13 | // The input supports double quotation to allow "." inside the key name, 14 | // but escape sequences are not supported. Lexers must unescape them beforehand. 15 | func parseKey(key string) ([]string, error) { 16 | groups := []string{} 17 | var buffer bytes.Buffer 18 | inQuotes := false 19 | wasInQuotes := false 20 | ignoreSpace := true 21 | expectDot := false 22 | 23 | for _, char := range key { 24 | if ignoreSpace { 25 | if char == ' ' { 26 | continue 27 | } 28 | ignoreSpace = false 29 | } 30 | switch char { 31 | case '"': 32 | if inQuotes { 33 | groups = append(groups, buffer.String()) 34 | buffer.Reset() 35 | wasInQuotes = true 36 | } 37 | inQuotes = !inQuotes 38 | expectDot = false 39 | case '.': 40 | if inQuotes { 41 | buffer.WriteRune(char) 42 | } else { 43 | if !wasInQuotes { 44 | if buffer.Len() == 0 { 45 | return nil, errors.New("empty table key") 46 | } 47 | groups = append(groups, buffer.String()) 48 | buffer.Reset() 49 | } 50 | ignoreSpace = true 51 | expectDot = false 52 | wasInQuotes = false 53 | } 54 | case ' ': 55 | if inQuotes { 56 | buffer.WriteRune(char) 57 | } else { 58 | expectDot = true 59 | } 60 | default: 61 | if !inQuotes && !isValidBareChar(char) { 62 | return nil, fmt.Errorf("invalid bare character: %c", char) 63 | } 64 | if !inQuotes && expectDot { 65 | return nil, errors.New("what?") 66 | } 67 | buffer.WriteRune(char) 68 | expectDot = false 69 | } 70 | } 71 | if inQuotes { 72 | return nil, errors.New("mismatched quotes") 73 | } 74 | if buffer.Len() > 0 { 75 | groups = append(groups, buffer.String()) 76 | } 77 | if len(groups) == 0 { 78 | return nil, errors.New("empty key") 79 | } 80 | return groups, nil 81 | } 82 | 83 | func isValidBareChar(r rune) bool { 84 | return isAlphanumeric(r) || r == '-' || unicode.IsNumber(r) 85 | } 86 | -------------------------------------------------------------------------------- /vendor/github.com/pelletier/go-toml/position.go: -------------------------------------------------------------------------------- 1 | // Position support for go-toml 2 | 3 | package toml 4 | 5 | import ( 6 | "fmt" 7 | ) 8 | 9 | // Position of a document element within a TOML document. 10 | // 11 | // Line and Col are both 1-indexed positions for the element's line number and 12 | // column number, respectively. Values of zero or less will cause Invalid(), 13 | // to return true. 14 | type Position struct { 15 | Line int // line within the document 16 | Col int // column within the line 17 | } 18 | 19 | // String representation of the position. 20 | // Displays 1-indexed line and column numbers. 21 | func (p Position) String() string { 22 | return fmt.Sprintf("(%d, %d)", p.Line, p.Col) 23 | } 24 | 25 | // Invalid returns whether or not the position is valid (i.e. with negative or 26 | // null values) 27 | func (p Position) Invalid() bool { 28 | return p.Line <= 0 || p.Col <= 0 29 | } 30 | -------------------------------------------------------------------------------- /vendor/github.com/pkg/errors/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2015, Dave Cheney 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, this 8 | list of conditions and the following disclaimer. 9 | 10 | * Redistributions in binary form must reproduce the above copyright notice, 11 | this list of conditions and the following disclaimer in the documentation 12 | and/or other materials provided with the distribution. 13 | 14 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 17 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 18 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 20 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 21 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 22 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 23 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | -------------------------------------------------------------------------------- /vendor/github.com/pmezard/go-difflib/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2013, Patrick Mezard 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are 6 | met: 7 | 8 | Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | The names of its contributors may not be used to endorse or promote 14 | products derived from this software without specific prior written 15 | permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 18 | IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 19 | TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 20 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 23 | TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 24 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 25 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 26 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 27 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/testify/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2012 - 2013 Mat Ryer and Tyler Bunnell 2 | 3 | Please consider promoting this project if you find it useful. 4 | 5 | Permission is hereby granted, free of charge, to any person 6 | obtaining a copy of this software and associated documentation 7 | files (the "Software"), to deal in the Software without restriction, 8 | including without limitation the rights to use, copy, modify, merge, 9 | publish, distribute, sublicense, and/or sell copies of the Software, 10 | and to permit persons to whom the Software is furnished to do so, 11 | subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included 14 | in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 20 | DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT 21 | OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE 22 | OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/testify/assert/doc.go: -------------------------------------------------------------------------------- 1 | // Package assert provides a set of comprehensive testing tools for use with the normal Go testing system. 2 | // 3 | // Example Usage 4 | // 5 | // The following is a complete example using assert in a standard test function: 6 | // import ( 7 | // "testing" 8 | // "github.com/stretchr/testify/assert" 9 | // ) 10 | // 11 | // func TestSomething(t *testing.T) { 12 | // 13 | // var a string = "Hello" 14 | // var b string = "Hello" 15 | // 16 | // assert.Equal(t, a, b, "The two words should be the same.") 17 | // 18 | // } 19 | // 20 | // if you assert many times, use the format below: 21 | // 22 | // import ( 23 | // "testing" 24 | // "github.com/stretchr/testify/assert" 25 | // ) 26 | // 27 | // func TestSomething(t *testing.T) { 28 | // assert := assert.New(t) 29 | // 30 | // var a string = "Hello" 31 | // var b string = "Hello" 32 | // 33 | // assert.Equal(a, b, "The two words should be the same.") 34 | // } 35 | // 36 | // Assertions 37 | // 38 | // Assertions allow you to easily write test code, and are global funcs in the `assert` package. 39 | // All assertion functions take, as the first argument, the `*testing.T` object provided by the 40 | // testing framework. This allows the assertion funcs to write the failings and other details to 41 | // the correct place. 42 | // 43 | // Every assertion function also takes an optional string message as the final argument, 44 | // allowing custom error messages to be appended to the message the assertion method outputs. 45 | package assert 46 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/testify/assert/errors.go: -------------------------------------------------------------------------------- 1 | package assert 2 | 3 | import ( 4 | "errors" 5 | ) 6 | 7 | // AnError is an error instance useful for testing. If the code does not care 8 | // about error specifics, and only needs to return the error for example, this 9 | // error should be used to make the test code more readable. 10 | var AnError = errors.New("assert.AnError general error for testing") 11 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/testify/assert/forward_assertions.go: -------------------------------------------------------------------------------- 1 | package assert 2 | 3 | // Assertions provides assertion methods around the 4 | // TestingT interface. 5 | type Assertions struct { 6 | t TestingT 7 | } 8 | 9 | // New makes a new Assertions object for the specified TestingT. 10 | func New(t TestingT) *Assertions { 11 | return &Assertions{ 12 | t: t, 13 | } 14 | } 15 | 16 | //go:generate go run ../_codegen/main.go -output-package=assert -template=assertion_forward.go.tmpl -include-format-funcs 17 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/testify/require/doc.go: -------------------------------------------------------------------------------- 1 | // Package require implements the same assertions as the `assert` package but 2 | // stops test execution when a test fails. 3 | // 4 | // Example Usage 5 | // 6 | // The following is a complete example using require in a standard test function: 7 | // import ( 8 | // "testing" 9 | // "github.com/stretchr/testify/require" 10 | // ) 11 | // 12 | // func TestSomething(t *testing.T) { 13 | // 14 | // var a string = "Hello" 15 | // var b string = "Hello" 16 | // 17 | // require.Equal(t, a, b, "The two words should be the same.") 18 | // 19 | // } 20 | // 21 | // Assertions 22 | // 23 | // The `require` package have same global functions as in the `assert` package, 24 | // but instead of returning a boolean result they call `t.FailNow()`. 25 | // 26 | // Every assertion function also takes an optional string message as the final argument, 27 | // allowing custom error messages to be appended to the message the assertion method outputs. 28 | package require 29 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/testify/require/forward_requirements.go: -------------------------------------------------------------------------------- 1 | package require 2 | 3 | // Assertions provides assertion methods around the 4 | // TestingT interface. 5 | type Assertions struct { 6 | t TestingT 7 | } 8 | 9 | // New makes a new Assertions object for the specified TestingT. 10 | func New(t TestingT) *Assertions { 11 | return &Assertions{ 12 | t: t, 13 | } 14 | } 15 | 16 | //go:generate go run ../_codegen/main.go -output-package=require -template=require_forward.go.tmpl -include-format-funcs 17 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/testify/require/requirements.go: -------------------------------------------------------------------------------- 1 | package require 2 | 3 | // TestingT is an interface wrapper around *testing.T 4 | type TestingT interface { 5 | Errorf(format string, args ...interface{}) 6 | FailNow() 7 | } 8 | 9 | type tHelper interface { 10 | Helper() 11 | } 12 | 13 | // ComparisonAssertionFunc is a common function prototype when comparing two values. Can be useful 14 | // for table driven tests. 15 | type ComparisonAssertionFunc func(TestingT, interface{}, interface{}, ...interface{}) 16 | 17 | // ValueAssertionFunc is a common function prototype when validating a single value. Can be useful 18 | // for table driven tests. 19 | type ValueAssertionFunc func(TestingT, interface{}, ...interface{}) 20 | 21 | // BoolAssertionFunc is a common function prototype when validating a bool value. Can be useful 22 | // for table driven tests. 23 | type BoolAssertionFunc func(TestingT, bool, ...interface{}) 24 | 25 | // ValuesAssertionFunc is a common function prototype when validating an error value. Can be useful 26 | // for table driven tests. 27 | type ErrorAssertionFunc func(TestingT, error, ...interface{}) 28 | 29 | //go:generate go run ../_codegen/main.go -output-package=require -template=require.go.tmpl -include-format-funcs 30 | -------------------------------------------------------------------------------- /vendor/go.uber.org/atomic/LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2016 Uber Technologies, Inc. 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. 20 | -------------------------------------------------------------------------------- /vendor/go.uber.org/atomic/string.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2016 Uber Technologies, Inc. 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy 4 | // of this software and associated documentation files (the "Software"), to deal 5 | // in the Software without restriction, including without limitation the rights 6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | // copies of the Software, and to permit persons to whom the Software is 8 | // furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in 11 | // all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | 21 | package atomic 22 | 23 | // String is an atomic type-safe wrapper around Value for strings. 24 | type String struct{ v Value } 25 | 26 | // NewString creates a String. 27 | func NewString(str string) *String { 28 | s := &String{} 29 | if str != "" { 30 | s.Store(str) 31 | } 32 | return s 33 | } 34 | 35 | // Load atomically loads the wrapped string. 36 | func (s *String) Load() string { 37 | v := s.v.Load() 38 | if v == nil { 39 | return "" 40 | } 41 | return v.(string) 42 | } 43 | 44 | // Store atomically stores the passed string. 45 | // Note: Converting the string to an interface{} to store in the Value 46 | // requires an allocation. 47 | func (s *String) Store(str string) { 48 | s.v.Store(str) 49 | } 50 | -------------------------------------------------------------------------------- /vendor/go.uber.org/multierr/LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2017 Uber Technologies, Inc. 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. 20 | -------------------------------------------------------------------------------- /vendor/go.uber.org/zap/LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2016-2017 Uber Technologies, Inc. 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. 20 | -------------------------------------------------------------------------------- /vendor/go.uber.org/zap/buffer/pool.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2016 Uber Technologies, Inc. 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy 4 | // of this software and associated documentation files (the "Software"), to deal 5 | // in the Software without restriction, including without limitation the rights 6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | // copies of the Software, and to permit persons to whom the Software is 8 | // furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in 11 | // all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | 21 | package buffer 22 | 23 | import "sync" 24 | 25 | // A Pool is a type-safe wrapper around a sync.Pool. 26 | type Pool struct { 27 | p *sync.Pool 28 | } 29 | 30 | // NewPool constructs a new Pool. 31 | func NewPool() Pool { 32 | return Pool{p: &sync.Pool{ 33 | New: func() interface{} { 34 | return &Buffer{bs: make([]byte, 0, _size)} 35 | }, 36 | }} 37 | } 38 | 39 | // Get retrieves a Buffer from the pool, creating one if necessary. 40 | func (p Pool) Get() *Buffer { 41 | buf := p.p.Get().(*Buffer) 42 | buf.Reset() 43 | buf.pool = p 44 | return buf 45 | } 46 | 47 | func (p Pool) put(buf *Buffer) { 48 | p.p.Put(buf) 49 | } 50 | -------------------------------------------------------------------------------- /vendor/go.uber.org/zap/flag.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2016 Uber Technologies, Inc. 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy 4 | // of this software and associated documentation files (the "Software"), to deal 5 | // in the Software without restriction, including without limitation the rights 6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | // copies of the Software, and to permit persons to whom the Software is 8 | // furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in 11 | // all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | 21 | package zap 22 | 23 | import ( 24 | "flag" 25 | 26 | "go.uber.org/zap/zapcore" 27 | ) 28 | 29 | // LevelFlag uses the standard library's flag.Var to declare a global flag 30 | // with the specified name, default, and usage guidance. The returned value is 31 | // a pointer to the value of the flag. 32 | // 33 | // If you don't want to use the flag package's global state, you can use any 34 | // non-nil *Level as a flag.Value with your own *flag.FlagSet. 35 | func LevelFlag(name string, defaultLevel zapcore.Level, usage string) *zapcore.Level { 36 | lvl := defaultLevel 37 | flag.Var(&lvl, name, usage) 38 | return &lvl 39 | } 40 | -------------------------------------------------------------------------------- /vendor/go.uber.org/zap/internal/bufferpool/bufferpool.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2016 Uber Technologies, Inc. 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy 4 | // of this software and associated documentation files (the "Software"), to deal 5 | // in the Software without restriction, including without limitation the rights 6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | // copies of the Software, and to permit persons to whom the Software is 8 | // furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in 11 | // all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | 21 | // Package bufferpool houses zap's shared internal buffer pool. Third-party 22 | // packages can recreate the same functionality with buffers.NewPool. 23 | package bufferpool 24 | 25 | import "go.uber.org/zap/buffer" 26 | 27 | var ( 28 | _pool = buffer.NewPool() 29 | // Get retrieves a buffer from the pool, creating one if necessary. 30 | Get = _pool.Get 31 | ) 32 | -------------------------------------------------------------------------------- /vendor/go.uber.org/zap/internal/color/color.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2016 Uber Technologies, Inc. 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy 4 | // of this software and associated documentation files (the "Software"), to deal 5 | // in the Software without restriction, including without limitation the rights 6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | // copies of the Software, and to permit persons to whom the Software is 8 | // furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in 11 | // all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | 21 | // Package color adds coloring functionality for TTY output. 22 | package color 23 | 24 | import "fmt" 25 | 26 | // Foreground colors. 27 | const ( 28 | Black Color = iota + 30 29 | Red 30 | Green 31 | Yellow 32 | Blue 33 | Magenta 34 | Cyan 35 | White 36 | ) 37 | 38 | // Color represents a text color. 39 | type Color uint8 40 | 41 | // Add adds the coloring to the given string. 42 | func (c Color) Add(s string) string { 43 | return fmt.Sprintf("\x1b[%dm%s\x1b[0m", uint8(c), s) 44 | } 45 | -------------------------------------------------------------------------------- /vendor/go.uber.org/zap/internal/exit/exit.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2016 Uber Technologies, Inc. 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy 4 | // of this software and associated documentation files (the "Software"), to deal 5 | // in the Software without restriction, including without limitation the rights 6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | // copies of the Software, and to permit persons to whom the Software is 8 | // furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in 11 | // all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | 21 | // Package exit provides stubs so that unit tests can exercise code that calls 22 | // os.Exit(1). 23 | package exit 24 | 25 | import "os" 26 | 27 | var real = func() { os.Exit(1) } 28 | 29 | // Exit normally terminates the process by calling os.Exit(1). If the package 30 | // is stubbed, it instead records a call in the testing spy. 31 | func Exit() { 32 | real() 33 | } 34 | 35 | // A StubbedExit is a testing fake for os.Exit. 36 | type StubbedExit struct { 37 | Exited bool 38 | prev func() 39 | } 40 | 41 | // Stub substitutes a fake for the call to os.Exit(1). 42 | func Stub() *StubbedExit { 43 | s := &StubbedExit{prev: real} 44 | real = s.exit 45 | return s 46 | } 47 | 48 | // WithStub runs the supplied function with Exit stubbed. It returns the stub 49 | // used, so that users can test whether the process would have crashed. 50 | func WithStub(f func()) *StubbedExit { 51 | s := Stub() 52 | defer s.Unstub() 53 | f() 54 | return s 55 | } 56 | 57 | // Unstub restores the previous exit function. 58 | func (se *StubbedExit) Unstub() { 59 | real = se.prev 60 | } 61 | 62 | func (se *StubbedExit) exit() { 63 | se.Exited = true 64 | } 65 | -------------------------------------------------------------------------------- /vendor/go.uber.org/zap/time.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2016 Uber Technologies, Inc. 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy 4 | // of this software and associated documentation files (the "Software"), to deal 5 | // in the Software without restriction, including without limitation the rights 6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | // copies of the Software, and to permit persons to whom the Software is 8 | // furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in 11 | // all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | 21 | package zap 22 | 23 | import "time" 24 | 25 | func timeToMillis(t time.Time) int64 { 26 | return t.UnixNano() / int64(time.Millisecond) 27 | } 28 | -------------------------------------------------------------------------------- /vendor/go.uber.org/zap/zapcore/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2016 Uber Technologies, Inc. 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy 4 | // of this software and associated documentation files (the "Software"), to deal 5 | // in the Software without restriction, including without limitation the rights 6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | // copies of the Software, and to permit persons to whom the Software is 8 | // furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in 11 | // all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | 21 | // Package zapcore defines and implements the low-level interfaces upon which 22 | // zap is built. By providing alternate implementations of these interfaces, 23 | // external packages can extend zap's capabilities. 24 | package zapcore // import "go.uber.org/zap/zapcore" 25 | -------------------------------------------------------------------------------- /vendor/go.uber.org/zap/zapcore/hook.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2016 Uber Technologies, Inc. 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy 4 | // of this software and associated documentation files (the "Software"), to deal 5 | // in the Software without restriction, including without limitation the rights 6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | // copies of the Software, and to permit persons to whom the Software is 8 | // furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in 11 | // all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | 21 | package zapcore 22 | 23 | import "go.uber.org/multierr" 24 | 25 | type hooked struct { 26 | Core 27 | funcs []func(Entry) error 28 | } 29 | 30 | // RegisterHooks wraps a Core and runs a collection of user-defined callback 31 | // hooks each time a message is logged. Execution of the callbacks is blocking. 32 | // 33 | // This offers users an easy way to register simple callbacks (e.g., metrics 34 | // collection) without implementing the full Core interface. 35 | func RegisterHooks(core Core, hooks ...func(Entry) error) Core { 36 | funcs := append([]func(Entry) error{}, hooks...) 37 | return &hooked{ 38 | Core: core, 39 | funcs: funcs, 40 | } 41 | } 42 | 43 | func (h *hooked) Check(ent Entry, ce *CheckedEntry) *CheckedEntry { 44 | // Let the wrapped Core decide whether to log this message or not. This 45 | // also gives the downstream a chance to register itself directly with the 46 | // CheckedEntry. 47 | if downstream := h.Core.Check(ent, ce); downstream != nil { 48 | return downstream.AddCore(ent, h) 49 | } 50 | return ce 51 | } 52 | 53 | func (h *hooked) With(fields []Field) Core { 54 | return &hooked{ 55 | Core: h.Core.With(fields), 56 | funcs: h.funcs, 57 | } 58 | } 59 | 60 | func (h *hooked) Write(ent Entry, _ []Field) error { 61 | // Since our downstream had a chance to register itself directly with the 62 | // CheckedMessage, we don't need to call it here. 63 | var err error 64 | for i := range h.funcs { 65 | err = multierr.Append(err, h.funcs[i](ent)) 66 | } 67 | return err 68 | } 69 | -------------------------------------------------------------------------------- /vendor/go.uber.org/zap/zapcore/level_strings.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2016 Uber Technologies, Inc. 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy 4 | // of this software and associated documentation files (the "Software"), to deal 5 | // in the Software without restriction, including without limitation the rights 6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | // copies of the Software, and to permit persons to whom the Software is 8 | // furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in 11 | // all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | 21 | package zapcore 22 | 23 | import "go.uber.org/zap/internal/color" 24 | 25 | var ( 26 | _levelToColor = map[Level]color.Color{ 27 | DebugLevel: color.Magenta, 28 | InfoLevel: color.Blue, 29 | WarnLevel: color.Yellow, 30 | ErrorLevel: color.Red, 31 | DPanicLevel: color.Red, 32 | PanicLevel: color.Red, 33 | FatalLevel: color.Red, 34 | } 35 | _unknownLevelColor = color.Red 36 | 37 | _levelToLowercaseColorString = make(map[Level]string, len(_levelToColor)) 38 | _levelToCapitalColorString = make(map[Level]string, len(_levelToColor)) 39 | ) 40 | 41 | func init() { 42 | for level, color := range _levelToColor { 43 | _levelToLowercaseColorString[level] = color.Add(level.String()) 44 | _levelToCapitalColorString[level] = color.Add(level.CapitalString()) 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /vendor/go.uber.org/zap/zapcore/marshaler.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2016 Uber Technologies, Inc. 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy 4 | // of this software and associated documentation files (the "Software"), to deal 5 | // in the Software without restriction, including without limitation the rights 6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | // copies of the Software, and to permit persons to whom the Software is 8 | // furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in 11 | // all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | 21 | package zapcore 22 | 23 | // ObjectMarshaler allows user-defined types to efficiently add themselves to the 24 | // logging context, and to selectively omit information which shouldn't be 25 | // included in logs (e.g., passwords). 26 | type ObjectMarshaler interface { 27 | MarshalLogObject(ObjectEncoder) error 28 | } 29 | 30 | // ObjectMarshalerFunc is a type adapter that turns a function into an 31 | // ObjectMarshaler. 32 | type ObjectMarshalerFunc func(ObjectEncoder) error 33 | 34 | // MarshalLogObject calls the underlying function. 35 | func (f ObjectMarshalerFunc) MarshalLogObject(enc ObjectEncoder) error { 36 | return f(enc) 37 | } 38 | 39 | // ArrayMarshaler allows user-defined types to efficiently add themselves to the 40 | // logging context, and to selectively omit information which shouldn't be 41 | // included in logs (e.g., passwords). 42 | type ArrayMarshaler interface { 43 | MarshalLogArray(ArrayEncoder) error 44 | } 45 | 46 | // ArrayMarshalerFunc is a type adapter that turns a function into an 47 | // ArrayMarshaler. 48 | type ArrayMarshalerFunc func(ArrayEncoder) error 49 | 50 | // MarshalLogArray calls the underlying function. 51 | func (f ArrayMarshalerFunc) MarshalLogArray(enc ArrayEncoder) error { 52 | return f(enc) 53 | } 54 | -------------------------------------------------------------------------------- /vendor/go.uber.org/zap/zapcore/tee.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2016 Uber Technologies, Inc. 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy 4 | // of this software and associated documentation files (the "Software"), to deal 5 | // in the Software without restriction, including without limitation the rights 6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | // copies of the Software, and to permit persons to whom the Software is 8 | // furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in 11 | // all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | 21 | package zapcore 22 | 23 | import "go.uber.org/multierr" 24 | 25 | type multiCore []Core 26 | 27 | // NewTee creates a Core that duplicates log entries into two or more 28 | // underlying Cores. 29 | // 30 | // Calling it with a single Core returns the input unchanged, and calling 31 | // it with no input returns a no-op Core. 32 | func NewTee(cores ...Core) Core { 33 | switch len(cores) { 34 | case 0: 35 | return NewNopCore() 36 | case 1: 37 | return cores[0] 38 | default: 39 | return multiCore(cores) 40 | } 41 | } 42 | 43 | func (mc multiCore) With(fields []Field) Core { 44 | clone := make(multiCore, len(mc)) 45 | for i := range mc { 46 | clone[i] = mc[i].With(fields) 47 | } 48 | return clone 49 | } 50 | 51 | func (mc multiCore) Enabled(lvl Level) bool { 52 | for i := range mc { 53 | if mc[i].Enabled(lvl) { 54 | return true 55 | } 56 | } 57 | return false 58 | } 59 | 60 | func (mc multiCore) Check(ent Entry, ce *CheckedEntry) *CheckedEntry { 61 | for i := range mc { 62 | ce = mc[i].Check(ent, ce) 63 | } 64 | return ce 65 | } 66 | 67 | func (mc multiCore) Write(ent Entry, fields []Field) error { 68 | var err error 69 | for i := range mc { 70 | err = multierr.Append(err, mc[i].Write(ent, fields)) 71 | } 72 | return err 73 | } 74 | 75 | func (mc multiCore) Sync() error { 76 | var err error 77 | for i := range mc { 78 | err = multierr.Append(err, mc[i].Sync()) 79 | } 80 | return err 81 | } 82 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/AUTHORS: -------------------------------------------------------------------------------- 1 | # This source code refers to The Go Authors for copyright purposes. 2 | # The master list of authors is in the main Go distribution, 3 | # visible at https://tip.golang.org/AUTHORS. 4 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/CONTRIBUTORS: -------------------------------------------------------------------------------- 1 | # This source code was written by the Go contributors. 2 | # The master list of contributors is in the main Go distribution, 3 | # visible at https://tip.golang.org/CONTRIBUTORS. 4 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2009 The Go Authors. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are 5 | met: 6 | 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above 10 | copyright notice, this list of conditions and the following disclaimer 11 | in the documentation and/or other materials provided with the 12 | distribution. 13 | * Neither the name of Google Inc. nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/PATENTS: -------------------------------------------------------------------------------- 1 | Additional IP Rights Grant (Patents) 2 | 3 | "This implementation" means the copyrightable works distributed by 4 | Google as part of the Go project. 5 | 6 | Google hereby grants to You a perpetual, worldwide, non-exclusive, 7 | no-charge, royalty-free, irrevocable (except as stated in this section) 8 | patent license to make, have made, use, offer to sell, sell, import, 9 | transfer and otherwise run, modify and propagate the contents of this 10 | implementation of Go, where such license applies only to those patent 11 | claims, both currently owned or controlled by Google and acquired in 12 | the future, licensable by Google that are necessarily infringed by this 13 | implementation of Go. This grant does not include claims that would be 14 | infringed only as a consequence of further modification of this 15 | implementation. If you or your agent or exclusive licensee institute or 16 | order or agree to the institution of patent litigation against any 17 | entity (including a cross-claim or counterclaim in a lawsuit) alleging 18 | that this implementation of Go or any code incorporated within this 19 | implementation of Go constitutes direct or contributory patent 20 | infringement, or inducement of patent infringement, then any patent 21 | rights granted to you under this License for this implementation of Go 22 | shall terminate as of the date such litigation is filed. 23 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/bcrypt/base64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package bcrypt 6 | 7 | import "encoding/base64" 8 | 9 | const alphabet = "./ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789" 10 | 11 | var bcEncoding = base64.NewEncoding(alphabet) 12 | 13 | func base64Encode(src []byte) []byte { 14 | n := bcEncoding.EncodedLen(len(src)) 15 | dst := make([]byte, n) 16 | bcEncoding.Encode(dst, src) 17 | for dst[n-1] == '=' { 18 | n-- 19 | } 20 | return dst[:n] 21 | } 22 | 23 | func base64Decode(src []byte) ([]byte, error) { 24 | numOfEquals := 4 - (len(src) % 4) 25 | for i := 0; i < numOfEquals; i++ { 26 | src = append(src, '=') 27 | } 28 | 29 | dst := make([]byte, bcEncoding.DecodedLen(len(src))) 30 | n, err := bcEncoding.Decode(dst, src) 31 | if err != nil { 32 | return nil, err 33 | } 34 | return dst[:n], nil 35 | } 36 | -------------------------------------------------------------------------------- /vendor/gopkg.in/natefinch/lumberjack.v2/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Nate Finch 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /vendor/gopkg.in/natefinch/lumberjack.v2/chown.go: -------------------------------------------------------------------------------- 1 | // +build !linux 2 | 3 | package lumberjack 4 | 5 | import ( 6 | "os" 7 | ) 8 | 9 | func chown(_ string, _ os.FileInfo) error { 10 | return nil 11 | } 12 | -------------------------------------------------------------------------------- /vendor/gopkg.in/natefinch/lumberjack.v2/chown_linux.go: -------------------------------------------------------------------------------- 1 | package lumberjack 2 | 3 | import ( 4 | "os" 5 | "syscall" 6 | ) 7 | 8 | // os_Chown is a var so we can mock it out during tests. 9 | var os_Chown = os.Chown 10 | 11 | func chown(name string, info os.FileInfo) error { 12 | f, err := os.OpenFile(name, os.O_CREATE|os.O_WRONLY|os.O_TRUNC, info.Mode()) 13 | if err != nil { 14 | return err 15 | } 16 | f.Close() 17 | stat := info.Sys().(*syscall.Stat_t) 18 | return os_Chown(name, int(stat.Uid), int(stat.Gid)) 19 | } 20 | -------------------------------------------------------------------------------- /vendor/gopkg.in/yaml.v2/LICENSE.libyaml: -------------------------------------------------------------------------------- 1 | The following files were ported to Go from C files of libyaml, and thus 2 | are still covered by their original copyright and license: 3 | 4 | apic.go 5 | emitterc.go 6 | parserc.go 7 | readerc.go 8 | scannerc.go 9 | writerc.go 10 | yamlh.go 11 | yamlprivateh.go 12 | 13 | Copyright (c) 2006 Kirill Simonov 14 | 15 | Permission is hereby granted, free of charge, to any person obtaining a copy of 16 | this software and associated documentation files (the "Software"), to deal in 17 | the Software without restriction, including without limitation the rights to 18 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 19 | of the Software, and to permit persons to whom the Software is furnished to do 20 | so, subject to the following conditions: 21 | 22 | The above copyright notice and this permission notice shall be included in all 23 | copies or substantial portions of the Software. 24 | 25 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 26 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 27 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 28 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 29 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 30 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 31 | SOFTWARE. 32 | -------------------------------------------------------------------------------- /vendor/gopkg.in/yaml.v2/NOTICE: -------------------------------------------------------------------------------- 1 | Copyright 2011-2016 Canonical Ltd. 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the License for the specific language governing permissions and 13 | limitations under the License. 14 | -------------------------------------------------------------------------------- /vendor/gopkg.in/yaml.v2/writerc.go: -------------------------------------------------------------------------------- 1 | package yaml 2 | 3 | // Set the writer error and return false. 4 | func yaml_emitter_set_writer_error(emitter *yaml_emitter_t, problem string) bool { 5 | emitter.error = yaml_WRITER_ERROR 6 | emitter.problem = problem 7 | return false 8 | } 9 | 10 | // Flush the output buffer. 11 | func yaml_emitter_flush(emitter *yaml_emitter_t) bool { 12 | if emitter.write_handler == nil { 13 | panic("write handler not set") 14 | } 15 | 16 | // Check if the buffer is empty. 17 | if emitter.buffer_pos == 0 { 18 | return true 19 | } 20 | 21 | if err := emitter.write_handler(emitter, emitter.buffer[:emitter.buffer_pos]); err != nil { 22 | return yaml_emitter_set_writer_error(emitter, "write error: "+err.Error()) 23 | } 24 | emitter.buffer_pos = 0 25 | return true 26 | } 27 | --------------------------------------------------------------------------------