mirror of
https://hubproxy.babadafafafafa.cn/https://github.com/yunionio/cloudpods.git
synced 2026-09-20 08:03:53 +08:00
add provider & update dep
This commit is contained in:
265
Gopkg.lock
generated
265
Gopkg.lock
generated
@@ -2,15 +2,15 @@
|
||||
|
||||
|
||||
[[projects]]
|
||||
digest = "1:4b94878e125f31ec67c892ecfe38c13211da40653281588598218f807ae72bf7"
|
||||
digest = "1:a151d8abdc2ab0a97060ac2e7c71472dff76255d76d5e65d29dcf21cf0ae0664"
|
||||
name = "github.com/360EntSecGroup-Skylar/excelize"
|
||||
packages = ["."]
|
||||
pruneopts = "UT"
|
||||
revision = "eb62256d165607c6877ce88efbba10c119137b3d"
|
||||
version = "v1.3.0"
|
||||
revision = "3e004d900b103379c2d62657a3070de4a2e8585a"
|
||||
version = "v1.4.0"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:402c5ecf012012f4a6ff2bcc6ee903f5280e8c27f4abaebb2319716065397304"
|
||||
digest = "1:0e1bf1a6e11f777ba0882d0c581788e3f19dcdc7f9f0e5305b13efefe73cd0d5"
|
||||
name = "github.com/Azure/azure-sdk-for-go"
|
||||
packages = [
|
||||
"services/compute/mgmt/2018-04-01/compute",
|
||||
@@ -25,11 +25,11 @@
|
||||
"version",
|
||||
]
|
||||
pruneopts = "UT"
|
||||
revision = "4e8cbbfb1aeab140cd0fa97fd16b64ee18c3ca6a"
|
||||
version = "v19.1.0"
|
||||
revision = "6d20bdbae88c06c36d72eb512295417693bfdf4e"
|
||||
version = "v21.1.0"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:b8a61bb5402d1b01ada88ccb213da33a5d29683cba5ce93813aa67d5826afe56"
|
||||
digest = "1:469646dd53a792f7ecbe8ddfb326a356354b7727ec26d783f3d76ea069eb432a"
|
||||
name = "github.com/Azure/go-autorest"
|
||||
packages = [
|
||||
"autorest",
|
||||
@@ -43,8 +43,8 @@
|
||||
"version",
|
||||
]
|
||||
pruneopts = "UT"
|
||||
revision = "9bc4033dd347c7f416fca46b2f42a043dc1fbdf6"
|
||||
version = "v10.15.5"
|
||||
revision = "a88c19ef2016e095f0b6c3b451074b4663f53bed"
|
||||
version = "v10.15.4"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:f7a3877d7116adfcdcd641f9f6ad18fc2126bd5c080d8854cc3b395a01e0b7f3"
|
||||
@@ -81,12 +81,12 @@
|
||||
revision = "2dd43d88c85c06c55828c86159d4583db9d41fbb"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:66b8ed452b31eb9075bc53295952487c333a9cb555de57ed61f5664c058d9050"
|
||||
digest = "1:6981402aef27693f4b2ec619117abd263fde29f8c1dfac46eef0f35038d37513"
|
||||
name = "github.com/Shopify/sarama"
|
||||
packages = ["."]
|
||||
pruneopts = "UT"
|
||||
revision = "35324cf48e33d8260e1c7c18854465a904ade249"
|
||||
version = "v1.17.0"
|
||||
revision = "ec843464b50d4c8b56403ec9d589cf41ea30e722"
|
||||
version = "v1.19.0"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:5e9ea5618cb3451ce312505a48a563e95ce26c9ef498cd0a8833255e5e7f5c61"
|
||||
@@ -107,12 +107,12 @@
|
||||
version = "1.27.7"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:fff66556e25e676b296f9f2c78853831911e6ae41d84303a9be7a534bd1c0901"
|
||||
digest = "1:5a2d4da3f703696f4bec1ba1d363f50461b72934b1817c07ab0963496ed1c90d"
|
||||
name = "github.com/aliyun/aliyun-oss-go-sdk"
|
||||
packages = ["oss"]
|
||||
pruneopts = "UT"
|
||||
revision = "36bf7aa2f916f274137aedd05d1d36f6a3c0f4a6"
|
||||
version = "1.9.0"
|
||||
revision = "ddc87ec2145f324f91257266e657cd7fa0ff1c8c"
|
||||
version = "1.9.1"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:8f5416c7f59da8600725ae1ff00a99af1da8b04c211ae6f3c8f8bcab0164f650"
|
||||
@@ -123,14 +123,15 @@
|
||||
version = "v1.0.1"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:eee9386329f4fcdf8d6c0def0c9771b634bdd5ba460d888aa98c17d59b37a76c"
|
||||
digest = "1:e64acfe8cda1955db545ede8e863c54d69f1ac6cd058df4349be4040320840fd"
|
||||
name = "github.com/apache/thrift"
|
||||
packages = ["lib/go/thrift"]
|
||||
pruneopts = "UT"
|
||||
revision = "e59b73d3c2bf1c328ccb78e683c0462fa1a473c7"
|
||||
revision = "327ebb6c2b6df8bf075da02ef45a2a034e9b79ba"
|
||||
version = "0.11.0"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:5a79e64c2a81cc6ab6e49a87e12d6d1ec86aab93edf6ff643b5b052c0142f12b"
|
||||
digest = "1:69c83bbce91c8bbe26c02018aee83bb761b68678d33699e342171cae4108598b"
|
||||
name = "github.com/aws/aws-sdk-go"
|
||||
packages = [
|
||||
"aws",
|
||||
@@ -164,8 +165,8 @@
|
||||
"service/sts",
|
||||
]
|
||||
pruneopts = "UT"
|
||||
revision = "85d9dfd77e6d694e83c3ac054141cb5e81eecc7f"
|
||||
version = "v1.15.43"
|
||||
revision = "46fe04784968cd7b54e859fcce45753456f736ac"
|
||||
version = "v1.15.52"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
@@ -184,15 +185,15 @@
|
||||
version = "v0.5.0"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:a2486f94bda33b301614ff5cfce102b7eed4c923fa650c2b83dba1fcf2117466"
|
||||
digest = "1:1659cb76cbd08a29826688d006e7a3d9279d6ca8a12155acb7b20164958987d3"
|
||||
name = "github.com/c-bata/go-prompt"
|
||||
packages = ["."]
|
||||
pruneopts = "UT"
|
||||
revision = "c52492ff1b386e5c0ba5271b5eaad165fab09eca"
|
||||
version = "v0.2.2"
|
||||
revision = "e99fbc797b795e0a7a94affc8d44f6a0350d85f0"
|
||||
version = "v0.2.1"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:40098afbdd06a76dee4b6bcb85a22fed81ac9d2ebaf775c91e558c80f57aaff1"
|
||||
digest = "1:7205ab9c5433db402268526647efc47daa3236f9a85a1faba705fda12fdafd29"
|
||||
name = "github.com/coredns/coredns"
|
||||
packages = [
|
||||
"core/dnsserver",
|
||||
@@ -245,16 +246,16 @@
|
||||
"request",
|
||||
]
|
||||
pruneopts = "UT"
|
||||
revision = "2e322f6e8a54f18c6aef9c25a7c432c291a3d9f7"
|
||||
version = "v1.2.0"
|
||||
revision = "eb51e8bac90fac86d34c9e1cb89b04ea0936b034"
|
||||
version = "v1.2.2"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:a2c1d0e43bd3baaa071d1b9ed72c27d78169b2b269f71c105ac4ba34b1be4a39"
|
||||
digest = "1:ffe9824d294da03b391f44e1ae8281281b4afc1bdaa9588c9097785e3af10cec"
|
||||
name = "github.com/davecgh/go-spew"
|
||||
packages = ["spew"]
|
||||
pruneopts = "UT"
|
||||
revision = "346938d642f2ec3594ed81d874461961cd0faa76"
|
||||
version = "v1.1.0"
|
||||
revision = "8991bc29aa16c548c550c7ff78260e27b9ab7c73"
|
||||
version = "v1.1.1"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:76dc72490af7174349349838f2fe118996381b31ea83243812a97e5a0fd5ed55"
|
||||
@@ -290,11 +291,11 @@
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
digest = "1:0448d1c1a596941c608762912fe7c865f88d9ffa45afb8af1edcf1401762bf7e"
|
||||
digest = "1:79f16588b5576b1b3cd90e48d2374cc9a1a8776862d28d8fd0f23b0e15534967"
|
||||
name = "github.com/eapache/go-xerial-snappy"
|
||||
packages = ["."]
|
||||
pruneopts = "UT"
|
||||
revision = "040cc1a32f578808623071247fdbd5cc43f37f5f"
|
||||
revision = "776d5712da21bc4762676d614db1d8a64f4238b0"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:444b82bfe35c83bbcaf84e310fb81a1f9ece03edfed586483c869e2c046aef69"
|
||||
@@ -310,7 +311,7 @@
|
||||
name = "github.com/farsightsec/golang-framestream"
|
||||
packages = ["."]
|
||||
pruneopts = "UT"
|
||||
revision = "c06a5734334d9629b3db143d74b47eb94ea68612"
|
||||
revision = "d0f7ed81b7afcc56d3c1a66a0fd26a1b609675f3"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:865079840386857c809b72ce300be7580cb50d3d3129ce11bf9aa6ca2bc1934a"
|
||||
@@ -329,12 +330,11 @@
|
||||
revision = "3f9db97f856818214da2e1057f8ad84803971cff"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:2cd7915ab26ede7d95b8749e6b1f933f1c6d5398030684e6505940a10f31cfda"
|
||||
digest = "1:c45cef8e0074ea2f8176a051df38553ba997a3616f1ec2d35222b1cf9864881e"
|
||||
name = "github.com/ghodss/yaml"
|
||||
packages = ["."]
|
||||
pruneopts = "UT"
|
||||
revision = "0ca9ea5df5451ffdf184b4428c902747c2c11cd7"
|
||||
version = "v1.0.0"
|
||||
revision = "73d445a93680fa1a78ae23a5839bad48f32ba1ee"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
@@ -345,23 +345,24 @@
|
||||
revision = "22d885f9ecc78bf4ee5d72b937e4bbcdc58e8cae"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:ab00ecdc9607692ffd5fb1ac21a9ba2d6cc95bae011f327022c0b1c323d218e2"
|
||||
digest = "1:ff09f03ca12c4d23c28c596eb0738745e36c1cac111f62f64819210f40607cd2"
|
||||
name = "github.com/gin-gonic/gin"
|
||||
packages = [
|
||||
"binding",
|
||||
"json",
|
||||
"render",
|
||||
]
|
||||
pruneopts = "UT"
|
||||
revision = "d459835d2b077e44f7c9b453505ee29881d5d12d"
|
||||
version = "v1.2"
|
||||
revision = "b869fe1415e4b9eb52f247441830d502aece2d4d"
|
||||
version = "v1.3.0"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:5abd6a22805b1919f6a6bca0ae58b13cef1f3412812f38569978f43ef02743d4"
|
||||
digest = "1:b98e7574fc27ec166fb31195ec72c3bd0bffd73926d3612eb4c929bc5236f75b"
|
||||
name = "github.com/go-ini/ini"
|
||||
packages = ["."]
|
||||
pruneopts = "UT"
|
||||
revision = "5cf292cae48347c2490ac1a58fe36735fb78df7e"
|
||||
version = "v1.38.2"
|
||||
revision = "7b294651033cd7d9e7f0d9ffa1b75ed1e198e737"
|
||||
version = "v1.38.3"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:31a18dae27a29aa074515e43a443abfd2ba6deb6d69309d8d7ce789c45f34659"
|
||||
@@ -380,15 +381,15 @@
|
||||
version = "v1.4.0"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:34e709f36fd4f868fb00dbaf8a6cab4c1ae685832d392874ba9d7c5dec2429d1"
|
||||
digest = "1:b7a8552c62868d867795b63eaf4f45d3e92d36db82b428e680b9c95a8c33e5b1"
|
||||
name = "github.com/gogo/protobuf"
|
||||
packages = [
|
||||
"proto",
|
||||
"sortkeys",
|
||||
]
|
||||
pruneopts = "UT"
|
||||
revision = "636bf0302bc95575d69441b25a2603156ffdddf1"
|
||||
version = "v1.1.1"
|
||||
revision = "342cbe0a04158f6dcb03ca0079991a51a4248c02"
|
||||
version = "v0.5"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:94d8c9e3a4954505ca89243e2121180972eecf8e3d160f3b34a48825ddd95cc1"
|
||||
@@ -416,15 +417,14 @@
|
||||
version = "v1.0.0"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
digest = "1:1ba1d79f2810270045c328ae5d674321db34e3aae468eb4233883b473c5c0467"
|
||||
digest = "1:2edd2416f89b4e841df0e4a78802ce14d2bc7ad79eba1a45986e39f0f8cb7d87"
|
||||
name = "github.com/golang/glog"
|
||||
packages = ["."]
|
||||
pruneopts = "UT"
|
||||
revision = "23def4e6c14b4da8ac2ed8007337bc5eb5007998"
|
||||
revision = "44145f04b68cf362d9c4df2182967c2275eaefed"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:17fe264ee908afc795734e8c4e63db2accabaf57326dbf21763a7d6b86096260"
|
||||
digest = "1:4c0989ca0bcd10799064318923b9bc2db6b4d6338dd75f3f2d86c3511aaaf5cf"
|
||||
name = "github.com/golang/protobuf"
|
||||
packages = [
|
||||
"proto",
|
||||
@@ -434,8 +434,8 @@
|
||||
"ptypes/timestamp",
|
||||
]
|
||||
pruneopts = "UT"
|
||||
revision = "b4deda0973fb4c70b50d226b1af49f3da59f5265"
|
||||
version = "v1.1.0"
|
||||
revision = "aa810b61a9c79d51363740d207bb46cf8e620ed5"
|
||||
version = "v1.2.0"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
@@ -447,27 +447,25 @@
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
digest = "1:9887333bbef17574b1db5f9893ea137ac44107235d624408a3ac9e0b98fbb2cb"
|
||||
digest = "1:0bfbe13936953a98ae3cfe8ed6670d396ad81edf069a806d2f6515d7bb6950df"
|
||||
name = "github.com/google/btree"
|
||||
packages = ["."]
|
||||
pruneopts = "UT"
|
||||
revision = "e89373fe6b4a7413d7acd6da1725b83ef713e6e4"
|
||||
revision = "4030bb1f1f0c35b30ca7009e9ebd06849dd45306"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
digest = "1:3ee90c0d94da31b442dde97c99635aaafec68d0b8a3c12ee2075c6bdabeec6bb"
|
||||
digest = "1:41bfd4219241b7f7d6e6fdb13fc712576f1337e68e6b895136283b76928fdd66"
|
||||
name = "github.com/google/gofuzz"
|
||||
packages = ["."]
|
||||
pruneopts = "UT"
|
||||
revision = "24818f796faf91cd76ec7bddd72458fbced7a6c1"
|
||||
revision = "44d81051d367757e1c7c6a5a86423ece9afcf63c"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:8f8811f9be822914c3a25c6a071e93beb4c805d7b026cbf298bc577bc1cc945b"
|
||||
digest = "1:9f7a9e0b3f54aad2c053f778b9933263de723f6d722c68092b1eec06b95a5860"
|
||||
name = "github.com/google/uuid"
|
||||
packages = ["."]
|
||||
pruneopts = "UT"
|
||||
revision = "064e2069ce9c359c118179501254f67d7d37ba24"
|
||||
version = "0.2"
|
||||
revision = "7e072fc3a7be179aee6d3359e46015aa8c995314"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:65c4414eeb350c47b8de71110150d0ea8a281835b1f386eacaa3ad7325929c21"
|
||||
@@ -498,11 +496,11 @@
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
digest = "1:62db7727ec8e026e51e1b46696e0fdf6a956a701032eca4d63e311816820717c"
|
||||
digest = "1:8ec54d9488698e9db22139250bde10e35aab02c20236e4d1c1457604c2c4fe18"
|
||||
name = "github.com/googollee/go-socket.io"
|
||||
packages = ["."]
|
||||
pruneopts = "UT"
|
||||
revision = "f12da5711bc66c18a0724987fff7f4f3db35c70f"
|
||||
revision = "25e1f67559cf5d0e41efbc3e0157bb952596ffc3"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:c79fb010be38a59d657c48c6ba1d003a8aa651fa56b579d959d74573b7dff8e1"
|
||||
@@ -541,15 +539,14 @@
|
||||
revision = "36ee7e946282a3fb1cfecd476ddc9b35d8847e42"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
digest = "1:86c1210529e69d69860f2bb3ee9ccce0b595aa3f9165e7dd1388e5c612915888"
|
||||
digest = "1:878f0defa9b853f9acfaf4a162ba450a89d0050eff084f9fe7f5bd15948f172a"
|
||||
name = "github.com/gregjones/httpcache"
|
||||
packages = [
|
||||
".",
|
||||
"diskcache",
|
||||
]
|
||||
pruneopts = "UT"
|
||||
revision = "9cad4c3443a7200dd6400aef47183728de563a38"
|
||||
revision = "787624de3eb7bd915c329cba748687a3b22666a6"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
@@ -560,20 +557,19 @@
|
||||
revision = "8e809c8a86450a29b90dcc9efbf062d0fe6d9746"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
digest = "1:09970bb8daf100bdf11b48b72c71ef980cd2b50efbd903989b3d182956be0b83"
|
||||
name = "github.com/hako/durafmt"
|
||||
packages = ["."]
|
||||
pruneopts = "UT"
|
||||
revision = "7b7ae1e72eade09dbc9c2cfba3e6c4bae7b8bcac"
|
||||
version = "1.0.0"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:8eb1de8112c9924d59bf1d3e5c26f5eaa2bfc2a5fcbb92dc1c2e4546d695f277"
|
||||
digest = "1:06ec9147400aabb0d6960dd8557638603b5f320cd4cb8a3eceaae407e782849a"
|
||||
name = "github.com/imdario/mergo"
|
||||
packages = ["."]
|
||||
pruneopts = "UT"
|
||||
revision = "9f23e2d6bd2a77f959b2bf6acdbefd708a83a4a4"
|
||||
version = "v0.3.6"
|
||||
revision = "6633656539c1639d9d78127b7d47c622b5d7b6dc"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:b6f4477f09f11785097a121811f3a90d8d26cab73c1aa71abda859bdf6ad2334"
|
||||
@@ -602,12 +598,20 @@
|
||||
revision = "0b12d6b5"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:eaefc85d32c03e5f0c2b88ea2f79fce3d993e2c78316d21319575dd4ea9153ca"
|
||||
digest = "1:3e551bbb3a7c0ab2a2bf4660e7fcad16db089fdcfbb44b0199e62838038623ea"
|
||||
name = "github.com/json-iterator/go"
|
||||
packages = ["."]
|
||||
pruneopts = "UT"
|
||||
revision = "ab8a2e0c74be9d3be70b3184d9acc634935ded82"
|
||||
version = "1.1.4"
|
||||
revision = "1624edc4454b8682399def8740d46db5e4362ba4"
|
||||
version = "v1.1.5"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:0a69a1c0db3591fcefb47f115b224592c8dfa4368b7ba9fae509d5e16cdc95c8"
|
||||
name = "github.com/konsorten/go-windows-terminal-sequences"
|
||||
packages = ["."]
|
||||
pruneopts = "UT"
|
||||
revision = "5c8c8bd35d3832f5d134ae1e1e375b69a4d25242"
|
||||
version = "v1.0.1"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
@@ -618,12 +622,12 @@
|
||||
revision = "b84e30acd515aadc4b783ad4ff83aff3299bdfe0"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
digest = "1:094e04c4742b596bce4455eb535d4e4365016b44016db76f8593211406d77299"
|
||||
digest = "1:29d28429a93b076908a36420a7ecb2bf429d24c15a4b5e2c220ea00fc84b71af"
|
||||
name = "github.com/kr/pty"
|
||||
packages = ["."]
|
||||
pruneopts = "UT"
|
||||
revision = "fa756f09eeb418bf1cc6268c66ceaad9bb98f598"
|
||||
revision = "db8e3cd836b82e82e0a9c8edc6896967dd31374f"
|
||||
version = "v1.1.3"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:4e878df5f4e9fd625bf9c9aac77ef7cbfa4a74c01265505527c23470c0e40300"
|
||||
@@ -642,28 +646,28 @@
|
||||
version = "v0.0.9"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:d4d17353dbd05cb52a2a52b7fe1771883b682806f68db442b436294926bbfafb"
|
||||
digest = "1:0981502f9816113c9c8c4ac301583841855c8cf4da8c72f696b3ebedf6d0e4e5"
|
||||
name = "github.com/mattn/go-isatty"
|
||||
packages = ["."]
|
||||
pruneopts = "UT"
|
||||
revision = "0360b2af4f38e8d38c7fce2a9f4e702702d73a39"
|
||||
version = "v0.0.3"
|
||||
revision = "6ca4dbf54d38eea1a992b3c722a76a5d1c4cb25c"
|
||||
version = "v0.0.4"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
digest = "1:cdb899c199f907ac9fb50495ec71212c95cb5b0e0a8ee0800da0238036091033"
|
||||
name = "github.com/mattn/go-runewidth"
|
||||
packages = ["."]
|
||||
pruneopts = "UT"
|
||||
revision = "ce7b0b5c7b45a81508558cd1dba6bb1e4ddb51bb"
|
||||
version = "v0.0.3"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
digest = "1:d775613e6db40f54d34cc8b319ee5c2df56752f9f5e55e2f6004d11684bdc8fd"
|
||||
digest = "1:325f68c3bd3044dcf51d46e802136cd239817e1fb130b5f3466a4cec4dd427d3"
|
||||
name = "github.com/mattn/go-tty"
|
||||
packages = ["."]
|
||||
pruneopts = "UT"
|
||||
revision = "931426f7535ac39720c8909d70ece5a41a2502a6"
|
||||
revision = "13ff1204f104d52c3f7645ec027ecbcf9026429e"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:ff5ebae34cfbf047d505ee150de27e60570e8c394b3b8fdbb720ff6ac71985fc"
|
||||
@@ -695,12 +699,12 @@
|
||||
version = "v0.10.11"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:463e4140189f8194f9121ca1c7fe3b8e9e9a2ab3d949b43c835c21034927dc62"
|
||||
digest = "1:57689550840d285f2da9e85356a66e626592a8b6f1170d7f2482438e64fe82e3"
|
||||
name = "github.com/miekg/dns"
|
||||
packages = ["."]
|
||||
pruneopts = "UT"
|
||||
revision = "5a2b9fab83ff0f8bfc99684bd5f43a37abe560f1"
|
||||
version = "v1.0.8"
|
||||
revision = "d74956db7b5b20451796774572d0f5a0222e377a"
|
||||
version = "v1.0.13"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:33422d238f147d247752996a26574ac48dcf472976eda7f5134015f06bf16563"
|
||||
@@ -718,6 +722,14 @@
|
||||
revision = "4b7aa43c6742a2c18fdef89dd197aaae7dac7ccd"
|
||||
version = "1.0.1"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
digest = "1:84bd7f8a2e0bcd53ddc33c3b47c34c1fe340c8632cbe928f7f8ae10ec6ecdd62"
|
||||
name = "github.com/mohae/deepcopy"
|
||||
packages = ["."]
|
||||
pruneopts = "UT"
|
||||
revision = "c48cc78d482608239f6c4c92a4abd87eb8761c90"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
digest = "1:7aefb397a53fc437c90f0fdb3e1419c751c5a3a165ced52325d5d797edf1aca6"
|
||||
@@ -778,15 +790,15 @@
|
||||
version = "v2.0.1"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:29803f52611cbcc1dfe55b456e9fdac362af7248b3d29d7ea1bec0a12e71dff4"
|
||||
digest = "1:e39a5ee8fcbec487f8fc68863ef95f2b025e0739b0e4aa55558a2b4cf8f0ecf0"
|
||||
name = "github.com/pierrec/lz4"
|
||||
packages = [
|
||||
".",
|
||||
"internal/xxh32",
|
||||
]
|
||||
pruneopts = "UT"
|
||||
revision = "1958fd8fff7f115e79725b1288e0b878b3e06b00"
|
||||
version = "v2.0.3"
|
||||
revision = "635575b42742856941dbc767b44905bb9ba083f6"
|
||||
version = "v2.0.7"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
@@ -794,7 +806,7 @@
|
||||
name = "github.com/pkg/term"
|
||||
packages = ["termios"]
|
||||
pruneopts = "UT"
|
||||
revision = "cda20d4ac917ad418d86e151eff439648b06185b"
|
||||
revision = "bffc007b7fd5a70e20e28f5b7649bb84671ef436"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:0028cb19b2e4c3112225cd871870f2d9cf49b9b4276531f03438a88e94be86fe"
|
||||
@@ -825,7 +837,7 @@
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
digest = "1:e469cd65badf7694aeb44874518606d93c1d59e7735d3754ad442782437d3cc3"
|
||||
digest = "1:63b68062b8968092eb86bedc4e68894bd096ea6b24920faca8b9dcf451f54bb5"
|
||||
name = "github.com/prometheus/common"
|
||||
packages = [
|
||||
"expfmt",
|
||||
@@ -833,11 +845,11 @@
|
||||
"model",
|
||||
]
|
||||
pruneopts = "UT"
|
||||
revision = "7600349dcfe1abd18d72d3a1770870d9800a7801"
|
||||
revision = "c7de2306084e37d54b8be01f3541a8464345e9a5"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
digest = "1:8c49953a1414305f2ff5465147ee576dd705487c35b15918fcd4efdc0cb7a290"
|
||||
digest = "1:ef74914912f99c79434d9c09658274678bc85080ebe3ab32bec3940ebce5e1fc"
|
||||
name = "github.com/prometheus/procfs"
|
||||
packages = [
|
||||
".",
|
||||
@@ -846,7 +858,7 @@
|
||||
"xfs",
|
||||
]
|
||||
pruneopts = "UT"
|
||||
revision = "05ee40e3a273f7245e8777337fc7b46e533a9a92"
|
||||
revision = "185b4288413d2a0dd0806f78c90dde719829e5ae"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
@@ -881,12 +893,12 @@
|
||||
version = "1.1.0"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:d867dfa6751c8d7a435821ad3b736310c2ed68945d05b50fb9d23aee0540c8cc"
|
||||
digest = "1:3f53e9e4dfbb664cd62940c9c4b65a2171c66acd0b7621a1a6b8e78513525a52"
|
||||
name = "github.com/sirupsen/logrus"
|
||||
packages = ["."]
|
||||
pruneopts = "UT"
|
||||
revision = "3e01752db0189b9157070a0e1668a620f9a85da2"
|
||||
version = "v1.0.6"
|
||||
revision = "ad15b42461921f1fb3529b058c6786c6a45d5162"
|
||||
version = "v1.1.1"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:9424f440bba8f7508b69414634aef3b2b3a877e522d8a4624692412805407bb7"
|
||||
@@ -913,15 +925,14 @@
|
||||
revision = "d188e65d659ef53fcdb0691c12f1bba64928b649"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:98e5cda86f67cd1ac95389d98670b66dea8cae480fe6292b83bccccfe60b4106"
|
||||
digest = "1:7b36ba7867ad2d262abedeff4c9362f2e8aa00cf6dd3254a509f24c27eb1d5b7"
|
||||
name = "github.com/ugorji/go"
|
||||
packages = ["codec"]
|
||||
pruneopts = "UT"
|
||||
revision = "f3cacc17c85ecb7f1b6a9e373ee85d1480919868"
|
||||
revision = "9c7f9b7a2bc3a520f7c7b30b34b7f85f47fe27b6"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
digest = "1:91771429c8de08d4d9b32663ad78bfa8ee1e0a146e921d9937c117665fd0377f"
|
||||
digest = "1:506f2f0fee9b0e75b987286233a3b0d3fbf7cb145d754b0719b672822246cbc6"
|
||||
name = "github.com/vmware/govmomi"
|
||||
packages = [
|
||||
".",
|
||||
@@ -941,11 +952,12 @@
|
||||
"vim25/xml",
|
||||
]
|
||||
pruneopts = "UT"
|
||||
revision = "bbd99532a768d2fe369079ceda730e30726ae1a6"
|
||||
revision = "3617f28d167d448f93f282a867870f109516d2a5"
|
||||
version = "v0.19.0"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
digest = "1:2d12661fb1e092a12b9675f9cd59fb3119f03d696bd6febcb5fe2324d2639965"
|
||||
digest = "1:71c5989353531072eeb9547066e05bdeaaf9ef0512673bca3b4b824092d70de3"
|
||||
name = "golang.org/x/crypto"
|
||||
packages = [
|
||||
"curve25519",
|
||||
@@ -960,11 +972,11 @@
|
||||
"ssh/terminal",
|
||||
]
|
||||
pruneopts = "UT"
|
||||
revision = "c126467f60eb25f8f27e5a981f32a87e3965053f"
|
||||
revision = "7c1a557ab941a71c619514f229f0b27ccb0c27cf"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
digest = "1:c945d925a3dae287abe075a89c6b09e1015da39d350eb512bb5d01ebcd7783e7"
|
||||
digest = "1:4ab551743538ce88c540073958b2fb653ca077c5d4c3d1991d86016dd38e22f6"
|
||||
name = "golang.org/x/net"
|
||||
packages = [
|
||||
"bpf",
|
||||
@@ -981,18 +993,18 @@
|
||||
"trace",
|
||||
]
|
||||
pruneopts = "UT"
|
||||
revision = "f4c29de78a2a91c00474a2e689954305c350adf9"
|
||||
revision = "146acd28ed5894421fb5aac80ca93bc1b1f46f87"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
digest = "1:be95d758fc4d9216e5d41ff5b98b46938fba85ca5bc2ddc45a1b03e2bb10fe7c"
|
||||
digest = "1:850d28ab022512e2cd3cf511a77f363c29e22689b4031f2050871f5de47ae4a0"
|
||||
name = "golang.org/x/sys"
|
||||
packages = [
|
||||
"unix",
|
||||
"windows",
|
||||
]
|
||||
pruneopts = "UT"
|
||||
revision = "e072cadbbdc8dd3d3ffa82b8b4b9304c261d9311"
|
||||
revision = "4497e2df6f9e69048a54498c7affbbec3294ad47"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:a2ab62866c75542dd18d2b069fec854577a20211d7c0ea6ae746072a1dccdd18"
|
||||
@@ -1018,31 +1030,30 @@
|
||||
version = "v0.3.0"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
digest = "1:c9e7a4b4d47c0ed205d257648b0e5b0440880cb728506e318f8ac7cd36270bc4"
|
||||
digest = "1:d37b0ef2944431fe9e8ef35c6fffc8990d9e2ca300588df94a6890f3649ae365"
|
||||
name = "golang.org/x/time"
|
||||
packages = ["rate"]
|
||||
pruneopts = "UT"
|
||||
revision = "fbb02b2291d28baffd63558aa44b4b56f178d650"
|
||||
revision = "f51c12702a4d776e4c1fa9b0fabab841babae631"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:c25289f43ac4a68d88b02245742347c94f1e108c534dda442188015ff80669b3"
|
||||
name = "google.golang.org/appengine"
|
||||
packages = ["cloudsql"]
|
||||
pruneopts = "UT"
|
||||
revision = "b1f26356af11148e710935ed1ac8a7f5702c7612"
|
||||
version = "v1.1.0"
|
||||
revision = "ae0ab99deb4dc413a2b4bd6c8bdd0eb67f1e4d06"
|
||||
version = "v1.2.0"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
digest = "1:077c1c599507b3b3e9156d17d36e1e61928ee9b53a5b420f10f28ebd4a0b275c"
|
||||
digest = "1:56b0bca90b7e5d1facf5fbdacba23e4e0ce069d25381b8e2f70ef1e7ebfb9c1a"
|
||||
name = "google.golang.org/genproto"
|
||||
packages = ["googleapis/rpc/status"]
|
||||
pruneopts = "UT"
|
||||
revision = "daca94659cb50e9f37c1b834680f2e46358f10b0"
|
||||
revision = "af9cb2a35e7f169ec875002c1829c9b315cddc04"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:3dd7996ce6bf52dec6a2f69fa43e7c4cefea1d4dfa3c8ab7a5f8a9f7434e239d"
|
||||
digest = "1:ab8e92d746fb5c4c18846b0879842ac8e53b3d352449423d0924a11f1020ae1b"
|
||||
name = "google.golang.org/grpc"
|
||||
packages = [
|
||||
".",
|
||||
@@ -1073,8 +1084,8 @@
|
||||
"tap",
|
||||
]
|
||||
pruneopts = "UT"
|
||||
revision = "32fb0ac620c32ba40a4626ddf94d90d12cce3455"
|
||||
version = "v1.14.0"
|
||||
revision = "8dea3dc473e90c8179e519d91302d0597c0ca1d1"
|
||||
version = "v1.15.0"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:2655728699af00d823b0a68bd7169fd241a30c04252f456b34421908701b9c3f"
|
||||
@@ -1093,12 +1104,12 @@
|
||||
version = "v8.18.2"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:2d1fbdc6777e5408cabeb02bf336305e724b925ff4546ded0fa8715a7267922a"
|
||||
digest = "1:ef72505cf098abdd34efeea032103377bec06abb61d8a06f002d5d296a4b1185"
|
||||
name = "gopkg.in/inf.v0"
|
||||
packages = ["."]
|
||||
pruneopts = "UT"
|
||||
revision = "d2d2541c53f18d2a059457998ce2876cc8e67cbf"
|
||||
version = "v0.9.1"
|
||||
revision = "3887ee99ecf07df5b447e9b00d9c0b2adaa9f3e4"
|
||||
version = "v0.9.0"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:342378ac4dcb378a5448dd723f0784ae519383532f5e70ade24132c4c8693202"
|
||||
@@ -1109,7 +1120,8 @@
|
||||
version = "v2.2.1"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:74142cd2275f77547c35ac51514108d9798a09aa0cf377a5c1084718ef7aa225"
|
||||
branch = "master"
|
||||
digest = "1:e77103eb194b363b0a5d257edd309213132ce8171fd0fd3739d47c7c9d9b9ea0"
|
||||
name = "k8s.io/api"
|
||||
packages = [
|
||||
"admissionregistration/v1alpha1",
|
||||
@@ -1143,10 +1155,11 @@
|
||||
"storage/v1beta1",
|
||||
]
|
||||
pruneopts = "UT"
|
||||
revision = "072894a440bdee3a891dea811fe42902311cd2a3"
|
||||
revision = "26c7a45db37856b19f05ba5aa21d2df4b81ecff3"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:29d5abc33d8cbec19b4cd032a87d28010dd615578dd695a655fc3d5ec3ab86b6"
|
||||
branch = "master"
|
||||
digest = "1:45dfef2f63bde631e0e7c80f97073c94a6792ead321e6974545fe05affc866f9"
|
||||
name = "k8s.io/apimachinery"
|
||||
packages = [
|
||||
"pkg/api/errors",
|
||||
@@ -1174,19 +1187,19 @@
|
||||
"pkg/util/framer",
|
||||
"pkg/util/intstr",
|
||||
"pkg/util/json",
|
||||
"pkg/util/naming",
|
||||
"pkg/util/net",
|
||||
"pkg/util/runtime",
|
||||
"pkg/util/sets",
|
||||
"pkg/util/validation",
|
||||
"pkg/util/validation/field",
|
||||
"pkg/util/wait",
|
||||
"pkg/util/yaml",
|
||||
"pkg/version",
|
||||
"pkg/watch",
|
||||
"third_party/forked/golang/reflect",
|
||||
]
|
||||
pruneopts = "UT"
|
||||
revision = "103fd098999dc9c0c88536f5c9ad2e5da39373ae"
|
||||
revision = "56cf97ad69c72c043045c349a1badf99d9f7ef44"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:ac46cc5d5c55dd93d4844327334d2253d563d76f14d4b38a8b522b97f0f52214"
|
||||
@@ -1251,11 +1264,11 @@
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
digest = "1:49ffc35ec8d3f7789393cd132acd359e8ac1f5d38c7a2b91c484b041840c62c0"
|
||||
digest = "1:1196c8593b21d45fc845d33f55711a716c94106936c0b618dc0f1aaaad3dbf01"
|
||||
name = "yunion.io/x/jsonutils"
|
||||
packages = ["."]
|
||||
pruneopts = "UT"
|
||||
revision = "d1290e94d4753c1748fc7c89f472a523cc0a5c08"
|
||||
revision = "4870efdca45d242cbfb4ad112769ed0a7c7be2e6"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
@@ -1308,11 +1321,11 @@
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
digest = "1:e52c4c426ba5bbb92b2d6b2f20f694ff836dde16151adaca39c86d5fb010fea9"
|
||||
digest = "1:a22a70d0156f2b836993f4d07b38c4b1c2058d61ced4e55bb7fb77b297424a04"
|
||||
name = "yunion.io/x/sqlchemy"
|
||||
packages = ["."]
|
||||
pruneopts = "UT"
|
||||
revision = "946ed13318f85073e55dbb8105593c710e943a31"
|
||||
revision = "3342ff524267b69938600968f3f193fc794b309c"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
|
||||
195
Gopkg.toml
195
Gopkg.toml
@@ -25,18 +25,138 @@
|
||||
# unused-packages = true
|
||||
|
||||
|
||||
[[constraint]]
|
||||
name = "github.com/360EntSecGroup-Skylar/excelize"
|
||||
version = "1.4.0"
|
||||
|
||||
[[constraint]]
|
||||
name = "github.com/Azure/azure-sdk-for-go"
|
||||
version = "21.1.0"
|
||||
|
||||
[[constraint]]
|
||||
name = "github.com/Azure/go-autorest"
|
||||
version = "10.15.4"
|
||||
|
||||
[[constraint]]
|
||||
branch = "master"
|
||||
name = "github.com/Microsoft/azure-vhd-utils"
|
||||
|
||||
[[constraint]]
|
||||
name = "github.com/aliyun/alibaba-cloud-sdk-go"
|
||||
version = "1.27.7"
|
||||
|
||||
[[constraint]]
|
||||
name = "github.com/aliyun/aliyun-oss-go-sdk"
|
||||
version = "1.9.1"
|
||||
|
||||
[[constraint]]
|
||||
name = "github.com/aokoli/goutils"
|
||||
version = "1.0.1"
|
||||
|
||||
[[constraint]]
|
||||
name = "github.com/aws/aws-sdk-go"
|
||||
version = "1.15.52"
|
||||
|
||||
[[constraint]]
|
||||
name = "github.com/bitly/go-simplejson"
|
||||
version = "0.5.0"
|
||||
|
||||
[[constraint]]
|
||||
name = "github.com/c-bata/go-prompt"
|
||||
version = "0.2.2"
|
||||
version = "0.2.1"
|
||||
|
||||
[[constraint]]
|
||||
name = "github.com/coredns/coredns"
|
||||
version = "1.2.2"
|
||||
|
||||
[[constraint]]
|
||||
name = "github.com/fatih/color"
|
||||
version = "1.7.0"
|
||||
|
||||
[[constraint]]
|
||||
name = "github.com/go-sql-driver/mysql"
|
||||
version = "1.4.0"
|
||||
|
||||
[[constraint]]
|
||||
name = "github.com/golang-plus/uuid"
|
||||
version = "1.0.0"
|
||||
|
||||
[[constraint]]
|
||||
branch = "master"
|
||||
name = "github.com/googollee/go-socket.io"
|
||||
|
||||
[[constraint]]
|
||||
name = "github.com/gorilla/mux"
|
||||
version = "1.6.2"
|
||||
|
||||
[[constraint]]
|
||||
branch = "master"
|
||||
name = "github.com/gosuri/uitable"
|
||||
|
||||
[[constraint]]
|
||||
name = "github.com/hako/durafmt"
|
||||
version = "1.0.0"
|
||||
|
||||
[[constraint]]
|
||||
name = "github.com/jinzhu/gorm"
|
||||
version = "1.9.1"
|
||||
|
||||
[[constraint]]
|
||||
name = "github.com/json-iterator/go"
|
||||
version = "1.1.5"
|
||||
|
||||
[[constraint]]
|
||||
name = "github.com/kr/pty"
|
||||
version = "1.1.3"
|
||||
|
||||
[[constraint]]
|
||||
name = "github.com/mholt/caddy"
|
||||
version = "0.10.11"
|
||||
|
||||
[[constraint]]
|
||||
name = "github.com/miekg/dns"
|
||||
version = "1.0.13"
|
||||
|
||||
[[constraint]]
|
||||
branch = "master"
|
||||
name = "github.com/moul/http2curl"
|
||||
|
||||
[[constraint]]
|
||||
branch = "master"
|
||||
name = "github.com/serialx/hashring"
|
||||
|
||||
[[constraint]]
|
||||
name = "github.com/stretchr/testify"
|
||||
version = "1.2.2"
|
||||
|
||||
[[constraint]]
|
||||
name = "github.com/vmware/govmomi"
|
||||
version = "0.19.0"
|
||||
|
||||
[[constraint]]
|
||||
branch = "master"
|
||||
name = "golang.org/x/crypto"
|
||||
|
||||
[[constraint]]
|
||||
name = "gopkg.in/gin-gonic/gin.v1"
|
||||
version = "1.2.0"
|
||||
|
||||
[[constraint]]
|
||||
branch = "master"
|
||||
name = "k8s.io/api"
|
||||
|
||||
[[constraint]]
|
||||
branch = "master"
|
||||
name = "k8s.io/apimachinery"
|
||||
|
||||
[[constraint]]
|
||||
name = "k8s.io/client-go"
|
||||
version = "8.0.0"
|
||||
|
||||
[[constraint]]
|
||||
branch = "master"
|
||||
name = "yunion.io/x/jsonutils"
|
||||
|
||||
[[constraint]]
|
||||
branch = "master"
|
||||
name = "yunion.io/x/sqlchemy"
|
||||
|
||||
[[constraint]]
|
||||
branch = "master"
|
||||
name = "yunion.io/x/log"
|
||||
@@ -45,71 +165,14 @@
|
||||
branch = "master"
|
||||
name = "yunion.io/x/pkg"
|
||||
|
||||
[[constraint]]
|
||||
branch = "master"
|
||||
name = "yunion.io/x/sqlchemy"
|
||||
|
||||
[[constraint]]
|
||||
branch = "master"
|
||||
name = "yunion.io/x/structarg"
|
||||
|
||||
# client-go v8.0.0 uses apimachinery 103fd098999dc9c0c88536f5c9ad2e5da39373ae
|
||||
# and api 072894a440bdee3a891dea811fe42902311cd2a3 (see Godep.json). go dep
|
||||
# is unable to match Godep.json automatically so have to specify here.
|
||||
[[constraint]]
|
||||
name = "k8s.io/client-go"
|
||||
version = "v8.0.0"
|
||||
[[override]]
|
||||
name = "k8s.io/apimachinery"
|
||||
revision = "103fd098999dc9c0c88536f5c9ad2e5da39373ae"
|
||||
[[override]]
|
||||
name = "k8s.io/api"
|
||||
revision = "072894a440bdee3a891dea811fe42902311cd2a3"
|
||||
|
||||
[[override]]
|
||||
name = "github.com/apache/thrift"
|
||||
revision = "e59b73d3c2bf1c328ccb78e683c0462fa1a473c7"
|
||||
[[override]]
|
||||
name = "github.com/ugorji/go"
|
||||
revision = "f3cacc17c85ecb7f1b6a9e373ee85d1480919868"
|
||||
|
||||
[[constraint]]
|
||||
name = "github.com/coredns/coredns"
|
||||
version = "v1.2.0"
|
||||
|
||||
[prune]
|
||||
go-tests = true
|
||||
unused-packages = true
|
||||
|
||||
[[constraint]]
|
||||
branch = "master"
|
||||
name = "github.com/vmware/govmomi"
|
||||
|
||||
|
||||
[[constraint]]
|
||||
branch = "master"
|
||||
name = "github.com/hako/durafmt"
|
||||
|
||||
[[constraint]]
|
||||
name = "github.com/Azure/azure-sdk-for-go"
|
||||
version = "19.1.0"
|
||||
|
||||
[[constraint]]
|
||||
branch = "master"
|
||||
name = "github.com/googollee/go-socket.io"
|
||||
|
||||
[[constraint]]
|
||||
branch = "master"
|
||||
name = "github.com/kr/pty"
|
||||
|
||||
[[constraint]]
|
||||
branch = "master"
|
||||
name = "github.com/Microsoft/azure-vhd-utils"
|
||||
|
||||
[[constraint]]
|
||||
branch = "master"
|
||||
name = "github.com/texttheater/golang-levenshtein"
|
||||
|
||||
[[constraint]]
|
||||
name = "github.com/360EntSecGroup-Skylar/excelize"
|
||||
version = "v1.3.0"
|
||||
|
||||
[[constraint]]
|
||||
name = "github.com/aws/aws-sdk-go"
|
||||
version = "1.15.43"
|
||||
|
||||
@@ -8,15 +8,15 @@ import (
|
||||
"github.com/aws/aws-sdk-go/aws/credentials"
|
||||
"github.com/aws/aws-sdk-go/aws/session"
|
||||
"github.com/aws/aws-sdk-go/service/ec2"
|
||||
"yunion.io/x/jsonutils"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
const (
|
||||
CLOUD_PROVIDER_AWS = models.CLOUD_PROVIDER_AWS
|
||||
CLOUD_PROVIDER_AWS_CN = "AWS"
|
||||
|
||||
AWS_DEFAULT_REGION = "cn-hangzhou"
|
||||
AWS_API_VERSION = "2014-05-26"
|
||||
AWS_DEFAULT_REGION = "us-west-1"
|
||||
AWS_API_VERSION = "2018-10-10"
|
||||
)
|
||||
|
||||
type SAwsClient struct {
|
||||
@@ -27,6 +27,15 @@ type SAwsClient struct {
|
||||
iregions []cloudprovider.ICloudRegion
|
||||
}
|
||||
|
||||
func NewAwsClient(providerId string, providerName string, accessKey string, secret string) (*SAwsClient, error) {
|
||||
client := SAwsClient{providerId: providerId, providerName: providerName, accessKey: accessKey, secret: secret}
|
||||
err := client.fetchRegions()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &client, nil
|
||||
}
|
||||
|
||||
func (self *SAwsClient) getDefaultSession() (*session.Session, error) {
|
||||
return session.NewSession(&sdk.Config{
|
||||
Region: sdk.String(AWS_DEFAULT_REGION),
|
||||
@@ -34,57 +43,125 @@ func (self *SAwsClient) getDefaultSession() (*session.Session, error) {
|
||||
})
|
||||
}
|
||||
|
||||
func (self *SAwsClient) UpdateAccount(accessKey, secret string) error {
|
||||
if self.accessKey != accessKey || self.secret != secret {
|
||||
self.accessKey = accessKey
|
||||
self.secret = secret
|
||||
return self.fetchRegions()
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
// 用于初始化region信息
|
||||
func (self *SAwsClient) fetchRegions() error {
|
||||
s, err := self.getDefaultSession()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
svc := ec2.New(s)
|
||||
// https://docs.aws.amazon.com/sdk-for-go/api/service/ec2/#EC2.DescribeRegions
|
||||
result, err := svc.DescribeRegions(&ec2.DescribeRegionsInput{})
|
||||
fmt.Println(result)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
sregions := make([]SRegion, 0)
|
||||
regions := jsonutils.ParseString("")
|
||||
regions.Unmarshal(&sregions, "Regions")
|
||||
|
||||
regions := make([]SRegion, 0)
|
||||
// empty iregions
|
||||
self.iregions = self.iregions[:0]
|
||||
for _, region := range result.Regions {
|
||||
name := *region.RegionName
|
||||
endpoint := *region.Endpoint
|
||||
sregion := SRegion{client: self, RegionId: name, RegionEndpoint: endpoint}
|
||||
regions = append(regions, sregion)
|
||||
self.iregions = append(self.iregions, &sregion)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self *SAwsClient) GetRegions() error {
|
||||
// https://docs.aws.amazon.com/sdk-for-go/api/service/ec2/#EC2.DescribeRegions
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
func (self *SAwsClient) UpdateAccount(accessKey, secret string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self *SAwsClient) GetRegion(regionId string) *SRegion {
|
||||
return nil
|
||||
// 只是使用fetchRegions初始化好的self.iregions. 本身并不从云服务器厂商拉取region信息
|
||||
func (self *SAwsClient) GetRegions() []SRegion {
|
||||
regions := make([]SRegion, len(self.iregions))
|
||||
for i := 0; i < len(regions); i += 1 {
|
||||
region := self.iregions[i].(*SRegion)
|
||||
regions[i] = *region
|
||||
}
|
||||
return regions
|
||||
}
|
||||
|
||||
func (self *SAwsClient) GetIRegions() []cloudprovider.ICloudRegion {
|
||||
panic("implement me")
|
||||
return self.iregions
|
||||
}
|
||||
|
||||
func (self *SAwsClient) GetRegion(regionId string) *SRegion {
|
||||
if len(regionId) == 0 {
|
||||
regionId = AWS_DEFAULT_REGION
|
||||
}
|
||||
for i := 0; i < len(self.iregions); i += 1 {
|
||||
if self.iregions[i].GetId() == regionId {
|
||||
return self.iregions[i].(*SRegion)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self *SAwsClient) GetIRegionById(id string) (cloudprovider.ICloudRegion, error) {
|
||||
panic("implement me")
|
||||
for i := 0; i < len(self.iregions); i += 1 {
|
||||
if self.iregions[i].GetGlobalId() == id {
|
||||
return self.iregions[i], nil
|
||||
}
|
||||
}
|
||||
return nil, cloudprovider.ErrNotFound
|
||||
}
|
||||
|
||||
func (self *SAwsClient) GetIHostById(id string) (cloudprovider.ICloudHost, error) {
|
||||
panic("implement me")
|
||||
for i := 0; i < len(self.iregions); i += 1 {
|
||||
ihost, err := self.iregions[i].GetIHostById(id)
|
||||
if err == nil {
|
||||
return ihost, nil
|
||||
} else if err != cloudprovider.ErrNotFound {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
return nil, cloudprovider.ErrNotFound
|
||||
}
|
||||
|
||||
func (self *SAwsClient) GetIVpcById(id string) (cloudprovider.ICloudVpc, error) {
|
||||
panic("implement me")
|
||||
for i := 0; i < len(self.iregions); i += 1 {
|
||||
ihost, err := self.iregions[i].GetIVpcById(id)
|
||||
if err == nil {
|
||||
return ihost, nil
|
||||
} else if err != cloudprovider.ErrNotFound {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
return nil, cloudprovider.ErrNotFound
|
||||
}
|
||||
|
||||
func (self *SAwsClient) GetIStorageById(id string) (cloudprovider.ICloudStorage, error) {
|
||||
panic("implement me")
|
||||
for i := 0; i < len(self.iregions); i += 1 {
|
||||
ihost, err := self.iregions[i].GetIStorageById(id)
|
||||
if err == nil {
|
||||
return ihost, nil
|
||||
} else if err != cloudprovider.ErrNotFound {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
return nil, cloudprovider.ErrNotFound
|
||||
}
|
||||
|
||||
func (self *SAwsClient) GetIStoragecacheById(id string) (cloudprovider.ICloudStoragecache, error) {
|
||||
panic("implement me")
|
||||
for i := 0; i < len(self.iregions); i += 1 {
|
||||
ihost, err := self.iregions[i].GetIStoragecacheById(id)
|
||||
if err == nil {
|
||||
return ihost, nil
|
||||
} else if err != cloudprovider.ErrNotFound {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
return nil, cloudprovider.ErrNotFound
|
||||
}
|
||||
|
||||
type SAccountBalance struct {
|
||||
@@ -97,13 +174,4 @@ type SAccountBalance struct {
|
||||
|
||||
func (self *SAwsClient) QueryAccountBalance() (*SAccountBalance, error) {
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
func NewAwsClient(providerId string, providerName string, accessKey string, secret string) (*SAwsClient, error) {
|
||||
client := SAwsClient{providerId: providerId, providerName: providerName, accessKey: accessKey, secret: secret}
|
||||
err := client.fetchRegions()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &client, nil
|
||||
}
|
||||
}
|
||||
2
pkg/util/aws/aws_test.go
Normal file
2
pkg/util/aws/aws_test.go
Normal file
@@ -0,0 +1,2 @@
|
||||
package aws
|
||||
|
||||
18
pkg/util/aws/instancetype.go
Normal file
18
pkg/util/aws/instancetype.go
Normal file
@@ -0,0 +1,18 @@
|
||||
package aws
|
||||
|
||||
type SInstanceType struct {
|
||||
CpuCoreCount int
|
||||
MemorySize float32
|
||||
EniQuantity int // 实例规格支持网卡数量
|
||||
GPUAmount int
|
||||
GPUSpec string
|
||||
InstanceTypeFamily string
|
||||
InstanceTypeId string
|
||||
LocalStorageCategory string
|
||||
LocalStorageAmount int
|
||||
LocalStorageCapacity int64
|
||||
InstanceBandwidthRx int
|
||||
InstanceBandwidthTx int
|
||||
InstancePpsRx int
|
||||
InstancePpsTx int
|
||||
}
|
||||
@@ -14,7 +14,11 @@ func (self *SAwsProviderFactory) GetId() string {
|
||||
}
|
||||
|
||||
func (self *SAwsProviderFactory) GetProvider(providerId, providerName, url, account, secret string) (cloudprovider.ICloudProvider, error) {
|
||||
panic("implement me")
|
||||
client, err := aws.NewAwsClient(providerId, providerName, account, secret)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &SAwsProvider{client: client}, nil
|
||||
}
|
||||
|
||||
func init() {
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
package aws
|
||||
|
||||
import "yunion.io/x/onecloud/pkg/cloudprovider"
|
||||
import (
|
||||
"yunion.io/x/onecloud/pkg/cloudprovider"
|
||||
"yunion.io/x/jsonutils"
|
||||
)
|
||||
|
||||
type SRegion struct {
|
||||
client *SAwsClient
|
||||
@@ -8,12 +11,102 @@ type SRegion struct {
|
||||
izones []cloudprovider.ICloudZone
|
||||
ivpcs []cloudprovider.ICloudVpc
|
||||
|
||||
storageCache *SStoragecache
|
||||
storageCache *SStoragecache
|
||||
instanceTypes []SInstanceType
|
||||
|
||||
ID string
|
||||
SubscriptionID string
|
||||
Name string
|
||||
DisplayName string
|
||||
Latitude float32
|
||||
Longitude float32
|
||||
RegionEndpoint string
|
||||
RegionId string // 这里为保持一致沿用阿里云RegionId的叫法, 与AWS RegionName字段对应
|
||||
}
|
||||
|
||||
func (self *SRegion) GetId() string {
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
func (self *SRegion) GetName() string {
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
func (self *SRegion) GetGlobalId() string {
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
func (self *SRegion) GetStatus() string {
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
func (self *SRegion) Refresh() error {
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
func (self *SRegion) IsEmulated() bool {
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
func (self *SRegion) GetMetadata() *jsonutils.JSONDict {
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
func (self *SRegion) GetLatitude() float32 {
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
func (self *SRegion) GetLongitude() float32 {
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
func (self *SRegion) GetIZones() ([]cloudprovider.ICloudZone, error) {
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
func (self *SRegion) GetIVpcs() ([]cloudprovider.ICloudVpc, error) {
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
func (self *SRegion) GetIEips() ([]cloudprovider.ICloudEIP, error) {
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
func (self *SRegion) GetISnapshots() ([]cloudprovider.ICloudSnapshot, error) {
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
func (self *SRegion) GetISnapshotById(snapshotId string) (cloudprovider.ICloudSnapshot, error) {
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
func (self *SRegion) GetIZoneById(id string) (cloudprovider.ICloudZone, error) {
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
func (self *SRegion) GetIVpcById(id string) (cloudprovider.ICloudVpc, error) {
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
func (self *SRegion) GetIHostById(id string) (cloudprovider.ICloudHost, error) {
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
func (self *SRegion) GetIStorageById(id string) (cloudprovider.ICloudStorage, error) {
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
func (self *SRegion) GetIStoragecacheById(id string) (cloudprovider.ICloudStoragecache, error) {
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
func (self *SRegion) CreateIVpc(name string, desc string, cidr string) (cloudprovider.ICloudVpc, error) {
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
func (self *SRegion) CreateEIP(name string, bwMbps int, chargeType string) (cloudprovider.ICloudEIP, error) {
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
func (self *SRegion) GetIEipById(id string) (cloudprovider.ICloudEIP, error) {
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
func (self *SRegion) GetProvider() string {
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
|
||||
11
vendor/github.com/360EntSecGroup-Skylar/excelize/.travis.yml
generated
vendored
11
vendor/github.com/360EntSecGroup-Skylar/excelize/.travis.yml
generated
vendored
@@ -6,6 +6,17 @@ install:
|
||||
go:
|
||||
- 1.8.x
|
||||
- 1.9.x
|
||||
- 1.10.x
|
||||
- 1.11.x
|
||||
|
||||
os:
|
||||
- linux
|
||||
- osx
|
||||
|
||||
env:
|
||||
matrix:
|
||||
- GOARCH=amd64
|
||||
- GOARCH=386
|
||||
|
||||
script:
|
||||
- go vet ./...
|
||||
|
||||
19
vendor/github.com/360EntSecGroup-Skylar/excelize/CONTRIBUTING.md
generated
vendored
19
vendor/github.com/360EntSecGroup-Skylar/excelize/CONTRIBUTING.md
generated
vendored
@@ -25,7 +25,6 @@ Security reports are greatly appreciated and we will publicly thank you for it.
|
||||
We currently do not offer a paid security bounty program, but are not
|
||||
ruling it out in the future.
|
||||
|
||||
|
||||
## Reporting other issues
|
||||
|
||||
A great way to contribute to the project is to send a detailed report when you
|
||||
@@ -44,7 +43,7 @@ When reporting issues, always include the output of `go env`.
|
||||
|
||||
Also include the steps required to reproduce the problem if possible and
|
||||
applicable. This information will help us review and fix your issue faster.
|
||||
When sending lengthy log-files, consider posting them as a gist (https://gist.github.com).
|
||||
When sending lengthy log-files, consider posting them as a gist [https://gist.github.com](https://gist.github.com).
|
||||
Don't forget to remove sensitive data from your logfiles before posting (you can
|
||||
replace those parts with "REDACTED").
|
||||
|
||||
@@ -77,9 +76,9 @@ However, there might be a way to implement that feature *on top of* excelize.
|
||||
|
||||
Fork the repository and make changes on your fork in a feature branch:
|
||||
|
||||
- If it's a bug fix branch, name it XXXX-something where XXXX is the number of
|
||||
* If it's a bug fix branch, name it XXXX-something where XXXX is the number of
|
||||
the issue.
|
||||
- If it's a feature branch, create an enhancement issue to announce
|
||||
* If it's a feature branch, create an enhancement issue to announce
|
||||
your intentions, and name it XXXX-something where XXXX is the number of the
|
||||
issue.
|
||||
|
||||
@@ -194,7 +193,7 @@ signature certifies that you wrote the patch or otherwise have the right to pass
|
||||
it on as an open-source patch. The rules are pretty simple: if you can certify
|
||||
the below (from [developercertificate.org](http://developercertificate.org/)):
|
||||
|
||||
```
|
||||
```text
|
||||
Developer Certificate of Origin
|
||||
Version 1.1
|
||||
|
||||
@@ -242,14 +241,14 @@ Use your real name (sorry, no pseudonyms or anonymous contributions.)
|
||||
If you set your `user.name` and `user.email` git configs, you can sign your
|
||||
commit automatically with `git commit -s`.
|
||||
|
||||
### How can I become a maintainer?
|
||||
### How can I become a maintainer
|
||||
|
||||
First, all maintainers have 3 things
|
||||
|
||||
- They share responsibility in the project's success.
|
||||
- They have made a long-term, recurring time investment to improve the project.
|
||||
- They spend that time doing whatever needs to be done, not necessarily what
|
||||
is the most interesting or fun.
|
||||
* They share responsibility in the project's success.
|
||||
* They have made a long-term, recurring time investment to improve the project.
|
||||
* They spend that time doing whatever needs to be done, not necessarily what
|
||||
is the most interesting or fun.
|
||||
|
||||
Maintainers are often under-appreciated, because their work is harder to appreciate.
|
||||
It's easy to appreciate a really cool and technically advanced feature. It's harder
|
||||
|
||||
45
vendor/github.com/360EntSecGroup-Skylar/excelize/PULL_REQUEST_TEMPLATE.md
generated
vendored
Normal file
45
vendor/github.com/360EntSecGroup-Skylar/excelize/PULL_REQUEST_TEMPLATE.md
generated
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
# PR Details
|
||||
|
||||
<!--- Provide a general summary of your changes in the Title above -->
|
||||
|
||||
## Description
|
||||
|
||||
<!--- Describe your changes in detail -->
|
||||
|
||||
## Related Issue
|
||||
|
||||
<!--- This project only accepts pull requests related to open issues -->
|
||||
<!--- If suggesting a new feature or change, please discuss it in an issue first -->
|
||||
<!--- If fixing a bug, there should be an issue describing it with steps to reproduce -->
|
||||
<!--- Please link to the issue here: -->
|
||||
|
||||
## Motivation and Context
|
||||
|
||||
<!--- Why is this change required? What problem does it solve? -->
|
||||
|
||||
## How Has This Been Tested
|
||||
|
||||
<!--- Please describe in detail how you tested your changes. -->
|
||||
<!--- Include details of your testing environment, and the tests you ran to -->
|
||||
<!--- see how your change affects other areas of the code, etc. -->
|
||||
|
||||
## Types of changes
|
||||
|
||||
<!--- What types of changes does your code introduce? Put an `x` in all the boxes that apply: -->
|
||||
|
||||
- [ ] Docs change / refactoring / dependency upgrade
|
||||
- [ ] Bug fix (non-breaking change which fixes an issue)
|
||||
- [ ] New feature (non-breaking change which adds functionality)
|
||||
- [ ] Breaking change (fix or feature that would cause existing functionality to change)
|
||||
|
||||
## Checklist
|
||||
|
||||
<!--- Go over all the following points, and put an `x` in all the boxes that apply. -->
|
||||
<!--- If you're unsure about any of these, don't hesitate to ask. We're here to help! -->
|
||||
|
||||
- [ ] My code follows the code style of this project.
|
||||
- [ ] My change requires a change to the documentation.
|
||||
- [ ] I have updated the documentation accordingly.
|
||||
- [ ] I have read the **CONTRIBUTING** document.
|
||||
- [ ] I have added tests to cover my changes.
|
||||
- [ ] All new and existing tests passed.
|
||||
2
vendor/github.com/360EntSecGroup-Skylar/excelize/README.md
generated
vendored
2
vendor/github.com/360EntSecGroup-Skylar/excelize/README.md
generated
vendored
@@ -11,7 +11,7 @@
|
||||
|
||||
## Introduction
|
||||
|
||||
Excelize is a library written in pure Golang and providing a set of functions that allow you to write to and read from XLSX files. Support reads and writes XLSX file generated by Microsoft Excel™ 2007 and later. Support save file without losing original charts of XLSX. This library needs Go version 1.8 or later. The full API docs can be seen using go's built-in documentation tool, or online at [godoc.org](https://godoc.org/github.com/360EntSecGroup-Skylar/excelize) and [Chinese translation](https://xuri.me/excelize/zh_cn).
|
||||
Excelize is a library written in pure Go and providing a set of functions that allow you to write to and read from XLSX files. Support reads and writes XLSX file generated by Microsoft Excel™ 2007 and later. Support save file without losing original charts of XLSX. This library needs Go version 1.8 or later. The full API docs can be seen using go's built-in documentation tool, or online at [godoc.org](https://godoc.org/github.com/360EntSecGroup-Skylar/excelize) and [docs reference](https://xuri.me/excelize/).
|
||||
|
||||
## Basic Usage
|
||||
|
||||
|
||||
2
vendor/github.com/360EntSecGroup-Skylar/excelize/README_zh.md
generated
vendored
2
vendor/github.com/360EntSecGroup-Skylar/excelize/README_zh.md
generated
vendored
@@ -11,7 +11,7 @@
|
||||
|
||||
## 简介
|
||||
|
||||
Excelize 是 Go 语言编写的用于操作 Office Excel 文档类库,基于 ECMA-376 Office OpenXML 标准。可以使用它来读取、写入由 Microsoft Excel™ 2007 及以上版本创建的 XLSX 文档。相比较其他的开源类库,Excelize 支持写入原本带有图片(表)、透视表和切片器等复杂样式的文档,还支持向 Excel 文档中插入图片与图表,并且在保存后不会丢失文档原有样式,可以应用于各类报表系统中。使用本类库要求使用的 Go 语言为 1.8 或更高版本,完整的 API 使用文档请访问 [godoc.org](https://godoc.org/github.com/360EntSecGroup-Skylar/excelize) 或查看 [中文翻译](https://xuri.me/excelize/zh_cn)。
|
||||
Excelize 是 Go 语言编写的用于操作 Office Excel 文档类库,基于 ECMA-376 Office OpenXML 标准。可以使用它来读取、写入由 Microsoft Excel™ 2007 及以上版本创建的 XLSX 文档。相比较其他的开源类库,Excelize 支持写入原本带有图片(表)、透视表和切片器等复杂样式的文档,还支持向 Excel 文档中插入图片与图表,并且在保存后不会丢失文档原有样式,可以应用于各类报表系统中。使用本类库要求使用的 Go 语言为 1.8 或更高版本,完整的 API 使用文档请访问 [godoc.org](https://godoc.org/github.com/360EntSecGroup-Skylar/excelize) 或查看 [参考文档](https://xuri.me/excelize/)。
|
||||
|
||||
## 快速上手
|
||||
|
||||
|
||||
115
vendor/github.com/360EntSecGroup-Skylar/excelize/cell.go
generated
vendored
115
vendor/github.com/360EntSecGroup-Skylar/excelize/cell.go
generated
vendored
@@ -1,3 +1,12 @@
|
||||
// Copyright 2016 - 2018 The excelize Authors. All rights reserved. Use of
|
||||
// this source code is governed by a BSD-style license that can be found in
|
||||
// the LICENSE file.
|
||||
//
|
||||
// Package excelize providing a set of functions that allow you to write to
|
||||
// and read from XLSX files. Support reads and writes XLSX file generated by
|
||||
// Microsoft Excel™ 2007 and later. Support save file without losing original
|
||||
// charts of XLSX. This library needs Go version 1.8 or later.
|
||||
|
||||
package excelize
|
||||
|
||||
import (
|
||||
@@ -9,7 +18,18 @@ import (
|
||||
"time"
|
||||
)
|
||||
|
||||
// mergeCellsParser provides function to check merged cells in worksheet by
|
||||
const (
|
||||
// STCellFormulaTypeArray defined the formula is an array formula.
|
||||
STCellFormulaTypeArray = "array"
|
||||
// STCellFormulaTypeDataTable defined the formula is a data table formula.
|
||||
STCellFormulaTypeDataTable = "dataTable"
|
||||
// STCellFormulaTypeNormal defined the formula is a regular cell formula.
|
||||
STCellFormulaTypeNormal = "normal"
|
||||
// STCellFormulaTypeShared defined the formula is part of a shared formula.
|
||||
STCellFormulaTypeShared = "shared"
|
||||
)
|
||||
|
||||
// mergeCellsParser provides a function to check merged cells in worksheet by
|
||||
// given axis.
|
||||
func (f *File) mergeCellsParser(xlsx *xlsxWorksheet, axis string) string {
|
||||
axis = strings.ToUpper(axis)
|
||||
@@ -23,8 +43,8 @@ func (f *File) mergeCellsParser(xlsx *xlsxWorksheet, axis string) string {
|
||||
return axis
|
||||
}
|
||||
|
||||
// SetCellValue provides function to set value of a cell. The following shows
|
||||
// the supported data types:
|
||||
// SetCellValue provides a function to set value of a cell. The following
|
||||
// shows the supported data types:
|
||||
//
|
||||
// int
|
||||
// int8
|
||||
@@ -72,7 +92,7 @@ func (f *File) SetCellValue(sheet, axis string, value interface{}) {
|
||||
}
|
||||
}
|
||||
|
||||
// setCellIntValue provides function to set int value of a cell.
|
||||
// setCellIntValue provides a function to set int value of a cell.
|
||||
func (f *File) setCellIntValue(sheet, axis string, value interface{}) {
|
||||
switch value.(type) {
|
||||
case int:
|
||||
@@ -100,7 +120,7 @@ func (f *File) setCellIntValue(sheet, axis string, value interface{}) {
|
||||
}
|
||||
}
|
||||
|
||||
// SetCellBool provides function to set bool type value of a cell by given
|
||||
// SetCellBool provides a function to set bool type value of a cell by given
|
||||
// worksheet name, cell coordinates and cell value.
|
||||
func (f *File) SetCellBool(sheet, axis string, value bool) {
|
||||
xlsx := f.workSheetReader(sheet)
|
||||
@@ -128,10 +148,10 @@ func (f *File) SetCellBool(sheet, axis string, value bool) {
|
||||
}
|
||||
}
|
||||
|
||||
// GetCellValue provides function to get formatted value from cell by given
|
||||
// worksheet name and axis in XLSX file. If it is possible to apply a format to
|
||||
// the cell value, it will do so, if not then an error will be returned, along
|
||||
// with the raw value of the cell.
|
||||
// GetCellValue provides a function to get formatted value from cell by given
|
||||
// worksheet name and axis in XLSX file. If it is possible to apply a format
|
||||
// to the cell value, it will do so, if not then an error will be returned,
|
||||
// along with the raw value of the cell.
|
||||
func (f *File) GetCellValue(sheet, axis string) string {
|
||||
xlsx := f.workSheetReader(sheet)
|
||||
axis = f.mergeCellsParser(xlsx, axis)
|
||||
@@ -163,9 +183,9 @@ func (f *File) GetCellValue(sheet, axis string) string {
|
||||
return ""
|
||||
}
|
||||
|
||||
// formattedValue provides function to returns a value after formatted. If it is
|
||||
// possible to apply a format to the cell value, it will do so, if not then an
|
||||
// error will be returned, along with the raw value of the cell.
|
||||
// formattedValue provides a function to returns a value after formatted. If
|
||||
// it is possible to apply a format to the cell value, it will do so, if not
|
||||
// then an error will be returned, along with the raw value of the cell.
|
||||
func (f *File) formattedValue(s int, v string) string {
|
||||
if s == 0 {
|
||||
return v
|
||||
@@ -178,7 +198,7 @@ func (f *File) formattedValue(s int, v string) string {
|
||||
return v
|
||||
}
|
||||
|
||||
// GetCellStyle provides function to get cell style index by given worksheet
|
||||
// GetCellStyle provides a function to get cell style index by given worksheet
|
||||
// name and cell coordinates.
|
||||
func (f *File) GetCellStyle(sheet, axis string) int {
|
||||
xlsx := f.workSheetReader(sheet)
|
||||
@@ -200,8 +220,8 @@ func (f *File) GetCellStyle(sheet, axis string) int {
|
||||
return f.prepareCellStyle(xlsx, cell, xlsx.SheetData.Row[xAxis].C[yAxis].S)
|
||||
}
|
||||
|
||||
// GetCellFormula provides function to get formula from cell by given worksheet
|
||||
// name and axis in XLSX file.
|
||||
// GetCellFormula provides a function to get formula from cell by given
|
||||
// worksheet name and axis in XLSX file.
|
||||
func (f *File) GetCellFormula(sheet, axis string) string {
|
||||
xlsx := f.workSheetReader(sheet)
|
||||
axis = f.mergeCellsParser(xlsx, axis)
|
||||
@@ -224,6 +244,9 @@ func (f *File) GetCellFormula(sheet, axis string) string {
|
||||
if xlsx.SheetData.Row[k].R == row {
|
||||
for i := range xlsx.SheetData.Row[k].C {
|
||||
if axis == xlsx.SheetData.Row[k].C[i].R {
|
||||
if xlsx.SheetData.Row[k].C[i].F.T == STCellFormulaTypeShared {
|
||||
return getSharedForumula(xlsx, xlsx.SheetData.Row[k].C[i].F.Si)
|
||||
}
|
||||
if xlsx.SheetData.Row[k].C[i].F != nil {
|
||||
return xlsx.SheetData.Row[k].C[i].F.Content
|
||||
}
|
||||
@@ -234,7 +257,35 @@ func (f *File) GetCellFormula(sheet, axis string) string {
|
||||
return ""
|
||||
}
|
||||
|
||||
// SetCellFormula provides function to set cell formula by given string and
|
||||
// getSharedForumula find a cell contains the same formula as another cell,
|
||||
// the "shared" value can be used for the t attribute and the si attribute can
|
||||
// be used to refer to the cell containing the formula. Two formulas are
|
||||
// considered to be the same when their respective representations in
|
||||
// R1C1-reference notation, are the same.
|
||||
//
|
||||
// Note that this function not validate ref tag to check the cell if or not in
|
||||
// allow area, and always return origin shared formula.
|
||||
func getSharedForumula(xlsx *xlsxWorksheet, si string) string {
|
||||
for k := range xlsx.SheetData.Row {
|
||||
for i := range xlsx.SheetData.Row[k].C {
|
||||
if xlsx.SheetData.Row[k].C[i].F == nil {
|
||||
continue
|
||||
}
|
||||
if xlsx.SheetData.Row[k].C[i].F.T != STCellFormulaTypeShared {
|
||||
continue
|
||||
}
|
||||
if xlsx.SheetData.Row[k].C[i].F.Si != si {
|
||||
continue
|
||||
}
|
||||
if xlsx.SheetData.Row[k].C[i].F.Ref != "" {
|
||||
return xlsx.SheetData.Row[k].C[i].F.Content
|
||||
}
|
||||
}
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
// SetCellFormula provides a function to set cell formula by given string and
|
||||
// worksheet name.
|
||||
func (f *File) SetCellFormula(sheet, axis, formula string) {
|
||||
xlsx := f.workSheetReader(sheet)
|
||||
@@ -263,10 +314,10 @@ func (f *File) SetCellFormula(sheet, axis, formula string) {
|
||||
}
|
||||
}
|
||||
|
||||
// SetCellHyperLink provides function to set cell hyperlink by given worksheet
|
||||
// name and link URL address. LinkType defines two types of hyperlink "External"
|
||||
// for web site or "Location" for moving to one of cell in this workbook. The
|
||||
// below is example for external link.
|
||||
// SetCellHyperLink provides a function to set cell hyperlink by given
|
||||
// worksheet name and link URL address. LinkType defines two types of
|
||||
// hyperlink "External" for web site or "Location" for moving to one of cell
|
||||
// in this workbook. The below is example for external link.
|
||||
//
|
||||
// xlsx.SetCellHyperLink("Sheet1", "A3", "https://github.com/360EntSecGroup-Skylar/excelize", "External")
|
||||
// // Set underline and font color style for the cell.
|
||||
@@ -299,10 +350,10 @@ func (f *File) SetCellHyperLink(sheet, axis, link, linkType string) {
|
||||
xlsx.Hyperlinks.Hyperlink = append(xlsx.Hyperlinks.Hyperlink, hyperlink)
|
||||
}
|
||||
|
||||
// GetCellHyperLink provides function to get cell hyperlink by given worksheet
|
||||
// name and axis. Boolean type value link will be ture if the cell has a
|
||||
// hyperlink and the target is the address of the hyperlink. Otherwise, the
|
||||
// value of link will be false and the value of the target will be a blank
|
||||
// GetCellHyperLink provides a function to get cell hyperlink by given
|
||||
// worksheet name and axis. Boolean type value link will be ture if the cell
|
||||
// has a hyperlink and the target is the address of the hyperlink. Otherwise,
|
||||
// the value of link will be false and the value of the target will be a blank
|
||||
// string. For example get hyperlink of Sheet1!H6:
|
||||
//
|
||||
// link, target := xlsx.GetCellHyperLink("Sheet1", "H6")
|
||||
@@ -327,8 +378,8 @@ func (f *File) GetCellHyperLink(sheet, axis string) (bool, string) {
|
||||
return link, target
|
||||
}
|
||||
|
||||
// MergeCell provides function to merge cells by given coordinate area and sheet
|
||||
// name. For example create a merged cell of D3:E9 on Sheet1:
|
||||
// MergeCell provides a function to merge cells by given coordinate area and
|
||||
// sheet name. For example create a merged cell of D3:E9 on Sheet1:
|
||||
//
|
||||
// xlsx.MergeCell("Sheet1", "D3", "E9")
|
||||
//
|
||||
@@ -387,7 +438,7 @@ func (f *File) MergeCell(sheet, hcell, vcell string) {
|
||||
}
|
||||
}
|
||||
|
||||
// SetCellInt provides function to set int type value of a cell by given
|
||||
// SetCellInt provides a function to set int type value of a cell by given
|
||||
// worksheet name, cell coordinates and cell value.
|
||||
func (f *File) SetCellInt(sheet, axis string, value int) {
|
||||
xlsx := f.workSheetReader(sheet)
|
||||
@@ -411,7 +462,7 @@ func (f *File) SetCellInt(sheet, axis string, value int) {
|
||||
xlsx.SheetData.Row[xAxis].C[yAxis].V = strconv.Itoa(value)
|
||||
}
|
||||
|
||||
// prepareCellStyle provides function to prepare style index of cell in
|
||||
// prepareCellStyle provides a function to prepare style index of cell in
|
||||
// worksheet by given column index and style index.
|
||||
func (f *File) prepareCellStyle(xlsx *xlsxWorksheet, col, style int) int {
|
||||
if xlsx.Cols != nil && style == 0 {
|
||||
@@ -424,8 +475,8 @@ func (f *File) prepareCellStyle(xlsx *xlsxWorksheet, col, style int) int {
|
||||
return style
|
||||
}
|
||||
|
||||
// SetCellStr provides function to set string type value of a cell. Total number
|
||||
// of characters that a cell can contain 32767 characters.
|
||||
// SetCellStr provides a function to set string type value of a cell. Total
|
||||
// number of characters that a cell can contain 32767 characters.
|
||||
func (f *File) SetCellStr(sheet, axis, value string) {
|
||||
xlsx := f.workSheetReader(sheet)
|
||||
axis = f.mergeCellsParser(xlsx, axis)
|
||||
@@ -460,7 +511,7 @@ func (f *File) SetCellStr(sheet, axis, value string) {
|
||||
xlsx.SheetData.Row[xAxis].C[yAxis].V = value
|
||||
}
|
||||
|
||||
// SetCellDefault provides function to set string type value of a cell as
|
||||
// SetCellDefault provides a function to set string type value of a cell as
|
||||
// default format without escaping the cell.
|
||||
func (f *File) SetCellDefault(sheet, axis, value string) {
|
||||
xlsx := f.workSheetReader(sheet)
|
||||
@@ -525,7 +576,7 @@ func (f *File) SetSheetRow(sheet, axis string, slice interface{}) {
|
||||
}
|
||||
}
|
||||
|
||||
// checkCellInArea provides function to determine if a given coordinate is
|
||||
// checkCellInArea provides a function to determine if a given coordinate is
|
||||
// within an area.
|
||||
func checkCellInArea(cell, area string) bool {
|
||||
cell = strings.ToUpper(cell)
|
||||
|
||||
109
vendor/github.com/360EntSecGroup-Skylar/excelize/chart.go
generated
vendored
109
vendor/github.com/360EntSecGroup-Skylar/excelize/chart.go
generated
vendored
@@ -1,3 +1,12 @@
|
||||
// Copyright 2016 - 2018 The excelize Authors. All rights reserved. Use of
|
||||
// this source code is governed by a BSD-style license that can be found in
|
||||
// the LICENSE file.
|
||||
//
|
||||
// Package excelize providing a set of functions that allow you to write to
|
||||
// and read from XLSX files. Support reads and writes XLSX file generated by
|
||||
// Microsoft Excel™ 2007 and later. Support save file without losing original
|
||||
// charts of XLSX. This library needs Go version 1.8 or later.
|
||||
|
||||
package excelize
|
||||
|
||||
import (
|
||||
@@ -190,9 +199,9 @@ var (
|
||||
}
|
||||
)
|
||||
|
||||
// parseFormatChartSet provides function to parse the format settings of the
|
||||
// parseFormatChartSet provides a function to parse the format settings of the
|
||||
// chart with default value.
|
||||
func parseFormatChartSet(formatSet string) *formatChart {
|
||||
func parseFormatChartSet(formatSet string) (*formatChart, error) {
|
||||
format := formatChart{
|
||||
Dimension: formatChartDimension{
|
||||
Width: 480,
|
||||
@@ -216,8 +225,8 @@ func parseFormatChartSet(formatSet string) *formatChart {
|
||||
},
|
||||
ShowBlanksAs: "gap",
|
||||
}
|
||||
json.Unmarshal([]byte(formatSet), &format)
|
||||
return &format
|
||||
err := json.Unmarshal([]byte(formatSet), &format)
|
||||
return &format, err
|
||||
}
|
||||
|
||||
// AddChart provides the method to add chart in a sheet by given chart format
|
||||
@@ -352,13 +361,18 @@ func parseFormatChartSet(formatSet string) *formatChart {
|
||||
// minimum
|
||||
//
|
||||
// reverse_order: Specifies that the categories or values on reverse order (orientation of the chart). The reverse_order property is optional. The default value is false.
|
||||
//
|
||||
// maximum: Specifies that the fixed maximum, 0 is auto. The maximum property is optional. The default value is auto.
|
||||
//
|
||||
// minimum: Specifies that the fixed minimum, 0 is auto. The minimum property is optional. The default value is auto.
|
||||
//
|
||||
// Set chart size by dimension property. The dimension property is optional. The default width is 480, and height is 290.
|
||||
//
|
||||
func (f *File) AddChart(sheet, cell, format string) {
|
||||
formatSet := parseFormatChartSet(format)
|
||||
func (f *File) AddChart(sheet, cell, format string) error {
|
||||
formatSet, err := parseFormatChartSet(format)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
// Read sheet data.
|
||||
xlsx := f.workSheetReader(sheet)
|
||||
// Add first picture for given sheet, create xl/drawings/ and xl/drawings/_rels/ folder.
|
||||
@@ -371,9 +385,10 @@ func (f *File) AddChart(sheet, cell, format string) {
|
||||
f.addChart(formatSet)
|
||||
f.addContentTypePart(chartID, "chart")
|
||||
f.addContentTypePart(drawingID, "drawings")
|
||||
return err
|
||||
}
|
||||
|
||||
// countCharts provides function to get chart files count storage in the
|
||||
// countCharts provides a function to get chart files count storage in the
|
||||
// folder xl/charts.
|
||||
func (f *File) countCharts() int {
|
||||
count := 0
|
||||
@@ -385,7 +400,7 @@ func (f *File) countCharts() int {
|
||||
return count
|
||||
}
|
||||
|
||||
// prepareDrawing provides function to prepare drawing ID and XML by given
|
||||
// prepareDrawing provides a function to prepare drawing ID and XML by given
|
||||
// drawingID, worksheet name and default drawingXML.
|
||||
func (f *File) prepareDrawing(xlsx *xlsxWorksheet, drawingID int, sheet, drawingXML string) (int, string) {
|
||||
sheetRelationshipsDrawingXML := "../drawings/drawing" + strconv.Itoa(drawingID) + ".xml"
|
||||
@@ -402,8 +417,8 @@ func (f *File) prepareDrawing(xlsx *xlsxWorksheet, drawingID int, sheet, drawing
|
||||
return drawingID, drawingXML
|
||||
}
|
||||
|
||||
// addChart provides function to create chart as xl/charts/chart%d.xml by given
|
||||
// format sets.
|
||||
// addChart provides a function to create chart as xl/charts/chart%d.xml by
|
||||
// given format sets.
|
||||
func (f *File) addChart(formatSet *formatChart) {
|
||||
count := f.countCharts()
|
||||
xlsxChartSpace := xlsxChartSpace{
|
||||
@@ -558,7 +573,7 @@ func (f *File) addChart(formatSet *formatChart) {
|
||||
f.saveFileList(media, chart)
|
||||
}
|
||||
|
||||
// drawBaseChart provides function to draw the c:plotArea element for bar,
|
||||
// drawBaseChart provides a function to draw the c:plotArea element for bar,
|
||||
// and column series charts by given format sets.
|
||||
func (f *File) drawBaseChart(formatSet *formatChart) *cPlotArea {
|
||||
c := cCharts{
|
||||
@@ -655,7 +670,7 @@ func (f *File) drawBaseChart(formatSet *formatChart) *cPlotArea {
|
||||
return charts[formatSet.Type]
|
||||
}
|
||||
|
||||
// drawDoughnutChart provides function to draw the c:plotArea element for
|
||||
// drawDoughnutChart provides a function to draw the c:plotArea element for
|
||||
// doughnut chart by given format sets.
|
||||
func (f *File) drawDoughnutChart(formatSet *formatChart) *cPlotArea {
|
||||
return &cPlotArea{
|
||||
@@ -669,8 +684,8 @@ func (f *File) drawDoughnutChart(formatSet *formatChart) *cPlotArea {
|
||||
}
|
||||
}
|
||||
|
||||
// drawLineChart provides function to draw the c:plotArea element for line chart
|
||||
// by given format sets.
|
||||
// drawLineChart provides a function to draw the c:plotArea element for line
|
||||
// chart by given format sets.
|
||||
func (f *File) drawLineChart(formatSet *formatChart) *cPlotArea {
|
||||
return &cPlotArea{
|
||||
LineChart: &cCharts{
|
||||
@@ -695,8 +710,8 @@ func (f *File) drawLineChart(formatSet *formatChart) *cPlotArea {
|
||||
}
|
||||
}
|
||||
|
||||
// drawPieChart provides function to draw the c:plotArea element for pie chart
|
||||
// by given format sets.
|
||||
// drawPieChart provides a function to draw the c:plotArea element for pie
|
||||
// chart by given format sets.
|
||||
func (f *File) drawPieChart(formatSet *formatChart) *cPlotArea {
|
||||
return &cPlotArea{
|
||||
PieChart: &cCharts{
|
||||
@@ -708,8 +723,8 @@ func (f *File) drawPieChart(formatSet *formatChart) *cPlotArea {
|
||||
}
|
||||
}
|
||||
|
||||
// drawPie3DChart provides function to draw the c:plotArea element for 3D pie
|
||||
// chart by given format sets.
|
||||
// drawPie3DChart provides a function to draw the c:plotArea element for 3D
|
||||
// pie chart by given format sets.
|
||||
func (f *File) drawPie3DChart(formatSet *formatChart) *cPlotArea {
|
||||
return &cPlotArea{
|
||||
Pie3DChart: &cCharts{
|
||||
@@ -721,7 +736,7 @@ func (f *File) drawPie3DChart(formatSet *formatChart) *cPlotArea {
|
||||
}
|
||||
}
|
||||
|
||||
// drawRadarChart provides function to draw the c:plotArea element for radar
|
||||
// drawRadarChart provides a function to draw the c:plotArea element for radar
|
||||
// chart by given format sets.
|
||||
func (f *File) drawRadarChart(formatSet *formatChart) *cPlotArea {
|
||||
return &cPlotArea{
|
||||
@@ -744,8 +759,8 @@ func (f *File) drawRadarChart(formatSet *formatChart) *cPlotArea {
|
||||
}
|
||||
}
|
||||
|
||||
// drawScatterChart provides function to draw the c:plotArea element for scatter
|
||||
// chart by given format sets.
|
||||
// drawScatterChart provides a function to draw the c:plotArea element for
|
||||
// scatter chart by given format sets.
|
||||
func (f *File) drawScatterChart(formatSet *formatChart) *cPlotArea {
|
||||
return &cPlotArea{
|
||||
ScatterChart: &cCharts{
|
||||
@@ -767,8 +782,8 @@ func (f *File) drawScatterChart(formatSet *formatChart) *cPlotArea {
|
||||
}
|
||||
}
|
||||
|
||||
// drawChartSeries provides function to draw the c:ser element by given format
|
||||
// sets.
|
||||
// drawChartSeries provides a function to draw the c:ser element by given
|
||||
// format sets.
|
||||
func (f *File) drawChartSeries(formatSet *formatChart) *[]cSer {
|
||||
ser := []cSer{}
|
||||
for k := range formatSet.Series {
|
||||
@@ -793,7 +808,7 @@ func (f *File) drawChartSeries(formatSet *formatChart) *[]cSer {
|
||||
return &ser
|
||||
}
|
||||
|
||||
// drawChartSeriesSpPr provides function to draw the c:spPr element by given
|
||||
// drawChartSeriesSpPr provides a function to draw the c:spPr element by given
|
||||
// format sets.
|
||||
func (f *File) drawChartSeriesSpPr(i int, formatSet *formatChart) *cSpPr {
|
||||
spPrScatter := &cSpPr{
|
||||
@@ -815,8 +830,8 @@ func (f *File) drawChartSeriesSpPr(i int, formatSet *formatChart) *cSpPr {
|
||||
return chartSeriesSpPr[formatSet.Type]
|
||||
}
|
||||
|
||||
// drawChartSeriesDPt provides function to draw the c:dPt element by given data
|
||||
// index and format sets.
|
||||
// drawChartSeriesDPt provides a function to draw the c:dPt element by given
|
||||
// data index and format sets.
|
||||
func (f *File) drawChartSeriesDPt(i int, formatSet *formatChart) []*cDPt {
|
||||
dpt := []*cDPt{{
|
||||
IDx: &attrValInt{Val: i},
|
||||
@@ -844,8 +859,8 @@ func (f *File) drawChartSeriesDPt(i int, formatSet *formatChart) []*cDPt {
|
||||
return chartSeriesDPt[formatSet.Type]
|
||||
}
|
||||
|
||||
// drawChartSeriesCat provides function to draw the c:cat element by given chart
|
||||
// series and format sets.
|
||||
// drawChartSeriesCat provides a function to draw the c:cat element by given
|
||||
// chart series and format sets.
|
||||
func (f *File) drawChartSeriesCat(v formatChartSeries, formatSet *formatChart) *cCat {
|
||||
cat := &cCat{
|
||||
StrRef: &cStrRef{
|
||||
@@ -856,8 +871,8 @@ func (f *File) drawChartSeriesCat(v formatChartSeries, formatSet *formatChart) *
|
||||
return chartSeriesCat[formatSet.Type]
|
||||
}
|
||||
|
||||
// drawChartSeriesVal provides function to draw the c:val element by given chart
|
||||
// series and format sets.
|
||||
// drawChartSeriesVal provides a function to draw the c:val element by given
|
||||
// chart series and format sets.
|
||||
func (f *File) drawChartSeriesVal(v formatChartSeries, formatSet *formatChart) *cVal {
|
||||
val := &cVal{
|
||||
NumRef: &cNumRef{
|
||||
@@ -868,8 +883,8 @@ func (f *File) drawChartSeriesVal(v formatChartSeries, formatSet *formatChart) *
|
||||
return chartSeriesVal[formatSet.Type]
|
||||
}
|
||||
|
||||
// drawChartSeriesMarker provides function to draw the c:marker element by given
|
||||
// data index and format sets.
|
||||
// drawChartSeriesMarker provides a function to draw the c:marker element by
|
||||
// given data index and format sets.
|
||||
func (f *File) drawChartSeriesMarker(i int, formatSet *formatChart) *cMarker {
|
||||
marker := &cMarker{
|
||||
Symbol: &attrValString{Val: "circle"},
|
||||
@@ -894,7 +909,7 @@ func (f *File) drawChartSeriesMarker(i int, formatSet *formatChart) *cMarker {
|
||||
return chartSeriesMarker[formatSet.Type]
|
||||
}
|
||||
|
||||
// drawChartSeriesXVal provides function to draw the c:xVal element by given
|
||||
// drawChartSeriesXVal provides a function to draw the c:xVal element by given
|
||||
// chart series and format sets.
|
||||
func (f *File) drawChartSeriesXVal(v formatChartSeries, formatSet *formatChart) *cCat {
|
||||
cat := &cCat{
|
||||
@@ -906,7 +921,7 @@ func (f *File) drawChartSeriesXVal(v formatChartSeries, formatSet *formatChart)
|
||||
return chartSeriesXVal[formatSet.Type]
|
||||
}
|
||||
|
||||
// drawChartSeriesYVal provides function to draw the c:yVal element by given
|
||||
// drawChartSeriesYVal provides a function to draw the c:yVal element by given
|
||||
// chart series and format sets.
|
||||
func (f *File) drawChartSeriesYVal(v formatChartSeries, formatSet *formatChart) *cVal {
|
||||
val := &cVal{
|
||||
@@ -918,8 +933,8 @@ func (f *File) drawChartSeriesYVal(v formatChartSeries, formatSet *formatChart)
|
||||
return chartSeriesYVal[formatSet.Type]
|
||||
}
|
||||
|
||||
// drawChartDLbls provides function to draw the c:dLbls element by given format
|
||||
// sets.
|
||||
// drawChartDLbls provides a function to draw the c:dLbls element by given
|
||||
// format sets.
|
||||
func (f *File) drawChartDLbls(formatSet *formatChart) *cDLbls {
|
||||
return &cDLbls{
|
||||
ShowLegendKey: &attrValBool{Val: formatSet.Legend.ShowLegendKey},
|
||||
@@ -932,15 +947,15 @@ func (f *File) drawChartDLbls(formatSet *formatChart) *cDLbls {
|
||||
}
|
||||
}
|
||||
|
||||
// drawChartSeriesDLbls provides function to draw the c:dLbls element by given
|
||||
// format sets.
|
||||
// drawChartSeriesDLbls provides a function to draw the c:dLbls element by
|
||||
// given format sets.
|
||||
func (f *File) drawChartSeriesDLbls(formatSet *formatChart) *cDLbls {
|
||||
dLbls := f.drawChartDLbls(formatSet)
|
||||
chartSeriesDLbls := map[string]*cDLbls{Bar: dLbls, BarStacked: dLbls, BarPercentStacked: dLbls, Bar3DClustered: dLbls, Bar3DStacked: dLbls, Bar3DPercentStacked: dLbls, Col: dLbls, ColStacked: dLbls, ColPercentStacked: dLbls, Col3DClustered: dLbls, Col3D: dLbls, Col3DStacked: dLbls, Col3DPercentStacked: dLbls, Doughnut: dLbls, Line: dLbls, Pie: dLbls, Pie3D: dLbls, Radar: dLbls, Scatter: nil}
|
||||
return chartSeriesDLbls[formatSet.Type]
|
||||
}
|
||||
|
||||
// drawPlotAreaCatAx provides function to draw the c:catAx element.
|
||||
// drawPlotAreaCatAx provides a function to draw the c:catAx element.
|
||||
func (f *File) drawPlotAreaCatAx(formatSet *formatChart) []*cAxs {
|
||||
min := &attrValFloat{Val: formatSet.XAxis.Minimum}
|
||||
max := &attrValFloat{Val: formatSet.XAxis.Maximum}
|
||||
@@ -979,7 +994,7 @@ func (f *File) drawPlotAreaCatAx(formatSet *formatChart) []*cAxs {
|
||||
}
|
||||
}
|
||||
|
||||
// drawPlotAreaValAx provides function to draw the c:valAx element.
|
||||
// drawPlotAreaValAx provides a function to draw the c:valAx element.
|
||||
func (f *File) drawPlotAreaValAx(formatSet *formatChart) []*cAxs {
|
||||
min := &attrValFloat{Val: formatSet.YAxis.Minimum}
|
||||
max := &attrValFloat{Val: formatSet.YAxis.Maximum}
|
||||
@@ -1015,7 +1030,7 @@ func (f *File) drawPlotAreaValAx(formatSet *formatChart) []*cAxs {
|
||||
}
|
||||
}
|
||||
|
||||
// drawPlotAreaSpPr provides function to draw the c:spPr element.
|
||||
// drawPlotAreaSpPr provides a function to draw the c:spPr element.
|
||||
func (f *File) drawPlotAreaSpPr() *cSpPr {
|
||||
return &cSpPr{
|
||||
Ln: &aLn{
|
||||
@@ -1034,7 +1049,7 @@ func (f *File) drawPlotAreaSpPr() *cSpPr {
|
||||
}
|
||||
}
|
||||
|
||||
// drawPlotAreaTxPr provides function to draw the c:txPr element.
|
||||
// drawPlotAreaTxPr provides a function to draw the c:txPr element.
|
||||
func (f *File) drawPlotAreaTxPr() *cTxPr {
|
||||
return &cTxPr{
|
||||
BodyPr: aBodyPr{
|
||||
@@ -1073,8 +1088,8 @@ func (f *File) drawPlotAreaTxPr() *cTxPr {
|
||||
}
|
||||
}
|
||||
|
||||
// drawingParser provides function to parse drawingXML. In order to solve the
|
||||
// problem that the label structure is changed after serialization and
|
||||
// drawingParser provides a function to parse drawingXML. In order to solve
|
||||
// the problem that the label structure is changed after serialization and
|
||||
// deserialization, two different structures: decodeWsDr and encodeWsDr are
|
||||
// defined.
|
||||
func (f *File) drawingParser(drawingXML string, content *xlsxWsDr) int {
|
||||
@@ -1082,7 +1097,7 @@ func (f *File) drawingParser(drawingXML string, content *xlsxWsDr) int {
|
||||
_, ok := f.XLSX[drawingXML]
|
||||
if ok { // Append Model
|
||||
decodeWsDr := decodeWsDr{}
|
||||
xml.Unmarshal([]byte(f.readXML(drawingXML)), &decodeWsDr)
|
||||
_ = xml.Unmarshal([]byte(f.readXML(drawingXML)), &decodeWsDr)
|
||||
content.R = decodeWsDr.R
|
||||
cNvPrID = len(decodeWsDr.OneCellAnchor) + len(decodeWsDr.TwoCellAnchor) + 1
|
||||
for _, v := range decodeWsDr.OneCellAnchor {
|
||||
@@ -1101,8 +1116,8 @@ func (f *File) drawingParser(drawingXML string, content *xlsxWsDr) int {
|
||||
return cNvPrID
|
||||
}
|
||||
|
||||
// addDrawingChart provides function to add chart graphic frame by given sheet,
|
||||
// drawingXML, cell, width, height, relationship index and format sets.
|
||||
// addDrawingChart provides a function to add chart graphic frame by given
|
||||
// sheet, drawingXML, cell, width, height, relationship index and format sets.
|
||||
func (f *File) addDrawingChart(sheet, drawingXML, cell string, width, height, rID int, formatSet *formatPicture) {
|
||||
cell = strings.ToUpper(cell)
|
||||
fromCol := string(strings.Map(letterOnlyMapF, cell))
|
||||
|
||||
37
vendor/github.com/360EntSecGroup-Skylar/excelize/col.go
generated
vendored
37
vendor/github.com/360EntSecGroup-Skylar/excelize/col.go
generated
vendored
@@ -1,3 +1,12 @@
|
||||
// Copyright 2016 - 2018 The excelize Authors. All rights reserved. Use of
|
||||
// this source code is governed by a BSD-style license that can be found in
|
||||
// the LICENSE file.
|
||||
//
|
||||
// Package excelize providing a set of functions that allow you to write to
|
||||
// and read from XLSX files. Support reads and writes XLSX file generated by
|
||||
// Microsoft Excel™ 2007 and later. Support save file without losing original
|
||||
// charts of XLSX. This library needs Go version 1.8 or later.
|
||||
|
||||
package excelize
|
||||
|
||||
import (
|
||||
@@ -121,8 +130,8 @@ func (f *File) SetColOutlineLevel(sheet, column string, level uint8) {
|
||||
xlsx.Cols.Col = append(xlsx.Cols.Col, col)
|
||||
}
|
||||
|
||||
// SetColWidth provides function to set the width of a single column or multiple
|
||||
// columns. For example:
|
||||
// SetColWidth provides a function to set the width of a single column or
|
||||
// multiple columns. For example:
|
||||
//
|
||||
// xlsx := excelize.NewFile()
|
||||
// xlsx.SetColWidth("Sheet1", "A", "H", 20)
|
||||
@@ -259,8 +268,8 @@ func (f *File) positionObjectPixels(sheet string, colStart, rowStart, x1, y1, wi
|
||||
return colStart, rowStart, xAbs, yAbs, colEnd, rowEnd, x2, y2
|
||||
}
|
||||
|
||||
// getColWidth provides function to get column width in pixels by given sheet
|
||||
// name and column index.
|
||||
// getColWidth provides a function to get column width in pixels by given
|
||||
// sheet name and column index.
|
||||
func (f *File) getColWidth(sheet string, col int) int {
|
||||
xlsx := f.workSheetReader(sheet)
|
||||
if xlsx.Cols != nil {
|
||||
@@ -278,8 +287,8 @@ func (f *File) getColWidth(sheet string, col int) int {
|
||||
return int(defaultColWidthPixels)
|
||||
}
|
||||
|
||||
// GetColWidth provides function to get column width by given worksheet name and
|
||||
// column index.
|
||||
// GetColWidth provides a function to get column width by given worksheet name
|
||||
// and column index.
|
||||
func (f *File) GetColWidth(sheet, column string) float64 {
|
||||
col := TitleToNumber(strings.ToUpper(column)) + 1
|
||||
xlsx := f.workSheetReader(sheet)
|
||||
@@ -298,8 +307,8 @@ func (f *File) GetColWidth(sheet, column string) float64 {
|
||||
return defaultColWidthPixels
|
||||
}
|
||||
|
||||
// InsertCol provides function to insert a new column before given column index.
|
||||
// For example, create a new column before column C in Sheet1:
|
||||
// InsertCol provides a function to insert a new column before given column
|
||||
// index. For example, create a new column before column C in Sheet1:
|
||||
//
|
||||
// xlsx.InsertCol("Sheet1", "C")
|
||||
//
|
||||
@@ -308,8 +317,8 @@ func (f *File) InsertCol(sheet, column string) {
|
||||
f.adjustHelper(sheet, col, -1, 1)
|
||||
}
|
||||
|
||||
// RemoveCol provides function to remove single column by given worksheet name
|
||||
// and column index. For example, remove column C in Sheet1:
|
||||
// RemoveCol provides a function to remove single column by given worksheet
|
||||
// name and column index. For example, remove column C in Sheet1:
|
||||
//
|
||||
// xlsx.RemoveCol("Sheet1", "C")
|
||||
//
|
||||
@@ -346,10 +355,10 @@ func completeCol(xlsx *xlsxWorksheet, row, cell int) {
|
||||
}
|
||||
}
|
||||
|
||||
// convertColWidthToPixels provieds function to convert the width of a cell from
|
||||
// user's units to pixels. Excel rounds the column width to the nearest pixel.
|
||||
// If the width hasn't been set by the user we use the default value. If the
|
||||
// column is hidden it has a value of zero.
|
||||
// convertColWidthToPixels provieds function to convert the width of a cell
|
||||
// from user's units to pixels. Excel rounds the column width to the nearest
|
||||
// pixel. If the width hasn't been set by the user we use the default value.
|
||||
// If the column is hidden it has a value of zero.
|
||||
func convertColWidthToPixels(width float64) float64 {
|
||||
var padding float64 = 5
|
||||
var pixels float64
|
||||
|
||||
97
vendor/github.com/360EntSecGroup-Skylar/excelize/comment.go
generated
vendored
97
vendor/github.com/360EntSecGroup-Skylar/excelize/comment.go
generated
vendored
@@ -1,21 +1,61 @@
|
||||
// Copyright 2016 - 2018 The excelize Authors. All rights reserved. Use of
|
||||
// this source code is governed by a BSD-style license that can be found in
|
||||
// the LICENSE file.
|
||||
//
|
||||
// Package excelize providing a set of functions that allow you to write to
|
||||
// and read from XLSX files. Support reads and writes XLSX file generated by
|
||||
// Microsoft Excel™ 2007 and later. Support save file without losing original
|
||||
// charts of XLSX. This library needs Go version 1.8 or later.
|
||||
|
||||
package excelize
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"encoding/xml"
|
||||
"fmt"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// parseFormatCommentsSet provides function to parse the format settings of the
|
||||
// comment with default value.
|
||||
func parseFormatCommentsSet(formatSet string) *formatComment {
|
||||
// parseFormatCommentsSet provides a function to parse the format settings of
|
||||
// the comment with default value.
|
||||
func parseFormatCommentsSet(formatSet string) (*formatComment, error) {
|
||||
format := formatComment{
|
||||
Author: "Author:",
|
||||
Text: " ",
|
||||
}
|
||||
json.Unmarshal([]byte(formatSet), &format)
|
||||
return &format
|
||||
err := json.Unmarshal([]byte(formatSet), &format)
|
||||
return &format, err
|
||||
}
|
||||
|
||||
// GetComments retrieves all comments and returns a map of worksheet name to
|
||||
// the worksheet comments.
|
||||
func (f *File) GetComments() (comments map[string][]Comment) {
|
||||
comments = map[string][]Comment{}
|
||||
for n := range f.sheetMap {
|
||||
commentID := f.GetSheetIndex(n)
|
||||
commentsXML := "xl/comments" + strconv.Itoa(commentID) + ".xml"
|
||||
c, ok := f.XLSX[commentsXML]
|
||||
if ok {
|
||||
d := xlsxComments{}
|
||||
xml.Unmarshal([]byte(c), &d)
|
||||
sheetComments := []Comment{}
|
||||
for _, comment := range d.CommentList.Comment {
|
||||
sheetComment := Comment{}
|
||||
if comment.AuthorID < len(d.Authors) {
|
||||
sheetComment.Author = d.Authors[comment.AuthorID].Author
|
||||
}
|
||||
sheetComment.Ref = comment.Ref
|
||||
sheetComment.AuthorID = comment.AuthorID
|
||||
for _, text := range comment.Text.R {
|
||||
sheetComment.Text += text.T
|
||||
}
|
||||
sheetComments = append(sheetComments, sheetComment)
|
||||
}
|
||||
comments[n] = sheetComments
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// AddComment provides the method to add comment in a sheet by given worksheet
|
||||
@@ -25,8 +65,11 @@ func parseFormatCommentsSet(formatSet string) *formatComment {
|
||||
//
|
||||
// xlsx.AddComment("Sheet1", "A30", `{"author":"Excelize: ","text":"This is a comment."}`)
|
||||
//
|
||||
func (f *File) AddComment(sheet, cell, format string) {
|
||||
formatSet := parseFormatCommentsSet(format)
|
||||
func (f *File) AddComment(sheet, cell, format string) error {
|
||||
formatSet, err := parseFormatCommentsSet(format)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
// Read sheet data.
|
||||
xlsx := f.workSheetReader(sheet)
|
||||
commentID := f.countComments() + 1
|
||||
@@ -46,13 +89,23 @@ func (f *File) AddComment(sheet, cell, format string) {
|
||||
}
|
||||
commentsXML := "xl/comments" + strconv.Itoa(commentID) + ".xml"
|
||||
f.addComment(commentsXML, cell, formatSet)
|
||||
f.addDrawingVML(commentID, drawingVML, cell)
|
||||
var colCount int
|
||||
for i, l := range strings.Split(formatSet.Text, "\n") {
|
||||
if ll := len(l); ll > colCount {
|
||||
if i == 0 {
|
||||
ll += len(formatSet.Author)
|
||||
}
|
||||
colCount = ll
|
||||
}
|
||||
}
|
||||
f.addDrawingVML(commentID, drawingVML, cell, strings.Count(formatSet.Text, "\n")+1, colCount)
|
||||
f.addContentTypePart(commentID, "comments")
|
||||
return err
|
||||
}
|
||||
|
||||
// addDrawingVML provides function to create comment as
|
||||
// addDrawingVML provides a function to create comment as
|
||||
// xl/drawings/vmlDrawing%d.vml by given commit ID and cell.
|
||||
func (f *File) addDrawingVML(commentID int, drawingVML, cell string) {
|
||||
func (f *File) addDrawingVML(commentID int, drawingVML, cell string, lineCount, colCount int) {
|
||||
col := string(strings.Map(letterOnlyMapF, cell))
|
||||
row, _ := strconv.Atoi(strings.Map(intOnlyMapF, cell))
|
||||
xAxis := row - 1
|
||||
@@ -79,7 +132,7 @@ func (f *File) addDrawingVML(commentID int, drawingVML, cell string) {
|
||||
},
|
||||
VPath: &vPath{
|
||||
Gradientshapeok: "t",
|
||||
Connecttype: "rect",
|
||||
Connecttype: "miter",
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -109,10 +162,12 @@ func (f *File) addDrawingVML(commentID int, drawingVML, cell string) {
|
||||
},
|
||||
ClientData: &xClientData{
|
||||
ObjectType: "Note",
|
||||
Anchor: "3, 15, 8, 6, 4, 54, 13, 2",
|
||||
AutoFill: "False",
|
||||
Row: xAxis,
|
||||
Column: yAxis,
|
||||
Anchor: fmt.Sprintf(
|
||||
"%d, 23, %d, 0, %d, %d, %d, 5",
|
||||
1+yAxis, 1+xAxis, 2+yAxis+lineCount, colCount+yAxis, 2+xAxis+lineCount),
|
||||
AutoFill: "True",
|
||||
Row: xAxis,
|
||||
Column: yAxis,
|
||||
},
|
||||
}
|
||||
s, _ := xml.Marshal(sp)
|
||||
@@ -127,7 +182,7 @@ func (f *File) addDrawingVML(commentID int, drawingVML, cell string) {
|
||||
c, ok := f.XLSX[drawingVML]
|
||||
if ok {
|
||||
d := decodeVmlDrawing{}
|
||||
xml.Unmarshal([]byte(c), &d)
|
||||
_ = xml.Unmarshal([]byte(c), &d)
|
||||
for _, v := range d.Shape {
|
||||
s := xlsxShape{
|
||||
ID: "_x0000_s1025",
|
||||
@@ -145,8 +200,8 @@ func (f *File) addDrawingVML(commentID int, drawingVML, cell string) {
|
||||
f.XLSX[drawingVML] = v
|
||||
}
|
||||
|
||||
// addComment provides function to create chart as xl/comments%d.xml by given
|
||||
// cell and format sets.
|
||||
// addComment provides a function to create chart as xl/comments%d.xml by
|
||||
// given cell and format sets.
|
||||
func (f *File) addComment(commentsXML, cell string, formatSet *formatComment) {
|
||||
a := formatSet.Author
|
||||
t := formatSet.Text
|
||||
@@ -197,7 +252,7 @@ func (f *File) addComment(commentsXML, cell string, formatSet *formatComment) {
|
||||
c, ok := f.XLSX[commentsXML]
|
||||
if ok {
|
||||
d := xlsxComments{}
|
||||
xml.Unmarshal([]byte(c), &d)
|
||||
_ = xml.Unmarshal([]byte(c), &d)
|
||||
comments.CommentList.Comment = append(comments.CommentList.Comment, d.CommentList.Comment...)
|
||||
}
|
||||
comments.CommentList.Comment = append(comments.CommentList.Comment, cmt)
|
||||
@@ -205,8 +260,8 @@ func (f *File) addComment(commentsXML, cell string, formatSet *formatComment) {
|
||||
f.saveFileList(commentsXML, v)
|
||||
}
|
||||
|
||||
// countComments provides function to get comments files count storage in the
|
||||
// folder xl.
|
||||
// countComments provides a function to get comments files count storage in
|
||||
// the folder xl.
|
||||
func (f *File) countComments() int {
|
||||
count := 0
|
||||
for k := range f.XLSX {
|
||||
|
||||
233
vendor/github.com/360EntSecGroup-Skylar/excelize/datavalidation.go
generated
vendored
Normal file
233
vendor/github.com/360EntSecGroup-Skylar/excelize/datavalidation.go
generated
vendored
Normal file
@@ -0,0 +1,233 @@
|
||||
// Copyright 2016 - 2018 The excelize Authors. All rights reserved. Use of
|
||||
// this source code is governed by a BSD-style license that can be found in
|
||||
// the LICENSE file.
|
||||
//
|
||||
// Package excelize providing a set of functions that allow you to write to
|
||||
// and read from XLSX files. Support reads and writes XLSX file generated by
|
||||
// Microsoft Excel™ 2007 and later. Support save file without losing original
|
||||
// charts of XLSX. This library needs Go version 1.8 or later.
|
||||
|
||||
package excelize
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// DataValidationType defined the type of data validation.
|
||||
type DataValidationType int
|
||||
|
||||
// Data validation types.
|
||||
const (
|
||||
_DataValidationType = iota
|
||||
typeNone // inline use
|
||||
DataValidationTypeCustom
|
||||
DataValidationTypeDate
|
||||
DataValidationTypeDecimal
|
||||
typeList // inline use
|
||||
DataValidationTypeTextLeng
|
||||
DataValidationTypeTime
|
||||
// DataValidationTypeWhole Integer
|
||||
DataValidationTypeWhole
|
||||
)
|
||||
|
||||
const (
|
||||
// dataValidationFormulaStrLen 255 characters+ 2 quotes
|
||||
dataValidationFormulaStrLen = 257
|
||||
// dataValidationFormulaStrLenErr
|
||||
dataValidationFormulaStrLenErr = "data validation must be 0-255 characters"
|
||||
)
|
||||
|
||||
// DataValidationErrorStyle defined the style of data validation error alert.
|
||||
type DataValidationErrorStyle int
|
||||
|
||||
// Data validation error styles.
|
||||
const (
|
||||
_ DataValidationErrorStyle = iota
|
||||
DataValidationErrorStyleStop
|
||||
DataValidationErrorStyleWarning
|
||||
DataValidationErrorStyleInformation
|
||||
)
|
||||
|
||||
// Data validation error styles.
|
||||
const (
|
||||
styleStop = "stop"
|
||||
styleWarning = "warning"
|
||||
styleInformation = "information"
|
||||
)
|
||||
|
||||
// DataValidationOperator operator enum.
|
||||
type DataValidationOperator int
|
||||
|
||||
// Data validation operators.
|
||||
const (
|
||||
_DataValidationOperator = iota
|
||||
DataValidationOperatorBetween
|
||||
DataValidationOperatorEqual
|
||||
DataValidationOperatorGreaterThan
|
||||
DataValidationOperatorGreaterThanOrEqual
|
||||
DataValidationOperatorLessThan
|
||||
DataValidationOperatorLessThanOrEqual
|
||||
DataValidationOperatorNotBetween
|
||||
DataValidationOperatorNotEqual
|
||||
)
|
||||
|
||||
// NewDataValidation return data validation struct.
|
||||
func NewDataValidation(allowBlank bool) *DataValidation {
|
||||
return &DataValidation{
|
||||
AllowBlank: allowBlank,
|
||||
ShowErrorMessage: false,
|
||||
ShowInputMessage: false,
|
||||
}
|
||||
}
|
||||
|
||||
// SetError set error notice.
|
||||
func (dd *DataValidation) SetError(style DataValidationErrorStyle, title, msg string) {
|
||||
dd.Error = &msg
|
||||
dd.ErrorTitle = &title
|
||||
strStyle := styleStop
|
||||
switch style {
|
||||
case DataValidationErrorStyleStop:
|
||||
strStyle = styleStop
|
||||
case DataValidationErrorStyleWarning:
|
||||
strStyle = styleWarning
|
||||
case DataValidationErrorStyleInformation:
|
||||
strStyle = styleInformation
|
||||
|
||||
}
|
||||
dd.ShowErrorMessage = true
|
||||
dd.ErrorStyle = &strStyle
|
||||
}
|
||||
|
||||
// SetInput set prompt notice.
|
||||
func (dd *DataValidation) SetInput(title, msg string) {
|
||||
dd.ShowInputMessage = true
|
||||
dd.PromptTitle = &title
|
||||
dd.Prompt = &msg
|
||||
}
|
||||
|
||||
// SetDropList data validation list.
|
||||
func (dd *DataValidation) SetDropList(keys []string) error {
|
||||
dd.Formula1 = "\"" + strings.Join(keys, ",") + "\""
|
||||
dd.Type = convDataValidationType(typeList)
|
||||
return nil
|
||||
}
|
||||
|
||||
// SetRange provides function to set data validation range in drop list.
|
||||
func (dd *DataValidation) SetRange(f1, f2 int, t DataValidationType, o DataValidationOperator) error {
|
||||
formula1 := fmt.Sprintf("%d", f1)
|
||||
formula2 := fmt.Sprintf("%d", f2)
|
||||
if dataValidationFormulaStrLen < len(dd.Formula1) || dataValidationFormulaStrLen < len(dd.Formula2) {
|
||||
return fmt.Errorf(dataValidationFormulaStrLenErr)
|
||||
}
|
||||
|
||||
dd.Formula1 = formula1
|
||||
dd.Formula2 = formula2
|
||||
dd.Type = convDataValidationType(t)
|
||||
dd.Operator = convDataValidationOperatior(o)
|
||||
return nil
|
||||
}
|
||||
|
||||
// SetSqrefDropList provides set data validation on a range with source
|
||||
// reference range of the worksheet by given data validation object and
|
||||
// worksheet name. The data validation object can be created by
|
||||
// NewDataValidation function. For example, set data validation on
|
||||
// Sheet1!A7:B8 with validation criteria source Sheet1!E1:E3 settings, create
|
||||
// in-cell dropdown by allowing list source:
|
||||
//
|
||||
// dvRange := excelize.NewDataValidation(true)
|
||||
// dvRange.Sqref = "A7:B8"
|
||||
// dvRange.SetSqrefDropList("E1:E3", true)
|
||||
// xlsx.AddDataValidation("Sheet1", dvRange)
|
||||
//
|
||||
func (dd *DataValidation) SetSqrefDropList(sqref string, isCurrentSheet bool) error {
|
||||
if isCurrentSheet {
|
||||
dd.Formula1 = sqref
|
||||
dd.Type = convDataValidationType(typeList)
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("cross-sheet sqref cell are not supported")
|
||||
}
|
||||
|
||||
// SetSqref provides function to set data validation range in drop list.
|
||||
func (dd *DataValidation) SetSqref(sqref string) {
|
||||
if dd.Sqref == "" {
|
||||
dd.Sqref = sqref
|
||||
} else {
|
||||
dd.Sqref = fmt.Sprintf("%s %s", dd.Sqref, sqref)
|
||||
}
|
||||
}
|
||||
|
||||
// convDataValidationType get excel data validation type.
|
||||
func convDataValidationType(t DataValidationType) string {
|
||||
typeMap := map[DataValidationType]string{
|
||||
typeNone: "none",
|
||||
DataValidationTypeCustom: "custom",
|
||||
DataValidationTypeDate: "date",
|
||||
DataValidationTypeDecimal: "decimal",
|
||||
typeList: "list",
|
||||
DataValidationTypeTextLeng: "textLength",
|
||||
DataValidationTypeTime: "time",
|
||||
DataValidationTypeWhole: "whole",
|
||||
}
|
||||
|
||||
return typeMap[t]
|
||||
|
||||
}
|
||||
|
||||
// convDataValidationOperatior get excel data validation operator.
|
||||
func convDataValidationOperatior(o DataValidationOperator) string {
|
||||
typeMap := map[DataValidationOperator]string{
|
||||
DataValidationOperatorBetween: "between",
|
||||
DataValidationOperatorEqual: "equal",
|
||||
DataValidationOperatorGreaterThan: "greaterThan",
|
||||
DataValidationOperatorGreaterThanOrEqual: "greaterThanOrEqual",
|
||||
DataValidationOperatorLessThan: "lessThan",
|
||||
DataValidationOperatorLessThanOrEqual: "lessThanOrEqual",
|
||||
DataValidationOperatorNotBetween: "notBetween",
|
||||
DataValidationOperatorNotEqual: "notEqual",
|
||||
}
|
||||
|
||||
return typeMap[o]
|
||||
|
||||
}
|
||||
|
||||
// AddDataValidation provides set data validation on a range of the worksheet
|
||||
// by given data validation object and worksheet name. The data validation
|
||||
// object can be created by NewDataValidation function.
|
||||
//
|
||||
// Example 1, set data validation on Sheet1!A1:B2 with validation criteria
|
||||
// settings, show error alert after invalid data is entered with "Stop" style
|
||||
// and custom title "error body":
|
||||
//
|
||||
// dvRange := excelize.NewDataValidation(true)
|
||||
// dvRange.Sqref = "A1:B2"
|
||||
// dvRange.SetRange(10, 20, excelize.DataValidationTypeWhole, excelize.DataValidationOperatorBetween)
|
||||
// dvRange.SetError(excelize.DataValidationErrorStyleStop, "error title", "error body")
|
||||
// xlsx.AddDataValidation("Sheet1", dvRange)
|
||||
//
|
||||
// Example 2, set data validation on Sheet1!A3:B4 with validation criteria
|
||||
// settings, and show input message when cell is selected:
|
||||
//
|
||||
// dvRange = excelize.NewDataValidation(true)
|
||||
// dvRange.Sqref = "A3:B4"
|
||||
// dvRange.SetRange(10, 20, excelize.DataValidationTypeWhole, excelize.DataValidationOperatorGreaterThan)
|
||||
// dvRange.SetInput("input title", "input body")
|
||||
// xlsx.AddDataValidation("Sheet1", dvRange)
|
||||
//
|
||||
// Example 3, set data validation on Sheet1!A5:B6 with validation criteria
|
||||
// settings, create in-cell dropdown by allowing list source:
|
||||
//
|
||||
// dvRange = excelize.NewDataValidation(true)
|
||||
// dvRange.Sqref = "A5:B6"
|
||||
// dvRange.SetDropList([]string{"1", "2", "3"})
|
||||
// xlsx.AddDataValidation("Sheet1", dvRange)
|
||||
//
|
||||
func (f *File) AddDataValidation(sheet string, dv *DataValidation) {
|
||||
xlsx := f.workSheetReader(sheet)
|
||||
if nil == xlsx.DataValidations {
|
||||
xlsx.DataValidations = new(xlsxDataValidations)
|
||||
}
|
||||
xlsx.DataValidations.DataValidation = append(xlsx.DataValidations.DataValidation, dv)
|
||||
xlsx.DataValidations.Count = len(xlsx.DataValidations.DataValidation)
|
||||
}
|
||||
59
vendor/github.com/360EntSecGroup-Skylar/excelize/date.go
generated
vendored
59
vendor/github.com/360EntSecGroup-Skylar/excelize/date.go
generated
vendored
@@ -1,3 +1,12 @@
|
||||
// Copyright 2016 - 2018 The excelize Authors. All rights reserved. Use of
|
||||
// this source code is governed by a BSD-style license that can be found in
|
||||
// the LICENSE file.
|
||||
//
|
||||
// Package excelize providing a set of functions that allow you to write to
|
||||
// and read from XLSX files. Support reads and writes XLSX file generated by
|
||||
// Microsoft Excel™ 2007 and later. Support save file without losing original
|
||||
// charts of XLSX. This library needs Go version 1.8 or later.
|
||||
|
||||
package excelize
|
||||
|
||||
import (
|
||||
@@ -8,17 +17,31 @@ import (
|
||||
// timeLocationUTC defined the UTC time location.
|
||||
var timeLocationUTC, _ = time.LoadLocation("UTC")
|
||||
|
||||
// timeToUTCTime provides function to convert time to UTC time.
|
||||
// timeToUTCTime provides a function to convert time to UTC time.
|
||||
func timeToUTCTime(t time.Time) time.Time {
|
||||
return time.Date(t.Year(), t.Month(), t.Day(), t.Hour(), t.Minute(), t.Second(), t.Nanosecond(), timeLocationUTC)
|
||||
}
|
||||
|
||||
// timeToExcelTime provides function to convert time to Excel time.
|
||||
// timeToExcelTime provides a function to convert time to Excel time.
|
||||
func timeToExcelTime(t time.Time) float64 {
|
||||
return float64(t.UnixNano())/8.64e13 + 25569.0
|
||||
// TODO in future this should probably also handle date1904 and like TimeFromExcelTime
|
||||
var excelTime float64
|
||||
var deltaDays int64
|
||||
excelTime = 0
|
||||
deltaDays = 290 * 364
|
||||
// check if UnixNano would be out of int64 range
|
||||
for t.Unix() > deltaDays*24*60*60 {
|
||||
// reduce by aprox. 290 years, which is max for int64 nanoseconds
|
||||
delta := time.Duration(deltaDays) * 24 * time.Hour
|
||||
excelTime = excelTime + float64(deltaDays)
|
||||
t = t.Add(-delta)
|
||||
}
|
||||
// finally add remainder of UnixNano to keep nano precision
|
||||
// and 25569 which is days between 1900 and 1970
|
||||
return excelTime + float64(t.UnixNano())/8.64e13 + 25569.0
|
||||
}
|
||||
|
||||
// shiftJulianToNoon provides function to process julian date to noon.
|
||||
// shiftJulianToNoon provides a function to process julian date to noon.
|
||||
func shiftJulianToNoon(julianDays, julianFraction float64) (float64, float64) {
|
||||
switch {
|
||||
case -0.5 < julianFraction && julianFraction < 0.5:
|
||||
@@ -33,7 +56,7 @@ func shiftJulianToNoon(julianDays, julianFraction float64) (float64, float64) {
|
||||
return julianDays, julianFraction
|
||||
}
|
||||
|
||||
// fractionOfADay provides function to return the integer values for hour,
|
||||
// fractionOfADay provides a function to return the integer values for hour,
|
||||
// minutes, seconds and nanoseconds that comprised a given fraction of a day.
|
||||
// values would round to 1 us.
|
||||
func fractionOfADay(fraction float64) (hours, minutes, seconds, nanoseconds int) {
|
||||
@@ -54,7 +77,7 @@ func fractionOfADay(fraction float64) (hours, minutes, seconds, nanoseconds int)
|
||||
return
|
||||
}
|
||||
|
||||
// julianDateToGregorianTime provides function to convert julian date to
|
||||
// julianDateToGregorianTime provides a function to convert julian date to
|
||||
// gregorian time.
|
||||
func julianDateToGregorianTime(part1, part2 float64) time.Time {
|
||||
part1I, part1F := math.Modf(part1)
|
||||
@@ -67,12 +90,12 @@ func julianDateToGregorianTime(part1, part2 float64) time.Time {
|
||||
return time.Date(year, time.Month(month), day, hours, minutes, seconds, nanoseconds, time.UTC)
|
||||
}
|
||||
|
||||
// By this point generations of programmers have repeated the algorithm sent to
|
||||
// the editor of "Communications of the ACM" in 1968 (published in CACM, volume
|
||||
// 11, number 10, October 1968, p.657). None of those programmers seems to have
|
||||
// found it necessary to explain the constants or variable names set out by
|
||||
// Henry F. Fliegel and Thomas C. Van Flandern. Maybe one day I'll buy that
|
||||
// jounal and expand an explanation here - that day is not today.
|
||||
// By this point generations of programmers have repeated the algorithm sent
|
||||
// to the editor of "Communications of the ACM" in 1968 (published in CACM,
|
||||
// volume 11, number 10, October 1968, p.657). None of those programmers seems
|
||||
// to have found it necessary to explain the constants or variable names set
|
||||
// out by Henry F. Fliegel and Thomas C. Van Flandern. Maybe one day I'll buy
|
||||
// that jounal and expand an explanation here - that day is not today.
|
||||
func doTheFliegelAndVanFlandernAlgorithm(jd int) (day, month, year int) {
|
||||
l := jd + 68569
|
||||
n := (4 * l) / 146097
|
||||
@@ -87,9 +110,10 @@ func doTheFliegelAndVanFlandernAlgorithm(jd int) (day, month, year int) {
|
||||
return d, m, y
|
||||
}
|
||||
|
||||
// timeFromExcelTime provides function to convert an excelTime representation
|
||||
// (stored as a floating point number) to a time.Time.
|
||||
// timeFromExcelTime provides a function to convert an excelTime
|
||||
// representation (stored as a floating point number) to a time.Time.
|
||||
func timeFromExcelTime(excelTime float64, date1904 bool) time.Time {
|
||||
const MDD int64 = 106750 // Max time.Duration Days, aprox. 290 years
|
||||
var date time.Time
|
||||
var intPart = int64(excelTime)
|
||||
// Excel uses Julian dates prior to March 1st 1900, and Gregorian
|
||||
@@ -113,6 +137,13 @@ func timeFromExcelTime(excelTime float64, date1904 bool) time.Time {
|
||||
} else {
|
||||
date = time.Date(1899, 12, 30, 0, 0, 0, 0, time.UTC)
|
||||
}
|
||||
|
||||
// Duration is limited to aprox. 290 years
|
||||
for intPart > MDD {
|
||||
durationDays := time.Duration(MDD) * time.Hour * 24
|
||||
date = date.Add(durationDays)
|
||||
intPart = intPart - MDD
|
||||
}
|
||||
durationDays := time.Duration(intPart) * time.Hour * 24
|
||||
durationPart := time.Duration(dayNanoSeconds * floatPart)
|
||||
return date.Add(durationDays).Add(durationPart)
|
||||
|
||||
48
vendor/github.com/360EntSecGroup-Skylar/excelize/excelize.go
generated
vendored
48
vendor/github.com/360EntSecGroup-Skylar/excelize/excelize.go
generated
vendored
@@ -1,3 +1,13 @@
|
||||
// Copyright 2016 - 2018 The excelize Authors. All rights reserved. Use of
|
||||
// this source code is governed by a BSD-style license that can be found in
|
||||
// the LICENSE file.
|
||||
//
|
||||
// Package excelize providing a set of functions that allow you to write to
|
||||
// and read from XLSX files. Support reads and writes XLSX file generated by
|
||||
// Microsoft Excel™ 2007 and later. Support save file without losing original
|
||||
// charts of XLSX. This library needs Go version 1.8 or later.
|
||||
//
|
||||
// See https://xuri.me/excelize for more information about this package.
|
||||
package excelize
|
||||
|
||||
import (
|
||||
@@ -21,6 +31,7 @@ type File struct {
|
||||
Sheet map[string]*xlsxWorksheet
|
||||
SheetCount int
|
||||
Styles *xlsxStyleSheet
|
||||
Theme *xlsxTheme
|
||||
WorkBook *xlsxWorkbook
|
||||
WorkBookRels *xlsxWorkbookRels
|
||||
XLSX map[string][]byte
|
||||
@@ -66,10 +77,11 @@ func OpenReader(r io.Reader) (*File, error) {
|
||||
}
|
||||
f.sheetMap = f.getSheetMap()
|
||||
f.Styles = f.stylesReader()
|
||||
f.Theme = f.themeReader()
|
||||
return f, nil
|
||||
}
|
||||
|
||||
// setDefaultTimeStyle provides function to set default numbers format for
|
||||
// setDefaultTimeStyle provides a function to set default numbers format for
|
||||
// time.Time type cell value by given worksheet name, cell coordinates and
|
||||
// number format code.
|
||||
func (f *File) setDefaultTimeStyle(sheet, axis string, format int) {
|
||||
@@ -79,8 +91,8 @@ func (f *File) setDefaultTimeStyle(sheet, axis string, format int) {
|
||||
}
|
||||
}
|
||||
|
||||
// workSheetReader provides function to get the pointer to the structure after
|
||||
// deserialization by given worksheet name.
|
||||
// workSheetReader provides a function to get the pointer to the structure
|
||||
// after deserialization by given worksheet name.
|
||||
func (f *File) workSheetReader(sheet string) *xlsxWorksheet {
|
||||
name, ok := f.sheetMap[trimSheetName(sheet)]
|
||||
if !ok {
|
||||
@@ -88,7 +100,7 @@ func (f *File) workSheetReader(sheet string) *xlsxWorksheet {
|
||||
}
|
||||
if f.Sheet[name] == nil {
|
||||
var xlsx xlsxWorksheet
|
||||
xml.Unmarshal(f.readXML(name), &xlsx)
|
||||
_ = xml.Unmarshal(f.readXML(name), &xlsx)
|
||||
if f.checked == nil {
|
||||
f.checked = make(map[string]bool)
|
||||
}
|
||||
@@ -103,7 +115,7 @@ func (f *File) workSheetReader(sheet string) *xlsxWorksheet {
|
||||
return f.Sheet[name]
|
||||
}
|
||||
|
||||
// checkSheet provides function to fill each row element and make that is
|
||||
// checkSheet provides a function to fill each row element and make that is
|
||||
// continuous in a worksheet of XML.
|
||||
func checkSheet(xlsx *xlsxWorksheet) {
|
||||
row := len(xlsx.SheetData.Row)
|
||||
@@ -131,7 +143,7 @@ func checkSheet(xlsx *xlsxWorksheet) {
|
||||
xlsx.SheetData = sheetData
|
||||
}
|
||||
|
||||
// replaceWorkSheetsRelationshipsNameSpaceBytes provides function to replace
|
||||
// replaceWorkSheetsRelationshipsNameSpaceBytes provides a function to replace
|
||||
// xl/worksheets/sheet%d.xml XML tags to self-closing for compatible Microsoft
|
||||
// Office Excel 2007.
|
||||
func replaceWorkSheetsRelationshipsNameSpaceBytes(workbookMarshal []byte) []byte {
|
||||
@@ -180,7 +192,7 @@ func (f *File) UpdateLinkedValue() {
|
||||
}
|
||||
}
|
||||
|
||||
// adjustHelper provides function to adjust rows and columns dimensions,
|
||||
// adjustHelper provides a function to adjust rows and columns dimensions,
|
||||
// hyperlinks, merged cells and auto filter when inserting or deleting rows or
|
||||
// columns.
|
||||
//
|
||||
@@ -202,7 +214,7 @@ func (f *File) adjustHelper(sheet string, column, row, offset int) {
|
||||
checkRow(xlsx)
|
||||
}
|
||||
|
||||
// adjustColDimensions provides function to update column dimensions when
|
||||
// adjustColDimensions provides a function to update column dimensions when
|
||||
// inserting or deleting rows or columns.
|
||||
func (f *File) adjustColDimensions(xlsx *xlsxWorksheet, column, offset int) {
|
||||
for i, r := range xlsx.SheetData.Row {
|
||||
@@ -218,8 +230,8 @@ func (f *File) adjustColDimensions(xlsx *xlsxWorksheet, column, offset int) {
|
||||
}
|
||||
}
|
||||
|
||||
// adjustRowDimensions provides function to update row dimensions when inserting
|
||||
// or deleting rows or columns.
|
||||
// adjustRowDimensions provides a function to update row dimensions when
|
||||
// inserting or deleting rows or columns.
|
||||
func (f *File) adjustRowDimensions(xlsx *xlsxWorksheet, rowIndex, offset int) {
|
||||
if rowIndex == -1 {
|
||||
return
|
||||
@@ -238,7 +250,7 @@ func (f *File) adjustRowDimensions(xlsx *xlsxWorksheet, rowIndex, offset int) {
|
||||
}
|
||||
}
|
||||
|
||||
// adjustHyperlinks provides function to update hyperlinks when inserting or
|
||||
// adjustHyperlinks provides a function to update hyperlinks when inserting or
|
||||
// deleting rows or columns.
|
||||
func (f *File) adjustHyperlinks(sheet string, column, rowIndex, offset int) {
|
||||
xlsx := f.workSheetReader(sheet)
|
||||
@@ -278,8 +290,8 @@ func (f *File) adjustHyperlinks(sheet string, column, rowIndex, offset int) {
|
||||
}
|
||||
}
|
||||
|
||||
// adjustMergeCellsHelper provides function to update merged cells when inserting or
|
||||
// deleting rows or columns.
|
||||
// adjustMergeCellsHelper provides a function to update merged cells when
|
||||
// inserting or deleting rows or columns.
|
||||
func (f *File) adjustMergeCellsHelper(xlsx *xlsxWorksheet, column, rowIndex, offset int) {
|
||||
if xlsx.MergeCells != nil {
|
||||
for k, v := range xlsx.MergeCells.Cells {
|
||||
@@ -319,8 +331,8 @@ func (f *File) adjustMergeCellsHelper(xlsx *xlsxWorksheet, column, rowIndex, off
|
||||
}
|
||||
}
|
||||
|
||||
// adjustMergeCells provides function to update merged cells when inserting or
|
||||
// deleting rows or columns.
|
||||
// adjustMergeCells provides a function to update merged cells when inserting
|
||||
// or deleting rows or columns.
|
||||
func (f *File) adjustMergeCells(xlsx *xlsxWorksheet, column, rowIndex, offset int) {
|
||||
f.adjustMergeCellsHelper(xlsx, column, rowIndex, offset)
|
||||
|
||||
@@ -340,8 +352,8 @@ func (f *File) adjustMergeCells(xlsx *xlsxWorksheet, column, rowIndex, offset in
|
||||
}
|
||||
}
|
||||
|
||||
// adjustAutoFilter provides function to update the auto filter when inserting
|
||||
// or deleting rows or columns.
|
||||
// adjustAutoFilter provides a function to update the auto filter when
|
||||
// inserting or deleting rows or columns.
|
||||
func (f *File) adjustAutoFilter(xlsx *xlsxWorksheet, column, rowIndex, offset int) {
|
||||
f.adjustAutoFilterHelper(xlsx, column, rowIndex, offset)
|
||||
|
||||
@@ -374,7 +386,7 @@ func (f *File) adjustAutoFilter(xlsx *xlsxWorksheet, column, rowIndex, offset in
|
||||
}
|
||||
}
|
||||
|
||||
// adjustAutoFilterHelper provides function to update the auto filter when
|
||||
// adjustAutoFilterHelper provides a function to update the auto filter when
|
||||
// inserting or deleting rows or columns.
|
||||
func (f *File) adjustAutoFilterHelper(xlsx *xlsxWorksheet, column, rowIndex, offset int) {
|
||||
if xlsx.AutoFilter != nil {
|
||||
|
||||
BIN
vendor/github.com/360EntSecGroup-Skylar/excelize/excelize.png
generated
vendored
BIN
vendor/github.com/360EntSecGroup-Skylar/excelize/excelize.png
generated
vendored
Binary file not shown.
|
Before Width: | Height: | Size: 42 KiB After Width: | Height: | Size: 53 KiB |
42
vendor/github.com/360EntSecGroup-Skylar/excelize/file.go
generated
vendored
42
vendor/github.com/360EntSecGroup-Skylar/excelize/file.go
generated
vendored
@@ -1,3 +1,12 @@
|
||||
// Copyright 2016 - 2018 The excelize Authors. All rights reserved. Use of
|
||||
// this source code is governed by a BSD-style license that can be found in
|
||||
// the LICENSE file.
|
||||
//
|
||||
// Package excelize providing a set of functions that allow you to write to
|
||||
// and read from XLSX files. Support reads and writes XLSX file generated by
|
||||
// Microsoft Excel™ 2007 and later. Support save file without losing original
|
||||
// charts of XLSX. This library needs Go version 1.8 or later.
|
||||
|
||||
package excelize
|
||||
|
||||
import (
|
||||
@@ -8,7 +17,7 @@ import (
|
||||
"os"
|
||||
)
|
||||
|
||||
// NewFile provides function to create new file by default template. For
|
||||
// NewFile provides a function to create new file by default template. For
|
||||
// example:
|
||||
//
|
||||
// xlsx := NewFile()
|
||||
@@ -36,19 +45,20 @@ func NewFile() *File {
|
||||
f.WorkBookRels = f.workbookRelsReader()
|
||||
f.Sheet["xl/worksheets/sheet1.xml"] = f.workSheetReader("Sheet1")
|
||||
f.sheetMap["Sheet1"] = "xl/worksheets/sheet1.xml"
|
||||
f.Theme = f.themeReader()
|
||||
return f
|
||||
}
|
||||
|
||||
// Save provides function to override the xlsx file with origin path.
|
||||
// Save provides a function to override the xlsx file with origin path.
|
||||
func (f *File) Save() error {
|
||||
if f.Path == "" {
|
||||
return fmt.Errorf("No path defined for file, consider File.WriteTo or File.Write")
|
||||
return fmt.Errorf("no path defined for file, consider File.WriteTo or File.Write")
|
||||
}
|
||||
return f.SaveAs(f.Path)
|
||||
}
|
||||
|
||||
// SaveAs provides function to create or update to an xlsx file at the provided
|
||||
// path.
|
||||
// SaveAs provides a function to create or update to an xlsx file at the
|
||||
// provided path.
|
||||
func (f *File) SaveAs(name string) error {
|
||||
file, err := os.OpenFile(name, os.O_WRONLY|os.O_TRUNC|os.O_CREATE, 0666)
|
||||
if err != nil {
|
||||
@@ -58,8 +68,14 @@ func (f *File) SaveAs(name string) error {
|
||||
return f.Write(file)
|
||||
}
|
||||
|
||||
// Write provides function to write to an io.Writer.
|
||||
// Write provides a function to write to an io.Writer.
|
||||
func (f *File) Write(w io.Writer) error {
|
||||
_, err := f.WriteTo(w)
|
||||
return err
|
||||
}
|
||||
|
||||
// WriteTo implements io.WriterTo to write the file.
|
||||
func (f *File) WriteTo(w io.Writer) (int64, error) {
|
||||
buf := new(bytes.Buffer)
|
||||
zw := zip.NewWriter(buf)
|
||||
f.contentTypesWriter()
|
||||
@@ -70,21 +86,17 @@ func (f *File) Write(w io.Writer) error {
|
||||
for path, content := range f.XLSX {
|
||||
fi, err := zw.Create(path)
|
||||
if err != nil {
|
||||
return err
|
||||
return 0, err
|
||||
}
|
||||
_, err = fi.Write([]byte(content))
|
||||
_, err = fi.Write(content)
|
||||
if err != nil {
|
||||
return err
|
||||
return 0, err
|
||||
}
|
||||
}
|
||||
err := zw.Close()
|
||||
if err != nil {
|
||||
return err
|
||||
return 0, err
|
||||
}
|
||||
|
||||
if _, err := buf.WriteTo(w); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
return buf.WriteTo(w)
|
||||
}
|
||||
|
||||
139
vendor/github.com/360EntSecGroup-Skylar/excelize/hsl.go
generated
vendored
Normal file
139
vendor/github.com/360EntSecGroup-Skylar/excelize/hsl.go
generated
vendored
Normal file
@@ -0,0 +1,139 @@
|
||||
// Copyright (c) 2012 Rodrigo Moraes. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
package excelize
|
||||
|
||||
import (
|
||||
"image/color"
|
||||
"math"
|
||||
)
|
||||
|
||||
// HSLModel converts any color.Color to a HSL color.
|
||||
var HSLModel = color.ModelFunc(hslModel)
|
||||
|
||||
// HSL represents a cylindrical coordinate of points in an RGB color model.
|
||||
//
|
||||
// Values are in the range 0 to 1.
|
||||
type HSL struct {
|
||||
H, S, L float64
|
||||
}
|
||||
|
||||
// RGBA returns the alpha-premultiplied red, green, blue and alpha values
|
||||
// for the HSL.
|
||||
func (c HSL) RGBA() (uint32, uint32, uint32, uint32) {
|
||||
r, g, b := HSLToRGB(c.H, c.S, c.L)
|
||||
return uint32(r) * 0x101, uint32(g) * 0x101, uint32(b) * 0x101, 0xffff
|
||||
}
|
||||
|
||||
// hslModel converts a color.Color to HSL.
|
||||
func hslModel(c color.Color) color.Color {
|
||||
if _, ok := c.(HSL); ok {
|
||||
return c
|
||||
}
|
||||
r, g, b, _ := c.RGBA()
|
||||
h, s, l := RGBToHSL(uint8(r>>8), uint8(g>>8), uint8(b>>8))
|
||||
return HSL{h, s, l}
|
||||
}
|
||||
|
||||
// RGBToHSL converts an RGB triple to a HSL triple.
|
||||
func RGBToHSL(r, g, b uint8) (h, s, l float64) {
|
||||
fR := float64(r) / 255
|
||||
fG := float64(g) / 255
|
||||
fB := float64(b) / 255
|
||||
max := math.Max(math.Max(fR, fG), fB)
|
||||
min := math.Min(math.Min(fR, fG), fB)
|
||||
l = (max + min) / 2
|
||||
if max == min {
|
||||
// Achromatic.
|
||||
h, s = 0, 0
|
||||
} else {
|
||||
// Chromatic.
|
||||
d := max - min
|
||||
if l > 0.5 {
|
||||
s = d / (2.0 - max - min)
|
||||
} else {
|
||||
s = d / (max + min)
|
||||
}
|
||||
switch max {
|
||||
case fR:
|
||||
h = (fG - fB) / d
|
||||
if fG < fB {
|
||||
h += 6
|
||||
}
|
||||
case fG:
|
||||
h = (fB-fR)/d + 2
|
||||
case fB:
|
||||
h = (fR-fG)/d + 4
|
||||
}
|
||||
h /= 6
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// HSLToRGB converts an HSL triple to a RGB triple.
|
||||
func HSLToRGB(h, s, l float64) (r, g, b uint8) {
|
||||
var fR, fG, fB float64
|
||||
if s == 0 {
|
||||
fR, fG, fB = l, l, l
|
||||
} else {
|
||||
var q float64
|
||||
if l < 0.5 {
|
||||
q = l * (1 + s)
|
||||
} else {
|
||||
q = l + s - s*l
|
||||
}
|
||||
p := 2*l - q
|
||||
fR = hueToRGB(p, q, h+1.0/3)
|
||||
fG = hueToRGB(p, q, h)
|
||||
fB = hueToRGB(p, q, h-1.0/3)
|
||||
}
|
||||
r = uint8((fR * 255) + 0.5)
|
||||
g = uint8((fG * 255) + 0.5)
|
||||
b = uint8((fB * 255) + 0.5)
|
||||
return
|
||||
}
|
||||
|
||||
// hueToRGB is a helper function for HSLToRGB.
|
||||
func hueToRGB(p, q, t float64) float64 {
|
||||
if t < 0 {
|
||||
t++
|
||||
}
|
||||
if t > 1 {
|
||||
t--
|
||||
}
|
||||
if t < 1.0/6 {
|
||||
return p + (q-p)*6*t
|
||||
}
|
||||
if t < 0.5 {
|
||||
return q
|
||||
}
|
||||
if t < 2.0/3 {
|
||||
return p + (q-p)*(2.0/3-t)*6
|
||||
}
|
||||
return p
|
||||
}
|
||||
53
vendor/github.com/360EntSecGroup-Skylar/excelize/lib.go
generated
vendored
53
vendor/github.com/360EntSecGroup-Skylar/excelize/lib.go
generated
vendored
@@ -1,9 +1,17 @@
|
||||
// Copyright 2016 - 2018 The excelize Authors. All rights reserved. Use of
|
||||
// this source code is governed by a BSD-style license that can be found in
|
||||
// the LICENSE file.
|
||||
//
|
||||
// Package excelize providing a set of functions that allow you to write to
|
||||
// and read from XLSX files. Support reads and writes XLSX file generated by
|
||||
// Microsoft Excel™ 2007 and later. Support save file without losing original
|
||||
// charts of XLSX. This library needs Go version 1.8 or later.
|
||||
|
||||
package excelize
|
||||
|
||||
import (
|
||||
"archive/zip"
|
||||
"bytes"
|
||||
"encoding/gob"
|
||||
"io"
|
||||
"log"
|
||||
"math"
|
||||
@@ -26,7 +34,7 @@ func ReadZipReader(r *zip.Reader) (map[string][]byte, int, error) {
|
||||
return fileList, worksheets, nil
|
||||
}
|
||||
|
||||
// readXML provides function to read XML content as string.
|
||||
// readXML provides a function to read XML content as string.
|
||||
func (f *File) readXML(name string) []byte {
|
||||
if content, ok := f.XLSX[name]; ok {
|
||||
return content
|
||||
@@ -34,8 +42,8 @@ func (f *File) readXML(name string) []byte {
|
||||
return []byte{}
|
||||
}
|
||||
|
||||
// saveFileList provides function to update given file content in file list of
|
||||
// XLSX.
|
||||
// saveFileList provides a function to update given file content in file list
|
||||
// of XLSX.
|
||||
func (f *File) saveFileList(name string, content []byte) {
|
||||
newContent := make([]byte, 0, len(XMLHeader)+len(content))
|
||||
newContent = append(newContent, []byte(XMLHeader)...)
|
||||
@@ -50,12 +58,12 @@ func readFile(file *zip.File) []byte {
|
||||
log.Fatal(err)
|
||||
}
|
||||
buff := bytes.NewBuffer(nil)
|
||||
io.Copy(buff, rc)
|
||||
_, _ = io.Copy(buff, rc)
|
||||
rc.Close()
|
||||
return buff.Bytes()
|
||||
}
|
||||
|
||||
// ToAlphaString provides function to convert integer to Excel sheet column
|
||||
// ToAlphaString provides a function to convert integer to Excel sheet column
|
||||
// title. For example convert 36 to column title AK:
|
||||
//
|
||||
// excelize.ToAlphaString(36)
|
||||
@@ -73,9 +81,9 @@ func ToAlphaString(value int) string {
|
||||
return ans
|
||||
}
|
||||
|
||||
// TitleToNumber provides function to convert Excel sheet column title to int
|
||||
// (this function doesn't do value check currently). For example convert AK
|
||||
// and ak to column title 36:
|
||||
// TitleToNumber provides a function to convert Excel sheet column title to
|
||||
// int (this function doesn't do value check currently). For example convert
|
||||
// AK and ak to column title 36:
|
||||
//
|
||||
// excelize.TitleToNumber("AK")
|
||||
// excelize.TitleToNumber("ak")
|
||||
@@ -115,17 +123,6 @@ func intOnlyMapF(rune rune) rune {
|
||||
return -1
|
||||
}
|
||||
|
||||
// deepCopy provides method to creates a deep copy of whatever is passed to it
|
||||
// and returns the copy in an interface. The returned value will need to be
|
||||
// asserted to the correct type.
|
||||
func deepCopy(dst, src interface{}) error {
|
||||
var buf bytes.Buffer
|
||||
if err := gob.NewEncoder(&buf).Encode(src); err != nil {
|
||||
return err
|
||||
}
|
||||
return gob.NewDecoder(bytes.NewBuffer(buf.Bytes())).Decode(dst)
|
||||
}
|
||||
|
||||
// boolPtr returns a pointer to a bool with the given value.
|
||||
func boolPtr(b bool) *bool { return &b }
|
||||
|
||||
@@ -137,8 +134,8 @@ func defaultTrue(b *bool) bool {
|
||||
return *b
|
||||
}
|
||||
|
||||
// axisLowerOrEqualThan returns true if axis1 <= axis2
|
||||
// axis1/axis2 can be either a column or a row axis, e.g. "A", "AAE", "42", "1", etc.
|
||||
// axisLowerOrEqualThan returns true if axis1 <= axis2 axis1/axis2 can be
|
||||
// either a column or a row axis, e.g. "A", "AAE", "42", "1", etc.
|
||||
//
|
||||
// For instance, the following comparisons are all true:
|
||||
//
|
||||
@@ -159,7 +156,8 @@ func axisLowerOrEqualThan(axis1, axis2 string) bool {
|
||||
}
|
||||
}
|
||||
|
||||
// getCellColRow returns the two parts of a cell identifier (its col and row) as strings
|
||||
// getCellColRow returns the two parts of a cell identifier (its col and row)
|
||||
// as strings
|
||||
//
|
||||
// For instance:
|
||||
//
|
||||
@@ -176,3 +174,12 @@ func getCellColRow(cell string) (col, row string) {
|
||||
|
||||
return cell, ""
|
||||
}
|
||||
|
||||
// parseFormatSet provides a method to convert format string to []byte and
|
||||
// handle empty string.
|
||||
func parseFormatSet(formatSet string) []byte {
|
||||
if formatSet != "" {
|
||||
return []byte(formatSet)
|
||||
}
|
||||
return []byte("{}")
|
||||
}
|
||||
|
||||
157
vendor/github.com/360EntSecGroup-Skylar/excelize/picture.go
generated
vendored
157
vendor/github.com/360EntSecGroup-Skylar/excelize/picture.go
generated
vendored
@@ -1,3 +1,12 @@
|
||||
// Copyright 2016 - 2018 The excelize Authors. All rights reserved. Use of
|
||||
// this source code is governed by a BSD-style license that can be found in
|
||||
// the LICENSE file.
|
||||
//
|
||||
// Package excelize providing a set of functions that allow you to write to
|
||||
// and read from XLSX files. Support reads and writes XLSX file generated by
|
||||
// Microsoft Excel™ 2007 and later. Support save file without losing original
|
||||
// charts of XLSX. This library needs Go version 1.8 or later.
|
||||
|
||||
package excelize
|
||||
|
||||
import (
|
||||
@@ -14,9 +23,9 @@ import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
// parseFormatPictureSet provides function to parse the format settings of the
|
||||
// picture with default value.
|
||||
func parseFormatPictureSet(formatSet string) *formatPicture {
|
||||
// parseFormatPictureSet provides a function to parse the format settings of
|
||||
// the picture with default value.
|
||||
func parseFormatPictureSet(formatSet string) (*formatPicture, error) {
|
||||
format := formatPicture{
|
||||
FPrintsWithSheet: true,
|
||||
FLocksWithSheet: false,
|
||||
@@ -26,8 +35,8 @@ func parseFormatPictureSet(formatSet string) *formatPicture {
|
||||
XScale: 1.0,
|
||||
YScale: 1.0,
|
||||
}
|
||||
json.Unmarshal([]byte(formatSet), &format)
|
||||
return &format
|
||||
err := json.Unmarshal(parseFormatSet(formatSet), &format)
|
||||
return &format, err
|
||||
}
|
||||
|
||||
// AddPicture provides the method to add picture in a sheet by given picture
|
||||
@@ -78,20 +87,66 @@ func parseFormatPictureSet(formatSet string) *formatPicture {
|
||||
// positioning is move and size with cells.
|
||||
func (f *File) AddPicture(sheet, cell, picture, format string) error {
|
||||
var err error
|
||||
var drawingHyperlinkRID int
|
||||
var hyperlinkType string
|
||||
// Check picture exists first.
|
||||
if _, err = os.Stat(picture); os.IsNotExist(err) {
|
||||
return err
|
||||
}
|
||||
ext, ok := supportImageTypes[path.Ext(picture)]
|
||||
if !ok {
|
||||
return errors.New("Unsupported image extension")
|
||||
return errors.New("unsupported image extension")
|
||||
}
|
||||
file, _ := ioutil.ReadFile(picture)
|
||||
_, name := filepath.Split(picture)
|
||||
return f.AddPictureFromBytes(sheet, cell, format, name, ext, file)
|
||||
}
|
||||
|
||||
// AddPictureFromBytes provides the method to add picture in a sheet by given
|
||||
// picture format set (such as offset, scale, aspect ratio setting and print
|
||||
// settings), file base name, extension name and file bytes. For example:
|
||||
//
|
||||
// package main
|
||||
//
|
||||
// import (
|
||||
// "fmt"
|
||||
// _ "image/jpeg"
|
||||
// "io/ioutil"
|
||||
//
|
||||
// "github.com/360EntSecGroup-Skylar/excelize"
|
||||
// )
|
||||
//
|
||||
// func main() {
|
||||
// xlsx := excelize.NewFile()
|
||||
//
|
||||
// file, err := ioutil.ReadFile("./image1.jpg")
|
||||
// if err != nil {
|
||||
// fmt.Println(err)
|
||||
// }
|
||||
// err = xlsx.AddPictureFromBytes("Sheet1", "A2", "", "Excel Logo", ".jpg", file)
|
||||
// if err != nil {
|
||||
// fmt.Println(err)
|
||||
// }
|
||||
// err = xlsx.SaveAs("./Book1.xlsx")
|
||||
// if err != nil {
|
||||
// fmt.Println(err)
|
||||
// }
|
||||
// }
|
||||
//
|
||||
func (f *File) AddPictureFromBytes(sheet, cell, format, name, extension string, file []byte) error {
|
||||
var err error
|
||||
var drawingHyperlinkRID int
|
||||
var hyperlinkType string
|
||||
ext, ok := supportImageTypes[extension]
|
||||
if !ok {
|
||||
return errors.New("unsupported image extension")
|
||||
}
|
||||
formatSet, err := parseFormatPictureSet(format)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
image, _, err := image.DecodeConfig(bytes.NewReader(file))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
readFile, _ := os.Open(picture)
|
||||
image, _, err := image.DecodeConfig(readFile)
|
||||
_, file := filepath.Split(picture)
|
||||
formatSet := parseFormatPictureSet(format)
|
||||
// Read sheet data.
|
||||
xlsx := f.workSheetReader(sheet)
|
||||
// Add first picture for given sheet, create xl/drawings/ and xl/drawings/_rels/ folder.
|
||||
@@ -107,13 +162,13 @@ func (f *File) AddPicture(sheet, cell, picture, format string) error {
|
||||
}
|
||||
drawingHyperlinkRID = f.addDrawingRelationships(drawingID, SourceRelationshipHyperLink, formatSet.Hyperlink, hyperlinkType)
|
||||
}
|
||||
f.addDrawingPicture(sheet, drawingXML, cell, file, image.Width, image.Height, drawingRID, drawingHyperlinkRID, formatSet)
|
||||
f.addMedia(picture, ext)
|
||||
f.addDrawingPicture(sheet, drawingXML, cell, name, image.Width, image.Height, drawingRID, drawingHyperlinkRID, formatSet)
|
||||
f.addMedia(file, ext)
|
||||
f.addContentTypePart(drawingID, "drawings")
|
||||
return err
|
||||
}
|
||||
|
||||
// addSheetRelationships provides function to add
|
||||
// addSheetRelationships provides a function to add
|
||||
// xl/worksheets/_rels/sheet%d.xml.rels by given worksheet name, relationship
|
||||
// type and target.
|
||||
func (f *File) addSheetRelationships(sheet, relType, target, targetMode string) int {
|
||||
@@ -130,7 +185,7 @@ func (f *File) addSheetRelationships(sheet, relType, target, targetMode string)
|
||||
_, ok = f.XLSX[rels]
|
||||
if ok {
|
||||
ID.Reset()
|
||||
xml.Unmarshal([]byte(f.readXML(rels)), &sheetRels)
|
||||
_ = xml.Unmarshal([]byte(f.readXML(rels)), &sheetRels)
|
||||
rID = len(sheetRels.Relationships) + 1
|
||||
ID.WriteString("rId")
|
||||
ID.WriteString(strconv.Itoa(rID))
|
||||
@@ -146,9 +201,9 @@ func (f *File) addSheetRelationships(sheet, relType, target, targetMode string)
|
||||
return rID
|
||||
}
|
||||
|
||||
// deleteSheetRelationships provides function to delete relationships in
|
||||
// xl/worksheets/_rels/sheet%d.xml.rels by given worksheet name and relationship
|
||||
// index.
|
||||
// deleteSheetRelationships provides a function to delete relationships in
|
||||
// xl/worksheets/_rels/sheet%d.xml.rels by given worksheet name and
|
||||
// relationship index.
|
||||
func (f *File) deleteSheetRelationships(sheet, rID string) {
|
||||
name, ok := f.sheetMap[trimSheetName(sheet)]
|
||||
if !ok {
|
||||
@@ -156,7 +211,7 @@ func (f *File) deleteSheetRelationships(sheet, rID string) {
|
||||
}
|
||||
var rels = "xl/worksheets/_rels/" + strings.TrimPrefix(name, "xl/worksheets/") + ".rels"
|
||||
var sheetRels xlsxWorkbookRels
|
||||
xml.Unmarshal([]byte(f.readXML(rels)), &sheetRels)
|
||||
_ = xml.Unmarshal([]byte(f.readXML(rels)), &sheetRels)
|
||||
for k, v := range sheetRels.Relationships {
|
||||
if v.ID == rID {
|
||||
sheetRels.Relationships = append(sheetRels.Relationships[:k], sheetRels.Relationships[k+1:]...)
|
||||
@@ -166,7 +221,7 @@ func (f *File) deleteSheetRelationships(sheet, rID string) {
|
||||
f.saveFileList(rels, output)
|
||||
}
|
||||
|
||||
// addSheetLegacyDrawing provides function to add legacy drawing element to
|
||||
// addSheetLegacyDrawing provides a function to add legacy drawing element to
|
||||
// xl/worksheets/sheet%d.xml by given worksheet name and relationship index.
|
||||
func (f *File) addSheetLegacyDrawing(sheet string, rID int) {
|
||||
xlsx := f.workSheetReader(sheet)
|
||||
@@ -175,7 +230,7 @@ func (f *File) addSheetLegacyDrawing(sheet string, rID int) {
|
||||
}
|
||||
}
|
||||
|
||||
// addSheetDrawing provides function to add drawing element to
|
||||
// addSheetDrawing provides a function to add drawing element to
|
||||
// xl/worksheets/sheet%d.xml by given worksheet name and relationship index.
|
||||
func (f *File) addSheetDrawing(sheet string, rID int) {
|
||||
xlsx := f.workSheetReader(sheet)
|
||||
@@ -184,7 +239,7 @@ func (f *File) addSheetDrawing(sheet string, rID int) {
|
||||
}
|
||||
}
|
||||
|
||||
// addSheetPicture provides function to add picture element to
|
||||
// addSheetPicture provides a function to add picture element to
|
||||
// xl/worksheets/sheet%d.xml by given worksheet name and relationship index.
|
||||
func (f *File) addSheetPicture(sheet string, rID int) {
|
||||
xlsx := f.workSheetReader(sheet)
|
||||
@@ -193,7 +248,7 @@ func (f *File) addSheetPicture(sheet string, rID int) {
|
||||
}
|
||||
}
|
||||
|
||||
// countDrawings provides function to get drawing files count storage in the
|
||||
// countDrawings provides a function to get drawing files count storage in the
|
||||
// folder xl/drawings.
|
||||
func (f *File) countDrawings() int {
|
||||
count := 0
|
||||
@@ -205,7 +260,7 @@ func (f *File) countDrawings() int {
|
||||
return count
|
||||
}
|
||||
|
||||
// addDrawingPicture provides function to add picture by given sheet,
|
||||
// addDrawingPicture provides a function to add picture by given sheet,
|
||||
// drawingXML, cell, file name, width, height relationship index and format
|
||||
// sets.
|
||||
func (f *File) addDrawingPicture(sheet, drawingXML, cell, file string, width, height, rID, hyperlinkRID int, formatSet *formatPicture) {
|
||||
@@ -260,8 +315,8 @@ func (f *File) addDrawingPicture(sheet, drawingXML, cell, file string, width, he
|
||||
f.saveFileList(drawingXML, output)
|
||||
}
|
||||
|
||||
// addDrawingRelationships provides function to add image part relationships in
|
||||
// the file xl/drawings/_rels/drawing%d.xml.rels by given drawing index,
|
||||
// addDrawingRelationships provides a function to add image part relationships
|
||||
// in the file xl/drawings/_rels/drawing%d.xml.rels by given drawing index,
|
||||
// relationship type and target.
|
||||
func (f *File) addDrawingRelationships(index int, relType, target, targetMode string) int {
|
||||
var rels = "xl/drawings/_rels/drawing" + strconv.Itoa(index) + ".xml.rels"
|
||||
@@ -273,7 +328,7 @@ func (f *File) addDrawingRelationships(index int, relType, target, targetMode st
|
||||
_, ok := f.XLSX[rels]
|
||||
if ok {
|
||||
ID.Reset()
|
||||
xml.Unmarshal([]byte(f.readXML(rels)), &drawingRels)
|
||||
_ = xml.Unmarshal([]byte(f.readXML(rels)), &drawingRels)
|
||||
rID = len(drawingRels.Relationships) + 1
|
||||
ID.WriteString("rId")
|
||||
ID.WriteString(strconv.Itoa(rID))
|
||||
@@ -289,8 +344,8 @@ func (f *File) addDrawingRelationships(index int, relType, target, targetMode st
|
||||
return rID
|
||||
}
|
||||
|
||||
// countMedia provides function to get media files count storage in the folder
|
||||
// xl/media/image.
|
||||
// countMedia provides a function to get media files count storage in the
|
||||
// folder xl/media/image.
|
||||
func (f *File) countMedia() int {
|
||||
count := 0
|
||||
for k := range f.XLSX {
|
||||
@@ -301,17 +356,16 @@ func (f *File) countMedia() int {
|
||||
return count
|
||||
}
|
||||
|
||||
// addMedia provides function to add picture into folder xl/media/image by given
|
||||
// file name and extension name.
|
||||
func (f *File) addMedia(file, ext string) {
|
||||
// addMedia provides a function to add picture into folder xl/media/image by
|
||||
// given file and extension name.
|
||||
func (f *File) addMedia(file []byte, ext string) {
|
||||
count := f.countMedia()
|
||||
dat, _ := ioutil.ReadFile(file)
|
||||
media := "xl/media/image" + strconv.Itoa(count+1) + ext
|
||||
f.XLSX[media] = dat
|
||||
f.XLSX[media] = file
|
||||
}
|
||||
|
||||
// setContentTypePartImageExtensions provides function to set the content type
|
||||
// for relationship parts and the Main Document part.
|
||||
// setContentTypePartImageExtensions provides a function to set the content
|
||||
// type for relationship parts and the Main Document part.
|
||||
func (f *File) setContentTypePartImageExtensions() {
|
||||
var imageTypes = map[string]bool{"jpeg": false, "png": false, "gif": false}
|
||||
content := f.contentTypesReader()
|
||||
@@ -331,7 +385,7 @@ func (f *File) setContentTypePartImageExtensions() {
|
||||
}
|
||||
}
|
||||
|
||||
// setContentTypePartVMLExtensions provides function to set the content type
|
||||
// setContentTypePartVMLExtensions provides a function to set the content type
|
||||
// for relationship parts and the Main Document part.
|
||||
func (f *File) setContentTypePartVMLExtensions() {
|
||||
vml := false
|
||||
@@ -349,8 +403,8 @@ func (f *File) setContentTypePartVMLExtensions() {
|
||||
}
|
||||
}
|
||||
|
||||
// addContentTypePart provides function to add content type part relationships
|
||||
// in the file [Content_Types].xml by given index.
|
||||
// addContentTypePart provides a function to add content type part
|
||||
// relationships in the file [Content_Types].xml by given index.
|
||||
func (f *File) addContentTypePart(index int, contentType string) {
|
||||
setContentType := map[string]func(){
|
||||
"comments": f.setContentTypePartVMLExtensions,
|
||||
@@ -384,7 +438,7 @@ func (f *File) addContentTypePart(index int, contentType string) {
|
||||
})
|
||||
}
|
||||
|
||||
// getSheetRelationshipsTargetByID provides function to get Target attribute
|
||||
// getSheetRelationshipsTargetByID provides a function to get Target attribute
|
||||
// value in xl/worksheets/_rels/sheet%d.xml.rels by given worksheet name and
|
||||
// relationship index.
|
||||
func (f *File) getSheetRelationshipsTargetByID(sheet, rID string) string {
|
||||
@@ -394,7 +448,7 @@ func (f *File) getSheetRelationshipsTargetByID(sheet, rID string) string {
|
||||
}
|
||||
var rels = "xl/worksheets/_rels/" + strings.TrimPrefix(name, "xl/worksheets/") + ".rels"
|
||||
var sheetRels xlsxWorkbookRels
|
||||
xml.Unmarshal([]byte(f.readXML(rels)), &sheetRels)
|
||||
_ = xml.Unmarshal([]byte(f.readXML(rels)), &sheetRels)
|
||||
for _, v := range sheetRels.Relationships {
|
||||
if v.ID == rID {
|
||||
return v.Target
|
||||
@@ -403,9 +457,9 @@ func (f *File) getSheetRelationshipsTargetByID(sheet, rID string) string {
|
||||
return ""
|
||||
}
|
||||
|
||||
// GetPicture provides function to get picture base name and raw content embed
|
||||
// in XLSX by given worksheet and cell name. This function returns the file name
|
||||
// in XLSX and file contents as []byte data types. For example:
|
||||
// GetPicture provides a function to get picture base name and raw content
|
||||
// embed in XLSX by given worksheet and cell name. This function returns the
|
||||
// file name in XLSX and file contents as []byte data types. For example:
|
||||
//
|
||||
// xlsx, err := excelize.OpenFile("./Book1.xlsx")
|
||||
// if err != nil {
|
||||
@@ -431,10 +485,10 @@ func (f *File) GetPicture(sheet, cell string) (string, []byte) {
|
||||
|
||||
_, ok := f.XLSX[drawingXML]
|
||||
if !ok {
|
||||
return "", []byte{}
|
||||
return "", nil
|
||||
}
|
||||
decodeWsDr := decodeWsDr{}
|
||||
xml.Unmarshal([]byte(f.readXML(drawingXML)), &decodeWsDr)
|
||||
_ = xml.Unmarshal([]byte(f.readXML(drawingXML)), &decodeWsDr)
|
||||
|
||||
cell = strings.ToUpper(cell)
|
||||
fromCol := string(strings.Map(letterOnlyMapF, cell))
|
||||
@@ -446,7 +500,7 @@ func (f *File) GetPicture(sheet, cell string) (string, []byte) {
|
||||
|
||||
for _, anchor := range decodeWsDr.TwoCellAnchor {
|
||||
decodeTwoCellAnchor := decodeTwoCellAnchor{}
|
||||
xml.Unmarshal([]byte("<decodeTwoCellAnchor>"+anchor.Content+"</decodeTwoCellAnchor>"), &decodeTwoCellAnchor)
|
||||
_ = xml.Unmarshal([]byte("<decodeTwoCellAnchor>"+anchor.Content+"</decodeTwoCellAnchor>"), &decodeTwoCellAnchor)
|
||||
if decodeTwoCellAnchor.From != nil && decodeTwoCellAnchor.Pic != nil {
|
||||
if decodeTwoCellAnchor.From.Col == col && decodeTwoCellAnchor.From.Row == row {
|
||||
xlsxWorkbookRelation := f.getDrawingRelationships(drawingRelationships, decodeTwoCellAnchor.Pic.BlipFill.Blip.Embed)
|
||||
@@ -460,15 +514,16 @@ func (f *File) GetPicture(sheet, cell string) (string, []byte) {
|
||||
return "", []byte{}
|
||||
}
|
||||
|
||||
// getDrawingRelationships provides function to get drawing relationships from
|
||||
// xl/drawings/_rels/drawing%s.xml.rels by given file name and relationship ID.
|
||||
// getDrawingRelationships provides a function to get drawing relationships
|
||||
// from xl/drawings/_rels/drawing%s.xml.rels by given file name and
|
||||
// relationship ID.
|
||||
func (f *File) getDrawingRelationships(rels, rID string) *xlsxWorkbookRelation {
|
||||
_, ok := f.XLSX[rels]
|
||||
if !ok {
|
||||
return nil
|
||||
}
|
||||
var drawingRels xlsxWorkbookRels
|
||||
xml.Unmarshal([]byte(f.readXML(rels)), &drawingRels)
|
||||
_ = xml.Unmarshal([]byte(f.readXML(rels)), &drawingRels)
|
||||
for _, v := range drawingRels.Relationships {
|
||||
if v.ID == rID {
|
||||
return &v
|
||||
|
||||
62
vendor/github.com/360EntSecGroup-Skylar/excelize/rows.go
generated
vendored
62
vendor/github.com/360EntSecGroup-Skylar/excelize/rows.go
generated
vendored
@@ -1,3 +1,12 @@
|
||||
// Copyright 2016 - 2018 The excelize Authors. All rights reserved. Use of
|
||||
// this source code is governed by a BSD-style license that can be found in
|
||||
// the LICENSE file.
|
||||
//
|
||||
// Package excelize providing a set of functions that allow you to write to
|
||||
// and read from XLSX files. Support reads and writes XLSX file generated by
|
||||
// Microsoft Excel™ 2007 and later. Support save file without losing original
|
||||
// charts of XLSX. This library needs Go version 1.8 or later.
|
||||
|
||||
package excelize
|
||||
|
||||
import (
|
||||
@@ -31,7 +40,7 @@ func (f *File) GetRows(sheet string) [][]string {
|
||||
output, _ := xml.Marshal(f.Sheet[name])
|
||||
f.saveFileList(name, replaceWorkSheetsRelationshipsNameSpaceBytes(output))
|
||||
}
|
||||
decoder := xml.NewDecoder(bytes.NewReader(f.readXML(name)))
|
||||
xml.NewDecoder(bytes.NewReader(f.readXML(name)))
|
||||
d := f.sharedStringsReader()
|
||||
var inElement string
|
||||
var r xlsxRow
|
||||
@@ -44,7 +53,7 @@ func (f *File) GetRows(sheet string) [][]string {
|
||||
}
|
||||
rows = append(rows, row)
|
||||
}
|
||||
decoder = xml.NewDecoder(bytes.NewReader(f.readXML(name)))
|
||||
decoder := xml.NewDecoder(bytes.NewReader(f.readXML(name)))
|
||||
for {
|
||||
token, _ := decoder.Token()
|
||||
if token == nil {
|
||||
@@ -55,7 +64,7 @@ func (f *File) GetRows(sheet string) [][]string {
|
||||
inElement = startElement.Name.Local
|
||||
if inElement == "row" {
|
||||
r = xlsxRow{}
|
||||
decoder.DecodeElement(&r, &startElement)
|
||||
_ = decoder.DecodeElement(&r, &startElement)
|
||||
cr := r.R - 1
|
||||
for _, colCell := range r.C {
|
||||
c := TitleToNumber(strings.Map(letterOnlyMapF, colCell.R))
|
||||
@@ -110,9 +119,9 @@ func (rows *Rows) Columns() []string {
|
||||
}
|
||||
startElement := rows.token.(xml.StartElement)
|
||||
r := xlsxRow{}
|
||||
rows.decoder.DecodeElement(&r, &startElement)
|
||||
_ = rows.decoder.DecodeElement(&r, &startElement)
|
||||
d := rows.f.sharedStringsReader()
|
||||
row := make([]string, len(r.C), len(r.C))
|
||||
row := make([]string, len(r.C))
|
||||
for _, colCell := range r.C {
|
||||
c := TitleToNumber(strings.Map(letterOnlyMapF, colCell.R))
|
||||
val, _ := colCell.getValueFrom(rows.f, d)
|
||||
@@ -132,7 +141,7 @@ func (err ErrSheetNotExist) Error() string {
|
||||
|
||||
// Rows return a rows iterator. For example:
|
||||
//
|
||||
// rows, err := xlsx.GetRows("Sheet1")
|
||||
// rows, err := xlsx.Rows("Sheet1")
|
||||
// for rows.Next() {
|
||||
// for _, colCell := range rows.Columns() {
|
||||
// fmt.Print(colCell, "\t")
|
||||
@@ -173,7 +182,7 @@ func (f *File) getTotalRowsCols(name string) (int, int) {
|
||||
inElement = startElement.Name.Local
|
||||
if inElement == "row" {
|
||||
r = xlsxRow{}
|
||||
decoder.DecodeElement(&r, &startElement)
|
||||
_ = decoder.DecodeElement(&r, &startElement)
|
||||
tr = r.R
|
||||
for _, colCell := range r.C {
|
||||
col := TitleToNumber(strings.Map(letterOnlyMapF, colCell.R))
|
||||
@@ -202,7 +211,7 @@ func (f *File) SetRowHeight(sheet string, row int, height float64) {
|
||||
xlsx.SheetData.Row[rowIdx].CustomHeight = true
|
||||
}
|
||||
|
||||
// getRowHeight provides function to get row height in pixels by given sheet
|
||||
// getRowHeight provides a function to get row height in pixels by given sheet
|
||||
// name and row index.
|
||||
func (f *File) getRowHeight(sheet string, row int) int {
|
||||
xlsx := f.workSheetReader(sheet)
|
||||
@@ -215,7 +224,7 @@ func (f *File) getRowHeight(sheet string, row int) int {
|
||||
return int(defaultRowHeightPixels)
|
||||
}
|
||||
|
||||
// GetRowHeight provides function to get row height by given worksheet name
|
||||
// GetRowHeight provides a function to get row height by given worksheet name
|
||||
// and row index. For example, get the height of the first row in Sheet1:
|
||||
//
|
||||
// xlsx.GetRowHeight("Sheet1", 1)
|
||||
@@ -231,7 +240,7 @@ func (f *File) GetRowHeight(sheet string, row int) float64 {
|
||||
return defaultRowHeightPixels
|
||||
}
|
||||
|
||||
// sharedStringsReader provides function to get the pointer to the structure
|
||||
// sharedStringsReader provides a function to get the pointer to the structure
|
||||
// after deserialization of xl/sharedStrings.xml.
|
||||
func (f *File) sharedStringsReader() *xlsxSST {
|
||||
if f.SharedStrings == nil {
|
||||
@@ -240,14 +249,15 @@ func (f *File) sharedStringsReader() *xlsxSST {
|
||||
if len(ss) == 0 {
|
||||
ss = f.readXML("xl/SharedStrings.xml")
|
||||
}
|
||||
xml.Unmarshal([]byte(ss), &sharedStrings)
|
||||
_ = xml.Unmarshal([]byte(ss), &sharedStrings)
|
||||
f.SharedStrings = &sharedStrings
|
||||
}
|
||||
return f.SharedStrings
|
||||
}
|
||||
|
||||
// getValueFrom return a value from a column/row cell, this function is inteded
|
||||
// to be used with for range on rows an argument with the xlsx opened file.
|
||||
// getValueFrom return a value from a column/row cell, this function is
|
||||
// inteded to be used with for range on rows an argument with the xlsx opened
|
||||
// file.
|
||||
func (xlsx *xlsxC) getValueFrom(f *File, d *xlsxSST) (string, error) {
|
||||
switch xlsx.T {
|
||||
case "s":
|
||||
@@ -315,9 +325,9 @@ func (f *File) SetRowOutlineLevel(sheet string, rowIndex int, level uint8) {
|
||||
xlsx.SheetData.Row[rowIndex].OutlineLevel = level
|
||||
}
|
||||
|
||||
// GetRowOutlineLevel provides a function to get outline level number of a single row by given
|
||||
// worksheet name and row index. For example, get outline number of row 2 in
|
||||
// Sheet1:
|
||||
// GetRowOutlineLevel provides a function to get outline level number of a
|
||||
// single row by given worksheet name and row index. For example, get outline
|
||||
// number of row 2 in Sheet1:
|
||||
//
|
||||
// xlsx.GetRowOutlineLevel("Sheet1", 2)
|
||||
//
|
||||
@@ -329,8 +339,8 @@ func (f *File) GetRowOutlineLevel(sheet string, rowIndex int) uint8 {
|
||||
return xlsx.SheetData.Row[rowIndex].OutlineLevel
|
||||
}
|
||||
|
||||
// RemoveRow provides function to remove single row by given worksheet name and
|
||||
// row index. For example, remove row 3 in Sheet1:
|
||||
// RemoveRow provides a function to remove single row by given worksheet name
|
||||
// and row index. For example, remove row 3 in Sheet1:
|
||||
//
|
||||
// xlsx.RemoveRow("Sheet1", 2)
|
||||
//
|
||||
@@ -349,8 +359,8 @@ func (f *File) RemoveRow(sheet string, row int) {
|
||||
}
|
||||
}
|
||||
|
||||
// InsertRow provides function to insert a new row before given row index. For
|
||||
// example, create a new row before row 3 in Sheet1:
|
||||
// InsertRow provides a function to insert a new row before given row index.
|
||||
// For example, create a new row before row 3 in Sheet1:
|
||||
//
|
||||
// xlsx.InsertRow("Sheet1", 2)
|
||||
//
|
||||
@@ -362,8 +372,8 @@ func (f *File) InsertRow(sheet string, row int) {
|
||||
f.adjustHelper(sheet, -1, row, 1)
|
||||
}
|
||||
|
||||
// checkRow provides function to check and fill each column element for all rows
|
||||
// and make that is continuous in a worksheet of XML. For example:
|
||||
// checkRow provides a function to check and fill each column element for all
|
||||
// rows and make that is continuous in a worksheet of XML. For example:
|
||||
//
|
||||
// <row r="15" spans="1:22" x14ac:dyDescent="0.2">
|
||||
// <c r="A15" s="2" />
|
||||
@@ -416,7 +426,7 @@ func checkRow(xlsx *xlsxWorksheet) {
|
||||
}
|
||||
}
|
||||
|
||||
// completeRow provides function to check and fill each column element for a
|
||||
// completeRow provides a function to check and fill each column element for a
|
||||
// single row and make that is continuous in a worksheet of XML by given row
|
||||
// index and axis.
|
||||
func completeRow(xlsx *xlsxWorksheet, row, cell int) {
|
||||
@@ -448,9 +458,9 @@ func completeRow(xlsx *xlsxWorksheet, row, cell int) {
|
||||
}
|
||||
}
|
||||
|
||||
// convertRowHeightToPixels provides function to convert the height of a cell
|
||||
// from user's units to pixels. If the height hasn't been set by the user we use
|
||||
// the default value. If the row is hidden it has a value of zero.
|
||||
// convertRowHeightToPixels provides a function to convert the height of a
|
||||
// cell from user's units to pixels. If the height hasn't been set by the user
|
||||
// we use the default value. If the row is hidden it has a value of zero.
|
||||
func convertRowHeightToPixels(height float64) float64 {
|
||||
var pixels float64
|
||||
if height == 0 {
|
||||
|
||||
33
vendor/github.com/360EntSecGroup-Skylar/excelize/shape.go
generated
vendored
33
vendor/github.com/360EntSecGroup-Skylar/excelize/shape.go
generated
vendored
@@ -1,3 +1,12 @@
|
||||
// Copyright 2016 - 2018 The excelize Authors. All rights reserved. Use of
|
||||
// this source code is governed by a BSD-style license that can be found in
|
||||
// the LICENSE file.
|
||||
//
|
||||
// Package excelize providing a set of functions that allow you to write to
|
||||
// and read from XLSX files. Support reads and writes XLSX file generated by
|
||||
// Microsoft Excel™ 2007 and later. Support save file without losing original
|
||||
// charts of XLSX. This library needs Go version 1.8 or later.
|
||||
|
||||
package excelize
|
||||
|
||||
import (
|
||||
@@ -7,9 +16,9 @@ import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
// parseFormatShapeSet provides function to parse the format settings of the
|
||||
// parseFormatShapeSet provides a function to parse the format settings of the
|
||||
// shape with default value.
|
||||
func parseFormatShapeSet(formatSet string) *formatShape {
|
||||
func parseFormatShapeSet(formatSet string) (*formatShape, error) {
|
||||
format := formatShape{
|
||||
Width: 160,
|
||||
Height: 160,
|
||||
@@ -23,14 +32,14 @@ func parseFormatShapeSet(formatSet string) *formatShape {
|
||||
YScale: 1.0,
|
||||
},
|
||||
}
|
||||
json.Unmarshal([]byte(formatSet), &format)
|
||||
return &format
|
||||
err := json.Unmarshal([]byte(formatSet), &format)
|
||||
return &format, err
|
||||
}
|
||||
|
||||
// AddShape provides the method to add shape in a sheet by given worksheet
|
||||
// index, shape format set (such as offset, scale, aspect ratio setting and
|
||||
// print settings) and properties set. For example, add text box (rect shape) in
|
||||
// Sheet1:
|
||||
// print settings) and properties set. For example, add text box (rect shape)
|
||||
// in Sheet1:
|
||||
//
|
||||
// xlsx.AddShape("Sheet1", "G6", `{"type":"rect","color":{"line":"#4286F4","fill":"#8eb9ff"},"paragraph":[{"text":"Rectangle Shape","font":{"bold":true,"italic":true,"family":"Berlin Sans FB Demi","size":36,"color":"#777777","underline":"sng"}}],"width":180,"height": 90}`)
|
||||
//
|
||||
@@ -245,8 +254,11 @@ func parseFormatShapeSet(formatSet string) *formatShape {
|
||||
// wavyHeavy
|
||||
// wavyDbl
|
||||
//
|
||||
func (f *File) AddShape(sheet, cell, format string) {
|
||||
formatSet := parseFormatShapeSet(format)
|
||||
func (f *File) AddShape(sheet, cell, format string) error {
|
||||
formatSet, err := parseFormatShapeSet(format)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
// Read sheet data.
|
||||
xlsx := f.workSheetReader(sheet)
|
||||
// Add first shape for given sheet, create xl/drawings/ and xl/drawings/_rels/ folder.
|
||||
@@ -266,9 +278,10 @@ func (f *File) AddShape(sheet, cell, format string) {
|
||||
}
|
||||
f.addDrawingShape(sheet, drawingXML, cell, formatSet)
|
||||
f.addContentTypePart(drawingID, "drawings")
|
||||
return err
|
||||
}
|
||||
|
||||
// addDrawingShape provides function to add preset geometry by given sheet,
|
||||
// addDrawingShape provides a function to add preset geometry by given sheet,
|
||||
// drawingXMLand format sets.
|
||||
func (f *File) addDrawingShape(sheet, drawingXML, cell string, formatSet *formatShape) {
|
||||
textUnderlineType := map[string]bool{"none": true, "words": true, "sng": true, "dbl": true, "heavy": true, "dotted": true, "dottedHeavy": true, "dash": true, "dashHeavy": true, "dashLong": true, "dashLongHeavy": true, "dotDash": true, "dotDashHeavy": true, "dotDotDash": true, "dotDotDashHeavy": true, "wavy": true, "wavyHeavy": true, "wavyDbl": true}
|
||||
@@ -393,7 +406,7 @@ func (f *File) addDrawingShape(sheet, drawingXML, cell string, formatSet *format
|
||||
f.saveFileList(drawingXML, output)
|
||||
}
|
||||
|
||||
// setShapeRef provides function to set color with hex model by given actual
|
||||
// setShapeRef provides a function to set color with hex model by given actual
|
||||
// color value.
|
||||
func setShapeRef(color string, i int) *aRef {
|
||||
if color == "" {
|
||||
|
||||
132
vendor/github.com/360EntSecGroup-Skylar/excelize/sheet.go
generated
vendored
132
vendor/github.com/360EntSecGroup-Skylar/excelize/sheet.go
generated
vendored
@@ -1,3 +1,12 @@
|
||||
// Copyright 2016 - 2018 The excelize Authors. All rights reserved. Use of
|
||||
// this source code is governed by a BSD-style license that can be found in
|
||||
// the LICENSE file.
|
||||
//
|
||||
// Package excelize providing a set of functions that allow you to write to
|
||||
// and read from XLSX files. Support reads and writes XLSX file generated by
|
||||
// Microsoft Excel™ 2007 and later. Support save file without losing original
|
||||
// charts of XLSX. This library needs Go version 1.8 or later.
|
||||
|
||||
package excelize
|
||||
|
||||
import (
|
||||
@@ -5,14 +14,17 @@ import (
|
||||
"encoding/json"
|
||||
"encoding/xml"
|
||||
"errors"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path"
|
||||
"strconv"
|
||||
"strings"
|
||||
"unicode/utf8"
|
||||
|
||||
"github.com/mohae/deepcopy"
|
||||
)
|
||||
|
||||
// NewSheet provides function to create a new sheet by given worksheet name,
|
||||
// NewSheet provides a function to create a new sheet by given worksheet name,
|
||||
// when creating a new XLSX file, the default sheet will be create, when you
|
||||
// create a new file.
|
||||
func (f *File) NewSheet(name string) int {
|
||||
@@ -34,18 +46,18 @@ func (f *File) NewSheet(name string) int {
|
||||
return f.SheetCount
|
||||
}
|
||||
|
||||
// contentTypesReader provides function to get the pointer to the
|
||||
// contentTypesReader provides a function to get the pointer to the
|
||||
// [Content_Types].xml structure after deserialization.
|
||||
func (f *File) contentTypesReader() *xlsxTypes {
|
||||
if f.ContentTypes == nil {
|
||||
var content xlsxTypes
|
||||
xml.Unmarshal([]byte(f.readXML("[Content_Types].xml")), &content)
|
||||
_ = xml.Unmarshal([]byte(f.readXML("[Content_Types].xml")), &content)
|
||||
f.ContentTypes = &content
|
||||
}
|
||||
return f.ContentTypes
|
||||
}
|
||||
|
||||
// contentTypesWriter provides function to save [Content_Types].xml after
|
||||
// contentTypesWriter provides a function to save [Content_Types].xml after
|
||||
// serialize structure.
|
||||
func (f *File) contentTypesWriter() {
|
||||
if f.ContentTypes != nil {
|
||||
@@ -54,18 +66,18 @@ func (f *File) contentTypesWriter() {
|
||||
}
|
||||
}
|
||||
|
||||
// workbookReader provides function to get the pointer to the xl/workbook.xml
|
||||
// workbookReader provides a function to get the pointer to the xl/workbook.xml
|
||||
// structure after deserialization.
|
||||
func (f *File) workbookReader() *xlsxWorkbook {
|
||||
if f.WorkBook == nil {
|
||||
var content xlsxWorkbook
|
||||
xml.Unmarshal([]byte(f.readXML("xl/workbook.xml")), &content)
|
||||
_ = xml.Unmarshal([]byte(f.readXML("xl/workbook.xml")), &content)
|
||||
f.WorkBook = &content
|
||||
}
|
||||
return f.WorkBook
|
||||
}
|
||||
|
||||
// workbookWriter provides function to save xl/workbook.xml after serialize
|
||||
// workbookWriter provides a function to save xl/workbook.xml after serialize
|
||||
// structure.
|
||||
func (f *File) workbookWriter() {
|
||||
if f.WorkBook != nil {
|
||||
@@ -74,7 +86,7 @@ func (f *File) workbookWriter() {
|
||||
}
|
||||
}
|
||||
|
||||
// worksheetWriter provides function to save xl/worksheets/sheet%d.xml after
|
||||
// worksheetWriter provides a function to save xl/worksheets/sheet%d.xml after
|
||||
// serialize structure.
|
||||
func (f *File) worksheetWriter() {
|
||||
for path, sheet := range f.Sheet {
|
||||
@@ -92,15 +104,17 @@ func (f *File) worksheetWriter() {
|
||||
}
|
||||
}
|
||||
|
||||
// trimCell provides function to trim blank cells which created by completeCol.
|
||||
// trimCell provides a function to trim blank cells which created by completeCol.
|
||||
func trimCell(column []xlsxC) []xlsxC {
|
||||
col := []xlsxC{}
|
||||
col := make([]xlsxC, len(column))
|
||||
i := 0
|
||||
for _, c := range column {
|
||||
if c.S != 0 || c.V != "" || c.F != nil || c.T != "" {
|
||||
col = append(col, c)
|
||||
col[i] = c
|
||||
i++
|
||||
}
|
||||
}
|
||||
return col
|
||||
return col[0:i]
|
||||
}
|
||||
|
||||
// Read and update property of contents type of XLSX.
|
||||
@@ -128,25 +142,33 @@ func (f *File) setSheet(index int, name string) {
|
||||
// allowed in sheet title.
|
||||
func (f *File) setWorkbook(name string, rid int) {
|
||||
content := f.workbookReader()
|
||||
rID := 0
|
||||
for _, v := range content.Sheets.Sheet {
|
||||
t, _ := strconv.Atoi(v.SheetID)
|
||||
if t > rID {
|
||||
rID = t
|
||||
}
|
||||
}
|
||||
rID++
|
||||
content.Sheets.Sheet = append(content.Sheets.Sheet, xlsxSheet{
|
||||
Name: trimSheetName(name),
|
||||
SheetID: strconv.Itoa(rid),
|
||||
SheetID: strconv.Itoa(rID),
|
||||
ID: "rId" + strconv.Itoa(rid),
|
||||
})
|
||||
}
|
||||
|
||||
// workbookRelsReader provides function to read and unmarshal workbook
|
||||
// workbookRelsReader provides a function to read and unmarshal workbook
|
||||
// relationships of XLSX file.
|
||||
func (f *File) workbookRelsReader() *xlsxWorkbookRels {
|
||||
if f.WorkBookRels == nil {
|
||||
var content xlsxWorkbookRels
|
||||
xml.Unmarshal([]byte(f.readXML("xl/_rels/workbook.xml.rels")), &content)
|
||||
_ = xml.Unmarshal([]byte(f.readXML("xl/_rels/workbook.xml.rels")), &content)
|
||||
f.WorkBookRels = &content
|
||||
}
|
||||
return f.WorkBookRels
|
||||
}
|
||||
|
||||
// workbookRelsWriter provides function to save xl/_rels/workbook.xml.rels after
|
||||
// workbookRelsWriter provides a function to save xl/_rels/workbook.xml.rels after
|
||||
// serialize structure.
|
||||
func (f *File) workbookRelsWriter() {
|
||||
if f.WorkBookRels != nil {
|
||||
@@ -193,19 +215,13 @@ func (f *File) setAppXML() {
|
||||
// library doesn't multiple namespace declarations in a single element of a
|
||||
// document. This function is a horrible hack to fix that after the XML
|
||||
// marshalling is completed.
|
||||
func replaceRelationshipsNameSpace(workbookMarshal string) string {
|
||||
oldXmlns := `<workbook xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main">`
|
||||
newXmlns := `<workbook xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="x15" xmlns:x15="http://schemas.microsoft.com/office/spreadsheetml/2010/11/main">`
|
||||
return strings.Replace(workbookMarshal, oldXmlns, newXmlns, -1)
|
||||
}
|
||||
|
||||
func replaceRelationshipsNameSpaceBytes(workbookMarshal []byte) []byte {
|
||||
oldXmlns := []byte(`<workbook xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main">`)
|
||||
newXmlns := []byte(`<workbook xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="x15" xmlns:x15="http://schemas.microsoft.com/office/spreadsheetml/2010/11/main">`)
|
||||
return bytes.Replace(workbookMarshal, oldXmlns, newXmlns, -1)
|
||||
}
|
||||
|
||||
// SetActiveSheet provides function to set default active worksheet of XLSX by
|
||||
// SetActiveSheet provides a function to set default active worksheet of XLSX by
|
||||
// given index. Note that active index is different with the index that got by
|
||||
// function GetSheetMap, and it should be greater than 0 and less than total
|
||||
// worksheet numbers.
|
||||
@@ -241,7 +257,7 @@ func (f *File) SetActiveSheet(index int) {
|
||||
}
|
||||
}
|
||||
|
||||
// GetActiveSheetIndex provides function to get active sheet of XLSX. If not
|
||||
// GetActiveSheetIndex provides a function to get active sheet of XLSX. If not
|
||||
// found the active sheet will be return integer 0.
|
||||
func (f *File) GetActiveSheetIndex() int {
|
||||
buffer := bytes.Buffer{}
|
||||
@@ -251,7 +267,7 @@ func (f *File) GetActiveSheetIndex() int {
|
||||
buffer.WriteString("xl/worksheets/sheet")
|
||||
buffer.WriteString(strings.TrimPrefix(v.ID, "rId"))
|
||||
buffer.WriteString(".xml")
|
||||
xml.Unmarshal([]byte(f.readXML(buffer.String())), &xlsx)
|
||||
_ = xml.Unmarshal([]byte(f.readXML(buffer.String())), &xlsx)
|
||||
for _, sheetView := range xlsx.SheetViews.SheetView {
|
||||
if sheetView.TabSelected {
|
||||
ID, _ := strconv.Atoi(strings.TrimPrefix(v.ID, "rId"))
|
||||
@@ -263,7 +279,7 @@ func (f *File) GetActiveSheetIndex() int {
|
||||
return 0
|
||||
}
|
||||
|
||||
// SetSheetName provides function to set the worksheet name be given old and new
|
||||
// SetSheetName provides a function to set the worksheet name be given old and new
|
||||
// worksheet name. Maximum 31 characters are allowed in sheet title and this
|
||||
// function only changes the name of the sheet and will not update the sheet
|
||||
// name in the formula or reference associated with the cell. So there may be
|
||||
@@ -281,7 +297,7 @@ func (f *File) SetSheetName(oldName, newName string) {
|
||||
}
|
||||
}
|
||||
|
||||
// GetSheetName provides function to get worksheet name of XLSX by given
|
||||
// GetSheetName provides a function to get worksheet name of XLSX by given
|
||||
// worksheet index. If given sheet index is invalid, will return an empty
|
||||
// string.
|
||||
func (f *File) GetSheetName(index int) string {
|
||||
@@ -300,7 +316,7 @@ func (f *File) GetSheetName(index int) string {
|
||||
return ""
|
||||
}
|
||||
|
||||
// GetSheetIndex provides function to get worksheet index of XLSX by given sheet
|
||||
// GetSheetIndex provides a function to get worksheet index of XLSX by given sheet
|
||||
// name. If given worksheet name is invalid, will return an integer type value
|
||||
// 0.
|
||||
func (f *File) GetSheetIndex(name string) int {
|
||||
@@ -319,7 +335,7 @@ func (f *File) GetSheetIndex(name string) int {
|
||||
return 0
|
||||
}
|
||||
|
||||
// GetSheetMap provides function to get worksheet name and index map of XLSX.
|
||||
// GetSheetMap provides a function to get worksheet name and index map of XLSX.
|
||||
// For example:
|
||||
//
|
||||
// xlsx, err := excelize.OpenFile("./Book1.xlsx")
|
||||
@@ -345,7 +361,7 @@ func (f *File) GetSheetMap() map[int]string {
|
||||
return sheetMap
|
||||
}
|
||||
|
||||
// getSheetMap provides function to get worksheet name and XML file path map of
|
||||
// getSheetMap provides a function to get worksheet name and XML file path map of
|
||||
// XLSX.
|
||||
func (f *File) getSheetMap() map[string]string {
|
||||
maps := make(map[string]string)
|
||||
@@ -355,8 +371,8 @@ func (f *File) getSheetMap() map[string]string {
|
||||
return maps
|
||||
}
|
||||
|
||||
// SetSheetBackground provides function to set background picture by given
|
||||
// worksheet name.
|
||||
// SetSheetBackground provides a function to set background picture by given
|
||||
// worksheet name and file path.
|
||||
func (f *File) SetSheetBackground(sheet, picture string) error {
|
||||
var err error
|
||||
// Check picture exists first.
|
||||
@@ -365,17 +381,18 @@ func (f *File) SetSheetBackground(sheet, picture string) error {
|
||||
}
|
||||
ext, ok := supportImageTypes[path.Ext(picture)]
|
||||
if !ok {
|
||||
return errors.New("Unsupported image extension")
|
||||
return errors.New("unsupported image extension")
|
||||
}
|
||||
pictureID := f.countMedia() + 1
|
||||
rID := f.addSheetRelationships(sheet, SourceRelationshipImage, "../media/image"+strconv.Itoa(pictureID)+ext, "")
|
||||
f.addSheetPicture(sheet, rID)
|
||||
f.addMedia(picture, ext)
|
||||
file, _ := ioutil.ReadFile(picture)
|
||||
f.addMedia(file, ext)
|
||||
f.setContentTypePartImageExtensions()
|
||||
return err
|
||||
}
|
||||
|
||||
// DeleteSheet provides function to delete worksheet in a workbook by given
|
||||
// DeleteSheet provides a function to delete worksheet in a workbook by given
|
||||
// worksheet name. Use this method with caution, which will affect changes in
|
||||
// references such as formulas, charts, and so on. If there is any referenced
|
||||
// value of the deleted worksheet, it will cause a file error when you open it.
|
||||
@@ -399,7 +416,7 @@ func (f *File) DeleteSheet(name string) {
|
||||
f.SetActiveSheet(len(f.GetSheetMap()))
|
||||
}
|
||||
|
||||
// deleteSheetFromWorkbookRels provides function to remove worksheet
|
||||
// deleteSheetFromWorkbookRels provides a function to remove worksheet
|
||||
// relationships by given relationships ID in the file
|
||||
// xl/_rels/workbook.xml.rels.
|
||||
func (f *File) deleteSheetFromWorkbookRels(rID string) string {
|
||||
@@ -413,7 +430,7 @@ func (f *File) deleteSheetFromWorkbookRels(rID string) string {
|
||||
return ""
|
||||
}
|
||||
|
||||
// deleteSheetFromContentTypes provides function to remove worksheet
|
||||
// deleteSheetFromContentTypes provides a function to remove worksheet
|
||||
// relationships by given target name in the file [Content_Types].xml.
|
||||
func (f *File) deleteSheetFromContentTypes(target string) {
|
||||
content := f.contentTypesReader()
|
||||
@@ -424,7 +441,7 @@ func (f *File) deleteSheetFromContentTypes(target string) {
|
||||
}
|
||||
}
|
||||
|
||||
// CopySheet provides function to duplicate a worksheet by gave source and
|
||||
// CopySheet provides a function to duplicate a worksheet by gave source and
|
||||
// target worksheet index. Note that currently doesn't support duplicate
|
||||
// workbooks that contain tables, charts or pictures. For Example:
|
||||
//
|
||||
@@ -435,18 +452,17 @@ func (f *File) deleteSheetFromContentTypes(target string) {
|
||||
//
|
||||
func (f *File) CopySheet(from, to int) error {
|
||||
if from < 1 || to < 1 || from == to || f.GetSheetName(from) == "" || f.GetSheetName(to) == "" {
|
||||
return errors.New("Invalid worksheet index")
|
||||
return errors.New("invalid worksheet index")
|
||||
}
|
||||
f.copySheet(from, to)
|
||||
return nil
|
||||
}
|
||||
|
||||
// copySheet provides function to duplicate a worksheet by gave source and
|
||||
// copySheet provides a function to duplicate a worksheet by gave source and
|
||||
// target worksheet name.
|
||||
func (f *File) copySheet(from, to int) {
|
||||
sheet := f.workSheetReader("sheet" + strconv.Itoa(from))
|
||||
worksheet := xlsxWorksheet{}
|
||||
deepCopy(&worksheet, &sheet)
|
||||
worksheet := deepcopy.Copy(sheet).(*xlsxWorksheet)
|
||||
path := "xl/worksheets/sheet" + strconv.Itoa(to) + ".xml"
|
||||
if len(worksheet.SheetViews.SheetView) > 0 {
|
||||
worksheet.SheetViews.SheetView[0].TabSelected = false
|
||||
@@ -454,7 +470,7 @@ func (f *File) copySheet(from, to int) {
|
||||
worksheet.Drawing = nil
|
||||
worksheet.TableParts = nil
|
||||
worksheet.PageSetUp = nil
|
||||
f.Sheet[path] = &worksheet
|
||||
f.Sheet[path] = worksheet
|
||||
toRels := "xl/worksheets/_rels/sheet" + strconv.Itoa(to) + ".xml.rels"
|
||||
fromRels := "xl/worksheets/_rels/sheet" + strconv.Itoa(from) + ".xml.rels"
|
||||
_, ok := f.XLSX[fromRels]
|
||||
@@ -463,7 +479,7 @@ func (f *File) copySheet(from, to int) {
|
||||
}
|
||||
}
|
||||
|
||||
// SetSheetVisible provides function to set worksheet visible by given worksheet
|
||||
// SetSheetVisible provides a function to set worksheet visible by given worksheet
|
||||
// name. A workbook must contain at least one visible worksheet. If the given
|
||||
// worksheet has been activated, this setting will be invalidated. Sheet state
|
||||
// values as defined by http://msdn.microsoft.com/en-us/library/office/documentformat.openxml.spreadsheet.sheetstatevalues.aspx
|
||||
@@ -505,14 +521,14 @@ func (f *File) SetSheetVisible(name string, visible bool) {
|
||||
}
|
||||
}
|
||||
|
||||
// parseFormatPanesSet provides function to parse the panes settings.
|
||||
func parseFormatPanesSet(formatSet string) *formatPanes {
|
||||
// parseFormatPanesSet provides a function to parse the panes settings.
|
||||
func parseFormatPanesSet(formatSet string) (*formatPanes, error) {
|
||||
format := formatPanes{}
|
||||
json.Unmarshal([]byte(formatSet), &format)
|
||||
return &format
|
||||
err := json.Unmarshal([]byte(formatSet), &format)
|
||||
return &format, err
|
||||
}
|
||||
|
||||
// SetPanes provides function to create and remove freeze panes and split panes
|
||||
// SetPanes provides a function to create and remove freeze panes and split panes
|
||||
// by given worksheet name and panes format set.
|
||||
//
|
||||
// activePane defines the pane that is active. The possible values for this
|
||||
@@ -598,7 +614,7 @@ func parseFormatPanesSet(formatSet string) *formatPanes {
|
||||
// xlsx.SetPanes("Sheet1", `{"freeze":false,"split":false}`)
|
||||
//
|
||||
func (f *File) SetPanes(sheet, panes string) {
|
||||
fs := parseFormatPanesSet(panes)
|
||||
fs, _ := parseFormatPanesSet(panes)
|
||||
xlsx := f.workSheetReader(sheet)
|
||||
p := &xlsxPane{
|
||||
ActivePane: fs.ActivePane,
|
||||
@@ -626,7 +642,7 @@ func (f *File) SetPanes(sheet, panes string) {
|
||||
xlsx.SheetViews.SheetView[len(xlsx.SheetViews.SheetView)-1].Selection = s
|
||||
}
|
||||
|
||||
// GetSheetVisible provides function to get worksheet visible by given worksheet
|
||||
// GetSheetVisible provides a function to get worksheet visible by given worksheet
|
||||
// name. For example, get visible state of Sheet1:
|
||||
//
|
||||
// xlsx.GetSheetVisible("Sheet1")
|
||||
@@ -644,11 +660,19 @@ func (f *File) GetSheetVisible(name string) bool {
|
||||
return visible
|
||||
}
|
||||
|
||||
// trimSheetName provides function to trim invaild characters by given worksheet
|
||||
// trimSheetName provides a function to trim invaild characters by given worksheet
|
||||
// name.
|
||||
func trimSheetName(name string) string {
|
||||
r := strings.NewReplacer(":", "", "\\", "", "/", "", "?", "", "*", "", "[", "", "]", "")
|
||||
name = r.Replace(name)
|
||||
r := []rune{}
|
||||
for _, v := range name {
|
||||
switch v {
|
||||
case 58, 92, 47, 63, 42, 91, 93: // replace :\/?*[]
|
||||
continue
|
||||
default:
|
||||
r = append(r, v)
|
||||
}
|
||||
}
|
||||
name = string(r)
|
||||
if utf8.RuneCountInString(name) > 31 {
|
||||
name = string([]rune(name)[0:31])
|
||||
}
|
||||
|
||||
13
vendor/github.com/360EntSecGroup-Skylar/excelize/sheetpr.go
generated
vendored
13
vendor/github.com/360EntSecGroup-Skylar/excelize/sheetpr.go
generated
vendored
@@ -1,3 +1,12 @@
|
||||
// Copyright 2016 - 2018 The excelize Authors. All rights reserved. Use of
|
||||
// this source code is governed by a BSD-style license that can be found in
|
||||
// the LICENSE file.
|
||||
//
|
||||
// Package excelize providing a set of functions that allow you to write to
|
||||
// and read from XLSX files. Support reads and writes XLSX file generated by
|
||||
// Microsoft Excel™ 2007 and later. Support save file without losing original
|
||||
// charts of XLSX. This library needs Go version 1.8 or later.
|
||||
|
||||
package excelize
|
||||
|
||||
// SheetPrOption is an option of a view of a worksheet. See SetSheetPrOptions().
|
||||
@@ -98,7 +107,7 @@ func (o *AutoPageBreaks) getSheetPrOption(pr *xlsxSheetPr) {
|
||||
*o = AutoPageBreaks(pr.PageSetUpPr.AutoPageBreaks)
|
||||
}
|
||||
|
||||
// SetSheetPrOptions provides function to sets worksheet properties.
|
||||
// SetSheetPrOptions provides a function to sets worksheet properties.
|
||||
//
|
||||
// Available options:
|
||||
// CodeName(string)
|
||||
@@ -120,7 +129,7 @@ func (f *File) SetSheetPrOptions(name string, opts ...SheetPrOption) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetSheetPrOptions provides function to gets worksheet properties.
|
||||
// GetSheetPrOptions provides a function to gets worksheet properties.
|
||||
//
|
||||
// Available options:
|
||||
// CodeName(string)
|
||||
|
||||
9
vendor/github.com/360EntSecGroup-Skylar/excelize/sheetview.go
generated
vendored
9
vendor/github.com/360EntSecGroup-Skylar/excelize/sheetview.go
generated
vendored
@@ -1,3 +1,12 @@
|
||||
// Copyright 2016 - 2018 The excelize Authors. All rights reserved. Use of
|
||||
// this source code is governed by a BSD-style license that can be found in
|
||||
// the LICENSE file.
|
||||
//
|
||||
// Package excelize providing a set of functions that allow you to write to
|
||||
// and read from XLSX files. Support reads and writes XLSX file generated by
|
||||
// Microsoft Excel™ 2007 and later. Support save file without losing original
|
||||
// charts of XLSX. This library needs Go version 1.8 or later.
|
||||
|
||||
package excelize
|
||||
|
||||
import "fmt"
|
||||
|
||||
276
vendor/github.com/360EntSecGroup-Skylar/excelize/styles.go
generated
vendored
276
vendor/github.com/360EntSecGroup-Skylar/excelize/styles.go
generated
vendored
@@ -1,3 +1,12 @@
|
||||
// Copyright 2016 - 2018 The excelize Authors. All rights reserved. Use of
|
||||
// this source code is governed by a BSD-style license that can be found in
|
||||
// the LICENSE file.
|
||||
//
|
||||
// Package excelize providing a set of functions that allow you to write to
|
||||
// and read from XLSX files. Support reads and writes XLSX file generated by
|
||||
// Microsoft Excel™ 2007 and later. Support save file without losing original
|
||||
// charts of XLSX. This library needs Go version 1.8 or later.
|
||||
|
||||
package excelize
|
||||
|
||||
import (
|
||||
@@ -10,8 +19,8 @@ import (
|
||||
)
|
||||
|
||||
// Excel styles can reference number formats that are built-in, all of which
|
||||
// have an id less than 164. This is a possibly incomplete list comprised of as
|
||||
// many of them as I could find.
|
||||
// have an id less than 164. This is a possibly incomplete list comprised of
|
||||
// as many of them as I could find.
|
||||
var builtInNumFmt = map[int]string{
|
||||
0: "general",
|
||||
1: "0",
|
||||
@@ -798,45 +807,46 @@ var validType = map[string]string{
|
||||
|
||||
// criteriaType defined the list of valid criteria types.
|
||||
var criteriaType = map[string]string{
|
||||
"between": "between",
|
||||
"not between": "notBetween",
|
||||
"equal to": "equal",
|
||||
"=": "equal",
|
||||
"==": "equal",
|
||||
"not equal to": "notEqual",
|
||||
"!=": "notEqual",
|
||||
"<>": "notEqual",
|
||||
"greater than": "greaterThan",
|
||||
">": "greaterThan",
|
||||
"less than": "lessThan",
|
||||
"<": "lessThan",
|
||||
"between": "between",
|
||||
"not between": "notBetween",
|
||||
"equal to": "equal",
|
||||
"=": "equal",
|
||||
"==": "equal",
|
||||
"not equal to": "notEqual",
|
||||
"!=": "notEqual",
|
||||
"<>": "notEqual",
|
||||
"greater than": "greaterThan",
|
||||
">": "greaterThan",
|
||||
"less than": "lessThan",
|
||||
"<": "lessThan",
|
||||
"greater than or equal to": "greaterThanOrEqual",
|
||||
">=": "greaterThanOrEqual",
|
||||
"less than or equal to": "lessThanOrEqual",
|
||||
"<=": "lessThanOrEqual",
|
||||
"containing": "containsText",
|
||||
"not containing": "notContains",
|
||||
"begins with": "beginsWith",
|
||||
"ends with": "endsWith",
|
||||
"yesterday": "yesterday",
|
||||
"today": "today",
|
||||
"last 7 days": "last7Days",
|
||||
"last week": "lastWeek",
|
||||
"this week": "thisWeek",
|
||||
"continue week": "continueWeek",
|
||||
"last month": "lastMonth",
|
||||
"this month": "thisMonth",
|
||||
"continue month": "continueMonth",
|
||||
">=": "greaterThanOrEqual",
|
||||
"less than or equal to": "lessThanOrEqual",
|
||||
"<=": "lessThanOrEqual",
|
||||
"containing": "containsText",
|
||||
"not containing": "notContains",
|
||||
"begins with": "beginsWith",
|
||||
"ends with": "endsWith",
|
||||
"yesterday": "yesterday",
|
||||
"today": "today",
|
||||
"last 7 days": "last7Days",
|
||||
"last week": "lastWeek",
|
||||
"this week": "thisWeek",
|
||||
"continue week": "continueWeek",
|
||||
"last month": "lastMonth",
|
||||
"this month": "thisMonth",
|
||||
"continue month": "continueMonth",
|
||||
}
|
||||
|
||||
// formatToString provides function to return original string by given built-in
|
||||
// number formats code and cell string.
|
||||
// formatToString provides a function to return original string by given
|
||||
// built-in number formats code and cell string.
|
||||
func formatToString(i int, v string) string {
|
||||
return v
|
||||
}
|
||||
|
||||
// formatToInt provides function to convert original string to integer format as
|
||||
// string type by given built-in number formats code and cell string.
|
||||
// formatToInt provides a function to convert original string to integer
|
||||
// format as string type by given built-in number formats code and cell
|
||||
// string.
|
||||
func formatToInt(i int, v string) string {
|
||||
f, err := strconv.ParseFloat(v, 64)
|
||||
if err != nil {
|
||||
@@ -845,8 +855,9 @@ func formatToInt(i int, v string) string {
|
||||
return fmt.Sprintf("%d", int(f))
|
||||
}
|
||||
|
||||
// formatToFloat provides function to convert original string to float format as
|
||||
// string type by given built-in number formats code and cell string.
|
||||
// formatToFloat provides a function to convert original string to float
|
||||
// format as string type by given built-in number formats code and cell
|
||||
// string.
|
||||
func formatToFloat(i int, v string) string {
|
||||
f, err := strconv.ParseFloat(v, 64)
|
||||
if err != nil {
|
||||
@@ -855,8 +866,8 @@ func formatToFloat(i int, v string) string {
|
||||
return fmt.Sprintf("%.2f", f)
|
||||
}
|
||||
|
||||
// formatToA provides function to convert original string to special format as
|
||||
// string type by given built-in number formats code and cell string.
|
||||
// formatToA provides a function to convert original string to special format
|
||||
// as string type by given built-in number formats code and cell string.
|
||||
func formatToA(i int, v string) string {
|
||||
f, err := strconv.ParseFloat(v, 64)
|
||||
if err != nil {
|
||||
@@ -870,8 +881,8 @@ func formatToA(i int, v string) string {
|
||||
return fmt.Sprintf("%d", t)
|
||||
}
|
||||
|
||||
// formatToB provides function to convert original string to special format as
|
||||
// string type by given built-in number formats code and cell string.
|
||||
// formatToB provides a function to convert original string to special format
|
||||
// as string type by given built-in number formats code and cell string.
|
||||
func formatToB(i int, v string) string {
|
||||
f, err := strconv.ParseFloat(v, 64)
|
||||
if err != nil {
|
||||
@@ -883,8 +894,8 @@ func formatToB(i int, v string) string {
|
||||
return fmt.Sprintf("%.2f", f)
|
||||
}
|
||||
|
||||
// formatToC provides function to convert original string to special format as
|
||||
// string type by given built-in number formats code and cell string.
|
||||
// formatToC provides a function to convert original string to special format
|
||||
// as string type by given built-in number formats code and cell string.
|
||||
func formatToC(i int, v string) string {
|
||||
f, err := strconv.ParseFloat(v, 64)
|
||||
if err != nil {
|
||||
@@ -894,8 +905,8 @@ func formatToC(i int, v string) string {
|
||||
return fmt.Sprintf("%d%%", int(f))
|
||||
}
|
||||
|
||||
// formatToD provides function to convert original string to special format as
|
||||
// string type by given built-in number formats code and cell string.
|
||||
// formatToD provides a function to convert original string to special format
|
||||
// as string type by given built-in number formats code and cell string.
|
||||
func formatToD(i int, v string) string {
|
||||
f, err := strconv.ParseFloat(v, 64)
|
||||
if err != nil {
|
||||
@@ -905,8 +916,8 @@ func formatToD(i int, v string) string {
|
||||
return fmt.Sprintf("%.2f%%", f)
|
||||
}
|
||||
|
||||
// formatToE provides function to convert original string to special format as
|
||||
// string type by given built-in number formats code and cell string.
|
||||
// formatToE provides a function to convert original string to special format
|
||||
// as string type by given built-in number formats code and cell string.
|
||||
func formatToE(i int, v string) string {
|
||||
f, err := strconv.ParseFloat(v, 64)
|
||||
if err != nil {
|
||||
@@ -915,17 +926,17 @@ func formatToE(i int, v string) string {
|
||||
return fmt.Sprintf("%.e", f)
|
||||
}
|
||||
|
||||
// parseTime provides function to returns a string parsed using time.Time.
|
||||
// parseTime provides a function to returns a string parsed using time.Time.
|
||||
// Replace Excel placeholders with Go time placeholders. For example, replace
|
||||
// yyyy with 2006. These are in a specific order, due to the fact that m is used
|
||||
// in month, minute, and am/pm. It would be easier to fix that with regular
|
||||
// expressions, but if it's possible to keep this simple it would be easier to
|
||||
// maintain. Full-length month and days (e.g. March, Tuesday) have letters in
|
||||
// them that would be replaced by other characters below (such as the 'h' in
|
||||
// March, or the 'd' in Tuesday) below. First we convert them to arbitrary
|
||||
// characters unused in Excel Date formats, and then at the end, turn them to
|
||||
// what they should actually be.
|
||||
// Based off: http://www.ozgrid.com/Excel/CustomFormats.htm
|
||||
// yyyy with 2006. These are in a specific order, due to the fact that m is
|
||||
// used in month, minute, and am/pm. It would be easier to fix that with
|
||||
// regular expressions, but if it's possible to keep this simple it would be
|
||||
// easier to maintain. Full-length month and days (e.g. March, Tuesday) have
|
||||
// letters in them that would be replaced by other characters below (such as
|
||||
// the 'h' in March, or the 'd' in Tuesday) below. First we convert them to
|
||||
// arbitrary characters unused in Excel Date formats, and then at the end,
|
||||
// turn them to what they should actually be. Based off:
|
||||
// http://www.ozgrid.com/Excel/CustomFormats.htm
|
||||
func parseTime(i int, v string) string {
|
||||
f, err := strconv.ParseFloat(v, 64)
|
||||
if err != nil {
|
||||
@@ -983,18 +994,18 @@ func is12HourTime(format string) bool {
|
||||
return strings.Contains(format, "am/pm") || strings.Contains(format, "AM/PM") || strings.Contains(format, "a/p") || strings.Contains(format, "A/P")
|
||||
}
|
||||
|
||||
// stylesReader provides function to get the pointer to the structure after
|
||||
// stylesReader provides a function to get the pointer to the structure after
|
||||
// deserialization of xl/styles.xml.
|
||||
func (f *File) stylesReader() *xlsxStyleSheet {
|
||||
if f.Styles == nil {
|
||||
var styleSheet xlsxStyleSheet
|
||||
xml.Unmarshal([]byte(f.readXML("xl/styles.xml")), &styleSheet)
|
||||
_ = xml.Unmarshal([]byte(f.readXML("xl/styles.xml")), &styleSheet)
|
||||
f.Styles = &styleSheet
|
||||
}
|
||||
return f.Styles
|
||||
}
|
||||
|
||||
// styleSheetWriter provides function to save xl/styles.xml after serialize
|
||||
// styleSheetWriter provides a function to save xl/styles.xml after serialize
|
||||
// structure.
|
||||
func (f *File) styleSheetWriter() {
|
||||
if f.Styles != nil {
|
||||
@@ -1003,7 +1014,7 @@ func (f *File) styleSheetWriter() {
|
||||
}
|
||||
}
|
||||
|
||||
// parseFormatStyleSet provides function to parse the format settings of the
|
||||
// parseFormatStyleSet provides a function to parse the format settings of the
|
||||
// cells and conditional formats.
|
||||
func parseFormatStyleSet(style string) (*formatStyle, error) {
|
||||
format := formatStyle{
|
||||
@@ -1013,8 +1024,8 @@ func parseFormatStyleSet(style string) (*formatStyle, error) {
|
||||
return &format, err
|
||||
}
|
||||
|
||||
// NewStyle provides function to create style for cells by given style format.
|
||||
// Note that the color field uses RGB color code.
|
||||
// NewStyle provides a function to create style for cells by given style
|
||||
// format. Note that the color field uses RGB color code.
|
||||
//
|
||||
// The following shows the border styles sorted by excelize index number:
|
||||
//
|
||||
@@ -1404,7 +1415,7 @@ func parseFormatStyleSet(style string) (*formatStyle, error) {
|
||||
// 173 | $ English (New Zealand)
|
||||
// 174 | $ English (Singapore)
|
||||
// 175 | $ English (Trinidad & Tobago)
|
||||
// 176 | $ English (U.S. Vigin Islands)
|
||||
// 176 | $ English (U.S. Virgin Islands)
|
||||
// 177 | $ English (United States)
|
||||
// 178 | $ French (Canada)
|
||||
// 179 | $ Hawaiian (United States)
|
||||
@@ -1906,10 +1917,10 @@ func (f *File) NewStyle(style string) (int, error) {
|
||||
return cellXfsID, nil
|
||||
}
|
||||
|
||||
// NewConditionalStyle provides function to create style for conditional format
|
||||
// by given style format. The parameters are the same as function NewStyle().
|
||||
// Note that the color field uses RGB color code and only support to set font,
|
||||
// fills, alignment and borders currently.
|
||||
// NewConditionalStyle provides a function to create style for conditional
|
||||
// format by given style format. The parameters are the same as function
|
||||
// NewStyle(). Note that the color field uses RGB color code and only support
|
||||
// to set font, fills, alignment and borders currently.
|
||||
func (f *File) NewConditionalStyle(style string) (int, error) {
|
||||
s := f.stylesReader()
|
||||
fs, err := parseFormatStyleSet(style)
|
||||
@@ -1935,7 +1946,8 @@ func (f *File) NewConditionalStyle(style string) (int, error) {
|
||||
return s.Dxfs.Count - 1, nil
|
||||
}
|
||||
|
||||
// setFont provides function to add font style by given cell format settings.
|
||||
// setFont provides a function to add font style by given cell format
|
||||
// settings.
|
||||
func setFont(formatStyle *formatStyle) *font {
|
||||
fontUnderlineType := map[string]string{"single": "single", "double": "double"}
|
||||
if formatStyle.Font.Size < 1 {
|
||||
@@ -1963,8 +1975,8 @@ func setFont(formatStyle *formatStyle) *font {
|
||||
return &f
|
||||
}
|
||||
|
||||
// setNumFmt provides function to check if number format code in the range of
|
||||
// built-in values.
|
||||
// setNumFmt provides a function to check if number format code in the range
|
||||
// of built-in values.
|
||||
func setNumFmt(style *xlsxStyleSheet, formatStyle *formatStyle) int {
|
||||
dp := "0."
|
||||
numFmtID := 164 // Default custom number format code from 164.
|
||||
@@ -2011,7 +2023,7 @@ func setNumFmt(style *xlsxStyleSheet, formatStyle *formatStyle) int {
|
||||
return formatStyle.NumFmt
|
||||
}
|
||||
|
||||
// setCustomNumFmt provides function to set custom number format code.
|
||||
// setCustomNumFmt provides a function to set custom number format code.
|
||||
func setCustomNumFmt(style *xlsxStyleSheet, formatStyle *formatStyle) int {
|
||||
nf := xlsxNumFmt{FormatCode: *formatStyle.CustomNumFmt}
|
||||
if style.NumFmts != nil {
|
||||
@@ -2029,7 +2041,7 @@ func setCustomNumFmt(style *xlsxStyleSheet, formatStyle *formatStyle) int {
|
||||
return nf.NumFmtID
|
||||
}
|
||||
|
||||
// setLangNumFmt provides function to set number format code with language.
|
||||
// setLangNumFmt provides a function to set number format code with language.
|
||||
func setLangNumFmt(style *xlsxStyleSheet, formatStyle *formatStyle) int {
|
||||
numFmts, ok := langNumFmt[formatStyle.Lang]
|
||||
if !ok {
|
||||
@@ -2056,8 +2068,8 @@ func setLangNumFmt(style *xlsxStyleSheet, formatStyle *formatStyle) int {
|
||||
return nf.NumFmtID
|
||||
}
|
||||
|
||||
// setFills provides function to add fill elements in the styles.xml by given
|
||||
// cell format settings.
|
||||
// setFills provides a function to add fill elements in the styles.xml by
|
||||
// given cell format settings.
|
||||
func setFills(formatStyle *formatStyle, fg bool) *xlsxFill {
|
||||
var patterns = []string{
|
||||
"none",
|
||||
@@ -2137,9 +2149,10 @@ func setFills(formatStyle *formatStyle, fg bool) *xlsxFill {
|
||||
return &fill
|
||||
}
|
||||
|
||||
// setAlignment provides function to formatting information pertaining to text
|
||||
// alignment in cells. There are a variety of choices for how text is aligned
|
||||
// both horizontally and vertically, as well as indentation settings, and so on.
|
||||
// setAlignment provides a function to formatting information pertaining to
|
||||
// text alignment in cells. There are a variety of choices for how text is
|
||||
// aligned both horizontally and vertically, as well as indentation settings,
|
||||
// and so on.
|
||||
func setAlignment(formatStyle *formatStyle) *xlsxAlignment {
|
||||
var alignment xlsxAlignment
|
||||
if formatStyle.Alignment != nil {
|
||||
@@ -2156,7 +2169,7 @@ func setAlignment(formatStyle *formatStyle) *xlsxAlignment {
|
||||
return &alignment
|
||||
}
|
||||
|
||||
// setProtection provides function to set protection properties associated
|
||||
// setProtection provides a function to set protection properties associated
|
||||
// with the cell.
|
||||
func setProtection(formatStyle *formatStyle) *xlsxProtection {
|
||||
var protection xlsxProtection
|
||||
@@ -2167,7 +2180,7 @@ func setProtection(formatStyle *formatStyle) *xlsxProtection {
|
||||
return &protection
|
||||
}
|
||||
|
||||
// setBorders provides function to add border elements in the styles.xml by
|
||||
// setBorders provides a function to add border elements in the styles.xml by
|
||||
// given borders format settings.
|
||||
func setBorders(formatStyle *formatStyle) *xlsxBorder {
|
||||
var styles = []string{
|
||||
@@ -2219,7 +2232,7 @@ func setBorders(formatStyle *formatStyle) *xlsxBorder {
|
||||
return &border
|
||||
}
|
||||
|
||||
// setCellXfs provides function to set describes all of the formatting for a
|
||||
// setCellXfs provides a function to set describes all of the formatting for a
|
||||
// cell.
|
||||
func setCellXfs(style *xlsxStyleSheet, fontID, numFmtID, fillID, borderID int, applyAlignment, applyProtection bool, alignment *xlsxAlignment, protection *xlsxProtection) int {
|
||||
var xf xlsxXf
|
||||
@@ -2246,9 +2259,10 @@ func setCellXfs(style *xlsxStyleSheet, fontID, numFmtID, fillID, borderID int, a
|
||||
return style.CellXfs.Count - 1
|
||||
}
|
||||
|
||||
// SetCellStyle provides function to add style attribute for cells by given
|
||||
// SetCellStyle provides a function to add style attribute for cells by given
|
||||
// worksheet name, coordinate area and style ID. Note that diagonalDown and
|
||||
// diagonalUp type border should be use same color in the same coordinate area.
|
||||
// diagonalUp type border should be use same color in the same coordinate
|
||||
// area.
|
||||
//
|
||||
// For example create a borders of cell H9 on Sheet1:
|
||||
//
|
||||
@@ -2352,9 +2366,10 @@ func (f *File) SetCellStyle(sheet, hcell, vcell string, styleID int) {
|
||||
}
|
||||
}
|
||||
|
||||
// SetConditionalFormat provides function to create conditional formatting rule
|
||||
// for cell value. Conditional formatting is a feature of Excel which allows you
|
||||
// to apply a format to a cell or a range of cells based on certain criteria.
|
||||
// SetConditionalFormat provides a function to create conditional formatting
|
||||
// rule for cell value. Conditional formatting is a feature of Excel which
|
||||
// allows you to apply a format to a cell or a range of cells based on certain
|
||||
// criteria.
|
||||
//
|
||||
// The type option is a required parameter and it has no default value.
|
||||
// Allowable type values and their associated parameters are:
|
||||
@@ -2407,7 +2422,7 @@ func (f *File) SetCellStyle(sheet, hcell, vcell string, styleID int) {
|
||||
//
|
||||
// The criteria parameter is used to set the criteria by which the cell data
|
||||
// will be evaluated. It has no default value. The most common criteria as
|
||||
// applied to {'type': 'cell'} are:
|
||||
// applied to {"type":"cell"} are:
|
||||
//
|
||||
// between |
|
||||
// not between |
|
||||
@@ -2562,10 +2577,12 @@ func (f *File) SetCellStyle(sheet, hcell, vcell string, styleID int) {
|
||||
//
|
||||
// bar_color - Used for data_bar. Same as min_color, see above.
|
||||
//
|
||||
func (f *File) SetConditionalFormat(sheet, area, formatSet string) {
|
||||
func (f *File) SetConditionalFormat(sheet, area, formatSet string) error {
|
||||
var format []*formatConditional
|
||||
json.Unmarshal([]byte(formatSet), &format)
|
||||
|
||||
err := json.Unmarshal([]byte(formatSet), &format)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
drawContFmtFunc := map[string]func(p int, ct string, fmtCond *formatConditional) *xlsxCfRule{
|
||||
"cellIs": drawCondFmtCellIs,
|
||||
"top10": drawCondFmtTop10,
|
||||
@@ -2601,11 +2618,12 @@ func (f *File) SetConditionalFormat(sheet, area, formatSet string) {
|
||||
SQRef: area,
|
||||
CfRule: cfRule,
|
||||
})
|
||||
return err
|
||||
}
|
||||
|
||||
// drawCondFmtCellIs provides function to create conditional formatting rule for
|
||||
// cell value (include between, not between, equal, not equal, greater than and
|
||||
// less than) by given priority, criteria type and format settings.
|
||||
// drawCondFmtCellIs provides a function to create conditional formatting rule
|
||||
// for cell value (include between, not between, equal, not equal, greater
|
||||
// than and less than) by given priority, criteria type and format settings.
|
||||
func drawCondFmtCellIs(p int, ct string, format *formatConditional) *xlsxCfRule {
|
||||
c := &xlsxCfRule{
|
||||
Priority: p + 1,
|
||||
@@ -2626,8 +2644,8 @@ func drawCondFmtCellIs(p int, ct string, format *formatConditional) *xlsxCfRule
|
||||
return c
|
||||
}
|
||||
|
||||
// drawCondFmtTop10 provides function to create conditional formatting rule for
|
||||
// top N (default is top 10) by given priority, criteria type and format
|
||||
// drawCondFmtTop10 provides a function to create conditional formatting rule
|
||||
// for top N (default is top 10) by given priority, criteria type and format
|
||||
// settings.
|
||||
func drawCondFmtTop10(p int, ct string, format *formatConditional) *xlsxCfRule {
|
||||
c := &xlsxCfRule{
|
||||
@@ -2644,9 +2662,9 @@ func drawCondFmtTop10(p int, ct string, format *formatConditional) *xlsxCfRule {
|
||||
return c
|
||||
}
|
||||
|
||||
// drawCondFmtAboveAverage provides function to create conditional formatting
|
||||
// rule for above average and below average by given priority, criteria type and
|
||||
// format settings.
|
||||
// drawCondFmtAboveAverage provides a function to create conditional
|
||||
// formatting rule for above average and below average by given priority,
|
||||
// criteria type and format settings.
|
||||
func drawCondFmtAboveAverage(p int, ct string, format *formatConditional) *xlsxCfRule {
|
||||
return &xlsxCfRule{
|
||||
Priority: p + 1,
|
||||
@@ -2656,7 +2674,7 @@ func drawCondFmtAboveAverage(p int, ct string, format *formatConditional) *xlsxC
|
||||
}
|
||||
}
|
||||
|
||||
// drawCondFmtDuplicateUniqueValues provides function to create conditional
|
||||
// drawCondFmtDuplicateUniqueValues provides a function to create conditional
|
||||
// formatting rule for duplicate and unique values by given priority, criteria
|
||||
// type and format settings.
|
||||
func drawCondFmtDuplicateUniqueValues(p int, ct string, format *formatConditional) *xlsxCfRule {
|
||||
@@ -2667,16 +2685,29 @@ func drawCondFmtDuplicateUniqueValues(p int, ct string, format *formatConditiona
|
||||
}
|
||||
}
|
||||
|
||||
// drawCondFmtColorScale provides function to create conditional formatting rule
|
||||
// for color scale (include 2 color scale and 3 color scale) by given priority,
|
||||
// criteria type and format settings.
|
||||
// drawCondFmtColorScale provides a function to create conditional formatting
|
||||
// rule for color scale (include 2 color scale and 3 color scale) by given
|
||||
// priority, criteria type and format settings.
|
||||
func drawCondFmtColorScale(p int, ct string, format *formatConditional) *xlsxCfRule {
|
||||
minValue := format.MinValue
|
||||
if minValue == "" {
|
||||
minValue = "0"
|
||||
}
|
||||
maxValue := format.MaxValue
|
||||
if maxValue == "" {
|
||||
maxValue = "0"
|
||||
}
|
||||
midValue := format.MidValue
|
||||
if midValue == "" {
|
||||
midValue = "50"
|
||||
}
|
||||
|
||||
c := &xlsxCfRule{
|
||||
Priority: p + 1,
|
||||
Type: "colorScale",
|
||||
ColorScale: &xlsxColorScale{
|
||||
Cfvo: []*xlsxCfvo{
|
||||
{Type: format.MinType},
|
||||
{Type: format.MinType, Val: minValue},
|
||||
},
|
||||
Color: []*xlsxColor{
|
||||
{RGB: getPaletteColor(format.MinColor)},
|
||||
@@ -2684,16 +2715,16 @@ func drawCondFmtColorScale(p int, ct string, format *formatConditional) *xlsxCfR
|
||||
},
|
||||
}
|
||||
if validType[format.Type] == "3_color_scale" {
|
||||
c.ColorScale.Cfvo = append(c.ColorScale.Cfvo, &xlsxCfvo{Type: format.MidType, Val: 50})
|
||||
c.ColorScale.Cfvo = append(c.ColorScale.Cfvo, &xlsxCfvo{Type: format.MidType, Val: midValue})
|
||||
c.ColorScale.Color = append(c.ColorScale.Color, &xlsxColor{RGB: getPaletteColor(format.MidColor)})
|
||||
}
|
||||
c.ColorScale.Cfvo = append(c.ColorScale.Cfvo, &xlsxCfvo{Type: format.MaxType})
|
||||
c.ColorScale.Cfvo = append(c.ColorScale.Cfvo, &xlsxCfvo{Type: format.MaxType, Val: maxValue})
|
||||
c.ColorScale.Color = append(c.ColorScale.Color, &xlsxColor{RGB: getPaletteColor(format.MaxColor)})
|
||||
return c
|
||||
}
|
||||
|
||||
// drawCondFmtDataBar provides function to create conditional formatting rule
|
||||
// for data bar by given priority, criteria type and format settings.
|
||||
// drawCondFmtDataBar provides a function to create conditional formatting
|
||||
// rule for data bar by given priority, criteria type and format settings.
|
||||
func drawCondFmtDataBar(p int, ct string, format *formatConditional) *xlsxCfRule {
|
||||
return &xlsxCfRule{
|
||||
Priority: p + 1,
|
||||
@@ -2705,8 +2736,8 @@ func drawCondFmtDataBar(p int, ct string, format *formatConditional) *xlsxCfRule
|
||||
}
|
||||
}
|
||||
|
||||
// drawConfFmtExp provides function to create conditional formatting rule for
|
||||
// expression by given priority, criteria type and format settings.
|
||||
// drawConfFmtExp provides a function to create conditional formatting rule
|
||||
// for expression by given priority, criteria type and format settings.
|
||||
func drawConfFmtExp(p int, ct string, format *formatConditional) *xlsxCfRule {
|
||||
return &xlsxCfRule{
|
||||
Priority: p + 1,
|
||||
@@ -2716,7 +2747,34 @@ func drawConfFmtExp(p int, ct string, format *formatConditional) *xlsxCfRule {
|
||||
}
|
||||
}
|
||||
|
||||
// getPaletteColor provides function to convert the RBG color by given string.
|
||||
// getPaletteColor provides a function to convert the RBG color by given
|
||||
// string.
|
||||
func getPaletteColor(color string) string {
|
||||
return "FF" + strings.Replace(strings.ToUpper(color), "#", "", -1)
|
||||
}
|
||||
|
||||
// themeReader provides a function to get the pointer to the xl/theme/theme1.xml
|
||||
// structure after deserialization.
|
||||
func (f *File) themeReader() *xlsxTheme {
|
||||
var theme xlsxTheme
|
||||
_ = xml.Unmarshal([]byte(f.readXML("xl/theme/theme1.xml")), &theme)
|
||||
return &theme
|
||||
}
|
||||
|
||||
// ThemeColor applied the color with tint value.
|
||||
func ThemeColor(baseColor string, tint float64) string {
|
||||
if tint == 0 {
|
||||
return "FF" + baseColor
|
||||
}
|
||||
r, _ := strconv.ParseInt(baseColor[0:2], 16, 64)
|
||||
g, _ := strconv.ParseInt(baseColor[2:4], 16, 64)
|
||||
b, _ := strconv.ParseInt(baseColor[4:6], 16, 64)
|
||||
h, s, l := RGBToHSL(uint8(r), uint8(g), uint8(b))
|
||||
if tint < 0 {
|
||||
l *= (1 + tint)
|
||||
} else {
|
||||
l = l*(1-tint) + (1 - (1 - tint))
|
||||
}
|
||||
br, bg, bb := HSLToRGB(h, s, l)
|
||||
return fmt.Sprintf("FF%02X%02X%02X", br, bg, bb)
|
||||
}
|
||||
|
||||
72
vendor/github.com/360EntSecGroup-Skylar/excelize/table.go
generated
vendored
72
vendor/github.com/360EntSecGroup-Skylar/excelize/table.go
generated
vendored
@@ -1,3 +1,12 @@
|
||||
// Copyright 2016 - 2018 The excelize Authors. All rights reserved. Use of
|
||||
// this source code is governed by a BSD-style license that can be found in
|
||||
// the LICENSE file.
|
||||
//
|
||||
// Package excelize providing a set of functions that allow you to write to
|
||||
// and read from XLSX files. Support reads and writes XLSX file generated by
|
||||
// Microsoft Excel™ 2007 and later. Support save file without losing original
|
||||
// charts of XLSX. This library needs Go version 1.8 or later.
|
||||
|
||||
package excelize
|
||||
|
||||
import (
|
||||
@@ -9,15 +18,15 @@ import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
// parseFormatTableSet provides function to parse the format settings of the
|
||||
// parseFormatTableSet provides a function to parse the format settings of the
|
||||
// table with default value.
|
||||
func parseFormatTableSet(formatSet string) *formatTable {
|
||||
func parseFormatTableSet(formatSet string) (*formatTable, error) {
|
||||
format := formatTable{
|
||||
TableStyle: "",
|
||||
ShowRowStripes: true,
|
||||
}
|
||||
json.Unmarshal([]byte(formatSet), &format)
|
||||
return &format
|
||||
err := json.Unmarshal(parseFormatSet(formatSet), &format)
|
||||
return &format, err
|
||||
}
|
||||
|
||||
// AddTable provides the method to add table in a worksheet by given worksheet
|
||||
@@ -41,8 +50,11 @@ func parseFormatTableSet(formatSet string) *formatTable {
|
||||
// TableStyleMedium1 - TableStyleMedium28
|
||||
// TableStyleDark1 - TableStyleDark11
|
||||
//
|
||||
func (f *File) AddTable(sheet, hcell, vcell, format string) {
|
||||
formatSet := parseFormatTableSet(format)
|
||||
func (f *File) AddTable(sheet, hcell, vcell, format string) error {
|
||||
formatSet, err := parseFormatTableSet(format)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
hcell = strings.ToUpper(hcell)
|
||||
vcell = strings.ToUpper(vcell)
|
||||
// Coordinate conversion, convert C1:B3 to 2,0,1,2.
|
||||
@@ -69,10 +81,11 @@ func (f *File) AddTable(sheet, hcell, vcell, format string) {
|
||||
f.addSheetTable(sheet, rID)
|
||||
f.addTable(sheet, tableXML, hxAxis, hyAxis, vxAxis, vyAxis, tableID, formatSet)
|
||||
f.addContentTypePart(tableID, "table")
|
||||
return err
|
||||
}
|
||||
|
||||
// countTables provides function to get table files count storage in the folder
|
||||
// xl/tables.
|
||||
// countTables provides a function to get table files count storage in the
|
||||
// folder xl/tables.
|
||||
func (f *File) countTables() int {
|
||||
count := 0
|
||||
for k := range f.XLSX {
|
||||
@@ -83,7 +96,7 @@ func (f *File) countTables() int {
|
||||
return count
|
||||
}
|
||||
|
||||
// addSheetTable provides function to add tablePart element to
|
||||
// addSheetTable provides a function to add tablePart element to
|
||||
// xl/worksheets/sheet%d.xml by given worksheet name and relationship index.
|
||||
func (f *File) addSheetTable(sheet string, rID int) {
|
||||
xlsx := f.workSheetReader(sheet)
|
||||
@@ -97,8 +110,8 @@ func (f *File) addSheetTable(sheet string, rID int) {
|
||||
xlsx.TableParts.TableParts = append(xlsx.TableParts.TableParts, table)
|
||||
}
|
||||
|
||||
// addTable provides function to add table by given worksheet name, coordinate
|
||||
// area and format set.
|
||||
// addTable provides a function to add table by given worksheet name,
|
||||
// coordinate area and format set.
|
||||
func (f *File) addTable(sheet, tableXML string, hxAxis, hyAxis, vxAxis, vyAxis, i int, formatSet *formatTable) {
|
||||
// Correct the minimum number of rows, the table at least two lines.
|
||||
if hyAxis == vyAxis {
|
||||
@@ -153,12 +166,12 @@ func (f *File) addTable(sheet, tableXML string, hxAxis, hyAxis, vxAxis, vyAxis,
|
||||
f.saveFileList(tableXML, table)
|
||||
}
|
||||
|
||||
// parseAutoFilterSet provides function to parse the settings of the auto
|
||||
// parseAutoFilterSet provides a function to parse the settings of the auto
|
||||
// filter.
|
||||
func parseAutoFilterSet(formatSet string) *formatAutoFilter {
|
||||
func parseAutoFilterSet(formatSet string) (*formatAutoFilter, error) {
|
||||
format := formatAutoFilter{}
|
||||
json.Unmarshal([]byte(formatSet), &format)
|
||||
return &format
|
||||
err := json.Unmarshal([]byte(formatSet), &format)
|
||||
return &format, err
|
||||
}
|
||||
|
||||
// AutoFilter provides the method to add auto filter in a worksheet by given
|
||||
@@ -232,7 +245,8 @@ func parseAutoFilterSet(formatSet string) *formatAutoFilter {
|
||||
// Price < 2000
|
||||
//
|
||||
func (f *File) AutoFilter(sheet, hcell, vcell, format string) error {
|
||||
formatSet := parseAutoFilterSet(format)
|
||||
formatSet, _ := parseAutoFilterSet(format)
|
||||
|
||||
hcell = strings.ToUpper(hcell)
|
||||
vcell = strings.ToUpper(vcell)
|
||||
|
||||
@@ -256,11 +270,10 @@ func (f *File) AutoFilter(sheet, hcell, vcell, format string) error {
|
||||
}
|
||||
ref := ToAlphaString(hxAxis) + strconv.Itoa(hyAxis+1) + ":" + ToAlphaString(vxAxis) + strconv.Itoa(vyAxis+1)
|
||||
refRange := vxAxis - hxAxis
|
||||
err := f.autoFilter(sheet, ref, refRange, hxAxis, formatSet)
|
||||
return err
|
||||
return f.autoFilter(sheet, ref, refRange, hxAxis, formatSet)
|
||||
}
|
||||
|
||||
// autoFilter provides function to extract the tokens from the filter
|
||||
// autoFilter provides a function to extract the tokens from the filter
|
||||
// expression. The tokens are mainly non-whitespace groups.
|
||||
func (f *File) autoFilter(sheet, ref string, refRange, hxAxis int, formatSet *formatAutoFilter) error {
|
||||
xlsx := f.workSheetReader(sheet)
|
||||
@@ -278,7 +291,7 @@ func (f *File) autoFilter(sheet, ref string, refRange, hxAxis int, formatSet *fo
|
||||
col := TitleToNumber(formatSet.Column)
|
||||
offset := col - hxAxis
|
||||
if offset < 0 || offset > refRange {
|
||||
return fmt.Errorf("Incorrect index of column '%s'", formatSet.Column)
|
||||
return fmt.Errorf("incorrect index of column '%s'", formatSet.Column)
|
||||
}
|
||||
filter.FilterColumn = &xlsxFilterColumn{
|
||||
ColID: offset,
|
||||
@@ -286,7 +299,7 @@ func (f *File) autoFilter(sheet, ref string, refRange, hxAxis int, formatSet *fo
|
||||
re := regexp.MustCompile(`"(?:[^"]|"")*"|\S+`)
|
||||
token := re.FindAllString(formatSet.Expression, -1)
|
||||
if len(token) != 3 && len(token) != 7 {
|
||||
return fmt.Errorf("Incorrect number of tokens in criteria '%s'", formatSet.Expression)
|
||||
return fmt.Errorf("incorrect number of tokens in criteria '%s'", formatSet.Expression)
|
||||
}
|
||||
expressions, tokens, err := f.parseFilterExpression(formatSet.Expression, token)
|
||||
if err != nil {
|
||||
@@ -297,8 +310,8 @@ func (f *File) autoFilter(sheet, ref string, refRange, hxAxis int, formatSet *fo
|
||||
return nil
|
||||
}
|
||||
|
||||
// writeAutoFilter provides function to check for single or double custom filters
|
||||
// as default filters and handle them accordingly.
|
||||
// writeAutoFilter provides a function to check for single or double custom
|
||||
// filters as default filters and handle them accordingly.
|
||||
func (f *File) writeAutoFilter(filter *xlsxAutoFilter, exp []int, tokens []string) {
|
||||
if len(exp) == 1 && exp[0] == 2 {
|
||||
// Single equality.
|
||||
@@ -325,7 +338,7 @@ func (f *File) writeAutoFilter(filter *xlsxAutoFilter, exp []int, tokens []strin
|
||||
}
|
||||
}
|
||||
|
||||
// writeCustomFilter provides function to write the <customFilter> element.
|
||||
// writeCustomFilter provides a function to write the <customFilter> element.
|
||||
func (f *File) writeCustomFilter(filter *xlsxAutoFilter, operator int, val string) {
|
||||
operators := map[int]string{
|
||||
1: "lessThan",
|
||||
@@ -349,8 +362,9 @@ func (f *File) writeCustomFilter(filter *xlsxAutoFilter, operator int, val strin
|
||||
}
|
||||
}
|
||||
|
||||
// parseFilterExpression provides function to converts the tokens of a possibly
|
||||
// conditional expression into 1 or 2 sub expressions for further parsing.
|
||||
// parseFilterExpression provides a function to converts the tokens of a
|
||||
// possibly conditional expression into 1 or 2 sub expressions for further
|
||||
// parsing.
|
||||
//
|
||||
// Examples:
|
||||
//
|
||||
@@ -390,7 +404,7 @@ func (f *File) parseFilterExpression(expression string, tokens []string) ([]int,
|
||||
return expressions, t, nil
|
||||
}
|
||||
|
||||
// parseFilterTokens provides function to parse the 3 tokens of a filter
|
||||
// parseFilterTokens provides a function to parse the 3 tokens of a filter
|
||||
// expression and return the operator and token.
|
||||
func (f *File) parseFilterTokens(expression string, tokens []string) ([]int, string, error) {
|
||||
operators := map[string]int{
|
||||
@@ -410,7 +424,7 @@ func (f *File) parseFilterTokens(expression string, tokens []string) ([]int, str
|
||||
operator, ok := operators[strings.ToLower(tokens[1])]
|
||||
if !ok {
|
||||
// Convert the operator from a number to a descriptive string.
|
||||
return []int{}, "", fmt.Errorf("Unknown operator: %s", tokens[1])
|
||||
return []int{}, "", fmt.Errorf("unknown operator: %s", tokens[1])
|
||||
}
|
||||
token := tokens[2]
|
||||
// Special handling for Blanks/NonBlanks.
|
||||
@@ -418,7 +432,7 @@ func (f *File) parseFilterTokens(expression string, tokens []string) ([]int, str
|
||||
if re {
|
||||
// Only allow Equals or NotEqual in this context.
|
||||
if operator != 2 && operator != 5 {
|
||||
return []int{operator}, token, fmt.Errorf("The operator '%s' in expression '%s' is not valid in relation to Blanks/NonBlanks'", tokens[1], expression)
|
||||
return []int{operator}, token, fmt.Errorf("the operator '%s' in expression '%s' is not valid in relation to Blanks/NonBlanks'", tokens[1], expression)
|
||||
}
|
||||
token = strings.ToLower(token)
|
||||
// The operator should always be 2 (=) to flag a "simple" equality in
|
||||
|
||||
13
vendor/github.com/360EntSecGroup-Skylar/excelize/templates.go
generated
vendored
13
vendor/github.com/360EntSecGroup-Skylar/excelize/templates.go
generated
vendored
@@ -1,3 +1,12 @@
|
||||
// Copyright 2016 - 2018 The excelize Authors. All rights reserved. Use of
|
||||
// this source code is governed by a BSD-style license that can be found in
|
||||
// the LICENSE file.
|
||||
//
|
||||
// Package excelize providing a set of functions that allow you to write to
|
||||
// and read from XLSX files. Support reads and writes XLSX file generated by
|
||||
// Microsoft Excel™ 2007 and later. Support save file without losing original
|
||||
// charts of XLSX. This library needs Go version 1.8 or later.
|
||||
//
|
||||
// This file contains default templates for XML files we don't yet populated
|
||||
// based on content.
|
||||
|
||||
@@ -7,10 +16,12 @@ package excelize
|
||||
const XMLHeader = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n"
|
||||
|
||||
var (
|
||||
// XMLHeaderByte define an XML declaration can also contain a standalone
|
||||
// declaration.
|
||||
XMLHeaderByte = []byte(XMLHeader)
|
||||
)
|
||||
|
||||
const templateDocpropsApp = `<Properties xmlns="http://schemas.openxmlformats.org/officeDocument/2006/extended-properties" xmlns:vt="http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes"><TotalTime>0</TotalTime><Application>Golang Excelize</Application></Properties>`
|
||||
const templateDocpropsApp = `<Properties xmlns="http://schemas.openxmlformats.org/officeDocument/2006/extended-properties" xmlns:vt="http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes"><TotalTime>0</TotalTime><Application>Go Excelize</Application></Properties>`
|
||||
|
||||
const templateContentTypes = `<Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types"><Override PartName="/xl/theme/theme1.xml" ContentType="application/vnd.openxmlformats-officedocument.theme+xml"/><Override PartName="/xl/styles.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml"/><Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml"/><Default Extension="xml" ContentType="application/xml"/><Override PartName="/xl/workbook.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml"/><Override PartName="/docProps/app.xml" ContentType="application/vnd.openxmlformats-officedocument.extended-properties+xml"/><Override PartName="/xl/worksheets/sheet1.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml"/><Override PartName="/docProps/core.xml" ContentType="application/vnd.openxmlformats-package.core-properties+xml"/></Types>`
|
||||
|
||||
|
||||
9
vendor/github.com/360EntSecGroup-Skylar/excelize/vmlDrawing.go
generated
vendored
9
vendor/github.com/360EntSecGroup-Skylar/excelize/vmlDrawing.go
generated
vendored
@@ -1,3 +1,12 @@
|
||||
// Copyright 2016 - 2018 The excelize Authors. All rights reserved. Use of
|
||||
// this source code is governed by a BSD-style license that can be found in
|
||||
// the LICENSE file.
|
||||
//
|
||||
// Package excelize providing a set of functions that allow you to write to
|
||||
// and read from XLSX files. Support reads and writes XLSX file generated by
|
||||
// Microsoft Excel™ 2007 and later. Support save file without losing original
|
||||
// charts of XLSX. This library needs Go version 1.8 or later.
|
||||
|
||||
package excelize
|
||||
|
||||
import "encoding/xml"
|
||||
|
||||
9
vendor/github.com/360EntSecGroup-Skylar/excelize/xmlChart.go
generated
vendored
9
vendor/github.com/360EntSecGroup-Skylar/excelize/xmlChart.go
generated
vendored
@@ -1,3 +1,12 @@
|
||||
// Copyright 2016 - 2018 The excelize Authors. All rights reserved. Use of
|
||||
// this source code is governed by a BSD-style license that can be found in
|
||||
// the LICENSE file.
|
||||
//
|
||||
// Package excelize providing a set of functions that allow you to write to
|
||||
// and read from XLSX files. Support reads and writes XLSX file generated by
|
||||
// Microsoft Excel™ 2007 and later. Support save file without losing original
|
||||
// charts of XLSX. This library needs Go version 1.8 or later.
|
||||
|
||||
package excelize
|
||||
|
||||
import "encoding/xml"
|
||||
|
||||
17
vendor/github.com/360EntSecGroup-Skylar/excelize/xmlComments.go
generated
vendored
17
vendor/github.com/360EntSecGroup-Skylar/excelize/xmlComments.go
generated
vendored
@@ -1,3 +1,12 @@
|
||||
// Copyright 2016 - 2018 The excelize Authors. All rights reserved. Use of
|
||||
// this source code is governed by a BSD-style license that can be found in
|
||||
// the LICENSE file.
|
||||
//
|
||||
// Package excelize providing a set of functions that allow you to write to
|
||||
// and read from XLSX files. Support reads and writes XLSX file generated by
|
||||
// Microsoft Excel™ 2007 and later. Support save file without losing original
|
||||
// charts of XLSX. This library needs Go version 1.8 or later.
|
||||
|
||||
package excelize
|
||||
|
||||
import "encoding/xml"
|
||||
@@ -53,3 +62,11 @@ type formatComment struct {
|
||||
Author string `json:"author"`
|
||||
Text string `json:"text"`
|
||||
}
|
||||
|
||||
// Comment directly maps the comment information.
|
||||
type Comment struct {
|
||||
Author string `json:"author"`
|
||||
AuthorID int `json:"author_id"`
|
||||
Ref string `json:"ref"`
|
||||
Text string `json:"text"`
|
||||
}
|
||||
|
||||
9
vendor/github.com/360EntSecGroup-Skylar/excelize/xmlContentTypes.go
generated
vendored
9
vendor/github.com/360EntSecGroup-Skylar/excelize/xmlContentTypes.go
generated
vendored
@@ -1,3 +1,12 @@
|
||||
// Copyright 2016 - 2018 The excelize Authors. All rights reserved. Use of
|
||||
// this source code is governed by a BSD-style license that can be found in
|
||||
// the LICENSE file.
|
||||
//
|
||||
// Package excelize providing a set of functions that allow you to write to
|
||||
// and read from XLSX files. Support reads and writes XLSX file generated by
|
||||
// Microsoft Excel™ 2007 and later. Support save file without losing original
|
||||
// charts of XLSX. This library needs Go version 1.8 or later.
|
||||
|
||||
package excelize
|
||||
|
||||
import "encoding/xml"
|
||||
|
||||
9
vendor/github.com/360EntSecGroup-Skylar/excelize/xmlDecodeDrawing.go
generated
vendored
9
vendor/github.com/360EntSecGroup-Skylar/excelize/xmlDecodeDrawing.go
generated
vendored
@@ -1,3 +1,12 @@
|
||||
// Copyright 2016 - 2018 The excelize Authors. All rights reserved. Use of
|
||||
// this source code is governed by a BSD-style license that can be found in
|
||||
// the LICENSE file.
|
||||
//
|
||||
// Package excelize providing a set of functions that allow you to write to
|
||||
// and read from XLSX files. Support reads and writes XLSX file generated by
|
||||
// Microsoft Excel™ 2007 and later. Support save file without losing original
|
||||
// charts of XLSX. This library needs Go version 1.8 or later.
|
||||
|
||||
package excelize
|
||||
|
||||
import "encoding/xml"
|
||||
|
||||
9
vendor/github.com/360EntSecGroup-Skylar/excelize/xmlDrawing.go
generated
vendored
9
vendor/github.com/360EntSecGroup-Skylar/excelize/xmlDrawing.go
generated
vendored
@@ -1,3 +1,12 @@
|
||||
// Copyright 2016 - 2018 The excelize Authors. All rights reserved. Use of
|
||||
// this source code is governed by a BSD-style license that can be found in
|
||||
// the LICENSE file.
|
||||
//
|
||||
// Package excelize providing a set of functions that allow you to write to
|
||||
// and read from XLSX files. Support reads and writes XLSX file generated by
|
||||
// Microsoft Excel™ 2007 and later. Support save file without losing original
|
||||
// charts of XLSX. This library needs Go version 1.8 or later.
|
||||
|
||||
package excelize
|
||||
|
||||
import "encoding/xml"
|
||||
|
||||
9
vendor/github.com/360EntSecGroup-Skylar/excelize/xmlSharedStrings.go
generated
vendored
9
vendor/github.com/360EntSecGroup-Skylar/excelize/xmlSharedStrings.go
generated
vendored
@@ -1,3 +1,12 @@
|
||||
// Copyright 2016 - 2018 The excelize Authors. All rights reserved. Use of
|
||||
// this source code is governed by a BSD-style license that can be found in
|
||||
// the LICENSE file.
|
||||
//
|
||||
// Package excelize providing a set of functions that allow you to write to
|
||||
// and read from XLSX files. Support reads and writes XLSX file generated by
|
||||
// Microsoft Excel™ 2007 and later. Support save file without losing original
|
||||
// charts of XLSX. This library needs Go version 1.8 or later.
|
||||
|
||||
package excelize
|
||||
|
||||
import "encoding/xml"
|
||||
|
||||
9
vendor/github.com/360EntSecGroup-Skylar/excelize/xmlStyles.go
generated
vendored
9
vendor/github.com/360EntSecGroup-Skylar/excelize/xmlStyles.go
generated
vendored
@@ -1,3 +1,12 @@
|
||||
// Copyright 2016 - 2018 The excelize Authors. All rights reserved. Use of
|
||||
// this source code is governed by a BSD-style license that can be found in
|
||||
// the LICENSE file.
|
||||
//
|
||||
// Package excelize providing a set of functions that allow you to write to
|
||||
// and read from XLSX files. Support reads and writes XLSX file generated by
|
||||
// Microsoft Excel™ 2007 and later. Support save file without losing original
|
||||
// charts of XLSX. This library needs Go version 1.8 or later.
|
||||
|
||||
package excelize
|
||||
|
||||
import "encoding/xml"
|
||||
|
||||
9
vendor/github.com/360EntSecGroup-Skylar/excelize/xmlTable.go
generated
vendored
9
vendor/github.com/360EntSecGroup-Skylar/excelize/xmlTable.go
generated
vendored
@@ -1,3 +1,12 @@
|
||||
// Copyright 2016 - 2018 The excelize Authors. All rights reserved. Use of
|
||||
// this source code is governed by a BSD-style license that can be found in
|
||||
// the LICENSE file.
|
||||
//
|
||||
// Package excelize providing a set of functions that allow you to write to
|
||||
// and read from XLSX files. Support reads and writes XLSX file generated by
|
||||
// Microsoft Excel™ 2007 and later. Support save file without losing original
|
||||
// charts of XLSX. This library needs Go version 1.8 or later.
|
||||
|
||||
package excelize
|
||||
|
||||
import "encoding/xml"
|
||||
|
||||
149
vendor/github.com/360EntSecGroup-Skylar/excelize/xmlTheme.go
generated
vendored
Normal file
149
vendor/github.com/360EntSecGroup-Skylar/excelize/xmlTheme.go
generated
vendored
Normal file
@@ -0,0 +1,149 @@
|
||||
// Copyright 2016 - 2018 The excelize Authors. All rights reserved. Use of
|
||||
// this source code is governed by a BSD-style license that can be found in
|
||||
// the LICENSE file.
|
||||
//
|
||||
// Package excelize providing a set of functions that allow you to write to
|
||||
// and read from XLSX files. Support reads and writes XLSX file generated by
|
||||
// Microsoft Excel™ 2007 and later. Support save file without losing original
|
||||
// charts of XLSX. This library needs Go version 1.8 or later.
|
||||
|
||||
package excelize
|
||||
|
||||
import "encoding/xml"
|
||||
|
||||
// xlsxTheme directly maps the theme element in the namespace
|
||||
// http://schemas.openxmlformats.org/drawingml/2006/main
|
||||
type xlsxTheme struct {
|
||||
ThemeElements xlsxThemeElements `xml:"themeElements"`
|
||||
ObjectDefaults xlsxObjectDefaults `xml:"objectDefaults"`
|
||||
ExtraClrSchemeLst xlsxExtraClrSchemeLst `xml:"extraClrSchemeLst"`
|
||||
ExtLst *xlsxExtLst `xml:"extLst"`
|
||||
}
|
||||
|
||||
// objectDefaults element allows for the definition of default shape, line,
|
||||
// and textbox formatting properties. An application can use this information
|
||||
// to format a shape (or text) initially on insertion into a document.
|
||||
type xlsxObjectDefaults struct {
|
||||
ObjectDefaults string `xml:",innerxml"`
|
||||
}
|
||||
|
||||
// xlsxExtraClrSchemeLst element is a container for the list of extra color
|
||||
// schemes present in a document.
|
||||
type xlsxExtraClrSchemeLst struct {
|
||||
ExtraClrSchemeLst string `xml:",innerxml"`
|
||||
}
|
||||
|
||||
// xlsxThemeElements directly maps the element defines the theme formatting
|
||||
// options for the theme and is the workhorse of the theme. This is where the
|
||||
// bulk of the shared theme information is contained and used by a document.
|
||||
// This element contains the color scheme, font scheme, and format scheme
|
||||
// elements which define the different formatting aspects of what a theme
|
||||
// defines.
|
||||
type xlsxThemeElements struct {
|
||||
ClrScheme xlsxClrScheme `xml:"clrScheme"`
|
||||
FontScheme xlsxFontScheme `xml:"fontScheme"`
|
||||
FmtScheme xlsxFmtScheme `xml:"fmtScheme"`
|
||||
}
|
||||
|
||||
// xlsxClrScheme element specifies the theme color, stored in the document's
|
||||
// Theme part to which the value of this theme color shall be mapped. This
|
||||
// mapping enables multiple theme colors to be chained together.
|
||||
type xlsxClrScheme struct {
|
||||
Name string `xml:"name,attr"`
|
||||
Children []xlsxClrSchemeEl `xml:",any"`
|
||||
}
|
||||
|
||||
// xlsxFontScheme element defines the font scheme within the theme. The font
|
||||
// scheme consists of a pair of major and minor fonts for which to use in a
|
||||
// document. The major font corresponds well with the heading areas of a
|
||||
// document, and the minor font corresponds well with the normal text or
|
||||
// paragraph areas.
|
||||
type xlsxFontScheme struct {
|
||||
Name string `xml:"name,attr"`
|
||||
MajorFont xlsxMajorFont `xml:"majorFont"`
|
||||
MinorFont xlsxMinorFont `xml:"minorFont"`
|
||||
ExtLst *xlsxExtLst `xml:"extLst"`
|
||||
}
|
||||
|
||||
// xlsxMajorFont element defines the set of major fonts which are to be used
|
||||
// under different languages or locals.
|
||||
type xlsxMajorFont struct {
|
||||
Children []xlsxFontSchemeEl `xml:",any"`
|
||||
}
|
||||
|
||||
// xlsxMinorFont element defines the set of minor fonts that are to be used
|
||||
// under different languages or locals.
|
||||
type xlsxMinorFont struct {
|
||||
Children []xlsxFontSchemeEl `xml:",any"`
|
||||
}
|
||||
|
||||
// xlsxFmtScheme element contains the background fill styles, effect styles,
|
||||
// fill styles, and line styles which define the style matrix for a theme. The
|
||||
// style matrix consists of subtle, moderate, and intense fills, lines, and
|
||||
// effects. The background fills are not generally thought of to directly be
|
||||
// associated with the matrix, but do play a role in the style of the overall
|
||||
// document. Usually, a given object chooses a single line style, a single
|
||||
// fill style, and a single effect style in order to define the overall final
|
||||
// look of the object.
|
||||
type xlsxFmtScheme struct {
|
||||
Name string `xml:"name,attr"`
|
||||
FillStyleLst xlsxFillStyleLst `xml:"fillStyleLst"`
|
||||
LnStyleLst xlsxLnStyleLst `xml:"lnStyleLst"`
|
||||
EffectStyleLst xlsxEffectStyleLst `xml:"effectStyleLst"`
|
||||
BgFillStyleLst xlsxBgFillStyleLst `xml:"bgFillStyleLst"`
|
||||
}
|
||||
|
||||
// xlsxFillStyleLst element defines a set of three fill styles that are used
|
||||
// within a theme. The three fill styles are arranged in order from subtle to
|
||||
// moderate to intense.
|
||||
type xlsxFillStyleLst struct {
|
||||
FillStyleLst string `xml:",innerxml"`
|
||||
}
|
||||
|
||||
// xlsxLnStyleLst element defines a list of three line styles for use within a
|
||||
// theme. The three line styles are arranged in order from subtle to moderate
|
||||
// to intense versions of lines. This list makes up part of the style matrix.
|
||||
type xlsxLnStyleLst struct {
|
||||
LnStyleLst string `xml:",innerxml"`
|
||||
}
|
||||
|
||||
// xlsxEffectStyleLst element defines a set of three effect styles that create
|
||||
// the effect style list for a theme. The effect styles are arranged in order
|
||||
// of subtle to moderate to intense.
|
||||
type xlsxEffectStyleLst struct {
|
||||
EffectStyleLst string `xml:",innerxml"`
|
||||
}
|
||||
|
||||
// xlsxBgFillStyleLst element defines a list of background fills that are
|
||||
// used within a theme. The background fills consist of three fills, arranged
|
||||
// in order from subtle to moderate to intense.
|
||||
type xlsxBgFillStyleLst struct {
|
||||
BgFillStyleLst string `xml:",innerxml"`
|
||||
}
|
||||
|
||||
// xlsxClrScheme maps to children of the clrScheme element in the namespace
|
||||
// http://schemas.openxmlformats.org/drawingml/2006/main - currently I have
|
||||
// not checked it for completeness - it does as much as I need.
|
||||
type xlsxClrSchemeEl struct {
|
||||
XMLName xml.Name
|
||||
SysClr *xlsxSysClr `xml:"sysClr"`
|
||||
SrgbClr *attrValString `xml:"srgbClr"`
|
||||
}
|
||||
|
||||
// xlsxFontSchemeEl directly maps the major and minor font of the style's font
|
||||
// scheme.
|
||||
type xlsxFontSchemeEl struct {
|
||||
XMLName xml.Name
|
||||
Script string `xml:"script,attr,omitempty"`
|
||||
Typeface string `xml:"typeface,attr"`
|
||||
Panose string `xml:"panose,attr,omitempty"`
|
||||
PitchFamily string `xml:"pitchFamily,attr,omitempty"`
|
||||
Charset string `xml:"charset,attr,omitempty"`
|
||||
}
|
||||
|
||||
// xlsxSysClr element specifies a color bound to predefined operating system
|
||||
// elements.
|
||||
type xlsxSysClr struct {
|
||||
Val string `xml:"val,attr"`
|
||||
LastClr string `xml:"lastClr,attr"`
|
||||
}
|
||||
9
vendor/github.com/360EntSecGroup-Skylar/excelize/xmlWorkbook.go
generated
vendored
9
vendor/github.com/360EntSecGroup-Skylar/excelize/xmlWorkbook.go
generated
vendored
@@ -1,3 +1,12 @@
|
||||
// Copyright 2016 - 2018 The excelize Authors. All rights reserved. Use of
|
||||
// this source code is governed by a BSD-style license that can be found in
|
||||
// the LICENSE file.
|
||||
//
|
||||
// Package excelize providing a set of functions that allow you to write to
|
||||
// and read from XLSX files. Support reads and writes XLSX file generated by
|
||||
// Microsoft Excel™ 2007 and later. Support save file without losing original
|
||||
// charts of XLSX. This library needs Go version 1.8 or later.
|
||||
|
||||
package excelize
|
||||
|
||||
import "encoding/xml"
|
||||
|
||||
42
vendor/github.com/360EntSecGroup-Skylar/excelize/xmlWorksheet.go
generated
vendored
42
vendor/github.com/360EntSecGroup-Skylar/excelize/xmlWorksheet.go
generated
vendored
@@ -1,3 +1,12 @@
|
||||
// Copyright 2016 - 2018 The excelize Authors. All rights reserved. Use of
|
||||
// this source code is governed by a BSD-style license that can be found in
|
||||
// the LICENSE file.
|
||||
//
|
||||
// Package excelize providing a set of functions that allow you to write to
|
||||
// and read from XLSX files. Support reads and writes XLSX file generated by
|
||||
// Microsoft Excel™ 2007 and later. Support save file without losing original
|
||||
// charts of XLSX. This library needs Go version 1.8 or later.
|
||||
|
||||
package excelize
|
||||
|
||||
import "encoding/xml"
|
||||
@@ -18,7 +27,7 @@ type xlsxWorksheet struct {
|
||||
MergeCells *xlsxMergeCells `xml:"mergeCells"`
|
||||
PhoneticPr *xlsxPhoneticPr `xml:"phoneticPr"`
|
||||
ConditionalFormatting []*xlsxConditionalFormatting `xml:"conditionalFormatting"`
|
||||
DataValidations *xlsxDataValidations `xml:"dataValidations"`
|
||||
DataValidations *xlsxDataValidations `xml:"dataValidations,omitempty"`
|
||||
Hyperlinks *xlsxHyperlinks `xml:"hyperlinks"`
|
||||
PrintOptions *xlsxPrintOptions `xml:"printOptions"`
|
||||
PageMargins *xlsxPageMargins `xml:"pageMargins"`
|
||||
@@ -294,11 +303,30 @@ type xlsxMergeCells struct {
|
||||
// xlsxDataValidations expresses all data validation information for cells in a
|
||||
// sheet which have data validation features applied.
|
||||
type xlsxDataValidations struct {
|
||||
Count int `xml:"count,attr,omitempty"`
|
||||
DisablePrompts bool `xml:"disablePrompts,attr,omitempty"`
|
||||
XWindow int `xml:"xWindow,attr,omitempty"`
|
||||
YWindow int `xml:"yWindow,attr,omitempty"`
|
||||
DataValidation string `xml:",innerxml"`
|
||||
Count int `xml:"count,attr,omitempty"`
|
||||
DisablePrompts bool `xml:"disablePrompts,attr,omitempty"`
|
||||
XWindow int `xml:"xWindow,attr,omitempty"`
|
||||
YWindow int `xml:"yWindow,attr,omitempty"`
|
||||
DataValidation []*DataValidation `xml:"dataValidation"`
|
||||
}
|
||||
|
||||
// DataValidation directly maps the a single item of data validation defined
|
||||
// on a range of the worksheet.
|
||||
type DataValidation struct {
|
||||
AllowBlank bool `xml:"allowBlank,attr"`
|
||||
Error *string `xml:"error,attr"`
|
||||
ErrorStyle *string `xml:"errorStyle,attr"`
|
||||
ErrorTitle *string `xml:"errorTitle,attr"`
|
||||
Operator string `xml:"operator,attr"`
|
||||
Prompt *string `xml:"prompt,attr"`
|
||||
PromptTitle *string `xml:"promptTitle"`
|
||||
ShowDropDown bool `xml:"showDropDown,attr"`
|
||||
ShowErrorMessage bool `xml:"showErrorMessage,attr"`
|
||||
ShowInputMessage bool `xml:"showInputMessage,attr"`
|
||||
Sqref string `xml:"sqref,attr"`
|
||||
Type string `xml:"type,attr"`
|
||||
Formula1 string `xml:"formula1"`
|
||||
Formula2 string `xml:"formula2"`
|
||||
}
|
||||
|
||||
// xlsxC directly maps the c element in the namespace
|
||||
@@ -446,7 +474,7 @@ type xlsxIconSet struct {
|
||||
type xlsxCfvo struct {
|
||||
Gte bool `xml:"gte,attr,omitempty"`
|
||||
Type string `xml:"type,attr,omitempty"`
|
||||
Val int `xml:"val,attr"`
|
||||
Val string `xml:"val,attr"`
|
||||
ExtLst *xlsxExtLst `xml:"extLst"`
|
||||
}
|
||||
|
||||
|
||||
@@ -798,84 +798,6 @@ func PossibleVirtualMachineSizeTypesValues() []VirtualMachineSizeTypes {
|
||||
// AccessURI a disk access SAS uri.
|
||||
type AccessURI struct {
|
||||
autorest.Response `json:"-"`
|
||||
// AccessURIOutput - Operation output data (raw JSON)
|
||||
*AccessURIOutput `json:"properties,omitempty"`
|
||||
}
|
||||
|
||||
// MarshalJSON is the custom marshaler for AccessURI.
|
||||
func (au AccessURI) MarshalJSON() ([]byte, error) {
|
||||
objectMap := make(map[string]interface{})
|
||||
if au.AccessURIOutput != nil {
|
||||
objectMap["properties"] = au.AccessURIOutput
|
||||
}
|
||||
return json.Marshal(objectMap)
|
||||
}
|
||||
|
||||
// UnmarshalJSON is the custom unmarshaler for AccessURI struct.
|
||||
func (au *AccessURI) UnmarshalJSON(body []byte) error {
|
||||
var m map[string]*json.RawMessage
|
||||
err := json.Unmarshal(body, &m)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for k, v := range m {
|
||||
switch k {
|
||||
case "properties":
|
||||
if v != nil {
|
||||
var accessURIOutput AccessURIOutput
|
||||
err = json.Unmarshal(*v, &accessURIOutput)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
au.AccessURIOutput = &accessURIOutput
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// AccessURIOutput azure properties, including output.
|
||||
type AccessURIOutput struct {
|
||||
// AccessURIRaw - Operation output data (raw JSON)
|
||||
*AccessURIRaw `json:"output,omitempty"`
|
||||
}
|
||||
|
||||
// MarshalJSON is the custom marshaler for AccessURIOutput.
|
||||
func (auo AccessURIOutput) MarshalJSON() ([]byte, error) {
|
||||
objectMap := make(map[string]interface{})
|
||||
if auo.AccessURIRaw != nil {
|
||||
objectMap["output"] = auo.AccessURIRaw
|
||||
}
|
||||
return json.Marshal(objectMap)
|
||||
}
|
||||
|
||||
// UnmarshalJSON is the custom unmarshaler for AccessURIOutput struct.
|
||||
func (auo *AccessURIOutput) UnmarshalJSON(body []byte) error {
|
||||
var m map[string]*json.RawMessage
|
||||
err := json.Unmarshal(body, &m)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for k, v := range m {
|
||||
switch k {
|
||||
case "output":
|
||||
if v != nil {
|
||||
var accessURIRaw AccessURIRaw
|
||||
err = json.Unmarshal(*v, &accessURIRaw)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
auo.AccessURIRaw = &accessURIRaw
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// AccessURIRaw a disk access SAS uri.
|
||||
type AccessURIRaw struct {
|
||||
// AccessSAS - A SAS uri for accessing a disk.
|
||||
AccessSAS *string `json:"accessSAS,omitempty"`
|
||||
}
|
||||
@@ -1290,7 +1212,7 @@ type DataDisk struct {
|
||||
WriteAcceleratorEnabled *bool `json:"writeAcceleratorEnabled,omitempty"`
|
||||
// CreateOption - Specifies how the virtual machine should be created.<br><br> Possible values are:<br><br> **Attach** \u2013 This value is used when you are using a specialized disk to create the virtual machine.<br><br> **FromImage** \u2013 This value is used when you are using an image to create the virtual machine. If you are using a platform image, you also use the imageReference element described above. If you are using a marketplace image, you also use the plan element previously described. Possible values include: 'DiskCreateOptionTypesFromImage', 'DiskCreateOptionTypesEmpty', 'DiskCreateOptionTypesAttach'
|
||||
CreateOption DiskCreateOptionTypes `json:"createOption,omitempty"`
|
||||
// DiskSizeGB - Specifies the size of an empty data disk in gigabytes. This element can be used to overwrite the name of the disk in a virtual machine image. <br><br> This value cannot be larger than 1023 GB
|
||||
// DiskSizeGB - Specifies the size of an empty data disk in gigabytes. This element can be used to overwrite the size of the disk in a virtual machine image. <br><br> This value cannot be larger than 1023 GB
|
||||
DiskSizeGB *int32 `json:"diskSizeGB,omitempty"`
|
||||
// ManagedDisk - The managed disk parameters.
|
||||
ManagedDisk *ManagedDiskParameters `json:"managedDisk,omitempty"`
|
||||
@@ -2718,7 +2640,7 @@ type OSDisk struct {
|
||||
WriteAcceleratorEnabled *bool `json:"writeAcceleratorEnabled,omitempty"`
|
||||
// CreateOption - Specifies how the virtual machine should be created.<br><br> Possible values are:<br><br> **Attach** \u2013 This value is used when you are using a specialized disk to create the virtual machine.<br><br> **FromImage** \u2013 This value is used when you are using an image to create the virtual machine. If you are using a platform image, you also use the imageReference element described above. If you are using a marketplace image, you also use the plan element previously described. Possible values include: 'DiskCreateOptionTypesFromImage', 'DiskCreateOptionTypesEmpty', 'DiskCreateOptionTypesAttach'
|
||||
CreateOption DiskCreateOptionTypes `json:"createOption,omitempty"`
|
||||
// DiskSizeGB - Specifies the size of an empty data disk in gigabytes. This element can be used to overwrite the name of the disk in a virtual machine image. <br><br> This value cannot be larger than 1023 GB
|
||||
// DiskSizeGB - Specifies the size of an empty data disk in gigabytes. This element can be used to overwrite the size of the disk in a virtual machine image. <br><br> This value cannot be larger than 1023 GB
|
||||
DiskSizeGB *int32 `json:"diskSizeGB,omitempty"`
|
||||
// ManagedDisk - The managed disk parameters.
|
||||
ManagedDisk *ManagedDiskParameters `json:"managedDisk,omitempty"`
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Package compute implements the Azure ARM Compute service API version 2018-06-01.
|
||||
// Package compute implements the Azure ARM Compute service API version .
|
||||
//
|
||||
// Compute Client
|
||||
package compute
|
||||
|
||||
475
vendor/github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-06-01/compute/containerservices.go
generated
vendored
Normal file
475
vendor/github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-06-01/compute/containerservices.go
generated
vendored
Normal file
@@ -0,0 +1,475 @@
|
||||
package compute
|
||||
|
||||
// Copyright (c) Microsoft and contributors. All rights reserved.
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
// Code generated by Microsoft (R) AutoRest Code Generator.
|
||||
// Changes may cause incorrect behavior and will be lost if the code is regenerated.
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/Azure/go-autorest/autorest"
|
||||
"github.com/Azure/go-autorest/autorest/azure"
|
||||
"github.com/Azure/go-autorest/autorest/validation"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
// ContainerServicesClient is the compute Client
|
||||
type ContainerServicesClient struct {
|
||||
BaseClient
|
||||
}
|
||||
|
||||
// NewContainerServicesClient creates an instance of the ContainerServicesClient client.
|
||||
func NewContainerServicesClient(subscriptionID string) ContainerServicesClient {
|
||||
return NewContainerServicesClientWithBaseURI(DefaultBaseURI, subscriptionID)
|
||||
}
|
||||
|
||||
// NewContainerServicesClientWithBaseURI creates an instance of the ContainerServicesClient client.
|
||||
func NewContainerServicesClientWithBaseURI(baseURI string, subscriptionID string) ContainerServicesClient {
|
||||
return ContainerServicesClient{NewWithBaseURI(baseURI, subscriptionID)}
|
||||
}
|
||||
|
||||
// CreateOrUpdate creates or updates a container service with the specified configuration of orchestrator, masters, and
|
||||
// agents.
|
||||
// Parameters:
|
||||
// resourceGroupName - the name of the resource group.
|
||||
// containerServiceName - the name of the container service in the specified subscription and resource group.
|
||||
// parameters - parameters supplied to the Create or Update a Container Service operation.
|
||||
func (client ContainerServicesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, containerServiceName string, parameters ContainerService) (result ContainerServicesCreateOrUpdateFuture, err error) {
|
||||
if err := validation.Validate([]validation.Validation{
|
||||
{TargetValue: parameters,
|
||||
Constraints: []validation.Constraint{{Target: "parameters.ContainerServiceProperties", Name: validation.Null, Rule: false,
|
||||
Chain: []validation.Constraint{{Target: "parameters.ContainerServiceProperties.CustomProfile", Name: validation.Null, Rule: false,
|
||||
Chain: []validation.Constraint{{Target: "parameters.ContainerServiceProperties.CustomProfile.Orchestrator", Name: validation.Null, Rule: true, Chain: nil}}},
|
||||
{Target: "parameters.ContainerServiceProperties.ServicePrincipalProfile", Name: validation.Null, Rule: false,
|
||||
Chain: []validation.Constraint{{Target: "parameters.ContainerServiceProperties.ServicePrincipalProfile.ClientID", Name: validation.Null, Rule: true, Chain: nil},
|
||||
{Target: "parameters.ContainerServiceProperties.ServicePrincipalProfile.Secret", Name: validation.Null, Rule: true, Chain: nil},
|
||||
}},
|
||||
{Target: "parameters.ContainerServiceProperties.MasterProfile", Name: validation.Null, Rule: true,
|
||||
Chain: []validation.Constraint{{Target: "parameters.ContainerServiceProperties.MasterProfile.DNSPrefix", Name: validation.Null, Rule: true, Chain: nil}}},
|
||||
{Target: "parameters.ContainerServiceProperties.AgentPoolProfiles", Name: validation.Null, Rule: true, Chain: nil},
|
||||
{Target: "parameters.ContainerServiceProperties.WindowsProfile", Name: validation.Null, Rule: false,
|
||||
Chain: []validation.Constraint{{Target: "parameters.ContainerServiceProperties.WindowsProfile.AdminUsername", Name: validation.Null, Rule: true,
|
||||
Chain: []validation.Constraint{{Target: "parameters.ContainerServiceProperties.WindowsProfile.AdminUsername", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]+([._]?[a-zA-Z0-9]+)*$`, Chain: nil}}},
|
||||
{Target: "parameters.ContainerServiceProperties.WindowsProfile.AdminPassword", Name: validation.Null, Rule: true, Chain: nil},
|
||||
}},
|
||||
{Target: "parameters.ContainerServiceProperties.LinuxProfile", Name: validation.Null, Rule: true,
|
||||
Chain: []validation.Constraint{{Target: "parameters.ContainerServiceProperties.LinuxProfile.AdminUsername", Name: validation.Null, Rule: true,
|
||||
Chain: []validation.Constraint{{Target: "parameters.ContainerServiceProperties.LinuxProfile.AdminUsername", Name: validation.Pattern, Rule: `^[a-z][a-z0-9_-]*$`, Chain: nil}}},
|
||||
{Target: "parameters.ContainerServiceProperties.LinuxProfile.SSH", Name: validation.Null, Rule: true,
|
||||
Chain: []validation.Constraint{{Target: "parameters.ContainerServiceProperties.LinuxProfile.SSH.PublicKeys", Name: validation.Null, Rule: true, Chain: nil}}},
|
||||
}},
|
||||
{Target: "parameters.ContainerServiceProperties.DiagnosticsProfile", Name: validation.Null, Rule: false,
|
||||
Chain: []validation.Constraint{{Target: "parameters.ContainerServiceProperties.DiagnosticsProfile.VMDiagnostics", Name: validation.Null, Rule: true,
|
||||
Chain: []validation.Constraint{{Target: "parameters.ContainerServiceProperties.DiagnosticsProfile.VMDiagnostics.Enabled", Name: validation.Null, Rule: true, Chain: nil}}},
|
||||
}},
|
||||
}}}}}); err != nil {
|
||||
return result, validation.NewError("compute.ContainerServicesClient", "CreateOrUpdate", err.Error())
|
||||
}
|
||||
|
||||
req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, containerServiceName, parameters)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "compute.ContainerServicesClient", "CreateOrUpdate", nil, "Failure preparing request")
|
||||
return
|
||||
}
|
||||
|
||||
result, err = client.CreateOrUpdateSender(req)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "compute.ContainerServicesClient", "CreateOrUpdate", result.Response(), "Failure sending request")
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// CreateOrUpdatePreparer prepares the CreateOrUpdate request.
|
||||
func (client ContainerServicesClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, containerServiceName string, parameters ContainerService) (*http.Request, error) {
|
||||
pathParameters := map[string]interface{}{
|
||||
"containerServiceName": autorest.Encode("path", containerServiceName),
|
||||
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
||||
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||||
}
|
||||
|
||||
const APIVersion = "2017-01-31"
|
||||
queryParameters := map[string]interface{}{
|
||||
"api-version": APIVersion,
|
||||
}
|
||||
|
||||
preparer := autorest.CreatePreparer(
|
||||
autorest.AsContentType("application/json; charset=utf-8"),
|
||||
autorest.AsPut(),
|
||||
autorest.WithBaseURL(client.BaseURI),
|
||||
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerService/containerServices/{containerServiceName}", pathParameters),
|
||||
autorest.WithJSON(parameters),
|
||||
autorest.WithQueryParameters(queryParameters))
|
||||
return preparer.Prepare((&http.Request{}).WithContext(ctx))
|
||||
}
|
||||
|
||||
// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the
|
||||
// http.Response Body if it receives an error.
|
||||
func (client ContainerServicesClient) CreateOrUpdateSender(req *http.Request) (future ContainerServicesCreateOrUpdateFuture, err error) {
|
||||
var resp *http.Response
|
||||
resp, err = autorest.SendWithSender(client, req,
|
||||
azure.DoRetryWithRegistration(client.Client))
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
err = autorest.Respond(resp, azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted))
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
future.Future, err = azure.NewFutureFromResponse(resp)
|
||||
return
|
||||
}
|
||||
|
||||
// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always
|
||||
// closes the http.Response Body.
|
||||
func (client ContainerServicesClient) CreateOrUpdateResponder(resp *http.Response) (result ContainerService, err error) {
|
||||
err = autorest.Respond(
|
||||
resp,
|
||||
client.ByInspecting(),
|
||||
azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted),
|
||||
autorest.ByUnmarshallingJSON(&result),
|
||||
autorest.ByClosing())
|
||||
result.Response = autorest.Response{Response: resp}
|
||||
return
|
||||
}
|
||||
|
||||
// Delete deletes the specified container service in the specified subscription and resource group. The operation does
|
||||
// not delete other resources created as part of creating a container service, including storage accounts, VMs, and
|
||||
// availability sets. All the other resources created with the container service are part of the same resource group
|
||||
// and can be deleted individually.
|
||||
// Parameters:
|
||||
// resourceGroupName - the name of the resource group.
|
||||
// containerServiceName - the name of the container service in the specified subscription and resource group.
|
||||
func (client ContainerServicesClient) Delete(ctx context.Context, resourceGroupName string, containerServiceName string) (result ContainerServicesDeleteFuture, err error) {
|
||||
req, err := client.DeletePreparer(ctx, resourceGroupName, containerServiceName)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "compute.ContainerServicesClient", "Delete", nil, "Failure preparing request")
|
||||
return
|
||||
}
|
||||
|
||||
result, err = client.DeleteSender(req)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "compute.ContainerServicesClient", "Delete", result.Response(), "Failure sending request")
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// DeletePreparer prepares the Delete request.
|
||||
func (client ContainerServicesClient) DeletePreparer(ctx context.Context, resourceGroupName string, containerServiceName string) (*http.Request, error) {
|
||||
pathParameters := map[string]interface{}{
|
||||
"containerServiceName": autorest.Encode("path", containerServiceName),
|
||||
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
||||
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||||
}
|
||||
|
||||
const APIVersion = "2017-01-31"
|
||||
queryParameters := map[string]interface{}{
|
||||
"api-version": APIVersion,
|
||||
}
|
||||
|
||||
preparer := autorest.CreatePreparer(
|
||||
autorest.AsDelete(),
|
||||
autorest.WithBaseURL(client.BaseURI),
|
||||
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerService/containerServices/{containerServiceName}", pathParameters),
|
||||
autorest.WithQueryParameters(queryParameters))
|
||||
return preparer.Prepare((&http.Request{}).WithContext(ctx))
|
||||
}
|
||||
|
||||
// DeleteSender sends the Delete request. The method will close the
|
||||
// http.Response Body if it receives an error.
|
||||
func (client ContainerServicesClient) DeleteSender(req *http.Request) (future ContainerServicesDeleteFuture, err error) {
|
||||
var resp *http.Response
|
||||
resp, err = autorest.SendWithSender(client, req,
|
||||
azure.DoRetryWithRegistration(client.Client))
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
err = autorest.Respond(resp, azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent))
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
future.Future, err = azure.NewFutureFromResponse(resp)
|
||||
return
|
||||
}
|
||||
|
||||
// DeleteResponder handles the response to the Delete request. The method always
|
||||
// closes the http.Response Body.
|
||||
func (client ContainerServicesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) {
|
||||
err = autorest.Respond(
|
||||
resp,
|
||||
client.ByInspecting(),
|
||||
azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent),
|
||||
autorest.ByClosing())
|
||||
result.Response = resp
|
||||
return
|
||||
}
|
||||
|
||||
// Get gets the properties of the specified container service in the specified subscription and resource group. The
|
||||
// operation returns the properties including state, orchestrator, number of masters and agents, and FQDNs of masters
|
||||
// and agents.
|
||||
// Parameters:
|
||||
// resourceGroupName - the name of the resource group.
|
||||
// containerServiceName - the name of the container service in the specified subscription and resource group.
|
||||
func (client ContainerServicesClient) Get(ctx context.Context, resourceGroupName string, containerServiceName string) (result ContainerService, err error) {
|
||||
req, err := client.GetPreparer(ctx, resourceGroupName, containerServiceName)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "compute.ContainerServicesClient", "Get", nil, "Failure preparing request")
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := client.GetSender(req)
|
||||
if err != nil {
|
||||
result.Response = autorest.Response{Response: resp}
|
||||
err = autorest.NewErrorWithError(err, "compute.ContainerServicesClient", "Get", resp, "Failure sending request")
|
||||
return
|
||||
}
|
||||
|
||||
result, err = client.GetResponder(resp)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "compute.ContainerServicesClient", "Get", resp, "Failure responding to request")
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// GetPreparer prepares the Get request.
|
||||
func (client ContainerServicesClient) GetPreparer(ctx context.Context, resourceGroupName string, containerServiceName string) (*http.Request, error) {
|
||||
pathParameters := map[string]interface{}{
|
||||
"containerServiceName": autorest.Encode("path", containerServiceName),
|
||||
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
||||
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||||
}
|
||||
|
||||
const APIVersion = "2017-01-31"
|
||||
queryParameters := map[string]interface{}{
|
||||
"api-version": APIVersion,
|
||||
}
|
||||
|
||||
preparer := autorest.CreatePreparer(
|
||||
autorest.AsGet(),
|
||||
autorest.WithBaseURL(client.BaseURI),
|
||||
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerService/containerServices/{containerServiceName}", pathParameters),
|
||||
autorest.WithQueryParameters(queryParameters))
|
||||
return preparer.Prepare((&http.Request{}).WithContext(ctx))
|
||||
}
|
||||
|
||||
// GetSender sends the Get request. The method will close the
|
||||
// http.Response Body if it receives an error.
|
||||
func (client ContainerServicesClient) GetSender(req *http.Request) (*http.Response, error) {
|
||||
return autorest.SendWithSender(client, req,
|
||||
azure.DoRetryWithRegistration(client.Client))
|
||||
}
|
||||
|
||||
// GetResponder handles the response to the Get request. The method always
|
||||
// closes the http.Response Body.
|
||||
func (client ContainerServicesClient) GetResponder(resp *http.Response) (result ContainerService, err error) {
|
||||
err = autorest.Respond(
|
||||
resp,
|
||||
client.ByInspecting(),
|
||||
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
||||
autorest.ByUnmarshallingJSON(&result),
|
||||
autorest.ByClosing())
|
||||
result.Response = autorest.Response{Response: resp}
|
||||
return
|
||||
}
|
||||
|
||||
// List gets a list of container services in the specified subscription. The operation returns properties of each
|
||||
// container service including state, orchestrator, number of masters and agents, and FQDNs of masters and agents.
|
||||
func (client ContainerServicesClient) List(ctx context.Context) (result ContainerServiceListResultPage, err error) {
|
||||
result.fn = client.listNextResults
|
||||
req, err := client.ListPreparer(ctx)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "compute.ContainerServicesClient", "List", nil, "Failure preparing request")
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := client.ListSender(req)
|
||||
if err != nil {
|
||||
result.cslr.Response = autorest.Response{Response: resp}
|
||||
err = autorest.NewErrorWithError(err, "compute.ContainerServicesClient", "List", resp, "Failure sending request")
|
||||
return
|
||||
}
|
||||
|
||||
result.cslr, err = client.ListResponder(resp)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "compute.ContainerServicesClient", "List", resp, "Failure responding to request")
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// ListPreparer prepares the List request.
|
||||
func (client ContainerServicesClient) ListPreparer(ctx context.Context) (*http.Request, error) {
|
||||
pathParameters := map[string]interface{}{
|
||||
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||||
}
|
||||
|
||||
const APIVersion = "2017-01-31"
|
||||
queryParameters := map[string]interface{}{
|
||||
"api-version": APIVersion,
|
||||
}
|
||||
|
||||
preparer := autorest.CreatePreparer(
|
||||
autorest.AsGet(),
|
||||
autorest.WithBaseURL(client.BaseURI),
|
||||
autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.ContainerService/containerServices", pathParameters),
|
||||
autorest.WithQueryParameters(queryParameters))
|
||||
return preparer.Prepare((&http.Request{}).WithContext(ctx))
|
||||
}
|
||||
|
||||
// ListSender sends the List request. The method will close the
|
||||
// http.Response Body if it receives an error.
|
||||
func (client ContainerServicesClient) ListSender(req *http.Request) (*http.Response, error) {
|
||||
return autorest.SendWithSender(client, req,
|
||||
azure.DoRetryWithRegistration(client.Client))
|
||||
}
|
||||
|
||||
// ListResponder handles the response to the List request. The method always
|
||||
// closes the http.Response Body.
|
||||
func (client ContainerServicesClient) ListResponder(resp *http.Response) (result ContainerServiceListResult, err error) {
|
||||
err = autorest.Respond(
|
||||
resp,
|
||||
client.ByInspecting(),
|
||||
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
||||
autorest.ByUnmarshallingJSON(&result),
|
||||
autorest.ByClosing())
|
||||
result.Response = autorest.Response{Response: resp}
|
||||
return
|
||||
}
|
||||
|
||||
// listNextResults retrieves the next set of results, if any.
|
||||
func (client ContainerServicesClient) listNextResults(lastResults ContainerServiceListResult) (result ContainerServiceListResult, err error) {
|
||||
req, err := lastResults.containerServiceListResultPreparer()
|
||||
if err != nil {
|
||||
return result, autorest.NewErrorWithError(err, "compute.ContainerServicesClient", "listNextResults", nil, "Failure preparing next results request")
|
||||
}
|
||||
if req == nil {
|
||||
return
|
||||
}
|
||||
resp, err := client.ListSender(req)
|
||||
if err != nil {
|
||||
result.Response = autorest.Response{Response: resp}
|
||||
return result, autorest.NewErrorWithError(err, "compute.ContainerServicesClient", "listNextResults", resp, "Failure sending next results request")
|
||||
}
|
||||
result, err = client.ListResponder(resp)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "compute.ContainerServicesClient", "listNextResults", resp, "Failure responding to next results request")
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// ListComplete enumerates all values, automatically crossing page boundaries as required.
|
||||
func (client ContainerServicesClient) ListComplete(ctx context.Context) (result ContainerServiceListResultIterator, err error) {
|
||||
result.page, err = client.List(ctx)
|
||||
return
|
||||
}
|
||||
|
||||
// ListByResourceGroup gets a list of container services in the specified subscription and resource group. The
|
||||
// operation returns properties of each container service including state, orchestrator, number of masters and agents,
|
||||
// and FQDNs of masters and agents.
|
||||
// Parameters:
|
||||
// resourceGroupName - the name of the resource group.
|
||||
func (client ContainerServicesClient) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result ContainerServiceListResultPage, err error) {
|
||||
result.fn = client.listByResourceGroupNextResults
|
||||
req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "compute.ContainerServicesClient", "ListByResourceGroup", nil, "Failure preparing request")
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := client.ListByResourceGroupSender(req)
|
||||
if err != nil {
|
||||
result.cslr.Response = autorest.Response{Response: resp}
|
||||
err = autorest.NewErrorWithError(err, "compute.ContainerServicesClient", "ListByResourceGroup", resp, "Failure sending request")
|
||||
return
|
||||
}
|
||||
|
||||
result.cslr, err = client.ListByResourceGroupResponder(resp)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "compute.ContainerServicesClient", "ListByResourceGroup", resp, "Failure responding to request")
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// ListByResourceGroupPreparer prepares the ListByResourceGroup request.
|
||||
func (client ContainerServicesClient) ListByResourceGroupPreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) {
|
||||
pathParameters := map[string]interface{}{
|
||||
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
||||
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||||
}
|
||||
|
||||
const APIVersion = "2017-01-31"
|
||||
queryParameters := map[string]interface{}{
|
||||
"api-version": APIVersion,
|
||||
}
|
||||
|
||||
preparer := autorest.CreatePreparer(
|
||||
autorest.AsGet(),
|
||||
autorest.WithBaseURL(client.BaseURI),
|
||||
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerService/containerServices", pathParameters),
|
||||
autorest.WithQueryParameters(queryParameters))
|
||||
return preparer.Prepare((&http.Request{}).WithContext(ctx))
|
||||
}
|
||||
|
||||
// ListByResourceGroupSender sends the ListByResourceGroup request. The method will close the
|
||||
// http.Response Body if it receives an error.
|
||||
func (client ContainerServicesClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) {
|
||||
return autorest.SendWithSender(client, req,
|
||||
azure.DoRetryWithRegistration(client.Client))
|
||||
}
|
||||
|
||||
// ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always
|
||||
// closes the http.Response Body.
|
||||
func (client ContainerServicesClient) ListByResourceGroupResponder(resp *http.Response) (result ContainerServiceListResult, err error) {
|
||||
err = autorest.Respond(
|
||||
resp,
|
||||
client.ByInspecting(),
|
||||
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
||||
autorest.ByUnmarshallingJSON(&result),
|
||||
autorest.ByClosing())
|
||||
result.Response = autorest.Response{Response: resp}
|
||||
return
|
||||
}
|
||||
|
||||
// listByResourceGroupNextResults retrieves the next set of results, if any.
|
||||
func (client ContainerServicesClient) listByResourceGroupNextResults(lastResults ContainerServiceListResult) (result ContainerServiceListResult, err error) {
|
||||
req, err := lastResults.containerServiceListResultPreparer()
|
||||
if err != nil {
|
||||
return result, autorest.NewErrorWithError(err, "compute.ContainerServicesClient", "listByResourceGroupNextResults", nil, "Failure preparing next results request")
|
||||
}
|
||||
if req == nil {
|
||||
return
|
||||
}
|
||||
resp, err := client.ListByResourceGroupSender(req)
|
||||
if err != nil {
|
||||
result.Response = autorest.Response{Response: resp}
|
||||
return result, autorest.NewErrorWithError(err, "compute.ContainerServicesClient", "listByResourceGroupNextResults", resp, "Failure sending next results request")
|
||||
}
|
||||
result, err = client.ListByResourceGroupResponder(resp)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "compute.ContainerServicesClient", "listByResourceGroupNextResults", resp, "Failure responding to next results request")
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// ListByResourceGroupComplete enumerates all values, automatically crossing page boundaries as required.
|
||||
func (client ContainerServicesClient) ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result ContainerServiceListResultIterator, err error) {
|
||||
result.page, err = client.ListByResourceGroup(ctx, resourceGroupName)
|
||||
return
|
||||
}
|
||||
692
vendor/github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-06-01/compute/disks.go
generated
vendored
Normal file
692
vendor/github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-06-01/compute/disks.go
generated
vendored
Normal file
@@ -0,0 +1,692 @@
|
||||
package compute
|
||||
|
||||
// Copyright (c) Microsoft and contributors. All rights reserved.
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
// Code generated by Microsoft (R) AutoRest Code Generator.
|
||||
// Changes may cause incorrect behavior and will be lost if the code is regenerated.
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/Azure/go-autorest/autorest"
|
||||
"github.com/Azure/go-autorest/autorest/azure"
|
||||
"github.com/Azure/go-autorest/autorest/validation"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
// DisksClient is the compute Client
|
||||
type DisksClient struct {
|
||||
BaseClient
|
||||
}
|
||||
|
||||
// NewDisksClient creates an instance of the DisksClient client.
|
||||
func NewDisksClient(subscriptionID string) DisksClient {
|
||||
return NewDisksClientWithBaseURI(DefaultBaseURI, subscriptionID)
|
||||
}
|
||||
|
||||
// NewDisksClientWithBaseURI creates an instance of the DisksClient client.
|
||||
func NewDisksClientWithBaseURI(baseURI string, subscriptionID string) DisksClient {
|
||||
return DisksClient{NewWithBaseURI(baseURI, subscriptionID)}
|
||||
}
|
||||
|
||||
// CreateOrUpdate creates or updates a disk.
|
||||
// Parameters:
|
||||
// resourceGroupName - the name of the resource group.
|
||||
// diskName - the name of the managed disk that is being created. The name can't be changed after the disk is
|
||||
// created. Supported characters for the name are a-z, A-Z, 0-9 and _. The maximum name length is 80
|
||||
// characters.
|
||||
// disk - disk object supplied in the body of the Put disk operation.
|
||||
func (client DisksClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, diskName string, disk Disk) (result DisksCreateOrUpdateFuture, err error) {
|
||||
if err := validation.Validate([]validation.Validation{
|
||||
{TargetValue: disk,
|
||||
Constraints: []validation.Constraint{{Target: "disk.DiskProperties", Name: validation.Null, Rule: false,
|
||||
Chain: []validation.Constraint{{Target: "disk.DiskProperties.CreationData", Name: validation.Null, Rule: true,
|
||||
Chain: []validation.Constraint{{Target: "disk.DiskProperties.CreationData.ImageReference", Name: validation.Null, Rule: false,
|
||||
Chain: []validation.Constraint{{Target: "disk.DiskProperties.CreationData.ImageReference.ID", Name: validation.Null, Rule: true, Chain: nil}}},
|
||||
}},
|
||||
{Target: "disk.DiskProperties.EncryptionSettings", Name: validation.Null, Rule: false,
|
||||
Chain: []validation.Constraint{{Target: "disk.DiskProperties.EncryptionSettings.DiskEncryptionKey", Name: validation.Null, Rule: false,
|
||||
Chain: []validation.Constraint{{Target: "disk.DiskProperties.EncryptionSettings.DiskEncryptionKey.SourceVault", Name: validation.Null, Rule: true, Chain: nil},
|
||||
{Target: "disk.DiskProperties.EncryptionSettings.DiskEncryptionKey.SecretURL", Name: validation.Null, Rule: true, Chain: nil},
|
||||
}},
|
||||
{Target: "disk.DiskProperties.EncryptionSettings.KeyEncryptionKey", Name: validation.Null, Rule: false,
|
||||
Chain: []validation.Constraint{{Target: "disk.DiskProperties.EncryptionSettings.KeyEncryptionKey.SourceVault", Name: validation.Null, Rule: true, Chain: nil},
|
||||
{Target: "disk.DiskProperties.EncryptionSettings.KeyEncryptionKey.KeyURL", Name: validation.Null, Rule: true, Chain: nil},
|
||||
}},
|
||||
}},
|
||||
}}}}}); err != nil {
|
||||
return result, validation.NewError("compute.DisksClient", "CreateOrUpdate", err.Error())
|
||||
}
|
||||
|
||||
req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, diskName, disk)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "compute.DisksClient", "CreateOrUpdate", nil, "Failure preparing request")
|
||||
return
|
||||
}
|
||||
|
||||
result, err = client.CreateOrUpdateSender(req)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "compute.DisksClient", "CreateOrUpdate", result.Response(), "Failure sending request")
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// CreateOrUpdatePreparer prepares the CreateOrUpdate request.
|
||||
func (client DisksClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, diskName string, disk Disk) (*http.Request, error) {
|
||||
pathParameters := map[string]interface{}{
|
||||
"diskName": autorest.Encode("path", diskName),
|
||||
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
||||
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||||
}
|
||||
|
||||
const APIVersion = "2018-06-01"
|
||||
queryParameters := map[string]interface{}{
|
||||
"api-version": APIVersion,
|
||||
}
|
||||
|
||||
preparer := autorest.CreatePreparer(
|
||||
autorest.AsContentType("application/json; charset=utf-8"),
|
||||
autorest.AsPut(),
|
||||
autorest.WithBaseURL(client.BaseURI),
|
||||
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}", pathParameters),
|
||||
autorest.WithJSON(disk),
|
||||
autorest.WithQueryParameters(queryParameters))
|
||||
return preparer.Prepare((&http.Request{}).WithContext(ctx))
|
||||
}
|
||||
|
||||
// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the
|
||||
// http.Response Body if it receives an error.
|
||||
func (client DisksClient) CreateOrUpdateSender(req *http.Request) (future DisksCreateOrUpdateFuture, err error) {
|
||||
var resp *http.Response
|
||||
resp, err = autorest.SendWithSender(client, req,
|
||||
azure.DoRetryWithRegistration(client.Client))
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
err = autorest.Respond(resp, azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted))
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
future.Future, err = azure.NewFutureFromResponse(resp)
|
||||
return
|
||||
}
|
||||
|
||||
// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always
|
||||
// closes the http.Response Body.
|
||||
func (client DisksClient) CreateOrUpdateResponder(resp *http.Response) (result Disk, err error) {
|
||||
err = autorest.Respond(
|
||||
resp,
|
||||
client.ByInspecting(),
|
||||
azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
|
||||
autorest.ByUnmarshallingJSON(&result),
|
||||
autorest.ByClosing())
|
||||
result.Response = autorest.Response{Response: resp}
|
||||
return
|
||||
}
|
||||
|
||||
// Delete deletes a disk.
|
||||
// Parameters:
|
||||
// resourceGroupName - the name of the resource group.
|
||||
// diskName - the name of the managed disk that is being created. The name can't be changed after the disk is
|
||||
// created. Supported characters for the name are a-z, A-Z, 0-9 and _. The maximum name length is 80
|
||||
// characters.
|
||||
func (client DisksClient) Delete(ctx context.Context, resourceGroupName string, diskName string) (result DisksDeleteFuture, err error) {
|
||||
req, err := client.DeletePreparer(ctx, resourceGroupName, diskName)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "compute.DisksClient", "Delete", nil, "Failure preparing request")
|
||||
return
|
||||
}
|
||||
|
||||
result, err = client.DeleteSender(req)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "compute.DisksClient", "Delete", result.Response(), "Failure sending request")
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// DeletePreparer prepares the Delete request.
|
||||
func (client DisksClient) DeletePreparer(ctx context.Context, resourceGroupName string, diskName string) (*http.Request, error) {
|
||||
pathParameters := map[string]interface{}{
|
||||
"diskName": autorest.Encode("path", diskName),
|
||||
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
||||
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||||
}
|
||||
|
||||
const APIVersion = "2018-06-01"
|
||||
queryParameters := map[string]interface{}{
|
||||
"api-version": APIVersion,
|
||||
}
|
||||
|
||||
preparer := autorest.CreatePreparer(
|
||||
autorest.AsDelete(),
|
||||
autorest.WithBaseURL(client.BaseURI),
|
||||
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}", pathParameters),
|
||||
autorest.WithQueryParameters(queryParameters))
|
||||
return preparer.Prepare((&http.Request{}).WithContext(ctx))
|
||||
}
|
||||
|
||||
// DeleteSender sends the Delete request. The method will close the
|
||||
// http.Response Body if it receives an error.
|
||||
func (client DisksClient) DeleteSender(req *http.Request) (future DisksDeleteFuture, err error) {
|
||||
var resp *http.Response
|
||||
resp, err = autorest.SendWithSender(client, req,
|
||||
azure.DoRetryWithRegistration(client.Client))
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
err = autorest.Respond(resp, azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent))
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
future.Future, err = azure.NewFutureFromResponse(resp)
|
||||
return
|
||||
}
|
||||
|
||||
// DeleteResponder handles the response to the Delete request. The method always
|
||||
// closes the http.Response Body.
|
||||
func (client DisksClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) {
|
||||
err = autorest.Respond(
|
||||
resp,
|
||||
client.ByInspecting(),
|
||||
azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent),
|
||||
autorest.ByClosing())
|
||||
result.Response = resp
|
||||
return
|
||||
}
|
||||
|
||||
// Get gets information about a disk.
|
||||
// Parameters:
|
||||
// resourceGroupName - the name of the resource group.
|
||||
// diskName - the name of the managed disk that is being created. The name can't be changed after the disk is
|
||||
// created. Supported characters for the name are a-z, A-Z, 0-9 and _. The maximum name length is 80
|
||||
// characters.
|
||||
func (client DisksClient) Get(ctx context.Context, resourceGroupName string, diskName string) (result Disk, err error) {
|
||||
req, err := client.GetPreparer(ctx, resourceGroupName, diskName)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "compute.DisksClient", "Get", nil, "Failure preparing request")
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := client.GetSender(req)
|
||||
if err != nil {
|
||||
result.Response = autorest.Response{Response: resp}
|
||||
err = autorest.NewErrorWithError(err, "compute.DisksClient", "Get", resp, "Failure sending request")
|
||||
return
|
||||
}
|
||||
|
||||
result, err = client.GetResponder(resp)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "compute.DisksClient", "Get", resp, "Failure responding to request")
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// GetPreparer prepares the Get request.
|
||||
func (client DisksClient) GetPreparer(ctx context.Context, resourceGroupName string, diskName string) (*http.Request, error) {
|
||||
pathParameters := map[string]interface{}{
|
||||
"diskName": autorest.Encode("path", diskName),
|
||||
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
||||
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||||
}
|
||||
|
||||
const APIVersion = "2018-06-01"
|
||||
queryParameters := map[string]interface{}{
|
||||
"api-version": APIVersion,
|
||||
}
|
||||
|
||||
preparer := autorest.CreatePreparer(
|
||||
autorest.AsGet(),
|
||||
autorest.WithBaseURL(client.BaseURI),
|
||||
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}", pathParameters),
|
||||
autorest.WithQueryParameters(queryParameters))
|
||||
return preparer.Prepare((&http.Request{}).WithContext(ctx))
|
||||
}
|
||||
|
||||
// GetSender sends the Get request. The method will close the
|
||||
// http.Response Body if it receives an error.
|
||||
func (client DisksClient) GetSender(req *http.Request) (*http.Response, error) {
|
||||
return autorest.SendWithSender(client, req,
|
||||
azure.DoRetryWithRegistration(client.Client))
|
||||
}
|
||||
|
||||
// GetResponder handles the response to the Get request. The method always
|
||||
// closes the http.Response Body.
|
||||
func (client DisksClient) GetResponder(resp *http.Response) (result Disk, err error) {
|
||||
err = autorest.Respond(
|
||||
resp,
|
||||
client.ByInspecting(),
|
||||
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
||||
autorest.ByUnmarshallingJSON(&result),
|
||||
autorest.ByClosing())
|
||||
result.Response = autorest.Response{Response: resp}
|
||||
return
|
||||
}
|
||||
|
||||
// GrantAccess grants access to a disk.
|
||||
// Parameters:
|
||||
// resourceGroupName - the name of the resource group.
|
||||
// diskName - the name of the managed disk that is being created. The name can't be changed after the disk is
|
||||
// created. Supported characters for the name are a-z, A-Z, 0-9 and _. The maximum name length is 80
|
||||
// characters.
|
||||
// grantAccessData - access data object supplied in the body of the get disk access operation.
|
||||
func (client DisksClient) GrantAccess(ctx context.Context, resourceGroupName string, diskName string, grantAccessData GrantAccessData) (result DisksGrantAccessFuture, err error) {
|
||||
if err := validation.Validate([]validation.Validation{
|
||||
{TargetValue: grantAccessData,
|
||||
Constraints: []validation.Constraint{{Target: "grantAccessData.DurationInSeconds", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil {
|
||||
return result, validation.NewError("compute.DisksClient", "GrantAccess", err.Error())
|
||||
}
|
||||
|
||||
req, err := client.GrantAccessPreparer(ctx, resourceGroupName, diskName, grantAccessData)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "compute.DisksClient", "GrantAccess", nil, "Failure preparing request")
|
||||
return
|
||||
}
|
||||
|
||||
result, err = client.GrantAccessSender(req)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "compute.DisksClient", "GrantAccess", result.Response(), "Failure sending request")
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// GrantAccessPreparer prepares the GrantAccess request.
|
||||
func (client DisksClient) GrantAccessPreparer(ctx context.Context, resourceGroupName string, diskName string, grantAccessData GrantAccessData) (*http.Request, error) {
|
||||
pathParameters := map[string]interface{}{
|
||||
"diskName": autorest.Encode("path", diskName),
|
||||
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
||||
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||||
}
|
||||
|
||||
const APIVersion = "2018-06-01"
|
||||
queryParameters := map[string]interface{}{
|
||||
"api-version": APIVersion,
|
||||
}
|
||||
|
||||
preparer := autorest.CreatePreparer(
|
||||
autorest.AsContentType("application/json; charset=utf-8"),
|
||||
autorest.AsPost(),
|
||||
autorest.WithBaseURL(client.BaseURI),
|
||||
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}/beginGetAccess", pathParameters),
|
||||
autorest.WithJSON(grantAccessData),
|
||||
autorest.WithQueryParameters(queryParameters))
|
||||
return preparer.Prepare((&http.Request{}).WithContext(ctx))
|
||||
}
|
||||
|
||||
// GrantAccessSender sends the GrantAccess request. The method will close the
|
||||
// http.Response Body if it receives an error.
|
||||
func (client DisksClient) GrantAccessSender(req *http.Request) (future DisksGrantAccessFuture, err error) {
|
||||
var resp *http.Response
|
||||
resp, err = autorest.SendWithSender(client, req,
|
||||
azure.DoRetryWithRegistration(client.Client))
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
err = autorest.Respond(resp, azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted))
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
future.Future, err = azure.NewFutureFromResponse(resp)
|
||||
return
|
||||
}
|
||||
|
||||
// GrantAccessResponder handles the response to the GrantAccess request. The method always
|
||||
// closes the http.Response Body.
|
||||
func (client DisksClient) GrantAccessResponder(resp *http.Response) (result AccessURI, err error) {
|
||||
err = autorest.Respond(
|
||||
resp,
|
||||
client.ByInspecting(),
|
||||
azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
|
||||
autorest.ByUnmarshallingJSON(&result),
|
||||
autorest.ByClosing())
|
||||
result.Response = autorest.Response{Response: resp}
|
||||
return
|
||||
}
|
||||
|
||||
// List lists all the disks under a subscription.
|
||||
func (client DisksClient) List(ctx context.Context) (result DiskListPage, err error) {
|
||||
result.fn = client.listNextResults
|
||||
req, err := client.ListPreparer(ctx)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "compute.DisksClient", "List", nil, "Failure preparing request")
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := client.ListSender(req)
|
||||
if err != nil {
|
||||
result.dl.Response = autorest.Response{Response: resp}
|
||||
err = autorest.NewErrorWithError(err, "compute.DisksClient", "List", resp, "Failure sending request")
|
||||
return
|
||||
}
|
||||
|
||||
result.dl, err = client.ListResponder(resp)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "compute.DisksClient", "List", resp, "Failure responding to request")
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// ListPreparer prepares the List request.
|
||||
func (client DisksClient) ListPreparer(ctx context.Context) (*http.Request, error) {
|
||||
pathParameters := map[string]interface{}{
|
||||
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||||
}
|
||||
|
||||
const APIVersion = "2018-06-01"
|
||||
queryParameters := map[string]interface{}{
|
||||
"api-version": APIVersion,
|
||||
}
|
||||
|
||||
preparer := autorest.CreatePreparer(
|
||||
autorest.AsGet(),
|
||||
autorest.WithBaseURL(client.BaseURI),
|
||||
autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Compute/disks", pathParameters),
|
||||
autorest.WithQueryParameters(queryParameters))
|
||||
return preparer.Prepare((&http.Request{}).WithContext(ctx))
|
||||
}
|
||||
|
||||
// ListSender sends the List request. The method will close the
|
||||
// http.Response Body if it receives an error.
|
||||
func (client DisksClient) ListSender(req *http.Request) (*http.Response, error) {
|
||||
return autorest.SendWithSender(client, req,
|
||||
azure.DoRetryWithRegistration(client.Client))
|
||||
}
|
||||
|
||||
// ListResponder handles the response to the List request. The method always
|
||||
// closes the http.Response Body.
|
||||
func (client DisksClient) ListResponder(resp *http.Response) (result DiskList, err error) {
|
||||
err = autorest.Respond(
|
||||
resp,
|
||||
client.ByInspecting(),
|
||||
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
||||
autorest.ByUnmarshallingJSON(&result),
|
||||
autorest.ByClosing())
|
||||
result.Response = autorest.Response{Response: resp}
|
||||
return
|
||||
}
|
||||
|
||||
// listNextResults retrieves the next set of results, if any.
|
||||
func (client DisksClient) listNextResults(lastResults DiskList) (result DiskList, err error) {
|
||||
req, err := lastResults.diskListPreparer()
|
||||
if err != nil {
|
||||
return result, autorest.NewErrorWithError(err, "compute.DisksClient", "listNextResults", nil, "Failure preparing next results request")
|
||||
}
|
||||
if req == nil {
|
||||
return
|
||||
}
|
||||
resp, err := client.ListSender(req)
|
||||
if err != nil {
|
||||
result.Response = autorest.Response{Response: resp}
|
||||
return result, autorest.NewErrorWithError(err, "compute.DisksClient", "listNextResults", resp, "Failure sending next results request")
|
||||
}
|
||||
result, err = client.ListResponder(resp)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "compute.DisksClient", "listNextResults", resp, "Failure responding to next results request")
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// ListComplete enumerates all values, automatically crossing page boundaries as required.
|
||||
func (client DisksClient) ListComplete(ctx context.Context) (result DiskListIterator, err error) {
|
||||
result.page, err = client.List(ctx)
|
||||
return
|
||||
}
|
||||
|
||||
// ListByResourceGroup lists all the disks under a resource group.
|
||||
// Parameters:
|
||||
// resourceGroupName - the name of the resource group.
|
||||
func (client DisksClient) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result DiskListPage, err error) {
|
||||
result.fn = client.listByResourceGroupNextResults
|
||||
req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "compute.DisksClient", "ListByResourceGroup", nil, "Failure preparing request")
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := client.ListByResourceGroupSender(req)
|
||||
if err != nil {
|
||||
result.dl.Response = autorest.Response{Response: resp}
|
||||
err = autorest.NewErrorWithError(err, "compute.DisksClient", "ListByResourceGroup", resp, "Failure sending request")
|
||||
return
|
||||
}
|
||||
|
||||
result.dl, err = client.ListByResourceGroupResponder(resp)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "compute.DisksClient", "ListByResourceGroup", resp, "Failure responding to request")
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// ListByResourceGroupPreparer prepares the ListByResourceGroup request.
|
||||
func (client DisksClient) ListByResourceGroupPreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) {
|
||||
pathParameters := map[string]interface{}{
|
||||
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
||||
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||||
}
|
||||
|
||||
const APIVersion = "2018-06-01"
|
||||
queryParameters := map[string]interface{}{
|
||||
"api-version": APIVersion,
|
||||
}
|
||||
|
||||
preparer := autorest.CreatePreparer(
|
||||
autorest.AsGet(),
|
||||
autorest.WithBaseURL(client.BaseURI),
|
||||
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks", pathParameters),
|
||||
autorest.WithQueryParameters(queryParameters))
|
||||
return preparer.Prepare((&http.Request{}).WithContext(ctx))
|
||||
}
|
||||
|
||||
// ListByResourceGroupSender sends the ListByResourceGroup request. The method will close the
|
||||
// http.Response Body if it receives an error.
|
||||
func (client DisksClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) {
|
||||
return autorest.SendWithSender(client, req,
|
||||
azure.DoRetryWithRegistration(client.Client))
|
||||
}
|
||||
|
||||
// ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always
|
||||
// closes the http.Response Body.
|
||||
func (client DisksClient) ListByResourceGroupResponder(resp *http.Response) (result DiskList, err error) {
|
||||
err = autorest.Respond(
|
||||
resp,
|
||||
client.ByInspecting(),
|
||||
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
||||
autorest.ByUnmarshallingJSON(&result),
|
||||
autorest.ByClosing())
|
||||
result.Response = autorest.Response{Response: resp}
|
||||
return
|
||||
}
|
||||
|
||||
// listByResourceGroupNextResults retrieves the next set of results, if any.
|
||||
func (client DisksClient) listByResourceGroupNextResults(lastResults DiskList) (result DiskList, err error) {
|
||||
req, err := lastResults.diskListPreparer()
|
||||
if err != nil {
|
||||
return result, autorest.NewErrorWithError(err, "compute.DisksClient", "listByResourceGroupNextResults", nil, "Failure preparing next results request")
|
||||
}
|
||||
if req == nil {
|
||||
return
|
||||
}
|
||||
resp, err := client.ListByResourceGroupSender(req)
|
||||
if err != nil {
|
||||
result.Response = autorest.Response{Response: resp}
|
||||
return result, autorest.NewErrorWithError(err, "compute.DisksClient", "listByResourceGroupNextResults", resp, "Failure sending next results request")
|
||||
}
|
||||
result, err = client.ListByResourceGroupResponder(resp)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "compute.DisksClient", "listByResourceGroupNextResults", resp, "Failure responding to next results request")
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// ListByResourceGroupComplete enumerates all values, automatically crossing page boundaries as required.
|
||||
func (client DisksClient) ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result DiskListIterator, err error) {
|
||||
result.page, err = client.ListByResourceGroup(ctx, resourceGroupName)
|
||||
return
|
||||
}
|
||||
|
||||
// RevokeAccess revokes access to a disk.
|
||||
// Parameters:
|
||||
// resourceGroupName - the name of the resource group.
|
||||
// diskName - the name of the managed disk that is being created. The name can't be changed after the disk is
|
||||
// created. Supported characters for the name are a-z, A-Z, 0-9 and _. The maximum name length is 80
|
||||
// characters.
|
||||
func (client DisksClient) RevokeAccess(ctx context.Context, resourceGroupName string, diskName string) (result DisksRevokeAccessFuture, err error) {
|
||||
req, err := client.RevokeAccessPreparer(ctx, resourceGroupName, diskName)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "compute.DisksClient", "RevokeAccess", nil, "Failure preparing request")
|
||||
return
|
||||
}
|
||||
|
||||
result, err = client.RevokeAccessSender(req)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "compute.DisksClient", "RevokeAccess", result.Response(), "Failure sending request")
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// RevokeAccessPreparer prepares the RevokeAccess request.
|
||||
func (client DisksClient) RevokeAccessPreparer(ctx context.Context, resourceGroupName string, diskName string) (*http.Request, error) {
|
||||
pathParameters := map[string]interface{}{
|
||||
"diskName": autorest.Encode("path", diskName),
|
||||
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
||||
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||||
}
|
||||
|
||||
const APIVersion = "2018-06-01"
|
||||
queryParameters := map[string]interface{}{
|
||||
"api-version": APIVersion,
|
||||
}
|
||||
|
||||
preparer := autorest.CreatePreparer(
|
||||
autorest.AsPost(),
|
||||
autorest.WithBaseURL(client.BaseURI),
|
||||
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}/endGetAccess", pathParameters),
|
||||
autorest.WithQueryParameters(queryParameters))
|
||||
return preparer.Prepare((&http.Request{}).WithContext(ctx))
|
||||
}
|
||||
|
||||
// RevokeAccessSender sends the RevokeAccess request. The method will close the
|
||||
// http.Response Body if it receives an error.
|
||||
func (client DisksClient) RevokeAccessSender(req *http.Request) (future DisksRevokeAccessFuture, err error) {
|
||||
var resp *http.Response
|
||||
resp, err = autorest.SendWithSender(client, req,
|
||||
azure.DoRetryWithRegistration(client.Client))
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
err = autorest.Respond(resp, azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted))
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
future.Future, err = azure.NewFutureFromResponse(resp)
|
||||
return
|
||||
}
|
||||
|
||||
// RevokeAccessResponder handles the response to the RevokeAccess request. The method always
|
||||
// closes the http.Response Body.
|
||||
func (client DisksClient) RevokeAccessResponder(resp *http.Response) (result autorest.Response, err error) {
|
||||
err = autorest.Respond(
|
||||
resp,
|
||||
client.ByInspecting(),
|
||||
azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
|
||||
autorest.ByClosing())
|
||||
result.Response = resp
|
||||
return
|
||||
}
|
||||
|
||||
// Update updates (patches) a disk.
|
||||
// Parameters:
|
||||
// resourceGroupName - the name of the resource group.
|
||||
// diskName - the name of the managed disk that is being created. The name can't be changed after the disk is
|
||||
// created. Supported characters for the name are a-z, A-Z, 0-9 and _. The maximum name length is 80
|
||||
// characters.
|
||||
// disk - disk object supplied in the body of the Patch disk operation.
|
||||
func (client DisksClient) Update(ctx context.Context, resourceGroupName string, diskName string, disk DiskUpdate) (result DisksUpdateFuture, err error) {
|
||||
req, err := client.UpdatePreparer(ctx, resourceGroupName, diskName, disk)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "compute.DisksClient", "Update", nil, "Failure preparing request")
|
||||
return
|
||||
}
|
||||
|
||||
result, err = client.UpdateSender(req)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "compute.DisksClient", "Update", result.Response(), "Failure sending request")
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// UpdatePreparer prepares the Update request.
|
||||
func (client DisksClient) UpdatePreparer(ctx context.Context, resourceGroupName string, diskName string, disk DiskUpdate) (*http.Request, error) {
|
||||
pathParameters := map[string]interface{}{
|
||||
"diskName": autorest.Encode("path", diskName),
|
||||
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
||||
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||||
}
|
||||
|
||||
const APIVersion = "2018-06-01"
|
||||
queryParameters := map[string]interface{}{
|
||||
"api-version": APIVersion,
|
||||
}
|
||||
|
||||
preparer := autorest.CreatePreparer(
|
||||
autorest.AsContentType("application/json; charset=utf-8"),
|
||||
autorest.AsPatch(),
|
||||
autorest.WithBaseURL(client.BaseURI),
|
||||
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}", pathParameters),
|
||||
autorest.WithJSON(disk),
|
||||
autorest.WithQueryParameters(queryParameters))
|
||||
return preparer.Prepare((&http.Request{}).WithContext(ctx))
|
||||
}
|
||||
|
||||
// UpdateSender sends the Update request. The method will close the
|
||||
// http.Response Body if it receives an error.
|
||||
func (client DisksClient) UpdateSender(req *http.Request) (future DisksUpdateFuture, err error) {
|
||||
var resp *http.Response
|
||||
resp, err = autorest.SendWithSender(client, req,
|
||||
azure.DoRetryWithRegistration(client.Client))
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
err = autorest.Respond(resp, azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted))
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
future.Future, err = azure.NewFutureFromResponse(resp)
|
||||
return
|
||||
}
|
||||
|
||||
// UpdateResponder handles the response to the Update request. The method always
|
||||
// closes the http.Response Body.
|
||||
func (client DisksClient) UpdateResponder(resp *http.Response) (result Disk, err error) {
|
||||
err = autorest.Respond(
|
||||
resp,
|
||||
client.ByInspecting(),
|
||||
azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
|
||||
autorest.ByUnmarshallingJSON(&result),
|
||||
autorest.ByClosing())
|
||||
result.Response = autorest.Response{Response: resp}
|
||||
return
|
||||
}
|
||||
@@ -39,11 +39,12 @@ func NewGalleriesClientWithBaseURI(baseURI string, subscriptionID string) Galler
|
||||
return GalleriesClient{NewWithBaseURI(baseURI, subscriptionID)}
|
||||
}
|
||||
|
||||
// CreateOrUpdate create or update a gallery.
|
||||
// CreateOrUpdate create or update a Shared Image Gallery.
|
||||
// Parameters:
|
||||
// resourceGroupName - the name of the resource group.
|
||||
// galleryName - the name of the gallery.
|
||||
// gallery - parameters supplied to the create or update gallery operation.
|
||||
// galleryName - the name of the Shared Image Gallery. The allowed characters are alphabets and numbers with
|
||||
// dots and periods allowed in the middle. The maximum length is 80 characters.
|
||||
// gallery - parameters supplied to the create or update Shared Image Gallery operation.
|
||||
func (client GalleriesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, galleryName string, gallery Gallery) (result GalleriesCreateOrUpdateFuture, err error) {
|
||||
req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, galleryName, gallery)
|
||||
if err != nil {
|
||||
@@ -113,10 +114,10 @@ func (client GalleriesClient) CreateOrUpdateResponder(resp *http.Response) (resu
|
||||
return
|
||||
}
|
||||
|
||||
// Delete delete a gallery.
|
||||
// Delete delete a Shared Image Gallery.
|
||||
// Parameters:
|
||||
// resourceGroupName - the name of the resource group.
|
||||
// galleryName - the name of the gallery.
|
||||
// galleryName - the name of the Shared Image Gallery to be deleted.
|
||||
func (client GalleriesClient) Delete(ctx context.Context, resourceGroupName string, galleryName string) (result GalleriesDeleteFuture, err error) {
|
||||
req, err := client.DeletePreparer(ctx, resourceGroupName, galleryName)
|
||||
if err != nil {
|
||||
@@ -183,10 +184,10 @@ func (client GalleriesClient) DeleteResponder(resp *http.Response) (result autor
|
||||
return
|
||||
}
|
||||
|
||||
// Get retrieves information about a gallery.
|
||||
// Get retrieves information about a Shared Image Gallery.
|
||||
// Parameters:
|
||||
// resourceGroupName - the name of the resource group.
|
||||
// galleryName - the name of the gallery.
|
||||
// galleryName - the name of the Shared Image Gallery.
|
||||
func (client GalleriesClient) Get(ctx context.Context, resourceGroupName string, galleryName string) (result Gallery, err error) {
|
||||
req, err := client.GetPreparer(ctx, resourceGroupName, galleryName)
|
||||
if err != nil {
|
||||
|
||||
@@ -21,6 +21,7 @@ import (
|
||||
"context"
|
||||
"github.com/Azure/go-autorest/autorest"
|
||||
"github.com/Azure/go-autorest/autorest/azure"
|
||||
"github.com/Azure/go-autorest/autorest/validation"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
@@ -39,13 +40,27 @@ func NewGalleryImagesClientWithBaseURI(baseURI string, subscriptionID string) Ga
|
||||
return GalleryImagesClient{NewWithBaseURI(baseURI, subscriptionID)}
|
||||
}
|
||||
|
||||
// CreateOrUpdate create or update a gallery image.
|
||||
// CreateOrUpdate create or update a gallery Image Definition.
|
||||
// Parameters:
|
||||
// resourceGroupName - the name of the resource group.
|
||||
// galleryName - the name of the gallery.
|
||||
// galleryImageName - the name of the gallery image.
|
||||
// galleryName - the name of the Shared Image Gallery in which the Image Definition is to be created.
|
||||
// galleryImageName - the name of the gallery Image Definition to be created or updated. The allowed characters
|
||||
// are alphabets and numbers with dots, dashes, and periods allowed in the middle. The maximum length is 80
|
||||
// characters.
|
||||
// galleryImage - parameters supplied to the create or update gallery image operation.
|
||||
func (client GalleryImagesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, galleryName string, galleryImageName string, galleryImage GalleryImage) (result GalleryImagesCreateOrUpdateFuture, err error) {
|
||||
if err := validation.Validate([]validation.Validation{
|
||||
{TargetValue: galleryImage,
|
||||
Constraints: []validation.Constraint{{Target: "galleryImage.GalleryImageProperties", Name: validation.Null, Rule: false,
|
||||
Chain: []validation.Constraint{{Target: "galleryImage.GalleryImageProperties.Identifier", Name: validation.Null, Rule: true,
|
||||
Chain: []validation.Constraint{{Target: "galleryImage.GalleryImageProperties.Identifier.Publisher", Name: validation.Null, Rule: true, Chain: nil},
|
||||
{Target: "galleryImage.GalleryImageProperties.Identifier.Offer", Name: validation.Null, Rule: true, Chain: nil},
|
||||
{Target: "galleryImage.GalleryImageProperties.Identifier.Sku", Name: validation.Null, Rule: true, Chain: nil},
|
||||
}},
|
||||
}}}}}); err != nil {
|
||||
return result, validation.NewError("compute.GalleryImagesClient", "CreateOrUpdate", err.Error())
|
||||
}
|
||||
|
||||
req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, galleryName, galleryImageName, galleryImage)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "compute.GalleryImagesClient", "CreateOrUpdate", nil, "Failure preparing request")
|
||||
@@ -118,8 +133,8 @@ func (client GalleryImagesClient) CreateOrUpdateResponder(resp *http.Response) (
|
||||
// Delete delete a gallery image.
|
||||
// Parameters:
|
||||
// resourceGroupName - the name of the resource group.
|
||||
// galleryName - the name of the gallery.
|
||||
// galleryImageName - the name of the gallery image.
|
||||
// galleryName - the name of the Shared Image Gallery in which the Image Definition is to be deleted.
|
||||
// galleryImageName - the name of the gallery Image Definition to be deleted.
|
||||
func (client GalleryImagesClient) Delete(ctx context.Context, resourceGroupName string, galleryName string, galleryImageName string) (result GalleryImagesDeleteFuture, err error) {
|
||||
req, err := client.DeletePreparer(ctx, resourceGroupName, galleryName, galleryImageName)
|
||||
if err != nil {
|
||||
@@ -187,11 +202,11 @@ func (client GalleryImagesClient) DeleteResponder(resp *http.Response) (result a
|
||||
return
|
||||
}
|
||||
|
||||
// Get retrieves information about a gallery image.
|
||||
// Get retrieves information about a gallery Image Definition.
|
||||
// Parameters:
|
||||
// resourceGroupName - the name of the resource group.
|
||||
// galleryName - the name of the gallery.
|
||||
// galleryImageName - the name of the gallery image.
|
||||
// galleryName - the name of the Shared Image Gallery from which the Image Definitions are to be retrieved.
|
||||
// galleryImageName - the name of the gallery Image Definition to be retrieved.
|
||||
func (client GalleryImagesClient) Get(ctx context.Context, resourceGroupName string, galleryName string, galleryImageName string) (result GalleryImage, err error) {
|
||||
req, err := client.GetPreparer(ctx, resourceGroupName, galleryName, galleryImageName)
|
||||
if err != nil {
|
||||
@@ -256,10 +271,10 @@ func (client GalleryImagesClient) GetResponder(resp *http.Response) (result Gall
|
||||
return
|
||||
}
|
||||
|
||||
// ListByGallery list gallery images under a gallery.
|
||||
// ListByGallery list gallery Image Definitions in a gallery.
|
||||
// Parameters:
|
||||
// resourceGroupName - the name of the resource group.
|
||||
// galleryName - the name of the gallery.
|
||||
// galleryName - the name of the Shared Image Gallery from which Image Definitions are to be listed.
|
||||
func (client GalleryImagesClient) ListByGallery(ctx context.Context, resourceGroupName string, galleryName string) (result GalleryImageListPage, err error) {
|
||||
result.fn = client.listByGalleryNextResults
|
||||
req, err := client.ListByGalleryPreparer(ctx, resourceGroupName, galleryName)
|
||||
|
||||
@@ -21,6 +21,7 @@ import (
|
||||
"context"
|
||||
"github.com/Azure/go-autorest/autorest"
|
||||
"github.com/Azure/go-autorest/autorest/azure"
|
||||
"github.com/Azure/go-autorest/autorest/validation"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
@@ -39,16 +40,23 @@ func NewGalleryImageVersionsClientWithBaseURI(baseURI string, subscriptionID str
|
||||
return GalleryImageVersionsClient{NewWithBaseURI(baseURI, subscriptionID)}
|
||||
}
|
||||
|
||||
// CreateOrUpdate create or update a gallery image version.
|
||||
// CreateOrUpdate create or update a gallery Image Version.
|
||||
// Parameters:
|
||||
// resourceGroupName - the name of the resource group.
|
||||
// galleryName - the name of the gallery.
|
||||
// galleryImageName - the name of the gallery image.
|
||||
// galleryImageVersionName - the name of the gallery image version. Needs to follow semantic version name
|
||||
// pattern: The allowed characters are digit and period. Digits must be within the range of a 32-bit integer.
|
||||
// Format: <MajorVersion>.<MinorVersion>.<Patch>
|
||||
// galleryImageVersion - parameters supplied to the create or update gallery image version operation.
|
||||
// galleryName - the name of the Shared Image Gallery in which the Image Definition resides.
|
||||
// galleryImageName - the name of the gallery Image Definition in which the Image Version is to be created.
|
||||
// galleryImageVersionName - the name of the gallery Image Version to be created. Needs to follow semantic
|
||||
// version name pattern: The allowed characters are digit and period. Digits must be within the range of a
|
||||
// 32-bit integer. Format: <MajorVersion>.<MinorVersion>.<Patch>
|
||||
// galleryImageVersion - parameters supplied to the create or update gallery Image Version operation.
|
||||
func (client GalleryImageVersionsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, galleryName string, galleryImageName string, galleryImageVersionName string, galleryImageVersion GalleryImageVersion) (result GalleryImageVersionsCreateOrUpdateFuture, err error) {
|
||||
if err := validation.Validate([]validation.Validation{
|
||||
{TargetValue: galleryImageVersion,
|
||||
Constraints: []validation.Constraint{{Target: "galleryImageVersion.GalleryImageVersionProperties", Name: validation.Null, Rule: false,
|
||||
Chain: []validation.Constraint{{Target: "galleryImageVersion.GalleryImageVersionProperties.PublishingProfile", Name: validation.Null, Rule: true, Chain: nil}}}}}}); err != nil {
|
||||
return result, validation.NewError("compute.GalleryImageVersionsClient", "CreateOrUpdate", err.Error())
|
||||
}
|
||||
|
||||
req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, galleryName, galleryImageName, galleryImageVersionName, galleryImageVersion)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "compute.GalleryImageVersionsClient", "CreateOrUpdate", nil, "Failure preparing request")
|
||||
@@ -119,12 +127,12 @@ func (client GalleryImageVersionsClient) CreateOrUpdateResponder(resp *http.Resp
|
||||
return
|
||||
}
|
||||
|
||||
// Delete delete a gallery image version.
|
||||
// Delete delete a gallery Image Version.
|
||||
// Parameters:
|
||||
// resourceGroupName - the name of the resource group.
|
||||
// galleryName - the name of the gallery.
|
||||
// galleryImageName - the name of the gallery image.
|
||||
// galleryImageVersionName - the name of the gallery image version.
|
||||
// galleryName - the name of the Shared Image Gallery in which the Image Definition resides.
|
||||
// galleryImageName - the name of the gallery Image Definition in which the Image Version resides.
|
||||
// galleryImageVersionName - the name of the gallery Image Version to be deleted.
|
||||
func (client GalleryImageVersionsClient) Delete(ctx context.Context, resourceGroupName string, galleryName string, galleryImageName string, galleryImageVersionName string) (result GalleryImageVersionsDeleteFuture, err error) {
|
||||
req, err := client.DeletePreparer(ctx, resourceGroupName, galleryName, galleryImageName, galleryImageVersionName)
|
||||
if err != nil {
|
||||
@@ -193,12 +201,12 @@ func (client GalleryImageVersionsClient) DeleteResponder(resp *http.Response) (r
|
||||
return
|
||||
}
|
||||
|
||||
// Get retrieves information about a gallery image version.
|
||||
// Get retrieves information about a gallery Image Version.
|
||||
// Parameters:
|
||||
// resourceGroupName - the name of the resource group.
|
||||
// galleryName - the name of the gallery.
|
||||
// galleryImageName - the name of the gallery image.
|
||||
// galleryImageVersionName - the name of the gallery image version.
|
||||
// galleryName - the name of the Shared Image Gallery in which the Image Definition resides.
|
||||
// galleryImageName - the name of the gallery Image Definition in which the Image Version resides.
|
||||
// galleryImageVersionName - the name of the gallery Image Version to be retrieved.
|
||||
// expand - the expand expression to apply on the operation.
|
||||
func (client GalleryImageVersionsClient) Get(ctx context.Context, resourceGroupName string, galleryName string, galleryImageName string, galleryImageVersionName string, expand ReplicationStatusTypes) (result GalleryImageVersion, err error) {
|
||||
req, err := client.GetPreparer(ctx, resourceGroupName, galleryName, galleryImageName, galleryImageVersionName, expand)
|
||||
@@ -268,11 +276,12 @@ func (client GalleryImageVersionsClient) GetResponder(resp *http.Response) (resu
|
||||
return
|
||||
}
|
||||
|
||||
// ListByGalleryImage list gallery image versions under a gallery image.
|
||||
// ListByGalleryImage list gallery Image Versions in a gallery Image Definition.
|
||||
// Parameters:
|
||||
// resourceGroupName - the name of the resource group.
|
||||
// galleryName - the name of the gallery.
|
||||
// galleryImageName - the name of the gallery image.
|
||||
// galleryName - the name of the Shared Image Gallery in which the Image Definition resides.
|
||||
// galleryImageName - the name of the Shared Image Gallery Image Definition from which the Image Versions are
|
||||
// to be listed.
|
||||
func (client GalleryImageVersionsClient) ListByGalleryImage(ctx context.Context, resourceGroupName string, galleryName string, galleryImageName string) (result GalleryImageVersionListPage, err error) {
|
||||
result.fn = client.listByGalleryImageNextResults
|
||||
req, err := client.ListByGalleryImagePreparer(ctx, resourceGroupName, galleryName, galleryImageName)
|
||||
|
||||
2788
vendor/github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-06-01/compute/models.go
generated
vendored
2788
vendor/github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-06-01/compute/models.go
generated
vendored
File diff suppressed because one or more lines are too long
130
vendor/github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-06-01/compute/resourceskus.go
generated
vendored
Normal file
130
vendor/github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-06-01/compute/resourceskus.go
generated
vendored
Normal file
@@ -0,0 +1,130 @@
|
||||
package compute
|
||||
|
||||
// Copyright (c) Microsoft and contributors. All rights reserved.
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
// Code generated by Microsoft (R) AutoRest Code Generator.
|
||||
// Changes may cause incorrect behavior and will be lost if the code is regenerated.
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/Azure/go-autorest/autorest"
|
||||
"github.com/Azure/go-autorest/autorest/azure"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
// ResourceSkusClient is the compute Client
|
||||
type ResourceSkusClient struct {
|
||||
BaseClient
|
||||
}
|
||||
|
||||
// NewResourceSkusClient creates an instance of the ResourceSkusClient client.
|
||||
func NewResourceSkusClient(subscriptionID string) ResourceSkusClient {
|
||||
return NewResourceSkusClientWithBaseURI(DefaultBaseURI, subscriptionID)
|
||||
}
|
||||
|
||||
// NewResourceSkusClientWithBaseURI creates an instance of the ResourceSkusClient client.
|
||||
func NewResourceSkusClientWithBaseURI(baseURI string, subscriptionID string) ResourceSkusClient {
|
||||
return ResourceSkusClient{NewWithBaseURI(baseURI, subscriptionID)}
|
||||
}
|
||||
|
||||
// List gets the list of Microsoft.Compute SKUs available for your Subscription.
|
||||
func (client ResourceSkusClient) List(ctx context.Context) (result ResourceSkusResultPage, err error) {
|
||||
result.fn = client.listNextResults
|
||||
req, err := client.ListPreparer(ctx)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "compute.ResourceSkusClient", "List", nil, "Failure preparing request")
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := client.ListSender(req)
|
||||
if err != nil {
|
||||
result.rsr.Response = autorest.Response{Response: resp}
|
||||
err = autorest.NewErrorWithError(err, "compute.ResourceSkusClient", "List", resp, "Failure sending request")
|
||||
return
|
||||
}
|
||||
|
||||
result.rsr, err = client.ListResponder(resp)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "compute.ResourceSkusClient", "List", resp, "Failure responding to request")
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// ListPreparer prepares the List request.
|
||||
func (client ResourceSkusClient) ListPreparer(ctx context.Context) (*http.Request, error) {
|
||||
pathParameters := map[string]interface{}{
|
||||
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||||
}
|
||||
|
||||
const APIVersion = "2017-09-01"
|
||||
queryParameters := map[string]interface{}{
|
||||
"api-version": APIVersion,
|
||||
}
|
||||
|
||||
preparer := autorest.CreatePreparer(
|
||||
autorest.AsGet(),
|
||||
autorest.WithBaseURL(client.BaseURI),
|
||||
autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Compute/skus", pathParameters),
|
||||
autorest.WithQueryParameters(queryParameters))
|
||||
return preparer.Prepare((&http.Request{}).WithContext(ctx))
|
||||
}
|
||||
|
||||
// ListSender sends the List request. The method will close the
|
||||
// http.Response Body if it receives an error.
|
||||
func (client ResourceSkusClient) ListSender(req *http.Request) (*http.Response, error) {
|
||||
return autorest.SendWithSender(client, req,
|
||||
azure.DoRetryWithRegistration(client.Client))
|
||||
}
|
||||
|
||||
// ListResponder handles the response to the List request. The method always
|
||||
// closes the http.Response Body.
|
||||
func (client ResourceSkusClient) ListResponder(resp *http.Response) (result ResourceSkusResult, err error) {
|
||||
err = autorest.Respond(
|
||||
resp,
|
||||
client.ByInspecting(),
|
||||
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
||||
autorest.ByUnmarshallingJSON(&result),
|
||||
autorest.ByClosing())
|
||||
result.Response = autorest.Response{Response: resp}
|
||||
return
|
||||
}
|
||||
|
||||
// listNextResults retrieves the next set of results, if any.
|
||||
func (client ResourceSkusClient) listNextResults(lastResults ResourceSkusResult) (result ResourceSkusResult, err error) {
|
||||
req, err := lastResults.resourceSkusResultPreparer()
|
||||
if err != nil {
|
||||
return result, autorest.NewErrorWithError(err, "compute.ResourceSkusClient", "listNextResults", nil, "Failure preparing next results request")
|
||||
}
|
||||
if req == nil {
|
||||
return
|
||||
}
|
||||
resp, err := client.ListSender(req)
|
||||
if err != nil {
|
||||
result.Response = autorest.Response{Response: resp}
|
||||
return result, autorest.NewErrorWithError(err, "compute.ResourceSkusClient", "listNextResults", resp, "Failure sending next results request")
|
||||
}
|
||||
result, err = client.ListResponder(resp)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "compute.ResourceSkusClient", "listNextResults", resp, "Failure responding to next results request")
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// ListComplete enumerates all values, automatically crossing page boundaries as required.
|
||||
func (client ResourceSkusClient) ListComplete(ctx context.Context) (result ResourceSkusResultIterator, err error) {
|
||||
result.page, err = client.List(ctx)
|
||||
return
|
||||
}
|
||||
686
vendor/github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-06-01/compute/snapshots.go
generated
vendored
Normal file
686
vendor/github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-06-01/compute/snapshots.go
generated
vendored
Normal file
@@ -0,0 +1,686 @@
|
||||
package compute
|
||||
|
||||
// Copyright (c) Microsoft and contributors. All rights reserved.
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
// Code generated by Microsoft (R) AutoRest Code Generator.
|
||||
// Changes may cause incorrect behavior and will be lost if the code is regenerated.
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/Azure/go-autorest/autorest"
|
||||
"github.com/Azure/go-autorest/autorest/azure"
|
||||
"github.com/Azure/go-autorest/autorest/validation"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
// SnapshotsClient is the compute Client
|
||||
type SnapshotsClient struct {
|
||||
BaseClient
|
||||
}
|
||||
|
||||
// NewSnapshotsClient creates an instance of the SnapshotsClient client.
|
||||
func NewSnapshotsClient(subscriptionID string) SnapshotsClient {
|
||||
return NewSnapshotsClientWithBaseURI(DefaultBaseURI, subscriptionID)
|
||||
}
|
||||
|
||||
// NewSnapshotsClientWithBaseURI creates an instance of the SnapshotsClient client.
|
||||
func NewSnapshotsClientWithBaseURI(baseURI string, subscriptionID string) SnapshotsClient {
|
||||
return SnapshotsClient{NewWithBaseURI(baseURI, subscriptionID)}
|
||||
}
|
||||
|
||||
// CreateOrUpdate creates or updates a snapshot.
|
||||
// Parameters:
|
||||
// resourceGroupName - the name of the resource group.
|
||||
// snapshotName - the name of the snapshot that is being created. The name can't be changed after the snapshot
|
||||
// is created. Supported characters for the name are a-z, A-Z, 0-9 and _. The max name length is 80 characters.
|
||||
// snapshot - snapshot object supplied in the body of the Put disk operation.
|
||||
func (client SnapshotsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, snapshotName string, snapshot Snapshot) (result SnapshotsCreateOrUpdateFuture, err error) {
|
||||
if err := validation.Validate([]validation.Validation{
|
||||
{TargetValue: snapshot,
|
||||
Constraints: []validation.Constraint{{Target: "snapshot.SnapshotProperties", Name: validation.Null, Rule: false,
|
||||
Chain: []validation.Constraint{{Target: "snapshot.SnapshotProperties.CreationData", Name: validation.Null, Rule: true,
|
||||
Chain: []validation.Constraint{{Target: "snapshot.SnapshotProperties.CreationData.ImageReference", Name: validation.Null, Rule: false,
|
||||
Chain: []validation.Constraint{{Target: "snapshot.SnapshotProperties.CreationData.ImageReference.ID", Name: validation.Null, Rule: true, Chain: nil}}},
|
||||
}},
|
||||
{Target: "snapshot.SnapshotProperties.EncryptionSettings", Name: validation.Null, Rule: false,
|
||||
Chain: []validation.Constraint{{Target: "snapshot.SnapshotProperties.EncryptionSettings.DiskEncryptionKey", Name: validation.Null, Rule: false,
|
||||
Chain: []validation.Constraint{{Target: "snapshot.SnapshotProperties.EncryptionSettings.DiskEncryptionKey.SourceVault", Name: validation.Null, Rule: true, Chain: nil},
|
||||
{Target: "snapshot.SnapshotProperties.EncryptionSettings.DiskEncryptionKey.SecretURL", Name: validation.Null, Rule: true, Chain: nil},
|
||||
}},
|
||||
{Target: "snapshot.SnapshotProperties.EncryptionSettings.KeyEncryptionKey", Name: validation.Null, Rule: false,
|
||||
Chain: []validation.Constraint{{Target: "snapshot.SnapshotProperties.EncryptionSettings.KeyEncryptionKey.SourceVault", Name: validation.Null, Rule: true, Chain: nil},
|
||||
{Target: "snapshot.SnapshotProperties.EncryptionSettings.KeyEncryptionKey.KeyURL", Name: validation.Null, Rule: true, Chain: nil},
|
||||
}},
|
||||
}},
|
||||
}}}}}); err != nil {
|
||||
return result, validation.NewError("compute.SnapshotsClient", "CreateOrUpdate", err.Error())
|
||||
}
|
||||
|
||||
req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, snapshotName, snapshot)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "compute.SnapshotsClient", "CreateOrUpdate", nil, "Failure preparing request")
|
||||
return
|
||||
}
|
||||
|
||||
result, err = client.CreateOrUpdateSender(req)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "compute.SnapshotsClient", "CreateOrUpdate", result.Response(), "Failure sending request")
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// CreateOrUpdatePreparer prepares the CreateOrUpdate request.
|
||||
func (client SnapshotsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, snapshotName string, snapshot Snapshot) (*http.Request, error) {
|
||||
pathParameters := map[string]interface{}{
|
||||
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
||||
"snapshotName": autorest.Encode("path", snapshotName),
|
||||
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||||
}
|
||||
|
||||
const APIVersion = "2018-06-01"
|
||||
queryParameters := map[string]interface{}{
|
||||
"api-version": APIVersion,
|
||||
}
|
||||
|
||||
preparer := autorest.CreatePreparer(
|
||||
autorest.AsContentType("application/json; charset=utf-8"),
|
||||
autorest.AsPut(),
|
||||
autorest.WithBaseURL(client.BaseURI),
|
||||
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}", pathParameters),
|
||||
autorest.WithJSON(snapshot),
|
||||
autorest.WithQueryParameters(queryParameters))
|
||||
return preparer.Prepare((&http.Request{}).WithContext(ctx))
|
||||
}
|
||||
|
||||
// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the
|
||||
// http.Response Body if it receives an error.
|
||||
func (client SnapshotsClient) CreateOrUpdateSender(req *http.Request) (future SnapshotsCreateOrUpdateFuture, err error) {
|
||||
var resp *http.Response
|
||||
resp, err = autorest.SendWithSender(client, req,
|
||||
azure.DoRetryWithRegistration(client.Client))
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
err = autorest.Respond(resp, azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted))
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
future.Future, err = azure.NewFutureFromResponse(resp)
|
||||
return
|
||||
}
|
||||
|
||||
// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always
|
||||
// closes the http.Response Body.
|
||||
func (client SnapshotsClient) CreateOrUpdateResponder(resp *http.Response) (result Snapshot, err error) {
|
||||
err = autorest.Respond(
|
||||
resp,
|
||||
client.ByInspecting(),
|
||||
azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
|
||||
autorest.ByUnmarshallingJSON(&result),
|
||||
autorest.ByClosing())
|
||||
result.Response = autorest.Response{Response: resp}
|
||||
return
|
||||
}
|
||||
|
||||
// Delete deletes a snapshot.
|
||||
// Parameters:
|
||||
// resourceGroupName - the name of the resource group.
|
||||
// snapshotName - the name of the snapshot that is being created. The name can't be changed after the snapshot
|
||||
// is created. Supported characters for the name are a-z, A-Z, 0-9 and _. The max name length is 80 characters.
|
||||
func (client SnapshotsClient) Delete(ctx context.Context, resourceGroupName string, snapshotName string) (result SnapshotsDeleteFuture, err error) {
|
||||
req, err := client.DeletePreparer(ctx, resourceGroupName, snapshotName)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "compute.SnapshotsClient", "Delete", nil, "Failure preparing request")
|
||||
return
|
||||
}
|
||||
|
||||
result, err = client.DeleteSender(req)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "compute.SnapshotsClient", "Delete", result.Response(), "Failure sending request")
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// DeletePreparer prepares the Delete request.
|
||||
func (client SnapshotsClient) DeletePreparer(ctx context.Context, resourceGroupName string, snapshotName string) (*http.Request, error) {
|
||||
pathParameters := map[string]interface{}{
|
||||
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
||||
"snapshotName": autorest.Encode("path", snapshotName),
|
||||
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||||
}
|
||||
|
||||
const APIVersion = "2018-06-01"
|
||||
queryParameters := map[string]interface{}{
|
||||
"api-version": APIVersion,
|
||||
}
|
||||
|
||||
preparer := autorest.CreatePreparer(
|
||||
autorest.AsDelete(),
|
||||
autorest.WithBaseURL(client.BaseURI),
|
||||
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}", pathParameters),
|
||||
autorest.WithQueryParameters(queryParameters))
|
||||
return preparer.Prepare((&http.Request{}).WithContext(ctx))
|
||||
}
|
||||
|
||||
// DeleteSender sends the Delete request. The method will close the
|
||||
// http.Response Body if it receives an error.
|
||||
func (client SnapshotsClient) DeleteSender(req *http.Request) (future SnapshotsDeleteFuture, err error) {
|
||||
var resp *http.Response
|
||||
resp, err = autorest.SendWithSender(client, req,
|
||||
azure.DoRetryWithRegistration(client.Client))
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
err = autorest.Respond(resp, azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent))
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
future.Future, err = azure.NewFutureFromResponse(resp)
|
||||
return
|
||||
}
|
||||
|
||||
// DeleteResponder handles the response to the Delete request. The method always
|
||||
// closes the http.Response Body.
|
||||
func (client SnapshotsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) {
|
||||
err = autorest.Respond(
|
||||
resp,
|
||||
client.ByInspecting(),
|
||||
azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent),
|
||||
autorest.ByClosing())
|
||||
result.Response = resp
|
||||
return
|
||||
}
|
||||
|
||||
// Get gets information about a snapshot.
|
||||
// Parameters:
|
||||
// resourceGroupName - the name of the resource group.
|
||||
// snapshotName - the name of the snapshot that is being created. The name can't be changed after the snapshot
|
||||
// is created. Supported characters for the name are a-z, A-Z, 0-9 and _. The max name length is 80 characters.
|
||||
func (client SnapshotsClient) Get(ctx context.Context, resourceGroupName string, snapshotName string) (result Snapshot, err error) {
|
||||
req, err := client.GetPreparer(ctx, resourceGroupName, snapshotName)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "compute.SnapshotsClient", "Get", nil, "Failure preparing request")
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := client.GetSender(req)
|
||||
if err != nil {
|
||||
result.Response = autorest.Response{Response: resp}
|
||||
err = autorest.NewErrorWithError(err, "compute.SnapshotsClient", "Get", resp, "Failure sending request")
|
||||
return
|
||||
}
|
||||
|
||||
result, err = client.GetResponder(resp)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "compute.SnapshotsClient", "Get", resp, "Failure responding to request")
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// GetPreparer prepares the Get request.
|
||||
func (client SnapshotsClient) GetPreparer(ctx context.Context, resourceGroupName string, snapshotName string) (*http.Request, error) {
|
||||
pathParameters := map[string]interface{}{
|
||||
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
||||
"snapshotName": autorest.Encode("path", snapshotName),
|
||||
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||||
}
|
||||
|
||||
const APIVersion = "2018-06-01"
|
||||
queryParameters := map[string]interface{}{
|
||||
"api-version": APIVersion,
|
||||
}
|
||||
|
||||
preparer := autorest.CreatePreparer(
|
||||
autorest.AsGet(),
|
||||
autorest.WithBaseURL(client.BaseURI),
|
||||
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}", pathParameters),
|
||||
autorest.WithQueryParameters(queryParameters))
|
||||
return preparer.Prepare((&http.Request{}).WithContext(ctx))
|
||||
}
|
||||
|
||||
// GetSender sends the Get request. The method will close the
|
||||
// http.Response Body if it receives an error.
|
||||
func (client SnapshotsClient) GetSender(req *http.Request) (*http.Response, error) {
|
||||
return autorest.SendWithSender(client, req,
|
||||
azure.DoRetryWithRegistration(client.Client))
|
||||
}
|
||||
|
||||
// GetResponder handles the response to the Get request. The method always
|
||||
// closes the http.Response Body.
|
||||
func (client SnapshotsClient) GetResponder(resp *http.Response) (result Snapshot, err error) {
|
||||
err = autorest.Respond(
|
||||
resp,
|
||||
client.ByInspecting(),
|
||||
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
||||
autorest.ByUnmarshallingJSON(&result),
|
||||
autorest.ByClosing())
|
||||
result.Response = autorest.Response{Response: resp}
|
||||
return
|
||||
}
|
||||
|
||||
// GrantAccess grants access to a snapshot.
|
||||
// Parameters:
|
||||
// resourceGroupName - the name of the resource group.
|
||||
// snapshotName - the name of the snapshot that is being created. The name can't be changed after the snapshot
|
||||
// is created. Supported characters for the name are a-z, A-Z, 0-9 and _. The max name length is 80 characters.
|
||||
// grantAccessData - access data object supplied in the body of the get snapshot access operation.
|
||||
func (client SnapshotsClient) GrantAccess(ctx context.Context, resourceGroupName string, snapshotName string, grantAccessData GrantAccessData) (result SnapshotsGrantAccessFuture, err error) {
|
||||
if err := validation.Validate([]validation.Validation{
|
||||
{TargetValue: grantAccessData,
|
||||
Constraints: []validation.Constraint{{Target: "grantAccessData.DurationInSeconds", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil {
|
||||
return result, validation.NewError("compute.SnapshotsClient", "GrantAccess", err.Error())
|
||||
}
|
||||
|
||||
req, err := client.GrantAccessPreparer(ctx, resourceGroupName, snapshotName, grantAccessData)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "compute.SnapshotsClient", "GrantAccess", nil, "Failure preparing request")
|
||||
return
|
||||
}
|
||||
|
||||
result, err = client.GrantAccessSender(req)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "compute.SnapshotsClient", "GrantAccess", result.Response(), "Failure sending request")
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// GrantAccessPreparer prepares the GrantAccess request.
|
||||
func (client SnapshotsClient) GrantAccessPreparer(ctx context.Context, resourceGroupName string, snapshotName string, grantAccessData GrantAccessData) (*http.Request, error) {
|
||||
pathParameters := map[string]interface{}{
|
||||
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
||||
"snapshotName": autorest.Encode("path", snapshotName),
|
||||
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||||
}
|
||||
|
||||
const APIVersion = "2018-06-01"
|
||||
queryParameters := map[string]interface{}{
|
||||
"api-version": APIVersion,
|
||||
}
|
||||
|
||||
preparer := autorest.CreatePreparer(
|
||||
autorest.AsContentType("application/json; charset=utf-8"),
|
||||
autorest.AsPost(),
|
||||
autorest.WithBaseURL(client.BaseURI),
|
||||
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}/beginGetAccess", pathParameters),
|
||||
autorest.WithJSON(grantAccessData),
|
||||
autorest.WithQueryParameters(queryParameters))
|
||||
return preparer.Prepare((&http.Request{}).WithContext(ctx))
|
||||
}
|
||||
|
||||
// GrantAccessSender sends the GrantAccess request. The method will close the
|
||||
// http.Response Body if it receives an error.
|
||||
func (client SnapshotsClient) GrantAccessSender(req *http.Request) (future SnapshotsGrantAccessFuture, err error) {
|
||||
var resp *http.Response
|
||||
resp, err = autorest.SendWithSender(client, req,
|
||||
azure.DoRetryWithRegistration(client.Client))
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
err = autorest.Respond(resp, azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted))
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
future.Future, err = azure.NewFutureFromResponse(resp)
|
||||
return
|
||||
}
|
||||
|
||||
// GrantAccessResponder handles the response to the GrantAccess request. The method always
|
||||
// closes the http.Response Body.
|
||||
func (client SnapshotsClient) GrantAccessResponder(resp *http.Response) (result AccessURI, err error) {
|
||||
err = autorest.Respond(
|
||||
resp,
|
||||
client.ByInspecting(),
|
||||
azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
|
||||
autorest.ByUnmarshallingJSON(&result),
|
||||
autorest.ByClosing())
|
||||
result.Response = autorest.Response{Response: resp}
|
||||
return
|
||||
}
|
||||
|
||||
// List lists snapshots under a subscription.
|
||||
func (client SnapshotsClient) List(ctx context.Context) (result SnapshotListPage, err error) {
|
||||
result.fn = client.listNextResults
|
||||
req, err := client.ListPreparer(ctx)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "compute.SnapshotsClient", "List", nil, "Failure preparing request")
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := client.ListSender(req)
|
||||
if err != nil {
|
||||
result.sl.Response = autorest.Response{Response: resp}
|
||||
err = autorest.NewErrorWithError(err, "compute.SnapshotsClient", "List", resp, "Failure sending request")
|
||||
return
|
||||
}
|
||||
|
||||
result.sl, err = client.ListResponder(resp)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "compute.SnapshotsClient", "List", resp, "Failure responding to request")
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// ListPreparer prepares the List request.
|
||||
func (client SnapshotsClient) ListPreparer(ctx context.Context) (*http.Request, error) {
|
||||
pathParameters := map[string]interface{}{
|
||||
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||||
}
|
||||
|
||||
const APIVersion = "2018-06-01"
|
||||
queryParameters := map[string]interface{}{
|
||||
"api-version": APIVersion,
|
||||
}
|
||||
|
||||
preparer := autorest.CreatePreparer(
|
||||
autorest.AsGet(),
|
||||
autorest.WithBaseURL(client.BaseURI),
|
||||
autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Compute/snapshots", pathParameters),
|
||||
autorest.WithQueryParameters(queryParameters))
|
||||
return preparer.Prepare((&http.Request{}).WithContext(ctx))
|
||||
}
|
||||
|
||||
// ListSender sends the List request. The method will close the
|
||||
// http.Response Body if it receives an error.
|
||||
func (client SnapshotsClient) ListSender(req *http.Request) (*http.Response, error) {
|
||||
return autorest.SendWithSender(client, req,
|
||||
azure.DoRetryWithRegistration(client.Client))
|
||||
}
|
||||
|
||||
// ListResponder handles the response to the List request. The method always
|
||||
// closes the http.Response Body.
|
||||
func (client SnapshotsClient) ListResponder(resp *http.Response) (result SnapshotList, err error) {
|
||||
err = autorest.Respond(
|
||||
resp,
|
||||
client.ByInspecting(),
|
||||
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
||||
autorest.ByUnmarshallingJSON(&result),
|
||||
autorest.ByClosing())
|
||||
result.Response = autorest.Response{Response: resp}
|
||||
return
|
||||
}
|
||||
|
||||
// listNextResults retrieves the next set of results, if any.
|
||||
func (client SnapshotsClient) listNextResults(lastResults SnapshotList) (result SnapshotList, err error) {
|
||||
req, err := lastResults.snapshotListPreparer()
|
||||
if err != nil {
|
||||
return result, autorest.NewErrorWithError(err, "compute.SnapshotsClient", "listNextResults", nil, "Failure preparing next results request")
|
||||
}
|
||||
if req == nil {
|
||||
return
|
||||
}
|
||||
resp, err := client.ListSender(req)
|
||||
if err != nil {
|
||||
result.Response = autorest.Response{Response: resp}
|
||||
return result, autorest.NewErrorWithError(err, "compute.SnapshotsClient", "listNextResults", resp, "Failure sending next results request")
|
||||
}
|
||||
result, err = client.ListResponder(resp)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "compute.SnapshotsClient", "listNextResults", resp, "Failure responding to next results request")
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// ListComplete enumerates all values, automatically crossing page boundaries as required.
|
||||
func (client SnapshotsClient) ListComplete(ctx context.Context) (result SnapshotListIterator, err error) {
|
||||
result.page, err = client.List(ctx)
|
||||
return
|
||||
}
|
||||
|
||||
// ListByResourceGroup lists snapshots under a resource group.
|
||||
// Parameters:
|
||||
// resourceGroupName - the name of the resource group.
|
||||
func (client SnapshotsClient) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result SnapshotListPage, err error) {
|
||||
result.fn = client.listByResourceGroupNextResults
|
||||
req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "compute.SnapshotsClient", "ListByResourceGroup", nil, "Failure preparing request")
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := client.ListByResourceGroupSender(req)
|
||||
if err != nil {
|
||||
result.sl.Response = autorest.Response{Response: resp}
|
||||
err = autorest.NewErrorWithError(err, "compute.SnapshotsClient", "ListByResourceGroup", resp, "Failure sending request")
|
||||
return
|
||||
}
|
||||
|
||||
result.sl, err = client.ListByResourceGroupResponder(resp)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "compute.SnapshotsClient", "ListByResourceGroup", resp, "Failure responding to request")
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// ListByResourceGroupPreparer prepares the ListByResourceGroup request.
|
||||
func (client SnapshotsClient) ListByResourceGroupPreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) {
|
||||
pathParameters := map[string]interface{}{
|
||||
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
||||
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||||
}
|
||||
|
||||
const APIVersion = "2018-06-01"
|
||||
queryParameters := map[string]interface{}{
|
||||
"api-version": APIVersion,
|
||||
}
|
||||
|
||||
preparer := autorest.CreatePreparer(
|
||||
autorest.AsGet(),
|
||||
autorest.WithBaseURL(client.BaseURI),
|
||||
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots", pathParameters),
|
||||
autorest.WithQueryParameters(queryParameters))
|
||||
return preparer.Prepare((&http.Request{}).WithContext(ctx))
|
||||
}
|
||||
|
||||
// ListByResourceGroupSender sends the ListByResourceGroup request. The method will close the
|
||||
// http.Response Body if it receives an error.
|
||||
func (client SnapshotsClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) {
|
||||
return autorest.SendWithSender(client, req,
|
||||
azure.DoRetryWithRegistration(client.Client))
|
||||
}
|
||||
|
||||
// ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always
|
||||
// closes the http.Response Body.
|
||||
func (client SnapshotsClient) ListByResourceGroupResponder(resp *http.Response) (result SnapshotList, err error) {
|
||||
err = autorest.Respond(
|
||||
resp,
|
||||
client.ByInspecting(),
|
||||
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
||||
autorest.ByUnmarshallingJSON(&result),
|
||||
autorest.ByClosing())
|
||||
result.Response = autorest.Response{Response: resp}
|
||||
return
|
||||
}
|
||||
|
||||
// listByResourceGroupNextResults retrieves the next set of results, if any.
|
||||
func (client SnapshotsClient) listByResourceGroupNextResults(lastResults SnapshotList) (result SnapshotList, err error) {
|
||||
req, err := lastResults.snapshotListPreparer()
|
||||
if err != nil {
|
||||
return result, autorest.NewErrorWithError(err, "compute.SnapshotsClient", "listByResourceGroupNextResults", nil, "Failure preparing next results request")
|
||||
}
|
||||
if req == nil {
|
||||
return
|
||||
}
|
||||
resp, err := client.ListByResourceGroupSender(req)
|
||||
if err != nil {
|
||||
result.Response = autorest.Response{Response: resp}
|
||||
return result, autorest.NewErrorWithError(err, "compute.SnapshotsClient", "listByResourceGroupNextResults", resp, "Failure sending next results request")
|
||||
}
|
||||
result, err = client.ListByResourceGroupResponder(resp)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "compute.SnapshotsClient", "listByResourceGroupNextResults", resp, "Failure responding to next results request")
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// ListByResourceGroupComplete enumerates all values, automatically crossing page boundaries as required.
|
||||
func (client SnapshotsClient) ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result SnapshotListIterator, err error) {
|
||||
result.page, err = client.ListByResourceGroup(ctx, resourceGroupName)
|
||||
return
|
||||
}
|
||||
|
||||
// RevokeAccess revokes access to a snapshot.
|
||||
// Parameters:
|
||||
// resourceGroupName - the name of the resource group.
|
||||
// snapshotName - the name of the snapshot that is being created. The name can't be changed after the snapshot
|
||||
// is created. Supported characters for the name are a-z, A-Z, 0-9 and _. The max name length is 80 characters.
|
||||
func (client SnapshotsClient) RevokeAccess(ctx context.Context, resourceGroupName string, snapshotName string) (result SnapshotsRevokeAccessFuture, err error) {
|
||||
req, err := client.RevokeAccessPreparer(ctx, resourceGroupName, snapshotName)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "compute.SnapshotsClient", "RevokeAccess", nil, "Failure preparing request")
|
||||
return
|
||||
}
|
||||
|
||||
result, err = client.RevokeAccessSender(req)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "compute.SnapshotsClient", "RevokeAccess", result.Response(), "Failure sending request")
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// RevokeAccessPreparer prepares the RevokeAccess request.
|
||||
func (client SnapshotsClient) RevokeAccessPreparer(ctx context.Context, resourceGroupName string, snapshotName string) (*http.Request, error) {
|
||||
pathParameters := map[string]interface{}{
|
||||
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
||||
"snapshotName": autorest.Encode("path", snapshotName),
|
||||
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||||
}
|
||||
|
||||
const APIVersion = "2018-06-01"
|
||||
queryParameters := map[string]interface{}{
|
||||
"api-version": APIVersion,
|
||||
}
|
||||
|
||||
preparer := autorest.CreatePreparer(
|
||||
autorest.AsPost(),
|
||||
autorest.WithBaseURL(client.BaseURI),
|
||||
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}/endGetAccess", pathParameters),
|
||||
autorest.WithQueryParameters(queryParameters))
|
||||
return preparer.Prepare((&http.Request{}).WithContext(ctx))
|
||||
}
|
||||
|
||||
// RevokeAccessSender sends the RevokeAccess request. The method will close the
|
||||
// http.Response Body if it receives an error.
|
||||
func (client SnapshotsClient) RevokeAccessSender(req *http.Request) (future SnapshotsRevokeAccessFuture, err error) {
|
||||
var resp *http.Response
|
||||
resp, err = autorest.SendWithSender(client, req,
|
||||
azure.DoRetryWithRegistration(client.Client))
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
err = autorest.Respond(resp, azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted))
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
future.Future, err = azure.NewFutureFromResponse(resp)
|
||||
return
|
||||
}
|
||||
|
||||
// RevokeAccessResponder handles the response to the RevokeAccess request. The method always
|
||||
// closes the http.Response Body.
|
||||
func (client SnapshotsClient) RevokeAccessResponder(resp *http.Response) (result autorest.Response, err error) {
|
||||
err = autorest.Respond(
|
||||
resp,
|
||||
client.ByInspecting(),
|
||||
azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
|
||||
autorest.ByClosing())
|
||||
result.Response = resp
|
||||
return
|
||||
}
|
||||
|
||||
// Update updates (patches) a snapshot.
|
||||
// Parameters:
|
||||
// resourceGroupName - the name of the resource group.
|
||||
// snapshotName - the name of the snapshot that is being created. The name can't be changed after the snapshot
|
||||
// is created. Supported characters for the name are a-z, A-Z, 0-9 and _. The max name length is 80 characters.
|
||||
// snapshot - snapshot object supplied in the body of the Patch snapshot operation.
|
||||
func (client SnapshotsClient) Update(ctx context.Context, resourceGroupName string, snapshotName string, snapshot SnapshotUpdate) (result SnapshotsUpdateFuture, err error) {
|
||||
req, err := client.UpdatePreparer(ctx, resourceGroupName, snapshotName, snapshot)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "compute.SnapshotsClient", "Update", nil, "Failure preparing request")
|
||||
return
|
||||
}
|
||||
|
||||
result, err = client.UpdateSender(req)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "compute.SnapshotsClient", "Update", result.Response(), "Failure sending request")
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// UpdatePreparer prepares the Update request.
|
||||
func (client SnapshotsClient) UpdatePreparer(ctx context.Context, resourceGroupName string, snapshotName string, snapshot SnapshotUpdate) (*http.Request, error) {
|
||||
pathParameters := map[string]interface{}{
|
||||
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
||||
"snapshotName": autorest.Encode("path", snapshotName),
|
||||
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||||
}
|
||||
|
||||
const APIVersion = "2018-06-01"
|
||||
queryParameters := map[string]interface{}{
|
||||
"api-version": APIVersion,
|
||||
}
|
||||
|
||||
preparer := autorest.CreatePreparer(
|
||||
autorest.AsContentType("application/json; charset=utf-8"),
|
||||
autorest.AsPatch(),
|
||||
autorest.WithBaseURL(client.BaseURI),
|
||||
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}", pathParameters),
|
||||
autorest.WithJSON(snapshot),
|
||||
autorest.WithQueryParameters(queryParameters))
|
||||
return preparer.Prepare((&http.Request{}).WithContext(ctx))
|
||||
}
|
||||
|
||||
// UpdateSender sends the Update request. The method will close the
|
||||
// http.Response Body if it receives an error.
|
||||
func (client SnapshotsClient) UpdateSender(req *http.Request) (future SnapshotsUpdateFuture, err error) {
|
||||
var resp *http.Response
|
||||
resp, err = autorest.SendWithSender(client, req,
|
||||
azure.DoRetryWithRegistration(client.Client))
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
err = autorest.Respond(resp, azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted))
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
future.Future, err = azure.NewFutureFromResponse(resp)
|
||||
return
|
||||
}
|
||||
|
||||
// UpdateResponder handles the response to the Update request. The method always
|
||||
// closes the http.Response Body.
|
||||
func (client SnapshotsClient) UpdateResponder(resp *http.Response) (result Snapshot, err error) {
|
||||
err = autorest.Respond(
|
||||
resp,
|
||||
client.ByInspecting(),
|
||||
azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
|
||||
autorest.ByUnmarshallingJSON(&result),
|
||||
autorest.ByClosing())
|
||||
result.Response = autorest.Response{Response: resp}
|
||||
return
|
||||
}
|
||||
@@ -178,6 +178,78 @@ func (client VirtualMachineScaleSetRollingUpgradesClient) GetLatestResponder(res
|
||||
return
|
||||
}
|
||||
|
||||
// StartExtensionUpgrade starts a rolling upgrade to move all extensions for all virtual machine scale set instances to
|
||||
// the latest available extension version. Instances which are already running the latest extension versions are not
|
||||
// affected.
|
||||
// Parameters:
|
||||
// resourceGroupName - the name of the resource group.
|
||||
// VMScaleSetName - the name of the VM scale set.
|
||||
func (client VirtualMachineScaleSetRollingUpgradesClient) StartExtensionUpgrade(ctx context.Context, resourceGroupName string, VMScaleSetName string) (result VirtualMachineScaleSetRollingUpgradesStartExtensionUpgradeFuture, err error) {
|
||||
req, err := client.StartExtensionUpgradePreparer(ctx, resourceGroupName, VMScaleSetName)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetRollingUpgradesClient", "StartExtensionUpgrade", nil, "Failure preparing request")
|
||||
return
|
||||
}
|
||||
|
||||
result, err = client.StartExtensionUpgradeSender(req)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetRollingUpgradesClient", "StartExtensionUpgrade", result.Response(), "Failure sending request")
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// StartExtensionUpgradePreparer prepares the StartExtensionUpgrade request.
|
||||
func (client VirtualMachineScaleSetRollingUpgradesClient) StartExtensionUpgradePreparer(ctx context.Context, resourceGroupName string, VMScaleSetName string) (*http.Request, error) {
|
||||
pathParameters := map[string]interface{}{
|
||||
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
||||
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||||
"vmScaleSetName": autorest.Encode("path", VMScaleSetName),
|
||||
}
|
||||
|
||||
const APIVersion = "2018-06-01"
|
||||
queryParameters := map[string]interface{}{
|
||||
"api-version": APIVersion,
|
||||
}
|
||||
|
||||
preparer := autorest.CreatePreparer(
|
||||
autorest.AsPost(),
|
||||
autorest.WithBaseURL(client.BaseURI),
|
||||
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/extensionRollingUpgrade", pathParameters),
|
||||
autorest.WithQueryParameters(queryParameters))
|
||||
return preparer.Prepare((&http.Request{}).WithContext(ctx))
|
||||
}
|
||||
|
||||
// StartExtensionUpgradeSender sends the StartExtensionUpgrade request. The method will close the
|
||||
// http.Response Body if it receives an error.
|
||||
func (client VirtualMachineScaleSetRollingUpgradesClient) StartExtensionUpgradeSender(req *http.Request) (future VirtualMachineScaleSetRollingUpgradesStartExtensionUpgradeFuture, err error) {
|
||||
var resp *http.Response
|
||||
resp, err = autorest.SendWithSender(client, req,
|
||||
azure.DoRetryWithRegistration(client.Client))
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
err = autorest.Respond(resp, azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted))
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
future.Future, err = azure.NewFutureFromResponse(resp)
|
||||
return
|
||||
}
|
||||
|
||||
// StartExtensionUpgradeResponder handles the response to the StartExtensionUpgrade request. The method always
|
||||
// closes the http.Response Body.
|
||||
func (client VirtualMachineScaleSetRollingUpgradesClient) StartExtensionUpgradeResponder(resp *http.Response) (result autorest.Response, err error) {
|
||||
err = autorest.Respond(
|
||||
resp,
|
||||
client.ByInspecting(),
|
||||
azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
|
||||
autorest.ByClosing())
|
||||
result.Response = resp
|
||||
return
|
||||
}
|
||||
|
||||
// StartOSUpgrade starts a rolling upgrade to move all virtual machine scale set instances to the latest available
|
||||
// Platform Image OS version. Instances which are already running the latest available OS version are not affected.
|
||||
// Parameters:
|
||||
|
||||
@@ -943,7 +943,9 @@ func (client VirtualMachineScaleSetsClient) ListSkusComplete(ctx context.Context
|
||||
return
|
||||
}
|
||||
|
||||
// PerformMaintenance perform maintenance on one or more virtual machines in a VM scale set.
|
||||
// PerformMaintenance perform maintenance on one or more virtual machines in a VM scale set. Operation on instances
|
||||
// which are not eligible for perform maintenance will be failed. Please refer to best practices for more details:
|
||||
// https://docs.microsoft.com/en-us/azure/virtual-machine-scale-sets/virtual-machine-scale-sets-maintenance-notifications
|
||||
// Parameters:
|
||||
// resourceGroupName - the name of the resource group.
|
||||
// VMScaleSetName - the name of the VM scale set.
|
||||
|
||||
@@ -40,7 +40,8 @@ func NewVirtualMachineSizesClientWithBaseURI(baseURI string, subscriptionID stri
|
||||
return VirtualMachineSizesClient{NewWithBaseURI(baseURI, subscriptionID)}
|
||||
}
|
||||
|
||||
// List lists all available virtual machine sizes for a subscription in a location.
|
||||
// List this API is deprecated. Use [Resources
|
||||
// Skus](https://docs.microsoft.com/en-us/rest/api/compute/resourceskus/list)
|
||||
// Parameters:
|
||||
// location - the location upon which virtual-machine-sizes is queried.
|
||||
func (client VirtualMachineSizesClient) List(ctx context.Context, location string) (result VirtualMachineSizeListResult, err error) {
|
||||
|
||||
143
vendor/github.com/Azure/azure-sdk-for-go/services/network/mgmt/2018-06-01/network/models.go
generated
vendored
143
vendor/github.com/Azure/azure-sdk-for-go/services/network/mgmt/2018-06-01/network/models.go
generated
vendored
@@ -5452,6 +5452,27 @@ type BgpSettings struct {
|
||||
PeerWeight *int32 `json:"peerWeight,omitempty"`
|
||||
}
|
||||
|
||||
// ConfigurationDiagnosticParameters parameters to get network configuration diagnostic.
|
||||
type ConfigurationDiagnosticParameters struct {
|
||||
// TargetResourceID - The ID of the target resource to perform network configuration diagnostic. Valid options are VM, NetworkInterface, VMSS/NetworkInterface and Application Gateway.
|
||||
TargetResourceID *string `json:"targetResourceId,omitempty"`
|
||||
// Queries - List of traffic queries.
|
||||
Queries *[]TrafficQuery `json:"queries,omitempty"`
|
||||
}
|
||||
|
||||
// ConfigurationDiagnosticResponse results of network configuration diagnostic on the target resource.
|
||||
type ConfigurationDiagnosticResponse struct {
|
||||
autorest.Response `json:"-"`
|
||||
// Results - List of network configuration diagnostic results.
|
||||
Results *[]ConfigurationDiagnosticResult `json:"results,omitempty"`
|
||||
}
|
||||
|
||||
// ConfigurationDiagnosticResult network configuration diagnostic result corresponded to provided traffic query.
|
||||
type ConfigurationDiagnosticResult struct {
|
||||
TrafficQuery *TrafficQuery `json:"trafficQuery,omitempty"`
|
||||
NetworkSecurityGroupResult *SecurityGroupResult `json:"networkSecurityGroupResult,omitempty"`
|
||||
}
|
||||
|
||||
// ConnectionMonitor parameters that define the operation to create a connection monitor.
|
||||
type ConnectionMonitor struct {
|
||||
// Location - Connection monitor location.
|
||||
@@ -5853,6 +5874,16 @@ type ConnectionStateSnapshot struct {
|
||||
EndTime *date.Time `json:"endTime,omitempty"`
|
||||
// EvaluationState - Connectivity analysis evaluation state. Possible values include: 'NotStarted', 'InProgress', 'Completed'
|
||||
EvaluationState EvaluationState `json:"evaluationState,omitempty"`
|
||||
// AvgLatencyInMs - Average latency in ms.
|
||||
AvgLatencyInMs *int32 `json:"avgLatencyInMs,omitempty"`
|
||||
// MinLatencyInMs - Minimum latency in ms.
|
||||
MinLatencyInMs *int32 `json:"minLatencyInMs,omitempty"`
|
||||
// MaxLatencyInMs - Maximum latency in ms.
|
||||
MaxLatencyInMs *int32 `json:"maxLatencyInMs,omitempty"`
|
||||
// ProbesSent - The number of sent probes.
|
||||
ProbesSent *int32 `json:"probesSent,omitempty"`
|
||||
// ProbesFailed - The number of failed probes.
|
||||
ProbesFailed *int32 `json:"probesFailed,omitempty"`
|
||||
// Hops - List of hops between the source and the destination.
|
||||
Hops *[]ConnectivityHop `json:"hops,omitempty"`
|
||||
}
|
||||
@@ -6487,6 +6518,20 @@ type ErrorDetails struct {
|
||||
Message *string `json:"message,omitempty"`
|
||||
}
|
||||
|
||||
// ErrorResponse the error object.
|
||||
type ErrorResponse struct {
|
||||
Error *ErrorDetails `json:"error,omitempty"`
|
||||
}
|
||||
|
||||
// EvaluatedNetworkSecurityGroup results of network security group evaluation.
|
||||
type EvaluatedNetworkSecurityGroup struct {
|
||||
// NetworkSecurityGroupID - Network security group ID.
|
||||
NetworkSecurityGroupID *string `json:"networkSecurityGroupId,omitempty"`
|
||||
MatchedRule *MatchedRule `json:"matchedRule,omitempty"`
|
||||
// RulesEvaluationResult - List of network security rules evaluation results.
|
||||
RulesEvaluationResult *[]SecurityRulesEvaluationResult `json:"rulesEvaluationResult,omitempty"`
|
||||
}
|
||||
|
||||
// ExpressRouteCircuit expressRouteCircuit resource
|
||||
type ExpressRouteCircuit struct {
|
||||
autorest.Response `json:"-"`
|
||||
@@ -11947,6 +11992,14 @@ type LogSpecification struct {
|
||||
BlobDuration *string `json:"blobDuration,omitempty"`
|
||||
}
|
||||
|
||||
// MatchedRule matched rule.
|
||||
type MatchedRule struct {
|
||||
// RuleName - Name of the matched network security rule.
|
||||
RuleName *string `json:"ruleName,omitempty"`
|
||||
// Action - The network traffic is allowed or denied. Possible values are 'Allow' and 'Deny'.
|
||||
Action *string `json:"action,omitempty"`
|
||||
}
|
||||
|
||||
// MetricSpecification description of metrics specification.
|
||||
type MetricSpecification struct {
|
||||
// Name - The name of the metric.
|
||||
@@ -14833,6 +14886,14 @@ type SecurityGroupPropertiesFormat struct {
|
||||
ProvisioningState *string `json:"provisioningState,omitempty"`
|
||||
}
|
||||
|
||||
// SecurityGroupResult network configuration diagnostic result corresponded provided traffic query.
|
||||
type SecurityGroupResult struct {
|
||||
// SecurityRuleAccessResult - The network traffic is allowed or denied. Possible values are 'Allow' and 'Deny'. Possible values include: 'SecurityRuleAccessAllow', 'SecurityRuleAccessDeny'
|
||||
SecurityRuleAccessResult SecurityRuleAccess `json:"securityRuleAccessResult,omitempty"`
|
||||
// EvaluatedNetworkSecurityGroups - List of results network security groups diagnostic.
|
||||
EvaluatedNetworkSecurityGroups *[]EvaluatedNetworkSecurityGroup `json:"evaluatedNetworkSecurityGroups,omitempty"`
|
||||
}
|
||||
|
||||
// SecurityGroupsCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a long-running
|
||||
// operation.
|
||||
type SecurityGroupsCreateOrUpdateFuture struct {
|
||||
@@ -15208,6 +15269,22 @@ func (future *SecurityRulesDeleteFuture) Result(client SecurityRulesClient) (ar
|
||||
return
|
||||
}
|
||||
|
||||
// SecurityRulesEvaluationResult network security rules evaluation result.
|
||||
type SecurityRulesEvaluationResult struct {
|
||||
// Name - Name of the network security rule.
|
||||
Name *string `json:"name,omitempty"`
|
||||
// ProtocolMatched - Value indicating whether protocol is matched.
|
||||
ProtocolMatched *bool `json:"protocolMatched,omitempty"`
|
||||
// SourceMatched - Value indicating whether source is matched.
|
||||
SourceMatched *bool `json:"sourceMatched,omitempty"`
|
||||
// SourcePortMatched - Value indicating whether source port is matched.
|
||||
SourcePortMatched *bool `json:"sourcePortMatched,omitempty"`
|
||||
// DestinationMatched - Value indicating whether destination is matched.
|
||||
DestinationMatched *bool `json:"destinationMatched,omitempty"`
|
||||
// DestinationPortMatched - Value indicating whether destination port is matched.
|
||||
DestinationPortMatched *bool `json:"destinationPortMatched,omitempty"`
|
||||
}
|
||||
|
||||
// ServiceEndpointPropertiesFormat the service endpoint properties.
|
||||
type ServiceEndpointPropertiesFormat struct {
|
||||
// Service - The type of the endpoint service.
|
||||
@@ -15567,6 +15644,20 @@ type TrafficAnalyticsProperties struct {
|
||||
NetworkWatcherFlowAnalyticsConfiguration *TrafficAnalyticsConfigurationProperties `json:"networkWatcherFlowAnalyticsConfiguration,omitempty"`
|
||||
}
|
||||
|
||||
// TrafficQuery parameters to compare with network configuration.
|
||||
type TrafficQuery struct {
|
||||
// Direction - The direction of the traffic. Accepted values are 'Inbound' and 'Outbound'. Possible values include: 'Inbound', 'Outbound'
|
||||
Direction Direction `json:"direction,omitempty"`
|
||||
// Protocol - Protocol to be verified on. Accepted values are '*', TCP, UDP.
|
||||
Protocol *string `json:"protocol,omitempty"`
|
||||
// Source - Traffic source. Accepted values are '*', IP Address/CIDR, Service Tag.
|
||||
Source *string `json:"source,omitempty"`
|
||||
// Destination - Traffic destination. Accepted values are: '*', IP Address/CIDR, Service Tag.
|
||||
Destination *string `json:"destination,omitempty"`
|
||||
// DestinationPort - Traffice destination port. Accepted values are '*', port (for example, 3389) and port range (for example, 80-100).
|
||||
DestinationPort *string `json:"destinationPort,omitempty"`
|
||||
}
|
||||
|
||||
// TroubleshootingDetails information gained from troubleshooting of specified resource.
|
||||
type TroubleshootingDetails struct {
|
||||
// ID - The id of the get troubleshoot operation.
|
||||
@@ -17487,6 +17578,29 @@ func (future *VirtualNetworkGatewaysResetFuture) Result(client VirtualNetworkGat
|
||||
return
|
||||
}
|
||||
|
||||
// VirtualNetworkGatewaysResetVpnClientSharedKeyFuture an abstraction for monitoring and retrieving the results of
|
||||
// a long-running operation.
|
||||
type VirtualNetworkGatewaysResetVpnClientSharedKeyFuture struct {
|
||||
azure.Future
|
||||
}
|
||||
|
||||
// Result returns the result of the asynchronous operation.
|
||||
// If the operation has not completed it will return an error.
|
||||
func (future *VirtualNetworkGatewaysResetVpnClientSharedKeyFuture) Result(client VirtualNetworkGatewaysClient) (ar autorest.Response, err error) {
|
||||
var done bool
|
||||
done, err = future.Done(client)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysResetVpnClientSharedKeyFuture", "Result", future.Response(), "Polling failure")
|
||||
return
|
||||
}
|
||||
if !done {
|
||||
err = azure.NewAsyncOpIncompleteError("network.VirtualNetworkGatewaysResetVpnClientSharedKeyFuture")
|
||||
return
|
||||
}
|
||||
ar.Response = future.Response()
|
||||
return
|
||||
}
|
||||
|
||||
// VirtualNetworkGatewaysSetVpnclientIpsecParametersFuture an abstraction for monitoring and retrieving the results
|
||||
// of a long-running operation.
|
||||
type VirtualNetworkGatewaysSetVpnclientIpsecParametersFuture struct {
|
||||
@@ -19493,6 +19607,35 @@ func (future *WatchersGetFlowLogStatusFuture) Result(client WatchersClient) (fli
|
||||
return
|
||||
}
|
||||
|
||||
// WatchersGetNetworkConfigurationDiagnosticFuture an abstraction for monitoring and retrieving the results of a
|
||||
// long-running operation.
|
||||
type WatchersGetNetworkConfigurationDiagnosticFuture struct {
|
||||
azure.Future
|
||||
}
|
||||
|
||||
// Result returns the result of the asynchronous operation.
|
||||
// If the operation has not completed it will return an error.
|
||||
func (future *WatchersGetNetworkConfigurationDiagnosticFuture) Result(client WatchersClient) (cdr ConfigurationDiagnosticResponse, err error) {
|
||||
var done bool
|
||||
done, err = future.Done(client)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "network.WatchersGetNetworkConfigurationDiagnosticFuture", "Result", future.Response(), "Polling failure")
|
||||
return
|
||||
}
|
||||
if !done {
|
||||
err = azure.NewAsyncOpIncompleteError("network.WatchersGetNetworkConfigurationDiagnosticFuture")
|
||||
return
|
||||
}
|
||||
sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
|
||||
if cdr.Response.Response, err = future.GetResult(sender); err == nil && cdr.Response.Response.StatusCode != http.StatusNoContent {
|
||||
cdr, err = client.GetNetworkConfigurationDiagnosticResponder(cdr.Response.Response)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "network.WatchersGetNetworkConfigurationDiagnosticFuture", "Result", cdr.Response.Response, "Failure responding to request")
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// WatchersGetNextHopFuture an abstraction for monitoring and retrieving the results of a long-running operation.
|
||||
type WatchersGetNextHopFuture struct {
|
||||
azure.Future
|
||||
|
||||
@@ -1037,6 +1037,77 @@ func (client VirtualNetworkGatewaysClient) ResetResponder(resp *http.Response) (
|
||||
return
|
||||
}
|
||||
|
||||
// ResetVpnClientSharedKey resets the VPN client shared key of the virtual network gateway in the specified resource
|
||||
// group.
|
||||
// Parameters:
|
||||
// resourceGroupName - the name of the resource group.
|
||||
// virtualNetworkGatewayName - the name of the virtual network gateway.
|
||||
func (client VirtualNetworkGatewaysClient) ResetVpnClientSharedKey(ctx context.Context, resourceGroupName string, virtualNetworkGatewayName string) (result VirtualNetworkGatewaysResetVpnClientSharedKeyFuture, err error) {
|
||||
req, err := client.ResetVpnClientSharedKeyPreparer(ctx, resourceGroupName, virtualNetworkGatewayName)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "ResetVpnClientSharedKey", nil, "Failure preparing request")
|
||||
return
|
||||
}
|
||||
|
||||
result, err = client.ResetVpnClientSharedKeySender(req)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "ResetVpnClientSharedKey", result.Response(), "Failure sending request")
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// ResetVpnClientSharedKeyPreparer prepares the ResetVpnClientSharedKey request.
|
||||
func (client VirtualNetworkGatewaysClient) ResetVpnClientSharedKeyPreparer(ctx context.Context, resourceGroupName string, virtualNetworkGatewayName string) (*http.Request, error) {
|
||||
pathParameters := map[string]interface{}{
|
||||
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
||||
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||||
"virtualNetworkGatewayName": autorest.Encode("path", virtualNetworkGatewayName),
|
||||
}
|
||||
|
||||
const APIVersion = "2018-06-01"
|
||||
queryParameters := map[string]interface{}{
|
||||
"api-version": APIVersion,
|
||||
}
|
||||
|
||||
preparer := autorest.CreatePreparer(
|
||||
autorest.AsPost(),
|
||||
autorest.WithBaseURL(client.BaseURI),
|
||||
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworkGateways/{virtualNetworkGatewayName}/resetvpnclientsharedkey", pathParameters),
|
||||
autorest.WithQueryParameters(queryParameters))
|
||||
return preparer.Prepare((&http.Request{}).WithContext(ctx))
|
||||
}
|
||||
|
||||
// ResetVpnClientSharedKeySender sends the ResetVpnClientSharedKey request. The method will close the
|
||||
// http.Response Body if it receives an error.
|
||||
func (client VirtualNetworkGatewaysClient) ResetVpnClientSharedKeySender(req *http.Request) (future VirtualNetworkGatewaysResetVpnClientSharedKeyFuture, err error) {
|
||||
var resp *http.Response
|
||||
resp, err = autorest.SendWithSender(client, req,
|
||||
azure.DoRetryWithRegistration(client.Client))
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
err = autorest.Respond(resp, azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted))
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
future.Future, err = azure.NewFutureFromResponse(resp)
|
||||
return
|
||||
}
|
||||
|
||||
// ResetVpnClientSharedKeyResponder handles the response to the ResetVpnClientSharedKey request. The method always
|
||||
// closes the http.Response Body.
|
||||
func (client VirtualNetworkGatewaysClient) ResetVpnClientSharedKeyResponder(resp *http.Response) (result autorest.Response, err error) {
|
||||
err = autorest.Respond(
|
||||
resp,
|
||||
client.ByInspecting(),
|
||||
azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
|
||||
autorest.ByClosing())
|
||||
result.Response = resp
|
||||
return
|
||||
}
|
||||
|
||||
// SetVpnclientIpsecParameters the Set VpnclientIpsecParameters operation sets the vpnclient ipsec policy for P2S
|
||||
// client of virtual network gateway in the specified resource group through Network resource provider.
|
||||
// Parameters:
|
||||
|
||||
@@ -494,6 +494,87 @@ func (client WatchersClient) GetFlowLogStatusResponder(resp *http.Response) (res
|
||||
return
|
||||
}
|
||||
|
||||
// GetNetworkConfigurationDiagnostic get network configuration diagnostic.
|
||||
// Parameters:
|
||||
// resourceGroupName - the name of the resource group.
|
||||
// networkWatcherName - the name of the network watcher.
|
||||
// parameters - parameters to get network configuration diagnostic.
|
||||
func (client WatchersClient) GetNetworkConfigurationDiagnostic(ctx context.Context, resourceGroupName string, networkWatcherName string, parameters ConfigurationDiagnosticParameters) (result WatchersGetNetworkConfigurationDiagnosticFuture, err error) {
|
||||
if err := validation.Validate([]validation.Validation{
|
||||
{TargetValue: parameters,
|
||||
Constraints: []validation.Constraint{{Target: "parameters.TargetResourceID", Name: validation.Null, Rule: true, Chain: nil},
|
||||
{Target: "parameters.Queries", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil {
|
||||
return result, validation.NewError("network.WatchersClient", "GetNetworkConfigurationDiagnostic", err.Error())
|
||||
}
|
||||
|
||||
req, err := client.GetNetworkConfigurationDiagnosticPreparer(ctx, resourceGroupName, networkWatcherName, parameters)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "network.WatchersClient", "GetNetworkConfigurationDiagnostic", nil, "Failure preparing request")
|
||||
return
|
||||
}
|
||||
|
||||
result, err = client.GetNetworkConfigurationDiagnosticSender(req)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "network.WatchersClient", "GetNetworkConfigurationDiagnostic", result.Response(), "Failure sending request")
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// GetNetworkConfigurationDiagnosticPreparer prepares the GetNetworkConfigurationDiagnostic request.
|
||||
func (client WatchersClient) GetNetworkConfigurationDiagnosticPreparer(ctx context.Context, resourceGroupName string, networkWatcherName string, parameters ConfigurationDiagnosticParameters) (*http.Request, error) {
|
||||
pathParameters := map[string]interface{}{
|
||||
"networkWatcherName": autorest.Encode("path", networkWatcherName),
|
||||
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
||||
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||||
}
|
||||
|
||||
const APIVersion = "2018-06-01"
|
||||
queryParameters := map[string]interface{}{
|
||||
"api-version": APIVersion,
|
||||
}
|
||||
|
||||
preparer := autorest.CreatePreparer(
|
||||
autorest.AsContentType("application/json; charset=utf-8"),
|
||||
autorest.AsPost(),
|
||||
autorest.WithBaseURL(client.BaseURI),
|
||||
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkWatchers/{networkWatcherName}/networkConfigurationDiagnostic", pathParameters),
|
||||
autorest.WithJSON(parameters),
|
||||
autorest.WithQueryParameters(queryParameters))
|
||||
return preparer.Prepare((&http.Request{}).WithContext(ctx))
|
||||
}
|
||||
|
||||
// GetNetworkConfigurationDiagnosticSender sends the GetNetworkConfigurationDiagnostic request. The method will close the
|
||||
// http.Response Body if it receives an error.
|
||||
func (client WatchersClient) GetNetworkConfigurationDiagnosticSender(req *http.Request) (future WatchersGetNetworkConfigurationDiagnosticFuture, err error) {
|
||||
var resp *http.Response
|
||||
resp, err = autorest.SendWithSender(client, req,
|
||||
azure.DoRetryWithRegistration(client.Client))
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
err = autorest.Respond(resp, azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted))
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
future.Future, err = azure.NewFutureFromResponse(resp)
|
||||
return
|
||||
}
|
||||
|
||||
// GetNetworkConfigurationDiagnosticResponder handles the response to the GetNetworkConfigurationDiagnostic request. The method always
|
||||
// closes the http.Response Body.
|
||||
func (client WatchersClient) GetNetworkConfigurationDiagnosticResponder(resp *http.Response) (result ConfigurationDiagnosticResponse, err error) {
|
||||
err = autorest.Respond(
|
||||
resp,
|
||||
client.ByInspecting(),
|
||||
azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
|
||||
autorest.ByUnmarshallingJSON(&result),
|
||||
autorest.ByClosing())
|
||||
result.Response = autorest.Response{Response: resp}
|
||||
return
|
||||
}
|
||||
|
||||
// GetNextHop gets the next hop from the specified VM.
|
||||
// Parameters:
|
||||
// resourceGroupName - the name of the resource group.
|
||||
|
||||
@@ -1152,6 +1152,129 @@ type OnErrorDeploymentExtended struct {
|
||||
DeploymentName *string `json:"deploymentName,omitempty"`
|
||||
}
|
||||
|
||||
// Operation microsoft.Resources operation
|
||||
type Operation struct {
|
||||
// Name - Operation name: {provider}/{resource}/{operation}
|
||||
Name *string `json:"name,omitempty"`
|
||||
// Display - The object that represents the operation.
|
||||
Display *OperationDisplay `json:"display,omitempty"`
|
||||
}
|
||||
|
||||
// OperationDisplay the object that represents the operation.
|
||||
type OperationDisplay struct {
|
||||
// Provider - Service provider: Microsoft.Resources
|
||||
Provider *string `json:"provider,omitempty"`
|
||||
// Resource - Resource on which the operation is performed: Profile, endpoint, etc.
|
||||
Resource *string `json:"resource,omitempty"`
|
||||
// Operation - Operation type: Read, write, delete, etc.
|
||||
Operation *string `json:"operation,omitempty"`
|
||||
// Description - Description of the operation.
|
||||
Description *string `json:"description,omitempty"`
|
||||
}
|
||||
|
||||
// OperationListResult result of the request to list Microsoft.Resources operations. It contains a list of
|
||||
// operations and a URL link to get the next set of results.
|
||||
type OperationListResult struct {
|
||||
autorest.Response `json:"-"`
|
||||
// Value - List of Microsoft.Resources operations.
|
||||
Value *[]Operation `json:"value,omitempty"`
|
||||
// NextLink - URL to get the next set of operation list results if there are any.
|
||||
NextLink *string `json:"nextLink,omitempty"`
|
||||
}
|
||||
|
||||
// OperationListResultIterator provides access to a complete listing of Operation values.
|
||||
type OperationListResultIterator struct {
|
||||
i int
|
||||
page OperationListResultPage
|
||||
}
|
||||
|
||||
// Next advances to the next value. If there was an error making
|
||||
// the request the iterator does not advance and the error is returned.
|
||||
func (iter *OperationListResultIterator) Next() error {
|
||||
iter.i++
|
||||
if iter.i < len(iter.page.Values()) {
|
||||
return nil
|
||||
}
|
||||
err := iter.page.Next()
|
||||
if err != nil {
|
||||
iter.i--
|
||||
return err
|
||||
}
|
||||
iter.i = 0
|
||||
return nil
|
||||
}
|
||||
|
||||
// NotDone returns true if the enumeration should be started or is not yet complete.
|
||||
func (iter OperationListResultIterator) NotDone() bool {
|
||||
return iter.page.NotDone() && iter.i < len(iter.page.Values())
|
||||
}
|
||||
|
||||
// Response returns the raw server response from the last page request.
|
||||
func (iter OperationListResultIterator) Response() OperationListResult {
|
||||
return iter.page.Response()
|
||||
}
|
||||
|
||||
// Value returns the current value or a zero-initialized value if the
|
||||
// iterator has advanced beyond the end of the collection.
|
||||
func (iter OperationListResultIterator) Value() Operation {
|
||||
if !iter.page.NotDone() {
|
||||
return Operation{}
|
||||
}
|
||||
return iter.page.Values()[iter.i]
|
||||
}
|
||||
|
||||
// IsEmpty returns true if the ListResult contains no values.
|
||||
func (olr OperationListResult) IsEmpty() bool {
|
||||
return olr.Value == nil || len(*olr.Value) == 0
|
||||
}
|
||||
|
||||
// operationListResultPreparer prepares a request to retrieve the next set of results.
|
||||
// It returns nil if no more results exist.
|
||||
func (olr OperationListResult) operationListResultPreparer() (*http.Request, error) {
|
||||
if olr.NextLink == nil || len(to.String(olr.NextLink)) < 1 {
|
||||
return nil, nil
|
||||
}
|
||||
return autorest.Prepare(&http.Request{},
|
||||
autorest.AsJSON(),
|
||||
autorest.AsGet(),
|
||||
autorest.WithBaseURL(to.String(olr.NextLink)))
|
||||
}
|
||||
|
||||
// OperationListResultPage contains a page of Operation values.
|
||||
type OperationListResultPage struct {
|
||||
fn func(OperationListResult) (OperationListResult, error)
|
||||
olr OperationListResult
|
||||
}
|
||||
|
||||
// Next advances to the next page of values. If there was an error making
|
||||
// the request the page does not advance and the error is returned.
|
||||
func (page *OperationListResultPage) Next() error {
|
||||
next, err := page.fn(page.olr)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
page.olr = next
|
||||
return nil
|
||||
}
|
||||
|
||||
// NotDone returns true if the page enumeration should be started or is not yet complete.
|
||||
func (page OperationListResultPage) NotDone() bool {
|
||||
return !page.olr.IsEmpty()
|
||||
}
|
||||
|
||||
// Response returns the raw server response from the last page request.
|
||||
func (page OperationListResultPage) Response() OperationListResult {
|
||||
return page.olr
|
||||
}
|
||||
|
||||
// Values returns the slice of values for the current page or nil if there are no values.
|
||||
func (page OperationListResultPage) Values() []Operation {
|
||||
if page.olr.IsEmpty() {
|
||||
return nil
|
||||
}
|
||||
return *page.olr.Value
|
||||
}
|
||||
|
||||
// ParametersLink entity representing the reference to the deployment paramaters.
|
||||
type ParametersLink struct {
|
||||
// URI - The URI of the parameters file.
|
||||
@@ -1297,7 +1420,7 @@ type ProviderOperationDisplayProperties struct {
|
||||
Provider *string `json:"provider,omitempty"`
|
||||
// Resource - Operation resource.
|
||||
Resource *string `json:"resource,omitempty"`
|
||||
// Operation - Operation.
|
||||
// Operation - Resource provider operation.
|
||||
Operation *string `json:"operation,omitempty"`
|
||||
// Description - Operation description.
|
||||
Description *string `json:"description,omitempty"`
|
||||
@@ -1338,7 +1461,7 @@ func (prt ProviderResourceType) MarshalJSON() ([]byte, error) {
|
||||
return json.Marshal(objectMap)
|
||||
}
|
||||
|
||||
// Resource resource.
|
||||
// Resource specified resource.
|
||||
type Resource struct {
|
||||
// ID - Resource ID
|
||||
ID *string `json:"id,omitempty"`
|
||||
|
||||
126
vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2018-05-01/resources/operations.go
generated
vendored
Normal file
126
vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2018-05-01/resources/operations.go
generated
vendored
Normal file
@@ -0,0 +1,126 @@
|
||||
package resources
|
||||
|
||||
// Copyright (c) Microsoft and contributors. All rights reserved.
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
// Code generated by Microsoft (R) AutoRest Code Generator.
|
||||
// Changes may cause incorrect behavior and will be lost if the code is regenerated.
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/Azure/go-autorest/autorest"
|
||||
"github.com/Azure/go-autorest/autorest/azure"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
// OperationsClient is the provides operations for working with resources and resource groups.
|
||||
type OperationsClient struct {
|
||||
BaseClient
|
||||
}
|
||||
|
||||
// NewOperationsClient creates an instance of the OperationsClient client.
|
||||
func NewOperationsClient(subscriptionID string) OperationsClient {
|
||||
return NewOperationsClientWithBaseURI(DefaultBaseURI, subscriptionID)
|
||||
}
|
||||
|
||||
// NewOperationsClientWithBaseURI creates an instance of the OperationsClient client.
|
||||
func NewOperationsClientWithBaseURI(baseURI string, subscriptionID string) OperationsClient {
|
||||
return OperationsClient{NewWithBaseURI(baseURI, subscriptionID)}
|
||||
}
|
||||
|
||||
// List lists all of the available Microsoft.Resources REST API operations.
|
||||
func (client OperationsClient) List(ctx context.Context) (result OperationListResultPage, err error) {
|
||||
result.fn = client.listNextResults
|
||||
req, err := client.ListPreparer(ctx)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "resources.OperationsClient", "List", nil, "Failure preparing request")
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := client.ListSender(req)
|
||||
if err != nil {
|
||||
result.olr.Response = autorest.Response{Response: resp}
|
||||
err = autorest.NewErrorWithError(err, "resources.OperationsClient", "List", resp, "Failure sending request")
|
||||
return
|
||||
}
|
||||
|
||||
result.olr, err = client.ListResponder(resp)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "resources.OperationsClient", "List", resp, "Failure responding to request")
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// ListPreparer prepares the List request.
|
||||
func (client OperationsClient) ListPreparer(ctx context.Context) (*http.Request, error) {
|
||||
const APIVersion = "2018-05-01"
|
||||
queryParameters := map[string]interface{}{
|
||||
"api-version": APIVersion,
|
||||
}
|
||||
|
||||
preparer := autorest.CreatePreparer(
|
||||
autorest.AsGet(),
|
||||
autorest.WithBaseURL(client.BaseURI),
|
||||
autorest.WithPath("/providers/Microsoft.Resources/operations"),
|
||||
autorest.WithQueryParameters(queryParameters))
|
||||
return preparer.Prepare((&http.Request{}).WithContext(ctx))
|
||||
}
|
||||
|
||||
// ListSender sends the List request. The method will close the
|
||||
// http.Response Body if it receives an error.
|
||||
func (client OperationsClient) ListSender(req *http.Request) (*http.Response, error) {
|
||||
return autorest.SendWithSender(client, req,
|
||||
autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
|
||||
}
|
||||
|
||||
// ListResponder handles the response to the List request. The method always
|
||||
// closes the http.Response Body.
|
||||
func (client OperationsClient) ListResponder(resp *http.Response) (result OperationListResult, err error) {
|
||||
err = autorest.Respond(
|
||||
resp,
|
||||
client.ByInspecting(),
|
||||
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
||||
autorest.ByUnmarshallingJSON(&result),
|
||||
autorest.ByClosing())
|
||||
result.Response = autorest.Response{Response: resp}
|
||||
return
|
||||
}
|
||||
|
||||
// listNextResults retrieves the next set of results, if any.
|
||||
func (client OperationsClient) listNextResults(lastResults OperationListResult) (result OperationListResult, err error) {
|
||||
req, err := lastResults.operationListResultPreparer()
|
||||
if err != nil {
|
||||
return result, autorest.NewErrorWithError(err, "resources.OperationsClient", "listNextResults", nil, "Failure preparing next results request")
|
||||
}
|
||||
if req == nil {
|
||||
return
|
||||
}
|
||||
resp, err := client.ListSender(req)
|
||||
if err != nil {
|
||||
result.Response = autorest.Response{Response: resp}
|
||||
return result, autorest.NewErrorWithError(err, "resources.OperationsClient", "listNextResults", resp, "Failure sending next results request")
|
||||
}
|
||||
result, err = client.ListResponder(resp)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "resources.OperationsClient", "listNextResults", resp, "Failure responding to next results request")
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// ListComplete enumerates all values, automatically crossing page boundaries as required.
|
||||
func (client OperationsClient) ListComplete(ctx context.Context) (result OperationListResultIterator, err error) {
|
||||
result.page, err = client.List(ctx)
|
||||
return
|
||||
}
|
||||
@@ -1166,7 +1166,7 @@ type Restriction struct {
|
||||
Type *string `json:"type,omitempty"`
|
||||
// Values - The value of restrictions. If the restriction type is set to location. This would be different locations where the SKU is restricted.
|
||||
Values *[]string `json:"values,omitempty"`
|
||||
// ReasonCode - The reason for the restriction. As of now this can be “QuotaId” or “NotAvailableForSubscription”. Quota Id is set when the SKU has requiredQuotas parameter as the subscription does not belong to that quota. The “NotAvailableForSubscription” is related to capacity at DC. Possible values include: 'QuotaID', 'NotAvailableForSubscription'
|
||||
// ReasonCode - The reason for the restriction. As of now this can be "QuotaId" or "NotAvailableForSubscription". Quota Id is set when the SKU has requiredQuotas parameter as the subscription does not belong to that quota. The "NotAvailableForSubscription" is related to capacity at DC. Possible values include: 'QuotaID', 'NotAvailableForSubscription'
|
||||
ReasonCode ReasonCode `json:"reasonCode,omitempty"`
|
||||
}
|
||||
|
||||
|
||||
@@ -1676,6 +1676,8 @@ type OperationDisplay struct {
|
||||
Resource *string `json:"resource,omitempty"`
|
||||
// Operation - Type of operation: get, read, delete, etc.
|
||||
Operation *string `json:"operation,omitempty"`
|
||||
// Description - Description of the operation.
|
||||
Description *string `json:"description,omitempty"`
|
||||
}
|
||||
|
||||
// OperationListResult result of the request to list Storage operations. It contains a list of operations and a URL
|
||||
@@ -1719,7 +1721,7 @@ type Restriction struct {
|
||||
Type *string `json:"type,omitempty"`
|
||||
// Values - The value of restrictions. If the restriction type is set to location. This would be different locations where the SKU is restricted.
|
||||
Values *[]string `json:"values,omitempty"`
|
||||
// ReasonCode - The reason for the restriction. As of now this can be “QuotaId” or “NotAvailableForSubscription”. Quota Id is set when the SKU has requiredQuotas parameter as the subscription does not belong to that quota. The “NotAvailableForSubscription” is related to capacity at DC. Possible values include: 'QuotaID', 'NotAvailableForSubscription'
|
||||
// ReasonCode - The reason for the restriction. As of now this can be "QuotaId" or "NotAvailableForSubscription". Quota Id is set when the SKU has requiredQuotas parameter as the subscription does not belong to that quota. The "NotAvailableForSubscription" is related to capacity at DC. Possible values include: 'QuotaID', 'NotAvailableForSubscription'
|
||||
ReasonCode ReasonCode `json:"reasonCode,omitempty"`
|
||||
}
|
||||
|
||||
|
||||
2
vendor/github.com/Azure/azure-sdk-for-go/version/version.go
generated
vendored
2
vendor/github.com/Azure/azure-sdk-for-go/version/version.go
generated
vendored
@@ -18,4 +18,4 @@ package version
|
||||
// Changes may cause incorrect behavior and will be lost if the code is regenerated.
|
||||
|
||||
// Number contains the semantic version of this SDK.
|
||||
const Number = "v19.1.0"
|
||||
const Number = "v21.1.0"
|
||||
|
||||
2
vendor/github.com/Azure/go-autorest/autorest/sender.go
generated
vendored
2
vendor/github.com/Azure/go-autorest/autorest/sender.go
generated
vendored
@@ -234,7 +234,7 @@ func DoRetryForStatusCodes(attempts int, backoff time.Duration, codes ...int) Se
|
||||
}
|
||||
delayed := DelayWithRetryAfter(resp, r.Context().Done())
|
||||
if !delayed && !DelayForBackoff(backoff, attempt, r.Context().Done()) {
|
||||
return resp, r.Context().Err()
|
||||
return nil, r.Context().Err()
|
||||
}
|
||||
// don't count a 429 against the number of attempts
|
||||
// so that we continue to retry until it succeeds
|
||||
|
||||
2
vendor/github.com/Azure/go-autorest/version/version.go
generated
vendored
2
vendor/github.com/Azure/go-autorest/version/version.go
generated
vendored
@@ -20,7 +20,7 @@ import (
|
||||
)
|
||||
|
||||
// Number contains the semantic version of this SDK.
|
||||
const Number = "v10.15.5"
|
||||
const Number = "v10.15.4"
|
||||
|
||||
var (
|
||||
userAgent = fmt.Sprintf("Go/%s (%s-%s) go-autorest/%s",
|
||||
|
||||
1
vendor/github.com/Shopify/sarama/.gitignore
generated
vendored
1
vendor/github.com/Shopify/sarama/.gitignore
generated
vendored
@@ -24,3 +24,4 @@ _testmain.go
|
||||
*.exe
|
||||
|
||||
coverage.txt
|
||||
profile.out
|
||||
|
||||
10
vendor/github.com/Shopify/sarama/.travis.yml
generated
vendored
10
vendor/github.com/Shopify/sarama/.travis.yml
generated
vendored
@@ -1,8 +1,8 @@
|
||||
language: go
|
||||
go:
|
||||
- 1.8.x
|
||||
- 1.9.x
|
||||
- 1.10.x
|
||||
- 1.9.7
|
||||
- 1.10.4
|
||||
- 1.11
|
||||
|
||||
env:
|
||||
global:
|
||||
@@ -12,9 +12,9 @@ env:
|
||||
- KAFKA_HOSTNAME=localhost
|
||||
- DEBUG=true
|
||||
matrix:
|
||||
- KAFKA_VERSION=0.11.0.2
|
||||
- KAFKA_VERSION=1.0.0
|
||||
- KAFKA_VERSION=1.1.0
|
||||
- KAFKA_VERSION=2.0.0
|
||||
|
||||
before_install:
|
||||
- export REPOSITORY_ROOT=${TRAVIS_BUILD_DIR}
|
||||
@@ -28,7 +28,7 @@ script:
|
||||
- make test
|
||||
- make vet
|
||||
- make errcheck
|
||||
- make fmt
|
||||
- if [ "$TRAVIS_GO_VERSION" = "1.11" ]; then make fmt; fi
|
||||
|
||||
after_success:
|
||||
- bash <(curl -s https://codecov.io/bash)
|
||||
|
||||
52
vendor/github.com/Shopify/sarama/CHANGELOG.md
generated
vendored
52
vendor/github.com/Shopify/sarama/CHANGELOG.md
generated
vendored
@@ -1,5 +1,57 @@
|
||||
# Changelog
|
||||
|
||||
#### Version 1.19.0 (2018-09-27)
|
||||
|
||||
New Features:
|
||||
- Implement a higher-level consumer group
|
||||
([#1099](https://github.com/Shopify/sarama/pull/1099)).
|
||||
|
||||
Improvements:
|
||||
- Add support for Go 1.11
|
||||
([#1176](https://github.com/Shopify/sarama/pull/1176)).
|
||||
|
||||
Bug Fixes:
|
||||
- Fix encoding of `MetadataResponse` with version 2 and higher
|
||||
([#1174](https://github.com/Shopify/sarama/pull/1174)).
|
||||
- Fix race condition in mock async producer
|
||||
([#1174](https://github.com/Shopify/sarama/pull/1174)).
|
||||
|
||||
#### Version 1.18.0 (2018-09-07)
|
||||
|
||||
New Features:
|
||||
- Make `Partitioner.RequiresConsistency` vary per-message
|
||||
([#1112](https://github.com/Shopify/sarama/pull/1112)).
|
||||
- Add customizable partitioner
|
||||
([#1118](https://github.com/Shopify/sarama/pull/1118)).
|
||||
- Add `ClusterAdmin` support for `CreateTopic`, `DeleteTopic`, `CreatePartitions`,
|
||||
`DeleteRecords`, `DescribeConfig`, `AlterConfig`, `CreateACL`, `ListAcls`, `DeleteACL`
|
||||
([#1055](https://github.com/Shopify/sarama/pull/1055)).
|
||||
|
||||
Improvements:
|
||||
- Add support for Kafka 2.0.0
|
||||
([#1149](https://github.com/Shopify/sarama/pull/1149)).
|
||||
- Allow setting `LocalAddr` when dialing an address to support multi-homed hosts
|
||||
([#1123](https://github.com/Shopify/sarama/pull/1123)).
|
||||
- Simpler offset management
|
||||
([#1127](https://github.com/Shopify/sarama/pull/1127)).
|
||||
|
||||
Bug Fixes:
|
||||
- Fix mutation of `ProducerMessage.MetaData` when producing to Kafka
|
||||
([#1110](https://github.com/Shopify/sarama/pull/1110)).
|
||||
- Fix consumer block when response did not contain all the
|
||||
expected topic/partition blocks
|
||||
([#1086](https://github.com/Shopify/sarama/pull/1086)).
|
||||
- Fix consumer block when response contains only constrol messages
|
||||
([#1115](https://github.com/Shopify/sarama/pull/1115)).
|
||||
- Add timeout config for ClusterAdmin requests
|
||||
([#1142](https://github.com/Shopify/sarama/pull/1142)).
|
||||
- Add version check when producing message with headers
|
||||
([#1117](https://github.com/Shopify/sarama/pull/1117)).
|
||||
- Fix `MetadataRequest` for empty list of topics
|
||||
([#1132](https://github.com/Shopify/sarama/pull/1132)).
|
||||
- Fix producer topic metadata on-demand fetch when topic error happens in metadata response
|
||||
([#1125](https://github.com/Shopify/sarama/pull/1125)).
|
||||
|
||||
#### Version 1.17.0 (2018-05-30)
|
||||
|
||||
New Features:
|
||||
|
||||
2
vendor/github.com/Shopify/sarama/Makefile
generated
vendored
2
vendor/github.com/Shopify/sarama/Makefile
generated
vendored
@@ -4,7 +4,7 @@ default: fmt vet errcheck test
|
||||
test:
|
||||
echo "" > coverage.txt
|
||||
for d in `go list ./... | grep -v vendor`; do \
|
||||
go test -p 1 -v -timeout 90s -race -coverprofile=profile.out -covermode=atomic $$d || exit 1; \
|
||||
go test -p 1 -v -timeout 240s -race -coverprofile=profile.out -covermode=atomic $$d || exit 1; \
|
||||
if [ -f profile.out ]; then \
|
||||
cat profile.out >> coverage.txt; \
|
||||
rm profile.out; \
|
||||
|
||||
2
vendor/github.com/Shopify/sarama/README.md
generated
vendored
2
vendor/github.com/Shopify/sarama/README.md
generated
vendored
@@ -21,7 +21,7 @@ You might also want to look at the [Frequently Asked Questions](https://github.c
|
||||
Sarama provides a "2 releases + 2 months" compatibility guarantee: we support
|
||||
the two latest stable releases of Kafka and Go, and we provide a two month
|
||||
grace period for older releases. This means we currently officially support
|
||||
Go 1.8 through 1.10, and Kafka 0.11 through 1.1, although older releases are
|
||||
Go 1.8 through 1.11, and Kafka 1.0 through 2.0, although older releases are
|
||||
still likely to work.
|
||||
|
||||
Sarama follows semantic versioning and provides API stability via the gopkg.in service.
|
||||
|
||||
382
vendor/github.com/Shopify/sarama/admin.go
generated
vendored
Normal file
382
vendor/github.com/Shopify/sarama/admin.go
generated
vendored
Normal file
@@ -0,0 +1,382 @@
|
||||
package sarama
|
||||
|
||||
import "errors"
|
||||
|
||||
// ClusterAdmin is the administrative client for Kafka, which supports managing and inspecting topics,
|
||||
// brokers, configurations and ACLs. The minimum broker version required is 0.10.0.0.
|
||||
// Methods with stricter requirements will specify the minimum broker version required.
|
||||
// You MUST call Close() on a client to avoid leaks
|
||||
type ClusterAdmin interface {
|
||||
// Creates a new topic. This operation is supported by brokers with version 0.10.1.0 or higher.
|
||||
// It may take several seconds after CreateTopic returns success for all the brokers
|
||||
// to become aware that the topic has been created. During this time, listTopics
|
||||
// may not return information about the new topic.The validateOnly option is supported from version 0.10.2.0.
|
||||
CreateTopic(topic string, detail *TopicDetail, validateOnly bool) error
|
||||
|
||||
// Delete a topic. It may take several seconds after the DeleteTopic to returns success
|
||||
// and for all the brokers to become aware that the topics are gone.
|
||||
// During this time, listTopics may continue to return information about the deleted topic.
|
||||
// If delete.topic.enable is false on the brokers, deleteTopic will mark
|
||||
// the topic for deletion, but not actually delete them.
|
||||
// This operation is supported by brokers with version 0.10.1.0 or higher.
|
||||
DeleteTopic(topic string) error
|
||||
|
||||
// Increase the number of partitions of the topics according to the corresponding values.
|
||||
// If partitions are increased for a topic that has a key, the partition logic or ordering of
|
||||
// the messages will be affected. It may take several seconds after this method returns
|
||||
// success for all the brokers to become aware that the partitions have been created.
|
||||
// During this time, ClusterAdmin#describeTopics may not return information about the
|
||||
// new partitions. This operation is supported by brokers with version 1.0.0 or higher.
|
||||
CreatePartitions(topic string, count int32, assignment [][]int32, validateOnly bool) error
|
||||
|
||||
// Delete records whose offset is smaller than the given offset of the corresponding partition.
|
||||
// This operation is supported by brokers with version 0.11.0.0 or higher.
|
||||
DeleteRecords(topic string, partitionOffsets map[int32]int64) error
|
||||
|
||||
// Get the configuration for the specified resources.
|
||||
// The returned configuration includes default values and the Default is true
|
||||
// can be used to distinguish them from user supplied values.
|
||||
// Config entries where ReadOnly is true cannot be updated.
|
||||
// The value of config entries where Sensitive is true is always nil so
|
||||
// sensitive information is not disclosed.
|
||||
// This operation is supported by brokers with version 0.11.0.0 or higher.
|
||||
DescribeConfig(resource ConfigResource) ([]ConfigEntry, error)
|
||||
|
||||
// Update the configuration for the specified resources with the default options.
|
||||
// This operation is supported by brokers with version 0.11.0.0 or higher.
|
||||
// The resources with their configs (topic is the only resource type with configs
|
||||
// that can be updated currently Updates are not transactional so they may succeed
|
||||
// for some resources while fail for others. The configs for a particular resource are updated automatically.
|
||||
AlterConfig(resourceType ConfigResourceType, name string, entries map[string]*string, validateOnly bool) error
|
||||
|
||||
// Creates access control lists (ACLs) which are bound to specific resources.
|
||||
// This operation is not transactional so it may succeed for some ACLs while fail for others.
|
||||
// If you attempt to add an ACL that duplicates an existing ACL, no error will be raised, but
|
||||
// no changes will be made. This operation is supported by brokers with version 0.11.0.0 or higher.
|
||||
CreateACL(resource Resource, acl Acl) error
|
||||
|
||||
// Lists access control lists (ACLs) according to the supplied filter.
|
||||
// it may take some time for changes made by createAcls or deleteAcls to be reflected in the output of ListAcls
|
||||
// This operation is supported by brokers with version 0.11.0.0 or higher.
|
||||
ListAcls(filter AclFilter) ([]ResourceAcls, error)
|
||||
|
||||
// Deletes access control lists (ACLs) according to the supplied filters.
|
||||
// This operation is not transactional so it may succeed for some ACLs while fail for others.
|
||||
// This operation is supported by brokers with version 0.11.0.0 or higher.
|
||||
DeleteACL(filter AclFilter, validateOnly bool) ([]MatchingAcl, error)
|
||||
|
||||
// Close shuts down the admin and closes underlying client.
|
||||
Close() error
|
||||
}
|
||||
|
||||
type clusterAdmin struct {
|
||||
client Client
|
||||
conf *Config
|
||||
}
|
||||
|
||||
// NewClusterAdmin creates a new ClusterAdmin using the given broker addresses and configuration.
|
||||
func NewClusterAdmin(addrs []string, conf *Config) (ClusterAdmin, error) {
|
||||
client, err := NewClient(addrs, conf)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
//make sure we can retrieve the controller
|
||||
_, err = client.Controller()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
ca := &clusterAdmin{
|
||||
client: client,
|
||||
conf: client.Config(),
|
||||
}
|
||||
return ca, nil
|
||||
}
|
||||
|
||||
func (ca *clusterAdmin) Close() error {
|
||||
return ca.client.Close()
|
||||
}
|
||||
|
||||
func (ca *clusterAdmin) Controller() (*Broker, error) {
|
||||
return ca.client.Controller()
|
||||
}
|
||||
|
||||
func (ca *clusterAdmin) CreateTopic(topic string, detail *TopicDetail, validateOnly bool) error {
|
||||
|
||||
if topic == "" {
|
||||
return ErrInvalidTopic
|
||||
}
|
||||
|
||||
if detail == nil {
|
||||
return errors.New("You must specify topic details")
|
||||
}
|
||||
|
||||
topicDetails := make(map[string]*TopicDetail)
|
||||
topicDetails[topic] = detail
|
||||
|
||||
request := &CreateTopicsRequest{
|
||||
TopicDetails: topicDetails,
|
||||
ValidateOnly: validateOnly,
|
||||
Timeout: ca.conf.Admin.Timeout,
|
||||
}
|
||||
|
||||
if ca.conf.Version.IsAtLeast(V0_11_0_0) {
|
||||
request.Version = 1
|
||||
}
|
||||
if ca.conf.Version.IsAtLeast(V1_0_0_0) {
|
||||
request.Version = 2
|
||||
}
|
||||
|
||||
b, err := ca.Controller()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
rsp, err := b.CreateTopics(request)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
topicErr, ok := rsp.TopicErrors[topic]
|
||||
if !ok {
|
||||
return ErrIncompleteResponse
|
||||
}
|
||||
|
||||
if topicErr.Err != ErrNoError {
|
||||
return topicErr.Err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (ca *clusterAdmin) DeleteTopic(topic string) error {
|
||||
|
||||
if topic == "" {
|
||||
return ErrInvalidTopic
|
||||
}
|
||||
|
||||
request := &DeleteTopicsRequest{
|
||||
Topics: []string{topic},
|
||||
Timeout: ca.conf.Admin.Timeout,
|
||||
}
|
||||
|
||||
if ca.conf.Version.IsAtLeast(V0_11_0_0) {
|
||||
request.Version = 1
|
||||
}
|
||||
|
||||
b, err := ca.Controller()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
rsp, err := b.DeleteTopics(request)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
topicErr, ok := rsp.TopicErrorCodes[topic]
|
||||
if !ok {
|
||||
return ErrIncompleteResponse
|
||||
}
|
||||
|
||||
if topicErr != ErrNoError {
|
||||
return topicErr
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (ca *clusterAdmin) CreatePartitions(topic string, count int32, assignment [][]int32, validateOnly bool) error {
|
||||
if topic == "" {
|
||||
return ErrInvalidTopic
|
||||
}
|
||||
|
||||
topicPartitions := make(map[string]*TopicPartition)
|
||||
topicPartitions[topic] = &TopicPartition{Count: count, Assignment: assignment}
|
||||
|
||||
request := &CreatePartitionsRequest{
|
||||
TopicPartitions: topicPartitions,
|
||||
Timeout: ca.conf.Admin.Timeout,
|
||||
}
|
||||
|
||||
b, err := ca.Controller()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
rsp, err := b.CreatePartitions(request)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
topicErr, ok := rsp.TopicPartitionErrors[topic]
|
||||
if !ok {
|
||||
return ErrIncompleteResponse
|
||||
}
|
||||
|
||||
if topicErr.Err != ErrNoError {
|
||||
return topicErr.Err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (ca *clusterAdmin) DeleteRecords(topic string, partitionOffsets map[int32]int64) error {
|
||||
|
||||
if topic == "" {
|
||||
return ErrInvalidTopic
|
||||
}
|
||||
|
||||
topics := make(map[string]*DeleteRecordsRequestTopic)
|
||||
topics[topic] = &DeleteRecordsRequestTopic{PartitionOffsets: partitionOffsets}
|
||||
request := &DeleteRecordsRequest{
|
||||
Topics: topics,
|
||||
Timeout: ca.conf.Admin.Timeout,
|
||||
}
|
||||
|
||||
b, err := ca.Controller()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
rsp, err := b.DeleteRecords(request)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
_, ok := rsp.Topics[topic]
|
||||
if !ok {
|
||||
return ErrIncompleteResponse
|
||||
}
|
||||
|
||||
//todo since we are dealing with couple of partitions it would be good if we return slice of errors
|
||||
//for each partition instead of one error
|
||||
return nil
|
||||
}
|
||||
|
||||
func (ca *clusterAdmin) DescribeConfig(resource ConfigResource) ([]ConfigEntry, error) {
|
||||
|
||||
var entries []ConfigEntry
|
||||
var resources []*ConfigResource
|
||||
resources = append(resources, &resource)
|
||||
|
||||
request := &DescribeConfigsRequest{
|
||||
Resources: resources,
|
||||
}
|
||||
|
||||
b, err := ca.Controller()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
rsp, err := b.DescribeConfigs(request)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
for _, rspResource := range rsp.Resources {
|
||||
if rspResource.Name == resource.Name {
|
||||
if rspResource.ErrorMsg != "" {
|
||||
return nil, errors.New(rspResource.ErrorMsg)
|
||||
}
|
||||
for _, cfgEntry := range rspResource.Configs {
|
||||
entries = append(entries, *cfgEntry)
|
||||
}
|
||||
}
|
||||
}
|
||||
return entries, nil
|
||||
}
|
||||
|
||||
func (ca *clusterAdmin) AlterConfig(resourceType ConfigResourceType, name string, entries map[string]*string, validateOnly bool) error {
|
||||
|
||||
var resources []*AlterConfigsResource
|
||||
resources = append(resources, &AlterConfigsResource{
|
||||
Type: resourceType,
|
||||
Name: name,
|
||||
ConfigEntries: entries,
|
||||
})
|
||||
|
||||
request := &AlterConfigsRequest{
|
||||
Resources: resources,
|
||||
ValidateOnly: validateOnly,
|
||||
}
|
||||
|
||||
b, err := ca.Controller()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
rsp, err := b.AlterConfigs(request)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for _, rspResource := range rsp.Resources {
|
||||
if rspResource.Name == name {
|
||||
if rspResource.ErrorMsg != "" {
|
||||
return errors.New(rspResource.ErrorMsg)
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (ca *clusterAdmin) CreateACL(resource Resource, acl Acl) error {
|
||||
var acls []*AclCreation
|
||||
acls = append(acls, &AclCreation{resource, acl})
|
||||
request := &CreateAclsRequest{AclCreations: acls}
|
||||
|
||||
b, err := ca.Controller()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
_, err = b.CreateAcls(request)
|
||||
return err
|
||||
}
|
||||
|
||||
func (ca *clusterAdmin) ListAcls(filter AclFilter) ([]ResourceAcls, error) {
|
||||
|
||||
request := &DescribeAclsRequest{AclFilter: filter}
|
||||
|
||||
b, err := ca.Controller()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
rsp, err := b.DescribeAcls(request)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var lAcls []ResourceAcls
|
||||
for _, rAcl := range rsp.ResourceAcls {
|
||||
lAcls = append(lAcls, *rAcl)
|
||||
}
|
||||
return lAcls, nil
|
||||
}
|
||||
|
||||
func (ca *clusterAdmin) DeleteACL(filter AclFilter, validateOnly bool) ([]MatchingAcl, error) {
|
||||
var filters []*AclFilter
|
||||
filters = append(filters, &filter)
|
||||
request := &DeleteAclsRequest{Filters: filters}
|
||||
|
||||
b, err := ca.Controller()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
rsp, err := b.DeleteAcls(request)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var mAcls []MatchingAcl
|
||||
for _, fr := range rsp.FilterResponses {
|
||||
for _, mACL := range fr.MatchingAcls {
|
||||
mAcls = append(mAcls, *mACL)
|
||||
}
|
||||
|
||||
}
|
||||
return mAcls, nil
|
||||
}
|
||||
17
vendor/github.com/Shopify/sarama/async_producer.go
generated
vendored
17
vendor/github.com/Shopify/sarama/async_producer.go
generated
vendored
@@ -145,8 +145,9 @@ type ProducerMessage struct {
|
||||
// least version 0.10.0.
|
||||
Timestamp time.Time
|
||||
|
||||
retries int
|
||||
flags flagSet
|
||||
retries int
|
||||
flags flagSet
|
||||
expectation chan *ProducerError
|
||||
}
|
||||
|
||||
const producerMessageOverhead = 26 // the metadata overhead of CRC, flags, etc.
|
||||
@@ -270,6 +271,9 @@ func (p *asyncProducer) dispatcher() {
|
||||
version := 1
|
||||
if p.conf.Version.IsAtLeast(V0_11_0_0) {
|
||||
version = 2
|
||||
} else if msg.Headers != nil {
|
||||
p.returnError(msg, ConfigurationError("Producing headers requires Kafka at least v0.11"))
|
||||
continue
|
||||
}
|
||||
if msg.byteSize(version) > p.conf.Producer.MaxMessageBytes {
|
||||
p.returnError(msg, ErrMessageSizeTooLarge)
|
||||
@@ -343,7 +347,14 @@ func (tp *topicProducer) partitionMessage(msg *ProducerMessage) error {
|
||||
var partitions []int32
|
||||
|
||||
err := tp.breaker.Run(func() (err error) {
|
||||
if tp.partitioner.RequiresConsistency() {
|
||||
var requiresConsistency = false
|
||||
if ep, ok := tp.partitioner.(DynamicConsistencyPartitioner); ok {
|
||||
requiresConsistency = ep.MessageRequiresConsistency(msg)
|
||||
} else {
|
||||
requiresConsistency = tp.partitioner.RequiresConsistency()
|
||||
}
|
||||
|
||||
if requiresConsistency {
|
||||
partitions, err = tp.parent.client.Partitions(msg.Topic)
|
||||
} else {
|
||||
partitions, err = tp.parent.client.WritablePartitions(msg.Topic)
|
||||
|
||||
129
vendor/github.com/Shopify/sarama/balance_strategy.go
generated
vendored
Normal file
129
vendor/github.com/Shopify/sarama/balance_strategy.go
generated
vendored
Normal file
@@ -0,0 +1,129 @@
|
||||
package sarama
|
||||
|
||||
import (
|
||||
"math"
|
||||
"sort"
|
||||
)
|
||||
|
||||
// BalanceStrategyPlan is the results of any BalanceStrategy.Plan attempt.
|
||||
// It contains an allocation of topic/partitions by memberID in the form of
|
||||
// a `memberID -> topic -> partitions` map.
|
||||
type BalanceStrategyPlan map[string]map[string][]int32
|
||||
|
||||
// Add assigns a topic with a number partitions to a member.
|
||||
func (p BalanceStrategyPlan) Add(memberID, topic string, partitions ...int32) {
|
||||
if len(partitions) == 0 {
|
||||
return
|
||||
}
|
||||
if _, ok := p[memberID]; !ok {
|
||||
p[memberID] = make(map[string][]int32, 1)
|
||||
}
|
||||
p[memberID][topic] = append(p[memberID][topic], partitions...)
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
// BalanceStrategy is used to balance topics and partitions
|
||||
// across memebers of a consumer group
|
||||
type BalanceStrategy interface {
|
||||
// Name uniquely identifies the strategy.
|
||||
Name() string
|
||||
|
||||
// Plan accepts a map of `memberID -> metadata` and a map of `topic -> partitions`
|
||||
// and returns a distribution plan.
|
||||
Plan(members map[string]ConsumerGroupMemberMetadata, topics map[string][]int32) (BalanceStrategyPlan, error)
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
// BalanceStrategyRange is the default and assigns partitions as ranges to consumer group members.
|
||||
// Example with one topic T with six partitions (0..5) and two members (M1, M2):
|
||||
// M1: {T: [0, 1, 2]}
|
||||
// M2: {T: [3, 4, 5]}
|
||||
var BalanceStrategyRange = &balanceStrategy{
|
||||
name: "range",
|
||||
coreFn: func(plan BalanceStrategyPlan, memberIDs []string, topic string, partitions []int32) {
|
||||
step := float64(len(partitions)) / float64(len(memberIDs))
|
||||
|
||||
for i, memberID := range memberIDs {
|
||||
pos := float64(i)
|
||||
min := int(math.Floor(pos*step + 0.5))
|
||||
max := int(math.Floor((pos+1)*step + 0.5))
|
||||
plan.Add(memberID, topic, partitions[min:max]...)
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
// BalanceStrategyRoundRobin assigns partitions to members in alternating order.
|
||||
// Example with topic T with six partitions (0..5) and two members (M1, M2):
|
||||
// M1: {T: [0, 2, 4]}
|
||||
// M2: {T: [1, 3, 5]}
|
||||
var BalanceStrategyRoundRobin = &balanceStrategy{
|
||||
name: "roundrobin",
|
||||
coreFn: func(plan BalanceStrategyPlan, memberIDs []string, topic string, partitions []int32) {
|
||||
for i, part := range partitions {
|
||||
memberID := memberIDs[i%len(memberIDs)]
|
||||
plan.Add(memberID, topic, part)
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
type balanceStrategy struct {
|
||||
name string
|
||||
coreFn func(plan BalanceStrategyPlan, memberIDs []string, topic string, partitions []int32)
|
||||
}
|
||||
|
||||
// Name implements BalanceStrategy.
|
||||
func (s *balanceStrategy) Name() string { return s.name }
|
||||
|
||||
// Balance implements BalanceStrategy.
|
||||
func (s *balanceStrategy) Plan(members map[string]ConsumerGroupMemberMetadata, topics map[string][]int32) (BalanceStrategyPlan, error) {
|
||||
// Build members by topic map
|
||||
mbt := make(map[string][]string)
|
||||
for memberID, meta := range members {
|
||||
for _, topic := range meta.Topics {
|
||||
mbt[topic] = append(mbt[topic], memberID)
|
||||
}
|
||||
}
|
||||
|
||||
// Sort members for each topic
|
||||
for topic, memberIDs := range mbt {
|
||||
sort.Sort(&balanceStrategySortable{
|
||||
topic: topic,
|
||||
memberIDs: memberIDs,
|
||||
})
|
||||
}
|
||||
|
||||
// Assemble plan
|
||||
plan := make(BalanceStrategyPlan, len(members))
|
||||
for topic, memberIDs := range mbt {
|
||||
s.coreFn(plan, memberIDs, topic, topics[topic])
|
||||
}
|
||||
return plan, nil
|
||||
}
|
||||
|
||||
type balanceStrategySortable struct {
|
||||
topic string
|
||||
memberIDs []string
|
||||
}
|
||||
|
||||
func (p balanceStrategySortable) Len() int { return len(p.memberIDs) }
|
||||
func (p balanceStrategySortable) Swap(i, j int) {
|
||||
p.memberIDs[i], p.memberIDs[j] = p.memberIDs[j], p.memberIDs[i]
|
||||
}
|
||||
func (p balanceStrategySortable) Less(i, j int) bool {
|
||||
return balanceStrategyHashValue(p.topic, p.memberIDs[i]) < balanceStrategyHashValue(p.topic, p.memberIDs[j])
|
||||
}
|
||||
|
||||
func balanceStrategyHashValue(vv ...string) uint32 {
|
||||
h := uint32(2166136261)
|
||||
for _, s := range vv {
|
||||
for _, c := range s {
|
||||
h ^= uint32(c)
|
||||
h *= 16777619
|
||||
}
|
||||
}
|
||||
return h
|
||||
}
|
||||
23
vendor/github.com/Shopify/sarama/broker.go
generated
vendored
23
vendor/github.com/Shopify/sarama/broker.go
generated
vendored
@@ -86,6 +86,7 @@ func (b *Broker) Open(conf *Config) error {
|
||||
dialer := net.Dialer{
|
||||
Timeout: conf.Net.DialTimeout,
|
||||
KeepAlive: conf.Net.KeepAlive,
|
||||
LocalAddr: conf.Net.LocalAddr,
|
||||
}
|
||||
|
||||
if conf.Net.TLS.Enable {
|
||||
@@ -386,17 +387,6 @@ func (b *Broker) ApiVersions(request *ApiVersionsRequest) (*ApiVersionsResponse,
|
||||
return response, nil
|
||||
}
|
||||
|
||||
func (b *Broker) CreatePartitions(request *CreatePartitionsRequest) (*CreatePartitionsResponse, error) {
|
||||
response := new(CreatePartitionsResponse)
|
||||
|
||||
err := b.sendAndReceive(request, response)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return response, nil
|
||||
}
|
||||
|
||||
func (b *Broker) CreateTopics(request *CreateTopicsRequest) (*CreateTopicsResponse, error) {
|
||||
response := new(CreateTopicsResponse)
|
||||
|
||||
@@ -419,6 +409,17 @@ func (b *Broker) DeleteTopics(request *DeleteTopicsRequest) (*DeleteTopicsRespon
|
||||
return response, nil
|
||||
}
|
||||
|
||||
func (b *Broker) CreatePartitions(request *CreatePartitionsRequest) (*CreatePartitionsResponse, error) {
|
||||
response := new(CreatePartitionsResponse)
|
||||
|
||||
err := b.sendAndReceive(request, response)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return response, nil
|
||||
}
|
||||
|
||||
func (b *Broker) DeleteRecords(request *DeleteRecordsRequest) (*DeleteRecordsResponse, error) {
|
||||
response := new(DeleteRecordsResponse)
|
||||
|
||||
|
||||
42
vendor/github.com/Shopify/sarama/client.go
generated
vendored
42
vendor/github.com/Shopify/sarama/client.go
generated
vendored
@@ -17,7 +17,7 @@ type Client interface {
|
||||
// altered after it has been created.
|
||||
Config() *Config
|
||||
|
||||
// Controller returns the cluster controller broker.
|
||||
// Controller returns the cluster controller broker. Requires Kafka 0.10 or higher.
|
||||
Controller() (*Broker, error)
|
||||
|
||||
// Brokers returns the current set of active brokers as retrieved from cluster metadata.
|
||||
@@ -100,10 +100,11 @@ type client struct {
|
||||
seedBrokers []*Broker
|
||||
deadSeeds []*Broker
|
||||
|
||||
controllerID int32 // cluster controller broker id
|
||||
brokers map[int32]*Broker // maps broker ids to brokers
|
||||
metadata map[string]map[int32]*PartitionMetadata // maps topics to partition ids to metadata
|
||||
coordinators map[string]int32 // Maps consumer group names to coordinating broker IDs
|
||||
controllerID int32 // cluster controller broker id
|
||||
brokers map[int32]*Broker // maps broker ids to brokers
|
||||
metadata map[string]map[int32]*PartitionMetadata // maps topics to partition ids to metadata
|
||||
metadataTopics map[string]none // topics that need to collect metadata
|
||||
coordinators map[string]int32 // Maps consumer group names to coordinating broker IDs
|
||||
|
||||
// If the number of partitions is large, we can get some churn calling cachedPartitions,
|
||||
// so the result is cached. It is important to update this value whenever metadata is changed
|
||||
@@ -136,6 +137,7 @@ func NewClient(addrs []string, conf *Config) (Client, error) {
|
||||
closed: make(chan none),
|
||||
brokers: make(map[int32]*Broker),
|
||||
metadata: make(map[string]map[int32]*PartitionMetadata),
|
||||
metadataTopics: make(map[string]none),
|
||||
cachedPartitionsResults: make(map[string][maxPartitionIndex][]int32),
|
||||
coordinators: make(map[string]int32),
|
||||
}
|
||||
@@ -207,6 +209,7 @@ func (client *client) Close() error {
|
||||
|
||||
client.brokers = nil
|
||||
client.metadata = nil
|
||||
client.metadataTopics = nil
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -231,6 +234,22 @@ func (client *client) Topics() ([]string, error) {
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
func (client *client) MetadataTopics() ([]string, error) {
|
||||
if client.Closed() {
|
||||
return nil, ErrClosedClient
|
||||
}
|
||||
|
||||
client.lock.RLock()
|
||||
defer client.lock.RUnlock()
|
||||
|
||||
ret := make([]string, 0, len(client.metadataTopics))
|
||||
for topic := range client.metadataTopics {
|
||||
ret = append(ret, topic)
|
||||
}
|
||||
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
func (client *client) Partitions(topic string) ([]int32, error) {
|
||||
if client.Closed() {
|
||||
return nil, ErrClosedClient
|
||||
@@ -388,6 +407,10 @@ func (client *client) Controller() (*Broker, error) {
|
||||
return nil, ErrClosedClient
|
||||
}
|
||||
|
||||
if !client.conf.Version.IsAtLeast(V0_10_0_0) {
|
||||
return nil, ErrUnsupportedVersion
|
||||
}
|
||||
|
||||
controller := client.cachedController()
|
||||
if controller == nil {
|
||||
if err := client.refreshMetadata(); err != nil {
|
||||
@@ -645,7 +668,7 @@ func (client *client) refreshMetadata() error {
|
||||
topics := []string{}
|
||||
|
||||
if !client.conf.Metadata.Full {
|
||||
if specificTopics, err := client.Topics(); err != nil {
|
||||
if specificTopics, err := client.MetadataTopics(); err != nil {
|
||||
return err
|
||||
} else if len(specificTopics) == 0 {
|
||||
return ErrNoTopicsToUpdateMetadata
|
||||
@@ -728,9 +751,16 @@ func (client *client) updateMetadata(data *MetadataResponse, allKnownMetaData bo
|
||||
|
||||
if allKnownMetaData {
|
||||
client.metadata = make(map[string]map[int32]*PartitionMetadata)
|
||||
client.metadataTopics = make(map[string]none)
|
||||
client.cachedPartitionsResults = make(map[string][maxPartitionIndex][]int32)
|
||||
}
|
||||
for _, topic := range data.Topics {
|
||||
// topics must be added firstly to `metadataTopics` to guarantee that all
|
||||
// requested topics must be recorded to keep them trackable for periodically
|
||||
// metadata refresh.
|
||||
if _, exists := client.metadataTopics[topic.Name]; !exists {
|
||||
client.metadataTopics[topic.Name] = none{}
|
||||
}
|
||||
delete(client.metadata, topic.Name)
|
||||
delete(client.cachedPartitionsResults, topic.Name)
|
||||
|
||||
|
||||
119
vendor/github.com/Shopify/sarama/config.go
generated
vendored
119
vendor/github.com/Shopify/sarama/config.go
generated
vendored
@@ -5,6 +5,7 @@ import (
|
||||
"crypto/tls"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"net"
|
||||
"regexp"
|
||||
"time"
|
||||
|
||||
@@ -17,6 +18,13 @@ var validID = regexp.MustCompile(`\A[A-Za-z0-9._-]+\z`)
|
||||
|
||||
// Config is used to pass multiple configuration options to Sarama's constructors.
|
||||
type Config struct {
|
||||
// Admin is the namespace for ClusterAdmin properties used by the administrative Kafka client.
|
||||
Admin struct {
|
||||
// The maximum duration the administrative Kafka client will wait for ClusterAdmin operations,
|
||||
// including topics, brokers, configurations and ACLs (defaults to 3 seconds).
|
||||
Timeout time.Duration
|
||||
}
|
||||
|
||||
// Net is the namespace for network-level properties used by the Broker, and
|
||||
// shared by the Client/Producer/Consumer.
|
||||
Net struct {
|
||||
@@ -58,6 +66,12 @@ type Config struct {
|
||||
// KeepAlive specifies the keep-alive period for an active network connection.
|
||||
// If zero, keep-alives are disabled. (default is 0: disabled).
|
||||
KeepAlive time.Duration
|
||||
|
||||
// LocalAddr is the local address to use when dialing an
|
||||
// address. The address must be of a compatible type for the
|
||||
// network being dialed.
|
||||
// If nil, a local address is automatically chosen.
|
||||
LocalAddr net.Addr
|
||||
}
|
||||
|
||||
// Metadata is the namespace for metadata management properties used by the
|
||||
@@ -159,14 +173,55 @@ type Config struct {
|
||||
|
||||
// Consumer is the namespace for configuration related to consuming messages,
|
||||
// used by the Consumer.
|
||||
//
|
||||
// Note that Sarama's Consumer type does not currently support automatic
|
||||
// consumer-group rebalancing and offset tracking. For Zookeeper-based
|
||||
// tracking (Kafka 0.8.2 and earlier), the https://github.com/wvanbergen/kafka
|
||||
// library builds on Sarama to add this support. For Kafka-based tracking
|
||||
// (Kafka 0.9 and later), the https://github.com/bsm/sarama-cluster library
|
||||
// builds on Sarama to add this support.
|
||||
Consumer struct {
|
||||
|
||||
// Group is the namespace for configuring consumer group.
|
||||
Group struct {
|
||||
Session struct {
|
||||
// The timeout used to detect consumer failures when using Kafka's group management facility.
|
||||
// The consumer sends periodic heartbeats to indicate its liveness to the broker.
|
||||
// If no heartbeats are received by the broker before the expiration of this session timeout,
|
||||
// then the broker will remove this consumer from the group and initiate a rebalance.
|
||||
// Note that the value must be in the allowable range as configured in the broker configuration
|
||||
// by `group.min.session.timeout.ms` and `group.max.session.timeout.ms` (default 10s)
|
||||
Timeout time.Duration
|
||||
}
|
||||
Heartbeat struct {
|
||||
// The expected time between heartbeats to the consumer coordinator when using Kafka's group
|
||||
// management facilities. Heartbeats are used to ensure that the consumer's session stays active and
|
||||
// to facilitate rebalancing when new consumers join or leave the group.
|
||||
// The value must be set lower than Consumer.Group.Session.Timeout, but typically should be set no
|
||||
// higher than 1/3 of that value.
|
||||
// It can be adjusted even lower to control the expected time for normal rebalances (default 3s)
|
||||
Interval time.Duration
|
||||
}
|
||||
Rebalance struct {
|
||||
// Strategy for allocating topic partitions to members (default BalanceStrategyRange)
|
||||
Strategy BalanceStrategy
|
||||
// The maximum allowed time for each worker to join the group once a rebalance has begun.
|
||||
// This is basically a limit on the amount of time needed for all tasks to flush any pending
|
||||
// data and commit offsets. If the timeout is exceeded, then the worker will be removed from
|
||||
// the group, which will cause offset commit failures (default 60s).
|
||||
Timeout time.Duration
|
||||
|
||||
Retry struct {
|
||||
// When a new consumer joins a consumer group the set of consumers attempt to "rebalance"
|
||||
// the load to assign partitions to each consumer. If the set of consumers changes while
|
||||
// this assignment is taking place the rebalance will fail and retry. This setting controls
|
||||
// the maximum number of attempts before giving up (default 4).
|
||||
Max int
|
||||
// Backoff time between retries during rebalance (default 2s)
|
||||
Backoff time.Duration
|
||||
}
|
||||
}
|
||||
Member struct {
|
||||
// Custom metadata to include when joining the group. The user data for all joined members
|
||||
// can be retrieved by sending a DescribeGroupRequest to the broker that is the
|
||||
// coordinator for the group.
|
||||
UserData []byte
|
||||
}
|
||||
}
|
||||
|
||||
Retry struct {
|
||||
// How long to wait after a failing to read from a partition before
|
||||
// trying again (default 2s).
|
||||
@@ -248,6 +303,12 @@ type Config struct {
|
||||
// broker version 0.9.0 or later.
|
||||
// (default is 0: disabled).
|
||||
Retention time.Duration
|
||||
|
||||
Retry struct {
|
||||
// The total number of times to retry failing commit
|
||||
// requests during OffsetManager shutdown (default 3).
|
||||
Max int
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -279,6 +340,8 @@ type Config struct {
|
||||
func NewConfig() *Config {
|
||||
c := &Config{}
|
||||
|
||||
c.Admin.Timeout = 3 * time.Second
|
||||
|
||||
c.Net.MaxOpenRequests = 5
|
||||
c.Net.DialTimeout = 30 * time.Second
|
||||
c.Net.ReadTimeout = 30 * time.Second
|
||||
@@ -307,6 +370,14 @@ func NewConfig() *Config {
|
||||
c.Consumer.Return.Errors = false
|
||||
c.Consumer.Offsets.CommitInterval = 1 * time.Second
|
||||
c.Consumer.Offsets.Initial = OffsetNewest
|
||||
c.Consumer.Offsets.Retry.Max = 3
|
||||
|
||||
c.Consumer.Group.Session.Timeout = 10 * time.Second
|
||||
c.Consumer.Group.Heartbeat.Interval = 3 * time.Second
|
||||
c.Consumer.Group.Rebalance.Strategy = BalanceStrategyRange
|
||||
c.Consumer.Group.Rebalance.Timeout = 60 * time.Second
|
||||
c.Consumer.Group.Rebalance.Retry.Max = 4
|
||||
c.Consumer.Group.Rebalance.Retry.Backoff = 2 * time.Second
|
||||
|
||||
c.ClientID = defaultClientID
|
||||
c.ChannelBufferSize = 256
|
||||
@@ -355,6 +426,15 @@ func (c *Config) Validate() error {
|
||||
if c.Consumer.Offsets.Retention%time.Millisecond != 0 {
|
||||
Logger.Println("Consumer.Offsets.Retention only supports millisecond precision; nanoseconds will be truncated.")
|
||||
}
|
||||
if c.Consumer.Group.Session.Timeout%time.Millisecond != 0 {
|
||||
Logger.Println("Consumer.Group.Session.Timeout only supports millisecond precision; nanoseconds will be truncated.")
|
||||
}
|
||||
if c.Consumer.Group.Heartbeat.Interval%time.Millisecond != 0 {
|
||||
Logger.Println("Consumer.Group.Heartbeat.Interval only supports millisecond precision; nanoseconds will be truncated.")
|
||||
}
|
||||
if c.Consumer.Group.Rebalance.Timeout%time.Millisecond != 0 {
|
||||
Logger.Println("Consumer.Group.Rebalance.Timeout only supports millisecond precision; nanoseconds will be truncated.")
|
||||
}
|
||||
if c.ClientID == defaultClientID {
|
||||
Logger.Println("ClientID is the default of 'sarama', you should consider setting it to something application-specific.")
|
||||
}
|
||||
@@ -377,6 +457,12 @@ func (c *Config) Validate() error {
|
||||
return ConfigurationError("Net.SASL.Password must not be empty when SASL is enabled")
|
||||
}
|
||||
|
||||
// validate the Admin values
|
||||
switch {
|
||||
case c.Admin.Timeout <= 0:
|
||||
return ConfigurationError("Admin.Timeout must be > 0")
|
||||
}
|
||||
|
||||
// validate the Metadata values
|
||||
switch {
|
||||
case c.Metadata.Retry.Max < 0:
|
||||
@@ -443,7 +529,26 @@ func (c *Config) Validate() error {
|
||||
return ConfigurationError("Consumer.Offsets.CommitInterval must be > 0")
|
||||
case c.Consumer.Offsets.Initial != OffsetOldest && c.Consumer.Offsets.Initial != OffsetNewest:
|
||||
return ConfigurationError("Consumer.Offsets.Initial must be OffsetOldest or OffsetNewest")
|
||||
case c.Consumer.Offsets.Retry.Max < 0:
|
||||
return ConfigurationError("Consumer.Offsets.Retry.Max must be >= 0")
|
||||
}
|
||||
|
||||
// validate the Consumer Group values
|
||||
switch {
|
||||
case c.Consumer.Group.Session.Timeout <= 2*time.Millisecond:
|
||||
return ConfigurationError("Consumer.Group.Session.Timeout must be >= 2ms")
|
||||
case c.Consumer.Group.Heartbeat.Interval < 1*time.Millisecond:
|
||||
return ConfigurationError("Consumer.Group.Heartbeat.Interval must be >= 1ms")
|
||||
case c.Consumer.Group.Heartbeat.Interval >= c.Consumer.Group.Session.Timeout:
|
||||
return ConfigurationError("Consumer.Group.Heartbeat.Interval must be < Consumer.Group.Session.Timeout")
|
||||
case c.Consumer.Group.Rebalance.Strategy == nil:
|
||||
return ConfigurationError("Consumer.Group.Rebalance.Strategy must not be empty")
|
||||
case c.Consumer.Group.Rebalance.Timeout <= time.Millisecond:
|
||||
return ConfigurationError("Consumer.Group.Rebalance.Timeout must be >= 1ms")
|
||||
case c.Consumer.Group.Rebalance.Retry.Max < 0:
|
||||
return ConfigurationError("Consumer.Group.Rebalance.Retry.Max must be >= 0")
|
||||
case c.Consumer.Group.Rebalance.Retry.Backoff < 0:
|
||||
return ConfigurationError("Consumer.Group.Rebalance.Retry.Backoff must be >= 0")
|
||||
}
|
||||
|
||||
// validate misc shared values
|
||||
|
||||
9
vendor/github.com/Shopify/sarama/consumer.go
generated
vendored
9
vendor/github.com/Shopify/sarama/consumer.go
generated
vendored
@@ -531,7 +531,7 @@ func (child *partitionConsumer) parseRecords(batch *RecordBatch) ([]*ConsumerMes
|
||||
child.offset = offset + 1
|
||||
}
|
||||
if len(messages) == 0 {
|
||||
return nil, ErrIncompleteResponse
|
||||
child.offset += 1
|
||||
}
|
||||
return messages, nil
|
||||
}
|
||||
@@ -579,10 +579,6 @@ func (child *partitionConsumer) parseResponse(response *FetchResponse) ([]*Consu
|
||||
|
||||
messages := []*ConsumerMessage{}
|
||||
for _, records := range block.RecordsSet {
|
||||
if control, err := records.isControl(); err != nil || control {
|
||||
continue
|
||||
}
|
||||
|
||||
switch records.recordsType {
|
||||
case legacyRecords:
|
||||
messageSetMessages, err := child.parseMessages(records.MsgSet)
|
||||
@@ -596,6 +592,9 @@ func (child *partitionConsumer) parseResponse(response *FetchResponse) ([]*Consu
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if control, err := records.isControl(); err != nil || control {
|
||||
continue
|
||||
}
|
||||
|
||||
messages = append(messages, recordBatchMessages...)
|
||||
default:
|
||||
|
||||
774
vendor/github.com/Shopify/sarama/consumer_group.go
generated
vendored
Normal file
774
vendor/github.com/Shopify/sarama/consumer_group.go
generated
vendored
Normal file
@@ -0,0 +1,774 @@
|
||||
package sarama
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"sort"
|
||||
"sync"
|
||||
"time"
|
||||
)
|
||||
|
||||
// ErrClosedConsumerGroup is the error returned when a method is called on a consumer group that has been closed.
|
||||
var ErrClosedConsumerGroup = errors.New("kafka: tried to use a consumer group that was closed")
|
||||
|
||||
// ConsumerGroup is responsible for dividing up processing of topics and partitions
|
||||
// over a collection of processes (the members of the consumer group).
|
||||
type ConsumerGroup interface {
|
||||
// Consume joins a cluster of consumers for a given list of topics and
|
||||
// starts a blocking ConsumerGroupSession through the ConsumerGroupHandler.
|
||||
//
|
||||
// The life-cycle of a session is represented by the following steps:
|
||||
//
|
||||
// 1. The consumers join the group (as explained in https://kafka.apache.org/documentation/#intro_consumers)
|
||||
// and is assigned their "fair share" of partitions, aka 'claims'.
|
||||
// 2. Before processing starts, the handler's Setup() hook is called to notify the user
|
||||
// of the claims and allow any necessary preparation or alteration of state.
|
||||
// 3. For each of the assigned claims the handler's ConsumeClaim() function is then called
|
||||
// in a separate goroutine which requires it to be thread-safe. Any state must be carefully protected
|
||||
// from concurrent reads/writes.
|
||||
// 4. The session will persist until one of the ConsumeClaim() functions exits. This can be either when the
|
||||
// parent context is cancelled or when a server-side rebalance cycle is initiated.
|
||||
// 5. Once all the ConsumeClaim() loops have exited, the handler's Cleanup() hook is called
|
||||
// to allow the user to perform any final tasks before a rebalance.
|
||||
// 6. Finally, marked offsets are committed one last time before claims are released.
|
||||
//
|
||||
// Please note, that once a relance is triggered, sessions must be completed within
|
||||
// Config.Consumer.Group.Rebalance.Timeout. This means that ConsumeClaim() functions must exit
|
||||
// as quickly as possible to allow time for Cleanup() and the final offset commit. If the timeout
|
||||
// is exceeded, the consumer will be removed from the group by Kafka, which will cause offset
|
||||
// commit failures.
|
||||
Consume(ctx context.Context, topics []string, handler ConsumerGroupHandler) error
|
||||
|
||||
// Errors returns a read channel of errors that occurred during the consumer life-cycle.
|
||||
// By default, errors are logged and not returned over this channel.
|
||||
// If you want to implement any custom error handling, set your config's
|
||||
// Consumer.Return.Errors setting to true, and read from this channel.
|
||||
Errors() <-chan error
|
||||
|
||||
// Close stops the ConsumerGroup and detaches any running sessions. It is required to call
|
||||
// this function before the object passes out of scope, as it will otherwise leak memory.
|
||||
Close() error
|
||||
}
|
||||
|
||||
type consumerGroup struct {
|
||||
client Client
|
||||
ownClient bool
|
||||
|
||||
config *Config
|
||||
consumer Consumer
|
||||
groupID string
|
||||
memberID string
|
||||
errors chan error
|
||||
|
||||
lock sync.Mutex
|
||||
closed chan none
|
||||
closeOnce sync.Once
|
||||
}
|
||||
|
||||
// NewConsumerGroup creates a new consumer group the given broker addresses and configuration.
|
||||
func NewConsumerGroup(addrs []string, groupID string, config *Config) (ConsumerGroup, error) {
|
||||
client, err := NewClient(addrs, config)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
c, err := NewConsumerGroupFromClient(groupID, client)
|
||||
if err != nil {
|
||||
_ = client.Close()
|
||||
return nil, err
|
||||
}
|
||||
|
||||
c.(*consumerGroup).ownClient = true
|
||||
return c, nil
|
||||
}
|
||||
|
||||
// NewConsumerFromClient creates a new consumer group using the given client. It is still
|
||||
// necessary to call Close() on the underlying client when shutting down this consumer.
|
||||
// PLEASE NOTE: consumer groups can only re-use but not share clients.
|
||||
func NewConsumerGroupFromClient(groupID string, client Client) (ConsumerGroup, error) {
|
||||
config := client.Config()
|
||||
if !config.Version.IsAtLeast(V0_10_2_0) {
|
||||
return nil, ConfigurationError("consumer groups require Version to be >= V0_10_2_0")
|
||||
}
|
||||
|
||||
consumer, err := NewConsumerFromClient(client)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &consumerGroup{
|
||||
client: client,
|
||||
consumer: consumer,
|
||||
config: config,
|
||||
groupID: groupID,
|
||||
errors: make(chan error, config.ChannelBufferSize),
|
||||
closed: make(chan none),
|
||||
}, nil
|
||||
}
|
||||
|
||||
// Errors implements ConsumerGroup.
|
||||
func (c *consumerGroup) Errors() <-chan error { return c.errors }
|
||||
|
||||
// Close implements ConsumerGroup.
|
||||
func (c *consumerGroup) Close() (err error) {
|
||||
c.closeOnce.Do(func() {
|
||||
close(c.closed)
|
||||
|
||||
c.lock.Lock()
|
||||
defer c.lock.Unlock()
|
||||
|
||||
// leave group
|
||||
if e := c.leave(); e != nil {
|
||||
err = e
|
||||
}
|
||||
|
||||
// drain errors
|
||||
go func() {
|
||||
close(c.errors)
|
||||
}()
|
||||
for e := range c.errors {
|
||||
err = e
|
||||
}
|
||||
|
||||
if c.ownClient {
|
||||
if e := c.client.Close(); e != nil {
|
||||
err = e
|
||||
}
|
||||
}
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
// Consume implements ConsumerGroup.
|
||||
func (c *consumerGroup) Consume(ctx context.Context, topics []string, handler ConsumerGroupHandler) error {
|
||||
// Ensure group is not closed
|
||||
select {
|
||||
case <-c.closed:
|
||||
return ErrClosedConsumerGroup
|
||||
default:
|
||||
}
|
||||
|
||||
c.lock.Lock()
|
||||
defer c.lock.Unlock()
|
||||
|
||||
// Quick exit when no topics are provided
|
||||
if len(topics) == 0 {
|
||||
return fmt.Errorf("no topics provided")
|
||||
}
|
||||
|
||||
// Refresh metadata for requested topics
|
||||
if err := c.client.RefreshMetadata(topics...); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Get coordinator
|
||||
coordinator, err := c.client.Coordinator(c.groupID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Init session
|
||||
sess, err := c.newSession(ctx, coordinator, topics, handler, c.config.Consumer.Group.Rebalance.Retry.Max)
|
||||
if err == ErrClosedClient {
|
||||
return ErrClosedConsumerGroup
|
||||
} else if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Wait for session exit signal
|
||||
<-sess.ctx.Done()
|
||||
|
||||
// Gracefully release session claims
|
||||
return sess.release(true)
|
||||
}
|
||||
|
||||
func (c *consumerGroup) newSession(ctx context.Context, coordinator *Broker, topics []string, handler ConsumerGroupHandler, retries int) (*consumerGroupSession, error) {
|
||||
// Join consumer group
|
||||
join, err := c.joinGroupRequest(coordinator, topics)
|
||||
if err != nil {
|
||||
_ = coordinator.Close()
|
||||
return nil, err
|
||||
}
|
||||
switch join.Err {
|
||||
case ErrNoError:
|
||||
c.memberID = join.MemberId
|
||||
case ErrUnknownMemberId, ErrIllegalGeneration: // reset member ID and retry immediately
|
||||
c.memberID = ""
|
||||
return c.newSession(ctx, coordinator, topics, handler, retries)
|
||||
case ErrRebalanceInProgress: // retry after backoff
|
||||
if retries <= 0 {
|
||||
return nil, join.Err
|
||||
}
|
||||
|
||||
select {
|
||||
case <-c.closed:
|
||||
return nil, ErrClosedConsumerGroup
|
||||
case <-time.After(c.config.Consumer.Group.Rebalance.Retry.Backoff):
|
||||
}
|
||||
|
||||
return c.newSession(ctx, coordinator, topics, handler, retries-1)
|
||||
default:
|
||||
return nil, join.Err
|
||||
}
|
||||
|
||||
// Prepare distribution plan if we joined as the leader
|
||||
var plan BalanceStrategyPlan
|
||||
if join.LeaderId == join.MemberId {
|
||||
members, err := join.GetMembers()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
plan, err = c.balance(members)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
// Sync consumer group
|
||||
sync, err := c.syncGroupRequest(coordinator, plan, join.GenerationId)
|
||||
if err != nil {
|
||||
_ = coordinator.Close()
|
||||
return nil, err
|
||||
}
|
||||
switch sync.Err {
|
||||
case ErrNoError:
|
||||
case ErrUnknownMemberId, ErrIllegalGeneration: // reset member ID and retry immediately
|
||||
c.memberID = ""
|
||||
return c.newSession(ctx, coordinator, topics, handler, retries)
|
||||
case ErrRebalanceInProgress: // retry after backoff
|
||||
if retries <= 0 {
|
||||
return nil, sync.Err
|
||||
}
|
||||
|
||||
select {
|
||||
case <-c.closed:
|
||||
return nil, ErrClosedConsumerGroup
|
||||
case <-time.After(c.config.Consumer.Group.Rebalance.Retry.Backoff):
|
||||
}
|
||||
|
||||
return c.newSession(ctx, coordinator, topics, handler, retries-1)
|
||||
default:
|
||||
return nil, sync.Err
|
||||
}
|
||||
|
||||
// Retrieve and sort claims
|
||||
var claims map[string][]int32
|
||||
if len(sync.MemberAssignment) > 0 {
|
||||
members, err := sync.GetMemberAssignment()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
claims = members.Topics
|
||||
|
||||
for _, partitions := range claims {
|
||||
sort.Sort(int32Slice(partitions))
|
||||
}
|
||||
}
|
||||
|
||||
return newConsumerGroupSession(c, ctx, claims, join.MemberId, join.GenerationId, handler)
|
||||
}
|
||||
|
||||
func (c *consumerGroup) joinGroupRequest(coordinator *Broker, topics []string) (*JoinGroupResponse, error) {
|
||||
req := &JoinGroupRequest{
|
||||
GroupId: c.groupID,
|
||||
MemberId: c.memberID,
|
||||
SessionTimeout: int32(c.config.Consumer.Group.Session.Timeout / time.Millisecond),
|
||||
ProtocolType: "consumer",
|
||||
}
|
||||
if c.config.Version.IsAtLeast(V0_10_1_0) {
|
||||
req.Version = 1
|
||||
req.RebalanceTimeout = int32(c.config.Consumer.Group.Rebalance.Timeout / time.Millisecond)
|
||||
}
|
||||
|
||||
meta := &ConsumerGroupMemberMetadata{
|
||||
Topics: topics,
|
||||
UserData: c.config.Consumer.Group.Member.UserData,
|
||||
}
|
||||
strategy := c.config.Consumer.Group.Rebalance.Strategy
|
||||
if err := req.AddGroupProtocolMetadata(strategy.Name(), meta); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return coordinator.JoinGroup(req)
|
||||
}
|
||||
|
||||
func (c *consumerGroup) syncGroupRequest(coordinator *Broker, plan BalanceStrategyPlan, generationID int32) (*SyncGroupResponse, error) {
|
||||
req := &SyncGroupRequest{
|
||||
GroupId: c.groupID,
|
||||
MemberId: c.memberID,
|
||||
GenerationId: generationID,
|
||||
}
|
||||
for memberID, topics := range plan {
|
||||
err := req.AddGroupAssignmentMember(memberID, &ConsumerGroupMemberAssignment{
|
||||
Topics: topics,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
return coordinator.SyncGroup(req)
|
||||
}
|
||||
|
||||
func (c *consumerGroup) heartbeatRequest(coordinator *Broker, memberID string, generationID int32) (*HeartbeatResponse, error) {
|
||||
req := &HeartbeatRequest{
|
||||
GroupId: c.groupID,
|
||||
MemberId: memberID,
|
||||
GenerationId: generationID,
|
||||
}
|
||||
|
||||
return coordinator.Heartbeat(req)
|
||||
}
|
||||
|
||||
func (c *consumerGroup) balance(members map[string]ConsumerGroupMemberMetadata) (BalanceStrategyPlan, error) {
|
||||
topics := make(map[string][]int32)
|
||||
for _, meta := range members {
|
||||
for _, topic := range meta.Topics {
|
||||
topics[topic] = nil
|
||||
}
|
||||
}
|
||||
|
||||
for topic := range topics {
|
||||
partitions, err := c.client.Partitions(topic)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
topics[topic] = partitions
|
||||
}
|
||||
|
||||
strategy := c.config.Consumer.Group.Rebalance.Strategy
|
||||
return strategy.Plan(members, topics)
|
||||
}
|
||||
|
||||
// Leaves the cluster, called by Close, protected by lock.
|
||||
func (c *consumerGroup) leave() error {
|
||||
if c.memberID == "" {
|
||||
return nil
|
||||
}
|
||||
|
||||
coordinator, err := c.client.Coordinator(c.groupID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
resp, err := coordinator.LeaveGroup(&LeaveGroupRequest{
|
||||
GroupId: c.groupID,
|
||||
MemberId: c.memberID,
|
||||
})
|
||||
if err != nil {
|
||||
_ = coordinator.Close()
|
||||
return err
|
||||
}
|
||||
|
||||
// Unset memberID
|
||||
c.memberID = ""
|
||||
|
||||
// Check response
|
||||
switch resp.Err {
|
||||
case ErrRebalanceInProgress, ErrUnknownMemberId, ErrNoError:
|
||||
return nil
|
||||
default:
|
||||
return resp.Err
|
||||
}
|
||||
}
|
||||
|
||||
func (c *consumerGroup) handleError(err error, topic string, partition int32) {
|
||||
select {
|
||||
case <-c.closed:
|
||||
return
|
||||
default:
|
||||
}
|
||||
|
||||
if _, ok := err.(*ConsumerError); !ok && topic != "" && partition > -1 {
|
||||
err = &ConsumerError{
|
||||
Topic: topic,
|
||||
Partition: partition,
|
||||
Err: err,
|
||||
}
|
||||
}
|
||||
|
||||
if c.config.Consumer.Return.Errors {
|
||||
select {
|
||||
case c.errors <- err:
|
||||
default:
|
||||
}
|
||||
} else {
|
||||
Logger.Println(err)
|
||||
}
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
// ConsumerGroupSession represents a consumer group member session.
|
||||
type ConsumerGroupSession interface {
|
||||
// Claims returns information about the claimed partitions by topic.
|
||||
Claims() map[string][]int32
|
||||
|
||||
// MemberID returns the cluster member ID.
|
||||
MemberID() string
|
||||
|
||||
// GenerationID returns the current generation ID.
|
||||
GenerationID() int32
|
||||
|
||||
// MarkOffset marks the provided offset, alongside a metadata string
|
||||
// that represents the state of the partition consumer at that point in time. The
|
||||
// metadata string can be used by another consumer to restore that state, so it
|
||||
// can resume consumption.
|
||||
//
|
||||
// To follow upstream conventions, you are expected to mark the offset of the
|
||||
// next message to read, not the last message read. Thus, when calling `MarkOffset`
|
||||
// you should typically add one to the offset of the last consumed message.
|
||||
//
|
||||
// Note: calling MarkOffset does not necessarily commit the offset to the backend
|
||||
// store immediately for efficiency reasons, and it may never be committed if
|
||||
// your application crashes. This means that you may end up processing the same
|
||||
// message twice, and your processing should ideally be idempotent.
|
||||
MarkOffset(topic string, partition int32, offset int64, metadata string)
|
||||
|
||||
// ResetOffset resets to the provided offset, alongside a metadata string that
|
||||
// represents the state of the partition consumer at that point in time. Reset
|
||||
// acts as a counterpart to MarkOffset, the difference being that it allows to
|
||||
// reset an offset to an earlier or smaller value, where MarkOffset only
|
||||
// allows incrementing the offset. cf MarkOffset for more details.
|
||||
ResetOffset(topic string, partition int32, offset int64, metadata string)
|
||||
|
||||
// MarkMessage marks a message as consumed.
|
||||
MarkMessage(msg *ConsumerMessage, metadata string)
|
||||
|
||||
// Context returns the session context.
|
||||
Context() context.Context
|
||||
}
|
||||
|
||||
type consumerGroupSession struct {
|
||||
parent *consumerGroup
|
||||
memberID string
|
||||
generationID int32
|
||||
handler ConsumerGroupHandler
|
||||
|
||||
claims map[string][]int32
|
||||
offsets *offsetManager
|
||||
ctx context.Context
|
||||
cancel func()
|
||||
|
||||
waitGroup sync.WaitGroup
|
||||
releaseOnce sync.Once
|
||||
hbDying, hbDead chan none
|
||||
}
|
||||
|
||||
func newConsumerGroupSession(parent *consumerGroup, ctx context.Context, claims map[string][]int32, memberID string, generationID int32, handler ConsumerGroupHandler) (*consumerGroupSession, error) {
|
||||
// init offset manager
|
||||
offsets, err := newOffsetManagerFromClient(parent.groupID, memberID, generationID, parent.client)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// init context
|
||||
ctx, cancel := context.WithCancel(ctx)
|
||||
|
||||
// init session
|
||||
sess := &consumerGroupSession{
|
||||
parent: parent,
|
||||
memberID: memberID,
|
||||
generationID: generationID,
|
||||
handler: handler,
|
||||
offsets: offsets,
|
||||
claims: claims,
|
||||
ctx: ctx,
|
||||
cancel: cancel,
|
||||
hbDying: make(chan none),
|
||||
hbDead: make(chan none),
|
||||
}
|
||||
|
||||
// start heartbeat loop
|
||||
go sess.heartbeatLoop()
|
||||
|
||||
// create a POM for each claim
|
||||
for topic, partitions := range claims {
|
||||
for _, partition := range partitions {
|
||||
pom, err := offsets.ManagePartition(topic, partition)
|
||||
if err != nil {
|
||||
_ = sess.release(false)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// handle POM errors
|
||||
go func(topic string, partition int32) {
|
||||
for err := range pom.Errors() {
|
||||
sess.parent.handleError(err, topic, partition)
|
||||
}
|
||||
}(topic, partition)
|
||||
}
|
||||
}
|
||||
|
||||
// perform setup
|
||||
if err := handler.Setup(sess); err != nil {
|
||||
_ = sess.release(true)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// start consuming
|
||||
for topic, partitions := range claims {
|
||||
for _, partition := range partitions {
|
||||
sess.waitGroup.Add(1)
|
||||
|
||||
go func(topic string, partition int32) {
|
||||
defer sess.waitGroup.Done()
|
||||
|
||||
// cancel the as session as soon as the first
|
||||
// goroutine exits
|
||||
defer sess.cancel()
|
||||
|
||||
// consume a single topic/partition, blocking
|
||||
sess.consume(topic, partition)
|
||||
}(topic, partition)
|
||||
}
|
||||
}
|
||||
return sess, nil
|
||||
}
|
||||
|
||||
func (s *consumerGroupSession) Claims() map[string][]int32 { return s.claims }
|
||||
func (s *consumerGroupSession) MemberID() string { return s.memberID }
|
||||
func (s *consumerGroupSession) GenerationID() int32 { return s.generationID }
|
||||
|
||||
func (s *consumerGroupSession) MarkOffset(topic string, partition int32, offset int64, metadata string) {
|
||||
if pom := s.offsets.findPOM(topic, partition); pom != nil {
|
||||
pom.MarkOffset(offset, metadata)
|
||||
}
|
||||
}
|
||||
|
||||
func (s *consumerGroupSession) ResetOffset(topic string, partition int32, offset int64, metadata string) {
|
||||
if pom := s.offsets.findPOM(topic, partition); pom != nil {
|
||||
pom.ResetOffset(offset, metadata)
|
||||
}
|
||||
}
|
||||
|
||||
func (s *consumerGroupSession) MarkMessage(msg *ConsumerMessage, metadata string) {
|
||||
s.MarkOffset(msg.Topic, msg.Partition, msg.Offset+1, metadata)
|
||||
}
|
||||
|
||||
func (s *consumerGroupSession) Context() context.Context {
|
||||
return s.ctx
|
||||
}
|
||||
|
||||
func (s *consumerGroupSession) consume(topic string, partition int32) {
|
||||
// quick exit if rebalance is due
|
||||
select {
|
||||
case <-s.ctx.Done():
|
||||
return
|
||||
case <-s.parent.closed:
|
||||
return
|
||||
default:
|
||||
}
|
||||
|
||||
// get next offset
|
||||
offset := s.parent.config.Consumer.Offsets.Initial
|
||||
if pom := s.offsets.findPOM(topic, partition); pom != nil {
|
||||
offset, _ = pom.NextOffset()
|
||||
}
|
||||
|
||||
// create new claim
|
||||
claim, err := newConsumerGroupClaim(s, topic, partition, offset)
|
||||
if err != nil {
|
||||
s.parent.handleError(err, topic, partition)
|
||||
return
|
||||
}
|
||||
|
||||
// handle errors
|
||||
go func() {
|
||||
for err := range claim.Errors() {
|
||||
s.parent.handleError(err, topic, partition)
|
||||
}
|
||||
}()
|
||||
|
||||
// trigger close when session is done
|
||||
go func() {
|
||||
select {
|
||||
case <-s.ctx.Done():
|
||||
case <-s.parent.closed:
|
||||
}
|
||||
claim.AsyncClose()
|
||||
}()
|
||||
|
||||
// start processing
|
||||
if err := s.handler.ConsumeClaim(s, claim); err != nil {
|
||||
s.parent.handleError(err, topic, partition)
|
||||
}
|
||||
|
||||
// ensure consumer is clased & drained
|
||||
claim.AsyncClose()
|
||||
for _, err := range claim.waitClosed() {
|
||||
s.parent.handleError(err, topic, partition)
|
||||
}
|
||||
}
|
||||
|
||||
func (s *consumerGroupSession) release(withCleanup bool) (err error) {
|
||||
// signal release, stop heartbeat
|
||||
s.cancel()
|
||||
|
||||
// wait for consumers to exit
|
||||
s.waitGroup.Wait()
|
||||
|
||||
// perform release
|
||||
s.releaseOnce.Do(func() {
|
||||
if withCleanup {
|
||||
if e := s.handler.Cleanup(s); e != nil {
|
||||
s.parent.handleError(err, "", -1)
|
||||
err = e
|
||||
}
|
||||
}
|
||||
|
||||
if e := s.offsets.Close(); e != nil {
|
||||
err = e
|
||||
}
|
||||
|
||||
close(s.hbDying)
|
||||
<-s.hbDead
|
||||
})
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func (s *consumerGroupSession) heartbeatLoop() {
|
||||
defer close(s.hbDead)
|
||||
defer s.cancel() // trigger the end of the session on exit
|
||||
|
||||
pause := time.NewTicker(s.parent.config.Consumer.Group.Heartbeat.Interval)
|
||||
defer pause.Stop()
|
||||
|
||||
retries := s.parent.config.Metadata.Retry.Max
|
||||
for {
|
||||
coordinator, err := s.parent.client.Coordinator(s.parent.groupID)
|
||||
if err != nil {
|
||||
if retries <= 0 {
|
||||
s.parent.handleError(err, "", -1)
|
||||
return
|
||||
}
|
||||
|
||||
select {
|
||||
case <-s.hbDying:
|
||||
return
|
||||
case <-time.After(s.parent.config.Metadata.Retry.Backoff):
|
||||
retries--
|
||||
}
|
||||
continue
|
||||
}
|
||||
|
||||
resp, err := s.parent.heartbeatRequest(coordinator, s.memberID, s.generationID)
|
||||
if err != nil {
|
||||
_ = coordinator.Close()
|
||||
retries--
|
||||
continue
|
||||
}
|
||||
|
||||
switch resp.Err {
|
||||
case ErrNoError:
|
||||
retries = s.parent.config.Metadata.Retry.Max
|
||||
case ErrRebalanceInProgress, ErrUnknownMemberId, ErrIllegalGeneration:
|
||||
return
|
||||
default:
|
||||
s.parent.handleError(err, "", -1)
|
||||
return
|
||||
}
|
||||
|
||||
select {
|
||||
case <-pause.C:
|
||||
case <-s.hbDying:
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
// ConsumerGroupHandler instances are used to handle individual topic/partition claims.
|
||||
// It also provides hooks for your consumer group session life-cycle and allow you to
|
||||
// trigger logic before or after the consume loop(s).
|
||||
//
|
||||
// PLEASE NOTE that handlers are likely be called from several goroutines concurrently,
|
||||
// ensure that all state is safely protected against race conditions.
|
||||
type ConsumerGroupHandler interface {
|
||||
// Setup is run at the beginning of a new session, before ConsumeClaim.
|
||||
Setup(ConsumerGroupSession) error
|
||||
|
||||
// Cleanup is run at the end of a session, once all ConsumeClaim goroutines have exites
|
||||
// but before the offsets are committed for the very last time.
|
||||
Cleanup(ConsumerGroupSession) error
|
||||
|
||||
// ConsumeClaim must start a consumer loop of ConsumerGroupClaim's Messages().
|
||||
// Once the Messages() channel is closed, the Handler must finish its processing
|
||||
// loop and exit.
|
||||
ConsumeClaim(ConsumerGroupSession, ConsumerGroupClaim) error
|
||||
}
|
||||
|
||||
// ConsumerGroupClaim processes Kafka messages from a given topic and partition within a consumer group.
|
||||
type ConsumerGroupClaim interface {
|
||||
// Topic returns the consumed topic name.
|
||||
Topic() string
|
||||
|
||||
// Partition returns the consumed partition.
|
||||
Partition() int32
|
||||
|
||||
// InitialOffset returns the initial offset that was used as a starting point for this claim.
|
||||
InitialOffset() int64
|
||||
|
||||
// HighWaterMarkOffset returns the high water mark offset of the partition,
|
||||
// i.e. the offset that will be used for the next message that will be produced.
|
||||
// You can use this to determine how far behind the processing is.
|
||||
HighWaterMarkOffset() int64
|
||||
|
||||
// Messages returns the read channel for the messages that are returned by
|
||||
// the broker. The messages channel will be closed when a new rebalance cycle
|
||||
// is due. You must finish processing and mark offsets within
|
||||
// Config.Consumer.Group.Session.Timeout before the topic/partition is eventually
|
||||
// re-assigned to another group member.
|
||||
Messages() <-chan *ConsumerMessage
|
||||
}
|
||||
|
||||
type consumerGroupClaim struct {
|
||||
topic string
|
||||
partition int32
|
||||
offset int64
|
||||
PartitionConsumer
|
||||
}
|
||||
|
||||
func newConsumerGroupClaim(sess *consumerGroupSession, topic string, partition int32, offset int64) (*consumerGroupClaim, error) {
|
||||
pcm, err := sess.parent.consumer.ConsumePartition(topic, partition, offset)
|
||||
if err == ErrOffsetOutOfRange {
|
||||
offset = sess.parent.config.Consumer.Offsets.Initial
|
||||
pcm, err = sess.parent.consumer.ConsumePartition(topic, partition, offset)
|
||||
}
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
go func() {
|
||||
for err := range pcm.Errors() {
|
||||
sess.parent.handleError(err, topic, partition)
|
||||
}
|
||||
}()
|
||||
|
||||
return &consumerGroupClaim{
|
||||
topic: topic,
|
||||
partition: partition,
|
||||
offset: offset,
|
||||
PartitionConsumer: pcm,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (c *consumerGroupClaim) Topic() string { return c.topic }
|
||||
func (c *consumerGroupClaim) Partition() int32 { return c.partition }
|
||||
func (c *consumerGroupClaim) InitialOffset() int64 { return c.offset }
|
||||
|
||||
// Drains messages and errors, ensures the claim is fully closed.
|
||||
func (c *consumerGroupClaim) waitClosed() (errs ConsumerErrors) {
|
||||
go func() {
|
||||
for range c.Messages() {
|
||||
}
|
||||
}()
|
||||
|
||||
for err := range c.Errors() {
|
||||
errs = append(errs, err)
|
||||
}
|
||||
return
|
||||
}
|
||||
2
vendor/github.com/Shopify/sarama/dev.yml
generated
vendored
2
vendor/github.com/Shopify/sarama/dev.yml
generated
vendored
@@ -2,7 +2,7 @@ name: sarama
|
||||
|
||||
up:
|
||||
- go:
|
||||
version: '1.9'
|
||||
version: '1.11'
|
||||
|
||||
commands:
|
||||
test:
|
||||
|
||||
23
vendor/github.com/Shopify/sarama/fetch_response.go
generated
vendored
23
vendor/github.com/Shopify/sarama/fetch_response.go
generated
vendored
@@ -104,15 +104,26 @@ func (b *FetchResponseBlock) decode(pd packetDecoder, version int16) (err error)
|
||||
return err
|
||||
}
|
||||
|
||||
// If we have at least one full records, we skip incomplete ones
|
||||
if partial && len(b.RecordsSet) > 0 {
|
||||
break
|
||||
n, err := records.numRecords()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
b.RecordsSet = append(b.RecordsSet, records)
|
||||
if n > 0 || (partial && len(b.RecordsSet) == 0) {
|
||||
b.RecordsSet = append(b.RecordsSet, records)
|
||||
|
||||
if b.Records == nil {
|
||||
b.Records = records
|
||||
if b.Records == nil {
|
||||
b.Records = records
|
||||
}
|
||||
}
|
||||
|
||||
overflow, err := records.isOverflow()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if partial || overflow {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
15
vendor/github.com/Shopify/sarama/length_field.go
generated
vendored
15
vendor/github.com/Shopify/sarama/length_field.go
generated
vendored
@@ -5,6 +5,19 @@ import "encoding/binary"
|
||||
// LengthField implements the PushEncoder and PushDecoder interfaces for calculating 4-byte lengths.
|
||||
type lengthField struct {
|
||||
startOffset int
|
||||
length int32
|
||||
}
|
||||
|
||||
func (l *lengthField) decode(pd packetDecoder) error {
|
||||
var err error
|
||||
l.length, err = pd.getInt32()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if l.length > int32(pd.remaining()) {
|
||||
return ErrInsufficientData
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (l *lengthField) saveOffset(in int) {
|
||||
@@ -21,7 +34,7 @@ func (l *lengthField) run(curOffset int, buf []byte) error {
|
||||
}
|
||||
|
||||
func (l *lengthField) check(curOffset int, buf []byte) error {
|
||||
if uint32(curOffset-l.startOffset-4) != binary.BigEndian.Uint32(buf[l.startOffset:]) {
|
||||
if int32(curOffset-l.startOffset-4) != l.length {
|
||||
return PacketDecodingError{"length field invalid"}
|
||||
}
|
||||
|
||||
|
||||
8
vendor/github.com/Shopify/sarama/message_set.go
generated
vendored
8
vendor/github.com/Shopify/sarama/message_set.go
generated
vendored
@@ -47,6 +47,7 @@ func (msb *MessageBlock) decode(pd packetDecoder) (err error) {
|
||||
|
||||
type MessageSet struct {
|
||||
PartialTrailingMessage bool // whether the set on the wire contained an incomplete trailing MessageBlock
|
||||
OverflowMessage bool // whether the set on the wire contained an overflow message
|
||||
Messages []*MessageBlock
|
||||
}
|
||||
|
||||
@@ -85,7 +86,12 @@ func (ms *MessageSet) decode(pd packetDecoder) (err error) {
|
||||
case ErrInsufficientData:
|
||||
// As an optimization the server is allowed to return a partial message at the
|
||||
// end of the message set. Clients should handle this case. So we just ignore such things.
|
||||
ms.PartialTrailingMessage = true
|
||||
if msb.Offset == -1 {
|
||||
// This is an overflow message caused by chunked down conversion
|
||||
ms.OverflowMessage = true
|
||||
} else {
|
||||
ms.PartialTrailingMessage = true
|
||||
}
|
||||
return nil
|
||||
default:
|
||||
return err
|
||||
|
||||
2
vendor/github.com/Shopify/sarama/metadata_request.go
generated
vendored
2
vendor/github.com/Shopify/sarama/metadata_request.go
generated
vendored
@@ -10,7 +10,7 @@ func (r *MetadataRequest) encode(pe packetEncoder) error {
|
||||
if r.Version < 0 || r.Version > 5 {
|
||||
return PacketEncodingError{"invalid or unsupported MetadataRequest version field"}
|
||||
}
|
||||
if r.Version == 0 || r.Topics != nil || len(r.Topics) > 0 {
|
||||
if r.Version == 0 || len(r.Topics) > 0 {
|
||||
err := pe.putArrayLength(len(r.Topics))
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
11
vendor/github.com/Shopify/sarama/metadata_response.go
generated
vendored
11
vendor/github.com/Shopify/sarama/metadata_response.go
generated
vendored
@@ -207,6 +207,10 @@ func (r *MetadataResponse) decode(pd packetDecoder, version int16) (err error) {
|
||||
}
|
||||
|
||||
func (r *MetadataResponse) encode(pe packetEncoder) error {
|
||||
if r.Version >= 3 {
|
||||
pe.putInt32(r.ThrottleTimeMs)
|
||||
}
|
||||
|
||||
err := pe.putArrayLength(len(r.Brokers))
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -218,6 +222,13 @@ func (r *MetadataResponse) encode(pe packetEncoder) error {
|
||||
}
|
||||
}
|
||||
|
||||
if r.Version >= 2 {
|
||||
err := pe.putNullableString(r.ClusterID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
if r.Version >= 1 {
|
||||
pe.putInt32(r.ControllerID)
|
||||
}
|
||||
|
||||
187
vendor/github.com/Shopify/sarama/mockresponses.go
generated
vendored
187
vendor/github.com/Shopify/sarama/mockresponses.go
generated
vendored
@@ -538,3 +538,190 @@ func (mr *MockOffsetFetchResponse) For(reqBody versionedDecoder) encoder {
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
type MockCreateTopicsResponse struct {
|
||||
t TestReporter
|
||||
}
|
||||
|
||||
func NewMockCreateTopicsResponse(t TestReporter) *MockCreateTopicsResponse {
|
||||
return &MockCreateTopicsResponse{t: t}
|
||||
}
|
||||
|
||||
func (mr *MockCreateTopicsResponse) For(reqBody versionedDecoder) encoder {
|
||||
req := reqBody.(*CreateTopicsRequest)
|
||||
res := &CreateTopicsResponse{}
|
||||
res.TopicErrors = make(map[string]*TopicError)
|
||||
|
||||
for topic, _ := range req.TopicDetails {
|
||||
res.TopicErrors[topic] = &TopicError{Err: ErrNoError}
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
type MockDeleteTopicsResponse struct {
|
||||
t TestReporter
|
||||
}
|
||||
|
||||
func NewMockDeleteTopicsResponse(t TestReporter) *MockDeleteTopicsResponse {
|
||||
return &MockDeleteTopicsResponse{t: t}
|
||||
}
|
||||
|
||||
func (mr *MockDeleteTopicsResponse) For(reqBody versionedDecoder) encoder {
|
||||
req := reqBody.(*DeleteTopicsRequest)
|
||||
res := &DeleteTopicsResponse{}
|
||||
res.TopicErrorCodes = make(map[string]KError)
|
||||
|
||||
for _, topic := range req.Topics {
|
||||
res.TopicErrorCodes[topic] = ErrNoError
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
type MockCreatePartitionsResponse struct {
|
||||
t TestReporter
|
||||
}
|
||||
|
||||
func NewMockCreatePartitionsResponse(t TestReporter) *MockCreatePartitionsResponse {
|
||||
return &MockCreatePartitionsResponse{t: t}
|
||||
}
|
||||
|
||||
func (mr *MockCreatePartitionsResponse) For(reqBody versionedDecoder) encoder {
|
||||
req := reqBody.(*CreatePartitionsRequest)
|
||||
res := &CreatePartitionsResponse{}
|
||||
res.TopicPartitionErrors = make(map[string]*TopicPartitionError)
|
||||
|
||||
for topic, _ := range req.TopicPartitions {
|
||||
res.TopicPartitionErrors[topic] = &TopicPartitionError{Err: ErrNoError}
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
type MockDeleteRecordsResponse struct {
|
||||
t TestReporter
|
||||
}
|
||||
|
||||
func NewMockDeleteRecordsResponse(t TestReporter) *MockDeleteRecordsResponse {
|
||||
return &MockDeleteRecordsResponse{t: t}
|
||||
}
|
||||
|
||||
func (mr *MockDeleteRecordsResponse) For(reqBody versionedDecoder) encoder {
|
||||
req := reqBody.(*DeleteRecordsRequest)
|
||||
res := &DeleteRecordsResponse{}
|
||||
res.Topics = make(map[string]*DeleteRecordsResponseTopic)
|
||||
|
||||
for topic, deleteRecordRequestTopic := range req.Topics {
|
||||
partitions := make(map[int32]*DeleteRecordsResponsePartition)
|
||||
for partition, _ := range deleteRecordRequestTopic.PartitionOffsets {
|
||||
partitions[partition] = &DeleteRecordsResponsePartition{Err: ErrNoError}
|
||||
}
|
||||
res.Topics[topic] = &DeleteRecordsResponseTopic{Partitions: partitions}
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
type MockDescribeConfigsResponse struct {
|
||||
t TestReporter
|
||||
}
|
||||
|
||||
func NewMockDescribeConfigsResponse(t TestReporter) *MockDescribeConfigsResponse {
|
||||
return &MockDescribeConfigsResponse{t: t}
|
||||
}
|
||||
|
||||
func (mr *MockDescribeConfigsResponse) For(reqBody versionedDecoder) encoder {
|
||||
req := reqBody.(*DescribeConfigsRequest)
|
||||
res := &DescribeConfigsResponse{}
|
||||
|
||||
var configEntries []*ConfigEntry
|
||||
configEntries = append(configEntries, &ConfigEntry{Name: "my_topic",
|
||||
Value: "my_topic",
|
||||
ReadOnly: true,
|
||||
Default: true,
|
||||
Sensitive: false,
|
||||
})
|
||||
|
||||
for _, r := range req.Resources {
|
||||
res.Resources = append(res.Resources, &ResourceResponse{Name: r.Name, Configs: configEntries})
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
type MockAlterConfigsResponse struct {
|
||||
t TestReporter
|
||||
}
|
||||
|
||||
func NewMockAlterConfigsResponse(t TestReporter) *MockAlterConfigsResponse {
|
||||
return &MockAlterConfigsResponse{t: t}
|
||||
}
|
||||
|
||||
func (mr *MockAlterConfigsResponse) For(reqBody versionedDecoder) encoder {
|
||||
req := reqBody.(*AlterConfigsRequest)
|
||||
res := &AlterConfigsResponse{}
|
||||
|
||||
for _, r := range req.Resources {
|
||||
res.Resources = append(res.Resources, &AlterConfigsResourceResponse{Name: r.Name,
|
||||
Type: TopicResource,
|
||||
ErrorMsg: "",
|
||||
})
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
type MockCreateAclsResponse struct {
|
||||
t TestReporter
|
||||
}
|
||||
|
||||
func NewMockCreateAclsResponse(t TestReporter) *MockCreateAclsResponse {
|
||||
return &MockCreateAclsResponse{t: t}
|
||||
}
|
||||
|
||||
func (mr *MockCreateAclsResponse) For(reqBody versionedDecoder) encoder {
|
||||
req := reqBody.(*CreateAclsRequest)
|
||||
res := &CreateAclsResponse{}
|
||||
|
||||
for range req.AclCreations {
|
||||
res.AclCreationResponses = append(res.AclCreationResponses, &AclCreationResponse{Err: ErrNoError})
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
type MockListAclsResponse struct {
|
||||
t TestReporter
|
||||
}
|
||||
|
||||
func NewMockListAclsResponse(t TestReporter) *MockListAclsResponse {
|
||||
return &MockListAclsResponse{t: t}
|
||||
}
|
||||
|
||||
func (mr *MockListAclsResponse) For(reqBody versionedDecoder) encoder {
|
||||
req := reqBody.(*DescribeAclsRequest)
|
||||
res := &DescribeAclsResponse{}
|
||||
|
||||
res.Err = ErrNoError
|
||||
acl := &ResourceAcls{}
|
||||
acl.Resource.ResourceName = *req.ResourceName
|
||||
acl.Resource.ResourceType = req.ResourceType
|
||||
acl.Acls = append(acl.Acls, &Acl{})
|
||||
res.ResourceAcls = append(res.ResourceAcls, acl)
|
||||
|
||||
return res
|
||||
}
|
||||
|
||||
type MockDeleteAclsResponse struct {
|
||||
t TestReporter
|
||||
}
|
||||
|
||||
func NewMockDeleteAclsResponse(t TestReporter) *MockDeleteAclsResponse {
|
||||
return &MockDeleteAclsResponse{t: t}
|
||||
}
|
||||
|
||||
func (mr *MockDeleteAclsResponse) For(reqBody versionedDecoder) encoder {
|
||||
req := reqBody.(*DeleteAclsRequest)
|
||||
res := &DeleteAclsResponse{}
|
||||
|
||||
for range req.Filters {
|
||||
response := &FilterResponse{Err: ErrNoError}
|
||||
response.MatchingAcls = append(response.MatchingAcls, &MatchingAcl{Err: ErrNoError})
|
||||
res.FilterResponses = append(res.FilterResponses, response)
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
664
vendor/github.com/Shopify/sarama/offset_manager.go
generated
vendored
664
vendor/github.com/Shopify/sarama/offset_manager.go
generated
vendored
@@ -25,27 +25,49 @@ type offsetManager struct {
|
||||
client Client
|
||||
conf *Config
|
||||
group string
|
||||
ticker *time.Ticker
|
||||
|
||||
lock sync.Mutex
|
||||
poms map[string]map[int32]*partitionOffsetManager
|
||||
boms map[*Broker]*brokerOffsetManager
|
||||
memberID string
|
||||
generation int32
|
||||
|
||||
broker *Broker
|
||||
brokerLock sync.RWMutex
|
||||
|
||||
poms map[string]map[int32]*partitionOffsetManager
|
||||
pomsLock sync.RWMutex
|
||||
|
||||
closeOnce sync.Once
|
||||
closing chan none
|
||||
closed chan none
|
||||
}
|
||||
|
||||
// NewOffsetManagerFromClient creates a new OffsetManager from the given client.
|
||||
// It is still necessary to call Close() on the underlying client when finished with the partition manager.
|
||||
func NewOffsetManagerFromClient(group string, client Client) (OffsetManager, error) {
|
||||
return newOffsetManagerFromClient(group, "", GroupGenerationUndefined, client)
|
||||
}
|
||||
|
||||
func newOffsetManagerFromClient(group, memberID string, generation int32, client Client) (*offsetManager, error) {
|
||||
// Check that we are not dealing with a closed Client before processing any other arguments
|
||||
if client.Closed() {
|
||||
return nil, ErrClosedClient
|
||||
}
|
||||
|
||||
conf := client.Config()
|
||||
om := &offsetManager{
|
||||
client: client,
|
||||
conf: client.Config(),
|
||||
conf: conf,
|
||||
group: group,
|
||||
ticker: time.NewTicker(conf.Consumer.Offsets.CommitInterval),
|
||||
poms: make(map[string]map[int32]*partitionOffsetManager),
|
||||
boms: make(map[*Broker]*brokerOffsetManager),
|
||||
|
||||
memberID: memberID,
|
||||
generation: generation,
|
||||
|
||||
closing: make(chan none),
|
||||
closed: make(chan none),
|
||||
}
|
||||
go withRecover(om.mainLoop)
|
||||
|
||||
return om, nil
|
||||
}
|
||||
@@ -56,8 +78,8 @@ func (om *offsetManager) ManagePartition(topic string, partition int32) (Partiti
|
||||
return nil, err
|
||||
}
|
||||
|
||||
om.lock.Lock()
|
||||
defer om.lock.Unlock()
|
||||
om.pomsLock.Lock()
|
||||
defer om.pomsLock.Unlock()
|
||||
|
||||
topicManagers := om.poms[topic]
|
||||
if topicManagers == nil {
|
||||
@@ -74,53 +96,307 @@ func (om *offsetManager) ManagePartition(topic string, partition int32) (Partiti
|
||||
}
|
||||
|
||||
func (om *offsetManager) Close() error {
|
||||
om.closeOnce.Do(func() {
|
||||
// exit the mainLoop
|
||||
close(om.closing)
|
||||
<-om.closed
|
||||
|
||||
// mark all POMs as closed
|
||||
om.asyncClosePOMs()
|
||||
|
||||
// flush one last time
|
||||
for attempt := 0; attempt <= om.conf.Consumer.Offsets.Retry.Max; attempt++ {
|
||||
om.flushToBroker()
|
||||
if om.releasePOMs(false) == 0 {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
om.releasePOMs(true)
|
||||
om.brokerLock.Lock()
|
||||
om.broker = nil
|
||||
om.brokerLock.Unlock()
|
||||
})
|
||||
return nil
|
||||
}
|
||||
|
||||
func (om *offsetManager) refBrokerOffsetManager(broker *Broker) *brokerOffsetManager {
|
||||
om.lock.Lock()
|
||||
defer om.lock.Unlock()
|
||||
|
||||
bom := om.boms[broker]
|
||||
if bom == nil {
|
||||
bom = om.newBrokerOffsetManager(broker)
|
||||
om.boms[broker] = bom
|
||||
func (om *offsetManager) fetchInitialOffset(topic string, partition int32, retries int) (int64, string, error) {
|
||||
broker, err := om.coordinator()
|
||||
if err != nil {
|
||||
if retries <= 0 {
|
||||
return 0, "", err
|
||||
}
|
||||
return om.fetchInitialOffset(topic, partition, retries-1)
|
||||
}
|
||||
|
||||
bom.refs++
|
||||
req := new(OffsetFetchRequest)
|
||||
req.Version = 1
|
||||
req.ConsumerGroup = om.group
|
||||
req.AddPartition(topic, partition)
|
||||
|
||||
return bom
|
||||
resp, err := broker.FetchOffset(req)
|
||||
if err != nil {
|
||||
if retries <= 0 {
|
||||
return 0, "", err
|
||||
}
|
||||
om.releaseCoordinator(broker)
|
||||
return om.fetchInitialOffset(topic, partition, retries-1)
|
||||
}
|
||||
|
||||
block := resp.GetBlock(topic, partition)
|
||||
if block == nil {
|
||||
return 0, "", ErrIncompleteResponse
|
||||
}
|
||||
|
||||
switch block.Err {
|
||||
case ErrNoError:
|
||||
return block.Offset, block.Metadata, nil
|
||||
case ErrNotCoordinatorForConsumer:
|
||||
if retries <= 0 {
|
||||
return 0, "", block.Err
|
||||
}
|
||||
om.releaseCoordinator(broker)
|
||||
return om.fetchInitialOffset(topic, partition, retries-1)
|
||||
case ErrOffsetsLoadInProgress:
|
||||
if retries <= 0 {
|
||||
return 0, "", block.Err
|
||||
}
|
||||
select {
|
||||
case <-om.closing:
|
||||
return 0, "", block.Err
|
||||
case <-time.After(om.conf.Metadata.Retry.Backoff):
|
||||
}
|
||||
return om.fetchInitialOffset(topic, partition, retries-1)
|
||||
default:
|
||||
return 0, "", block.Err
|
||||
}
|
||||
}
|
||||
|
||||
func (om *offsetManager) unrefBrokerOffsetManager(bom *brokerOffsetManager) {
|
||||
om.lock.Lock()
|
||||
defer om.lock.Unlock()
|
||||
func (om *offsetManager) coordinator() (*Broker, error) {
|
||||
om.brokerLock.RLock()
|
||||
broker := om.broker
|
||||
om.brokerLock.RUnlock()
|
||||
|
||||
bom.refs--
|
||||
if broker != nil {
|
||||
return broker, nil
|
||||
}
|
||||
|
||||
if bom.refs == 0 {
|
||||
close(bom.updateSubscriptions)
|
||||
if om.boms[bom.broker] == bom {
|
||||
delete(om.boms, bom.broker)
|
||||
om.brokerLock.Lock()
|
||||
defer om.brokerLock.Unlock()
|
||||
|
||||
if broker := om.broker; broker != nil {
|
||||
return broker, nil
|
||||
}
|
||||
|
||||
if err := om.client.RefreshCoordinator(om.group); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
broker, err := om.client.Coordinator(om.group)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
om.broker = broker
|
||||
return broker, nil
|
||||
}
|
||||
|
||||
func (om *offsetManager) releaseCoordinator(b *Broker) {
|
||||
om.brokerLock.Lock()
|
||||
if om.broker == b {
|
||||
om.broker = nil
|
||||
}
|
||||
om.brokerLock.Unlock()
|
||||
}
|
||||
|
||||
func (om *offsetManager) mainLoop() {
|
||||
defer om.ticker.Stop()
|
||||
defer close(om.closed)
|
||||
|
||||
for {
|
||||
select {
|
||||
case <-om.ticker.C:
|
||||
om.flushToBroker()
|
||||
om.releasePOMs(false)
|
||||
case <-om.closing:
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (om *offsetManager) abandonBroker(bom *brokerOffsetManager) {
|
||||
om.lock.Lock()
|
||||
defer om.lock.Unlock()
|
||||
func (om *offsetManager) flushToBroker() {
|
||||
req := om.constructRequest()
|
||||
if req == nil {
|
||||
return
|
||||
}
|
||||
|
||||
delete(om.boms, bom.broker)
|
||||
broker, err := om.coordinator()
|
||||
if err != nil {
|
||||
om.handleError(err)
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := broker.CommitOffset(req)
|
||||
if err != nil {
|
||||
om.handleError(err)
|
||||
om.releaseCoordinator(broker)
|
||||
_ = broker.Close()
|
||||
return
|
||||
}
|
||||
|
||||
om.handleResponse(broker, req, resp)
|
||||
}
|
||||
|
||||
func (om *offsetManager) abandonPartitionOffsetManager(pom *partitionOffsetManager) {
|
||||
om.lock.Lock()
|
||||
defer om.lock.Unlock()
|
||||
func (om *offsetManager) constructRequest() *OffsetCommitRequest {
|
||||
var r *OffsetCommitRequest
|
||||
var perPartitionTimestamp int64
|
||||
if om.conf.Consumer.Offsets.Retention == 0 {
|
||||
perPartitionTimestamp = ReceiveTime
|
||||
r = &OffsetCommitRequest{
|
||||
Version: 1,
|
||||
ConsumerGroup: om.group,
|
||||
ConsumerID: om.memberID,
|
||||
ConsumerGroupGeneration: om.generation,
|
||||
}
|
||||
} else {
|
||||
r = &OffsetCommitRequest{
|
||||
Version: 2,
|
||||
RetentionTime: int64(om.conf.Consumer.Offsets.Retention / time.Millisecond),
|
||||
ConsumerGroup: om.group,
|
||||
ConsumerID: om.memberID,
|
||||
ConsumerGroupGeneration: om.generation,
|
||||
}
|
||||
|
||||
delete(om.poms[pom.topic], pom.partition)
|
||||
if len(om.poms[pom.topic]) == 0 {
|
||||
delete(om.poms, pom.topic)
|
||||
}
|
||||
|
||||
om.pomsLock.RLock()
|
||||
defer om.pomsLock.RUnlock()
|
||||
|
||||
for _, topicManagers := range om.poms {
|
||||
for _, pom := range topicManagers {
|
||||
pom.lock.Lock()
|
||||
if pom.dirty {
|
||||
r.AddBlock(pom.topic, pom.partition, pom.offset, perPartitionTimestamp, pom.metadata)
|
||||
}
|
||||
pom.lock.Unlock()
|
||||
}
|
||||
}
|
||||
|
||||
if len(r.blocks) > 0 {
|
||||
return r
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (om *offsetManager) handleResponse(broker *Broker, req *OffsetCommitRequest, resp *OffsetCommitResponse) {
|
||||
om.pomsLock.RLock()
|
||||
defer om.pomsLock.RUnlock()
|
||||
|
||||
for _, topicManagers := range om.poms {
|
||||
for _, pom := range topicManagers {
|
||||
if req.blocks[pom.topic] == nil || req.blocks[pom.topic][pom.partition] == nil {
|
||||
continue
|
||||
}
|
||||
|
||||
var err KError
|
||||
var ok bool
|
||||
|
||||
if resp.Errors[pom.topic] == nil {
|
||||
pom.handleError(ErrIncompleteResponse)
|
||||
continue
|
||||
}
|
||||
if err, ok = resp.Errors[pom.topic][pom.partition]; !ok {
|
||||
pom.handleError(ErrIncompleteResponse)
|
||||
continue
|
||||
}
|
||||
|
||||
switch err {
|
||||
case ErrNoError:
|
||||
block := req.blocks[pom.topic][pom.partition]
|
||||
pom.updateCommitted(block.offset, block.metadata)
|
||||
case ErrNotLeaderForPartition, ErrLeaderNotAvailable,
|
||||
ErrConsumerCoordinatorNotAvailable, ErrNotCoordinatorForConsumer:
|
||||
// not a critical error, we just need to redispatch
|
||||
om.releaseCoordinator(broker)
|
||||
case ErrOffsetMetadataTooLarge, ErrInvalidCommitOffsetSize:
|
||||
// nothing we can do about this, just tell the user and carry on
|
||||
pom.handleError(err)
|
||||
case ErrOffsetsLoadInProgress:
|
||||
// nothing wrong but we didn't commit, we'll get it next time round
|
||||
break
|
||||
case ErrUnknownTopicOrPartition:
|
||||
// let the user know *and* try redispatching - if topic-auto-create is
|
||||
// enabled, redispatching should trigger a metadata req and create the
|
||||
// topic; if not then re-dispatching won't help, but we've let the user
|
||||
// know and it shouldn't hurt either (see https://github.com/Shopify/sarama/issues/706)
|
||||
fallthrough
|
||||
default:
|
||||
// dunno, tell the user and try redispatching
|
||||
pom.handleError(err)
|
||||
om.releaseCoordinator(broker)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (om *offsetManager) handleError(err error) {
|
||||
om.pomsLock.RLock()
|
||||
defer om.pomsLock.RUnlock()
|
||||
|
||||
for _, topicManagers := range om.poms {
|
||||
for _, pom := range topicManagers {
|
||||
pom.handleError(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (om *offsetManager) asyncClosePOMs() {
|
||||
om.pomsLock.RLock()
|
||||
defer om.pomsLock.RUnlock()
|
||||
|
||||
for _, topicManagers := range om.poms {
|
||||
for _, pom := range topicManagers {
|
||||
pom.AsyncClose()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Releases/removes closed POMs once they are clean (or when forced)
|
||||
func (om *offsetManager) releasePOMs(force bool) (remaining int) {
|
||||
om.pomsLock.Lock()
|
||||
defer om.pomsLock.Unlock()
|
||||
|
||||
for topic, topicManagers := range om.poms {
|
||||
for partition, pom := range topicManagers {
|
||||
pom.lock.Lock()
|
||||
releaseDue := pom.done && (force || !pom.dirty)
|
||||
pom.lock.Unlock()
|
||||
|
||||
if releaseDue {
|
||||
pom.release()
|
||||
|
||||
delete(om.poms[topic], partition)
|
||||
if len(om.poms[topic]) == 0 {
|
||||
delete(om.poms, topic)
|
||||
}
|
||||
}
|
||||
}
|
||||
remaining += len(om.poms[topic])
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (om *offsetManager) findPOM(topic string, partition int32) *partitionOffsetManager {
|
||||
om.pomsLock.RLock()
|
||||
defer om.pomsLock.RUnlock()
|
||||
|
||||
if partitions, ok := om.poms[topic]; ok {
|
||||
if pom, ok := partitions[partition]; ok {
|
||||
return pom
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Partition Offset Manager
|
||||
@@ -187,138 +463,26 @@ type partitionOffsetManager struct {
|
||||
offset int64
|
||||
metadata string
|
||||
dirty bool
|
||||
clean sync.Cond
|
||||
broker *brokerOffsetManager
|
||||
done bool
|
||||
|
||||
errors chan *ConsumerError
|
||||
rebalance chan none
|
||||
dying chan none
|
||||
releaseOnce sync.Once
|
||||
errors chan *ConsumerError
|
||||
}
|
||||
|
||||
func (om *offsetManager) newPartitionOffsetManager(topic string, partition int32) (*partitionOffsetManager, error) {
|
||||
pom := &partitionOffsetManager{
|
||||
offset, metadata, err := om.fetchInitialOffset(topic, partition, om.conf.Metadata.Retry.Max)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &partitionOffsetManager{
|
||||
parent: om,
|
||||
topic: topic,
|
||||
partition: partition,
|
||||
errors: make(chan *ConsumerError, om.conf.ChannelBufferSize),
|
||||
rebalance: make(chan none, 1),
|
||||
dying: make(chan none),
|
||||
}
|
||||
pom.clean.L = &pom.lock
|
||||
|
||||
if err := pom.selectBroker(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if err := pom.fetchInitialOffset(om.conf.Metadata.Retry.Max); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
pom.broker.updateSubscriptions <- pom
|
||||
|
||||
go withRecover(pom.mainLoop)
|
||||
|
||||
return pom, nil
|
||||
}
|
||||
|
||||
func (pom *partitionOffsetManager) mainLoop() {
|
||||
for {
|
||||
select {
|
||||
case <-pom.rebalance:
|
||||
if err := pom.selectBroker(); err != nil {
|
||||
pom.handleError(err)
|
||||
pom.rebalance <- none{}
|
||||
} else {
|
||||
pom.broker.updateSubscriptions <- pom
|
||||
}
|
||||
case <-pom.dying:
|
||||
if pom.broker != nil {
|
||||
select {
|
||||
case <-pom.rebalance:
|
||||
case pom.broker.updateSubscriptions <- pom:
|
||||
}
|
||||
pom.parent.unrefBrokerOffsetManager(pom.broker)
|
||||
}
|
||||
pom.parent.abandonPartitionOffsetManager(pom)
|
||||
close(pom.errors)
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (pom *partitionOffsetManager) selectBroker() error {
|
||||
if pom.broker != nil {
|
||||
pom.parent.unrefBrokerOffsetManager(pom.broker)
|
||||
pom.broker = nil
|
||||
}
|
||||
|
||||
var broker *Broker
|
||||
var err error
|
||||
|
||||
if err = pom.parent.client.RefreshCoordinator(pom.parent.group); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if broker, err = pom.parent.client.Coordinator(pom.parent.group); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
pom.broker = pom.parent.refBrokerOffsetManager(broker)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (pom *partitionOffsetManager) fetchInitialOffset(retries int) error {
|
||||
request := new(OffsetFetchRequest)
|
||||
request.Version = 1
|
||||
request.ConsumerGroup = pom.parent.group
|
||||
request.AddPartition(pom.topic, pom.partition)
|
||||
|
||||
response, err := pom.broker.broker.FetchOffset(request)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
block := response.GetBlock(pom.topic, pom.partition)
|
||||
if block == nil {
|
||||
return ErrIncompleteResponse
|
||||
}
|
||||
|
||||
switch block.Err {
|
||||
case ErrNoError:
|
||||
pom.offset = block.Offset
|
||||
pom.metadata = block.Metadata
|
||||
return nil
|
||||
case ErrNotCoordinatorForConsumer:
|
||||
if retries <= 0 {
|
||||
return block.Err
|
||||
}
|
||||
if err := pom.selectBroker(); err != nil {
|
||||
return err
|
||||
}
|
||||
return pom.fetchInitialOffset(retries - 1)
|
||||
case ErrOffsetsLoadInProgress:
|
||||
if retries <= 0 {
|
||||
return block.Err
|
||||
}
|
||||
time.Sleep(pom.parent.conf.Metadata.Retry.Backoff)
|
||||
return pom.fetchInitialOffset(retries - 1)
|
||||
default:
|
||||
return block.Err
|
||||
}
|
||||
}
|
||||
|
||||
func (pom *partitionOffsetManager) handleError(err error) {
|
||||
cErr := &ConsumerError{
|
||||
Topic: pom.topic,
|
||||
Partition: pom.partition,
|
||||
Err: err,
|
||||
}
|
||||
|
||||
if pom.parent.conf.Consumer.Return.Errors {
|
||||
pom.errors <- cErr
|
||||
} else {
|
||||
Logger.Println(cErr)
|
||||
}
|
||||
offset: offset,
|
||||
metadata: metadata,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (pom *partitionOffsetManager) Errors() <-chan *ConsumerError {
|
||||
@@ -353,7 +517,6 @@ func (pom *partitionOffsetManager) updateCommitted(offset int64, metadata string
|
||||
|
||||
if pom.offset == offset && pom.metadata == metadata {
|
||||
pom.dirty = false
|
||||
pom.clean.Signal()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -369,16 +532,9 @@ func (pom *partitionOffsetManager) NextOffset() (int64, string) {
|
||||
}
|
||||
|
||||
func (pom *partitionOffsetManager) AsyncClose() {
|
||||
go func() {
|
||||
pom.lock.Lock()
|
||||
defer pom.lock.Unlock()
|
||||
|
||||
for pom.dirty {
|
||||
pom.clean.Wait()
|
||||
}
|
||||
|
||||
close(pom.dying)
|
||||
}()
|
||||
pom.lock.Lock()
|
||||
pom.done = true
|
||||
pom.lock.Unlock()
|
||||
}
|
||||
|
||||
func (pom *partitionOffsetManager) Close() error {
|
||||
@@ -395,166 +551,22 @@ func (pom *partitionOffsetManager) Close() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Broker Offset Manager
|
||||
|
||||
type brokerOffsetManager struct {
|
||||
parent *offsetManager
|
||||
broker *Broker
|
||||
timer *time.Ticker
|
||||
updateSubscriptions chan *partitionOffsetManager
|
||||
subscriptions map[*partitionOffsetManager]none
|
||||
refs int
|
||||
}
|
||||
|
||||
func (om *offsetManager) newBrokerOffsetManager(broker *Broker) *brokerOffsetManager {
|
||||
bom := &brokerOffsetManager{
|
||||
parent: om,
|
||||
broker: broker,
|
||||
timer: time.NewTicker(om.conf.Consumer.Offsets.CommitInterval),
|
||||
updateSubscriptions: make(chan *partitionOffsetManager),
|
||||
subscriptions: make(map[*partitionOffsetManager]none),
|
||||
func (pom *partitionOffsetManager) handleError(err error) {
|
||||
cErr := &ConsumerError{
|
||||
Topic: pom.topic,
|
||||
Partition: pom.partition,
|
||||
Err: err,
|
||||
}
|
||||
|
||||
go withRecover(bom.mainLoop)
|
||||
|
||||
return bom
|
||||
}
|
||||
|
||||
func (bom *brokerOffsetManager) mainLoop() {
|
||||
for {
|
||||
select {
|
||||
case <-bom.timer.C:
|
||||
if len(bom.subscriptions) > 0 {
|
||||
bom.flushToBroker()
|
||||
}
|
||||
case s, ok := <-bom.updateSubscriptions:
|
||||
if !ok {
|
||||
bom.timer.Stop()
|
||||
return
|
||||
}
|
||||
if _, ok := bom.subscriptions[s]; ok {
|
||||
delete(bom.subscriptions, s)
|
||||
} else {
|
||||
bom.subscriptions[s] = none{}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (bom *brokerOffsetManager) flushToBroker() {
|
||||
request := bom.constructRequest()
|
||||
if request == nil {
|
||||
return
|
||||
}
|
||||
|
||||
response, err := bom.broker.CommitOffset(request)
|
||||
|
||||
if err != nil {
|
||||
bom.abort(err)
|
||||
return
|
||||
}
|
||||
|
||||
for s := range bom.subscriptions {
|
||||
if request.blocks[s.topic] == nil || request.blocks[s.topic][s.partition] == nil {
|
||||
continue
|
||||
}
|
||||
|
||||
var err KError
|
||||
var ok bool
|
||||
|
||||
if response.Errors[s.topic] == nil {
|
||||
s.handleError(ErrIncompleteResponse)
|
||||
delete(bom.subscriptions, s)
|
||||
s.rebalance <- none{}
|
||||
continue
|
||||
}
|
||||
if err, ok = response.Errors[s.topic][s.partition]; !ok {
|
||||
s.handleError(ErrIncompleteResponse)
|
||||
delete(bom.subscriptions, s)
|
||||
s.rebalance <- none{}
|
||||
continue
|
||||
}
|
||||
|
||||
switch err {
|
||||
case ErrNoError:
|
||||
block := request.blocks[s.topic][s.partition]
|
||||
s.updateCommitted(block.offset, block.metadata)
|
||||
case ErrNotLeaderForPartition, ErrLeaderNotAvailable,
|
||||
ErrConsumerCoordinatorNotAvailable, ErrNotCoordinatorForConsumer:
|
||||
// not a critical error, we just need to redispatch
|
||||
delete(bom.subscriptions, s)
|
||||
s.rebalance <- none{}
|
||||
case ErrOffsetMetadataTooLarge, ErrInvalidCommitOffsetSize:
|
||||
// nothing we can do about this, just tell the user and carry on
|
||||
s.handleError(err)
|
||||
case ErrOffsetsLoadInProgress:
|
||||
// nothing wrong but we didn't commit, we'll get it next time round
|
||||
break
|
||||
case ErrUnknownTopicOrPartition:
|
||||
// let the user know *and* try redispatching - if topic-auto-create is
|
||||
// enabled, redispatching should trigger a metadata request and create the
|
||||
// topic; if not then re-dispatching won't help, but we've let the user
|
||||
// know and it shouldn't hurt either (see https://github.com/Shopify/sarama/issues/706)
|
||||
fallthrough
|
||||
default:
|
||||
// dunno, tell the user and try redispatching
|
||||
s.handleError(err)
|
||||
delete(bom.subscriptions, s)
|
||||
s.rebalance <- none{}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (bom *brokerOffsetManager) constructRequest() *OffsetCommitRequest {
|
||||
var r *OffsetCommitRequest
|
||||
var perPartitionTimestamp int64
|
||||
if bom.parent.conf.Consumer.Offsets.Retention == 0 {
|
||||
perPartitionTimestamp = ReceiveTime
|
||||
r = &OffsetCommitRequest{
|
||||
Version: 1,
|
||||
ConsumerGroup: bom.parent.group,
|
||||
ConsumerGroupGeneration: GroupGenerationUndefined,
|
||||
}
|
||||
if pom.parent.conf.Consumer.Return.Errors {
|
||||
pom.errors <- cErr
|
||||
} else {
|
||||
r = &OffsetCommitRequest{
|
||||
Version: 2,
|
||||
RetentionTime: int64(bom.parent.conf.Consumer.Offsets.Retention / time.Millisecond),
|
||||
ConsumerGroup: bom.parent.group,
|
||||
ConsumerGroupGeneration: GroupGenerationUndefined,
|
||||
}
|
||||
|
||||
Logger.Println(cErr)
|
||||
}
|
||||
|
||||
for s := range bom.subscriptions {
|
||||
s.lock.Lock()
|
||||
if s.dirty {
|
||||
r.AddBlock(s.topic, s.partition, s.offset, perPartitionTimestamp, s.metadata)
|
||||
}
|
||||
s.lock.Unlock()
|
||||
}
|
||||
|
||||
if len(r.blocks) > 0 {
|
||||
return r
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (bom *brokerOffsetManager) abort(err error) {
|
||||
_ = bom.broker.Close() // we don't care about the error this might return, we already have one
|
||||
bom.parent.abandonBroker(bom)
|
||||
|
||||
for pom := range bom.subscriptions {
|
||||
pom.handleError(err)
|
||||
pom.rebalance <- none{}
|
||||
}
|
||||
|
||||
for s := range bom.updateSubscriptions {
|
||||
if _, ok := bom.subscriptions[s]; !ok {
|
||||
s.handleError(err)
|
||||
s.rebalance <- none{}
|
||||
}
|
||||
}
|
||||
|
||||
bom.subscriptions = make(map[*partitionOffsetManager]none)
|
||||
func (pom *partitionOffsetManager) release() {
|
||||
pom.releaseOnce.Do(func() {
|
||||
go close(pom.errors)
|
||||
})
|
||||
}
|
||||
|
||||
92
vendor/github.com/Shopify/sarama/partitioner.go
generated
vendored
92
vendor/github.com/Shopify/sarama/partitioner.go
generated
vendored
@@ -22,11 +22,51 @@ type Partitioner interface {
|
||||
RequiresConsistency() bool
|
||||
}
|
||||
|
||||
// DynamicConsistencyPartitioner can optionally be implemented by Partitioners
|
||||
// in order to allow more flexibility than is originally allowed by the
|
||||
// RequiresConsistency method in the Partitioner interface. This allows
|
||||
// partitioners to require consistency sometimes, but not all times. It's useful
|
||||
// for, e.g., the HashPartitioner, which does not require consistency if the
|
||||
// message key is nil.
|
||||
type DynamicConsistencyPartitioner interface {
|
||||
Partitioner
|
||||
|
||||
// MessageRequiresConsistency is similar to Partitioner.RequiresConsistency,
|
||||
// but takes in the message being partitioned so that the partitioner can
|
||||
// make a per-message determination.
|
||||
MessageRequiresConsistency(message *ProducerMessage) bool
|
||||
}
|
||||
|
||||
// PartitionerConstructor is the type for a function capable of constructing new Partitioners.
|
||||
type PartitionerConstructor func(topic string) Partitioner
|
||||
|
||||
type manualPartitioner struct{}
|
||||
|
||||
// HashPartitionOption lets you modify default values of the partitioner
|
||||
type HashPartitionerOption func(*hashPartitioner)
|
||||
|
||||
// WithAbsFirst means that the partitioner handles absolute values
|
||||
// in the same way as the reference Java implementation
|
||||
func WithAbsFirst() HashPartitionerOption {
|
||||
return func(hp *hashPartitioner) {
|
||||
hp.referenceAbs = true
|
||||
}
|
||||
}
|
||||
|
||||
// WithCustomHashFunction lets you specify what hash function to use for the partitioning
|
||||
func WithCustomHashFunction(hasher func() hash.Hash32) HashPartitionerOption {
|
||||
return func(hp *hashPartitioner) {
|
||||
hp.hasher = hasher()
|
||||
}
|
||||
}
|
||||
|
||||
// WithCustomFallbackPartitioner lets you specify what HashPartitioner should be used in case a Distribution Key is empty
|
||||
func WithCustomFallbackPartitioner(randomHP *hashPartitioner) HashPartitionerOption {
|
||||
return func(hp *hashPartitioner) {
|
||||
hp.random = hp
|
||||
}
|
||||
}
|
||||
|
||||
// NewManualPartitioner returns a Partitioner which uses the partition manually set in the provided
|
||||
// ProducerMessage's Partition field as the partition to produce to.
|
||||
func NewManualPartitioner(topic string) Partitioner {
|
||||
@@ -83,8 +123,9 @@ func (p *roundRobinPartitioner) RequiresConsistency() bool {
|
||||
}
|
||||
|
||||
type hashPartitioner struct {
|
||||
random Partitioner
|
||||
hasher hash.Hash32
|
||||
random Partitioner
|
||||
hasher hash.Hash32
|
||||
referenceAbs bool
|
||||
}
|
||||
|
||||
// NewCustomHashPartitioner is a wrapper around NewHashPartitioner, allowing the use of custom hasher.
|
||||
@@ -95,6 +136,21 @@ func NewCustomHashPartitioner(hasher func() hash.Hash32) PartitionerConstructor
|
||||
p := new(hashPartitioner)
|
||||
p.random = NewRandomPartitioner(topic)
|
||||
p.hasher = hasher()
|
||||
p.referenceAbs = false
|
||||
return p
|
||||
}
|
||||
}
|
||||
|
||||
// NewCustomPartitioner creates a default Partitioner but lets you specify the behavior of each component via options
|
||||
func NewCustomPartitioner(options ...HashPartitionerOption) PartitionerConstructor {
|
||||
return func(topic string) Partitioner {
|
||||
p := new(hashPartitioner)
|
||||
p.random = NewRandomPartitioner(topic)
|
||||
p.hasher = fnv.New32a()
|
||||
p.referenceAbs = false
|
||||
for _, option := range options {
|
||||
option(p)
|
||||
}
|
||||
return p
|
||||
}
|
||||
}
|
||||
@@ -107,6 +163,19 @@ func NewHashPartitioner(topic string) Partitioner {
|
||||
p := new(hashPartitioner)
|
||||
p.random = NewRandomPartitioner(topic)
|
||||
p.hasher = fnv.New32a()
|
||||
p.referenceAbs = false
|
||||
return p
|
||||
}
|
||||
|
||||
// NewReferenceHashPartitioner is like NewHashPartitioner except that it handles absolute values
|
||||
// in the same way as the reference Java implementation. NewHashPartitioner was supposed to do
|
||||
// that but it had a mistake and now there are people depending on both behaviours. This will
|
||||
// all go away on the next major version bump.
|
||||
func NewReferenceHashPartitioner(topic string) Partitioner {
|
||||
p := new(hashPartitioner)
|
||||
p.random = NewRandomPartitioner(topic)
|
||||
p.hasher = fnv.New32a()
|
||||
p.referenceAbs = true
|
||||
return p
|
||||
}
|
||||
|
||||
@@ -123,9 +192,18 @@ func (p *hashPartitioner) Partition(message *ProducerMessage, numPartitions int3
|
||||
if err != nil {
|
||||
return -1, err
|
||||
}
|
||||
partition := int32(p.hasher.Sum32()) % numPartitions
|
||||
if partition < 0 {
|
||||
partition = -partition
|
||||
var partition int32
|
||||
// Turns out we were doing our absolute value in a subtly different way from the upstream
|
||||
// implementation, but now we need to maintain backwards compat for people who started using
|
||||
// the old version; if referenceAbs is set we are compatible with the reference java client
|
||||
// but not past Sarama versions
|
||||
if p.referenceAbs {
|
||||
partition = (int32(p.hasher.Sum32()) & 0x7fffffff) % numPartitions
|
||||
} else {
|
||||
partition = int32(p.hasher.Sum32()) % numPartitions
|
||||
if partition < 0 {
|
||||
partition = -partition
|
||||
}
|
||||
}
|
||||
return partition, nil
|
||||
}
|
||||
@@ -133,3 +211,7 @@ func (p *hashPartitioner) Partition(message *ProducerMessage, numPartitions int3
|
||||
func (p *hashPartitioner) RequiresConsistency() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func (p *hashPartitioner) MessageRequiresConsistency(message *ProducerMessage) bool {
|
||||
return message.Key != nil
|
||||
}
|
||||
|
||||
21
vendor/github.com/Shopify/sarama/records.go
generated
vendored
21
vendor/github.com/Shopify/sarama/records.go
generated
vendored
@@ -163,6 +163,27 @@ func (r *Records) isControl() (bool, error) {
|
||||
return false, fmt.Errorf("unknown records type: %v", r.recordsType)
|
||||
}
|
||||
|
||||
func (r *Records) isOverflow() (bool, error) {
|
||||
if r.recordsType == unknownRecords {
|
||||
if empty, err := r.setTypeFromFields(); err != nil || empty {
|
||||
return false, err
|
||||
}
|
||||
}
|
||||
|
||||
switch r.recordsType {
|
||||
case unknownRecords:
|
||||
return false, nil
|
||||
case legacyRecords:
|
||||
if r.MsgSet == nil {
|
||||
return false, nil
|
||||
}
|
||||
return r.MsgSet.OverflowMessage, nil
|
||||
case defaultRecords:
|
||||
return false, nil
|
||||
}
|
||||
return false, fmt.Errorf("unknown records type: %v", r.recordsType)
|
||||
}
|
||||
|
||||
func magicValue(pd packetDecoder) (int8, error) {
|
||||
dec, err := pd.peek(magicOffset, magicLength)
|
||||
if err != nil {
|
||||
|
||||
23
vendor/github.com/Shopify/sarama/sync_producer.go
generated
vendored
23
vendor/github.com/Shopify/sarama/sync_producer.go
generated
vendored
@@ -90,13 +90,8 @@ func verifyProducerConfig(config *Config) error {
|
||||
}
|
||||
|
||||
func (sp *syncProducer) SendMessage(msg *ProducerMessage) (partition int32, offset int64, err error) {
|
||||
oldMetadata := msg.Metadata
|
||||
defer func() {
|
||||
msg.Metadata = oldMetadata
|
||||
}()
|
||||
|
||||
expectation := make(chan *ProducerError, 1)
|
||||
msg.Metadata = expectation
|
||||
msg.expectation = expectation
|
||||
sp.producer.Input() <- msg
|
||||
|
||||
if err := <-expectation; err != nil {
|
||||
@@ -107,21 +102,11 @@ func (sp *syncProducer) SendMessage(msg *ProducerMessage) (partition int32, offs
|
||||
}
|
||||
|
||||
func (sp *syncProducer) SendMessages(msgs []*ProducerMessage) error {
|
||||
savedMetadata := make([]interface{}, len(msgs))
|
||||
for i := range msgs {
|
||||
savedMetadata[i] = msgs[i].Metadata
|
||||
}
|
||||
defer func() {
|
||||
for i := range msgs {
|
||||
msgs[i].Metadata = savedMetadata[i]
|
||||
}
|
||||
}()
|
||||
|
||||
expectations := make(chan chan *ProducerError, len(msgs))
|
||||
go func() {
|
||||
for _, msg := range msgs {
|
||||
expectation := make(chan *ProducerError, 1)
|
||||
msg.Metadata = expectation
|
||||
msg.expectation = expectation
|
||||
sp.producer.Input() <- msg
|
||||
expectations <- expectation
|
||||
}
|
||||
@@ -144,7 +129,7 @@ func (sp *syncProducer) SendMessages(msgs []*ProducerMessage) error {
|
||||
func (sp *syncProducer) handleSuccesses() {
|
||||
defer sp.wg.Done()
|
||||
for msg := range sp.producer.Successes() {
|
||||
expectation := msg.Metadata.(chan *ProducerError)
|
||||
expectation := msg.expectation
|
||||
expectation <- nil
|
||||
}
|
||||
}
|
||||
@@ -152,7 +137,7 @@ func (sp *syncProducer) handleSuccesses() {
|
||||
func (sp *syncProducer) handleErrors() {
|
||||
defer sp.wg.Done()
|
||||
for err := range sp.producer.Errors() {
|
||||
expectation := err.Msg.Metadata.(chan *ProducerError)
|
||||
expectation := err.Msg.expectation
|
||||
expectation <- err
|
||||
}
|
||||
}
|
||||
|
||||
4
vendor/github.com/Shopify/sarama/utils.go
generated
vendored
4
vendor/github.com/Shopify/sarama/utils.go
generated
vendored
@@ -155,6 +155,7 @@ var (
|
||||
V0_11_0_2 = newKafkaVersion(0, 11, 0, 2)
|
||||
V1_0_0_0 = newKafkaVersion(1, 0, 0, 0)
|
||||
V1_1_0_0 = newKafkaVersion(1, 1, 0, 0)
|
||||
V2_0_0_0 = newKafkaVersion(2, 0, 0, 0)
|
||||
|
||||
SupportedVersions = []KafkaVersion{
|
||||
V0_8_2_0,
|
||||
@@ -173,9 +174,10 @@ var (
|
||||
V0_11_0_2,
|
||||
V1_0_0_0,
|
||||
V1_1_0_0,
|
||||
V2_0_0_0,
|
||||
}
|
||||
MinVersion = V0_8_2_0
|
||||
MaxVersion = V1_1_0_0
|
||||
MaxVersion = V2_0_0_0
|
||||
)
|
||||
|
||||
func ParseKafkaVersion(s string) (KafkaVersion, error) {
|
||||
|
||||
72
vendor/github.com/aliyun/aliyun-oss-go-sdk/oss/bucket.go
generated
vendored
72
vendor/github.com/aliyun/aliyun-oss-go-sdk/oss/bucket.go
generated
vendored
@@ -9,11 +9,11 @@ import (
|
||||
"hash"
|
||||
"hash/crc64"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
@@ -128,7 +128,8 @@ func (bucket Bucket) GetObject(objectKey string, options ...Option) (io.ReadClos
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return result.Response.Body, nil
|
||||
|
||||
return result.Response, nil
|
||||
}
|
||||
|
||||
// GetObjectToFile downloads the data to a local file.
|
||||
@@ -147,7 +148,7 @@ func (bucket Bucket) GetObjectToFile(objectKey, filePath string, options ...Opti
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer result.Response.Body.Close()
|
||||
defer result.Response.Close()
|
||||
|
||||
// If the local file does not exist, create a new one. If it exists, overwrite it.
|
||||
fd, err := os.OpenFile(tempFilePath, os.O_CREATE|os.O_TRUNC|os.O_WRONLY, FilePermMode)
|
||||
@@ -164,7 +165,12 @@ func (bucket Bucket) GetObjectToFile(objectKey, filePath string, options ...Opti
|
||||
|
||||
// Compares the CRC value
|
||||
hasRange, _, _ := isOptionSet(options, HTTPHeaderRange)
|
||||
if bucket.getConfig().IsEnableCRC && !hasRange {
|
||||
encodeOpt, _ := findOption(options, HTTPHeaderAcceptEncoding, nil)
|
||||
acceptEncoding := ""
|
||||
if encodeOpt != nil {
|
||||
acceptEncoding = encodeOpt.(string)
|
||||
}
|
||||
if bucket.getConfig().IsEnableCRC && !hasRange && acceptEncoding != "gzip" {
|
||||
result.Response.ClientCRC = result.ClientCRC.Sum64()
|
||||
err = checkCRC(result.Response, "GetObjectToFile")
|
||||
if err != nil {
|
||||
@@ -185,7 +191,7 @@ func (bucket Bucket) GetObjectToFile(objectKey, filePath string, options ...Opti
|
||||
// error it's nil if no error, otherwise it's an error object.
|
||||
//
|
||||
func (bucket Bucket) DoGetObject(request *GetObjectRequest, options []Option) (*GetObjectResult, error) {
|
||||
params := map[string]interface{}{}
|
||||
params, _ := getRawParams(options)
|
||||
resp, err := bucket.do("GET", request.ObjectKey, params, options, nil, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -208,7 +214,7 @@ func (bucket Bucket) DoGetObject(request *GetObjectRequest, options []Option) (*
|
||||
listener := getProgressListener(options)
|
||||
|
||||
contentLen, _ := strconv.ParseInt(resp.Headers.Get(HTTPHeaderContentLength), 10, 64)
|
||||
resp.Body = ioutil.NopCloser(TeeReader(resp.Body, crcCalc, contentLen, listener, nil))
|
||||
resp.Body = TeeReader(resp.Body, crcCalc, contentLen, listener, nil)
|
||||
|
||||
return result, nil
|
||||
}
|
||||
@@ -219,7 +225,7 @@ func (bucket Bucket) DoGetObject(request *GetObjectRequest, options []Option) (*
|
||||
// destObjectKey the target object to copy.
|
||||
// options options for copying an object. You can specify the conditions of copy. The valid conditions are CopySourceIfMatch,
|
||||
// CopySourceIfNoneMatch, CopySourceIfModifiedSince, CopySourceIfUnmodifiedSince, MetadataDirective.
|
||||
// Also you can specify the target object's attributes, such as CacheControl, ContentDisposition, ContentEncoding, Expires,
|
||||
// Also you can specify the target object's attributes, such as CacheControl, ContentDisposition, ContentEncoding, Expires,
|
||||
// ServerSideEncryption, ObjectACL, Meta. Refer to the link below for more details :
|
||||
// https://help.aliyun.com/document_detail/oss/api-reference/object/CopyObject.html
|
||||
//
|
||||
@@ -303,7 +309,7 @@ func (bucket Bucket) copy(srcObjectKey, destBucketName, destObjectKey string, op
|
||||
// reader io.Reader. The read instance for reading the data to append.
|
||||
// appendPosition the start position to append.
|
||||
// destObjectProperties the options for the first appending, such as CacheControl, ContentDisposition, ContentEncoding,
|
||||
// Expires, ServerSideEncryption, ObjectACL.
|
||||
// Expires, ServerSideEncryption, ObjectACL.
|
||||
//
|
||||
// int64 the next append position, it's valid when error is nil.
|
||||
// error it's nil if no error, otherwise it's an error object.
|
||||
@@ -464,7 +470,7 @@ func (bucket Bucket) IsObjectExist(objectKey string) (bool, error) {
|
||||
// options it contains all the filters for listing objects.
|
||||
// It could specify a prefix filter on object keys, the max keys count to return and the object key marker and the delimiter for grouping object names.
|
||||
// The key marker means the returned objects' key must be greater than it in lexicographic order.
|
||||
//
|
||||
//
|
||||
// For example, if the bucket has 8 objects, my-object-1, my-object-11, my-object-2, my-object-21,
|
||||
// my-object-22, my-object-3, my-object-31, my-object-32. If the prefix is my-object-2 (no other filters), then it returns
|
||||
// my-object-2, my-object-21, my-object-22 three objects. If the marker is my-object-22 (no other filters), then it returns
|
||||
@@ -474,9 +480,9 @@ func (bucket Bucket) IsObjectExist(objectKey string) (bool, error) {
|
||||
// But if the delimiter is specified with '/', then it only returns that folder's files (no subfolder's files). The direct subfolders are in the commonPrefixes properties.
|
||||
// For example, if the bucket has three objects fun/test.jpg, fun/movie/001.avi, fun/movie/007.avi. And if the prefix is "fun/", then it returns all three objects.
|
||||
// But if the delimiter is '/', then only "fun/test.jpg" is returned as files and fun/movie/ is returned as common prefix.
|
||||
//
|
||||
//
|
||||
// For common usage scenario, check out sample/list_object.go.
|
||||
//
|
||||
//
|
||||
// ListObjectsResponse the return value after operation succeeds (only valid when error is nil).
|
||||
//
|
||||
func (bucket Bucket) ListObjects(options ...Option) (ListObjectsResult, error) {
|
||||
@@ -802,7 +808,7 @@ func (bucket Bucket) GetObjectWithURL(signedURL string, options ...Option) (io.R
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return result.Response.Body, nil
|
||||
return result.Response, nil
|
||||
}
|
||||
|
||||
// GetObjectToFileWithURL downloads the object into a local file with the signed URL.
|
||||
@@ -821,7 +827,7 @@ func (bucket Bucket) GetObjectToFileWithURL(signedURL, filePath string, options
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer result.Response.Body.Close()
|
||||
defer result.Response.Close()
|
||||
|
||||
// If the file does not exist, create one. If exists, then overwrite it.
|
||||
fd, err := os.OpenFile(tempFilePath, os.O_CREATE|os.O_TRUNC|os.O_WRONLY, FilePermMode)
|
||||
@@ -838,7 +844,13 @@ func (bucket Bucket) GetObjectToFileWithURL(signedURL, filePath string, options
|
||||
|
||||
// Compare the CRC value. If CRC values do not match, return error.
|
||||
hasRange, _, _ := isOptionSet(options, HTTPHeaderRange)
|
||||
if bucket.getConfig().IsEnableCRC && !hasRange {
|
||||
encodeOpt, _ := findOption(options, HTTPHeaderAcceptEncoding, nil)
|
||||
acceptEncoding := ""
|
||||
if encodeOpt != nil {
|
||||
acceptEncoding = encodeOpt.(string)
|
||||
}
|
||||
|
||||
if bucket.getConfig().IsEnableCRC && !hasRange && acceptEncoding != "gzip" {
|
||||
result.Response.ClientCRC = result.ClientCRC.Sum64()
|
||||
err = checkCRC(result.Response, "GetObjectToFileWithURL")
|
||||
if err != nil {
|
||||
@@ -859,7 +871,7 @@ func (bucket Bucket) GetObjectToFileWithURL(signedURL, filePath string, options
|
||||
// error it's nil if no error, otherwise it's an error object.
|
||||
//
|
||||
func (bucket Bucket) DoGetObjectWithURL(signedURL string, options []Option) (*GetObjectResult, error) {
|
||||
params := map[string]interface{}{}
|
||||
params, _ := getRawParams(options)
|
||||
resp, err := bucket.doURL("GET", signedURL, params, options, nil, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -882,11 +894,39 @@ func (bucket Bucket) DoGetObjectWithURL(signedURL string, options []Option) (*Ge
|
||||
listener := getProgressListener(options)
|
||||
|
||||
contentLen, _ := strconv.ParseInt(resp.Headers.Get(HTTPHeaderContentLength), 10, 64)
|
||||
resp.Body = ioutil.NopCloser(TeeReader(resp.Body, crcCalc, contentLen, listener, nil))
|
||||
resp.Body = TeeReader(resp.Body, crcCalc, contentLen, listener, nil)
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
//
|
||||
// ProcessObject apply process on the specified image file.
|
||||
//
|
||||
// The supported process includes resize, rotate, crop, watermark, format,
|
||||
// udf, customized style, etc.
|
||||
//
|
||||
//
|
||||
// objectKey object key to process.
|
||||
// process process string, such as "image/resize,w_100|sys/saveas,o_dGVzdC5qcGc,b_dGVzdA"
|
||||
//
|
||||
// error it's nil if no error, otherwise it's an error object.
|
||||
//
|
||||
func (bucket Bucket) ProcessObject(objectKey string, process string) (ProcessObjectResult, error) {
|
||||
var out ProcessObjectResult
|
||||
params := map[string]interface{}{}
|
||||
params["x-oss-process"] = nil
|
||||
processData := fmt.Sprintf("%v=%v", "x-oss-process", process)
|
||||
data := strings.NewReader(processData)
|
||||
resp, err := bucket.do("POST", objectKey, params, nil, data, nil)
|
||||
if err != nil {
|
||||
return out, err
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
err = jsonUnmarshal(resp.Body, &out)
|
||||
return out, err
|
||||
}
|
||||
|
||||
// Private
|
||||
func (bucket Bucket) do(method, objectName string, params map[string]interface{}, options []Option,
|
||||
data io.Reader, listener ProgressListener) (*Response, error) {
|
||||
|
||||
17
vendor/github.com/aliyun/aliyun-oss-go-sdk/oss/conn.go
generated
vendored
17
vendor/github.com/aliyun/aliyun-oss-go-sdk/oss/conn.go
generated
vendored
@@ -4,6 +4,7 @@ import (
|
||||
"bytes"
|
||||
"crypto/md5"
|
||||
"encoding/base64"
|
||||
"encoding/json"
|
||||
"encoding/xml"
|
||||
"fmt"
|
||||
"hash"
|
||||
@@ -26,7 +27,7 @@ type Conn struct {
|
||||
client *http.Client
|
||||
}
|
||||
|
||||
var signKeyList = []string{"acl", "uploads", "location", "cors", "logging", "website", "referer", "lifecycle", "delete", "append", "tagging", "objectMeta", "uploadId", "partNumber", "security-token", "position", "img", "style", "styleName", "replication", "replicationProgress", "replicationLocation", "cname", "bucketInfo", "comp", "qos", "live", "status", "vod", "startTime", "endTime", "symlink", "x-oss-process", "response-content-type", "response-content-language", "response-expires", "response-cache-control", "response-content-disposition", "response-content-encoding", "udf", "udfName", "udfImage", "udfId", "udfImageDesc", "udfApplication", "comp", "udfApplicationLog", "restore"}
|
||||
var signKeyList = []string{"acl", "uploads", "location", "cors", "logging", "website", "referer", "lifecycle", "delete", "append", "tagging", "objectMeta", "uploadId", "partNumber", "security-token", "position", "img", "style", "styleName", "replication", "replicationProgress", "replicationLocation", "cname", "bucketInfo", "comp", "qos", "live", "status", "vod", "startTime", "endTime", "symlink", "x-oss-process", "response-content-type", "response-content-language", "response-expires", "response-cache-control", "response-content-disposition", "response-content-encoding", "udf", "udfName", "udfImage", "udfId", "udfImageDesc", "udfApplication", "comp", "udfApplicationLog", "restore", "callback", "callback-var"}
|
||||
|
||||
// init initializes Conn
|
||||
func (conn *Conn) init(config *Config, urlMaker *urlMaker) error {
|
||||
@@ -440,6 +441,14 @@ func xmlUnmarshal(body io.Reader, v interface{}) error {
|
||||
return xml.Unmarshal(data, v)
|
||||
}
|
||||
|
||||
func jsonUnmarshal(body io.Reader, v interface{}) error {
|
||||
data, err := ioutil.ReadAll(body)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return json.Unmarshal(data, v)
|
||||
}
|
||||
|
||||
// timeoutConn handles HTTP timeout
|
||||
type timeoutConn struct {
|
||||
conn net.Conn
|
||||
@@ -524,7 +533,11 @@ func (um *urlMaker) Init(endpoint string, isCname bool, isProxy bool) {
|
||||
host, _, err := net.SplitHostPort(um.NetLoc)
|
||||
if err != nil {
|
||||
host = um.NetLoc
|
||||
if host[0] == '[' && host[len(host)-1] == ']' {
|
||||
host = host[1 : len(host)-1]
|
||||
}
|
||||
}
|
||||
|
||||
ip := net.ParseIP(host)
|
||||
if ip != nil {
|
||||
um.Type = urlTypeIP
|
||||
@@ -587,7 +600,7 @@ func (um urlMaker) buildURL(bucket, object string) (string, string) {
|
||||
return host, path
|
||||
}
|
||||
|
||||
// getResource gets canonicalized resource
|
||||
// getResource gets canonicalized resource
|
||||
func (um urlMaker) getResource(bucketName, objectName, subResource string) string {
|
||||
if subResource != "" {
|
||||
subResource = "?" + subResource
|
||||
|
||||
11
vendor/github.com/aliyun/aliyun-oss-go-sdk/oss/const.go
generated
vendored
11
vendor/github.com/aliyun/aliyun-oss-go-sdk/oss/const.go
generated
vendored
@@ -106,6 +106,9 @@ const (
|
||||
HTTPHeaderOssRequestID = "X-Oss-Request-Id"
|
||||
HTTPHeaderOssCRC64 = "X-Oss-Hash-Crc64ecma"
|
||||
HTTPHeaderOssSymlinkTarget = "X-Oss-Symlink-Target"
|
||||
HTTPHeaderOssStorageClass = "X-Oss-Storage-Class"
|
||||
HTTPHeaderOssCallback = "X-Oss-Callback"
|
||||
HTTPHeaderOssCallbackVar = "X-Oss-Callback-Var"
|
||||
)
|
||||
|
||||
// HTTP Param
|
||||
@@ -123,10 +126,10 @@ const (
|
||||
|
||||
FilePermMode = os.FileMode(0664) // Default file permission
|
||||
|
||||
TempFilePrefix = "oss-go-temp-" // Temp file prefix
|
||||
TempFileSuffix = ".temp" // Temp file suffix
|
||||
TempFilePrefix = "oss-go-temp-" // Temp file prefix
|
||||
TempFileSuffix = ".temp" // Temp file suffix
|
||||
|
||||
CheckpointFileSuffix = ".cp" // Checkpoint file suffix
|
||||
CheckpointFileSuffix = ".cp" // Checkpoint file suffix
|
||||
|
||||
Version = "1.9.0" // Go SDK version
|
||||
Version = "1.9.1" // Go SDK version
|
||||
)
|
||||
|
||||
8
vendor/github.com/aliyun/aliyun-oss-go-sdk/oss/model.go
generated
vendored
8
vendor/github.com/aliyun/aliyun-oss-go-sdk/oss/model.go
generated
vendored
@@ -15,6 +15,14 @@ type Response struct {
|
||||
ServerCRC uint64
|
||||
}
|
||||
|
||||
func (r *Response) Read(p []byte) (n int, err error) {
|
||||
return r.Body.Read(p)
|
||||
}
|
||||
|
||||
func (r *Response) Close() error {
|
||||
return r.Body.Close()
|
||||
}
|
||||
|
||||
// PutObjectRequest is the request of DoPutObject
|
||||
type PutObjectRequest struct {
|
||||
ObjectKey string
|
||||
|
||||
18
vendor/github.com/aliyun/aliyun-oss-go-sdk/oss/multipart.go
generated
vendored
18
vendor/github.com/aliyun/aliyun-oss-go-sdk/oss/multipart.go
generated
vendored
@@ -5,6 +5,7 @@ import (
|
||||
"encoding/xml"
|
||||
"io"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"os"
|
||||
"sort"
|
||||
"strconv"
|
||||
@@ -13,7 +14,7 @@ import (
|
||||
// InitiateMultipartUpload initializes multipart upload
|
||||
//
|
||||
// objectKey object name
|
||||
// options the object constricts for upload. The valid options are CacheControl, ContentDisposition, ContentEncoding, Expires,
|
||||
// options the object constricts for upload. The valid options are CacheControl, ContentDisposition, ContentEncoding, Expires,
|
||||
// ServerSideEncryption, Meta, check out the following link:
|
||||
// https://help.aliyun.com/document_detail/oss/api-reference/multipart-upload/InitiateMultipartUpload.html
|
||||
//
|
||||
@@ -151,7 +152,7 @@ func (bucket Bucket) UploadPartCopy(imur InitiateMultipartUploadResult, srcBucke
|
||||
var out UploadPartCopyResult
|
||||
var part UploadPart
|
||||
|
||||
opts := []Option{CopySource(srcBucketName, srcObjectKey),
|
||||
opts := []Option{CopySource(srcBucketName, url.QueryEscape(srcObjectKey)),
|
||||
CopySourceRange(startPosition, partSize)}
|
||||
opts = append(opts, options...)
|
||||
params := map[string]interface{}{}
|
||||
@@ -231,9 +232,16 @@ func (bucket Bucket) AbortMultipartUpload(imur InitiateMultipartUploadResult) er
|
||||
// ListUploadedPartsResponse the return value if it succeeds, only valid when error is nil.
|
||||
// error it's nil if the operation succeeds, otherwise it's an error object.
|
||||
//
|
||||
func (bucket Bucket) ListUploadedParts(imur InitiateMultipartUploadResult) (ListUploadedPartsResult, error) {
|
||||
func (bucket Bucket) ListUploadedParts(imur InitiateMultipartUploadResult, options ...Option) (ListUploadedPartsResult, error) {
|
||||
var out ListUploadedPartsResult
|
||||
options = append(options, EncodingType("url"))
|
||||
|
||||
params := map[string]interface{}{}
|
||||
params, err := getRawParams(options)
|
||||
if err != nil {
|
||||
return out, err
|
||||
}
|
||||
|
||||
params["uploadId"] = imur.UploadID
|
||||
resp, err := bucket.do("GET", imur.Key, params, nil, nil, nil)
|
||||
if err != nil {
|
||||
@@ -242,6 +250,10 @@ func (bucket Bucket) ListUploadedParts(imur InitiateMultipartUploadResult) (List
|
||||
defer resp.Body.Close()
|
||||
|
||||
err = xmlUnmarshal(resp.Body, &out)
|
||||
if err != nil {
|
||||
return out, err
|
||||
}
|
||||
err = decodeListUploadedPartsResult(&out)
|
||||
return out, err
|
||||
}
|
||||
|
||||
|
||||
30
vendor/github.com/aliyun/aliyun-oss-go-sdk/oss/option.go
generated
vendored
30
vendor/github.com/aliyun/aliyun-oss-go-sdk/oss/option.go
generated
vendored
@@ -172,6 +172,21 @@ func Origin(value string) Option {
|
||||
return setHeader(HTTPHeaderOrigin, value)
|
||||
}
|
||||
|
||||
// ObjectStorageClass is an option to set the storage class of object
|
||||
func ObjectStorageClass(storageClass StorageClassType) Option {
|
||||
return setHeader(HTTPHeaderOssStorageClass, string(storageClass))
|
||||
}
|
||||
|
||||
// Callback is an option to set callback values
|
||||
func Callback(callback string) Option {
|
||||
return setHeader(HTTPHeaderOssCallback, callback)
|
||||
}
|
||||
|
||||
// CallbackVar is an option to set callback user defined values
|
||||
func CallbackVar(callbackVar string) Option {
|
||||
return setHeader(HTTPHeaderOssCallbackVar, callbackVar)
|
||||
}
|
||||
|
||||
// Delimiter is an option to set delimiler parameter
|
||||
func Delimiter(value string) Option {
|
||||
return addParam("delimiter", value)
|
||||
@@ -212,6 +227,16 @@ func UploadIDMarker(value string) Option {
|
||||
return addParam("upload-id-marker", value)
|
||||
}
|
||||
|
||||
// MaxParts is an option to set max-parts parameter
|
||||
func MaxParts(value int) Option {
|
||||
return addParam("max-parts", strconv.Itoa(value))
|
||||
}
|
||||
|
||||
// PartNumberMarker is an option to set part-number-marker parameter
|
||||
func PartNumberMarker(value int) Option {
|
||||
return addParam("part-number-marker", strconv.Itoa(value))
|
||||
}
|
||||
|
||||
// DeleteObjectsQuiet false:DeleteObjects in verbose mode; true:DeleteObjects in quite mode. Default is false.
|
||||
func DeleteObjectsQuiet(isQuiet bool) Option {
|
||||
return addArg(deleteObjectsQuiet, isQuiet)
|
||||
@@ -278,10 +303,11 @@ func ResponseContentEncoding(value string) Option {
|
||||
return addParam("response-content-encoding", value)
|
||||
}
|
||||
|
||||
// Process is an option to set X-Oss-Process param
|
||||
// Process is an option to set x-oss-process param
|
||||
func Process(value string) Option {
|
||||
return addParam("X-Oss-Process", value)
|
||||
return addParam("x-oss-process", value)
|
||||
}
|
||||
|
||||
func setHeader(key string, value interface{}) Option {
|
||||
return func(params map[string]optionValue) error {
|
||||
if value == nil {
|
||||
|
||||
9
vendor/github.com/aliyun/aliyun-oss-go-sdk/oss/progress.go
generated
vendored
9
vendor/github.com/aliyun/aliyun-oss-go-sdk/oss/progress.go
generated
vendored
@@ -62,7 +62,7 @@ type teeReader struct {
|
||||
// corresponding writes to w. There is no internal buffering -
|
||||
// the write must complete before the read completes.
|
||||
// Any error encountered while writing is reported as a read error.
|
||||
func TeeReader(reader io.Reader, writer io.Writer, totalBytes int64, listener ProgressListener, tracker *readerTracker) io.Reader {
|
||||
func TeeReader(reader io.Reader, writer io.Writer, totalBytes int64, listener ProgressListener, tracker *readerTracker) io.ReadCloser {
|
||||
return &teeReader{
|
||||
reader: reader,
|
||||
writer: writer,
|
||||
@@ -103,3 +103,10 @@ func (t *teeReader) Read(p []byte) (n int, err error) {
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func (t *teeReader) Close() error {
|
||||
if rc, ok := t.reader.(io.ReadCloser); ok {
|
||||
return rc.Close()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
18
vendor/github.com/aliyun/aliyun-oss-go-sdk/oss/type.go
generated
vendored
18
vendor/github.com/aliyun/aliyun-oss-go-sdk/oss/type.go
generated
vendored
@@ -363,6 +363,14 @@ type UncompletedUpload struct {
|
||||
Initiated time.Time `xml:"Initiated"` // Initialization time in the format such as 2012-02-23T04:18:23.000Z
|
||||
}
|
||||
|
||||
// ProcessObjectResult defines result object of ProcessObject
|
||||
type ProcessObjectResult struct {
|
||||
Bucket string `json:"bucket"`
|
||||
FileSize int `json:"fileSize"`
|
||||
Object string `json:"object"`
|
||||
Status string `json:"status"`
|
||||
}
|
||||
|
||||
// decodeDeleteObjectsResult decodes deleting objects result in URL encoding
|
||||
func decodeDeleteObjectsResult(result *DeleteObjectsResult) error {
|
||||
var err error
|
||||
@@ -409,6 +417,16 @@ func decodeListObjectsResult(result *ListObjectsResult) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// decodeListUploadedPartsResult decodes
|
||||
func decodeListUploadedPartsResult(result *ListUploadedPartsResult) error {
|
||||
var err error
|
||||
result.Key, err = url.QueryUnescape(result.Key)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// decodeListMultipartUploadResult decodes list multipart upload result in URL encoding
|
||||
func decodeListMultipartUploadResult(result *ListMultipartUploadResult) error {
|
||||
var err error
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user