diff --git a/Gopkg.lock b/Gopkg.lock index 73fd071221..f1e50932e4 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -3,92 +3,137 @@ [[projects]] branch = "master" + digest = "1:6da51e5ec493ad2b44cb04129e2d0a068c8fb9bd6cb5739d199573558696bb94" name = "github.com/Azure/go-ansiterm" packages = [ ".", - "winterm" + "winterm", ] + pruneopts = "UT" revision = "d6e3b3328b783f23731bc4d058875b0371ff8109" [[projects]] + digest = "1:bf42be3cb1519bf8018dfd99720b1005ee028d947124cab3ccf965da59381df6" name = "github.com/Microsoft/go-winio" packages = ["."] + pruneopts = "UT" revision = "7da180ee92d8bd8bb8c37fc560e673e6557c392f" version = "v0.4.7" [[projects]] branch = "master" + digest = "1:3721a10686511b80c052323423f0de17a8c06d417dbdd3b392b1578432a33aae" name = "github.com/Nvveen/Gotty" packages = ["."] + pruneopts = "UT" revision = "cd527374f1e5bff4938207604a14f2e38a9cf512" [[projects]] + digest = "1:320e7ead93de9fd2b0e59b50fd92a4d50c1f8ab455d96bc2eb083267453a9709" name = "github.com/asaskevich/govalidator" packages = ["."] + pruneopts = "UT" revision = "ccb8e960c48f04d6935e72476ae4a51028f9e22f" version = "v9" [[projects]] branch = "master" + digest = "1:d6afaeed1502aa28e80a4ed0981d570ad91b2579193404256ce672ed0a609e0d" name = "github.com/beorn7/perks" packages = ["quantile"] + pruneopts = "UT" revision = "3a771d992973f24aa725d07868b467d1ddfceafb" [[projects]] branch = "master" + digest = "1:35ac403a135b8a138870950720be1f0399e0a48387d4b5cca841b0ed8cf7a40b" name = "github.com/buger/jsonparser" packages = ["."] + pruneopts = "UT" revision = "2cac668e8456b4284edb0715e17e2af02d3ec993" [[projects]] + digest = "1:2209584c0f7c9b68c23374e659357ab546e1b70eec2761f03280f69a8fd23d77" name = "github.com/cenkalti/backoff" packages = ["."] + pruneopts = "UT" revision = "2ea60e5f094469f9e65adb9cd103795b73ae743e" version = "v2.0.0" [[projects]] branch = "master" + digest = "1:24310b2d7f85873dde28d21687a40f7eba239970827c6a5d68cb529c9803de3a" name = "github.com/cisco/senml" packages = ["."] + pruneopts = "UT" revision = "448c9510575e1dd6f780cb10addbad998cf80418" [[projects]] branch = "master" + digest = "1:fc8dbcc2a5de7c093e167828ebbdf551641761d2ad75431d3a167d467a264115" name = "github.com/containerd/continuity" packages = ["pathdriver"] + pruneopts = "UT" revision = "c6cef34830231743494fe2969284df7b82cc0ad0" [[projects]] + digest = "1:a2c1d0e43bd3baaa071d1b9ed72c27d78169b2b269f71c105ac4ba34b1be4a39" name = "github.com/davecgh/go-spew" packages = ["spew"] + pruneopts = "UT" revision = "346938d642f2ec3594ed81d874461961cd0faa76" version = "v1.1.0" [[projects]] + branch = "master" + digest = "1:ca71cdedcb487a361fe2588afeb3d373c0dfe21feaac229270fd6de234bd3c5e" + name = "github.com/dereulenspiegel/coap-mux" + packages = ["."] + pruneopts = "UT" + revision = "e137e310a99955be01d60b2237da89153ea40987" + +[[projects]] + digest = "1:76dc72490af7174349349838f2fe118996381b31ea83243812a97e5a0fd5ed55" name = "github.com/dgrijalva/jwt-go" packages = ["."] + pruneopts = "UT" revision = "06ea1031745cb8b3dab3f6a236daf2b0aa468b7e" version = "v3.2.0" [[projects]] + digest = "1:87dcb59127512b84097086504c16595cf8fef35b9e0bfca565dfc06e198158d7" name = "github.com/docker/go-connections" packages = ["nat"] + pruneopts = "UT" revision = "3ede32e2033de7505e6500d6c868c2b9ed9f169d" version = "v0.3.0" [[projects]] + digest = "1:6f82cacd0af5921e99bf3f46748705239b36489464f4529a1589bc895764fb18" name = "github.com/docker/go-units" packages = ["."] + pruneopts = "UT" revision = "47565b4f722fb6ceae66b95f853feed578a4a51c" version = "v0.3.3" [[projects]] + branch = "master" + digest = "1:f77ee3cd73cbf60434b4f72ec46a66773c555d46764399735b5f9a28505f3ece" + name = "github.com/dustin/go-coap" + packages = ["."] + pruneopts = "UT" + revision = "ddcc80675fa42611359d91a6dfa5aa57fb90e72b" + +[[projects]] + digest = "1:865079840386857c809b72ce300be7580cb50d3d3129ce11bf9aa6ca2bc1934a" name = "github.com/fatih/color" packages = ["."] + pruneopts = "UT" revision = "5b77d2a35fb0ede96d138fc9a99f5c9b6aef11b4" version = "v1.7.0" [[projects]] + digest = "1:3fd00c9248f27f544a9bff7254adf110e1c791d067522025fcaac7528b55087a" name = "github.com/go-kit/kit" packages = [ "endpoint", @@ -97,18 +142,22 @@ "metrics/internal/lv", "metrics/prometheus", "transport/grpc", - "transport/http" + "transport/http", ] + pruneopts = "UT" revision = "4dc7be5d2d12881735283bcab7352178e190fc71" version = "v0.6.0" [[projects]] + digest = "1:31a18dae27a29aa074515e43a443abfd2ba6deb6d69309d8d7ce789c45f34659" name = "github.com/go-logfmt/logfmt" packages = ["."] + pruneopts = "UT" revision = "390ab7935ee28ec6b286364bba9b4dd6410cb3d5" version = "v0.3.0" [[projects]] + digest = "1:7c2fd446293ff7799cc496d3446e674ee67902d119f244de645caf95dff1bb98" name = "github.com/go-redis/redis" packages = [ ".", @@ -118,125 +167,159 @@ "internal/pool", "internal/proto", "internal/singleflight", - "internal/util" + "internal/util", ] + pruneopts = "UT" revision = "f3bba01df2026fc865f7782948845db9cf44cf23" version = "v6.14.1" [[projects]] + digest = "1:c4a2528ccbcabf90f9f3c464a5fc9e302d592861bbfd0b7135a7de8a943d0406" name = "github.com/go-stack/stack" packages = ["."] + pruneopts = "UT" revision = "259ab82a6cad3992b4e21ff5cac294ccb06474bc" version = "v1.7.0" [[projects]] + digest = "1:8dfa0b1b7c4b7398d46340aef0f2a58aad5a75959eeeb79e023ab826f0c7f7f0" name = "github.com/go-zoo/bone" packages = ["."] + pruneopts = "UT" revision = "fd0aebc74e908868b09ac140fb5a53cb363884c1" version = "1.2" [[projects]] branch = "master" + digest = "1:cf497f8273ddb581939f686791154c7d349322f01a8cade02f21504c036abc5f" name = "github.com/gocql/gocql" packages = [ ".", "internal/lru", "internal/murmur", - "internal/streams" + "internal/streams", ] + pruneopts = "UT" revision = "651d6b1f343c6e168e45d119dcfe8f71e5bafb32" [[projects]] + digest = "1:9a688317f3231e0175b3429033f44411906c0ce119361b7b5019d01375f8cff7" name = "github.com/gogo/protobuf" packages = ["proto"] + pruneopts = "UT" revision = "1adfc126b41513cc696b209667c8656ea7aac67c" version = "v1.0.0" [[projects]] + digest = "1:17fe264ee908afc795734e8c4e63db2accabaf57326dbf21763a7d6b86096260" name = "github.com/golang/protobuf" packages = [ "proto", "ptypes", "ptypes/any", "ptypes/duration", - "ptypes/timestamp" + "ptypes/timestamp", ] + pruneopts = "UT" revision = "b4deda0973fb4c70b50d226b1af49f3da59f5265" version = "v1.1.0" [[projects]] branch = "master" + digest = "1:4a0c6bb4805508a6287675fac876be2ac1182539ca8a32468d8128882e9d5009" name = "github.com/golang/snappy" packages = ["."] + pruneopts = "UT" revision = "2e65f85255dbc3072edf28d6b5b8efc472979f5a" [[projects]] + digest = "1:43dd08a10854b2056e615d1b1d22ac94559d822e1f8b6fcc92c1a1057e85188e" name = "github.com/gorilla/websocket" packages = ["."] + pruneopts = "UT" revision = "ea4d1f681babbce9545c9c5f3d5194a789c89f5b" version = "v1.2.0" [[projects]] + digest = "1:364b908b9b27b97ab838f2f6f1b1f46281fa29b978a037d72a9b1d4f6d940190" name = "github.com/hailocab/go-hostpool" packages = ["."] + pruneopts = "UT" revision = "e80d13ce29ede4452c43dea11e79b9bc8a15b478" [[projects]] branch = "master" + digest = "1:51a6dbf048dc420793ec106b7c8d151d1ffb119285ce044cc41d2dbb7e23732e" name = "github.com/hokaccha/go-prettyjson" packages = ["."] + pruneopts = "UT" revision = "e6b9231a2b1cc5798b336fdbf99c16cd8ad1e0c9" [[projects]] + digest = "1:870d441fe217b8e689d7949fef6e43efbc787e50f200cb1e70dbca9204a1d6be" name = "github.com/inconshreveable/mousetrap" packages = ["."] + pruneopts = "UT" revision = "76626ae9c91c4f2a10f34cad8ce83ea42c93bb75" version = "v1.0" [[projects]] + digest = "1:ce530152667dc8ba823a586c1c81175aff2c4e15500520883a2727d0ed17c6f1" name = "github.com/influxdata/influxdb" packages = [ "client/v2", "models", - "pkg/escape" + "pkg/escape", ] + pruneopts = "UT" revision = "02d7d4f043b34ecb4e9b2dbec298c6f9450c2a32" version = "v1.5.2" [[projects]] branch = "master" + digest = "1:a64e323dc06b73892e5bb5d040ced475c4645d456038333883f58934abbf6f72" name = "github.com/kr/logfmt" packages = ["."] + pruneopts = "UT" revision = "b84e30acd515aadc4b783ad4ff83aff3299bdfe0" [[projects]] branch = "master" + digest = "1:1e537dfb7b4d543e25efa2c812084dd65736f8010979c1b7e167a5b876563199" name = "github.com/lib/pq" packages = [ ".", - "oid" + "oid", ] + pruneopts = "UT" revision = "d34b9ff171c21ad295489235aec8b6626023cd04" [[projects]] + digest = "1:c658e84ad3916da105a761660dcaeb01e63416c8ec7bc62256a9b411a05fcd67" name = "github.com/mattn/go-colorable" packages = ["."] + pruneopts = "UT" revision = "167de6bfdfba052fa6b2d3664c8f5272e23c9072" version = "v0.0.9" [[projects]] + digest = "1:d4d17353dbd05cb52a2a52b7fe1771883b682806f68db442b436294926bbfafb" name = "github.com/mattn/go-isatty" packages = ["."] + pruneopts = "UT" revision = "0360b2af4f38e8d38c7fce2a9f4e702702d73a39" version = "v0.0.3" [[projects]] + digest = "1:5985ef4caf91ece5d54817c11ea25f182697534f8ae6521eadcd628c142ac4b6" name = "github.com/matttproud/golang_protobuf_extensions" packages = ["pbutil"] + pruneopts = "UT" revision = "3247c84500bff8d9fb6d579d800f20b3e091582c" version = "v1.0.0" [[projects]] + digest = "1:e274a8817ced03e0eaab6615aee825e4bd374a31180a3f5c2c640403840cc9dc" name = "github.com/mongodb/mongo-go-driver" packages = [ "bson", @@ -286,52 +369,64 @@ "mongo/mongoopt", "mongo/replaceopt", "mongo/runcmdopt", - "mongo/updateopt" + "mongo/updateopt", ] + pruneopts = "UT" revision = "8df56f107cdd485351eb2523992c3364114b4b2e" version = "v0.0.10" [[projects]] + digest = "1:6ec5ca70ff99467ff3b134ca05ae1d247e42a0377a7c27a756ba932f4dfc3a88" name = "github.com/nats-io/go-nats" packages = [ ".", "encoders/builtin", - "util" + "util", ] + pruneopts = "UT" revision = "062418ea1c2181f52dc0f954f6204370519a868b" version = "v1.5.0" [[projects]] + digest = "1:c3cd663f2f30b92536b9f290ac85c6310dae36a14cb8961553ae9ccf0d85ae41" name = "github.com/nats-io/nuid" packages = ["."] + pruneopts = "UT" revision = "289cccf02c178dc782430d534e3c1f5b72af807f" version = "v1.0.0" [[projects]] + digest = "1:ee4d4af67d93cc7644157882329023ce9a7bcfce956a079069a9405521c7cc8d" name = "github.com/opencontainers/go-digest" packages = ["."] + pruneopts = "UT" revision = "279bed98673dd5bef374d3b6e4b09e2af76183bf" version = "v1.0.0-rc1" [[projects]] + digest = "1:11db38d694c130c800d0aefb502fb02519e514dc53d9804ce51d1ad25ec27db6" name = "github.com/opencontainers/image-spec" packages = [ "specs-go", - "specs-go/v1" + "specs-go/v1", ] + pruneopts = "UT" revision = "d60099175f88c47cd379c4738d158884749ed235" version = "v1.0.1" [[projects]] + digest = "1:1869683e323ebff2bdf8adcb560f82bf6f8d94019d35099e3403f7df12e9c07e" name = "github.com/opencontainers/runc" packages = [ "libcontainer/system", - "libcontainer/user" + "libcontainer/user", ] + pruneopts = "UT" revision = "baf6536d6259209c3edfa2b22237af82942d3dfa" version = "v0.1.1" [[projects]] + digest = "1:3b830e06971be8448e7c9e57c9cc15ce53ab7e8846e7b7c39110a177c7fae466" name = "github.com/ory/dockertest" packages = [ "docker", @@ -357,126 +452,158 @@ "docker/types/network", "docker/types/registry", "docker/types/strslice", - "docker/types/versions" + "docker/types/versions", ] + pruneopts = "UT" revision = "2e92e7784b6fb199fd168aa46269a2f1b34f299e" version = "v3.3.0" [[projects]] + digest = "1:40e195917a951a8bf867cd05de2a46aaf1806c50cf92eebf4c16f78cd196f747" name = "github.com/pkg/errors" packages = ["."] + pruneopts = "UT" revision = "645ef00459ed84a119197bfb8d8205042c6df63d" version = "v0.8.0" [[projects]] + digest = "1:0028cb19b2e4c3112225cd871870f2d9cf49b9b4276531f03438a88e94be86fe" name = "github.com/pmezard/go-difflib" packages = ["difflib"] + pruneopts = "UT" revision = "792786c7400a136282c1664665ae0a8db921c6c2" version = "v1.0.0" [[projects]] + digest = "1:d14a5f4bfecf017cb780bdde1b6483e5deb87e12c332544d2c430eda58734bcb" name = "github.com/prometheus/client_golang" packages = [ "prometheus", - "prometheus/promhttp" + "prometheus/promhttp", ] + pruneopts = "UT" revision = "c5b7fccd204277076155f10851dad72b76a49317" version = "v0.8.0" [[projects]] branch = "master" + digest = "1:32d10bdfa8f09ecf13598324dba86ab891f11db3c538b6a34d1c3b5b99d7c36b" name = "github.com/prometheus/client_model" packages = ["go"] + pruneopts = "UT" revision = "99fa1f4be8e564e8a6b613da7fa6f46c9edafc6c" [[projects]] branch = "master" + digest = "1:e469cd65badf7694aeb44874518606d93c1d59e7735d3754ad442782437d3cc3" name = "github.com/prometheus/common" packages = [ "expfmt", "internal/bitbucket.org/ww/goautoneg", - "model" + "model", ] + pruneopts = "UT" revision = "d811d2e9bf898806ecfb6ef6296774b13ffc314c" [[projects]] branch = "master" + digest = "1:570784e0ddbf67f14087c6d8cfb7b999b9c55e75518a755e88cb202566ea8a17" name = "github.com/prometheus/procfs" packages = [ ".", "internal/util", "nfs", - "xfs" + "xfs", ] + pruneopts = "UT" revision = "8b1c2da0d56deffdbb9e48d4414b4e674bd8083e" [[projects]] branch = "master" + digest = "1:c9f218adb858f881ce84d0c3d6ad9f65b40d7f31c705c8f00b04106294cb006e" name = "github.com/rubenv/sql-migrate" packages = [ ".", - "sqlparse" + "sqlparse", ] + pruneopts = "UT" revision = "081fe17d19ff4e2dd9f5a0c1158e6bcf74da6906" [[projects]] + digest = "1:274f67cb6fed9588ea2521ecdac05a6d62a8c51c074c1fccc6a49a40ba80e925" name = "github.com/satori/go.uuid" packages = ["."] + pruneopts = "UT" revision = "f58768cc1a7a7e77a3bd49e98cdd21419399b6a3" version = "v1.2.0" [[projects]] + digest = "1:9e9193aa51197513b3abcb108970d831fbcf40ef96aa845c4f03276e1fa316d2" name = "github.com/sirupsen/logrus" packages = ["."] + pruneopts = "UT" revision = "c155da19408a8799da419ed3eeb0cb5db0ad5dbc" version = "v1.0.5" [[projects]] + digest = "1:f7805d1cc7776d00da2aa3dbacf85927e58e6dad630ba9f3ea5b92d719f96269" name = "github.com/sony/gobreaker" packages = ["."] + pruneopts = "UT" revision = "e9556a45379ef1da12e54847edb2fb3d7d566f36" version = "0.3.0" [[projects]] + digest = "1:645cabccbb4fa8aab25a956cbcbdf6a6845ca736b2c64e197ca7cbb9d210b939" name = "github.com/spf13/cobra" packages = ["."] + pruneopts = "UT" revision = "ef82de70bb3f60c65fb8eebacbb2d122ef517385" version = "v0.0.3" [[projects]] + digest = "1:9424f440bba8f7508b69414634aef3b2b3a877e522d8a4624692412805407bb7" name = "github.com/spf13/pflag" packages = ["."] + pruneopts = "UT" revision = "583c0c0531f06d5278b7d917446061adc344b5cd" version = "v1.0.1" [[projects]] + digest = "1:7e8d267900c7fa7f35129a2a37596e38ed0f11ca746d6d9ba727980ee138f9f6" name = "github.com/stretchr/testify" packages = [ "assert", - "require" + "require", ] + pruneopts = "UT" revision = "12b6f73e6084dad08a7c6e575284b177ecafbc71" version = "v1.2.1" [[projects]] + digest = "1:03aa6e485e528acb119fb32901cf99582c380225fc7d5a02758e08b180cb56c3" name = "github.com/ugorji/go" packages = ["codec"] + pruneopts = "UT" revision = "b4c50a2b199d93b13dc15e78929cfb23bfdf21ab" version = "v1.1.1" [[projects]] branch = "master" + digest = "1:7310f5459b88177d24e26c5ec7deb100b78ec03c0437d7a7aaec3c7eac333a55" name = "golang.org/x/crypto" packages = [ "bcrypt", "blowfish", "pbkdf2", - "ssh/terminal" + "ssh/terminal", ] + pruneopts = "UT" revision = "2d027ae1dddd4694d54f7a8b6cbe78dca8720226" [[projects]] branch = "master" + digest = "1:49131f79ef90ca701638024267ba6e3b5cd0ce387e0b3ec79961a42430873db9" name = "golang.org/x/net" packages = [ "context", @@ -485,26 +612,32 @@ "http2/hpack", "idna", "internal/timeseries", - "trace" + "trace", ] + pruneopts = "UT" revision = "f73e4c9ed3b7ebdd5f699a16a880c2b1994e50dd" [[projects]] branch = "master" + digest = "1:e0140c0c868c6e0f01c0380865194592c011fe521d6e12d78bfd33e756fe018a" name = "golang.org/x/sync" packages = ["semaphore"] + pruneopts = "UT" revision = "1d60e4601c6fd243af51cc01ddf169918a5407ca" [[projects]] branch = "master" + digest = "1:66e34aa65b83061616603ba83517a4523c7261e18afd01c769dd215614bf7d70" name = "golang.org/x/sys" packages = [ "unix", - "windows" + "windows", ] + pruneopts = "UT" revision = "7dfd1290c7917b7ba22824b9d24954ab3002fe24" [[projects]] + digest = "1:a2ab62866c75542dd18d2b069fec854577a20211d7c0ea6ae746072a1dccdd18" name = "golang.org/x/text" packages = [ "collate", @@ -520,18 +653,22 @@ "unicode/bidi", "unicode/cldr", "unicode/norm", - "unicode/rangetable" + "unicode/rangetable", ] + pruneopts = "UT" revision = "f21a4dfb5e38f5895301dc265a8def02365cc3d0" version = "v0.3.0" [[projects]] branch = "master" + digest = "1:cd018653a358d4b743a9d3bee89e825521f2ab2f2ec0770164bf7632d8d73ab7" name = "google.golang.org/genproto" packages = ["googleapis/rpc/status"] + pruneopts = "UT" revision = "86e600f69ee4704c6efbf6a2a40a5c10700e76c2" [[projects]] + digest = "1:bb5ad466f9c22e1d7f34537a408ca215ee192e759979723b2b5e3f26dc80fd1f" name = "google.golang.org/grpc" packages = [ ".", @@ -557,32 +694,79 @@ "stats", "status", "tap", - "transport" + "transport", ] + pruneopts = "UT" revision = "41344da2231b913fa3d983840a57a6b1b7b631a1" version = "v1.12.0" [[projects]] + digest = "1:fa9a7c0ef59217bd22f32eb7cc027894d73f340a5633258cc079dec025db6a7f" name = "gopkg.in/gorp.v1" packages = ["."] + pruneopts = "UT" revision = "c87af80f3cc5036b55b83d77171e156791085e2e" version = "v1.7.1" [[projects]] + digest = "1:2d1fbdc6777e5408cabeb02bf336305e724b925ff4546ded0fa8715a7267922a" name = "gopkg.in/inf.v0" packages = ["."] + pruneopts = "UT" revision = "d2d2541c53f18d2a059457998ce2876cc8e67cbf" version = "v0.9.1" [[projects]] + digest = "1:784e96fed7cbc35a3fdefb802ed2f841c16dbc3cf6c02f6422cc94ff45d011fc" name = "gopkg.in/ory-am/dockertest.v3" packages = ["."] + pruneopts = "UT" revision = "2e92e7784b6fb199fd168aa46269a2f1b34f299e" version = "v3.3.0" [solve-meta] analyzer-name = "dep" analyzer-version = 1 - inputs-digest = "1f18adf44738d8f5c48b2f0576ab90c2f2c549f13a846b8f3c95aabaebe8efb4" + input-imports = [ + "github.com/asaskevich/govalidator", + "github.com/cisco/senml", + "github.com/dereulenspiegel/coap-mux", + "github.com/dgrijalva/jwt-go", + "github.com/dustin/go-coap", + "github.com/fatih/color", + "github.com/go-kit/kit/endpoint", + "github.com/go-kit/kit/log", + "github.com/go-kit/kit/metrics", + "github.com/go-kit/kit/metrics/prometheus", + "github.com/go-kit/kit/transport/grpc", + "github.com/go-kit/kit/transport/http", + "github.com/go-redis/redis", + "github.com/go-zoo/bone", + "github.com/gocql/gocql", + "github.com/gogo/protobuf/proto", + "github.com/golang/protobuf/proto", + "github.com/gorilla/websocket", + "github.com/hokaccha/go-prettyjson", + "github.com/influxdata/influxdb/client/v2", + "github.com/lib/pq", + "github.com/mongodb/mongo-go-driver/bson", + "github.com/mongodb/mongo-go-driver/mongo", + "github.com/mongodb/mongo-go-driver/mongo/findopt", + "github.com/nats-io/go-nats", + "github.com/prometheus/client_golang/prometheus", + "github.com/prometheus/client_golang/prometheus/promhttp", + "github.com/rubenv/sql-migrate", + "github.com/satori/go.uuid", + "github.com/sony/gobreaker", + "github.com/spf13/cobra", + "github.com/stretchr/testify/assert", + "github.com/stretchr/testify/require", + "golang.org/x/crypto/bcrypt", + "golang.org/x/net/context", + "google.golang.org/grpc", + "google.golang.org/grpc/codes", + "google.golang.org/grpc/status", + "gopkg.in/ory-am/dockertest.v3", + ] solver-name = "gps-cdcl" solver-version = 1 diff --git a/Gopkg.toml b/Gopkg.toml index 8735492f69..75d40ade20 100644 --- a/Gopkg.toml +++ b/Gopkg.toml @@ -86,6 +86,14 @@ branch = "master" name = "github.com/gocql/gocql" +[[constraint]] + branch = "master" + name = "github.com/dereulenspiegel/coap-mux" + +[[constraint]] + branch = "master" + name = "github.com/dustin/go-coap" + [prune] go-tests = true unused-packages = true diff --git a/Makefile b/Makefile index e03220ea57..258af885a8 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ BUILD_DIR = build -SERVICES = users things http normalizer ws influxdb-writer influxdb-reader mongodb-writer mongodb-reader cassandra-writer cassandra-reader cli +SERVICES = users things http normalizer ws coap influxdb-writer influxdb-reader mongodb-writer mongodb-reader cassandra-writer cassandra-reader cli DOCKERS = $(addprefix docker_,$(SERVICES)) DOCKERS_DEV = $(addprefix docker_dev_,$(SERVICES)) CGO_ENABLED ?= 0 diff --git a/cmd/coap/main.go b/cmd/coap/main.go new file mode 100644 index 0000000000..52a9aab102 --- /dev/null +++ b/cmd/coap/main.go @@ -0,0 +1,129 @@ +// +// Copyright (c) 2018 +// Mainflux +// +// SPDX-License-Identifier: Apache-2.0 +// + +package main + +import ( + "fmt" + "log" + "net/http" + "os" + "os/signal" + "syscall" + + gocoap "github.com/dustin/go-coap" + kitprometheus "github.com/go-kit/kit/metrics/prometheus" + "github.com/mainflux/mainflux" + "github.com/mainflux/mainflux/coap" + "github.com/mainflux/mainflux/coap/api" + "github.com/mainflux/mainflux/coap/nats" + logger "github.com/mainflux/mainflux/logger" + thingsapi "github.com/mainflux/mainflux/things/api/grpc" + stdprometheus "github.com/prometheus/client_golang/prometheus" + "google.golang.org/grpc" + + broker "github.com/nats-io/go-nats" +) + +const ( + defPort = "5683" + defNatsURL = broker.DefaultURL + defThingsURL = "localhost:8181" + defLogLevel = "error" + + envPort = "MF_COAP_ADAPTER_PORT" + envNatsURL = "MF_NATS_URL" + envThingsURL = "MF_THINGS_URL" + envLogLevel = "MF_COAP_ADAPTER_LOG_LEVEL" +) + +type config struct { + port string + natsURL string + thingsURL string + logLevel string +} + +func main() { + cfg := loadConfig() + + logger, err := logger.New(os.Stdout, cfg.logLevel) + if err != nil { + log.Fatalf(err.Error()) + } + + nc, err := broker.Connect(cfg.natsURL) + if err != nil { + logger.Error(fmt.Sprintf("Failed to connect to NATS: %s", err)) + os.Exit(1) + } + defer nc.Close() + + conn, err := grpc.Dial(cfg.thingsURL, grpc.WithInsecure()) + if err != nil { + logger.Error(fmt.Sprintf("Failed to connect to users service: %s", err)) + os.Exit(1) + } + defer conn.Close() + + cc := thingsapi.NewClient(conn) + respChan := make(chan string, 10000) + pubsub := nats.New(nc) + svc := coap.New(pubsub, respChan) + svc = api.LoggingMiddleware(svc, logger) + + svc = api.MetricsMiddleware( + svc, + kitprometheus.NewCounterFrom(stdprometheus.CounterOpts{ + Namespace: "coap_adapter", + Subsystem: "api", + Name: "request_count", + Help: "Number of requests received.", + }, []string{"method"}), + kitprometheus.NewSummaryFrom(stdprometheus.SummaryOpts{ + Namespace: "coap_adapter", + Subsystem: "api", + Name: "request_latency_microseconds", + Help: "Total duration of requests in microseconds.", + }, []string{"method"}), + ) + + errs := make(chan error, 2) + + go startHTTPServer(cfg.port, logger, errs) + go startCOAPServer(cfg.port, svc, cc, respChan, logger, errs) + + go func() { + c := make(chan os.Signal) + signal.Notify(c, syscall.SIGINT) + errs <- fmt.Errorf("%s", <-c) + }() + + err = <-errs + logger.Error(fmt.Sprintf("CoAP adapter terminated: %s", err)) +} + +func loadConfig() config { + return config{ + thingsURL: mainflux.Env(envThingsURL, defThingsURL), + natsURL: mainflux.Env(envNatsURL, defNatsURL), + port: mainflux.Env(envPort, defPort), + logLevel: mainflux.Env(envLogLevel, defLogLevel), + } +} + +func startHTTPServer(port string, logger logger.Logger, errs chan error) { + p := fmt.Sprintf(":%s", port) + logger.Info(fmt.Sprintf("CoAP service started, exposed port %s", port)) + errs <- http.ListenAndServe(p, api.MakeHTTPHandler()) +} + +func startCOAPServer(port string, svc coap.Service, auth mainflux.ThingsServiceClient, respChan chan<- string, l logger.Logger, errs chan error) { + p := fmt.Sprintf(":%s", port) + l.Info(fmt.Sprintf("CoAP adapter service started, exposed port %s", port)) + errs <- gocoap.ListenAndServe("udp", p, api.MakeCOAPHandler(svc, auth, l, respChan)) +} diff --git a/coap/README.md b/coap/README.md new file mode 100644 index 0000000000..6dd144edbf --- /dev/null +++ b/coap/README.md @@ -0,0 +1,61 @@ +# Mainflux CoAP Adapter + +Mainflux CoAP adapter provides an [CoAP](http://coap.technology/) API for sending messages through the +platform. + +## Configuration + +The service is configured using the environment variables presented in the +following table. Note that any unset variables will be replaced with their +default values. + +| Variable | Description | Default | +|---------------------------|------------------------|-----------------------| +| MF_COAP_ADAPTER_PORT | Service listening port | 5683 | +| MF_NATS_URL | NATS instance URL | nats://localhost:4222 | +| MF_THINGS_URL | Things service URL | localhost:8181 | +| MF_COAP_ADAPTER_LOG_LEVEL | Service log level | error | + +## Deployment + +The service is distributed as Docker container. The following snippet provides +a compose file template that can be used to deploy the service container locally: + +```yaml +version: "2" +services: + adapter: + image: mainflux/coap:[version] + container_name: [instance name] + ports: + - [host machine port]:[configured port] + environment: + MF_COAP_ADAPTER_PORT: [Service HTTP port] + MF_NATS_URL: [NATS instance URL] + MF_THINGS_URL: [Things service URL] + MF_COAP_ADAPTER_LOG_LEVEL: [Service log level] +``` + +Running this service outside of container requires working instance of the NATS service. +To start the service outside of the container, execute the following shell script: + +```bash +# download the latest version of the service +go get github.com/mainflux/mainflux + +cd $GOPATH/src/github.com/mainflux/mainflux + +# compile the http +make coap + +# copy binary to bin +make install + +# set the environment variables and run the service +MF_THINGS_URL=[Things service URL] MF_NATS_URL=[NATS instance URL] MF_COAP_ADAPTER_PORT=[Service HTTP port] MF_COAP_ADAPTER_LOG_LEVEL=[Service log level] $GOBIN/mainflux-coap +``` + +## Usage + +Since CoAP protocol does not support `Authorization` header (option), in order to send CoAP messages, +client valid `authorization` value must be present in `Uri-Query` option. diff --git a/coap/adapter.go b/coap/adapter.go new file mode 100644 index 0000000000..539805c195 --- /dev/null +++ b/coap/adapter.go @@ -0,0 +1,150 @@ +// +// Copyright (c) 2018 +// Mainflux +// +// SPDX-License-Identifier: Apache-2.0 +// + +// Package coap contains the domain concept definitions needed to support +// Mainflux coap adapter service functionality. All constant values are taken +// from RFC, and could be adjusted based on specific use case. +package coap + +import ( + "errors" + "sync" + "time" + + "github.com/mainflux/mainflux" + broker "github.com/nats-io/go-nats" +) + +const ( + chanID = "id" + keyHeader = "key" + + // AckRandomFactor is default ACK coefficient. + AckRandomFactor = 1.5 + // AckTimeout is the amount of time to wait for a response. + AckTimeout = 2000 * time.Millisecond + // MaxRetransmit is the maximum number of times a message will be retransmitted. + MaxRetransmit = 4 +) + +var ( + errBadOption = errors.New("bad option") + // ErrFailedMessagePublish indicates that message publishing failed. + ErrFailedMessagePublish = errors.New("failed to publish message") + + // ErrFailedSubscription indicates that client couldn't subscribe to specified channel. + ErrFailedSubscription = errors.New("failed to subscribe to a channel") + + // ErrFailedConnection indicates that service couldn't connect to message broker. + ErrFailedConnection = errors.New("failed to connect to message broker") +) + +// Broker represents NATS broker instance. +type Broker interface { + mainflux.MessagePublisher + + // Subscribes to channel with specified id and adds subscription to + // service map of subscriptions under given ID. + Subscribe(uint64, string, *Observer) error +} + +// Service specifies coap service API. +type Service interface { + Broker + // Unsubscribe method is used to stop observing resource. + Unsubscribe(string) +} + +var _ Service = (*adapterService)(nil) + +type adapterService struct { + pubsub Broker + obs map[string]*Observer + obsLock sync.Mutex +} + +// New instantiates the CoAP adapter implementation. +func New(pubsub Broker, responses <-chan string) Service { + as := &adapterService{ + pubsub: pubsub, + obs: make(map[string]*Observer), + obsLock: sync.Mutex{}, + } + + go as.listenResponses(responses) + return as +} + +func (svc *adapterService) get(obsID string) (*Observer, bool) { + svc.obsLock.Lock() + defer svc.obsLock.Unlock() + + val, ok := svc.obs[obsID] + return val, ok +} + +func (svc *adapterService) put(obsID string, o *Observer) { + svc.obsLock.Lock() + defer svc.obsLock.Unlock() + + val, ok := svc.obs[obsID] + if ok { + close(val.Cancel) + } + + svc.obs[obsID] = o +} + +func (svc *adapterService) remove(obsID string) { + svc.obsLock.Lock() + defer svc.obsLock.Unlock() + + val, ok := svc.obs[obsID] + if ok { + close(val.Cancel) + delete(svc.obs, obsID) + } +} + +// ListenResponses method handles ACK messages received from client. +func (svc *adapterService) listenResponses(responses <-chan string) { + for { + id := <-responses + + val, ok := svc.get(id) + if ok { + val.StoreExpired(false) + } + } +} + +func (svc *adapterService) Publish(msg mainflux.RawMessage) error { + if err := svc.pubsub.Publish(msg); err != nil { + switch err { + case broker.ErrConnectionClosed, broker.ErrInvalidConnection: + return ErrFailedConnection + default: + return ErrFailedMessagePublish + } + } + + return nil +} + +func (svc *adapterService) Subscribe(chanID uint64, obsID string, o *Observer) error { + if err := svc.pubsub.Subscribe(chanID, obsID, o); err != nil { + return ErrFailedSubscription + } + + // Put method removes Observer if already exists. + svc.put(obsID, o) + return nil +} + +func (svc *adapterService) Unsubscribe(obsID string) { + svc.remove(obsID) +} diff --git a/coap/api/doc.go b/coap/api/doc.go new file mode 100644 index 0000000000..a7449398fa --- /dev/null +++ b/coap/api/doc.go @@ -0,0 +1,10 @@ +// +// Copyright (c) 2018 +// Mainflux +// +// SPDX-License-Identifier: Apache-2.0 +// + +// Package api contains API-related concerns: endpoint definitions, middlewares +// and all resource representations. +package api diff --git a/coap/api/logging.go b/coap/api/logging.go new file mode 100644 index 0000000000..fb16b7f591 --- /dev/null +++ b/coap/api/logging.go @@ -0,0 +1,66 @@ +// +// Copyright (c) 2018 +// Mainflux +// +// SPDX-License-Identifier: Apache-2.0 +// + +// +build !test + +package api + +import ( + "fmt" + "time" + + "github.com/mainflux/mainflux" + "github.com/mainflux/mainflux/coap" + log "github.com/mainflux/mainflux/logger" +) + +var _ coap.Service = (*loggingMiddleware)(nil) + +type loggingMiddleware struct { + logger log.Logger + svc coap.Service +} + +// LoggingMiddleware adds logging facilities to the adapter. +func LoggingMiddleware(svc coap.Service, logger log.Logger) coap.Service { + return &loggingMiddleware{logger, svc} +} + +func (lm *loggingMiddleware) Publish(msg mainflux.RawMessage) (err error) { + defer func(begin time.Time) { + message := fmt.Sprintf("Method publish to channel %d took %s to complete", msg.Channel, time.Since(begin)) + if err != nil { + lm.logger.Warn(fmt.Sprintf("%s with error: %s.", message, err)) + return + } + lm.logger.Info(fmt.Sprintf("%s without errors.", message)) + }(time.Now()) + + return lm.svc.Publish(msg) +} + +func (lm *loggingMiddleware) Subscribe(chanID uint64, obsID string, o *coap.Observer) (err error) { + defer func(begin time.Time) { + message := fmt.Sprintf("Method subscribe to channel %d for client %s took %s to complete", chanID, obsID, time.Since(begin)) + if err != nil { + lm.logger.Warn(fmt.Sprintf("%s with error: %s.", message, err)) + return + } + lm.logger.Info(fmt.Sprintf("%s without errors.", message)) + }(time.Now()) + + return lm.svc.Subscribe(chanID, obsID, o) +} + +func (lm *loggingMiddleware) Unsubscribe(obsID string) { + defer func(begin time.Time) { + message := fmt.Sprintf("Method unsubscribe for the client %s took %s to complete without errors.", obsID, time.Since(begin)) + lm.logger.Info(fmt.Sprintf(message)) + }(time.Now()) + + lm.svc.Unsubscribe(obsID) +} diff --git a/coap/api/metrics.go b/coap/api/metrics.go new file mode 100644 index 0000000000..46a7a228e6 --- /dev/null +++ b/coap/api/metrics.go @@ -0,0 +1,62 @@ +// +// Copyright (c) 2018 +// Mainflux +// +// SPDX-License-Identifier: Apache-2.0 +// + +// +build !test + +package api + +import ( + "time" + + "github.com/go-kit/kit/metrics" + "github.com/mainflux/mainflux" + "github.com/mainflux/mainflux/coap" +) + +var _ coap.Service = (*metricsMiddleware)(nil) + +type metricsMiddleware struct { + counter metrics.Counter + latency metrics.Histogram + svc coap.Service +} + +// MetricsMiddleware instruments adapter by tracking request count and latency. +func MetricsMiddleware(svc coap.Service, counter metrics.Counter, latency metrics.Histogram) coap.Service { + return &metricsMiddleware{ + counter: counter, + latency: latency, + svc: svc, + } +} + +func (mm *metricsMiddleware) Publish(msg mainflux.RawMessage) error { + defer func(begin time.Time) { + mm.counter.With("method", "publish").Add(1) + mm.latency.With("method", "publish").Observe(time.Since(begin).Seconds()) + }(time.Now()) + + return mm.svc.Publish(msg) +} + +func (mm *metricsMiddleware) Subscribe(chanID uint64, clientID string, o *coap.Observer) error { + defer func(begin time.Time) { + mm.counter.With("method", "subscribe").Add(1) + mm.latency.With("method", "subscribe").Observe(time.Since(begin).Seconds()) + }(time.Now()) + + return mm.svc.Subscribe(chanID, clientID, o) +} + +func (mm *metricsMiddleware) Unsubscribe(clientID string) { + defer func(begin time.Time) { + mm.counter.With("method", "unsubscribe").Add(1) + mm.latency.With("method", "unsubscribe").Observe(time.Since(begin).Seconds()) + }(time.Now()) + + mm.svc.Unsubscribe(clientID) +} diff --git a/coap/api/transport.go b/coap/api/transport.go new file mode 100644 index 0000000000..ab1648081b --- /dev/null +++ b/coap/api/transport.go @@ -0,0 +1,296 @@ +// +// Copyright (c) 2018 +// Mainflux +// +// SPDX-License-Identifier: Apache-2.0 +// + +package api + +import ( + "bytes" + "context" + "encoding/binary" + "encoding/json" + "errors" + "fmt" + "net" + "net/http" + "strconv" + "time" + + "github.com/go-zoo/bone" + "github.com/mainflux/mainflux/coap" + log "github.com/mainflux/mainflux/logger" + "github.com/prometheus/client_golang/prometheus/promhttp" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" + + mux "github.com/dereulenspiegel/coap-mux" + gocoap "github.com/dustin/go-coap" + "github.com/mainflux/mainflux" +) + +const protocol = "coap" + +var ( + errBadRequest = errors.New("bad request") + errBadOption = errors.New("bad option") + auth mainflux.ThingsServiceClient + logger log.Logger +) + +type handler func(conn *net.UDPConn, addr *net.UDPAddr, msg *gocoap.Message) *gocoap.Message + +func notFoundHandler(l *net.UDPConn, a *net.UDPAddr, m *gocoap.Message) *gocoap.Message { + if m.IsConfirmable() { + return &gocoap.Message{ + Type: gocoap.Acknowledgement, + Code: gocoap.NotFound, + } + } + return nil +} + +//MakeHTTPHandler creates handler for version endpoint. +func MakeHTTPHandler() http.Handler { + b := bone.New() + b.GetFunc("/version", mainflux.Version(protocol)) + b.Handle("/metrics", promhttp.Handler()) + + return b +} + +// MakeCOAPHandler creates handler for CoAP messages. +func MakeCOAPHandler(svc coap.Service, tc mainflux.ThingsServiceClient, l log.Logger, responses chan<- string) gocoap.Handler { + auth = tc + logger = l + + r := mux.NewRouter() + r.Handle("/channels/{id}/messages", gocoap.FuncHandler(receive(svc))).Methods(gocoap.POST) + r.Handle("/channels/{id}/messages", gocoap.FuncHandler(observe(svc, responses))) + r.NotFoundHandler = gocoap.FuncHandler(notFoundHandler) + + return r +} + +func authorize(msg *gocoap.Message, res *gocoap.Message, cid uint64) (uint64, error) { + // Device Key is passed as Uri-Query parameter, which option ID is 15 (0xf). + key, err := authKey(msg.Option(gocoap.URIQuery)) + if err != nil { + switch err { + case errBadOption: + res.Code = gocoap.BadOption + case errBadRequest: + res.Code = gocoap.BadRequest + } + + return 0, err + } + + ctx, cancel := context.WithTimeout(context.Background(), time.Second) + defer cancel() + + id, err := auth.CanAccess(ctx, &mainflux.AccessReq{Token: key, ChanID: cid}) + + if err != nil { + e, ok := status.FromError(err) + if ok { + switch e.Code() { + case codes.PermissionDenied: + res.Code = gocoap.Forbidden + default: + res.Code = gocoap.ServiceUnavailable + } + return 0, err + } + res.Code = gocoap.InternalServerError + } + return id.GetValue(), nil +} + +func receive(svc coap.Service) handler { + return func(conn *net.UDPConn, addr *net.UDPAddr, msg *gocoap.Message) *gocoap.Message { + // By default message is NonConfirmable, so + // NonConfirmable response is sent back. + res := &gocoap.Message{ + Type: gocoap.NonConfirmable, + // According to https://tools.ietf.org/html/rfc7252#page-47: If the POST + // succeeds but does not result in a new resource being created on the + // server, the response SHOULD have a 2.04 (Changed) Response Code. + Code: gocoap.Changed, + MessageID: msg.MessageID, + Token: msg.Token, + Payload: []byte{}, + } + + if msg.IsConfirmable() { + res.Type = gocoap.Acknowledgement + res.SetOption(gocoap.ContentFormat, gocoap.AppJSON) + if len(msg.Payload) == 0 { + res.Code = gocoap.BadRequest + return res + } + } + + channelID := mux.Var(msg, "id") + + cid, err := strconv.ParseUint(channelID, 10, 64) + if err != nil { + res.Code = gocoap.NotFound + return res + } + + publisher, err := authorize(msg, res, cid) + if err != nil { + res.Code = gocoap.Forbidden + return res + } + + rawMsg := mainflux.RawMessage{ + Channel: cid, + Publisher: publisher, + Protocol: protocol, + Payload: msg.Payload, + } + + if err := svc.Publish(rawMsg); err != nil { + res.Code = gocoap.InternalServerError + } + + return res + } +} + +func observe(svc coap.Service, responses chan<- string) handler { + return func(conn *net.UDPConn, addr *net.UDPAddr, msg *gocoap.Message) *gocoap.Message { + res := &gocoap.Message{ + Type: gocoap.Acknowledgement, + Code: gocoap.Content, + MessageID: msg.MessageID, + Token: msg.Token, + Payload: []byte{}, + } + res.SetOption(gocoap.ContentFormat, gocoap.AppJSON) + + id := mux.Var(msg, "id") + chanID, err := strconv.ParseUint(id, 10, 64) + if err != nil { + res.Code = gocoap.NotFound + return res + } + + publisher, err := authorize(msg, res, chanID) + if err != nil { + res.Code = gocoap.Forbidden + logger.Warn(fmt.Sprintf("Failed to authorize: %s", err)) + return res + } + + obsID := fmt.Sprintf("%x-%d-%d", msg.Token, publisher, chanID) + + if msg.Type == gocoap.Acknowledgement { + responses <- obsID + return nil + } + + if value, ok := msg.Option(gocoap.Observe).(uint32); (ok && value == 1) || msg.Type == gocoap.Reset { + svc.Unsubscribe(obsID) + } + + if value, ok := msg.Option(gocoap.Observe).(uint32); ok && value == 0 { + res.AddOption(gocoap.Observe, 1) + o := coap.NewObserver() + if err := svc.Subscribe(chanID, obsID, o); err != nil { + logger.Warn(fmt.Sprintf("Failed to subscribe to NATS subject: %s", err)) + res.Code = gocoap.InternalServerError + return res + } + + go handleMessage(conn, addr, o, msg) + go ping(svc, obsID, conn, addr, o, msg) + go cancel(o) + } + + return res + } +} + +func cancel(observer *coap.Observer) { + <-observer.Cancel + close(observer.Messages) + observer.StoreExpired(true) +} + +func handleMessage(conn *net.UDPConn, addr *net.UDPAddr, o *coap.Observer, msg *gocoap.Message) { + notifyMsg := *msg + notifyMsg.Type = gocoap.NonConfirmable + notifyMsg.Code = gocoap.Content + notifyMsg.RemoveOption(gocoap.URIQuery) + for { + msg, ok := <-o.Messages + if !ok { + return + } + payload, err := json.Marshal(msg) + if err != nil { + logger.Warn(fmt.Sprintf("Failed to parse received message: %s", err)) + continue + } + + notifyMsg.Payload = payload + notifyMsg.MessageID = o.LoadMessageID() + buff := new(bytes.Buffer) + observe := uint64(notifyMsg.MessageID) + if err := binary.Write(buff, binary.BigEndian, observe); err != nil { + logger.Warn(fmt.Sprintf("Failed to generate Observe option value: %s", err)) + continue + } + + observeVal := buff.Bytes() + notifyMsg.SetOption(gocoap.Observe, observeVal[len(observeVal)-3:]) + + if err := gocoap.Transmit(conn, addr, notifyMsg); err != nil { + logger.Warn(fmt.Sprintf("Failed to send message to observer: %s", err)) + } + } +} + +func ping(svc coap.Service, obsID string, conn *net.UDPConn, addr *net.UDPAddr, o *coap.Observer, msg *gocoap.Message) { + pingMsg := *msg + pingMsg.Payload = []byte{} + pingMsg.Type = gocoap.Confirmable + pingMsg.RemoveOption(gocoap.URIQuery) + // According to RFC (https://tools.ietf.org/html/rfc7641#page-18), CON message must be sent at least every + // 24 hours. Since 24 hours is too long for our purposes, we use 12. + t := time.NewTicker(12 * time.Hour) + defer t.Stop() + for { + select { + case _, ok := <-t.C: + if !ok || o.LoadExpired() { + return + } + + o.StoreExpired(true) + timeout := float64(coap.AckTimeout) + logger.Info(fmt.Sprintf("Ping client %s.", obsID)) + for i := 0; i < coap.MaxRetransmit; i++ { + pingMsg.MessageID = o.LoadMessageID() + gocoap.Transmit(conn, addr, pingMsg) + time.Sleep(time.Duration(timeout * coap.AckRandomFactor)) + if !o.LoadExpired() { + break + } + timeout = 2 * timeout + } + + if o.LoadExpired() { + svc.Unsubscribe(obsID) + return + } + case <-o.Cancel: + return + } + } +} diff --git a/coap/api/util.go b/coap/api/util.go new file mode 100644 index 0000000000..8a12bc5715 --- /dev/null +++ b/coap/api/util.go @@ -0,0 +1,24 @@ +// +// Copyright (c) 2018 +// Mainflux +// +// SPDX-License-Identifier: Apache-2.0 +// + +package api + +import "strings" + +func authKey(opt interface{}) (string, error) { + val, ok := opt.(string) + if !ok { + return "", errBadRequest + } + + arr := strings.Split(val, "=") + if len(arr) != 2 || strings.ToLower(arr[0]) != "authorization" { + return "", errBadOption + } + + return arr[1], nil +} diff --git a/coap/nats/publisher.go b/coap/nats/publisher.go new file mode 100644 index 0000000000..2477e9df95 --- /dev/null +++ b/coap/nats/publisher.go @@ -0,0 +1,64 @@ +// +// Copyright (c) 2018 +// Mainflux +// +// SPDX-License-Identifier: Apache-2.0 +// + +// Package ats contains NATS message publisher implementation. +package nats + +import ( + "fmt" + + "github.com/golang/protobuf/proto" + "github.com/mainflux/mainflux" + "github.com/mainflux/mainflux/coap" + broker "github.com/nats-io/go-nats" +) + +const prefix = "channel" + +var _ mainflux.MessagePublisher = (*natsPublisher)(nil) + +type natsPublisher struct { + nc *broker.Conn +} + +// New instantiates NATS message publisher. +func New(nc *broker.Conn) coap.Broker { + return &natsPublisher{nc} +} + +func (pubsub *natsPublisher) Publish(msg mainflux.RawMessage) error { + data, err := proto.Marshal(&msg) + if err != nil { + return err + } + + subject := fmt.Sprintf("%s.%d", prefix, msg.Channel) + return pubsub.nc.Publish(subject, data) +} + +func (pubsub *natsPublisher) Subscribe(chanID uint64, obsID string, observer *coap.Observer) error { + sub, err := pubsub.nc.Subscribe(fmt.Sprintf("%s.%d", prefix, chanID), func(msg *broker.Msg) { + if msg == nil { + return + } + var rawMsg mainflux.RawMessage + if err := proto.Unmarshal(msg.Data, &rawMsg); err != nil { + return + } + observer.Messages <- rawMsg + }) + if err != nil { + return err + } + + go func() { + <-observer.Cancel + sub.Unsubscribe() + }() + + return nil +} diff --git a/coap/observer.go b/coap/observer.go new file mode 100644 index 0000000000..026c190194 --- /dev/null +++ b/coap/observer.go @@ -0,0 +1,72 @@ +// +// Copyright (c) 2018 +// Mainflux +// +// SPDX-License-Identifier: Apache-2.0 +// + +package coap + +import ( + "sync" + + "github.com/mainflux/mainflux" +) + +// Observer is used to handle CoAP subscription. +type Observer struct { + // Expired flag is used to mark that ticker sent a + // CON message, but response is not received yet. + // The flag changes its value once ACK message is + // received from the client. If Expired is true + // when ticker is triggered, Observer should be canceled + // and removed from the Service map. + expired bool + + // Message ID for notification messages. + msgID uint16 + + expiredLock, msgIDLock sync.Mutex + + // Messages is used to receive messages from NATS. + Messages chan mainflux.RawMessage + + // Cancel channel is used to cancel observing resource. + // Cancel channel should not be used to send or receive any + // data, it's purpose is to be closed once Observer canceled. + Cancel chan bool +} + +// NewObserver instantiates a new Observer. +func NewObserver() *Observer { + return &Observer{ + Messages: make(chan mainflux.RawMessage), + Cancel: make(chan bool), + } +} + +// LoadExpired reads Expired flag in thread-safe way. +func (o *Observer) LoadExpired() bool { + o.expiredLock.Lock() + defer o.expiredLock.Unlock() + + return o.expired +} + +// StoreExpired stores Expired flag in thread-safe way. +func (o *Observer) StoreExpired(val bool) { + o.expiredLock.Lock() + defer o.expiredLock.Unlock() + + o.expired = val +} + +// LoadMessageID reads MessageID and increments +// its value in thread-safe way. +func (o *Observer) LoadMessageID() uint16 { + o.msgIDLock.Lock() + defer o.msgIDLock.Unlock() + + o.msgID++ + return o.msgID +} diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index 01129488c7..518100b389 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -199,3 +199,21 @@ services: - 8880:8880 networks: - mainflux-base-net + + coap-adapter: + image: mainflux/coap:latest + container_name: mainflux-coap + depends_on: + - things + - nats + restart: on-failure + expose: + - 5683 + environment: + MF_COAP_ADAPTER_PORT: 5683 + MF_NATS_URL: nats://nats:4222 + MF_THINGS_URL: things:8183 + ports: + - 5683:5683 + networks: + - mainflux-base-net diff --git a/vendor/github.com/dereulenspiegel/coap-mux/.travis.yml b/vendor/github.com/dereulenspiegel/coap-mux/.travis.yml new file mode 100644 index 0000000000..f631d7aba3 --- /dev/null +++ b/vendor/github.com/dereulenspiegel/coap-mux/.travis.yml @@ -0,0 +1,10 @@ +language: go +go: +- 1.5 + +before_install: + - go get github.com/axw/gocov/gocov + - go get github.com/mattn/goveralls + - if ! go get github.com/golang/tools/cmd/cover; then go get golang.org/x/tools/cmd/cover; fi +script: + - $HOME/gopath/bin/goveralls -service=travis-ci diff --git a/vendor/github.com/dereulenspiegel/coap-mux/README.md b/vendor/github.com/dereulenspiegel/coap-mux/README.md new file mode 100644 index 0000000000..fe6a94d256 --- /dev/null +++ b/vendor/github.com/dereulenspiegel/coap-mux/README.md @@ -0,0 +1,14 @@ +# coap-mux [![Build Status](https://travis-ci.org/dereulenspiegel/coap-mux.svg)](https://travis-ci.org/dereulenspiegel/coap-mux) [![Coverage Status](https://coveralls.io/repos/dereulenspiegel/coap-mux/badge.svg?branch=master&service=github)](https://coveralls.io/github/dereulenspiegel/coap-mux?branch=master) [![GoDoc](https://godoc.org/github.com/olebedev/config?status.png)](https://godoc.org/github.com/dereulenspiegel/coap-mux) + +This package provides basic support for routing based on path and method for +CoAP server. This library is heavily inspired by [mux](https://github.com/gorilla/mux). + +## Installation + +`go get github.com/dereulenspiegel/coap-mux` + +## Usage + +Create a new router with `NewRouter()` and add routes with `NewRoute()`, +`Handle(path, handler)` or `Path(string)`. The returned route object can be +configured further. diff --git a/vendor/github.com/dereulenspiegel/coap-mux/matcher.go b/vendor/github.com/dereulenspiegel/coap-mux/matcher.go new file mode 100644 index 0000000000..eeb1ce8f1d --- /dev/null +++ b/vendor/github.com/dereulenspiegel/coap-mux/matcher.go @@ -0,0 +1,49 @@ +package mux + +import ( + "fmt" + "net" + "strings" + + coap "github.com/dustin/go-coap" +) + +// methodMatcher matches the request against HTTP methods. +type methodMatcher []coap.COAPCode + +func (m methodMatcher) Match(msg *coap.Message, addr *net.UDPAddr) bool { + for _, v := range m { + if v == msg.Code { + return true + } + } + return false +} + +type coaptypeMatcher []coap.COAPType + +func (m coaptypeMatcher) Match(msg *coap.Message, addr *net.UDPAddr) bool { + for _, v := range m { + if v == msg.Type { + return true + } + } + return false +} + +// addRegexpMatcher adds a host or path matcher and builder to a route. +func (r *Route) addRegexpMatcher(tpl string) error { + if len(tpl) == 0 || tpl[0] != '/' { + return fmt.Errorf("mux: path must start with a slash, got %q", tpl) + } + if r.regexp != nil { + tpl = strings.TrimRight(r.regexp.template, "/") + tpl + } + rr, err := newRouteRegexp(tpl) + if err != nil { + return err + } + r.regexp = rr + r.addMatcher(rr) + return nil +} diff --git a/vendor/github.com/dereulenspiegel/coap-mux/mux.go b/vendor/github.com/dereulenspiegel/coap-mux/mux.go new file mode 100644 index 0000000000..0572d9761d --- /dev/null +++ b/vendor/github.com/dereulenspiegel/coap-mux/mux.go @@ -0,0 +1,104 @@ +package mux + +import ( + "net" + "sync" + + coap "github.com/dustin/go-coap" +) + +var ( + mutex sync.RWMutex + msgVars = make(map[*coap.Message]map[string]string) +) + +func setVar(msg *coap.Message, name, data string) { + mutex.Lock() + r, exists := msgVars[msg] + if !exists { + r = make(map[string]string) + } + r[name] = data + mutex.Unlock() +} + +func setVars(msg *coap.Message, vars map[string]string) { + mutex.Lock() + msgVars[msg] = vars + mutex.Unlock() +} + +// Var retrieves a named variable for this message +func Var(msg *coap.Message, name string) string { + mutex.RLock() + var value = "" + + r, exists := msgVars[msg] + if exists { + value = r[name] + } + mutex.RUnlock() + return value +} + +func clearVars(msg *coap.Message) { + mutex.Lock() + delete(msgVars, msg) + mutex.Unlock() +} + +// Router handles routing CoAP Messages to the correct handlers. Currently +// It doesn't support default routes etc. +type Router struct { + NotFoundHandler coap.Handler + routes []*Route +} + +// NewRouter creates a new Router +func NewRouter() *Router { + return &Router{routes: make([]*Route, 0, 50)} +} + +// Match matches the incoming message against all routes. The first matching route +// wins. +func (r *Router) Match(msg *coap.Message, addr *net.UDPAddr, match *RouteMatch) bool { + for _, route := range r.routes { + if route.Match(msg, addr, match) { + return true + } + } + return false +} + +// NewRoute creates a new unconfigured Route +func (r *Router) NewRoute() *Route { + route := &Route{} + r.routes = append(r.routes, route) + return route +} + +// Handle creates a new Route with the given handler and a matcher for the +// given path +func (r *Router) Handle(path string, handler coap.Handler) *Route { + return r.NewRoute().Path(path).Handler(handler) +} + +// Path creates a new Route with a matcher for the given path +func (r *Router) Path(tpl string) *Route { + return r.NewRoute().Path(tpl) +} + +// This method implements the interface for coap.Handler +func (r *Router) ServeCOAP(l *net.UDPConn, a *net.UDPAddr, m *coap.Message) *coap.Message { + match := &RouteMatch{} + var returnMessage *coap.Message + if r.Match(m, a, match) { + // TODO set vars + setVars(m, match.Vars) + returnMessage = match.Handler.ServeCOAP(l, a, m) + clearVars(m) + } else { + returnMessage = r.NotFoundHandler.ServeCOAP(l, a, m) + } + return returnMessage +} diff --git a/vendor/github.com/dereulenspiegel/coap-mux/regexp.go b/vendor/github.com/dereulenspiegel/coap-mux/regexp.go new file mode 100644 index 0000000000..022de9d768 --- /dev/null +++ b/vendor/github.com/dereulenspiegel/coap-mux/regexp.go @@ -0,0 +1,196 @@ +package mux + +import ( + "bytes" + "fmt" + "net" + "regexp" + "strconv" + "strings" + + coap "github.com/dustin/go-coap" +) + +func braceIndices(s string) ([]int, error) { + var level, idx int + idxs := make([]int, 0) + for i := 0; i < len(s); i++ { + switch s[i] { + case '{': + if level++; level == 1 { + idx = i + } + case '}': + if level--; level == 0 { + idxs = append(idxs, idx, i-1) + } else if level < 0 { + return nil, fmt.Errorf("mux: unbalanced braces in %q", s) + } + } + } + if level != 0 { + return nil, fmt.Errorf("mux: unbalanced braces in %q", s) + } + return idxs, nil +} + +// routeRegexp stores a regexp to match a host or path and information to +// collect and validate route variables. +type routeRegexp struct { + // The unmodified template. + template string + // Expanded regexp. + regexp *regexp.Regexp + // Reverse template. + reverse string + // Variable names. + varsN []string + // Variable regexps (validators). + varsR []*regexp.Regexp +} + +// varGroupName builds a capturing group name for the indexed variable. +func varGroupName(idx int) string { + return "v" + strconv.Itoa(idx) +} + +// newRouteRegexp parses a route template and returns a routeRegexp, +// used to match a host, a path or a query string. +// +// It will extract named variables, assemble a regexp to be matched, create +// a "reverse" template to build URLs and compile regexps to validate variable +// values used in URL building. +// +// Previously we accepted only Python-like identifiers for variable +// names ([a-zA-Z_][a-zA-Z0-9_]*), but currently the only restriction is that +// name and pattern can't be empty, and names can't contain a colon. +func newRouteRegexp(tpl string) (*routeRegexp, error) { + // Check if it is well-formed. + idxs, errBraces := braceIndices(tpl) + if errBraces != nil { + return nil, errBraces + } + // Backup the original. + template := tpl + // Now let's parse it. + defaultPattern := "[^/]+" + + endSlash := false + // Strip slashes from pattern, since coap messages won't have the either at the + // beginning + for tpl[0] == '/' { + tpl = tpl[1:] + } + varsN := make([]string, len(idxs)/2) + varsR := make([]*regexp.Regexp, len(idxs)/2) + pattern := bytes.NewBufferString("") + pattern.WriteByte('^') + reverse := bytes.NewBufferString("") + var end int + var start int + var err error + end = -1 + for i := 0; i < len(idxs); i += 2 { + // Set all values we are interested in. + raw := tpl[end+1 : idxs[i]-1] + end = idxs[i+1] + start = idxs[i] + parts := strings.SplitN(tpl[start:end], ":", 2) + name := parts[0] + patt := defaultPattern + if len(parts) == 2 { + patt = parts[1] + } + // Name or pattern can't be empty. + if name == "" || patt == "" { + return nil, fmt.Errorf("mux: missing name or pattern in %q", + tpl[start:end]) + } + // Build the regexp pattern. + varIdx := i / 2 + fmt.Fprintf(pattern, "%s(?P<%s>%s)", regexp.QuoteMeta(raw), varGroupName(varIdx), patt) + // Build the reverse template. + fmt.Fprintf(reverse, "%s%%s", raw) + + // Append variable name and compiled pattern. + varsN[varIdx] = name + varsR[varIdx], err = regexp.Compile(fmt.Sprintf("^%s$", patt)) + if err != nil { + return nil, err + } + } + // Add the remaining. + raw := tpl[end+1:] + pattern.WriteString(regexp.QuoteMeta(raw)) + pattern.WriteByte('$') + reverse.WriteString(raw) + if endSlash { + reverse.WriteByte('/') + } + // Compile full regexp. + reg, errCompile := regexp.Compile(pattern.String()) + if errCompile != nil { + return nil, errCompile + } + // Done! + return &routeRegexp{ + template: template, + regexp: reg, + reverse: reverse.String(), + varsN: varsN, + varsR: varsR, + }, nil +} + +// Match matches the regexp against the URL host or path. +func (r *routeRegexp) Match(msg *coap.Message, addr *net.UDPAddr) bool { + return r.regexp.MatchString(msg.PathString()) +} + +// url builds a URL part using the given values. +func (r *routeRegexp) url(values map[string]string) (string, error) { + urlValues := make([]interface{}, len(r.varsN)) + for k, v := range r.varsN { + value, ok := values[v] + if !ok { + return "", fmt.Errorf("mux: missing route variable %q", v) + } + urlValues[k] = value + } + rv := fmt.Sprintf(r.reverse, urlValues...) + if !r.regexp.MatchString(rv) { + // The URL is checked against the full regexp, instead of checking + // individual variables. This is faster but to provide a good error + // message, we check individual regexps if the URL doesn't match. + for k, v := range r.varsN { + if !r.varsR[k].MatchString(values[v]) { + return "", fmt.Errorf( + "mux: variable %q doesn't match, expected %q", values[v], + r.varsR[k].String()) + } + } + } + return rv, nil +} + +// routeRegexpGroup groups the route matchers that carry variables. +type routeRegexpGroup struct { + path *routeRegexp +} + +// setMatch extracts the variables from the URL once a route matches. +func (v *routeRegexp) setMatch(msg *coap.Message, m *RouteMatch, r *Route) { + // Store path variables. + pathVars := v.regexp.FindStringSubmatch(msg.PathString()) + if pathVars != nil { + subexpNames := v.regexp.SubexpNames() + varName := 0 + for i, name := range subexpNames[1:] { + if name != "" && name == varGroupName(varName) { + m.Vars[v.varsN[varName]] = pathVars[i+1] + varName++ + } + } + + } +} diff --git a/vendor/github.com/dereulenspiegel/coap-mux/route.go b/vendor/github.com/dereulenspiegel/coap-mux/route.go new file mode 100644 index 0000000000..5f9bc6182d --- /dev/null +++ b/vendor/github.com/dereulenspiegel/coap-mux/route.go @@ -0,0 +1,97 @@ +package mux + +import ( + "net" + + coap "github.com/dustin/go-coap" +) + +type RouteMatch struct { + Handler coap.Handler + Vars map[string]string +} + +// Matcher is the interface to implement if you want to match additional +// properties +type Matcher interface { + Match(*coap.Message, *net.UDPAddr) bool +} + +// Route represents a set of Matchers which all have to match for a handler to +// be executed +type Route struct { + name string + handler coap.Handler + matchers []Matcher + regexp *routeRegexp +} + +// getRegexpGroup returns regexp definitions from this route. +func (r *Route) getRegexp() *routeRegexp { + if r.regexp == nil { + r.regexp = new(routeRegexp) + } + return r.regexp +} + +// Name sets a name for this Route. Currently we don't do anything with the name +func (r *Route) Name(name string) *Route { + r.name = name + return r +} + +// Match matches this route against the received packet and the peers UDPAddr. +// All matchers have to return true to, for the route to be matched. +func (r *Route) Match(msg *coap.Message, addr *net.UDPAddr, match *RouteMatch) bool { + for _, matcher := range r.matchers { + if matched := matcher.Match(msg, addr); !matched { + return false + } + } + match.Handler = r.handler + if match.Vars == nil { + match.Vars = make(map[string]string) + } + // Set variables. + if r.regexp != nil { + r.regexp.setMatch(msg, match, r) + } + return true +} + +// Handler sets the handler for this route +func (r *Route) Handler(h coap.Handler) *Route { + r.handler = h + return r +} + +// addMatcher adds a matcher to the route. +func (r *Route) addMatcher(m Matcher) *Route { + r.matchers = append(r.matchers, m) + return r +} + +// Matches adds a custom matcher to the Routes matchers +func (r *Route) Matches(matcher Matcher) *Route { + r.addMatcher(matcher) + return r +} + +// Methods matches this Route for COAPCodes like GET, POST etc. +func (r *Route) Methods(methods ...coap.COAPCode) *Route { + return r.addMatcher(methodMatcher(methods)) +} + +// Path matches this Route against a path. The path may contain variables +// enclosed in curly braces. Example: +// /api/{id}/ +func (r *Route) Path(tpl string) *Route { + r.addRegexpMatcher(tpl) + return r +} + +// COAPType matches this Route against the type of the message +func (r *Route) COAPType(coapTypes ...coap.COAPType) *Route { + r.addMatcher(coaptypeMatcher(coapTypes)) + return r +} diff --git a/vendor/github.com/dustin/go-coap/.gitignore b/vendor/github.com/dustin/go-coap/.gitignore new file mode 100644 index 0000000000..1256dd203b --- /dev/null +++ b/vendor/github.com/dustin/go-coap/.gitignore @@ -0,0 +1,5 @@ +#* +*~ +/example/server/server +/example/subserver/subserver +/example/client/client diff --git a/vendor/github.com/dustin/go-coap/LICENSE b/vendor/github.com/dustin/go-coap/LICENSE new file mode 100644 index 0000000000..1ddd439ba3 --- /dev/null +++ b/vendor/github.com/dustin/go-coap/LICENSE @@ -0,0 +1,20 @@ +The MIT License (MIT) + +Copyright (c) 2013 Dustin Sallings + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/vendor/github.com/dustin/go-coap/README.markdown b/vendor/github.com/dustin/go-coap/README.markdown new file mode 100644 index 0000000000..748fe6f8c8 --- /dev/null +++ b/vendor/github.com/dustin/go-coap/README.markdown @@ -0,0 +1,8 @@ +# Constrained Application Protocol Client and Server for go + +You can read more about CoAP in [RFC 7252][coap]. I also did +some preliminary work on `SUBSCRIBE` support from +[an early draft][shelby]. + +[shelby]: http://tools.ietf.org/html/draft-shelby-core-coap-01 +[coap]: http://tools.ietf.org/html/rfc7252 diff --git a/vendor/github.com/dustin/go-coap/client.go b/vendor/github.com/dustin/go-coap/client.go new file mode 100644 index 0000000000..95cf03ff76 --- /dev/null +++ b/vendor/github.com/dustin/go-coap/client.go @@ -0,0 +1,66 @@ +package coap + +import ( + "net" + "time" +) + +const ( + // ResponseTimeout is the amount of time to wait for a + // response. + ResponseTimeout = time.Second * 2 + // ResponseRandomFactor is a multiplier for response backoff. + ResponseRandomFactor = 1.5 + // MaxRetransmit is the maximum number of times a message will + // be retransmitted. + MaxRetransmit = 4 +) + +// Conn is a CoAP client connection. +type Conn struct { + conn *net.UDPConn + buf []byte +} + +// Dial connects a CoAP client. +func Dial(n, addr string) (*Conn, error) { + uaddr, err := net.ResolveUDPAddr(n, addr) + if err != nil { + return nil, err + } + + s, err := net.DialUDP("udp", nil, uaddr) + if err != nil { + return nil, err + } + + return &Conn{s, make([]byte, maxPktLen)}, nil +} + +// Send a message. Get a response if there is one. +func (c *Conn) Send(req Message) (*Message, error) { + err := Transmit(c.conn, nil, req) + if err != nil { + return nil, err + } + + if !req.IsConfirmable() { + return nil, nil + } + + rv, err := Receive(c.conn, c.buf) + if err != nil { + return nil, err + } + + return &rv, nil +} + +// Receive a message. +func (c *Conn) Receive() (*Message, error) { + rv, err := Receive(c.conn, c.buf) + if err != nil { + return nil, err + } + return &rv, nil +} diff --git a/vendor/github.com/dustin/go-coap/message.go b/vendor/github.com/dustin/go-coap/message.go new file mode 100644 index 0000000000..630ad2fd54 --- /dev/null +++ b/vendor/github.com/dustin/go-coap/message.go @@ -0,0 +1,641 @@ +package coap + +import ( + "bytes" + "encoding/binary" + "errors" + "fmt" + "reflect" + "sort" + "strings" +) + +// COAPType represents the message type. +type COAPType uint8 + +const ( + // Confirmable messages require acknowledgements. + Confirmable COAPType = 0 + // NonConfirmable messages do not require acknowledgements. + NonConfirmable COAPType = 1 + // Acknowledgement is a message indicating a response to confirmable message. + Acknowledgement COAPType = 2 + // Reset indicates a permanent negative acknowledgement. + Reset COAPType = 3 +) + +var typeNames = [256]string{ + Confirmable: "Confirmable", + NonConfirmable: "NonConfirmable", + Acknowledgement: "Acknowledgement", + Reset: "Reset", +} + +func init() { + for i := range typeNames { + if typeNames[i] == "" { + typeNames[i] = fmt.Sprintf("Unknown (0x%x)", i) + } + } +} + +func (t COAPType) String() string { + return typeNames[t] +} + +// COAPCode is the type used for both request and response codes. +type COAPCode uint8 + +// Request Codes +const ( + GET COAPCode = 1 + POST COAPCode = 2 + PUT COAPCode = 3 + DELETE COAPCode = 4 +) + +// Response Codes +const ( + Created COAPCode = 65 + Deleted COAPCode = 66 + Valid COAPCode = 67 + Changed COAPCode = 68 + Content COAPCode = 69 + BadRequest COAPCode = 128 + Unauthorized COAPCode = 129 + BadOption COAPCode = 130 + Forbidden COAPCode = 131 + NotFound COAPCode = 132 + MethodNotAllowed COAPCode = 133 + NotAcceptable COAPCode = 134 + PreconditionFailed COAPCode = 140 + RequestEntityTooLarge COAPCode = 141 + UnsupportedMediaType COAPCode = 143 + InternalServerError COAPCode = 160 + NotImplemented COAPCode = 161 + BadGateway COAPCode = 162 + ServiceUnavailable COAPCode = 163 + GatewayTimeout COAPCode = 164 + ProxyingNotSupported COAPCode = 165 +) + +var codeNames = [256]string{ + GET: "GET", + POST: "POST", + PUT: "PUT", + DELETE: "DELETE", + Created: "Created", + Deleted: "Deleted", + Valid: "Valid", + Changed: "Changed", + Content: "Content", + BadRequest: "BadRequest", + Unauthorized: "Unauthorized", + BadOption: "BadOption", + Forbidden: "Forbidden", + NotFound: "NotFound", + MethodNotAllowed: "MethodNotAllowed", + NotAcceptable: "NotAcceptable", + PreconditionFailed: "PreconditionFailed", + RequestEntityTooLarge: "RequestEntityTooLarge", + UnsupportedMediaType: "UnsupportedMediaType", + InternalServerError: "InternalServerError", + NotImplemented: "NotImplemented", + BadGateway: "BadGateway", + ServiceUnavailable: "ServiceUnavailable", + GatewayTimeout: "GatewayTimeout", + ProxyingNotSupported: "ProxyingNotSupported", +} + +func init() { + for i := range codeNames { + if codeNames[i] == "" { + codeNames[i] = fmt.Sprintf("Unknown (0x%x)", i) + } + } +} + +func (c COAPCode) String() string { + return codeNames[c] +} + +// Message encoding errors. +var ( + ErrInvalidTokenLen = errors.New("invalid token length") + ErrOptionTooLong = errors.New("option is too long") + ErrOptionGapTooLarge = errors.New("option gap too large") +) + +// OptionID identifies an option in a message. +type OptionID uint8 + +/* + +-----+----+---+---+---+----------------+--------+--------+---------+ + | No. | C | U | N | R | Name | Format | Length | Default | + +-----+----+---+---+---+----------------+--------+--------+---------+ + | 1 | x | | | x | If-Match | opaque | 0-8 | (none) | + | 3 | x | x | - | | Uri-Host | string | 1-255 | (see | + | | | | | | | | | below) | + | 4 | | | | x | ETag | opaque | 1-8 | (none) | + | 5 | x | | | | If-None-Match | empty | 0 | (none) | + | 7 | x | x | - | | Uri-Port | uint | 0-2 | (see | + | | | | | | | | | below) | + | 8 | | | | x | Location-Path | string | 0-255 | (none) | + | 11 | x | x | - | x | Uri-Path | string | 0-255 | (none) | + | 12 | | | | | Content-Format | uint | 0-2 | (none) | + | 14 | | x | - | | Max-Age | uint | 0-4 | 60 | + | 15 | x | x | - | x | Uri-Query | string | 0-255 | (none) | + | 17 | x | | | | Accept | uint | 0-2 | (none) | + | 20 | | | | x | Location-Query | string | 0-255 | (none) | + | 35 | x | x | - | | Proxy-Uri | string | 1-1034 | (none) | + | 39 | x | x | - | | Proxy-Scheme | string | 1-255 | (none) | + | 60 | | | x | | Size1 | uint | 0-4 | (none) | + +-----+----+---+---+---+----------------+--------+--------+---------+ +*/ + +// Option IDs. +const ( + IfMatch OptionID = 1 + URIHost OptionID = 3 + ETag OptionID = 4 + IfNoneMatch OptionID = 5 + Observe OptionID = 6 + URIPort OptionID = 7 + LocationPath OptionID = 8 + URIPath OptionID = 11 + ContentFormat OptionID = 12 + MaxAge OptionID = 14 + URIQuery OptionID = 15 + Accept OptionID = 17 + LocationQuery OptionID = 20 + ProxyURI OptionID = 35 + ProxyScheme OptionID = 39 + Size1 OptionID = 60 +) + +// Option value format (RFC7252 section 3.2) +type valueFormat uint8 + +const ( + valueUnknown valueFormat = iota + valueEmpty + valueOpaque + valueUint + valueString +) + +type optionDef struct { + valueFormat valueFormat + minLen int + maxLen int +} + +var optionDefs = [256]optionDef{ + IfMatch: optionDef{valueFormat: valueOpaque, minLen: 0, maxLen: 8}, + URIHost: optionDef{valueFormat: valueString, minLen: 1, maxLen: 255}, + ETag: optionDef{valueFormat: valueOpaque, minLen: 1, maxLen: 8}, + IfNoneMatch: optionDef{valueFormat: valueEmpty, minLen: 0, maxLen: 0}, + Observe: optionDef{valueFormat: valueUint, minLen: 0, maxLen: 3}, + URIPort: optionDef{valueFormat: valueUint, minLen: 0, maxLen: 2}, + LocationPath: optionDef{valueFormat: valueString, minLen: 0, maxLen: 255}, + URIPath: optionDef{valueFormat: valueString, minLen: 0, maxLen: 255}, + ContentFormat: optionDef{valueFormat: valueUint, minLen: 0, maxLen: 2}, + MaxAge: optionDef{valueFormat: valueUint, minLen: 0, maxLen: 4}, + URIQuery: optionDef{valueFormat: valueString, minLen: 0, maxLen: 255}, + Accept: optionDef{valueFormat: valueUint, minLen: 0, maxLen: 2}, + LocationQuery: optionDef{valueFormat: valueString, minLen: 0, maxLen: 255}, + ProxyURI: optionDef{valueFormat: valueString, minLen: 1, maxLen: 1034}, + ProxyScheme: optionDef{valueFormat: valueString, minLen: 1, maxLen: 255}, + Size1: optionDef{valueFormat: valueUint, minLen: 0, maxLen: 4}, +} + +// MediaType specifies the content type of a message. +type MediaType byte + +// Content types. +const ( + TextPlain MediaType = 0 // text/plain;charset=utf-8 + AppLinkFormat MediaType = 40 // application/link-format + AppXML MediaType = 41 // application/xml + AppOctets MediaType = 42 // application/octet-stream + AppExi MediaType = 47 // application/exi + AppJSON MediaType = 50 // application/json +) + +type option struct { + ID OptionID + Value interface{} +} + +func encodeInt(v uint32) []byte { + switch { + case v == 0: + return nil + case v < 256: + return []byte{byte(v)} + case v < 65536: + rv := []byte{0, 0} + binary.BigEndian.PutUint16(rv, uint16(v)) + return rv + case v < 16777216: + rv := []byte{0, 0, 0, 0} + binary.BigEndian.PutUint32(rv, uint32(v)) + return rv[1:] + default: + rv := []byte{0, 0, 0, 0} + binary.BigEndian.PutUint32(rv, uint32(v)) + return rv + } +} + +func decodeInt(b []byte) uint32 { + tmp := []byte{0, 0, 0, 0} + copy(tmp[4-len(b):], b) + return binary.BigEndian.Uint32(tmp) +} + +func (o option) toBytes() []byte { + var v uint32 + + switch i := o.Value.(type) { + case string: + return []byte(i) + case []byte: + return i + case MediaType: + v = uint32(i) + case int: + v = uint32(i) + case int32: + v = uint32(i) + case uint: + v = uint32(i) + case uint32: + v = i + default: + panic(fmt.Errorf("invalid type for option %x: %T (%v)", + o.ID, o.Value, o.Value)) + } + + return encodeInt(v) +} + +func parseOptionValue(optionID OptionID, valueBuf []byte) interface{} { + def := optionDefs[optionID] + if def.valueFormat == valueUnknown { + // Skip unrecognized options (RFC7252 section 5.4.1) + return nil + } + if len(valueBuf) < def.minLen || len(valueBuf) > def.maxLen { + // Skip options with illegal value length (RFC7252 section 5.4.3) + return nil + } + switch def.valueFormat { + case valueUint: + intValue := decodeInt(valueBuf) + if optionID == ContentFormat || optionID == Accept { + return MediaType(intValue) + } else { + return intValue + } + case valueString: + return string(valueBuf) + case valueOpaque, valueEmpty: + return valueBuf + } + // Skip unrecognized options (should never be reached) + return nil +} + +type options []option + +func (o options) Len() int { + return len(o) +} + +func (o options) Less(i, j int) bool { + if o[i].ID == o[j].ID { + return i < j + } + return o[i].ID < o[j].ID +} + +func (o options) Swap(i, j int) { + o[i], o[j] = o[j], o[i] +} + +func (o options) Minus(oid OptionID) options { + rv := options{} + for _, opt := range o { + if opt.ID != oid { + rv = append(rv, opt) + } + } + return rv +} + +// Message is a CoAP message. +type Message struct { + Type COAPType + Code COAPCode + MessageID uint16 + + Token, Payload []byte + + opts options +} + +// IsConfirmable returns true if this message is confirmable. +func (m Message) IsConfirmable() bool { + return m.Type == Confirmable +} + +// Options gets all the values for the given option. +func (m Message) Options(o OptionID) []interface{} { + var rv []interface{} + + for _, v := range m.opts { + if o == v.ID { + rv = append(rv, v.Value) + } + } + + return rv +} + +// Option gets the first value for the given option ID. +func (m Message) Option(o OptionID) interface{} { + for _, v := range m.opts { + if o == v.ID { + return v.Value + } + } + return nil +} + +func (m Message) optionStrings(o OptionID) []string { + var rv []string + for _, o := range m.Options(o) { + rv = append(rv, o.(string)) + } + return rv +} + +// Path gets the Path set on this message if any. +func (m Message) Path() []string { + return m.optionStrings(URIPath) +} + +// PathString gets a path as a / separated string. +func (m Message) PathString() string { + return strings.Join(m.Path(), "/") +} + +// SetPathString sets a path by a / separated string. +func (m *Message) SetPathString(s string) { + for s[0] == '/' { + s = s[1:] + } + m.SetPath(strings.Split(s, "/")) +} + +// SetPath updates or adds a URIPath attribute on this message. +func (m *Message) SetPath(s []string) { + m.SetOption(URIPath, s) +} + +// RemoveOption removes all references to an option +func (m *Message) RemoveOption(opID OptionID) { + m.opts = m.opts.Minus(opID) +} + +// AddOption adds an option. +func (m *Message) AddOption(opID OptionID, val interface{}) { + iv := reflect.ValueOf(val) + if (iv.Kind() == reflect.Slice || iv.Kind() == reflect.Array) && + iv.Type().Elem().Kind() == reflect.String { + for i := 0; i < iv.Len(); i++ { + m.opts = append(m.opts, option{opID, iv.Index(i).Interface()}) + } + return + } + m.opts = append(m.opts, option{opID, val}) +} + +// SetOption sets an option, discarding any previous value +func (m *Message) SetOption(opID OptionID, val interface{}) { + m.RemoveOption(opID) + m.AddOption(opID, val) +} + +const ( + extoptByteCode = 13 + extoptByteAddend = 13 + extoptWordCode = 14 + extoptWordAddend = 269 + extoptError = 15 +) + +// MarshalBinary produces the binary form of this Message. +func (m *Message) MarshalBinary() ([]byte, error) { + tmpbuf := []byte{0, 0} + binary.BigEndian.PutUint16(tmpbuf, m.MessageID) + + /* + 0 1 2 3 + 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + |Ver| T | TKL | Code | Message ID | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | Token (if any, TKL bytes) ... + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | Options (if any) ... + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + |1 1 1 1 1 1 1 1| Payload (if any) ... + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + */ + + buf := bytes.Buffer{} + buf.Write([]byte{ + (1 << 6) | (uint8(m.Type) << 4) | uint8(0xf&len(m.Token)), + byte(m.Code), + tmpbuf[0], tmpbuf[1], + }) + buf.Write(m.Token) + + /* + 0 1 2 3 4 5 6 7 + +---------------+---------------+ + | | | + | Option Delta | Option Length | 1 byte + | | | + +---------------+---------------+ + \ \ + / Option Delta / 0-2 bytes + \ (extended) \ + +-------------------------------+ + \ \ + / Option Length / 0-2 bytes + \ (extended) \ + +-------------------------------+ + \ \ + / / + \ \ + / Option Value / 0 or more bytes + \ \ + / / + \ \ + +-------------------------------+ + + See parseExtOption(), extendOption() + and writeOptionHeader() below for implementation details + */ + + extendOpt := func(opt int) (int, int) { + ext := 0 + if opt >= extoptByteAddend { + if opt >= extoptWordAddend { + ext = opt - extoptWordAddend + opt = extoptWordCode + } else { + ext = opt - extoptByteAddend + opt = extoptByteCode + } + } + return opt, ext + } + + writeOptHeader := func(delta, length int) { + d, dx := extendOpt(delta) + l, lx := extendOpt(length) + + buf.WriteByte(byte(d<<4) | byte(l)) + + tmp := []byte{0, 0} + writeExt := func(opt, ext int) { + switch opt { + case extoptByteCode: + buf.WriteByte(byte(ext)) + case extoptWordCode: + binary.BigEndian.PutUint16(tmp, uint16(ext)) + buf.Write(tmp) + } + } + + writeExt(d, dx) + writeExt(l, lx) + } + + sort.Stable(&m.opts) + + prev := 0 + + for _, o := range m.opts { + b := o.toBytes() + writeOptHeader(int(o.ID)-prev, len(b)) + buf.Write(b) + prev = int(o.ID) + } + + if len(m.Payload) > 0 { + buf.Write([]byte{0xff}) + } + + buf.Write(m.Payload) + + return buf.Bytes(), nil +} + +// ParseMessage extracts the Message from the given input. +func ParseMessage(data []byte) (Message, error) { + rv := Message{} + return rv, rv.UnmarshalBinary(data) +} + +// UnmarshalBinary parses the given binary slice as a Message. +func (m *Message) UnmarshalBinary(data []byte) error { + if len(data) < 4 { + return errors.New("short packet") + } + + if data[0]>>6 != 1 { + return errors.New("invalid version") + } + + m.Type = COAPType((data[0] >> 4) & 0x3) + tokenLen := int(data[0] & 0xf) + if tokenLen > 8 { + return ErrInvalidTokenLen + } + + m.Code = COAPCode(data[1]) + m.MessageID = binary.BigEndian.Uint16(data[2:4]) + + if tokenLen > 0 { + m.Token = make([]byte, tokenLen) + } + if len(data) < 4+tokenLen { + return errors.New("truncated") + } + copy(m.Token, data[4:4+tokenLen]) + b := data[4+tokenLen:] + prev := 0 + + parseExtOpt := func(opt int) (int, error) { + switch opt { + case extoptByteCode: + if len(b) < 1 { + return -1, errors.New("truncated") + } + opt = int(b[0]) + extoptByteAddend + b = b[1:] + case extoptWordCode: + if len(b) < 2 { + return -1, errors.New("truncated") + } + opt = int(binary.BigEndian.Uint16(b[:2])) + extoptWordAddend + b = b[2:] + } + return opt, nil + } + + for len(b) > 0 { + if b[0] == 0xff { + b = b[1:] + break + } + + delta := int(b[0] >> 4) + length := int(b[0] & 0x0f) + + if delta == extoptError || length == extoptError { + return errors.New("unexpected extended option marker") + } + + b = b[1:] + + delta, err := parseExtOpt(delta) + if err != nil { + return err + } + length, err = parseExtOpt(length) + if err != nil { + return err + } + + if len(b) < length { + return errors.New("truncated") + } + + oid := OptionID(prev + delta) + opval := parseOptionValue(oid, b[:length]) + b = b[length:] + prev = int(oid) + + if opval != nil { + m.opts = append(m.opts, option{ID: oid, Value: opval}) + } + } + m.Payload = b + return nil +} diff --git a/vendor/github.com/dustin/go-coap/messagetcp.go b/vendor/github.com/dustin/go-coap/messagetcp.go new file mode 100644 index 0000000000..09354b975b --- /dev/null +++ b/vendor/github.com/dustin/go-coap/messagetcp.go @@ -0,0 +1,69 @@ +package coap + +import ( + "encoding/binary" + "errors" + "io" +) + +// TcpMessage is a CoAP Message that can encode itself for TCP +// transport. +type TcpMessage struct { + Message +} + +func (m *TcpMessage) MarshalBinary() ([]byte, error) { + bin, err := m.Message.MarshalBinary() + if err != nil { + return nil, err + } + + /* + A CoAP TCP message looks like: + + 0 1 2 3 + 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | Message Length |Ver| T | TKL | Code | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | Token (if any, TKL bytes) ... + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | Options (if any) ... + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + |1 1 1 1 1 1 1 1| Payload (if any) ... + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + */ + + l := []byte{0, 0} + binary.BigEndian.PutUint16(l, uint16(len(bin))) + + return append(l, bin...), nil +} + +func (m *TcpMessage) UnmarshalBinary(data []byte) error { + if len(data) < 4 { + return errors.New("short packet") + } + + return m.Message.UnmarshalBinary(data) +} + +// Decode reads a single message from its input. +func Decode(r io.Reader) (*TcpMessage, error) { + var ln uint16 + err := binary.Read(r, binary.BigEndian, &ln) + if err != nil { + return nil, err + } + + packet := make([]byte, ln) + _, err = io.ReadFull(r, packet) + if err != nil { + return nil, err + } + + m := TcpMessage{} + + err = m.UnmarshalBinary(packet) + return &m, err +} diff --git a/vendor/github.com/dustin/go-coap/server.go b/vendor/github.com/dustin/go-coap/server.go new file mode 100644 index 0000000000..343b875f86 --- /dev/null +++ b/vendor/github.com/dustin/go-coap/server.go @@ -0,0 +1,102 @@ +// Package coap provides a CoAP client and server. +package coap + +import ( + "log" + "net" + "time" +) + +const maxPktLen = 1500 + +// Handler is a type that handles CoAP messages. +type Handler interface { + // Handle the message and optionally return a response message. + ServeCOAP(l *net.UDPConn, a *net.UDPAddr, m *Message) *Message +} + +type funcHandler func(l *net.UDPConn, a *net.UDPAddr, m *Message) *Message + +func (f funcHandler) ServeCOAP(l *net.UDPConn, a *net.UDPAddr, m *Message) *Message { + return f(l, a, m) +} + +// FuncHandler builds a handler from a function. +func FuncHandler(f func(l *net.UDPConn, a *net.UDPAddr, m *Message) *Message) Handler { + return funcHandler(f) +} + +func handlePacket(l *net.UDPConn, data []byte, u *net.UDPAddr, + rh Handler) { + + msg, err := ParseMessage(data) + if err != nil { + log.Printf("Error parsing %v", err) + return + } + + rv := rh.ServeCOAP(l, u, &msg) + if rv != nil { + Transmit(l, u, *rv) + } +} + +// Transmit a message. +func Transmit(l *net.UDPConn, a *net.UDPAddr, m Message) error { + d, err := m.MarshalBinary() + if err != nil { + return err + } + + if a == nil { + _, err = l.Write(d) + } else { + _, err = l.WriteTo(d, a) + } + return err +} + +// Receive a message. +func Receive(l *net.UDPConn, buf []byte) (Message, error) { + l.SetReadDeadline(time.Now().Add(ResponseTimeout)) + + nr, _, err := l.ReadFromUDP(buf) + if err != nil { + return Message{}, err + } + return ParseMessage(buf[:nr]) +} + +// ListenAndServe binds to the given address and serve requests forever. +func ListenAndServe(n, addr string, rh Handler) error { + uaddr, err := net.ResolveUDPAddr(n, addr) + if err != nil { + return err + } + + l, err := net.ListenUDP(n, uaddr) + if err != nil { + return err + } + + return Serve(l, rh) +} + +// Serve processes incoming UDP packets on the given listener, and processes +// these requests forever (or until the listener is closed). +func Serve(listener *net.UDPConn, rh Handler) error { + buf := make([]byte, maxPktLen) + for { + nr, addr, err := listener.ReadFromUDP(buf) + if err != nil { + if neterr, ok := err.(net.Error); ok && (neterr.Temporary() || neterr.Timeout()) { + time.Sleep(5 * time.Millisecond) + continue + } + return err + } + tmp := make([]byte, nr) + copy(tmp, buf) + go handlePacket(listener, tmp, addr, rh) + } +} diff --git a/vendor/github.com/dustin/go-coap/servmux.go b/vendor/github.com/dustin/go-coap/servmux.go new file mode 100644 index 0000000000..23132f1e77 --- /dev/null +++ b/vendor/github.com/dustin/go-coap/servmux.go @@ -0,0 +1,94 @@ +package coap + +import ( + "net" +) + +// ServeMux provides mappings from a common endpoint to handlers by +// request path. +type ServeMux struct { + m map[string]muxEntry +} + +type muxEntry struct { + h Handler + pattern string +} + +// NewServeMux creates a new ServeMux. +func NewServeMux() *ServeMux { return &ServeMux{m: make(map[string]muxEntry)} } + +// Does path match pattern? +func pathMatch(pattern, path string) bool { + if len(pattern) == 0 { + // should not happen + return false + } + n := len(pattern) + if pattern[n-1] != '/' { + return pattern == path + } + return len(path) >= n && path[0:n] == pattern +} + +// Find a handler on a handler map given a path string +// Most-specific (longest) pattern wins +func (mux *ServeMux) match(path string) (h Handler, pattern string) { + var n = 0 + for k, v := range mux.m { + if !pathMatch(k, path) { + continue + } + if h == nil || len(k) > n { + n = len(k) + h = v.h + pattern = v.pattern + } + } + return +} + +func notFoundHandler(l *net.UDPConn, a *net.UDPAddr, m *Message) *Message { + if m.IsConfirmable() { + return &Message{ + Type: Acknowledgement, + Code: NotFound, + } + } + return nil +} + +var _ = Handler(&ServeMux{}) + +// ServeCOAP handles a single COAP message. The message arrives from +// the given listener having originated from the given UDPAddr. +func (mux *ServeMux) ServeCOAP(l *net.UDPConn, a *net.UDPAddr, m *Message) *Message { + h, _ := mux.match(m.PathString()) + if h == nil { + h, _ = funcHandler(notFoundHandler), "" + } + // TODO: Rewrite path? + return h.ServeCOAP(l, a, m) +} + +// Handle configures a handler for the given path. +func (mux *ServeMux) Handle(pattern string, handler Handler) { + for pattern != "" && pattern[0] == '/' { + pattern = pattern[1:] + } + + if pattern == "" { + panic("http: invalid pattern " + pattern) + } + if handler == nil { + panic("http: nil handler") + } + + mux.m[pattern] = muxEntry{h: handler, pattern: pattern} +} + +// HandleFunc configures a handler for the given path. +func (mux *ServeMux) HandleFunc(pattern string, + f func(l *net.UDPConn, a *net.UDPAddr, m *Message) *Message) { + mux.Handle(pattern, FuncHandler(f)) +} diff --git a/vendor/github.com/spf13/cobra/cobra/cmd/license_agpl.go b/vendor/github.com/spf13/cobra/cobra/cmd/license_agpl.go deleted file mode 100644 index bc22e9732b..0000000000 --- a/vendor/github.com/spf13/cobra/cobra/cmd/license_agpl.go +++ /dev/null @@ -1,683 +0,0 @@ -package cmd - -func initAgpl() { - Licenses["agpl"] = License{ - Name: "GNU Affero General Public License", - PossibleMatches: []string{"agpl", "affero gpl", "gnu agpl"}, - Header: ` -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU Affero General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU Affero General Public License for more details. - -You should have received a copy of the GNU Affero General Public License -along with this program. If not, see .`, - Text: ` GNU AFFERO GENERAL PUBLIC LICENSE - Version 3, 19 November 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The GNU Affero General Public License is a free, copyleft license for -software and other kinds of works, specifically designed to ensure -cooperation with the community in the case of network server software. - - The licenses for most software and other practical works are designed -to take away your freedom to share and change the works. By contrast, -our General Public Licenses are intended to guarantee your freedom to -share and change all versions of a program--to make sure it remains free -software for all its users. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -them if you wish), that you receive source code or can get it if you -want it, that you can change the software or use pieces of it in new -free programs, and that you know you can do these things. - - Developers that use our General Public Licenses protect your rights -with two steps: (1) assert copyright on the software, and (2) offer -you this License which gives you legal permission to copy, distribute -and/or modify the software. - - A secondary benefit of defending all users' freedom is that -improvements made in alternate versions of the program, if they -receive widespread use, become available for other developers to -incorporate. Many developers of free software are heartened and -encouraged by the resulting cooperation. However, in the case of -software used on network servers, this result may fail to come about. -The GNU General Public License permits making a modified version and -letting the public access it on a server without ever releasing its -source code to the public. - - The GNU Affero General Public License is designed specifically to -ensure that, in such cases, the modified source code becomes available -to the community. It requires the operator of a network server to -provide the source code of the modified version running there to the -users of that server. Therefore, public use of a modified version, on -a publicly accessible server, gives the public access to the source -code of the modified version. - - An older license, called the Affero General Public License and -published by Affero, was designed to accomplish similar goals. This is -a different license, not a version of the Affero GPL, but Affero has -released a new version of the Affero GPL which permits relicensing under -this license. - - The precise terms and conditions for copying, distribution and -modification follow. - - TERMS AND CONDITIONS - - 0. Definitions. - - "This License" refers to version 3 of the GNU Affero General Public License. - - "Copyright" also means copyright-like laws that apply to other kinds of -works, such as semiconductor masks. - - "The Program" refers to any copyrightable work licensed under this -License. Each licensee is addressed as "you". "Licensees" and -"recipients" may be individuals or organizations. - - To "modify" a work means to copy from or adapt all or part of the work -in a fashion requiring copyright permission, other than the making of an -exact copy. The resulting work is called a "modified version" of the -earlier work or a work "based on" the earlier work. - - A "covered work" means either the unmodified Program or a work based -on the Program. - - To "propagate" a work means to do anything with it that, without -permission, would make you directly or secondarily liable for -infringement under applicable copyright law, except executing it on a -computer or modifying a private copy. Propagation includes copying, -distribution (with or without modification), making available to the -public, and in some countries other activities as well. - - To "convey" a work means any kind of propagation that enables other -parties to make or receive copies. Mere interaction with a user through -a computer network, with no transfer of a copy, is not conveying. - - An interactive user interface displays "Appropriate Legal Notices" -to the extent that it includes a convenient and prominently visible -feature that (1) displays an appropriate copyright notice, and (2) -tells the user that there is no warranty for the work (except to the -extent that warranties are provided), that licensees may convey the -work under this License, and how to view a copy of this License. If -the interface presents a list of user commands or options, such as a -menu, a prominent item in the list meets this criterion. - - 1. Source Code. - - The "source code" for a work means the preferred form of the work -for making modifications to it. "Object code" means any non-source -form of a work. - - A "Standard Interface" means an interface that either is an official -standard defined by a recognized standards body, or, in the case of -interfaces specified for a particular programming language, one that -is widely used among developers working in that language. - - The "System Libraries" of an executable work include anything, other -than the work as a whole, that (a) is included in the normal form of -packaging a Major Component, but which is not part of that Major -Component, and (b) serves only to enable use of the work with that -Major Component, or to implement a Standard Interface for which an -implementation is available to the public in source code form. A -"Major Component", in this context, means a major essential component -(kernel, window system, and so on) of the specific operating system -(if any) on which the executable work runs, or a compiler used to -produce the work, or an object code interpreter used to run it. - - The "Corresponding Source" for a work in object code form means all -the source code needed to generate, install, and (for an executable -work) run the object code and to modify the work, including scripts to -control those activities. However, it does not include the work's -System Libraries, or general-purpose tools or generally available free -programs which are used unmodified in performing those activities but -which are not part of the work. For example, Corresponding Source -includes interface definition files associated with source files for -the work, and the source code for shared libraries and dynamically -linked subprograms that the work is specifically designed to require, -such as by intimate data communication or control flow between those -subprograms and other parts of the work. - - The Corresponding Source need not include anything that users -can regenerate automatically from other parts of the Corresponding -Source. - - The Corresponding Source for a work in source code form is that -same work. - - 2. Basic Permissions. - - All rights granted under this License are granted for the term of -copyright on the Program, and are irrevocable provided the stated -conditions are met. This License explicitly affirms your unlimited -permission to run the unmodified Program. The output from running a -covered work is covered by this License only if the output, given its -content, constitutes a covered work. This License acknowledges your -rights of fair use or other equivalent, as provided by copyright law. - - You may make, run and propagate covered works that you do not -convey, without conditions so long as your license otherwise remains -in force. You may convey covered works to others for the sole purpose -of having them make modifications exclusively for you, or provide you -with facilities for running those works, provided that you comply with -the terms of this License in conveying all material for which you do -not control copyright. Those thus making or running the covered works -for you must do so exclusively on your behalf, under your direction -and control, on terms that prohibit them from making any copies of -your copyrighted material outside their relationship with you. - - Conveying under any other circumstances is permitted solely under -the conditions stated below. Sublicensing is not allowed; section 10 -makes it unnecessary. - - 3. Protecting Users' Legal Rights From Anti-Circumvention Law. - - No covered work shall be deemed part of an effective technological -measure under any applicable law fulfilling obligations under article -11 of the WIPO copyright treaty adopted on 20 December 1996, or -similar laws prohibiting or restricting circumvention of such -measures. - - When you convey a covered work, you waive any legal power to forbid -circumvention of technological measures to the extent such circumvention -is effected by exercising rights under this License with respect to -the covered work, and you disclaim any intention to limit operation or -modification of the work as a means of enforcing, against the work's -users, your or third parties' legal rights to forbid circumvention of -technological measures. - - 4. Conveying Verbatim Copies. - - You may convey verbatim copies of the Program's source code as you -receive it, in any medium, provided that you conspicuously and -appropriately publish on each copy an appropriate copyright notice; -keep intact all notices stating that this License and any -non-permissive terms added in accord with section 7 apply to the code; -keep intact all notices of the absence of any warranty; and give all -recipients a copy of this License along with the Program. - - You may charge any price or no price for each copy that you convey, -and you may offer support or warranty protection for a fee. - - 5. Conveying Modified Source Versions. - - You may convey a work based on the Program, or the modifications to -produce it from the Program, in the form of source code under the -terms of section 4, provided that you also meet all of these conditions: - - a) The work must carry prominent notices stating that you modified - it, and giving a relevant date. - - b) The work must carry prominent notices stating that it is - released under this License and any conditions added under section - 7. This requirement modifies the requirement in section 4 to - "keep intact all notices". - - c) You must license the entire work, as a whole, under this - License to anyone who comes into possession of a copy. This - License will therefore apply, along with any applicable section 7 - additional terms, to the whole of the work, and all its parts, - regardless of how they are packaged. This License gives no - permission to license the work in any other way, but it does not - invalidate such permission if you have separately received it. - - d) If the work has interactive user interfaces, each must display - Appropriate Legal Notices; however, if the Program has interactive - interfaces that do not display Appropriate Legal Notices, your - work need not make them do so. - - A compilation of a covered work with other separate and independent -works, which are not by their nature extensions of the covered work, -and which are not combined with it such as to form a larger program, -in or on a volume of a storage or distribution medium, is called an -"aggregate" if the compilation and its resulting copyright are not -used to limit the access or legal rights of the compilation's users -beyond what the individual works permit. Inclusion of a covered work -in an aggregate does not cause this License to apply to the other -parts of the aggregate. - - 6. Conveying Non-Source Forms. - - You may convey a covered work in object code form under the terms -of sections 4 and 5, provided that you also convey the -machine-readable Corresponding Source under the terms of this License, -in one of these ways: - - a) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by the - Corresponding Source fixed on a durable physical medium - customarily used for software interchange. - - b) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by a - written offer, valid for at least three years and valid for as - long as you offer spare parts or customer support for that product - model, to give anyone who possesses the object code either (1) a - copy of the Corresponding Source for all the software in the - product that is covered by this License, on a durable physical - medium customarily used for software interchange, for a price no - more than your reasonable cost of physically performing this - conveying of source, or (2) access to copy the - Corresponding Source from a network server at no charge. - - c) Convey individual copies of the object code with a copy of the - written offer to provide the Corresponding Source. This - alternative is allowed only occasionally and noncommercially, and - only if you received the object code with such an offer, in accord - with subsection 6b. - - d) Convey the object code by offering access from a designated - place (gratis or for a charge), and offer equivalent access to the - Corresponding Source in the same way through the same place at no - further charge. You need not require recipients to copy the - Corresponding Source along with the object code. If the place to - copy the object code is a network server, the Corresponding Source - may be on a different server (operated by you or a third party) - that supports equivalent copying facilities, provided you maintain - clear directions next to the object code saying where to find the - Corresponding Source. Regardless of what server hosts the - Corresponding Source, you remain obligated to ensure that it is - available for as long as needed to satisfy these requirements. - - e) Convey the object code using peer-to-peer transmission, provided - you inform other peers where the object code and Corresponding - Source of the work are being offered to the general public at no - charge under subsection 6d. - - A separable portion of the object code, whose source code is excluded -from the Corresponding Source as a System Library, need not be -included in conveying the object code work. - - A "User Product" is either (1) a "consumer product", which means any -tangible personal property which is normally used for personal, family, -or household purposes, or (2) anything designed or sold for incorporation -into a dwelling. In determining whether a product is a consumer product, -doubtful cases shall be resolved in favor of coverage. For a particular -product received by a particular user, "normally used" refers to a -typical or common use of that class of product, regardless of the status -of the particular user or of the way in which the particular user -actually uses, or expects or is expected to use, the product. A product -is a consumer product regardless of whether the product has substantial -commercial, industrial or non-consumer uses, unless such uses represent -the only significant mode of use of the product. - - "Installation Information" for a User Product means any methods, -procedures, authorization keys, or other information required to install -and execute modified versions of a covered work in that User Product from -a modified version of its Corresponding Source. The information must -suffice to ensure that the continued functioning of the modified object -code is in no case prevented or interfered with solely because -modification has been made. - - If you convey an object code work under this section in, or with, or -specifically for use in, a User Product, and the conveying occurs as -part of a transaction in which the right of possession and use of the -User Product is transferred to the recipient in perpetuity or for a -fixed term (regardless of how the transaction is characterized), the -Corresponding Source conveyed under this section must be accompanied -by the Installation Information. But this requirement does not apply -if neither you nor any third party retains the ability to install -modified object code on the User Product (for example, the work has -been installed in ROM). - - The requirement to provide Installation Information does not include a -requirement to continue to provide support service, warranty, or updates -for a work that has been modified or installed by the recipient, or for -the User Product in which it has been modified or installed. Access to a -network may be denied when the modification itself materially and -adversely affects the operation of the network or violates the rules and -protocols for communication across the network. - - Corresponding Source conveyed, and Installation Information provided, -in accord with this section must be in a format that is publicly -documented (and with an implementation available to the public in -source code form), and must require no special password or key for -unpacking, reading or copying. - - 7. Additional Terms. - - "Additional permissions" are terms that supplement the terms of this -License by making exceptions from one or more of its conditions. -Additional permissions that are applicable to the entire Program shall -be treated as though they were included in this License, to the extent -that they are valid under applicable law. If additional permissions -apply only to part of the Program, that part may be used separately -under those permissions, but the entire Program remains governed by -this License without regard to the additional permissions. - - When you convey a copy of a covered work, you may at your option -remove any additional permissions from that copy, or from any part of -it. (Additional permissions may be written to require their own -removal in certain cases when you modify the work.) You may place -additional permissions on material, added by you to a covered work, -for which you have or can give appropriate copyright permission. - - Notwithstanding any other provision of this License, for material you -add to a covered work, you may (if authorized by the copyright holders of -that material) supplement the terms of this License with terms: - - a) Disclaiming warranty or limiting liability differently from the - terms of sections 15 and 16 of this License; or - - b) Requiring preservation of specified reasonable legal notices or - author attributions in that material or in the Appropriate Legal - Notices displayed by works containing it; or - - c) Prohibiting misrepresentation of the origin of that material, or - requiring that modified versions of such material be marked in - reasonable ways as different from the original version; or - - d) Limiting the use for publicity purposes of names of licensors or - authors of the material; or - - e) Declining to grant rights under trademark law for use of some - trade names, trademarks, or service marks; or - - f) Requiring indemnification of licensors and authors of that - material by anyone who conveys the material (or modified versions of - it) with contractual assumptions of liability to the recipient, for - any liability that these contractual assumptions directly impose on - those licensors and authors. - - All other non-permissive additional terms are considered "further -restrictions" within the meaning of section 10. If the Program as you -received it, or any part of it, contains a notice stating that it is -governed by this License along with a term that is a further -restriction, you may remove that term. If a license document contains -a further restriction but permits relicensing or conveying under this -License, you may add to a covered work material governed by the terms -of that license document, provided that the further restriction does -not survive such relicensing or conveying. - - If you add terms to a covered work in accord with this section, you -must place, in the relevant source files, a statement of the -additional terms that apply to those files, or a notice indicating -where to find the applicable terms. - - Additional terms, permissive or non-permissive, may be stated in the -form of a separately written license, or stated as exceptions; -the above requirements apply either way. - - 8. Termination. - - You may not propagate or modify a covered work except as expressly -provided under this License. Any attempt otherwise to propagate or -modify it is void, and will automatically terminate your rights under -this License (including any patent licenses granted under the third -paragraph of section 11). - - However, if you cease all violation of this License, then your -license from a particular copyright holder is reinstated (a) -provisionally, unless and until the copyright holder explicitly and -finally terminates your license, and (b) permanently, if the copyright -holder fails to notify you of the violation by some reasonable means -prior to 60 days after the cessation. - - Moreover, your license from a particular copyright holder is -reinstated permanently if the copyright holder notifies you of the -violation by some reasonable means, this is the first time you have -received notice of violation of this License (for any work) from that -copyright holder, and you cure the violation prior to 30 days after -your receipt of the notice. - - Termination of your rights under this section does not terminate the -licenses of parties who have received copies or rights from you under -this License. If your rights have been terminated and not permanently -reinstated, you do not qualify to receive new licenses for the same -material under section 10. - - 9. Acceptance Not Required for Having Copies. - - You are not required to accept this License in order to receive or -run a copy of the Program. Ancillary propagation of a covered work -occurring solely as a consequence of using peer-to-peer transmission -to receive a copy likewise does not require acceptance. However, -nothing other than this License grants you permission to propagate or -modify any covered work. These actions infringe copyright if you do -not accept this License. Therefore, by modifying or propagating a -covered work, you indicate your acceptance of this License to do so. - - 10. Automatic Licensing of Downstream Recipients. - - Each time you convey a covered work, the recipient automatically -receives a license from the original licensors, to run, modify and -propagate that work, subject to this License. You are not responsible -for enforcing compliance by third parties with this License. - - An "entity transaction" is a transaction transferring control of an -organization, or substantially all assets of one, or subdividing an -organization, or merging organizations. If propagation of a covered -work results from an entity transaction, each party to that -transaction who receives a copy of the work also receives whatever -licenses to the work the party's predecessor in interest had or could -give under the previous paragraph, plus a right to possession of the -Corresponding Source of the work from the predecessor in interest, if -the predecessor has it or can get it with reasonable efforts. - - You may not impose any further restrictions on the exercise of the -rights granted or affirmed under this License. For example, you may -not impose a license fee, royalty, or other charge for exercise of -rights granted under this License, and you may not initiate litigation -(including a cross-claim or counterclaim in a lawsuit) alleging that -any patent claim is infringed by making, using, selling, offering for -sale, or importing the Program or any portion of it. - - 11. Patents. - - A "contributor" is a copyright holder who authorizes use under this -License of the Program or a work on which the Program is based. The -work thus licensed is called the contributor's "contributor version". - - A contributor's "essential patent claims" are all patent claims -owned or controlled by the contributor, whether already acquired or -hereafter acquired, that would be infringed by some manner, permitted -by this License, of making, using, or selling its contributor version, -but do not include claims that would be infringed only as a -consequence of further modification of the contributor version. For -purposes of this definition, "control" includes the right to grant -patent sublicenses in a manner consistent with the requirements of -this License. - - Each contributor grants you a non-exclusive, worldwide, royalty-free -patent license under the contributor's essential patent claims, to -make, use, sell, offer for sale, import and otherwise run, modify and -propagate the contents of its contributor version. - - In the following three paragraphs, a "patent license" is any express -agreement or commitment, however denominated, not to enforce a patent -(such as an express permission to practice a patent or covenant not to -sue for patent infringement). To "grant" such a patent license to a -party means to make such an agreement or commitment not to enforce a -patent against the party. - - If you convey a covered work, knowingly relying on a patent license, -and the Corresponding Source of the work is not available for anyone -to copy, free of charge and under the terms of this License, through a -publicly available network server or other readily accessible means, -then you must either (1) cause the Corresponding Source to be so -available, or (2) arrange to deprive yourself of the benefit of the -patent license for this particular work, or (3) arrange, in a manner -consistent with the requirements of this License, to extend the patent -license to downstream recipients. "Knowingly relying" means you have -actual knowledge that, but for the patent license, your conveying the -covered work in a country, or your recipient's use of the covered work -in a country, would infringe one or more identifiable patents in that -country that you have reason to believe are valid. - - If, pursuant to or in connection with a single transaction or -arrangement, you convey, or propagate by procuring conveyance of, a -covered work, and grant a patent license to some of the parties -receiving the covered work authorizing them to use, propagate, modify -or convey a specific copy of the covered work, then the patent license -you grant is automatically extended to all recipients of the covered -work and works based on it. - - A patent license is "discriminatory" if it does not include within -the scope of its coverage, prohibits the exercise of, or is -conditioned on the non-exercise of one or more of the rights that are -specifically granted under this License. You may not convey a covered -work if you are a party to an arrangement with a third party that is -in the business of distributing software, under which you make payment -to the third party based on the extent of your activity of conveying -the work, and under which the third party grants, to any of the -parties who would receive the covered work from you, a discriminatory -patent license (a) in connection with copies of the covered work -conveyed by you (or copies made from those copies), or (b) primarily -for and in connection with specific products or compilations that -contain the covered work, unless you entered into that arrangement, -or that patent license was granted, prior to 28 March 2007. - - Nothing in this License shall be construed as excluding or limiting -any implied license or other defenses to infringement that may -otherwise be available to you under applicable patent law. - - 12. No Surrender of Others' Freedom. - - If conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot convey a -covered work so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you may -not convey it at all. For example, if you agree to terms that obligate you -to collect a royalty for further conveying from those to whom you convey -the Program, the only way you could satisfy both those terms and this -License would be to refrain entirely from conveying the Program. - - 13. Remote Network Interaction; Use with the GNU General Public License. - - Notwithstanding any other provision of this License, if you modify the -Program, your modified version must prominently offer all users -interacting with it remotely through a computer network (if your version -supports such interaction) an opportunity to receive the Corresponding -Source of your version by providing access to the Corresponding Source -from a network server at no charge, through some standard or customary -means of facilitating copying of software. This Corresponding Source -shall include the Corresponding Source for any work covered by version 3 -of the GNU General Public License that is incorporated pursuant to the -following paragraph. - - Notwithstanding any other provision of this License, you have -permission to link or combine any covered work with a work licensed -under version 3 of the GNU General Public License into a single -combined work, and to convey the resulting work. The terms of this -License will continue to apply to the part which is the covered work, -but the work with which it is combined will remain governed by version -3 of the GNU General Public License. - - 14. Revised Versions of this License. - - The Free Software Foundation may publish revised and/or new versions of -the GNU Affero General Public License from time to time. Such new versions -will be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - - Each version is given a distinguishing version number. If the -Program specifies that a certain numbered version of the GNU Affero General -Public License "or any later version" applies to it, you have the -option of following the terms and conditions either of that numbered -version or of any later version published by the Free Software -Foundation. If the Program does not specify a version number of the -GNU Affero General Public License, you may choose any version ever published -by the Free Software Foundation. - - If the Program specifies that a proxy can decide which future -versions of the GNU Affero General Public License can be used, that proxy's -public statement of acceptance of a version permanently authorizes you -to choose that version for the Program. - - Later license versions may give you additional or different -permissions. However, no additional obligations are imposed on any -author or copyright holder as a result of your choosing to follow a -later version. - - 15. Disclaimer of Warranty. - - THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY -APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT -HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY -OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, -THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM -IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF -ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. Limitation of Liability. - - IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS -THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY -GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE -USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF -DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD -PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), -EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF -SUCH DAMAGES. - - 17. Interpretation of Sections 15 and 16. - - If the disclaimer of warranty and limitation of liability provided -above cannot be given local legal effect according to their terms, -reviewing courts shall apply local law that most closely approximates -an absolute waiver of all civil liability in connection with the -Program, unless a warranty or assumption of liability accompanies a -copy of the Program in return for a fee. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -state the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . - -Also add information on how to contact you by electronic and paper mail. - - If your software can interact with users remotely through a computer -network, you should also make sure that it provides a way for users to -get its source. For example, if your program is a web application, its -interface could display a "Source" link that leads users to an archive -of the code. There are many ways you could offer source, and different -solutions will be better for different programs; see section 13 for the -specific requirements. - - You should also get your employer (if you work as a programmer) or school, -if any, to sign a "copyright disclaimer" for the program, if necessary. -For more information on this, and how to apply and follow the GNU AGPL, see -. -`, - } -} diff --git a/vendor/github.com/spf13/cobra/cobra/cmd/license_apache_2.go b/vendor/github.com/spf13/cobra/cobra/cmd/license_apache_2.go deleted file mode 100644 index 38393d5417..0000000000 --- a/vendor/github.com/spf13/cobra/cobra/cmd/license_apache_2.go +++ /dev/null @@ -1,238 +0,0 @@ -// Copyright © 2015 Steve Francia . -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Parts inspired by https://github.com/ryanuber/go-license - -package cmd - -func initApache2() { - Licenses["apache"] = License{ - Name: "Apache 2.0", - PossibleMatches: []string{"apache", "apache20", "apache 2.0", "apache2.0", "apache-2.0"}, - Header: ` -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License.`, - Text: ` - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -`, - } -} diff --git a/vendor/github.com/spf13/cobra/cobra/cmd/license_bsd_clause_2.go b/vendor/github.com/spf13/cobra/cobra/cmd/license_bsd_clause_2.go deleted file mode 100644 index 4a847e04a0..0000000000 --- a/vendor/github.com/spf13/cobra/cobra/cmd/license_bsd_clause_2.go +++ /dev/null @@ -1,71 +0,0 @@ -// Copyright © 2015 Steve Francia . -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Parts inspired by https://github.com/ryanuber/go-license - -package cmd - -func initBsdClause2() { - Licenses["freebsd"] = License{ - Name: "Simplified BSD License", - PossibleMatches: []string{"freebsd", "simpbsd", "simple bsd", "2-clause bsd", - "2 clause bsd", "simplified bsd license"}, - Header: `All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - -1. Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - -2. Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE -LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -POSSIBILITY OF SUCH DAMAGE.`, - Text: `{{ .copyright }} -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - -1. Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - -2. Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -`, - } -} diff --git a/vendor/github.com/spf13/cobra/cobra/cmd/license_bsd_clause_3.go b/vendor/github.com/spf13/cobra/cobra/cmd/license_bsd_clause_3.go deleted file mode 100644 index c7476b31f5..0000000000 --- a/vendor/github.com/spf13/cobra/cobra/cmd/license_bsd_clause_3.go +++ /dev/null @@ -1,78 +0,0 @@ -// Copyright © 2015 Steve Francia . -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Parts inspired by https://github.com/ryanuber/go-license - -package cmd - -func initBsdClause3() { - Licenses["bsd"] = License{ - Name: "NewBSD", - PossibleMatches: []string{"bsd", "newbsd", "3 clause bsd", "3-clause bsd"}, - Header: `All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - -1. Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - -2. Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - -3. Neither the name of the copyright holder nor the names of its contributors - may be used to endorse or promote products derived from this software - without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE -LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -POSSIBILITY OF SUCH DAMAGE.`, - Text: `{{ .copyright }} -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - -1. Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - -2. Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - -3. Neither the name of the copyright holder nor the names of its contributors - may be used to endorse or promote products derived from this software - without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -`, - } -} diff --git a/vendor/github.com/spf13/cobra/cobra/cmd/license_gpl_2.go b/vendor/github.com/spf13/cobra/cobra/cmd/license_gpl_2.go deleted file mode 100644 index 03e05b3a7e..0000000000 --- a/vendor/github.com/spf13/cobra/cobra/cmd/license_gpl_2.go +++ /dev/null @@ -1,376 +0,0 @@ -// Copyright © 2015 Steve Francia . -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Parts inspired by https://github.com/ryanuber/go-license - -package cmd - -func initGpl2() { - Licenses["gpl2"] = License{ - Name: "GNU General Public License 2.0", - PossibleMatches: []string{"gpl2", "gnu gpl2", "gplv2"}, - Header: ` -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU Lesser General Public License -along with this program. If not, see .`, - Text: ` GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 - - Copyright (C) 1989, 1991 Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -License is intended to guarantee your freedom to share and change free -software--to make sure the software is free for all its users. This -General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit to -using it. (Some other Free Software Foundation software is covered by -the GNU Lesser General Public License instead.) You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -this service if you wish), that you receive source code or can get it -if you want it, that you can change the software or use pieces of it -in new free programs; and that you know you can do these things. - - To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. You must make sure that they, too, receive or can get the -source code. And you must show them these terms so they know their -rights. - - We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. - - Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. - - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that redistributors of a free -program will individually obtain patent licenses, in effect making the -program proprietary. To prevent this, we have made it clear that any -patent must be licensed for everyone's free use or not licensed at all. - - The precise terms and conditions for copying, distribution and -modification follow. - - GNU GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License applies to any program or other work which contains -a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The "Program", below, -refers to any such program or work, and a "work based on the Program" -means either the Program or any derivative work under copyright law: -that is to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into another -language. (Hereinafter, translation is included without limitation in -the term "modification".) Each licensee is addressed as "you". - -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running the Program is not restricted, and the output from the Program -is covered only if its contents constitute a work based on the -Program (independent of having been made by running the Program). -Whether that is true depends on what the Program does. - - 1. You may copy and distribute verbatim copies of the Program's -source code as you receive it, in any medium, provided that you -conspicuously and appropriately publish on each copy an appropriate -copyright notice and disclaimer of warranty; keep intact all the -notices that refer to this License and to the absence of any warranty; -and give any other recipients of the Program a copy of this License -along with the Program. - -You may charge a fee for the physical act of transferring a copy, and -you may at your option offer warranty protection in exchange for a fee. - - 2. You may modify your copy or copies of the Program or any portion -of it, thus forming a work based on the Program, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) You must cause the modified files to carry prominent notices - stating that you changed the files and the date of any change. - - b) You must cause any work that you distribute or publish, that in - whole or in part contains or is derived from the Program or any - part thereof, to be licensed as a whole at no charge to all third - parties under the terms of this License. - - c) If the modified program normally reads commands interactively - when run, you must cause it, when started running for such - interactive use in the most ordinary way, to print or display an - announcement including an appropriate copyright notice and a - notice that there is no warranty (or else, saying that you provide - a warranty) and that users may redistribute the program under - these conditions, and telling the user how to view a copy of this - License. (Exception: if the Program itself is interactive but - does not normally print such an announcement, your work based on - the Program is not required to print an announcement.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Program, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Program, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Program. - -In addition, mere aggregation of another work not based on the Program -with the Program (or with a work based on the Program) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may copy and distribute the Program (or a work based on it, -under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you also do one of the following: - - a) Accompany it with the complete corresponding machine-readable - source code, which must be distributed under the terms of Sections - 1 and 2 above on a medium customarily used for software interchange; or, - - b) Accompany it with a written offer, valid for at least three - years, to give any third party, for a charge no more than your - cost of physically performing source distribution, a complete - machine-readable copy of the corresponding source code, to be - distributed under the terms of Sections 1 and 2 above on a medium - customarily used for software interchange; or, - - c) Accompany it with the information you received as to the offer - to distribute corresponding source code. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form with such - an offer, in accord with Subsection b above.) - -The source code for a work means the preferred form of the work for -making modifications to it. For an executable work, complete source -code means all the source code for all modules it contains, plus any -associated interface definition files, plus the scripts used to -control compilation and installation of the executable. However, as a -special exception, the source code distributed need not include -anything that is normally distributed (in either source or binary -form) with the major components (compiler, kernel, and so on) of the -operating system on which the executable runs, unless that component -itself accompanies the executable. - -If distribution of executable or object code is made by offering -access to copy from a designated place, then offering equivalent -access to copy the source code from the same place counts as -distribution of the source code, even though third parties are not -compelled to copy the source along with the object code. - - 4. You may not copy, modify, sublicense, or distribute the Program -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense or distribute the Program is -void, and will automatically terminate your rights under this License. -However, parties who have received copies, or rights, from you under -this License will not have their licenses terminated so long as such -parties remain in full compliance. - - 5. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Program or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Program (or any work based on the -Program), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Program or works based on it. - - 6. Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the -original licensor to copy, distribute or modify the Program subject to -these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to -this License. - - 7. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Program at all. For example, if a patent -license would not permit royalty-free redistribution of the Program by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. - -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply and the section as a whole is intended to apply in other -circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system, which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 8. If the distribution and/or use of the Program is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Program under this License -may add an explicit geographical distribution limitation excluding -those countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - - 9. The Free Software Foundation may publish revised and/or new versions -of the General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - -Each version is given a distinguishing version number. If the Program -specifies a version number of this License which applies to it and "any -later version", you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -this License, you may choose any version ever published by the Free Software -Foundation. - - 10. If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. - - NO WARRANTY - - 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED -OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS -TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, -REPAIR OR CORRECTION. - - 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, -INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING -OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED -TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY -YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER -PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE -POSSIBILITY OF SUCH DAMAGES. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -Also add information on how to contact you by electronic and paper mail. - -If the program is interactive, make it output a short notice like this -when it starts in an interactive mode: - - Gnomovision version 69, Copyright (C) year name of author - Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type 'show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type 'show c' for details. - -The hypothetical commands 'show w' and 'show c' should show the appropriate -parts of the General Public License. Of course, the commands you use may -be called something other than 'show w' and 'show c'; they could even be -mouse-clicks or menu items--whatever suits your program. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the program, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the program - 'Gnomovision' (which makes passes at compilers) written by James Hacker. - - , 1 April 1989 - Ty Coon, President of Vice - -This General Public License does not permit incorporating your program into -proprietary programs. If your program is a subroutine library, you may -consider it more useful to permit linking proprietary applications with the -library. If this is what you want to do, use the GNU Lesser General -Public License instead of this License. -`, - } -} diff --git a/vendor/github.com/spf13/cobra/cobra/cmd/license_gpl_3.go b/vendor/github.com/spf13/cobra/cobra/cmd/license_gpl_3.go deleted file mode 100644 index ce07679c77..0000000000 --- a/vendor/github.com/spf13/cobra/cobra/cmd/license_gpl_3.go +++ /dev/null @@ -1,711 +0,0 @@ -// Copyright © 2015 Steve Francia . -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Parts inspired by https://github.com/ryanuber/go-license - -package cmd - -func initGpl3() { - Licenses["gpl3"] = License{ - Name: "GNU General Public License 3.0", - PossibleMatches: []string{"gpl3", "gplv3", "gpl", "gnu gpl3", "gnu gpl"}, - Header: ` -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see .`, - Text: ` GNU GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The GNU General Public License is a free, copyleft license for -software and other kinds of works. - - The licenses for most software and other practical works are designed -to take away your freedom to share and change the works. By contrast, -the GNU General Public License is intended to guarantee your freedom to -share and change all versions of a program--to make sure it remains free -software for all its users. We, the Free Software Foundation, use the -GNU General Public License for most of our software; it applies also to -any other work released this way by its authors. You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -them if you wish), that you receive source code or can get it if you -want it, that you can change the software or use pieces of it in new -free programs, and that you know you can do these things. - - To protect your rights, we need to prevent others from denying you -these rights or asking you to surrender the rights. Therefore, you have -certain responsibilities if you distribute copies of the software, or if -you modify it: responsibilities to respect the freedom of others. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must pass on to the recipients the same -freedoms that you received. You must make sure that they, too, receive -or can get the source code. And you must show them these terms so they -know their rights. - - Developers that use the GNU GPL protect your rights with two steps: -(1) assert copyright on the software, and (2) offer you this License -giving you legal permission to copy, distribute and/or modify it. - - For the developers' and authors' protection, the GPL clearly explains -that there is no warranty for this free software. For both users' and -authors' sake, the GPL requires that modified versions be marked as -changed, so that their problems will not be attributed erroneously to -authors of previous versions. - - Some devices are designed to deny users access to install or run -modified versions of the software inside them, although the manufacturer -can do so. This is fundamentally incompatible with the aim of -protecting users' freedom to change the software. The systematic -pattern of such abuse occurs in the area of products for individuals to -use, which is precisely where it is most unacceptable. Therefore, we -have designed this version of the GPL to prohibit the practice for those -products. If such problems arise substantially in other domains, we -stand ready to extend this provision to those domains in future versions -of the GPL, as needed to protect the freedom of users. - - Finally, every program is threatened constantly by software patents. -States should not allow patents to restrict development and use of -software on general-purpose computers, but in those that do, we wish to -avoid the special danger that patents applied to a free program could -make it effectively proprietary. To prevent this, the GPL assures that -patents cannot be used to render the program non-free. - - The precise terms and conditions for copying, distribution and -modification follow. - - TERMS AND CONDITIONS - - 0. Definitions. - - "This License" refers to version 3 of the GNU General Public License. - - "Copyright" also means copyright-like laws that apply to other kinds of -works, such as semiconductor masks. - - "The Program" refers to any copyrightable work licensed under this -License. Each licensee is addressed as "you". "Licensees" and -"recipients" may be individuals or organizations. - - To "modify" a work means to copy from or adapt all or part of the work -in a fashion requiring copyright permission, other than the making of an -exact copy. The resulting work is called a "modified version" of the -earlier work or a work "based on" the earlier work. - - A "covered work" means either the unmodified Program or a work based -on the Program. - - To "propagate" a work means to do anything with it that, without -permission, would make you directly or secondarily liable for -infringement under applicable copyright law, except executing it on a -computer or modifying a private copy. Propagation includes copying, -distribution (with or without modification), making available to the -public, and in some countries other activities as well. - - To "convey" a work means any kind of propagation that enables other -parties to make or receive copies. Mere interaction with a user through -a computer network, with no transfer of a copy, is not conveying. - - An interactive user interface displays "Appropriate Legal Notices" -to the extent that it includes a convenient and prominently visible -feature that (1) displays an appropriate copyright notice, and (2) -tells the user that there is no warranty for the work (except to the -extent that warranties are provided), that licensees may convey the -work under this License, and how to view a copy of this License. If -the interface presents a list of user commands or options, such as a -menu, a prominent item in the list meets this criterion. - - 1. Source Code. - - The "source code" for a work means the preferred form of the work -for making modifications to it. "Object code" means any non-source -form of a work. - - A "Standard Interface" means an interface that either is an official -standard defined by a recognized standards body, or, in the case of -interfaces specified for a particular programming language, one that -is widely used among developers working in that language. - - The "System Libraries" of an executable work include anything, other -than the work as a whole, that (a) is included in the normal form of -packaging a Major Component, but which is not part of that Major -Component, and (b) serves only to enable use of the work with that -Major Component, or to implement a Standard Interface for which an -implementation is available to the public in source code form. A -"Major Component", in this context, means a major essential component -(kernel, window system, and so on) of the specific operating system -(if any) on which the executable work runs, or a compiler used to -produce the work, or an object code interpreter used to run it. - - The "Corresponding Source" for a work in object code form means all -the source code needed to generate, install, and (for an executable -work) run the object code and to modify the work, including scripts to -control those activities. However, it does not include the work's -System Libraries, or general-purpose tools or generally available free -programs which are used unmodified in performing those activities but -which are not part of the work. For example, Corresponding Source -includes interface definition files associated with source files for -the work, and the source code for shared libraries and dynamically -linked subprograms that the work is specifically designed to require, -such as by intimate data communication or control flow between those -subprograms and other parts of the work. - - The Corresponding Source need not include anything that users -can regenerate automatically from other parts of the Corresponding -Source. - - The Corresponding Source for a work in source code form is that -same work. - - 2. Basic Permissions. - - All rights granted under this License are granted for the term of -copyright on the Program, and are irrevocable provided the stated -conditions are met. This License explicitly affirms your unlimited -permission to run the unmodified Program. The output from running a -covered work is covered by this License only if the output, given its -content, constitutes a covered work. This License acknowledges your -rights of fair use or other equivalent, as provided by copyright law. - - You may make, run and propagate covered works that you do not -convey, without conditions so long as your license otherwise remains -in force. You may convey covered works to others for the sole purpose -of having them make modifications exclusively for you, or provide you -with facilities for running those works, provided that you comply with -the terms of this License in conveying all material for which you do -not control copyright. Those thus making or running the covered works -for you must do so exclusively on your behalf, under your direction -and control, on terms that prohibit them from making any copies of -your copyrighted material outside their relationship with you. - - Conveying under any other circumstances is permitted solely under -the conditions stated below. Sublicensing is not allowed; section 10 -makes it unnecessary. - - 3. Protecting Users' Legal Rights From Anti-Circumvention Law. - - No covered work shall be deemed part of an effective technological -measure under any applicable law fulfilling obligations under article -11 of the WIPO copyright treaty adopted on 20 December 1996, or -similar laws prohibiting or restricting circumvention of such -measures. - - When you convey a covered work, you waive any legal power to forbid -circumvention of technological measures to the extent such circumvention -is effected by exercising rights under this License with respect to -the covered work, and you disclaim any intention to limit operation or -modification of the work as a means of enforcing, against the work's -users, your or third parties' legal rights to forbid circumvention of -technological measures. - - 4. Conveying Verbatim Copies. - - You may convey verbatim copies of the Program's source code as you -receive it, in any medium, provided that you conspicuously and -appropriately publish on each copy an appropriate copyright notice; -keep intact all notices stating that this License and any -non-permissive terms added in accord with section 7 apply to the code; -keep intact all notices of the absence of any warranty; and give all -recipients a copy of this License along with the Program. - - You may charge any price or no price for each copy that you convey, -and you may offer support or warranty protection for a fee. - - 5. Conveying Modified Source Versions. - - You may convey a work based on the Program, or the modifications to -produce it from the Program, in the form of source code under the -terms of section 4, provided that you also meet all of these conditions: - - a) The work must carry prominent notices stating that you modified - it, and giving a relevant date. - - b) The work must carry prominent notices stating that it is - released under this License and any conditions added under section - 7. This requirement modifies the requirement in section 4 to - "keep intact all notices". - - c) You must license the entire work, as a whole, under this - License to anyone who comes into possession of a copy. This - License will therefore apply, along with any applicable section 7 - additional terms, to the whole of the work, and all its parts, - regardless of how they are packaged. This License gives no - permission to license the work in any other way, but it does not - invalidate such permission if you have separately received it. - - d) If the work has interactive user interfaces, each must display - Appropriate Legal Notices; however, if the Program has interactive - interfaces that do not display Appropriate Legal Notices, your - work need not make them do so. - - A compilation of a covered work with other separate and independent -works, which are not by their nature extensions of the covered work, -and which are not combined with it such as to form a larger program, -in or on a volume of a storage or distribution medium, is called an -"aggregate" if the compilation and its resulting copyright are not -used to limit the access or legal rights of the compilation's users -beyond what the individual works permit. Inclusion of a covered work -in an aggregate does not cause this License to apply to the other -parts of the aggregate. - - 6. Conveying Non-Source Forms. - - You may convey a covered work in object code form under the terms -of sections 4 and 5, provided that you also convey the -machine-readable Corresponding Source under the terms of this License, -in one of these ways: - - a) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by the - Corresponding Source fixed on a durable physical medium - customarily used for software interchange. - - b) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by a - written offer, valid for at least three years and valid for as - long as you offer spare parts or customer support for that product - model, to give anyone who possesses the object code either (1) a - copy of the Corresponding Source for all the software in the - product that is covered by this License, on a durable physical - medium customarily used for software interchange, for a price no - more than your reasonable cost of physically performing this - conveying of source, or (2) access to copy the - Corresponding Source from a network server at no charge. - - c) Convey individual copies of the object code with a copy of the - written offer to provide the Corresponding Source. This - alternative is allowed only occasionally and noncommercially, and - only if you received the object code with such an offer, in accord - with subsection 6b. - - d) Convey the object code by offering access from a designated - place (gratis or for a charge), and offer equivalent access to the - Corresponding Source in the same way through the same place at no - further charge. You need not require recipients to copy the - Corresponding Source along with the object code. If the place to - copy the object code is a network server, the Corresponding Source - may be on a different server (operated by you or a third party) - that supports equivalent copying facilities, provided you maintain - clear directions next to the object code saying where to find the - Corresponding Source. Regardless of what server hosts the - Corresponding Source, you remain obligated to ensure that it is - available for as long as needed to satisfy these requirements. - - e) Convey the object code using peer-to-peer transmission, provided - you inform other peers where the object code and Corresponding - Source of the work are being offered to the general public at no - charge under subsection 6d. - - A separable portion of the object code, whose source code is excluded -from the Corresponding Source as a System Library, need not be -included in conveying the object code work. - - A "User Product" is either (1) a "consumer product", which means any -tangible personal property which is normally used for personal, family, -or household purposes, or (2) anything designed or sold for incorporation -into a dwelling. In determining whether a product is a consumer product, -doubtful cases shall be resolved in favor of coverage. For a particular -product received by a particular user, "normally used" refers to a -typical or common use of that class of product, regardless of the status -of the particular user or of the way in which the particular user -actually uses, or expects or is expected to use, the product. A product -is a consumer product regardless of whether the product has substantial -commercial, industrial or non-consumer uses, unless such uses represent -the only significant mode of use of the product. - - "Installation Information" for a User Product means any methods, -procedures, authorization keys, or other information required to install -and execute modified versions of a covered work in that User Product from -a modified version of its Corresponding Source. The information must -suffice to ensure that the continued functioning of the modified object -code is in no case prevented or interfered with solely because -modification has been made. - - If you convey an object code work under this section in, or with, or -specifically for use in, a User Product, and the conveying occurs as -part of a transaction in which the right of possession and use of the -User Product is transferred to the recipient in perpetuity or for a -fixed term (regardless of how the transaction is characterized), the -Corresponding Source conveyed under this section must be accompanied -by the Installation Information. But this requirement does not apply -if neither you nor any third party retains the ability to install -modified object code on the User Product (for example, the work has -been installed in ROM). - - The requirement to provide Installation Information does not include a -requirement to continue to provide support service, warranty, or updates -for a work that has been modified or installed by the recipient, or for -the User Product in which it has been modified or installed. Access to a -network may be denied when the modification itself materially and -adversely affects the operation of the network or violates the rules and -protocols for communication across the network. - - Corresponding Source conveyed, and Installation Information provided, -in accord with this section must be in a format that is publicly -documented (and with an implementation available to the public in -source code form), and must require no special password or key for -unpacking, reading or copying. - - 7. Additional Terms. - - "Additional permissions" are terms that supplement the terms of this -License by making exceptions from one or more of its conditions. -Additional permissions that are applicable to the entire Program shall -be treated as though they were included in this License, to the extent -that they are valid under applicable law. If additional permissions -apply only to part of the Program, that part may be used separately -under those permissions, but the entire Program remains governed by -this License without regard to the additional permissions. - - When you convey a copy of a covered work, you may at your option -remove any additional permissions from that copy, or from any part of -it. (Additional permissions may be written to require their own -removal in certain cases when you modify the work.) You may place -additional permissions on material, added by you to a covered work, -for which you have or can give appropriate copyright permission. - - Notwithstanding any other provision of this License, for material you -add to a covered work, you may (if authorized by the copyright holders of -that material) supplement the terms of this License with terms: - - a) Disclaiming warranty or limiting liability differently from the - terms of sections 15 and 16 of this License; or - - b) Requiring preservation of specified reasonable legal notices or - author attributions in that material or in the Appropriate Legal - Notices displayed by works containing it; or - - c) Prohibiting misrepresentation of the origin of that material, or - requiring that modified versions of such material be marked in - reasonable ways as different from the original version; or - - d) Limiting the use for publicity purposes of names of licensors or - authors of the material; or - - e) Declining to grant rights under trademark law for use of some - trade names, trademarks, or service marks; or - - f) Requiring indemnification of licensors and authors of that - material by anyone who conveys the material (or modified versions of - it) with contractual assumptions of liability to the recipient, for - any liability that these contractual assumptions directly impose on - those licensors and authors. - - All other non-permissive additional terms are considered "further -restrictions" within the meaning of section 10. If the Program as you -received it, or any part of it, contains a notice stating that it is -governed by this License along with a term that is a further -restriction, you may remove that term. If a license document contains -a further restriction but permits relicensing or conveying under this -License, you may add to a covered work material governed by the terms -of that license document, provided that the further restriction does -not survive such relicensing or conveying. - - If you add terms to a covered work in accord with this section, you -must place, in the relevant source files, a statement of the -additional terms that apply to those files, or a notice indicating -where to find the applicable terms. - - Additional terms, permissive or non-permissive, may be stated in the -form of a separately written license, or stated as exceptions; -the above requirements apply either way. - - 8. Termination. - - You may not propagate or modify a covered work except as expressly -provided under this License. Any attempt otherwise to propagate or -modify it is void, and will automatically terminate your rights under -this License (including any patent licenses granted under the third -paragraph of section 11). - - However, if you cease all violation of this License, then your -license from a particular copyright holder is reinstated (a) -provisionally, unless and until the copyright holder explicitly and -finally terminates your license, and (b) permanently, if the copyright -holder fails to notify you of the violation by some reasonable means -prior to 60 days after the cessation. - - Moreover, your license from a particular copyright holder is -reinstated permanently if the copyright holder notifies you of the -violation by some reasonable means, this is the first time you have -received notice of violation of this License (for any work) from that -copyright holder, and you cure the violation prior to 30 days after -your receipt of the notice. - - Termination of your rights under this section does not terminate the -licenses of parties who have received copies or rights from you under -this License. If your rights have been terminated and not permanently -reinstated, you do not qualify to receive new licenses for the same -material under section 10. - - 9. Acceptance Not Required for Having Copies. - - You are not required to accept this License in order to receive or -run a copy of the Program. Ancillary propagation of a covered work -occurring solely as a consequence of using peer-to-peer transmission -to receive a copy likewise does not require acceptance. However, -nothing other than this License grants you permission to propagate or -modify any covered work. These actions infringe copyright if you do -not accept this License. Therefore, by modifying or propagating a -covered work, you indicate your acceptance of this License to do so. - - 10. Automatic Licensing of Downstream Recipients. - - Each time you convey a covered work, the recipient automatically -receives a license from the original licensors, to run, modify and -propagate that work, subject to this License. You are not responsible -for enforcing compliance by third parties with this License. - - An "entity transaction" is a transaction transferring control of an -organization, or substantially all assets of one, or subdividing an -organization, or merging organizations. If propagation of a covered -work results from an entity transaction, each party to that -transaction who receives a copy of the work also receives whatever -licenses to the work the party's predecessor in interest had or could -give under the previous paragraph, plus a right to possession of the -Corresponding Source of the work from the predecessor in interest, if -the predecessor has it or can get it with reasonable efforts. - - You may not impose any further restrictions on the exercise of the -rights granted or affirmed under this License. For example, you may -not impose a license fee, royalty, or other charge for exercise of -rights granted under this License, and you may not initiate litigation -(including a cross-claim or counterclaim in a lawsuit) alleging that -any patent claim is infringed by making, using, selling, offering for -sale, or importing the Program or any portion of it. - - 11. Patents. - - A "contributor" is a copyright holder who authorizes use under this -License of the Program or a work on which the Program is based. The -work thus licensed is called the contributor's "contributor version". - - A contributor's "essential patent claims" are all patent claims -owned or controlled by the contributor, whether already acquired or -hereafter acquired, that would be infringed by some manner, permitted -by this License, of making, using, or selling its contributor version, -but do not include claims that would be infringed only as a -consequence of further modification of the contributor version. For -purposes of this definition, "control" includes the right to grant -patent sublicenses in a manner consistent with the requirements of -this License. - - Each contributor grants you a non-exclusive, worldwide, royalty-free -patent license under the contributor's essential patent claims, to -make, use, sell, offer for sale, import and otherwise run, modify and -propagate the contents of its contributor version. - - In the following three paragraphs, a "patent license" is any express -agreement or commitment, however denominated, not to enforce a patent -(such as an express permission to practice a patent or covenant not to -sue for patent infringement). To "grant" such a patent license to a -party means to make such an agreement or commitment not to enforce a -patent against the party. - - If you convey a covered work, knowingly relying on a patent license, -and the Corresponding Source of the work is not available for anyone -to copy, free of charge and under the terms of this License, through a -publicly available network server or other readily accessible means, -then you must either (1) cause the Corresponding Source to be so -available, or (2) arrange to deprive yourself of the benefit of the -patent license for this particular work, or (3) arrange, in a manner -consistent with the requirements of this License, to extend the patent -license to downstream recipients. "Knowingly relying" means you have -actual knowledge that, but for the patent license, your conveying the -covered work in a country, or your recipient's use of the covered work -in a country, would infringe one or more identifiable patents in that -country that you have reason to believe are valid. - - If, pursuant to or in connection with a single transaction or -arrangement, you convey, or propagate by procuring conveyance of, a -covered work, and grant a patent license to some of the parties -receiving the covered work authorizing them to use, propagate, modify -or convey a specific copy of the covered work, then the patent license -you grant is automatically extended to all recipients of the covered -work and works based on it. - - A patent license is "discriminatory" if it does not include within -the scope of its coverage, prohibits the exercise of, or is -conditioned on the non-exercise of one or more of the rights that are -specifically granted under this License. You may not convey a covered -work if you are a party to an arrangement with a third party that is -in the business of distributing software, under which you make payment -to the third party based on the extent of your activity of conveying -the work, and under which the third party grants, to any of the -parties who would receive the covered work from you, a discriminatory -patent license (a) in connection with copies of the covered work -conveyed by you (or copies made from those copies), or (b) primarily -for and in connection with specific products or compilations that -contain the covered work, unless you entered into that arrangement, -or that patent license was granted, prior to 28 March 2007. - - Nothing in this License shall be construed as excluding or limiting -any implied license or other defenses to infringement that may -otherwise be available to you under applicable patent law. - - 12. No Surrender of Others' Freedom. - - If conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot convey a -covered work so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you may -not convey it at all. For example, if you agree to terms that obligate you -to collect a royalty for further conveying from those to whom you convey -the Program, the only way you could satisfy both those terms and this -License would be to refrain entirely from conveying the Program. - - 13. Use with the GNU Affero General Public License. - - Notwithstanding any other provision of this License, you have -permission to link or combine any covered work with a work licensed -under version 3 of the GNU Affero General Public License into a single -combined work, and to convey the resulting work. The terms of this -License will continue to apply to the part which is the covered work, -but the special requirements of the GNU Affero General Public License, -section 13, concerning interaction through a network will apply to the -combination as such. - - 14. Revised Versions of this License. - - The Free Software Foundation may publish revised and/or new versions of -the GNU General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - - Each version is given a distinguishing version number. If the -Program specifies that a certain numbered version of the GNU General -Public License "or any later version" applies to it, you have the -option of following the terms and conditions either of that numbered -version or of any later version published by the Free Software -Foundation. If the Program does not specify a version number of the -GNU General Public License, you may choose any version ever published -by the Free Software Foundation. - - If the Program specifies that a proxy can decide which future -versions of the GNU General Public License can be used, that proxy's -public statement of acceptance of a version permanently authorizes you -to choose that version for the Program. - - Later license versions may give you additional or different -permissions. However, no additional obligations are imposed on any -author or copyright holder as a result of your choosing to follow a -later version. - - 15. Disclaimer of Warranty. - - THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY -APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT -HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY -OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, -THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM -IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF -ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. Limitation of Liability. - - IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS -THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY -GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE -USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF -DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD -PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), -EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF -SUCH DAMAGES. - - 17. Interpretation of Sections 15 and 16. - - If the disclaimer of warranty and limitation of liability provided -above cannot be given local legal effect according to their terms, -reviewing courts shall apply local law that most closely approximates -an absolute waiver of all civil liability in connection with the -Program, unless a warranty or assumption of liability accompanies a -copy of the Program in return for a fee. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -state the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . - -Also add information on how to contact you by electronic and paper mail. - - If the program does terminal interaction, make it output a short -notice like this when it starts in an interactive mode: - - Copyright (C) - This program comes with ABSOLUTELY NO WARRANTY; for details type 'show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type 'show c' for details. - -The hypothetical commands 'show w' and 'show c' should show the appropriate -parts of the General Public License. Of course, your program's commands -might be different; for a GUI interface, you would use an "about box". - - You should also get your employer (if you work as a programmer) or school, -if any, to sign a "copyright disclaimer" for the program, if necessary. -For more information on this, and how to apply and follow the GNU GPL, see -. - - The GNU General Public License does not permit incorporating your program -into proprietary programs. If your program is a subroutine library, you -may consider it more useful to permit linking proprietary applications with -the library. If this is what you want to do, use the GNU Lesser General -Public License instead of this License. But first, please read -. -`, - } -} diff --git a/vendor/github.com/spf13/cobra/cobra/cmd/license_lgpl.go b/vendor/github.com/spf13/cobra/cobra/cmd/license_lgpl.go deleted file mode 100644 index 0f8b96cad0..0000000000 --- a/vendor/github.com/spf13/cobra/cobra/cmd/license_lgpl.go +++ /dev/null @@ -1,186 +0,0 @@ -package cmd - -func initLgpl() { - Licenses["lgpl"] = License{ - Name: "GNU Lesser General Public License", - PossibleMatches: []string{"lgpl", "lesser gpl", "gnu lgpl"}, - Header: ` -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU Lesser General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public License -along with this program. If not, see .`, - Text: ` GNU LESSER GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - - This version of the GNU Lesser General Public License incorporates -the terms and conditions of version 3 of the GNU General Public -License, supplemented by the additional permissions listed below. - - 0. Additional Definitions. - - As used herein, "this License" refers to version 3 of the GNU Lesser -General Public License, and the "GNU GPL" refers to version 3 of the GNU -General Public License. - - "The Library" refers to a covered work governed by this License, -other than an Application or a Combined Work as defined below. - - An "Application" is any work that makes use of an interface provided -by the Library, but which is not otherwise based on the Library. -Defining a subclass of a class defined by the Library is deemed a mode -of using an interface provided by the Library. - - A "Combined Work" is a work produced by combining or linking an -Application with the Library. The particular version of the Library -with which the Combined Work was made is also called the "Linked -Version". - - The "Minimal Corresponding Source" for a Combined Work means the -Corresponding Source for the Combined Work, excluding any source code -for portions of the Combined Work that, considered in isolation, are -based on the Application, and not on the Linked Version. - - The "Corresponding Application Code" for a Combined Work means the -object code and/or source code for the Application, including any data -and utility programs needed for reproducing the Combined Work from the -Application, but excluding the System Libraries of the Combined Work. - - 1. Exception to Section 3 of the GNU GPL. - - You may convey a covered work under sections 3 and 4 of this License -without being bound by section 3 of the GNU GPL. - - 2. Conveying Modified Versions. - - If you modify a copy of the Library, and, in your modifications, a -facility refers to a function or data to be supplied by an Application -that uses the facility (other than as an argument passed when the -facility is invoked), then you may convey a copy of the modified -version: - - a) under this License, provided that you make a good faith effort to - ensure that, in the event an Application does not supply the - function or data, the facility still operates, and performs - whatever part of its purpose remains meaningful, or - - b) under the GNU GPL, with none of the additional permissions of - this License applicable to that copy. - - 3. Object Code Incorporating Material from Library Header Files. - - The object code form of an Application may incorporate material from -a header file that is part of the Library. You may convey such object -code under terms of your choice, provided that, if the incorporated -material is not limited to numerical parameters, data structure -layouts and accessors, or small macros, inline functions and templates -(ten or fewer lines in length), you do both of the following: - - a) Give prominent notice with each copy of the object code that the - Library is used in it and that the Library and its use are - covered by this License. - - b) Accompany the object code with a copy of the GNU GPL and this license - document. - - 4. Combined Works. - - You may convey a Combined Work under terms of your choice that, -taken together, effectively do not restrict modification of the -portions of the Library contained in the Combined Work and reverse -engineering for debugging such modifications, if you also do each of -the following: - - a) Give prominent notice with each copy of the Combined Work that - the Library is used in it and that the Library and its use are - covered by this License. - - b) Accompany the Combined Work with a copy of the GNU GPL and this license - document. - - c) For a Combined Work that displays copyright notices during - execution, include the copyright notice for the Library among - these notices, as well as a reference directing the user to the - copies of the GNU GPL and this license document. - - d) Do one of the following: - - 0) Convey the Minimal Corresponding Source under the terms of this - License, and the Corresponding Application Code in a form - suitable for, and under terms that permit, the user to - recombine or relink the Application with a modified version of - the Linked Version to produce a modified Combined Work, in the - manner specified by section 6 of the GNU GPL for conveying - Corresponding Source. - - 1) Use a suitable shared library mechanism for linking with the - Library. A suitable mechanism is one that (a) uses at run time - a copy of the Library already present on the user's computer - system, and (b) will operate properly with a modified version - of the Library that is interface-compatible with the Linked - Version. - - e) Provide Installation Information, but only if you would otherwise - be required to provide such information under section 6 of the - GNU GPL, and only to the extent that such information is - necessary to install and execute a modified version of the - Combined Work produced by recombining or relinking the - Application with a modified version of the Linked Version. (If - you use option 4d0, the Installation Information must accompany - the Minimal Corresponding Source and Corresponding Application - Code. If you use option 4d1, you must provide the Installation - Information in the manner specified by section 6 of the GNU GPL - for conveying Corresponding Source.) - - 5. Combined Libraries. - - You may place library facilities that are a work based on the -Library side by side in a single library together with other library -facilities that are not Applications and are not covered by this -License, and convey such a combined library under terms of your -choice, if you do both of the following: - - a) Accompany the combined library with a copy of the same work based - on the Library, uncombined with any other library facilities, - conveyed under the terms of this License. - - b) Give prominent notice with the combined library that part of it - is a work based on the Library, and explaining where to find the - accompanying uncombined form of the same work. - - 6. Revised Versions of the GNU Lesser General Public License. - - The Free Software Foundation may publish revised and/or new versions -of the GNU Lesser General Public License from time to time. Such new -versions will be similar in spirit to the present version, but may -differ in detail to address new problems or concerns. - - Each version is given a distinguishing version number. If the -Library as you received it specifies that a certain numbered version -of the GNU Lesser General Public License "or any later version" -applies to it, you have the option of following the terms and -conditions either of that published version or of any later version -published by the Free Software Foundation. If the Library as you -received it does not specify a version number of the GNU Lesser -General Public License, you may choose any version of the GNU Lesser -General Public License ever published by the Free Software Foundation. - - If the Library as you received it specifies that a proxy can decide -whether future versions of the GNU Lesser General Public License shall -apply, that proxy's public statement of acceptance of any version is -permanent authorization for you to choose that version for the -Library.`, - } -} diff --git a/vendor/github.com/spf13/cobra/cobra/cmd/license_mit.go b/vendor/github.com/spf13/cobra/cobra/cmd/license_mit.go deleted file mode 100644 index bd2d0c4fa8..0000000000 --- a/vendor/github.com/spf13/cobra/cobra/cmd/license_mit.go +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright © 2015 Steve Francia . -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Parts inspired by https://github.com/ryanuber/go-license - -package cmd - -func initMit() { - Licenses["mit"] = License{ - Name: "MIT License", - PossibleMatches: []string{"mit"}, - Header: ` -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE.`, - Text: `The MIT License (MIT) - -{{ .copyright }} - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -`, - } -} diff --git a/vendor/github.com/spf13/cobra/cobra/cmd/licenses.go b/vendor/github.com/spf13/cobra/cobra/cmd/licenses.go deleted file mode 100644 index a070134ddc..0000000000 --- a/vendor/github.com/spf13/cobra/cobra/cmd/licenses.go +++ /dev/null @@ -1,118 +0,0 @@ -// Copyright © 2015 Steve Francia . -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Parts inspired by https://github.com/ryanuber/go-license - -package cmd - -import ( - "strings" - "time" - - "github.com/spf13/viper" -) - -// Licenses contains all possible licenses a user can choose from. -var Licenses = make(map[string]License) - -// License represents a software license agreement, containing the Name of -// the license, its possible matches (on the command line as given to cobra), -// the header to be used with each file on the file's creating, and the text -// of the license -type License struct { - Name string // The type of license in use - PossibleMatches []string // Similar names to guess - Text string // License text data - Header string // License header for source files -} - -func init() { - // Allows a user to not use a license. - Licenses["none"] = License{"None", []string{"none", "false"}, "", ""} - - initApache2() - initMit() - initBsdClause3() - initBsdClause2() - initGpl2() - initGpl3() - initLgpl() - initAgpl() -} - -// getLicense returns license specified by user in flag or in config. -// If user didn't specify the license, it returns Apache License 2.0. -// -// TODO: Inspect project for existing license -func getLicense() License { - // If explicitly flagged, use that. - if userLicense != "" { - return findLicense(userLicense) - } - - // If user wants to have custom license, use that. - if viper.IsSet("license.header") || viper.IsSet("license.text") { - return License{Header: viper.GetString("license.header"), - Text: viper.GetString("license.text")} - } - - // If user wants to have built-in license, use that. - if viper.IsSet("license") { - return findLicense(viper.GetString("license")) - } - - // If user didn't set any license, use Apache 2.0 by default. - return Licenses["apache"] -} - -func copyrightLine() string { - author := viper.GetString("author") - - year := viper.GetString("year") // For tests. - if year == "" { - year = time.Now().Format("2006") - } - - return "Copyright © " + year + " " + author -} - -// findLicense looks for License object of built-in licenses. -// If it didn't find license, then the app will be terminated and -// error will be printed. -func findLicense(name string) License { - found := matchLicense(name) - if found == "" { - er("unknown license: " + name) - } - return Licenses[found] -} - -// matchLicense compares the given a license name -// to PossibleMatches of all built-in licenses. -// It returns blank string, if name is blank string or it didn't find -// then appropriate match to name. -func matchLicense(name string) string { - if name == "" { - return "" - } - - for key, lic := range Licenses { - for _, match := range lic.PossibleMatches { - if strings.EqualFold(name, match) { - return key - } - } - } - - return "" -}