diff --git a/Gopkg.lock b/Gopkg.lock index 9d026377..a74cb4df 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -21,15 +21,15 @@ version = "v1.4.2" [[projects]] - digest = "1:26b14a6dc72ace253599e969997d5ecf2143c63833c015179786bc756c76eaa4" + digest = "1:2be791e7b333ff7c06f8fb3dc18a7d70580e9399dbdffd352621d067ff260b6e" name = "github.com/Microsoft/go-winio" packages = ["."] pruneopts = "NUT" - revision = "97e4973ce50b2ff5f09635a57e2b88a037aae829" - version = "v0.4.11" + revision = "1a8911d1ed007260465c3bfbbc785ac6915a0bb8" + version = "v0.4.12" [[projects]] - digest = "1:51c7734aae4502a76644c6eed2a4b68f98406e263468789f26512810095a43fa" + digest = "1:a8e16b4caf3575365c9aa3380d9418f31dd0b810596faebfe3a15c37fabeee4a" name = "github.com/Microsoft/hcsshim" packages = [ ".", @@ -49,8 +49,8 @@ "internal/wclayer", ] pruneopts = "NUT" - revision = "79a8f772c4265236cf9da6af7f766b5caf2afb80" - version = "v0.8.4" + revision = "f92b8fb9c92e17da496af5a69e3ee13fbe9916e1" + version = "v0.8.6" [[projects]] branch = "master" @@ -72,15 +72,15 @@ revision = "5312a61534124124185d41f09206b9fef1d88403" [[projects]] - branch = "master" digest = "1:707ebe952a8b3d00b343c01536c79c73771d100f63ec6babeaed5c79e2b8a8dd" name = "github.com/beorn7/perks" packages = ["quantile"] pruneopts = "NUT" - revision = "3a771d992973f24aa725d07868b467d1ddfceafb" + revision = "4b2b341e8d7715fae06375aa633dbb6e91b3fb46" + version = "v1.0.0" [[projects]] - digest = "1:aaf95e919b44127f05cc1d3159f1b7b29d2cfdec597fa32dcfd0de7382031146" + digest = "1:d528dfb94faa77c3a046c4f752f78a955cedb226a89e30f40762d56d2099aced" name = "github.com/containerd/containerd" packages = [ ".", @@ -132,12 +132,11 @@ "sys", ] pruneopts = "NUT" - revision = "9754871865f7fe2f4e74d43e2fc7ccd237edcbce" - version = "v1.2.2" + revision = "7f5f1176dd9fb3cc8d3ce5de91759ed3dc969fa2" [[projects]] branch = "master" - digest = "1:4a940afce0fedb15226cd903bdd7207cb66a5c3b120a143ce309a2833bc09568" + digest = "1:835fc727705e8cf858ea44ad9bd872ff826d1c6b019598e0f9a64c9b942a947b" name = "github.com/containerd/continuity" packages = [ "fs", @@ -146,10 +145,10 @@ "sysx", ] pruneopts = "NUT" - revision = "bd77b46c8352f74eb12c85bdc01f4b90f69d66b4" + revision = "aaeac12a7ffcd198ae25440a9dff125c2e2703a7" [[projects]] - digest = "1:393d96d76afa9703cc64a43ca2b27c1e32a9be64fed9546a120a5e188b53a193" + digest = "1:a72272dfefbb22c87cda3dbefbb256741d861d2fb727210a66e0df0df6084b30" name = "github.com/containerd/cri" packages = ["pkg/util"] pruneopts = "NUT" @@ -158,19 +157,19 @@ [[projects]] branch = "master" - digest = "1:dd731323a802a9d3e8f037a4531c4e8a9ab417a8e97a3a7e7ff2214e2a8b6248" + digest = "1:c34ee53dc499450d386058a6cf7cc979a48724ac83b3fcb14a981abdfc2781b7" name = "github.com/containerd/fifo" packages = ["."] pruneopts = "NUT" - revision = "650d792183512bf92167787990b8f08a9175b3df" + revision = "a9fb20d87448d386e6d50b1f2e1fa70dcf0de43c" [[projects]] branch = "master" - digest = "1:07ac073876dbf7df80789ba4c2959a969200b34875a34fc13848f76d60b51551" + digest = "1:1acf9ab006ee65a15a0113a3a2efbf615458239e6521603596d34da1278655b2" name = "github.com/containerd/typeurl" packages = ["."] pruneopts = "NUT" - revision = "461401dc8f19d80baa4b70178935e4501286c00b" + revision = "b36cf1e3e273911c075b63799169eae96cc17222" [[projects]] digest = "1:ffe9824d294da03b391f44e1ae8281281b4afc1bdaa9588c9097785e3af10cec" @@ -181,15 +180,23 @@ version = "v1.1.1" [[projects]] - branch = "master" - digest = "1:8cd271f26db91626bd5993ed540069dbade9f6149134e7f8a0ed951cbbf4f2ec" + branch = "add-duffle-types" + digest = "1:26492e179ef4aebabd64482e08144f77273a817f0ad865021d4c7172d78c9892" name = "github.com/deislabs/cnab-go" - packages = ["bundle"] + packages = [ + "action", + "bundle", + "claim", + "credentials", + "driver", + "utils/crud", + ] pruneopts = "NUT" - revision = "7cd944a8ee450ee465795d21ad7302bed34ad1b0" + revision = "9cd2d85086f9a1e31ac1c59e6ec4f6bb36c2f980" + source = "github.com/radu-matei/cnab-go" [[projects]] - digest = "1:43d1a6ccaa7b9e319dbff50d89e744db06ae63af20aae1d0f4fb743fa525ce97" + digest = "1:e71d64468873ca819b91b975e67e71f349a89f41ab38040bcbd8840f5e193654" name = "github.com/docker/cli" packages = [ "cli", @@ -221,7 +228,7 @@ revision = "f95ca8e1ba6c22c9abcdbf65e8dcc39c53958bba" [[projects]] - digest = "1:54b22de865db36f1ffaf2bb4de6cc6c39148cae03c13c58758f2af5a74466d4f" + digest = "1:a828cce5747a0ac32a41fd9644660a815cbc3c61caa85c03b0a651d62320aa0b" name = "github.com/docker/compose-on-kubernetes" packages = [ "api", @@ -231,11 +238,10 @@ "api/compose/v1beta2", ] pruneopts = "NUT" - revision = "55bc84aade4e505b2772623c5739b49baf0f9269" - version = "v0.4.18" + revision = "a6086e2369e39c2058a003a7eb42e567ecfd1f03" [[projects]] - digest = "1:79f22d913ffae103c0ee94bb2ea0c6ddd52239b442501a935be3da935f44a237" + digest = "1:c2fd3505322eed56c220992927a13029d32b7fea0e9cc1ece7a2217369d76914" name = "github.com/docker/distribution" packages = [ ".", @@ -259,7 +265,7 @@ revision = "83389a148052d74ac602f5f1d62f86ff2f3c4aa5" [[projects]] - digest = "1:ac3d0158a1eb7e6508eac6ce7ff6fba0cadde0f48b5a17949dd2e221c94a2fd6" + digest = "1:6e8fe686e68797b78d54d112f816448cf5d4bbf33c24c2cd12da0508ec600dc8" name = "github.com/docker/docker" packages = [ "api", @@ -308,15 +314,15 @@ revision = "f76d6a078d881f410c00e8d900dcdfc2e026c841" [[projects]] - digest = "1:15e7be8bdfcc1ea804cedc8e3187605c58642cddd1d333781b888e4873c1ed5b" + digest = "1:3d35be2858b1ef8365c4ca66af373602137159cf708e51f91db89c04347501f2" name = "github.com/docker/docker-credential-helpers" packages = [ "client", "credentials", ] pruneopts = "NUT" - revision = "5241b46610f2491efdf9d1c85f1ddf5b02f6d962" - version = "v0.6.1" + revision = "8a9f93a99ff87f416cc79f267c68151af0026f60" + version = "v0.6.2" [[projects]] digest = "1:44fd27d0559326eb63ee0b7b5c80832c821761ff6d1b9cc4ad075783485a5837" @@ -327,7 +333,7 @@ version = "v1.5.1-1" [[projects]] - digest = "1:d131afebb270bf014e49fcdff0da3e861124976b7c1402181fac5196a57f3b31" + digest = "1:2a47f7eb1a2c30428d1ee6808cb66d4deb17e68a3e55d696f03c8068552ba5e8" name = "github.com/docker/go-connections" packages = [ "nat", @@ -347,19 +353,19 @@ revision = "9461782956ad83b30282bf90e31fa6a70c255ba9" [[projects]] - digest = "1:f46b7a16ee90fa98b687ffa27fdca5af8ce8947562307e4318a7e0598005be55" + digest = "1:d297c0c975275874c6b891a799fe0b3a6bc874134f7972fecad9590fcad38975" name = "github.com/docker/go-metrics" packages = ["."] pruneopts = "NUT" - revision = "d466d4f6fd960e01820085bd7e1a24426ee7ef18" + revision = "db152003892af64a8a892e1ee49edf8b6580a657" [[projects]] - digest = "1:4340101f42556a9cb2f7a360a0e95a019bfef6247d92e6c4c46f2433cf86a482" + digest = "1:97176fe8a268479a527d08df458c269dc27abf59c1643807d4e36398cbd9ef2d" name = "github.com/docker/go-units" packages = ["."] pruneopts = "NUT" - revision = "47565b4f722fb6ceae66b95f853feed578a4a51c" - version = "v0.3.3" + revision = "519db1ee28dcc9fd2474ae59fca29a810482bfb1" + version = "v0.4.0" [[projects]] digest = "1:1b91ae0dc69a41d4c2ed23ea5cffb721ea63f5037ca4b81e6d6771fbb8f45129" @@ -378,15 +384,15 @@ version = "v1.0.0" [[projects]] - digest = "1:dfd1bfac4ef78bce8efe6c52548baaaba18f634c0101581f4773336c653289c2" + digest = "1:c6f5a29fce208cb102ad1e356d3a3a361be54604549063943613058a377dd0d0" name = "github.com/gogo/googleapis" packages = ["google/rpc"] pruneopts = "NUT" - revision = "8558fb44d2f1fc223118afc694129d2c2d2924d1" - version = "v1.1.0" + revision = "d31c731455cb061f42baff3bda55bad0118b126b" + version = "v1.2.0" [[projects]] - digest = "1:7666507274154769bb45fbe0db36309e026f88ca08377aa28c201ee4c37ae5b2" + digest = "1:35210367ba31312afa1eaf3cf4797c855c6b6a4efe953b90d63abb830ec7fdd6" name = "github.com/gogo/protobuf" packages = [ "proto", @@ -394,8 +400,8 @@ "types", ] pruneopts = "NUT" - revision = "636bf0302bc95575d69441b25a2603156ffdddf1" - version = "v1.1.1" + revision = "ba06b47c162d49f2af050fb4c75bcbc86a159d5c" + version = "v1.2.1" [[projects]] branch = "master" @@ -406,7 +412,7 @@ revision = "23def4e6c14b4da8ac2ed8007337bc5eb5007998" [[projects]] - digest = "1:094772cd3a2a5b9bb621111bfbe964a2fbee790b014a645ea09eb842b1b658c1" + digest = "1:2d0636a8c490d2272dd725db26f74a537111b99b9dbdda0d8b98febe63702aa4" name = "github.com/golang/protobuf" packages = [ "proto", @@ -416,20 +422,19 @@ "ptypes/timestamp", ] pruneopts = "NUT" - revision = "aa810b61a9c79d51363740d207bb46cf8e620ed5" - version = "v1.2.0" + revision = "b5d812f8a3706043e23a9cd5babf2e5423744d30" + version = "v1.3.1" [[projects]] - branch = "master" digest = "1:05f95ffdfcf651bdb0f05b40b69e7f5663047f8da75c72d58728acb59b5cc107" name = "github.com/google/btree" packages = ["."] pruneopts = "NUT" revision = "4030bb1f1f0c35b30ca7009e9ebd06849dd45306" + version = "v1.0.0" [[projects]] - branch = "master" - digest = "1:e56e3dbbe1b106b456ef279639d809c03cace64dc015dbb0646cd27fc1cb2cb0" + digest = "1:2e588e08805f44a6b53d08a47a48b1b7fdb6903076fc8c245f1ec769b28ceb74" name = "github.com/google/go-containerregistry" packages = [ "pkg/authn", @@ -441,22 +446,23 @@ "pkg/v1/random", "pkg/v1/remote", "pkg/v1/remote/transport", + "pkg/v1/stream", "pkg/v1/types", "pkg/v1/v1util", ] pruneopts = "NUT" - revision = "f1df91a4a813cbc183527dc7b9a31ea6454557b5" + revision = "5296537b6d5d12241dd0a8b1ef70a59cba62f48c" [[projects]] - branch = "master" digest = "1:52c5834e2bebac9030c97cc0798ac11c3aa8a39f098aeb419f142533da6cd3cc" name = "github.com/google/gofuzz" packages = ["."] pruneopts = "NUT" - revision = "24818f796faf91cd76ec7bddd72458fbced7a6c1" + revision = "f140a6486e521aad38f5917de355cbf147cc0496" + version = "v1.0.0" [[projects]] - digest = "1:add738701bd5b2b985c0c37011092c57218bdc46caf1e682a73dc210ad36b03f" + digest = "1:06a7dadb7b760767341ffb6c8d377238d68a1226f2b21b5d497d2e3f6ecf6b4e" name = "github.com/googleapis/gnostic" packages = [ "OpenAPIv2", @@ -468,24 +474,16 @@ version = "v0.2.0" [[projects]] - digest = "1:c01767916c59f084bb7c41a7d5877c0f3099b1595cfa066e84ec6ad6b084dd89" - name = "github.com/gorilla/context" - packages = ["."] - pruneopts = "NUT" - revision = "08b5f424b9271eedf6f9f0ce86cb9396ed337a42" - version = "v1.1.1" - -[[projects]] - digest = "1:bf5cf1d53d703332e9bd8984c69784645b73a938317bf5ace9aadf20ac49379a" + digest = "1:f03d1f27dee54a6f51200778991db9b7a91e9d9cc42395ba813fc9efc490a9a2" name = "github.com/gorilla/mux" packages = ["."] pruneopts = "NUT" - revision = "e3702bed27f0d39777b0b37b664b6280e8ef8fbf" - version = "v1.6.2" + revision = "c5c6c98bc25355028a63748a498942a6398ccd22" + version = "v1.7.1" [[projects]] branch = "master" - digest = "1:42df938c96e4a54d2c19da35d6d3f3a6c432dd942a7375343a6bf06e1945ca5b" + digest = "1:2d30806677673203e02f0e36069be246e5fb819337f3e2200a322c1daa66fae3" name = "github.com/gosuri/uitable" packages = [ ".", @@ -497,25 +495,25 @@ [[projects]] branch = "master" - digest = "1:a1db0214936912602a7a8cedc09a2e3211f5c097dc89189fb4b3bc86346c9e89" + digest = "1:a86d65bc23eea505cd9139178e4d889733928fe165c7a008f41eaab039edf9df" name = "github.com/gregjones/httpcache" packages = [ ".", "diskcache", ] pruneopts = "NUT" - revision = "c63ab54fda8f77302f8d414e19933f2b6026a089" + revision = "3befbb6ad0cc97d4c25d851e9528915809e1a22f" [[projects]] - digest = "1:c7d9de42b661ba85788f5f631cbac165795a2ff7dc1c59a4241d6228b129c3e4" + digest = "1:53a4ebb0e1eb24a4644a3eec9457ba6ead5476a9ea5af43bf2c8b8b1a8ce47f2" name = "github.com/hashicorp/go-version" packages = ["."] pruneopts = "NUT" - revision = "d40cf49b3a77bba84a7afdbd7f1dc295d114efb1" - version = "v1.1.0" + revision = "ac23dc3fea5d1a983c43f6a0f6e2c13f0195d8bd" + version = "v1.2.0" [[projects]] - digest = "1:02e4365951e1bc55bd6505938ea88e12b5a9d5dfedcb1ae35d5a3833e502833e" + digest = "1:11c6c696067d3127ecf332b10f89394d386d9083f82baf71f40f2da31841a009" name = "github.com/hashicorp/hcl" packages = [ ".", @@ -550,12 +548,12 @@ version = "v1.0" [[projects]] - digest = "1:8e36686e8b139f8fe240c1d5cf3a145bc675c22ff8e707857cdd3ae17b00d728" + digest = "1:4e903242fe176238aaa469f59d7035f5abf2aa9acfefb8964ddd203651b574e9" name = "github.com/json-iterator/go" packages = ["."] pruneopts = "NUT" - revision = "1624edc4454b8682399def8740d46db5e4362ba4" - version = "v1.1.5" + revision = "0ff49de124c6f76f8494e194af75bde0f1a49a29" + version = "v1.1.6" [[projects]] branch = "master" @@ -566,12 +564,12 @@ revision = "95032a82bc518f77982ea72343cc1ade730072f0" [[projects]] - branch = "master" - digest = "1:c8a452cc8dd4ef9f857570ce2be31ca257a0928bf3c2b08cd7e11972b985c6d7" + digest = "1:58999a98719fddbac6303cb17e8d85b945f60b72f48e3a2df6b950b97fa926f1" name = "github.com/konsorten/go-windows-terminal-sequences" packages = ["."] pruneopts = "NUT" - revision = "b729f2633dfe35f4d1d8a32385f6685610ce1cb5" + revision = "f55edac94c9bbba5d6182a4be46d86a2c9b5b50e" + version = "v1.0.2" [[projects]] digest = "1:d244f8666a838fe6ad70ec8fe77f50ebc29fdc3331a2729ba5886bef8435d10d" @@ -582,28 +580,28 @@ version = "v1.8.0" [[projects]] - digest = "1:08c231ec84231a7e23d67e4b58f975e1423695a32467a362ee55a803f9de8061" + digest = "1:9785a54031460a402fab4e4bbb3124c8dd9e9f7b1982109fef605cb91632d480" name = "github.com/mattn/go-colorable" packages = ["."] pruneopts = "NUT" - revision = "167de6bfdfba052fa6b2d3664c8f5272e23c9072" - version = "v0.0.9" + revision = "3a70a971f94a22f2fa562ffcc7a0eb45f5daf045" + version = "v0.1.1" [[projects]] - digest = "1:bffa444ca07c69c599ae5876bc18b25bfd5fa85b297ca10a25594d284a7e9c5d" + digest = "1:85edcc76fa95b8b312642905b56284f4fe5c42d8becb219481adba7e97d4f5c5" name = "github.com/mattn/go-isatty" packages = ["."] pruneopts = "NUT" - revision = "6ca4dbf54d38eea1a992b3c722a76a5d1c4cb25c" - version = "v0.0.4" + revision = "c2a7a6ca930a4cd0bc33a3f298eb71960732a3a7" + version = "v0.0.7" [[projects]] - digest = "1:bff482b22ebed387378546ba6a7850fdef87fd47f8ee58a7c62124a8e889a56b" + digest = "1:70ef8268170621826f8c111ac1674afe75136f526f449453b4a6631c6dba1946" name = "github.com/mattn/go-runewidth" packages = ["."] pruneopts = "NUT" - revision = "ce7b0b5c7b45a81508558cd1dba6bb1e4ddb51bb" - version = "v0.0.3" + revision = "3ee7d812e62a0804a7d0a324e0249ca2db3476d3" + version = "v0.0.4" [[projects]] digest = "1:5985ef4caf91ece5d54817c11ea25f182697534f8ae6521eadcd628c142ac4b6" @@ -622,20 +620,20 @@ revision = "9520e82c474b0a04dd04f8a40959027271bab992" [[projects]] - branch = "master" - digest = "1:a42e6b3cf686e9ce1b3251e56614b9a188ba1f1aeb4178b91006f30f89dfa08d" + digest = "1:8173712f82b2da5dd36cdcbaa658f57fa8509634e5ecccbcfb948ecee051b0de" name = "github.com/miekg/pkcs11" packages = ["."] pruneopts = "NUT" - revision = "904a660e90be06218dab18cce44561bca248680d" + revision = "cb39313ec884f2cd77f4762875fe96aecf68f8e3" + version = "v1.0.2" [[projects]] - digest = "1:7ab17345d3ff52cee65e3f0494b5a53976955b090b8a99f93cb65f3d3322b2df" + digest = "1:a45ae66dea4c899d79fceb116accfa1892105c251f0dcd9a217ddc276b42ec68" name = "github.com/mitchellh/mapstructure" packages = ["."] pruneopts = "NUT" - revision = "fe40af7a9c397fa3ddba203c38a5042c5d0475ad" - version = "v1.1.1" + revision = "3536a929edddb9a5b34bd6861dc4a9647cb459fe" + version = "v1.1.2" [[projects]] digest = "1:2f42fa12d6911c7b7659738758631bec870b7e9b4c6be5444f963cdcfccc191f" @@ -654,12 +652,12 @@ version = "1.0.1" [[projects]] - digest = "1:8de645979b0fd0d565f882b5d07f9f89c23726105d22dc5e0419c4e0e185c367" + digest = "1:f2052f4354e87a0ce0b16b55586b8d34d502d164d56d5d4397afae37f3330c42" name = "github.com/oklog/ulid" packages = ["."] pruneopts = "NUT" - revision = "636e42066873d476ff697be5854f8a4bcfe33769" - version = "v1.3.0" + revision = "be3bccf06dda9a40aa6800c4736ac77f2fef987f" + version = "v2.0.2" [[projects]] digest = "1:e0cc8395ea893c898ff5eb0850f4d9851c1f57c78c232304a026379a47a552d0" @@ -670,7 +668,7 @@ version = "v1.0.0-rc1" [[projects]] - digest = "1:be059bd8249ad99021a870bf6ecd3da2e72107eeb1891e2ef2a3d350b1e00b35" + digest = "1:70711188c19c53147099d106169d6a81941ed5c2658651432de564a7d60fd288" name = "github.com/opencontainers/image-spec" packages = [ "identity", @@ -682,7 +680,7 @@ version = "v1.0.1" [[projects]] - digest = "1:c5a5a1953c1f70bab6e3e82880af4f8752aeace36a37612e4b718403e43ace1b" + digest = "1:ea8780346eba74e5eb3e8b6bded2ec46c1c81cd745bc00e9964b730955bf4252" name = "github.com/opencontainers/runc" packages = [ "libcontainer/system", @@ -701,12 +699,12 @@ version = "v1.0.1" [[projects]] - digest = "1:51ea800cff51752ff68e12e04106f5887b4daec6f9356721238c28019f0b42db" + digest = "1:4e9827f31d4fc1ddd732a0e3af4e863d281dd405adb2bfb96a25cc5346a77caf" name = "github.com/pelletier/go-toml" packages = ["."] pruneopts = "NUT" - revision = "c01d1270ff3e442a8a57cddc1c92dc1138598194" - version = "v1.2.0" + revision = "728039f679cbcd4f6a54e080d2219a4c4928c546" + version = "v1.4.0" [[projects]] branch = "master" @@ -717,16 +715,15 @@ revision = "53be0d36a84c2a886ca057d34b6aa4468df9ccb4" [[projects]] - digest = "1:6c6d91dc326ed6778783cff869c49fb2f61303cdd2ebbcf90abe53505793f3b6" + digest = "1:e1b94bd98c62fc2f905621fc6ba8209b7004e4513a1dfecb12a3de56ec2bb519" name = "github.com/peterbourgon/diskv" packages = ["."] pruneopts = "NUT" - revision = "5f041e8faa004a95c88a202771f4cc3e991971e6" - version = "v2.0.1" + revision = "0be1b92a6df0e4f5cb0a5d15fb7f643d0ad93ce6" + version = "v3.0.0" [[projects]] - branch = "master" - digest = "1:1c5a18736f0071a05ff992f89516ba037020643c932ed5c4ed144f63dcc02ab0" + digest = "1:f47d5892e50c2937477813f188fba877953faa98e2846497f842211ae3b52670" name = "github.com/pivotal/image-relocation" packages = [ "pkg/image", @@ -737,12 +734,12 @@ revision = "532dd0b42e7a50010d7868364309cd314a2bb376" [[projects]] - digest = "1:5cf3f025cbee5951a4ee961de067c8a89fc95a5adabead774f82822efabab121" + digest = "1:14715f705ff5dfe0ffd6571d7d201dd8e921030f8070321a79380d8ca4ec1a24" name = "github.com/pkg/errors" packages = ["."] pruneopts = "NUT" - revision = "645ef00459ed84a119197bfb8d8205042c6df63d" - version = "v0.8.0" + revision = "ba968bfe8b2f7e042a574c888954fccecfa385b4" + version = "v0.8.1" [[projects]] digest = "1:0028cb19b2e4c3112225cd871870f2d9cf49b9b4276531f03438a88e94be86fe" @@ -753,24 +750,26 @@ version = "v1.0.0" [[projects]] - digest = "1:3e5fd795ebf6a9e13e67d644da76130af7a6003286531f9573f8074c228b66a3" + digest = "1:00e5485f002096d8284d57ce59acb8e08121a5accdf92777ca7368bf9e5e18e8" name = "github.com/prometheus/client_golang" - packages = ["prometheus"] + packages = [ + "prometheus", + "prometheus/internal", + ] pruneopts = "NUT" - revision = "c5b7fccd204277076155f10851dad72b76a49317" - version = "v0.8.0" + revision = "505eaef017263e299324067d40ca2c48f6a2cf50" + version = "v0.9.2" [[projects]] branch = "master" - digest = "1:0f37e09b3e92aaeda5991581311f8dbf38944b36a3edec61cc2d1991f527554a" + digest = "1:2d5cd61daa5565187e1d96bae64dbbc6080dacf741448e9629c64fd93203b0d4" name = "github.com/prometheus/client_model" packages = ["go"] pruneopts = "NUT" - revision = "5c3871d89910bfb32f5fcab2aa4b9ec68e65a99f" + revision = "fd36f4220a901265f90734c3183c5f0c91daa0b8" [[projects]] - branch = "master" - digest = "1:edddf4ceb3a45778dfbb9364f128fffd92ea9bd6abd70edf1474f56565832682" + digest = "1:4e776079b966091d3e6e12ed2aaf728bea5cd1175ef88bb654e03adbf5d4f5d3" name = "github.com/prometheus/common" packages = [ "expfmt", @@ -778,50 +777,49 @@ "model", ] pruneopts = "NUT" - revision = "c7de2306084e37d54b8be01f3541a8464345e9a5" + revision = "1ba88736f028e37bc17328369e94a537ae9e0234" + version = "v0.4.0" [[projects]] branch = "master" - digest = "1:c0acd6d63adc573089863ec85a5d23f2a86eb70ebdfd756621c39f3e682b9c2e" + digest = "1:9b4097bdc74d7fd5387493679dba70d2b1c2159af409b31fa72ea97b9f9947a4" name = "github.com/prometheus/procfs" packages = [ ".", - "internal/util", - "nfs", - "xfs", + "internal/fs", ] pruneopts = "NUT" - revision = "418d78d0b9a7b7de3a6bbc8a23def624cc977bb2" + revision = "5867b95ac084bbfee6ea16595c4e05ab009021da" [[projects]] - digest = "1:01252cd79aac70f16cac02a72a1067dd136e0ad6d5b597d0129cf74c739fd8d1" + digest = "1:998e4640c25e00ccb7b2569bf94562283937b8afb3485c0e1a0a05a15330240d" name = "github.com/sirupsen/logrus" packages = ["."] pruneopts = "NUT" - revision = "a67f783a3814b8729bd2dac5780b5f78f8dbd64d" - version = "v1.1.0" + revision = "8bdbc7bcc01dcbb8ec23dc8a28e332258d25251f" + version = "v1.4.1" [[projects]] - digest = "1:a36d61943d51cd4a1d7ecaf6993190527535a57382114ebf6549956b3e4cb612" + digest = "1:6792bb72ea0e7112157d02e4e175cd421b43d004a853f56316a19beca6e0c074" name = "github.com/spf13/afero" packages = [ ".", "mem", ] pruneopts = "NUT" - revision = "d40851caa0d747393da1ffb28f7f9d8b4eeffebd" - version = "v1.1.2" + revision = "588a75ec4f32903aa5e39a2619ba6a4631e28424" + version = "v1.2.2" [[projects]] - digest = "1:3fa7947ca83b98ae553590d993886e845a4bff19b7b007e869c6e0dd3b9da9cd" + digest = "1:c5e6b121ef3d2043505edaf4c80e5a008cec2513dc8804795eb0479d1555bcf7" name = "github.com/spf13/cast" packages = ["."] pruneopts = "NUT" - revision = "8965335b8c7107321228e3e3702cab9832751bac" - version = "v1.2.0" + revision = "8c9545af88b134710ab1cd196795e7f2388358d7" + version = "v1.3.0" [[projects]] - digest = "1:2c3b60fc961b7ddca4336bb7bb39146cb73ea2ad73d4afc6b4ffea05571e712a" + digest = "1:343d44e06621142ab09ae0c76c1799104cdfddd3ffb445d78b1adf8dc3ffaf3d" name = "github.com/spf13/cobra" packages = ["."] pruneopts = "NUT" @@ -829,36 +827,36 @@ version = "v0.0.3" [[projects]] - digest = "1:f29f83301ed096daed24a90f4af591b7560cb14b9cc3e1827abbf04db7269ab5" + digest = "1:3d72352adb74e79d6d5a43d6f51bfd2d0bd0c9b5f3c00cf5a4b1636d8d3b9d92" name = "github.com/spf13/jwalterweatherman" packages = ["."] pruneopts = "NUT" - revision = "4a4406e478ca629068e7768fc33f3f044173c0a6" - version = "v1.0.0" + revision = "94f6ae3ed3bceceafa716478c5fbf8d29ca601a1" + version = "v1.1.0" [[projects]] - digest = "1:e3707aeaccd2adc89eba6c062fec72116fe1fc1ba71097da85b4d8ae1668a675" + digest = "1:9d8420bbf131d1618bde6530af37c3799340d3762cc47210c1d9532a4c3a2779" name = "github.com/spf13/pflag" packages = ["."] pruneopts = "NUT" - revision = "9a97c102cda95a86cec2345a6f09f55a939babf5" - version = "v1.0.2" + revision = "298182f68c66c05229eb03ac171abe6e309ee79a" + version = "v1.0.3" [[projects]] - digest = "1:9caed8c7c05e8927f5bc6eec5698119b2b63a7cf304effc6c9b818bc864a10d3" + digest = "1:60c6a70caa4381d3bb6c0211b634e1d5288b01dff882501353bf328fde40b375" name = "github.com/spf13/viper" packages = ["."] pruneopts = "NUT" - revision = "2c12c60302a5a0e62ee102ca9bc996277c2f64f5" - version = "v1.2.1" + revision = "9e56dacc08fbbf8c9ee2dbc717553c758ce42bc9" + version = "v1.3.2" [[projects]] - digest = "1:bacb8b590716ab7c33f2277240972c9582d389593ee8d66fc10074e0508b8126" + digest = "1:42e8c2456d7ec0f31e182c20022e74324c4da2cb3bd9069ff9b131fe33466308" name = "github.com/stretchr/testify" packages = ["assert"] pruneopts = "NUT" - revision = "f35b8ab0b5a2cef36673838d662e249dd9c94686" - version = "v1.2.2" + revision = "ffdc059bfe9ce6a4e144ba849dbedead332c6053" + version = "v1.3.0" [[projects]] branch = "master" @@ -877,7 +875,7 @@ version = "0.2.0" [[projects]] - digest = "1:91e0f8f0d700349de5a6a77910e37bb54002c77d35850930f766ec9a8ac335bb" + digest = "1:5657d02714d03999f98887942ca12e7d0492676d4485966a5a7819b84887790f" name = "github.com/theupdateframework/notary" packages = [ ".", @@ -901,18 +899,18 @@ [[projects]] branch = "master" - digest = "1:53078c9e741e588d7cbf480c07c7b5099b3099a607f6c4b5ba3ac7821af9a267" + digest = "1:35ce874cf16f78a2da908ab28b0277497e36603d289db00d39da5200bc8ace08" name = "golang.org/x/crypto" packages = [ "pbkdf2", "ssh/terminal", ] pruneopts = "NUT" - revision = "5295e8364332db77d75fce11f1d19c053919a9c9" + revision = "e1dfcc566284e143ba8f9afbb3fa563f2a0d212b" [[projects]] branch = "master" - digest = "1:7b5d2581000653d028cc75ed40863c28f2d030f16babd80776d7b48b526b4a1a" + digest = "1:f3ca2335176c6450575b1cb8539474a5650539b614b98243e6a4cfd72357f42d" name = "golang.org/x/net" packages = [ "context", @@ -927,7 +925,7 @@ "trace", ] pruneopts = "NUT" - revision = "4dfa2610cdf3b287375bbba5b8f2a14d3b01d8de" + revision = "a4d6f7feada510cc50e69a37b484cb0fdc6b7876" [[projects]] branch = "master" @@ -935,27 +933,28 @@ name = "golang.org/x/sync" packages = ["errgroup"] pruneopts = "NUT" - revision = "37e7f081c4d4c64e13b10787722085407fe5d15f" + revision = "112230192c580c3556b8cee6403af37a4fc5f28c" [[projects]] - branch = "master" - digest = "1:5ffbacb0c244e2f37080002d0154e28024f1c9350f74d788a70ab741dd858a1f" + digest = "1:0584f6fe1220fd370706fc125a81c594edb2f315af47722cc786dfce4a4dc6e6" name = "golang.org/x/sys" packages = [ "unix", "windows", ] pruneopts = "NUT" - revision = "e4b3c5e9061176387e7cea65e4dc5853801f3fb7" + revision = "f49334f85ddcf0f08d7fb6dd7363e9e6d6b777eb" [[projects]] - digest = "1:a0f29009397dc27c9dc8440f0945d49e5cbb9b72d0b0fc745474d9bfdea2d9f8" + digest = "1:8d8faad6b12a3a4c819a3f9618cb6ee1fa1cfc33253abeeea8b55336721e3405" name = "golang.org/x/text" packages = [ "collate", "collate/build", "internal/colltab", "internal/gen", + "internal/language", + "internal/language/compact", "internal/tag", "internal/triegen", "internal/ucd", @@ -968,27 +967,27 @@ "unicode/rangetable", ] pruneopts = "NUT" - revision = "f21a4dfb5e38f5895301dc265a8def02365cc3d0" - version = "v0.3.0" + revision = "342b2e1fbaa52c93f31447ad2c6abc048c63e475" + version = "v0.3.2" [[projects]] branch = "master" - digest = "1:c9e7a4b4d47c0ed205d257648b0e5b0440880cb728506e318f8ac7cd36270bc4" + digest = "1:9fdc2b55e8e0fafe4b41884091e51e77344f7dc511c5acedcfd98200003bff90" name = "golang.org/x/time" packages = ["rate"] pruneopts = "NUT" - revision = "fbb02b2291d28baffd63558aa44b4b56f178d650" + revision = "9d24e82272b4f38b78bc8cff74fa936d31ccd8ef" [[projects]] branch = "master" - digest = "1:077c1c599507b3b3e9156d17d36e1e61928ee9b53a5b420f10f28ebd4a0b275c" + digest = "1:fc5df4cb84cdf639ef702c176a50a9ee08ea3e68ebd67519c0f4f963c7d82978" name = "google.golang.org/genproto" packages = ["googleapis/rpc/status"] pruneopts = "NUT" - revision = "aa24cbd621fe1e2867110ea8c673d99a1a92efdc" + revision = "b515fa19cec88c32f305a962f34ae60068947aea" [[projects]] - digest = "1:3a3d0f6abdb6ec808baccd7b5ac3b40a6d5eb94f8294ff18a4f50c7ae2c2abc9" + digest = "1:0e2881968b34ee22486956afa001626d375164a627806903e232595c0ba40736" name = "google.golang.org/grpc" packages = [ ".", @@ -1006,6 +1005,7 @@ "health/grpc_health_v1", "internal", "internal/backoff", + "internal/balancerload", "internal/binarylog", "internal/channelz", "internal/envconfig", @@ -1025,11 +1025,11 @@ "tap", ] pruneopts = "NUT" - revision = "a02b0774206b209466313a0b525d2c738fe407eb" - version = "v1.18.0" + revision = "25c4f928eaa6d96443009bd842389fb4fa48664e" + version = "v1.20.1" [[projects]] - digest = "1:5c8fd19f63d241febadd44d4b060faecc2cff31a41e55dd8b719312eabb23b1a" + digest = "1:2cb310632dbcb044521e23f8e6f8ca3f091e51619df8193dc596b5cc373cb604" name = "gopkg.in/AlecAivazis/survey.v1" packages = [ ".", @@ -1037,8 +1037,8 @@ "terminal", ] pruneopts = "NUT" - revision = "0be4439d90f533f1ea2e0adddd5b1a405e6f5559" - version = "v1.6.3" + revision = "7cbcdead7f38aefeda49da82a8ec69910154b154" + version = "v1.8.4" [[projects]] digest = "1:2d1fbdc6777e5408cabeb02bf336305e724b925ff4546ded0fa8715a7267922a" @@ -1049,16 +1049,15 @@ version = "v0.9.1" [[projects]] - digest = "1:7c95b35057a0ff2e19f707173cc1a947fa43a6eb5c4d300d196ece0334046082" + digest = "1:18108594151654e9e696b27b181b953f9a90b16bf14d253dd1b397b025a1487f" name = "gopkg.in/yaml.v2" packages = ["."] pruneopts = "NUT" - revision = "5420a8b6744d3b0345ab293f6fcba19c978f1183" - version = "v2.2.1" + revision = "51d6538a90f86fe93ac480b35f37b2be17fef232" + version = "v2.2.2" [[projects]] - branch = "release-1.11" - digest = "1:be4113d6193256a33770227e4dd9866cef2a2dc47d9be015783fd9898fe946b3" + digest = "1:ef716a2116d8a040e16fbcd7fca71d3354915a94720de6af22c7a09970234296" name = "k8s.io/api" packages = [ "admissionregistration/v1alpha1", @@ -1092,10 +1091,10 @@ "storage/v1beta1", ] pruneopts = "NUT" - revision = "912cbe2bfef3d832db29f9d3125307fe907102e9" + revision = "kubernetes-1.11.2" [[projects]] - digest = "1:ca8ff78a26b50d456fa30a4ebe5791ad7ae6b4849114d118093c50faf9b61b4e" + digest = "1:13a711fa4a9db8c05c1217196f149dc3cbf01ccc2050bf1608ba5ab9e5d7afd3" name = "k8s.io/apimachinery" packages = [ "pkg/api/errors", @@ -1135,10 +1134,10 @@ "third_party/forked/golang/reflect", ] pruneopts = "NUT" - revision = "kubernetes-1.11.5" + revision = "kubernetes-1.11.2" [[projects]] - digest = "1:3410feb3ae6a78ca0e6a0e97e6e9687108b6c3fd74e41e371d4700d40f51c58a" + digest = "1:67aa6c8d98372e4816c5a2e63f7bbc852648b822a087df9d009c82b7ce20e71c" name = "k8s.io/client-go" packages = [ "discovery", @@ -1195,7 +1194,7 @@ "util/integer", ] pruneopts = "NUT" - revision = "kubernetes-1.11.5" + revision = "kubernetes-1.11.2" [[projects]] branch = "master" @@ -1210,7 +1209,12 @@ analyzer-version = 1 input-imports = [ "github.com/Masterminds/semver", + "github.com/deislabs/cnab-go/action", "github.com/deislabs/cnab-go/bundle", + "github.com/deislabs/cnab-go/claim", + "github.com/deislabs/cnab-go/credentials", + "github.com/deislabs/cnab-go/driver", + "github.com/deislabs/cnab-go/utils/crud", "github.com/docker/cli/cli/command", "github.com/docker/cli/cli/command/image/build", "github.com/docker/cli/cli/config", diff --git a/Gopkg.toml b/Gopkg.toml index 1c18036a..7ff0dc23 100644 --- a/Gopkg.toml +++ b/Gopkg.toml @@ -28,7 +28,11 @@ [[override]] name = "github.com/docker/go-metrics" - revision = "d466d4f6fd960e01820085bd7e1a24426ee7ef18" + revision = "db152003892af64a8a892e1ee49edf8b6580a657" + +[[override]] + version = "0.9.0" + name = "github.com/prometheus/client_golang" [[constraint]] name = "github.com/gosuri/uitable" @@ -46,10 +50,52 @@ non-go = true unused-packages = true go-tests = true + [[constraint]] name = "github.com/docker/go" version = "1.5.1-1" [[constraint]] - branch = "master" name = "github.com/pivotal/image-relocation" + revision = "532dd0b42e7a50010d7868364309cd314a2bb376" + +[[override]] + name = "github.com/google/go-containerregistry" + revision = "5296537b6d5d12241dd0a8b1ef70a59cba62f48c" + +[[constraint]] + name = "github.com/deislabs/cnab-go" + source = "github.com/radu-matei/cnab-go" + branch = "add-duffle-types" + +[[override]] + name = "k8s.io/apimachinery" + revision = "kubernetes-1.11.2" + +[[override]] + name = "k8s.io/api" + revision = "kubernetes-1.11.2" + +[[override]] + name = "k8s.io/client-go" + revision = "kubernetes-1.11.2" + +[[override]] + name = "k8s.io/kubernetes" + revision = "kubernetes-1.11.2" + +[[override]] + name = "k8s.io/kube-openapi" + revision = "d8ea2fe547a448256204cfc68dfee7b26c720acb" + +[[override]] + name = "github.com/docker/compose-on-kubernetes" + revision = "a6086e2369e39c2058a003a7eb42e567ecfd1f03" + +[[override]] + name = "github.com/containerd/containerd" + revision = "7f5f1176dd9fb3cc8d3ce5de91759ed3dc969fa2" + +[[override]] + name = "golang.org/x/sys" + revision = "f49334f85ddcf0f08d7fb6dd7363e9e6d6b777eb" diff --git a/cmd/duffle/claims_show.go b/cmd/duffle/claims_show.go index 3f11e894..06b3ce60 100644 --- a/cmd/duffle/claims_show.go +++ b/cmd/duffle/claims_show.go @@ -4,7 +4,7 @@ import ( "encoding/json" "io" - "github.com/deislabs/duffle/pkg/claim" + "github.com/deislabs/cnab-go/claim" "github.com/spf13/cobra" ) diff --git a/cmd/duffle/claims_show_test.go b/cmd/duffle/claims_show_test.go index 96817339..acea44be 100644 --- a/cmd/duffle/claims_show_test.go +++ b/cmd/duffle/claims_show_test.go @@ -5,7 +5,7 @@ import ( "encoding/json" "testing" - "github.com/deislabs/duffle/pkg/claim" + "github.com/deislabs/cnab-go/claim" "github.com/deislabs/cnab-go/bundle" "github.com/stretchr/testify/assert" diff --git a/cmd/duffle/claims_test.go b/cmd/duffle/claims_test.go index d067d4a1..2c5868c0 100644 --- a/cmd/duffle/claims_test.go +++ b/cmd/duffle/claims_test.go @@ -4,7 +4,7 @@ import ( "errors" "testing" - "github.com/deislabs/duffle/pkg/claim" + "github.com/deislabs/cnab-go/claim" "github.com/deislabs/cnab-go/bundle" "github.com/stretchr/testify/assert" diff --git a/cmd/duffle/credential_add.go b/cmd/duffle/credential_add.go index 9ec352e9..1c48c70c 100644 --- a/cmd/duffle/credential_add.go +++ b/cmd/duffle/credential_add.go @@ -8,11 +8,11 @@ import ( "path/filepath" "strings" + "github.com/deislabs/duffle/pkg/duffle/home" + + "github.com/deislabs/cnab-go/credentials" log "github.com/sirupsen/logrus" "github.com/spf13/cobra" - - "github.com/deislabs/duffle/pkg/credentials" - "github.com/deislabs/duffle/pkg/duffle/home" ) const credentialAddDesc = ` diff --git a/cmd/duffle/credential_edit.go b/cmd/duffle/credential_edit.go index 5870864a..51ef1731 100644 --- a/cmd/duffle/credential_edit.go +++ b/cmd/duffle/credential_edit.go @@ -6,12 +6,12 @@ import ( "io/ioutil" "path/filepath" + "github.com/deislabs/duffle/pkg/duffle/home" + + "github.com/deislabs/cnab-go/credentials" "github.com/ghodss/yaml" "github.com/spf13/cobra" survey "gopkg.in/AlecAivazis/survey.v1" - - "github.com/deislabs/duffle/pkg/credentials" - "github.com/deislabs/duffle/pkg/duffle/home" ) const credentialEditDesc = ` diff --git a/cmd/duffle/credential_generate.go b/cmd/duffle/credential_generate.go index 46918c61..4fc2723b 100644 --- a/cmd/duffle/credential_generate.go +++ b/cmd/duffle/credential_generate.go @@ -9,13 +9,13 @@ import ( "sort" "strings" + "github.com/deislabs/duffle/pkg/duffle/home" + "github.com/deislabs/cnab-go/bundle" + "github.com/deislabs/cnab-go/credentials" "github.com/spf13/cobra" survey "gopkg.in/AlecAivazis/survey.v1" yaml "gopkg.in/yaml.v2" - - "github.com/deislabs/duffle/pkg/credentials" - "github.com/deislabs/duffle/pkg/duffle/home" ) const credentialGenerateHelp = `Generate credentials from a CNAB bundle diff --git a/cmd/duffle/credential_list.go b/cmd/duffle/credential_list.go index eb3b633a..1cc02025 100644 --- a/cmd/duffle/credential_list.go +++ b/cmd/duffle/credential_list.go @@ -6,12 +6,12 @@ import ( "os" "path/filepath" + "github.com/deislabs/duffle/pkg/duffle/home" + + "github.com/deislabs/cnab-go/credentials" "github.com/gosuri/uitable" log "github.com/sirupsen/logrus" "github.com/spf13/cobra" - - "github.com/deislabs/duffle/pkg/credentials" - "github.com/deislabs/duffle/pkg/duffle/home" ) type credentialListCmd struct { diff --git a/cmd/duffle/credential_show.go b/cmd/duffle/credential_show.go index 9c9dd6a8..f0824132 100644 --- a/cmd/duffle/credential_show.go +++ b/cmd/duffle/credential_show.go @@ -5,11 +5,10 @@ import ( "io" "path/filepath" - "github.com/deislabs/duffle/pkg/credentials" "github.com/deislabs/duffle/pkg/duffle/home" + "github.com/deislabs/cnab-go/credentials" "github.com/ghodss/yaml" - "github.com/spf13/cobra" ) diff --git a/cmd/duffle/credential_show_test.go b/cmd/duffle/credential_show_test.go index 0663c38a..96655909 100644 --- a/cmd/duffle/credential_show_test.go +++ b/cmd/duffle/credential_show_test.go @@ -4,7 +4,7 @@ import ( "bytes" "testing" - "github.com/deislabs/duffle/pkg/credentials" + "github.com/deislabs/cnab-go/credentials" ) func TestPrintCredentials(t *testing.T) { diff --git a/cmd/duffle/install.go b/cmd/duffle/install.go index a38c262c..ea6dea74 100644 --- a/cmd/duffle/install.go +++ b/cmd/duffle/install.go @@ -7,14 +7,14 @@ import ( "path/filepath" "strings" + "github.com/deislabs/duffle/pkg/duffle/home" + "github.com/deislabs/duffle/pkg/repo" + + "github.com/deislabs/cnab-go/action" "github.com/deislabs/cnab-go/bundle" + "github.com/deislabs/cnab-go/claim" "github.com/spf13/cobra" "github.com/spf13/viper" - - "github.com/deislabs/duffle/pkg/action" - "github.com/deislabs/duffle/pkg/claim" - "github.com/deislabs/duffle/pkg/duffle/home" - "github.com/deislabs/duffle/pkg/repo" ) const installUsage = `Installs a Cloud Native Application Bundle (CNAB) diff --git a/cmd/duffle/main.go b/cmd/duffle/main.go index 7847765d..7bc14c30 100644 --- a/cmd/duffle/main.go +++ b/cmd/duffle/main.go @@ -7,16 +7,17 @@ import ( "runtime" "strings" - "github.com/deislabs/cnab-go/bundle" - "github.com/spf13/cobra" - - "github.com/deislabs/duffle/pkg/claim" - "github.com/deislabs/duffle/pkg/credentials" - "github.com/deislabs/duffle/pkg/driver" + duffleDriver "github.com/deislabs/duffle/pkg/driver" "github.com/deislabs/duffle/pkg/duffle/home" "github.com/deislabs/duffle/pkg/loader" "github.com/deislabs/duffle/pkg/reference" - "github.com/deislabs/duffle/pkg/utils/crud" + + "github.com/deislabs/cnab-go/bundle" + "github.com/deislabs/cnab-go/claim" + "github.com/deislabs/cnab-go/credentials" + "github.com/deislabs/cnab-go/driver" + "github.com/deislabs/cnab-go/utils/crud" + "github.com/spf13/cobra" ) var ( @@ -104,7 +105,7 @@ func must(err error) { // prepareDriver prepares a driver per the user's request. func prepareDriver(driverName string) (driver.Driver, error) { - driverImpl, err := driver.Lookup(driverName) + driverImpl, err := duffleDriver.Lookup(driverName) if err != nil { return driverImpl, err } diff --git a/cmd/duffle/main_test.go b/cmd/duffle/main_test.go index 9595bc0d..ea760e1b 100644 --- a/cmd/duffle/main_test.go +++ b/cmd/duffle/main_test.go @@ -6,10 +6,10 @@ import ( "path/filepath" "testing" - "github.com/deislabs/duffle/pkg/credentials" "github.com/deislabs/duffle/pkg/duffle/home" "github.com/deislabs/cnab-go/bundle" + "github.com/deislabs/cnab-go/credentials" "github.com/ghodss/yaml" "github.com/stretchr/testify/assert" ) diff --git a/cmd/duffle/run.go b/cmd/duffle/run.go index 6440b693..c061c56c 100644 --- a/cmd/duffle/run.go +++ b/cmd/duffle/run.go @@ -6,8 +6,8 @@ import ( "github.com/spf13/cobra" - "github.com/deislabs/duffle/pkg/action" - "github.com/deislabs/duffle/pkg/claim" + "github.com/deislabs/cnab-go/action" + "github.com/deislabs/cnab-go/claim" ) func newRunCmd(w io.Writer) *cobra.Command { diff --git a/cmd/duffle/status.go b/cmd/duffle/status.go index 17351a63..627f7549 100644 --- a/cmd/duffle/status.go +++ b/cmd/duffle/status.go @@ -8,8 +8,8 @@ import ( "github.com/gosuri/uitable" "github.com/spf13/cobra" - "github.com/deislabs/duffle/pkg/action" - "github.com/deislabs/duffle/pkg/claim" + "github.com/deislabs/cnab-go/action" + "github.com/deislabs/cnab-go/claim" ) func newStatusCmd(w io.Writer) *cobra.Command { diff --git a/cmd/duffle/uninstall.go b/cmd/duffle/uninstall.go index 95811a1d..89718b24 100644 --- a/cmd/duffle/uninstall.go +++ b/cmd/duffle/uninstall.go @@ -7,7 +7,7 @@ import ( "github.com/spf13/cobra" - "github.com/deislabs/duffle/pkg/action" + "github.com/deislabs/cnab-go/action" ) const uninstallUsage = `Uninstalls an installation of a CNAB bundle. diff --git a/cmd/duffle/upgrade.go b/cmd/duffle/upgrade.go index d9b27f68..841a9e9d 100644 --- a/cmd/duffle/upgrade.go +++ b/cmd/duffle/upgrade.go @@ -7,7 +7,7 @@ import ( "github.com/spf13/cobra" - "github.com/deislabs/duffle/pkg/action" + "github.com/deislabs/cnab-go/action" ) const upgradeUsage = `perform the upgrade action in the CNAB bundle` diff --git a/cmd/duffle/upgrade_test.go b/cmd/duffle/upgrade_test.go index 4951931f..2abb0966 100644 --- a/cmd/duffle/upgrade_test.go +++ b/cmd/duffle/upgrade_test.go @@ -8,7 +8,7 @@ import ( "github.com/deislabs/cnab-go/bundle" - "github.com/deislabs/duffle/pkg/claim" + "github.com/deislabs/cnab-go/claim" ) func TestUpgradePersistsClaim(t *testing.T) { diff --git a/pkg/action/action.go b/pkg/action/action.go deleted file mode 100644 index e6f7c276..00000000 --- a/pkg/action/action.go +++ /dev/null @@ -1,124 +0,0 @@ -package action - -import ( - "encoding/json" - "errors" - "fmt" - "io" - "strings" - - "github.com/deislabs/cnab-go/bundle" - - "github.com/deislabs/duffle/pkg/claim" - "github.com/deislabs/duffle/pkg/credentials" - "github.com/deislabs/duffle/pkg/driver" -) - -// stateful is there just to make callers of opFromClaims more readable -const stateful = false - -// Action describes one of the primary actions that can be executed in CNAB. -// -// The actions are: -// - install -// - upgrade -// - uninstall -// - downgrade -// - status -type Action interface { - // Run an action, and record the status in the given claim - Run(*claim.Claim, credentials.Set, io.Writer) error -} - -func selectInvocationImage(d driver.Driver, c *claim.Claim) (bundle.InvocationImage, error) { - if len(c.Bundle.InvocationImages) == 0 { - return bundle.InvocationImage{}, errors.New("no invocationImages are defined in the bundle") - } - - for _, ii := range c.Bundle.InvocationImages { - if d.Handles(ii.ImageType) { - return ii, nil - } - } - - return bundle.InvocationImage{}, errors.New("driver is not compatible with any of the invocation images in the bundle") -} - -func getImageMap(b *bundle.Bundle) ([]byte, error) { - imgs := b.Images - if imgs == nil { - imgs = make(map[string]bundle.Image) - } - return json.Marshal(imgs) -} - -func appliesToAction(action string, parameter bundle.ParameterDefinition) bool { - if len(parameter.ApplyTo) == 0 { - return true - } - for _, act := range parameter.ApplyTo { - if action == act { - return true - } - } - return false -} - -func opFromClaim(action string, stateless bool, c *claim.Claim, ii bundle.InvocationImage, creds credentials.Set, w io.Writer) (*driver.Operation, error) { - env, files, err := creds.Expand(c.Bundle, stateless) - if err != nil { - return nil, err - } - - // Quick verification that no params were passed that are not actual legit params. - for key := range c.Parameters { - if _, ok := c.Bundle.Parameters[key]; !ok { - return nil, fmt.Errorf("undefined parameter %q", key) - } - } - - for k, param := range c.Bundle.Parameters { - rawval, ok := c.Parameters[k] - if !ok { - if param.Required && appliesToAction(action, param) { - return nil, fmt.Errorf("missing required parameter %q for action %q", k, action) - } - continue - } - value := fmt.Sprintf("%v", rawval) - if param.Destination == nil { - // env is a CNAB_P_ - env[fmt.Sprintf("CNAB_P_%s", strings.ToUpper(k))] = value - continue - } - if param.Destination.Path != "" { - files[param.Destination.Path] = value - } - if param.Destination.EnvironmentVariable != "" { - env[param.Destination.EnvironmentVariable] = value - } - } - - imgMap, err := getImageMap(c.Bundle) - if err != nil { - return nil, fmt.Errorf("unable to generate image map: %s", err) - } - files["/cnab/app/image-map.json"] = string(imgMap) - - env["CNAB_INSTALLATION_NAME"] = c.Name - env["CNAB_ACTION"] = action - env["CNAB_BUNDLE_NAME"] = c.Bundle.Name - env["CNAB_BUNDLE_VERSION"] = c.Bundle.Version - - return &driver.Operation{ - Action: action, - Installation: c.Name, - Parameters: c.Parameters, - Image: ii.Image, - ImageType: ii.ImageType, - Revision: c.Revision, - Environment: env, - Files: files, - Out: w, - }, nil -} diff --git a/pkg/action/action_test.go b/pkg/action/action_test.go deleted file mode 100644 index 48a1a6bb..00000000 --- a/pkg/action/action_test.go +++ /dev/null @@ -1,238 +0,0 @@ -package action - -import ( - "encoding/json" - "errors" - "os" - "strings" - "testing" - "time" - - "github.com/deislabs/duffle/pkg/claim" - "github.com/deislabs/duffle/pkg/credentials" - "github.com/deislabs/duffle/pkg/driver" - - "github.com/deislabs/cnab-go/bundle" - "github.com/stretchr/testify/assert" -) - -type mockFailingDriver struct { - shouldHandle bool -} - -var mockSet = credentials.Set{ - "secret_one": "I'm a secret", - "secret_two": "I'm also a secret", -} - -func (d *mockFailingDriver) Handles(imageType string) bool { - return d.shouldHandle -} -func (d *mockFailingDriver) Run(op *driver.Operation) error { - return errors.New("I always fail") -} - -func mockBundle() *bundle.Bundle { - return &bundle.Bundle{ - Name: "bar", - Version: "0.1.0", - InvocationImages: []bundle.InvocationImage{ - { - BaseImage: bundle.BaseImage{Image: "foo/bar:0.1.0", ImageType: "docker"}, - }, - }, - Credentials: map[string]bundle.Location{ - "secret_one": { - EnvironmentVariable: "SECRET_ONE", - Path: "/foo/bar", - }, - "secret_two": { - EnvironmentVariable: "SECRET_TWO", - Path: "/secret/two", - }, - }, - Parameters: map[string]bundle.ParameterDefinition{ - "param_one": { - DefaultValue: "one", - }, - "param_two": { - DefaultValue: "two", - Destination: &bundle.Location{ - EnvironmentVariable: "PARAM_TWO", - }, - }, - "param_three": { - DefaultValue: "three", - Destination: &bundle.Location{ - Path: "/param/three", - }, - }, - }, - Actions: map[string]bundle.Action{ - "test": {Modifies: true}, - }, - Images: map[string]bundle.Image{ - "image-a": { - BaseImage: bundle.BaseImage{ - Image: "foo/bar:0.1.0", ImageType: "docker", - }, - Description: "description", - }, - }, - } - -} - -func TestOpFromClaim(t *testing.T) { - now := time.Now() - c := &claim.Claim{ - Created: now, - Modified: now, - Name: "name", - Revision: "revision", - Bundle: mockBundle(), - Parameters: map[string]interface{}{ - "param_one": "oneval", - "param_two": "twoval", - "param_three": "threeval", - }, - } - invocImage := c.Bundle.InvocationImages[0] - - op, err := opFromClaim(claim.ActionInstall, stateful, c, invocImage, mockSet, os.Stdout) - if err != nil { - t.Fatal(err) - } - - is := assert.New(t) - - is.Equal(c.Name, op.Installation) - is.Equal(c.Revision, op.Revision) - is.Equal(invocImage.Image, op.Image) - is.Equal(driver.ImageTypeDocker, op.ImageType) - is.Equal(op.Environment["SECRET_ONE"], "I'm a secret") - is.Equal(op.Environment["PARAM_TWO"], "twoval") - is.Equal(op.Environment["CNAB_P_PARAM_ONE"], "oneval") - is.Equal(op.Files["/secret/two"], "I'm also a secret") - is.Equal(op.Files["/param/three"], "threeval") - is.Contains(op.Files, "/cnab/app/image-map.json") - var imgMap map[string]bundle.Image - is.NoError(json.Unmarshal([]byte(op.Files["/cnab/app/image-map.json"]), &imgMap)) - is.Equal(c.Bundle.Images, imgMap) - is.Len(op.Parameters, 3) - is.Equal(os.Stdout, op.Out) -} - -func TestOpFromClaim_UndefinedParams(t *testing.T) { - now := time.Now() - c := &claim.Claim{ - Created: now, - Modified: now, - Name: "name", - Revision: "revision", - Bundle: mockBundle(), - Parameters: map[string]interface{}{ - "param_one": "oneval", - "param_two": "twoval", - "param_three": "threeval", - "param_one_million": "this is not a valid parameter", - }, - } - invocImage := c.Bundle.InvocationImages[0] - - _, err := opFromClaim(claim.ActionInstall, stateful, c, invocImage, mockSet, os.Stdout) - assert.Error(t, err) -} - -func TestOpFromClaim_MissingRequiredParameter(t *testing.T) { - now := time.Now() - b := mockBundle() - b.Parameters["param_one"] = bundle.ParameterDefinition{Required: true} - - c := &claim.Claim{ - Created: now, - Modified: now, - Name: "name", - Revision: "revision", - Bundle: b, - Parameters: map[string]interface{}{ - "param_two": "twoval", - "param_three": "threeval", - }, - } - invocImage := c.Bundle.InvocationImages[0] - - // missing required parameter fails - _, err := opFromClaim(claim.ActionInstall, stateful, c, invocImage, mockSet, os.Stdout) - assert.EqualError(t, err, `missing required parameter "param_one" for action "install"`) - - // fill the missing parameter - c.Parameters["param_one"] = "oneval" - _, err = opFromClaim(claim.ActionInstall, stateful, c, invocImage, mockSet, os.Stdout) - assert.Nil(t, err) -} - -func TestOpFromClaim_MissingRequiredParamSpecificToAction(t *testing.T) { - now := time.Now() - b := mockBundle() - // Add a required parameter only defined for the test action - b.Parameters["param_test"] = bundle.ParameterDefinition{ - ApplyTo: []string{"test"}, - Required: true, - } - c := &claim.Claim{ - Created: now, - Modified: now, - Name: "name", - Revision: "revision", - Bundle: b, - Parameters: map[string]interface{}{ - "param_one": "oneval", - "param_two": "twoval", - "param_three": "threeval", - }, - } - invocImage := c.Bundle.InvocationImages[0] - - // calling install action without the test required parameter for test action is ok - _, err := opFromClaim(claim.ActionInstall, stateful, c, invocImage, mockSet, os.Stdout) - assert.Nil(t, err) - - // test action needs the required parameter - _, err = opFromClaim("test", stateful, c, invocImage, mockSet, os.Stdout) - assert.EqualError(t, err, `missing required parameter "param_test" for action "test"`) - - c.Parameters["param_test"] = "only for test action" - _, err = opFromClaim("test", stateful, c, invocImage, mockSet, os.Stdout) - assert.Nil(t, err) -} - -func TestSelectInvocationImage_EmptyInvocationImages(t *testing.T) { - c := &claim.Claim{ - Bundle: &bundle.Bundle{}, - } - _, err := selectInvocationImage(&driver.DebugDriver{}, c) - if err == nil { - t.Fatal("expected an error") - } - want := "no invocationImages are defined" - got := err.Error() - if !strings.Contains(got, want) { - t.Fatalf("expected an error containing %q but got %q", want, got) - } -} - -func TestSelectInvocationImage_DriverIncompatible(t *testing.T) { - c := &claim.Claim{ - Bundle: mockBundle(), - } - _, err := selectInvocationImage(&mockFailingDriver{}, c) - if err == nil { - t.Fatal("expected an error") - } - want := "driver is not compatible" - got := err.Error() - if !strings.Contains(got, want) { - t.Fatalf("expected an error containing %q but got %q", want, got) - } -} diff --git a/pkg/action/install.go b/pkg/action/install.go deleted file mode 100644 index 2941fc74..00000000 --- a/pkg/action/install.go +++ /dev/null @@ -1,36 +0,0 @@ -package action - -import ( - "io" - - "github.com/deislabs/duffle/pkg/claim" - "github.com/deislabs/duffle/pkg/credentials" - "github.com/deislabs/duffle/pkg/driver" -) - -// Install describes an installation action -type Install struct { - Driver driver.Driver // Needs to be more than a string -} - -// Run performs an installation and updates the Claim accordingly -func (i *Install) Run(c *claim.Claim, creds credentials.Set, w io.Writer) error { - invocImage, err := selectInvocationImage(i.Driver, c) - if err != nil { - return err - } - - op, err := opFromClaim(claim.ActionInstall, stateful, c, invocImage, creds, w) - if err != nil { - return err - } - if err := i.Driver.Run(op); err != nil { - c.Update(claim.ActionInstall, claim.StatusFailure) - c.Result.Message = err.Error() - return err - } - - // Update claim: - c.Update(claim.ActionInstall, claim.StatusSuccess) - return nil -} diff --git a/pkg/action/install_test.go b/pkg/action/install_test.go deleted file mode 100644 index 7607438b..00000000 --- a/pkg/action/install_test.go +++ /dev/null @@ -1,37 +0,0 @@ -package action - -import ( - "io/ioutil" - "testing" - "time" - - "github.com/deislabs/duffle/pkg/claim" - "github.com/deislabs/duffle/pkg/driver" - - "github.com/stretchr/testify/assert" -) - -// makes sure Install implements Action interface -var _ Action = &Install{} - -func TestInstall_Run(t *testing.T) { - out := ioutil.Discard - - c := &claim.Claim{ - Created: time.Time{}, - Modified: time.Time{}, - Name: "name", - Revision: "revision", - Bundle: mockBundle(), - Parameters: map[string]interface{}{}, - } - - inst := &Install{Driver: &driver.DebugDriver{}} - assert.NoError(t, inst.Run(c, mockSet, out)) - - inst = &Install{Driver: &mockFailingDriver{}} - assert.Error(t, inst.Run(c, mockSet, out)) - - inst = &Install{Driver: &mockFailingDriver{shouldHandle: true}} - assert.Error(t, inst.Run(c, mockSet, out)) -} diff --git a/pkg/action/run_custom.go b/pkg/action/run_custom.go deleted file mode 100644 index 6ec09708..00000000 --- a/pkg/action/run_custom.go +++ /dev/null @@ -1,67 +0,0 @@ -package action - -import ( - "errors" - "io" - - "github.com/deislabs/duffle/pkg/claim" - "github.com/deislabs/duffle/pkg/credentials" - "github.com/deislabs/duffle/pkg/driver" -) - -var ( - // ErrBlockedAction indicates that the requested action was not allowed. - ErrBlockedAction = errors.New("action not allowed") - // ErrUndefinedAction indicates that a bundle does not define this action. - ErrUndefinedAction = errors.New("action not defined for bundle") -) - -// RunCustom allows the execution of an arbitrary target in a CNAB bundle. -type RunCustom struct { - Driver driver.Driver - Action string -} - -// blockedActions is a list of actions that cannot be run as custom. -// -// This prevents accidental circumvention of standard behavior. -var blockedActions = map[string]struct{}{"install": {}, "uninstall": {}, "upgrade": {}} - -// Run executes a status action in an image -func (i *RunCustom) Run(c *claim.Claim, creds credentials.Set, w io.Writer) error { - if _, ok := blockedActions[i.Action]; ok { - return ErrBlockedAction - } - - actionDef, ok := c.Bundle.Actions[i.Action] - if !ok { - return ErrUndefinedAction - } - - invocImage, err := selectInvocationImage(i.Driver, c) - if err != nil { - return err - } - - op, err := opFromClaim(i.Action, actionDef.Stateless, c, invocImage, creds, w) - if err != nil { - return err - } - - err = i.Driver.Run(op) - - // If this action says it does not modify the release, then we don't track - // it in the claim. Otherwise, we do. - if !actionDef.Modifies { - return err - } - - status := claim.StatusSuccess - if err != nil { - c.Result.Message = err.Error() - status = claim.StatusFailure - } - - c.Update(i.Action, status) - return err -} diff --git a/pkg/action/run_custom_test.go b/pkg/action/run_custom_test.go deleted file mode 100644 index 34648ce3..00000000 --- a/pkg/action/run_custom_test.go +++ /dev/null @@ -1,51 +0,0 @@ -package action - -import ( - "io/ioutil" - "testing" - "time" - - "github.com/deislabs/duffle/pkg/claim" - "github.com/deislabs/duffle/pkg/driver" - - "github.com/deislabs/cnab-go/bundle" - "github.com/stretchr/testify/assert" -) - -// makes sure RunCustom implements Action interface -var _ Action = &RunCustom{} - -func TestRunCustom(t *testing.T) { - out := ioutil.Discard - is := assert.New(t) - - rc := &RunCustom{ - Driver: &driver.DebugDriver{}, - Action: "test", - } - c := &claim.Claim{ - Created: time.Time{}, - Modified: time.Time{}, - Name: "runcustom", - Revision: "revision", - Bundle: mockBundle(), - Parameters: map[string]interface{}{}, - } - - if err := rc.Run(c, mockSet, out); err != nil { - t.Fatal(err) - } - is.Equal(claim.StatusSuccess, c.Result.Status) - is.Equal("test", c.Result.Action) - - // Make sure we don't allow forbidden custom actions - rc.Action = "install" - is.Error(rc.Run(c, mockSet, out)) - - // Get rid of custom actions, and this should fail - rc.Action = "test" - c.Bundle.Actions = map[string]bundle.Action{} - if err := rc.Run(c, mockSet, out); err == nil { - t.Fatal("Unknown action should fail") - } -} diff --git a/pkg/action/status.go b/pkg/action/status.go deleted file mode 100644 index 5fb5af5c..00000000 --- a/pkg/action/status.go +++ /dev/null @@ -1,28 +0,0 @@ -package action - -import ( - "io" - - "github.com/deislabs/duffle/pkg/claim" - "github.com/deislabs/duffle/pkg/credentials" - "github.com/deislabs/duffle/pkg/driver" -) - -// Status runs a status action on a CNAB bundle. -type Status struct { - Driver driver.Driver -} - -// Run executes a status action in an image -func (i *Status) Run(c *claim.Claim, creds credentials.Set, w io.Writer) error { - invocImage, err := selectInvocationImage(i.Driver, c) - if err != nil { - return err - } - - op, err := opFromClaim(claim.ActionStatus, stateful, c, invocImage, creds, w) - if err != nil { - return err - } - return i.Driver.Run(op) -} diff --git a/pkg/action/status_test.go b/pkg/action/status_test.go deleted file mode 100644 index 35a4e70a..00000000 --- a/pkg/action/status_test.go +++ /dev/null @@ -1,36 +0,0 @@ -package action - -import ( - "io/ioutil" - "testing" - "time" - - "github.com/deislabs/duffle/pkg/claim" - "github.com/deislabs/duffle/pkg/driver" - - "github.com/stretchr/testify/assert" -) - -// makes sure Status implements Action interface -var _ Action = &Status{} - -func TestStatus_Run(t *testing.T) { - out := ioutil.Discard - - st := &Status{Driver: &driver.DebugDriver{}} - c := &claim.Claim{ - Created: time.Time{}, - Modified: time.Time{}, - Name: "name", - Revision: "revision", - Bundle: mockBundle(), - Parameters: map[string]interface{}{}, - } - - if err := st.Run(c, mockSet, out); err != nil { - t.Fatal(err) - } - - st = &Status{Driver: &mockFailingDriver{}} - assert.Error(t, st.Run(c, mockSet, out)) -} diff --git a/pkg/action/uninstall.go b/pkg/action/uninstall.go deleted file mode 100644 index 4708cdff..00000000 --- a/pkg/action/uninstall.go +++ /dev/null @@ -1,35 +0,0 @@ -package action - -import ( - "io" - - "github.com/deislabs/duffle/pkg/claim" - "github.com/deislabs/duffle/pkg/credentials" - "github.com/deislabs/duffle/pkg/driver" -) - -// Uninstall runs an uninstall action -type Uninstall struct { - Driver driver.Driver -} - -// Run performs the uninstall steps and updates the Claim -func (u *Uninstall) Run(c *claim.Claim, creds credentials.Set, w io.Writer) error { - invocImage, err := selectInvocationImage(u.Driver, c) - if err != nil { - return err - } - - op, err := opFromClaim(claim.ActionUninstall, stateful, c, invocImage, creds, w) - if err != nil { - return err - } - if err := u.Driver.Run(op); err != nil { - c.Update(claim.ActionUninstall, claim.StatusFailure) - c.Result.Message = err.Error() - return err - } - - c.Update(claim.ActionUninstall, claim.StatusSuccess) - return nil -} diff --git a/pkg/action/uninstall_test.go b/pkg/action/uninstall_test.go deleted file mode 100644 index e98e3de8..00000000 --- a/pkg/action/uninstall_test.go +++ /dev/null @@ -1,58 +0,0 @@ -package action - -import ( - "io/ioutil" - "testing" - "time" - - "github.com/deislabs/duffle/pkg/claim" - "github.com/deislabs/duffle/pkg/driver" - - "github.com/stretchr/testify/assert" -) - -// makes sure Uninstall implements Action interface -var _ Action = &Uninstall{} - -func TestUninstall_Run(t *testing.T) { - out := ioutil.Discard - - c := &claim.Claim{ - Created: time.Time{}, - Modified: time.Time{}, - Name: "name", - Revision: "revision", - Bundle: mockBundle(), - Parameters: map[string]interface{}{}, - } - - uninst := &Uninstall{Driver: &driver.DebugDriver{}} - assert.NoError(t, uninst.Run(c, mockSet, out)) - if c.Created == c.Modified { - t.Error("Claim was not updated with modified time stamp during uninstallafter uninstall action") - } - - if c.Result.Action != claim.ActionUninstall { - t.Errorf("Claim result action not successfully updated. Expected %v, got %v", claim.ActionUninstall, c.Result.Action) - } - if c.Result.Status != claim.StatusSuccess { - t.Errorf("Claim result status not successfully updated. Expected %v, got %v", claim.StatusSuccess, c.Result.Status) - } - - uninst = &Uninstall{Driver: &mockFailingDriver{}} - assert.Error(t, uninst.Run(c, mockSet, out)) - - uninst = &Uninstall{Driver: &mockFailingDriver{shouldHandle: true}} - assert.Error(t, uninst.Run(c, mockSet, out)) - if c.Result.Message == "" { - t.Error("Expected error message in claim result message") - } - - if c.Result.Action != claim.ActionUninstall { - t.Errorf("Expected claim result action to be %v, got %v", claim.ActionUninstall, c.Result.Action) - } - - if c.Result.Status != claim.StatusFailure { - t.Errorf("Expected claim result status to be %v, got %v", claim.StatusFailure, c.Result.Status) - } -} diff --git a/pkg/action/upgrade.go b/pkg/action/upgrade.go deleted file mode 100644 index 0192020c..00000000 --- a/pkg/action/upgrade.go +++ /dev/null @@ -1,35 +0,0 @@ -package action - -import ( - "io" - - "github.com/deislabs/duffle/pkg/claim" - "github.com/deislabs/duffle/pkg/credentials" - "github.com/deislabs/duffle/pkg/driver" -) - -// Upgrade runs an upgrade action -type Upgrade struct { - Driver driver.Driver -} - -// Run performs the upgrade steps and updates the Claim -func (u *Upgrade) Run(c *claim.Claim, creds credentials.Set, w io.Writer) error { - invocImage, err := selectInvocationImage(u.Driver, c) - if err != nil { - return err - } - - op, err := opFromClaim(claim.ActionUpgrade, stateful, c, invocImage, creds, w) - if err != nil { - return err - } - if err := u.Driver.Run(op); err != nil { - c.Update(claim.ActionUpgrade, claim.StatusFailure) - c.Result.Message = err.Error() - return err - } - - c.Update(claim.ActionUpgrade, claim.StatusSuccess) - return nil -} diff --git a/pkg/action/upgrade_test.go b/pkg/action/upgrade_test.go deleted file mode 100644 index b16c7aee..00000000 --- a/pkg/action/upgrade_test.go +++ /dev/null @@ -1,58 +0,0 @@ -package action - -import ( - "io/ioutil" - "testing" - "time" - - "github.com/deislabs/duffle/pkg/claim" - "github.com/deislabs/duffle/pkg/driver" - - "github.com/stretchr/testify/assert" -) - -// makes sure Upgrade implements Action interface -var _ Action = &Upgrade{} - -func TestUpgrade_Run(t *testing.T) { - out := ioutil.Discard - - c := &claim.Claim{ - Created: time.Time{}, - Modified: time.Time{}, - Name: "name", - Revision: "revision", - Bundle: mockBundle(), - Parameters: map[string]interface{}{}, - } - - upgr := &Upgrade{Driver: &driver.DebugDriver{}} - assert.NoError(t, upgr.Run(c, mockSet, out)) - if c.Created == c.Modified { - t.Error("Claim was not updated with modified time stamp during upgrade action") - } - - if c.Result.Action != claim.ActionUpgrade { - t.Errorf("Claim result action not successfully updated. Expected %v, got %v", claim.ActionUninstall, c.Result.Action) - } - if c.Result.Status != claim.StatusSuccess { - t.Errorf("Claim result status not successfully updated. Expected %v, got %v", claim.StatusSuccess, c.Result.Status) - } - - upgr = &Upgrade{Driver: &mockFailingDriver{}} - assert.Error(t, upgr.Run(c, mockSet, out)) - - upgr = &Upgrade{Driver: &mockFailingDriver{shouldHandle: true}} - assert.Error(t, upgr.Run(c, mockSet, out)) - if c.Result.Message == "" { - t.Error("Expected error message in claim result message") - } - - if c.Result.Action != claim.ActionUpgrade { - t.Errorf("Expected claim result action to be %v, got %v", claim.ActionUpgrade, c.Result.Action) - } - - if c.Result.Status != claim.StatusFailure { - t.Errorf("Expected claim result status to be %v, got %v", claim.StatusFailure, c.Result.Status) - } -} diff --git a/pkg/claim/claim.go b/pkg/claim/claim.go deleted file mode 100644 index 7cf90505..00000000 --- a/pkg/claim/claim.go +++ /dev/null @@ -1,95 +0,0 @@ -package claim - -import ( - "fmt" - "math/rand" - "regexp" - "time" - - "github.com/oklog/ulid" - - "github.com/deislabs/cnab-go/bundle" -) - -// Status constants define the CNAB status fields on a Result. -const ( - StatusSuccess = "success" - StatusFailure = "failure" - StatusUnderway = "underway" - StatusUnknown = "unknown" -) - -// Action constants define the CNAB action to be taken -const ( - ActionInstall = "install" - ActionUpgrade = "upgrade" - ActionDowngrade = "downgrade" - ActionUninstall = "uninstall" - ActionStatus = "status" - ActionUnknown = "unknown" -) - -// Claim is an installation claim receipt. -// -// Claims reprsent information about a particular installation, and -// provide the necessary data to upgrade, uninstall, and downgrade -// a CNAB package. -type Claim struct { - Name string `json:"name"` - Revision string `json:"revision"` - Created time.Time `json:"created"` - Modified time.Time `json:"modified"` - Bundle *bundle.Bundle `json:"bundle"` - Result Result `json:"result"` - Parameters map[string]interface{} `json:"parameters"` - Files map[string]string `json:"files"` -} - -// ValidName is a regular expression that indicates whether a name is a valid claim name. -var ValidName = regexp.MustCompile("^[a-zA-Z0-9_-]+$") - -// New creates a new Claim initialized for an installation operation. -func New(name string) (*Claim, error) { - - if !ValidName.MatchString(name) { - return nil, fmt.Errorf("invalid name %q. Names must be [a-zA-Z0-9-_]+", name) - } - - now := time.Now() - return &Claim{ - Name: name, - Revision: ULID(), - Created: now, - Modified: now, - Result: Result{ - Action: ActionUnknown, - Status: StatusUnknown, - }, - Parameters: map[string]interface{}{}, - }, nil -} - -// Update is a convenience for modifying the necessary fields on a Claim. -// -// Per spec, when a claim is updated, the action, status, revision, and modified fields all change. -// All but status and action can be computed. -func (c *Claim) Update(action, status string) { - c.Result.Action = action - c.Result.Status = status - c.Modified = time.Now() - c.Revision = ULID() -} - -// Result tracks the result of a Duffle operation on a CNAB installation -type Result struct { - Message string `json:"message"` - Action string `json:"action"` - Status string `json:"status"` -} - -// ULID generates a string representation of a ULID. -func ULID() string { - now := time.Now() - entropy := rand.New(rand.NewSource(now.UnixNano())) - return ulid.MustNew(ulid.Timestamp(now), entropy).String() -} diff --git a/pkg/claim/claim_test.go b/pkg/claim/claim_test.go deleted file mode 100644 index 777e704b..00000000 --- a/pkg/claim/claim_test.go +++ /dev/null @@ -1,51 +0,0 @@ -package claim - -import ( - "testing" - "time" - - "github.com/stretchr/testify/assert" -) - -func TestNew(t *testing.T) { - // Make sure that the default Result has status and action set. - claim, err := New("my_claim") - assert.NoError(t, err) - - assert.Equal(t, "my_claim", claim.Name, "Name is set") - assert.Equal(t, "unknown", claim.Result.Status) - assert.Equal(t, "unknown", claim.Result.Action) -} - -func TestUpdate(t *testing.T) { - claim, err := New("claim") - assert.NoError(t, err) - oldMod := claim.Modified - oldUlid := claim.Revision - - time.Sleep(1 * time.Millisecond) // Force the Update to happen at a new time. For those of us who remembered to press the Turbo button. - - claim.Update(ActionInstall, StatusSuccess) - - is := assert.New(t) - is.NotEqual(oldMod, claim.Modified) - is.NotEqual(oldUlid, claim.Revision) - is.Equal("install", claim.Result.Action) - is.Equal("success", claim.Result.Status) -} - -func TestValidName(t *testing.T) { - is := assert.New(t) - - for name, expect := range map[string]bool{ - "M4cb3th": true, - "Lady MacBeth": false, //spaces illegal - "3_Witches": true, - "Banquø": false, // We could probably loosen this one up - "King-Duncan": true, - "MacDuff@geocities.com": false, - "hecate": true, // I wouldn't dare cross Hecate. - } { - is.Equal(expect, ValidName.MatchString(name)) - } -} diff --git a/pkg/claim/claimstore.go b/pkg/claim/claimstore.go deleted file mode 100644 index 13e1b0cb..00000000 --- a/pkg/claim/claimstore.go +++ /dev/null @@ -1,77 +0,0 @@ -package claim - -import ( - "encoding/json" - "errors" - - "github.com/deislabs/duffle/pkg/utils/crud" -) - -// ErrClaimNotFound represents a claim not found in claim storage -var ErrClaimNotFound = errors.New(`Claim does not exist`) - -// Store is a persistent store for claims. -type Store struct { - backingStore crud.Store -} - -// NewClaimStore creates a persistent store for claims using the specified -// backing key-blob store. -func NewClaimStore(backingStore crud.Store) Store { - return Store{ - backingStore: backingStore, - } -} - -// List lists the names of the stored claims. -func (s Store) List() ([]string, error) { - return s.backingStore.List() -} - -// Store saves a claim. Any previous version of the claim (that is, with the same -// name) is overwritten. -func (s Store) Store(claim Claim) error { - bytes, err := json.MarshalIndent(claim, "", " ") - if err != nil { - return err - } - return s.backingStore.Store(claim.Name, bytes) -} - -// Read loads the claim with the given name from the store. -func (s Store) Read(name string) (Claim, error) { - bytes, err := s.backingStore.Read(name) - if err != nil { - if err == crud.ErrFileDoesNotExist { - return Claim{}, ErrClaimNotFound - } - return Claim{}, err - } - claim := Claim{} - err = json.Unmarshal(bytes, &claim) - return claim, err -} - -// ReadAll retrieves all the claims -func (s Store) ReadAll() ([]Claim, error) { - claims := make([]Claim, 0) - - list, err := s.backingStore.List() - if err != nil { - return claims, err - } - - for _, c := range list { - cl, err := s.Read(c) - if err != nil { - return claims, err - } - claims = append(claims, cl) - } - return claims, nil -} - -// Delete deletes a claim from the store. -func (s Store) Delete(name string) error { - return s.backingStore.Delete(name) -} diff --git a/pkg/claim/claimstore_test.go b/pkg/claim/claimstore_test.go deleted file mode 100644 index af352c96..00000000 --- a/pkg/claim/claimstore_test.go +++ /dev/null @@ -1,126 +0,0 @@ -package claim - -import ( - "io/ioutil" - "os" - "path/filepath" - "testing" - "time" - - "github.com/deislabs/cnab-go/bundle" - "github.com/stretchr/testify/assert" - - "github.com/deislabs/duffle/pkg/utils/crud" -) - -func TestCanSaveReadAndDelete(t *testing.T) { - is := assert.New(t) - claim, err := New("foo") - is.NoError(err) - claim.Bundle = &bundle.Bundle{Name: "foobundle", Version: "0.1.2"} - - tempDir, err := ioutil.TempDir("", "duffletest") - if err != nil { - t.Fatalf("Failed to create temp dir: %s", err) - } - defer os.RemoveAll(tempDir) - - storeDir := filepath.Join(tempDir, "claimstore") - store := NewClaimStore(crud.NewFileSystemStore(storeDir, "json")) - - is.NoError(store.Store(*claim), "Failed to store: %s", err) - - c, err := store.Read("foo") - is.NoError(err, "Failed to read: %s", err) - is.Equal(c.Bundle, claim.Bundle, "Expected to read back bundle %s, got %s", claim.Bundle.Name, c.Bundle.Name) - - claims, err := store.List() - is.NoError(err, "Failed to list: %s", err) - is.Len(claims, 1) - is.Equal(claims[0], claim.Name) - - is.NoError(store.Delete("foo")) - - _, err = store.Read("foo") - is.Error(err, "Should have had error reading after deletion but did not") -} - -func TestCanUpdate(t *testing.T) { - claim, err := New("foo") - assert.NoError(t, err) - claim.Bundle = &bundle.Bundle{Name: "foobundle", Version: "0.1.2"} - rev := claim.Revision - - tempDir, err := ioutil.TempDir("", "duffletest") - if err != nil { - t.Fatalf("Failed to create temp dir: %s", err) - } - defer os.RemoveAll(tempDir) - - storeDir := filepath.Join(tempDir, "claimstore") - store := NewClaimStore(crud.NewFileSystemStore(storeDir, "json")) - - err = store.Store(*claim) - if err != nil { - t.Fatal(err) - } - - time.Sleep(1 * time.Millisecond) - claim.Update(ActionInstall, StatusSuccess) - - err = store.Store(*claim) - if err != nil { - t.Errorf("Failed to update: %s", err) - } - - c, err := store.Read("foo") - if err != nil { - t.Errorf("Failed to read: %s", err) - } - - if c.Result.Action != ActionInstall { - t.Errorf("Expected to read back action %s, got %s", ActionInstall, c.Result.Action) - } - if c.Revision == rev { - t.Errorf("Expected to read back new revision, got old revision %s", rev) - } -} - -func TestReadAll(t *testing.T) { - is := assert.New(t) - - tempDir, err := ioutil.TempDir("", "duffletest") - if err != nil { - t.Fatalf("Failed to create temp dir: %s", err) - } - defer os.RemoveAll(tempDir) - - storeDir := filepath.Join(tempDir, "claimstore") - store := NewClaimStore(crud.NewFileSystemStore(storeDir, "json")) - - claim, err := New("foo") - is.NoError(err) - claim.Bundle = &bundle.Bundle{Name: "foobundle", Version: "0.1.0"} - - is.NoError(store.Store(*claim), "Failed to store: %s", err) - - claim2, err := New("bar") - is.NoError(err) - claim2.Bundle = &bundle.Bundle{Name: "barbundle", Version: "0.1.0"} - - is.NoError(store.Store(*claim2), "Failed to store: %s", err) - - claim3, err := New("baz") - is.NoError(err) - claim3.Bundle = &bundle.Bundle{Name: "bazbundle", Version: "0.1.0"} - - is.NoError(store.Store(*claim3), "Failed to store: %s", err) - - claims, err := store.ReadAll() - is.NoError(err, "Failed to read claims: %s", err) - - is.Len(claims, 3) - is.Equal("foo", claim.Name) - is.Equal("bar", claim2.Name) - is.Equal("baz", claim3.Name) -} diff --git a/pkg/credentials/credentialset.go b/pkg/credentials/credentialset.go deleted file mode 100644 index aa42467a..00000000 --- a/pkg/credentials/credentialset.go +++ /dev/null @@ -1,183 +0,0 @@ -package credentials - -import ( - "fmt" - "io/ioutil" - "os" - "os/exec" - "strings" - - "github.com/deislabs/cnab-go/bundle" - - yaml "gopkg.in/yaml.v2" -) - -// Set is an actual set of resolved credentials. -// This is the output of resolving a credentialset file. -type Set map[string]string - -// Expand expands the set into env vars and paths per the spec in the bundle. -// -// This matches the credentials required by the bundle to the credentials present -// in the credentialset, and then expands them per the definition in the Bundle. -func (s Set) Expand(b *bundle.Bundle, stateless bool) (env, files map[string]string, err error) { - env, files = map[string]string{}, map[string]string{} - for name, val := range b.Credentials { - src, ok := s[name] - if !ok { - if stateless { - continue - } - err = fmt.Errorf("credential %q is missing from the user-supplied credentials", name) - return - } - if val.EnvironmentVariable != "" { - env[val.EnvironmentVariable] = src - } - if val.Path != "" { - files[val.Path] = src - } - } - return -} - -// Merge merges a second Set into the base. -// -// Duplicate credential names are not allow and will result in an -// error, this is the case even if the values are identical. -func (s Set) Merge(s2 Set) error { - for k, v := range s2 { - if _, ok := s[k]; ok { - return fmt.Errorf("ambiguous credential resolution: %q is already present in base credential sets, cannot merge", k) - } - s[k] = v - } - return nil -} - -// CredentialSet represents a collection of credentials -type CredentialSet struct { - // Name is the name of the credentialset. - Name string `json:"name" yaml:"name"` - // Creadentials is a list of credential specs. - Credentials []CredentialStrategy `json:"credentials" yaml:"credentials"` -} - -// Load a CredentialSet from a file at a given path. -// -// It does not load the individual credentials. -func Load(path string) (*CredentialSet, error) { - cset := &CredentialSet{} - data, err := ioutil.ReadFile(path) - if err != nil { - return cset, err - } - return cset, yaml.Unmarshal(data, cset) -} - -// Validate compares the given credentials with the spec. -// -// This will result in an error only if: -// - a parameter in the spec is not present in the given set -// - a parameter in the given set does not match the format required by the spec -// -// It is allowed for spec to specify both an env var and a file. In such case, if -// the givn set provides either, it will be considered valid. -func Validate(given Set, spec map[string]bundle.Location) error { - for name := range spec { - if !isValidCred(given, name) { - return fmt.Errorf("bundle requires credential for %s", name) - } - } - return nil -} - -func isValidCred(haystack Set, needle string) bool { - for name := range haystack { - if name == needle { - return true - } - } - return false -} - -// Resolve looks up the credentials as described in Source, then copies -// the resulting value into the Value field of each credential strategy. -// -// The typical workflow for working with a credential set is: -// -// - Load the set -// - Validate the credentials against a spec -// - Resolve the credentials -// - Expand them into bundle values -func (c *CredentialSet) Resolve() (Set, error) { - l := len(c.Credentials) - res := make(map[string]string, l) - for i := 0; i < l; i++ { - cred := c.Credentials[i] - src := cred.Source - // Precedence is Command, Path, EnvVar, Value - switch { - case src.Command != "": - data, err := execCmd(src.Command) - if err != nil { - return res, err - } - cred.Value = string(data) - case src.Path != "": - data, err := ioutil.ReadFile(os.ExpandEnv(src.Path)) - if err != nil { - return res, fmt.Errorf("credential %q: %s", c.Credentials[i].Name, err) - } - cred.Value = string(data) - case src.EnvVar != "": - var ok bool - cred.Value, ok = os.LookupEnv(src.EnvVar) - if ok { - break - } - fallthrough - default: - cred.Value = src.Value - } - res[c.Credentials[i].Name] = cred.Value - } - return res, nil -} - -func execCmd(cmd string) ([]byte, error) { - parts := strings.Split(cmd, " ") - c := parts[0] - args := parts[1:] - run := exec.Command(c, args...) - - return run.CombinedOutput() -} - -// CredentialStrategy represents a source credential and the destination to which it should be sent. -type CredentialStrategy struct { - // Name is the name of the credential. - // Name is used to match a credential strategy to a bundle's credential. - Name string `json:"name" yaml:"name"` - // Source is the location of the credential. - // During resolution, the source will be loaded, and the result temporarily placed - // into Value. - Source Source `json:"source,omitempty" yaml:"source,omitempty"` - // Value holds the credential value. - // When a credential is loaded, it is loaded into this field. In all - // other cases, it is empty. This field is omitted during serialization. - Value string `json:"-" yaml:"-"` -} - -// Source represents a strategy for loading a credential from local host. -type Source struct { - Path string `json:"path,omitempty" yaml:"path,omitempty"` - Command string `json:"command,omitempty" yaml:"command,omitempty"` - Value string `json:"value,omitempty" yaml:"value,omitempty"` - EnvVar string `json:"env,omitempty" yaml:"env,omitempty"` -} - -// Destination reprents a strategy for injecting a credential into an image. -type Destination struct { - Value string `json:"value,omitempty" yaml:"value,omitempty"` -} diff --git a/pkg/credentials/credentialset_test.go b/pkg/credentials/credentialset_test.go deleted file mode 100644 index cb3a5fd9..00000000 --- a/pkg/credentials/credentialset_test.go +++ /dev/null @@ -1,127 +0,0 @@ -package credentials - -import ( - "fmt" - "os" - "runtime" - "strings" - "testing" - - "github.com/deislabs/cnab-go/bundle" - - "github.com/stretchr/testify/assert" -) - -func TestCredentialSet(t *testing.T) { - is := assert.New(t) - if err := os.Setenv("TEST_USE_VAR", "kakapu"); err != nil { - t.Fatal("could not setup env") - } - defer os.Unsetenv("TEST_USE_VAR") - - goos := "unix" - if runtime.GOOS == "windows" { - goos = runtime.GOOS - } - credset, err := Load(fmt.Sprintf("testdata/staging-%s.yaml", goos)) - is.NoError(err) - - results, err := credset.Resolve() - if err != nil { - t.Fatal(err) - } - count := 5 - is.Len(results, count, "Expected %d credentials", count) - - for _, tt := range []struct { - name string - key string - expect string - path string - }{ - {name: "run_program", key: "TEST_RUN_PROGRAM", expect: "wildebeest"}, - {name: "use_var", key: "TEST_USE_VAR", expect: "kakapu"}, - {name: "read_file", key: "TEST_READ_FILE", expect: "serval"}, - {name: "fallthrough", key: "TEST_FALLTHROUGH", expect: "quokka", path: "/animals/quokka.txt"}, - {name: "plain_value", key: "TEST_PLAIN_VALUE", expect: "cassowary"}, - } { - dest, ok := results[tt.name] - is.True(ok) - is.Equal(tt.expect, strings.TrimSpace(dest)) - } -} - -func TestCredentialSet_Expand(t *testing.T) { - b := &bundle.Bundle{ - Name: "knapsack", - Credentials: map[string]bundle.Location{ - "first": { - EnvironmentVariable: "FIRST_VAR", - }, - "second": { - Path: "/second/path", - }, - "third": { - EnvironmentVariable: "/THIRD_VAR", - Path: "/third/path", - }, - }, - } - cs := Set{ - "first": "first", - "second": "second", - "third": "third", - } - - env, path, err := cs.Expand(b, false) - is := assert.New(t) - is.NoError(err) - for k, v := range b.Credentials { - if v.EnvironmentVariable != "" { - is.Equal(env[v.EnvironmentVariable], cs[k]) - } - if v.Path != "" { - is.Equal(path[v.Path], cs[k]) - } - } -} - -func TestCredentialSet_Merge(t *testing.T) { - cs := Set{ - "first": "first", - "second": "second", - "third": "third", - } - - is := assert.New(t) - - err := cs.Merge(Set{}) - is.NoError(err) - is.Len(cs, 3) - is.NotContains(cs, "fourth") - - err = cs.Merge(Set{"fourth": "fourth"}) - is.NoError(err) - is.Len(cs, 4) - is.Contains(cs, "fourth") - - err = cs.Merge(Set{"second": "bis"}) - is.EqualError(err, `ambiguous credential resolution: "second" is already present in base credential sets, cannot merge`) - -} - -func TestCredentialSetMissingCred(t *testing.T) { - b := &bundle.Bundle{ - Name: "knapsack", - Credentials: map[string]bundle.Location{ - "first": { - EnvironmentVariable: "FIRST_VAR", - }, - }, - } - cs := Set{} - _, _, err := cs.Expand(b, false) - assert.EqualError(t, err, `credential "first" is missing from the user-supplied credentials`) - _, _, err = cs.Expand(b, true) - assert.NoError(t, err) -} diff --git a/pkg/credentials/testdata/someconfig.txt b/pkg/credentials/testdata/someconfig.txt deleted file mode 100644 index 1b8ede8c..00000000 --- a/pkg/credentials/testdata/someconfig.txt +++ /dev/null @@ -1 +0,0 @@ -serval \ No newline at end of file diff --git a/pkg/credentials/testdata/staging-unix.yaml b/pkg/credentials/testdata/staging-unix.yaml deleted file mode 100644 index 4d36b4a9..00000000 --- a/pkg/credentials/testdata/staging-unix.yaml +++ /dev/null @@ -1,19 +0,0 @@ -name: staging -credentials: - - name: read_file - source: - path: $GOPATH/src/github.com/deislabs/duffle/pkg/credentials/testdata/someconfig.txt - - name: run_program - source: - command: "echo wildebeest" - - name: use_var - source: - env: TEST_USE_VAR - value: "this space intentionally left non-blank" - - name: fallthrough - source: - name: NO_SUCH_VAR - value: quokka - - name: plain_value - source: - value: cassowary diff --git a/pkg/credentials/testdata/staging-windows.yaml b/pkg/credentials/testdata/staging-windows.yaml deleted file mode 100644 index 1d3359c9..00000000 --- a/pkg/credentials/testdata/staging-windows.yaml +++ /dev/null @@ -1,19 +0,0 @@ -name: staging -credentials: - - name: read_file - source: - path: $GOPATH/src/github.com/deislabs/duffle/pkg/credentials/testdata/someconfig.txt - - name: run_program - source: - command: "cmd.exe /c echo wildebeest" - - name: use_var - source: - env: TEST_USE_VAR - value: "this space intentionally left non-blank" - - name: fallthrough - source: - name: NO_SUCH_VAR - value: quokka - - name: plain_value - source: - value: cassowary diff --git a/pkg/driver/command_driver.go b/pkg/driver/command_driver.go index 86353e27..930e84f0 100644 --- a/pkg/driver/command_driver.go +++ b/pkg/driver/command_driver.go @@ -7,6 +7,8 @@ import ( "os" "os/exec" "strings" + + "github.com/deislabs/cnab-go/driver" ) // CommandDriver relies upon a system command to provide a driver implementation @@ -15,7 +17,7 @@ type CommandDriver struct { } // Run executes the command -func (d *CommandDriver) Run(op *Operation) error { +func (d *CommandDriver) Run(op *driver.Operation) error { return d.exec(op) } @@ -39,7 +41,7 @@ func (d *CommandDriver) cliName() string { return "duffle-" + strings.ToLower(d.Name) } -func (d *CommandDriver) exec(op *Operation) error { +func (d *CommandDriver) exec(op *driver.Operation) error { // We need to do two things here: We need to make it easier for the // command to access data, and we need to make it easy for the command // to pass that data on to the image it invokes. So we do some data diff --git a/pkg/driver/command_driver_test.go b/pkg/driver/command_driver_test.go index 7451f5c5..9c1266bb 100644 --- a/pkg/driver/command_driver_test.go +++ b/pkg/driver/command_driver_test.go @@ -1,3 +1,5 @@ package driver -var _ Driver = &CommandDriver{} +import "github.com/deislabs/cnab-go/driver" + +var _ driver.Driver = &CommandDriver{} diff --git a/pkg/driver/docker_driver.go b/pkg/driver/docker_driver.go index 720e5a63..a03c12f2 100644 --- a/pkg/driver/docker_driver.go +++ b/pkg/driver/docker_driver.go @@ -9,6 +9,7 @@ import ( "os" unix_path "path" + "github.com/deislabs/cnab-go/driver" "github.com/docker/cli/cli/command" cliflags "github.com/docker/cli/cli/flags" "github.com/docker/distribution/reference" @@ -33,13 +34,13 @@ type DockerDriver struct { } // Run executes the Docker driver -func (d *DockerDriver) Run(op *Operation) error { +func (d *DockerDriver) Run(op *driver.Operation) error { return d.exec(op) } // Handles indicates that the Docker driver supports "docker" and "oci" func (d *DockerDriver) Handles(dt string) bool { - return dt == ImageTypeDocker || dt == ImageTypeOCI + return dt == driver.ImageTypeDocker || dt == driver.ImageTypeOCI } // AddConfigurationOptions adds configuration callbacks to the driver @@ -123,7 +124,7 @@ func (d *DockerDriver) initializeDockerCli() (command.Cli, error) { return cli, nil } -func (d *DockerDriver) exec(op *Operation) error { +func (d *DockerDriver) exec(op *driver.Operation) error { ctx := context.Background() cli, err := d.initializeDockerCli() diff --git a/pkg/driver/driver.go b/pkg/driver/driver.go deleted file mode 100644 index 069af05e..00000000 --- a/pkg/driver/driver.go +++ /dev/null @@ -1,110 +0,0 @@ -package driver - -import ( - "fmt" - "io" - - "github.com/docker/go/canonical/json" -) - -// ImageType constants provide some of the image types supported -// TODO: I think we can remove all but Docker, since the rest are supported externally -const ( - ImageTypeDocker = "docker" - ImageTypeOCI = "oci" - ImageTypeQCOW = "qcow" -) - -// Lookup takes a driver name and tries to resolve the most pertinent driver. -func Lookup(name string) (Driver, error) { - switch name { - case "docker": - return &DockerDriver{}, nil - case "debug": - return &DebugDriver{}, nil - case "command": - return &CommandDriver{Name: name}, nil - default: - return nil, fmt.Errorf("unsupported driver: %s", name) - } -} - -// Operation describes the data passed into the driver to run an operation -type Operation struct { - // Installation is the name of this installation - Installation string `json:"installation_name"` - // The revision ID for this installation - Revision string `json:"revision"` - // Action is the action to be performed - Action string `json:"action"` - // Parameters are the parameters to be injected into the container - Parameters map[string]interface{} `json:"parameters"` - // Image is the invocation image - Image string `json:"image"` - // ImageType is the type of image. - ImageType string `json:"image_type"` - // Environment contains environment variables that should be injected into the invocation image - Environment map[string]string `json:"environment"` - // Files contains files that should be injected into the invocation image. - Files map[string]string `json:"files"` - // Output stream for log messages from the driver - Out io.Writer -} - -// ResolvedCred is a credential that has been resolved and is ready for injection into the runtime. -type ResolvedCred struct { - Type string `json:"type"` - Name string `json:"name"` - Value string `json:"value"` -} - -// Driver is capable of running a invocation image -type Driver interface { - // Run executes the operation inside of the invocation image - Run(*Operation) error - // Handles receives an ImageType* and answers whether this driver supports that type - Handles(string) bool -} - -// Configurable drivers can explain their configuration, and have it explicitly set -type Configurable interface { - // Config returns a map of configuration names and values that can be set via environment variable - Config() map[string]string - // SetConfig allows setting configuration, where name corresponds to the key in Config, and value is - // the value to be set. - SetConfig(map[string]string) -} - -// DebugDriver prints the information passed to a driver -// -// It does not ever run the image. -type DebugDriver struct { - config map[string]string -} - -// Run executes the operation on the Debug driver -func (d *DebugDriver) Run(op *Operation) error { - data, err := json.MarshalIndent(op, "", " ") - if err != nil { - return err - } - fmt.Fprintln(op.Out, string(data)) - return nil -} - -// Handles always returns true, effectively claiming to work for any image type -func (d *DebugDriver) Handles(dt string) bool { - return true -} - -// Config returns the configuration help text -func (d *DebugDriver) Config() map[string]string { - return map[string]string{ - "VERBOSE": "Increase verbosity. true, false are supported values", - } -} - -// SetConfig sets configuration for this driver -func (d *DebugDriver) SetConfig(settings map[string]string) { - d.config = settings -} diff --git a/pkg/driver/driver_test.go b/pkg/driver/driver_test.go deleted file mode 100644 index 0392b609..00000000 --- a/pkg/driver/driver_test.go +++ /dev/null @@ -1,80 +0,0 @@ -package driver - -import ( - "io/ioutil" - "testing" - - "github.com/stretchr/testify/assert" -) - -var _ Driver = &DockerDriver{} -var _ Driver = &DebugDriver{} - -func TestLookup_UnsupportedDriver(t *testing.T) { - d, err := Lookup("no_such_driver") - - assert.Nil(t, d) - assert.Error(t, err) -} - -func TestLookup_CommandDriver(t *testing.T) { - d, err := Lookup("command") - - assert.NoError(t, err) - assert.IsType(t, d, &CommandDriver{}) -} - -func TestDebugDriver_Handles(t *testing.T) { - d, err := Lookup("debug") - is := assert.New(t) - is.NoError(err) - is.NotNil(d) - is.True(d.Handles(ImageTypeDocker)) - is.True(d.Handles("anything")) -} - -func TestDebugDriver_Run(t *testing.T) { - d, err := Lookup("debug") - is := assert.New(t) - is.NoError(err) - is.NotNil(d) - - op := &Operation{ - Installation: "test", - Image: "test:1.2.3", - ImageType: "oci", - Out: ioutil.Discard, - } - is.NoError(d.Run(op)) -} - -func TestDockerDriver_Handles(t *testing.T) { - d, err := Lookup("docker") - is := assert.New(t) - is.NoError(err) - is.NotNil(d) - is.True(d.Handles(ImageTypeDocker)) - is.False(d.Handles(ImageTypeQCOW)) - is.False(d.Handles("anything")) -} - -func TestDockerDriver_Run(t *testing.T) { - d, err := Lookup("docker") - - // Don't actually run Docker - d.(*DockerDriver).Simulate = true - - is := assert.New(t) - is.NoError(err) - is.NotNil(d) - - op := &Operation{ - Installation: "test", - Image: "test:1.2.3", - ImageType: "oci", - Environment: map[string]string{}, - Files: map[string]string{}, - Out: ioutil.Discard, - } - is.NoError(d.Run(op)) -} diff --git a/pkg/driver/lookup.go b/pkg/driver/lookup.go new file mode 100644 index 00000000..de58fe9d --- /dev/null +++ b/pkg/driver/lookup.go @@ -0,0 +1,21 @@ +package driver + +import ( + "fmt" + + "github.com/deislabs/cnab-go/driver" +) + +// Lookup takes a driver name and tries to resolve the most pertinent driver. +func Lookup(name string) (driver.Driver, error) { + switch name { + case "docker": + return &DockerDriver{}, nil + case "debug": + return &driver.DebugDriver{}, nil + case "command": + return &CommandDriver{Name: name}, nil + default: + return nil, fmt.Errorf("unsupported driver: %s", name) + } +} diff --git a/pkg/utils/crud/filesystem.go b/pkg/utils/crud/filesystem.go deleted file mode 100644 index ac8d9cb5..00000000 --- a/pkg/utils/crud/filesystem.go +++ /dev/null @@ -1,115 +0,0 @@ -package crud - -import ( - "errors" - "fmt" - "io/ioutil" - "os" - "path/filepath" - "strings" -) - -// ErrFileDoesNotExist represents when file path is not found on file system -var ErrFileDoesNotExist = errors.New(`File does not exist`) - -// NewFileSystemStore creates a Store backed by a file system directory. -// Each key is represented by a file in that directory. -func NewFileSystemStore(baseDirectory string, fileExtension string) Store { - return fileSystemStore{ - baseDirectory: baseDirectory, - fileExtension: fileExtension, - } -} - -type fileSystemStore struct { - baseDirectory string - fileExtension string -} - -func (s fileSystemStore) List() ([]string, error) { - if err := s.ensure(); err != nil { - return nil, err - } - - files, err := ioutil.ReadDir(s.baseDirectory) - if err != nil { - return []string{}, err - } - - return names(s.storageFiles(files)), nil -} - -func (s fileSystemStore) Store(name string, data []byte) error { - filename, err := s.fullyQualifiedName(name) - if err != nil { - return err - } - - return ioutil.WriteFile(filename, data, os.ModePerm) -} - -func (s fileSystemStore) Read(name string) ([]byte, error) { - filename, err := s.fullyQualifiedName(name) - if err != nil { - return nil, err - } - - if _, err := os.Stat(filename); os.IsNotExist(err) { - return nil, ErrFileDoesNotExist - } - - return ioutil.ReadFile(filename) -} - -func (s fileSystemStore) Delete(name string) error { - filename, err := s.fullyQualifiedName(name) - if err != nil { - return err - } - return os.Remove(filename) -} - -func (s fileSystemStore) fileNameOf(name string) string { - return filepath.Join(s.baseDirectory, fmt.Sprintf("%s.%s", name, s.fileExtension)) -} - -func (s fileSystemStore) fullyQualifiedName(name string) (string, error) { - if err := s.ensure(); err != nil { - return "", err - } - return s.fileNameOf(name), nil -} - -func (s fileSystemStore) ensure() error { - fi, err := os.Stat(s.baseDirectory) - if err == nil { - if fi.IsDir() { - return nil - } - return errors.New("Storage directory name exists, but is not a directory") - } - return os.MkdirAll(s.baseDirectory, os.ModePerm) -} - -func (s fileSystemStore) storageFiles(files []os.FileInfo) []os.FileInfo { - result := make([]os.FileInfo, 0) - ext := "." + s.fileExtension - for _, file := range files { - if !file.IsDir() && filepath.Ext(file.Name()) == ext { - result = append(result, file) - } - } - return result -} - -func names(files []os.FileInfo) []string { - result := make([]string, 0) - for _, file := range files { - result = append(result, name(file.Name())) - } - return result -} - -func name(filename string) string { - return strings.TrimSuffix(filepath.Base(filename), filepath.Ext(filename)) -} diff --git a/pkg/utils/crud/filesystem_test.go b/pkg/utils/crud/filesystem_test.go deleted file mode 100644 index 7979fa75..00000000 --- a/pkg/utils/crud/filesystem_test.go +++ /dev/null @@ -1,32 +0,0 @@ -package crud - -import ( - "io/ioutil" - "os" - "testing" - - "github.com/stretchr/testify/assert" -) - -var _ Store = &fileSystemStore{} - -func TestFilesystemStore(t *testing.T) { - is := assert.New(t) - tmdir, err := ioutil.TempDir("", "duffle-test-") - is.NoError(err) - defer os.RemoveAll(tmdir) - s := NewFileSystemStore(tmdir, "data") - key := "testkey" - val := []byte("testval") - is.NoError(s.Store(key, val)) - list, err := s.List() - is.NoError(err) - is.Len(list, 1) - d, err := s.Read("testkey") - is.NoError(err) - is.Equal([]byte("testval"), d) - is.NoError(s.Delete(key)) - list, err = s.List() - is.NoError(err) - is.Len(list, 0) -} diff --git a/pkg/utils/crud/store.go b/pkg/utils/crud/store.go deleted file mode 100644 index e9eb128e..00000000 --- a/pkg/utils/crud/store.go +++ /dev/null @@ -1,9 +0,0 @@ -package crud - -// Store is a simplified interface to a key-blob store supporting CRUD operations. -type Store interface { - List() ([]string, error) - Store(name string, data []byte) error - Read(name string) ([]byte, error) - Delete(name string) error -} diff --git a/pkg/utils/crud/store_test.go b/pkg/utils/crud/store_test.go deleted file mode 100644 index 1b76cb1b..00000000 --- a/pkg/utils/crud/store_test.go +++ /dev/null @@ -1,45 +0,0 @@ -package crud - -import ( - "testing" - - "github.com/stretchr/testify/assert" -) - -// The main point of these tests is to catch any case where the interface -// changes. But we also provide a mock for testing. -var _ Store = &MockStore{} - -func TestMockStore(t *testing.T) { - s := NewMockStore() - is := assert.New(t) - is.NoError(s.Store("test", []byte("data"))) - list, err := s.List() - is.NoError(err) - is.Len(list, 1) - data, err := s.Read("test") - is.NoError(err) - is.Equal(data, []byte("data")) - -} - -type MockStore struct { - data map[string][]byte -} - -func NewMockStore() *MockStore { - return &MockStore{data: map[string][]byte{}} -} - -func (s *MockStore) List() ([]string, error) { - buf := make([]string, len(s.data)) - i := 0 - for k := range s.data { - buf[i] = k - i++ - } - return buf, nil -} -func (s *MockStore) Store(name string, data []byte) error { s.data[name] = data; return nil } -func (s *MockStore) Read(name string) ([]byte, error) { return s.data[name], nil } -func (s *MockStore) Delete(name string) error { delete(s.data, name); return nil }