diff --git a/.github/workflows/dev-container.yml b/.github/workflows/dev-container.yml index a5b0d88..677a604 100644 --- a/.github/workflows/dev-container.yml +++ b/.github/workflows/dev-container.yml @@ -11,6 +11,10 @@ jobs: docker_build: name: Docker Build & Publish runs-on: ubuntu-latest + matrix: + dockerfile: + - dev-container + - legacy steps: - uses: actions/checkout@master diff --git a/go.mod b/go.mod index e93c553..2dd4837 100644 --- a/go.mod +++ b/go.mod @@ -5,8 +5,16 @@ go 1.15 require ( github.com/bwmarrin/discordgo v0.23.2 github.com/dghubble/trie v0.0.0-20201011220304-ed6d6b8add55 + github.com/google/go-cmp v0.5.4 // indirect github.com/joho/godotenv v1.3.0 + github.com/kr/pretty v0.1.0 // indirect github.com/lampjaw/discordclient v0.0.0-20210312234541-165fc2e57e2b github.com/onsi/gomega v1.11.0 + golang.org/x/net v0.0.0-20201224014010-6772e930b67b // indirect + golang.org/x/sys v0.0.0-20210225134936-a50acf3fe073 // indirect + golang.org/x/text v0.3.4 // indirect + golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect + google.golang.org/protobuf v1.25.0 // indirect + gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 // indirect k8s.io/klog v1.0.0 ) diff --git a/go.sum b/go.sum index 1daecc4..306bf24 100644 --- a/go.sum +++ b/go.sum @@ -1,27 +1,46 @@ +cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/bwmarrin/discordgo v0.23.2 h1:BzrtTktixGHIu9Tt7dEE6diysEF9HWnXeHuoJEt2fH4= github.com/bwmarrin/discordgo v0.23.2/go.mod h1:c1WtWUGN6nREDmzIpyTp/iD3VYt4Fpx+bVyfBG7JE+M= +github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= +github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/dghubble/trie v0.0.0-20201011220304-ed6d6b8add55 h1:3yKntgWb7KwnHd4nCVgCIUNQs4qRdua+jitRqGMxKys= github.com/dghubble/trie v0.0.0-20201011220304-ed6d6b8add55/go.mod h1:xNBeoT4V92/aNvuC3IJ2g59uxuKP4/kzvkpoHrb7v4A= +github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= +github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= github.com/go-logr/logr v0.1.0/go.mod h1:ixOQHD9gLJUVQQ2ZOR7zLEifBX6tGkNJF4QyIY7sIas= +github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= +github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= +github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= github.com/golang/protobuf v1.4.3 h1:JjCZWpVbqXDqFVmTfYWEVTMIYrL/NPdPSCHPJ0T/raM= github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= +github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.4.0 h1:xsAVV57WRhGj6kEIi8ReJzQlHHqcBYCElAvkovg3B/4= github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.4 h1:L8R9j+yAqZuZjsqh/z+F1NCffTKKLShY6zXTItVIZ8M= +github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/gorilla/websocket v1.4.0 h1:WDFjx/TMzVgy9VdMMQi2K2Emtwi2QcUQsztZ/zLaH/Q= github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/joho/godotenv v1.3.0 h1:Zjp+RcGpHhGlrMbJzXTrZZPrWj+1vfm90La1wgB6Bhc= github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg= +github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= +github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= +github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= +github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/lampjaw/discordclient v0.0.0-20210312234541-165fc2e57e2b h1:SDLw5YNtl6n7eArjurP/yLgMBA4qT4hBIJ5YuROaizY= github.com/lampjaw/discordclient v0.0.0-20210312234541-165fc2e57e2b/go.mod h1:li2xX5VLDvw1fPoYpA3nTShwnLbYrcSzso9dOSnZ3Iw= github.com/nxadm/tail v1.4.4 h1:DQuhQpB1tVlglWS2hLQ5OV6B5r8aGxSrPc5Qo6uTN78= @@ -32,15 +51,30 @@ github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108 github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= github.com/onsi/gomega v1.11.0 h1:+CqWgvj0OZycCaqclBD1pxKHAU+tOkHmQIWvDHq2aug= github.com/onsi/gomega v1.11.0/go.mod h1:azGKhqFUon9Vuj0YmTfLSmx0FUwqXYSTl5re8lQLTUg= +github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= golang.org/x/crypto v0.0.0-20181030102418-4d3f4d9ffa16/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9 h1:psW17arqaxU48Z5kZ0CQnkZWQJsqcURM6tKiBApRjXI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= +golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= +golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= +golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20201202161906-c7110b5ffcbb h1:eBmm0M9fYhWpKZLjQUUKka/LtIxf46G4fxeEz5KJr9U= golang.org/x/net v0.0.0-20201202161906-c7110b5ffcbb/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.0.0-20201224014010-6772e930b67b h1:iFwSg7t5GZmB/Q5TjiEAsdoLDrdJRC1RiF2WhuV29Qw= +golang.org/x/net v0.0.0-20201224014010-6772e930b67b/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= +golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -48,26 +82,54 @@ golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f h1:+Nyd8tzPX9R7BWHguqsrbFdRx3WQ/1ib8I44HXV5yTA= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210225134936-a50acf3fe073 h1:8qxJSnu+7dRq6upnbntrmriWByIakBuct5OM/MdQC1M= +golang.org/x/sys v0.0.0-20210225134936-a50acf3fe073/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3 h1:cokOdA+Jmi5PJGXLlLllQSgYigAEfHXJAERHVMaCc2k= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.4 h1:0YWbFKbhXG/wIiuHDSKpS0Iy7FSA+u45VtBMfQcFTTc= +golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= +golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= +google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= +google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= +google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= +google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= +google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= +google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= +google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= +google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= google.golang.org/protobuf v1.23.0 h1:4MY060fB1DLGMB/7MBTLnwQUY6+F09GEiz6SsrNqyzM= google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.25.0 h1:Ejskq+SyPohKW+1uil0JJMtmHCgJPJ/qWTxr8qp+R4c= +google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= +gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= +honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= k8s.io/klog v1.0.0 h1:Pt+yjF5aB1xDSVbau4VsWe+dQNzA0qv1LlXdC2dF6Q8= k8s.io/klog v1.0.0/go.mod h1:4Bi6QPql/J/LkTDqv7R/cd3hPo4k2DG6Ptcz060Ez5I= diff --git a/hack/dockerfiles/legacy.Dockerfile b/hack/dockerfiles/legacy.Dockerfile new file mode 100644 index 0000000..6d9fd3e --- /dev/null +++ b/hack/dockerfiles/legacy.Dockerfile @@ -0,0 +1,47 @@ +FROM golang:1.15-alpine AS base + +# Create the user and group files that will be used in the running container to +# run the process as an unprivileged user. +RUN mkdir /user \ + && echo 'nobody:x:65534:65534:nobody:/:' >/user/passwd \ + && echo 'nobody:x:65534:' >/user/group + +# Install the Certificate-Authority certificates for the app to be able to make +# calls to HTTPS endpoints. +# Git is required for fetching the dependencies. +RUN apk add --no-cache ca-certificates git + +# Set the working directory outside $GOPATH to enable the support for modules. +WORKDIR /src + +# Fetch dependencies first; they are less susceptible to change on every build +# and will therefore be cached for speeding up the next build +COPY ./go.mod ./go.sum ./ +RUN go mod download + +# Import the code from the context. +COPY ./ ./ + +FROM base AS export-to-gcs + +RUN CGO_ENABLED=0 go build \ + -installsuffix "static" \ + -o /export-to-gcs ./src/legacy/export-to-gcs + +# Final stage: the running container. +FROM scratch AS final + +# Import the user and group files from the first stage. +COPY --from=base /user/group /user/passwd /etc/ + +# Import the Certificate-Authority certificates for enabling HTTPS. +COPY --from=base /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ + +# Import the compiled executable from the first stage. +COPY --from=export-to-gcs /export-to-gcs /export-to-gcs + +# Perform any further action as an unprivileged user. +USER nobody:nobody + +# Run the compiled binary. +ENTRYPOINT ["/export-to-gcs"] diff --git a/packages/api/handlers/sync-from-legacy.ts b/packages/api/handlers/sync-from-legacy.ts new file mode 100644 index 0000000..94444f7 --- /dev/null +++ b/packages/api/handlers/sync-from-legacy.ts @@ -0,0 +1,60 @@ +import { + Features, + GuildData as GuildDataT, + UserGuildPermissions, +} from '@roleypoly/types'; +import { isRoot, respond, withSession } from '../utils/api-tools'; +import { fetchLegacyServer, transformLegacyGuild } from '../utils/import-from-legacy'; +import { GuildData } from '../utils/kv'; + +const noPermissions = () => + respond({ error: 'no permissions to this guild' }, { status: 403 }); +const notFound = () => respond({ error: 'guild not found' }, { status: 404 }); +const alreadyImported = () => + respond({ error: 'guild already imported' }, { status: 400 }); + +export const SyncFromLegacy = withSession( + (session) => async (request: Request): Promise => { + const url = new URL(request.url); + const [, , guildID] = url.pathname.split('/'); + + // Allow root users to trigger this too, just in case. + if (!isRoot(session.user.id)) { + const guild = session.guilds.find((guild) => guild.id === guildID); + if (!guild) { + return notFound(); + } + + if ( + guild?.permissionLevel !== UserGuildPermissions.Manager || + guild?.permissionLevel !== UserGuildPermissions.Admin + ) { + return noPermissions(); + } + } + + const shouldForce = url.searchParams.get('force') === 'yes'; + + // Not using getGuildData as we want null feedback, not a zeroed out object. + const checkGuild = await GuildData.get(guildID); + // Don't force, and guild exists in our side, but LegacyGuild flag is set, + // fail this request. + if ( + !shouldForce && + checkGuild && + (checkGuild.features & Features.LegacyGuild) === Features.LegacyGuild + ) { + return alreadyImported(); + } + + const legacyGuild = await fetchLegacyServer(guildID); + if (!legacyGuild) { + return notFound(); + } + + const newGuildData = transformLegacyGuild(legacyGuild); + await GuildData.put(guildID, newGuildData); + + return respond({ ok: true }); + } +); diff --git a/packages/api/index.ts b/packages/api/index.ts index bb809ea..f854a06 100644 --- a/packages/api/index.ts +++ b/packages/api/index.ts @@ -6,6 +6,7 @@ import { GetSlug } from './handlers/get-slug'; import { LoginBounce } from './handlers/login-bounce'; import { LoginCallback } from './handlers/login-callback'; import { RevokeSession } from './handlers/revoke-session'; +import { SyncFromLegacy } from './handlers/sync-from-legacy'; import { UpdateRoles } from './handlers/update-roles'; import { Router } from './router'; import { respond } from './utils/api-tools'; @@ -26,6 +27,7 @@ router.add('POST', 'revoke-session', RevokeSession); router.add('GET', 'get-slug', GetSlug); router.add('GET', 'get-picker-data', GetPickerData); router.add('PATCH', 'update-roles', UpdateRoles); +router.add('POST', 'sync-from-legacy', SyncFromLegacy); // Root users only router.add('GET', 'x-create-roleypoly-data', CreateRoleypolyData); diff --git a/packages/api/package.json b/packages/api/package.json index 0be4316..05d34f8 100644 --- a/packages/api/package.json +++ b/packages/api/package.json @@ -4,7 +4,7 @@ "scripts": { "build": "yarn workspace @roleypoly/worker-emulator build --basePath `pwd`", "lint:types": "tsc --noEmit", - "start": "yarn workspace @roleypoly/worker-emulator start --basePath `pwd`" + "start": "cfw-emulator" }, "devDependencies": { "@cloudflare/workers-types": "^2.2.1", diff --git a/packages/api/utils/config.ts b/packages/api/utils/config.ts index 1fdb774..e04fae8 100644 --- a/packages/api/utils/config.ts +++ b/packages/api/utils/config.ts @@ -12,3 +12,4 @@ export const uiPublicURI = safeURI(env('UI_PUBLIC_URI')); export const apiPublicURI = safeURI(env('API_PUBLIC_URI')); export const rootUsers = list(env('ROOT_USERS')); export const allowedCallbackHosts = list(env('ALLOWED_CALLBACK_HOSTS')); +export const importSharedKey = env('BOT_IMPORT_TOKEN'); diff --git a/packages/api/utils/import-from-legacy.ts b/packages/api/utils/import-from-legacy.ts new file mode 100644 index 0000000..5c559ab --- /dev/null +++ b/packages/api/utils/import-from-legacy.ts @@ -0,0 +1,54 @@ +import { sortBy } from '@roleypoly/misc-utils/sortBy'; +import { CategoryType, Features, GuildData } from '@roleypoly/types'; +import KSUID from 'ksuid'; +import { importSharedKey } from './config'; + +export type LegacyCategory = { + id: string; + name: string; + roles: string[]; + hidden: boolean; + type: 'single' | 'multi'; + position: number; +}; + +export type LegacyGuildData = { + id: string; + categories: LegacyCategory[]; + message: string; +}; + +export const fetchLegacyServer = async (id: string): Promise => { + const guildDataResponse = await fetch( + `https://beta.roleypoly.com/x/import-to-next/${id}`, + { + headers: { + authorization: `Shared ${importSharedKey}`, + }, + } + ); + + if (guildDataResponse.status === 404) { + return null; + } + + if (guildDataResponse.status !== 200) { + throw new Error('Guild data fetch failed'); + } + + return await guildDataResponse.json(); +}; + +export const transformLegacyGuild = (guild: LegacyGuildData): GuildData => { + return { + id: guild.id, + message: guild.message, + features: Features.LegacyGuild, + categories: sortBy(guild.categories, 'position').map((category, idx) => ({ + ...category, + id: KSUID.randomSync().string, + position: idx, // Reset positions by index. May have side-effects but oh well. + type: category.type === 'multi' ? CategoryType.Multi : CategoryType.Single, + })), + }; +}; diff --git a/packages/backend-emulator/main.js b/packages/backend-emulator/main.js old mode 100644 new mode 100755 index 4e1b80a..6f19843 --- a/packages/backend-emulator/main.js +++ b/packages/backend-emulator/main.js @@ -1,3 +1,4 @@ +#!/usr/bin/env node const path = require('path'); require('dotenv').config({ path: path.resolve(__dirname, '../../.env') }); const vm = require('vm'); @@ -11,7 +12,7 @@ const crypto = new Crypto(); const fetch = require('node-fetch'); const args = require('minimist')(process.argv.slice(2)); -const basePath = args.basePath; +const basePath = args.basePath || process.cwd(); if (!basePath) { throw new Error('--basePath is not set.'); } @@ -170,7 +171,7 @@ const rebuild = () => const watcher = chokidar.watch(path.resolve(__dirname, basePath), { ignoreInitial: true, - ignore: '**/dist', + ignore: '**/{dist,node_modules}', }); watcher.on('all', async (type, path) => { diff --git a/packages/backend-emulator/package.json b/packages/backend-emulator/package.json index 09dfc44..75e72fc 100644 --- a/packages/backend-emulator/package.json +++ b/packages/backend-emulator/package.json @@ -1,6 +1,9 @@ { "name": "@roleypoly/worker-emulator", "version": "0.1.0", + "bin": { + "cfw-emulator": "./main.js" + }, "scripts": { "build": "node main.js --build", "start": "node main.js" diff --git a/packages/types/Category.ts b/packages/types/Category.ts index 7a3feff..89b673e 100644 --- a/packages/types/Category.ts +++ b/packages/types/Category.ts @@ -1,6 +1,6 @@ export enum CategoryType { - Single = 0, - Multi, + Multi = 0, + Single = 1, } export type Category = { diff --git a/packages/types/Guild.ts b/packages/types/Guild.ts index 9d855fe..383c09a 100644 --- a/packages/types/Guild.ts +++ b/packages/types/Guild.ts @@ -10,8 +10,9 @@ export type Guild = { }; export enum Features { - None, + None = 0, Preview = None, + LegacyGuild = 1 << 1, } export type GuildData = { diff --git a/terraform/variables.tf b/terraform/variables.tf index b98bd6b..11a6cfb 100644 --- a/terraform/variables.tf +++ b/terraform/variables.tf @@ -30,6 +30,12 @@ variable "bot_client_secret" { sensitive = true } +variable "bot_import_token" { + type = string + description = "Bot Import Token" + sensitive = true +} + variable "bot_token" { type = string description = "Bot Client Secret" diff --git a/terraform/workers.tf b/terraform/workers.tf index 1904726..e6edc0d 100644 --- a/terraform/workers.tf +++ b/terraform/workers.tf @@ -44,6 +44,11 @@ resource "cloudflare_worker_script" "backend" { text = var.bot_token } + secret_text_binding { + name = "BOT_IMPORT_TOKEN" + text = var.bot_import_token + } + plain_text_binding { name = "UI_PUBLIC_URI" text = var.ui_public_uri