diff --git a/go.mod b/go.mod index bd3598f..2999d78 100644 --- a/go.mod +++ b/go.mod @@ -3,6 +3,7 @@ module github.com/cloudnativedaysjp/seaman go 1.19 require ( + github.com/cloudnativedaysjp/cnd-operation-server v0.0.0-20221008071418-9488b9239b80 github.com/creasty/defaults v1.6.0 github.com/go-logr/logr v1.2.3 github.com/go-logr/zapr v1.2.3 @@ -14,6 +15,8 @@ require ( go.uber.org/zap v1.23.0 golang.org/x/oauth2 v0.0.0-20221006150949-b44042a4b9c1 golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 + google.golang.org/grpc v1.50.0 + google.golang.org/protobuf v1.28.1 sigs.k8s.io/yaml v1.3.0 ) @@ -21,7 +24,7 @@ require ( github.com/go-playground/locales v0.14.0 // indirect github.com/go-playground/universal-translator v0.18.0 // indirect github.com/golang/protobuf v1.5.2 // indirect - github.com/gorilla/websocket v1.4.2 // indirect + github.com/gorilla/websocket v1.5.0 // indirect github.com/leodido/go-urn v1.2.1 // indirect github.com/shurcooL/graphql v0.0.0-20220606043923-3cf50f8a0a29 // indirect go.uber.org/atomic v1.10.0 // indirect @@ -29,10 +32,10 @@ require ( golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3 // indirect golang.org/x/mod v0.4.2 // indirect golang.org/x/net v0.0.0-20220624214902-1bab6f366d9e // indirect - golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a // indirect + golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab // indirect golang.org/x/text v0.3.7 // indirect golang.org/x/tools v0.1.1 // indirect google.golang.org/appengine v1.6.7 // indirect - google.golang.org/protobuf v1.28.0 // indirect + google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect ) diff --git a/go.sum b/go.sum index a0803e1..8a45f50 100644 --- a/go.sum +++ b/go.sum @@ -1,11 +1,19 @@ +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/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8= github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= +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/cloudnativedaysjp/cnd-operation-server v0.0.0-20221008071418-9488b9239b80 h1:3SfpCs+2JnL1D/GgYxP0fLiaeRfm3YfiaOYPVVAIzJQ= +github.com/cloudnativedaysjp/cnd-operation-server v0.0.0-20221008071418-9488b9239b80/go.mod h1:VYi5TAWjIFfmUxNcKruG8+aZP5lj566jWI5MFDASOLQ= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/creasty/defaults v1.6.0 h1:ltuE9cfphUtlrBeomuu8PEyISTXnxqkBIoQfXgv7BSc= github.com/creasty/defaults v1.6.0/go.mod h1:iGzKe6pbEHnpMPtfDXZEr0NVxWnPTjb1bbDy08fPzYM= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +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/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= github.com/go-logr/logr v1.2.3 h1:2DntVwHkVopvECVRSlL5PSo9eG+cAkDCuckLubN+rq0= github.com/go-logr/logr v1.2.3/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= @@ -21,18 +29,33 @@ github.com/go-playground/validator/v10 v10.11.1 h1:prmOlTVv+YjZjmRmNSF3VmspqJIxJ github.com/go-playground/validator/v10 v10.11.1/go.mod h1:i+3WkQ1FvaUjjxh1kSvIA4dMGDBiPU55YFDl0WbKdWU= github.com/go-test/deep v1.0.4 h1:u2CU3YKy9I2pmu9pX0eq50wCgjfGIt539SqR7FbHiho= github.com/go-test/deep v1.0.4/go.mod h1:wGDj63lr65AM2AQyKZd/NYHGb0R+1RLqB8NKt3aSFNA= +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/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc= github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs= +github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.1/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.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw= github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= +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/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.7/go.mod h1:n+brtR0CgQNWTVd5ZUFpTBC8YFBDLK/h/bpaJ8/DtOE= github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= -github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc= github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= +github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc= +github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0= @@ -49,6 +72,7 @@ github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc= github.com/rogpeppe/go-internal v1.8.0 h1:FCbCCtXNOY3UtUuHUYaghJg4y7Fd14rXifAYUAtL9R8= github.com/rogpeppe/go-internal v1.8.0/go.mod h1:WmiCO8CzOY8rg0OYDC4/i/2WRWAB6poM+XZ2dLUbcbE= @@ -81,9 +105,16 @@ golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACk golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3 h1:0es+/5331RGQPcXlMfP+WrnIIS6dNnNRe0WB02W0F4M= golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= +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/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= golang.org/x/mod v0.4.2 h1:Gz96sIWK3OalVv/I/qNygP42zyoKp3xptRVCWRFEBvo= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +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-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-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= @@ -92,12 +123,14 @@ golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96b golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20220624214902-1bab6f366d9e h1:TsQ7F31D3bUCLeqPT0u+yjp1guoArKaNKmCr22PYgTQ= golang.org/x/net v0.0.0-20220624214902-1bab6f366d9e/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= -golang.org/x/oauth2 v0.0.0-20220909003341-f21342109be1 h1:lxqLZaMad/dJHMFZH0NiNpiEZI/nhgWhe4wgzpE+MuA= -golang.org/x/oauth2 v0.0.0-20220909003341-f21342109be1/go.mod h1:h4gKUeWbJ4rQPri7E0u6Gs4e9Ri2zaLxzw5DI5XGrYg= +golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20221006150949-b44042a4b9c1 h1:3VPzK7eqH25j7GYw5w6g/GzNRc0/fYtrxz27z1gD4W0= golang.org/x/oauth2 v0.0.0-20221006150949-b44042a4b9c1/go.mod h1:h4gKUeWbJ4rQPri7E0u6Gs4e9Ri2zaLxzw5DI5XGrYg= +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/sync v0.0.0-20210220032951-036812b2e83c/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-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -106,8 +139,8 @@ golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210806184541-e5e7981a1069/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a h1:dGzPydgVsqGcTRVwiLJ1jVbufYwmzD3LfVPLKsKg+0k= -golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab h1:2QkjZIsXupsJbJIdSjjUOgWK3aEtzyuh2mPt3l/CkeU= +golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 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.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= @@ -116,7 +149,10 @@ golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= 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/tools v0.0.0-20191108193012-7d206e10da11/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.1.1 h1:wGiQel/hW0NnEkJUk8lbzkX2gFJU6PFxf1v5OlCfuOs= @@ -127,12 +163,30 @@ golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8T golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 h1:H2TDz8ibqkAF6YGhCdN3jS9O0/s90v0rJh3X/OLHEUk= golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2/go.mod h1:K8+ghG5WaK9qNqU5K3HdILfMLy1f3aNYFI/wnl100a8= +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/appengine v1.6.7 h1:FZR1q0exgwxzPzp/aF+VccGrSfxfPpkBqjIIEq3ru6c= google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= +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 h1:+kGHl1aib/qcwaRi1CbqBZ1rk19r85MNUf8HaBghugY= +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/grpc v1.50.0 h1:fPVVDxY9w++VjTZsYvXWqEf9Rqar/e+9zYfxKK+W+YU= +google.golang.org/grpc v1.50.0/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCDK+GI= +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.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.28.0 h1:w43yiav+6bVFTBQFZX0r7ipe9JQ1QsbMgHwbBziscLw= -google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +google.golang.org/protobuf v1.28.1 h1:d0NfwRgPtno5B1Wa6L2DAG+KivqkdutMf1UhdNx175w= +google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= @@ -145,5 +199,7 @@ gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +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= sigs.k8s.io/yaml v1.3.0 h1:a2VclLzOGrwOHDiV8EfBGhvjHvP46CtW5j6POvhYGGo= sigs.k8s.io/yaml v1.3.0/go.mod h1:GeOyir5tyXNByN85N/dRIT9es5UQNerPYEKK56eTBm8= diff --git a/seaman/api/broadcast.go b/seaman/api/broadcast.go new file mode 100644 index 0000000..549691f --- /dev/null +++ b/seaman/api/broadcast.go @@ -0,0 +1,6 @@ +package api + +const ( + // Action IDs + ActIdBroadcast_SceneNext = "broadcast_scenenext" +) diff --git a/seaman/controller/broadcast.go b/seaman/controller/broadcast.go new file mode 100644 index 0000000..76737ef --- /dev/null +++ b/seaman/controller/broadcast.go @@ -0,0 +1,142 @@ +package controller + +import ( + "context" + "strconv" + "strings" + + "github.com/go-logr/logr" + "github.com/slack-go/slack" + "github.com/slack-go/slack/socketmode" + "golang.org/x/xerrors" + "google.golang.org/protobuf/types/known/emptypb" + + pb "github.com/cloudnativedaysjp/cnd-operation-server/pkg/ws-proxy/schema" + + infra_cnd "github.com/cloudnativedaysjp/seaman/seaman/infra/cnd-operation-server" + infra_slack "github.com/cloudnativedaysjp/seaman/seaman/infra/slack" + "github.com/cloudnativedaysjp/seaman/seaman/utils" + "github.com/cloudnativedaysjp/seaman/seaman/view" +) + +type BroadcastController struct { + slackFactory infra_slack.SlackClientFactory + cndSceneClient pb.TrackServiceClient + cndTrackClient pb.TrackServiceClient + log logr.Logger +} + +func NewBroadcastController( + logger logr.Logger, + slackFactory infra_slack.SlackClientFactory, + cndClient infra_cnd.CndWrapper, +) *BroadcastController { + return &BroadcastController{slackFactory, cndClient, cndClient, logger} +} + +func (c *BroadcastController) ListTrack(evt *socketmode.Event, client *socketmode.Client) { + client.Ack(*evt.Request) + ev, err := getAppMentionEvent(evt) + if err != nil { + c.log.Error(err, "failed to get AppMentionEvent") + return + } + channelId := ev.Channel + messageTs := ev.TimeStamp + + // init logger & context + logger := c.log.WithValues("messageTs", messageTs) + ctx := utils.IntoContext(context.Background(), logger) + // new client from factory + sc, err := c.slackFactory.New(client.Client) + if err != nil { + logger.Error(xerrors.Errorf("message: %w", err), + "failed to initialize Slack client") + return + } + + resp, err := c.cndTrackClient.ListTrack(ctx, &emptypb.Empty{}) + if err != nil { + logger.Error(err, "cndTrackClient.ListTrack() was failed") + _ = sc.PostMessage(ctx, channelId, view.SomethingIsWrong(messageTs)) + return + } + + if err := sc.PostMessage(ctx, channelId, view.BroadcastListTrack(resp.Tracks)); err != nil { + logger.Error(xerrors.Errorf("message: %w", err), "failed to post message") + _ = sc.PostMessage(ctx, channelId, view.SomethingIsWrong(messageTs)) + return + } +} + +func (c *BroadcastController) DisableAutomation(evt *socketmode.Event, client *socketmode.Client) { + client.Ack(*evt.Request) + c.switchAutomation(evt, client, false) +} + +func (c *BroadcastController) EnableAutomation(evt *socketmode.Event, client *socketmode.Client) { + client.Ack(*evt.Request) + c.switchAutomation(evt, client, true) +} + +func (c *BroadcastController) switchAutomation(evt *socketmode.Event, client *socketmode.Client, enabled bool) { + ev, err := getAppMentionEvent(evt) + if err != nil { + c.log.Error(err, "failed to get AppMentionEvent") + return + } + channelId := ev.Channel + messageTs := ev.TimeStamp + + // init logger & context + logger := c.log.WithValues("messageTs", messageTs) + ctx := utils.IntoContext(context.Background(), logger) + // new client from factory + sc, err := c.slackFactory.New(client.Client) + if err != nil { + logger.Error(xerrors.Errorf("message: %w", err), + "failed to initialize Slack client") + return + } + // parse arguments + s := strings.Fields(ev.Text) + if !(len(s) >= 2) { + _ = sc.PostMessage(ctx, channelId, view.InvalidArguments(messageTs, + "args.length must be greater than 2")) + return + } + trackIdStr := s[1] + trackId, err := strconv.Atoi(trackIdStr) + if err != nil { + _ = sc.PostMessage(ctx, channelId, view.InvalidArguments(messageTs, + "args[1] (trackId) must be integer")) + return + } + + var msg slack.Msg + if enabled { + resp, err := c.cndTrackClient.EnableAutomation(ctx, + &pb.SwitchAutomationRequest{TrackId: int32(trackId)}) + if err != nil { + logger.Error(err, "cndTrackClient.DisableAutomation() was failed") + _ = sc.PostMessage(ctx, channelId, view.SomethingIsWrong(messageTs)) + return + } + msg = view.BroadcastEnabled(resp.TrackName) + } else { + resp, err := c.cndTrackClient.DisableAutomation(ctx, + &pb.SwitchAutomationRequest{TrackId: int32(trackId)}) + if err != nil { + logger.Error(err, "cndTrackClient.DisableAutomation() was failed") + _ = sc.PostMessage(ctx, channelId, view.SomethingIsWrong(messageTs)) + return + } + msg = view.BroadcastDisabled(resp.TrackName) + } + + if err := sc.PostMessage(ctx, channelId, msg); err != nil { + logger.Error(xerrors.Errorf("message: %w", err), "failed to post message") + _ = sc.PostMessage(ctx, channelId, view.SomethingIsWrong(messageTs)) + return + } +} diff --git a/seaman/infra/cnd-operation-server/wrapper.go b/seaman/infra/cnd-operation-server/wrapper.go new file mode 100644 index 0000000..02b6ef1 --- /dev/null +++ b/seaman/infra/cnd-operation-server/wrapper.go @@ -0,0 +1,55 @@ +package cndoperationserver + +import ( + "context" + + "google.golang.org/grpc" + "google.golang.org/protobuf/types/known/emptypb" + + pb "github.com/cloudnativedaysjp/cnd-operation-server/pkg/ws-proxy/schema" +) + +type CndWrapper struct { + Scene pb.SceneServiceClient + Track pb.TrackServiceClient +} + +func NewCndWrapper(scene pb.SceneServiceClient, track pb.TrackServiceClient) *CndWrapper { + return &CndWrapper{scene, track} +} + +// +// Scene +// + +var _ pb.SceneServiceClient = (*CndWrapper)(nil) + +func (w CndWrapper) ListScene(ctx context.Context, in *pb.ListSceneRequest, opts ...grpc.CallOption) (*pb.ListSceneResponse, error) { + return w.Scene.ListScene(ctx, in, opts...) +} + +func (w CndWrapper) MoveSceneToNext(ctx context.Context, in *pb.MoveSceneToNextRequest, opts ...grpc.CallOption) (*emptypb.Empty, error) { + return w.Scene.MoveSceneToNext(ctx, in, opts...) +} + +// +// Track +// + +var _ pb.TrackServiceClient = (*CndWrapper)(nil) + +func (w CndWrapper) GetTrack(ctx context.Context, in *pb.GetTrackRequest, opts ...grpc.CallOption) (*pb.Track, error) { + return w.Track.GetTrack(ctx, in, opts...) +} + +func (w CndWrapper) ListTrack(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*pb.ListTrackResponse, error) { + return w.Track.ListTrack(ctx, in, opts...) +} + +func (w CndWrapper) EnableAutomation(ctx context.Context, in *pb.SwitchAutomationRequest, opts ...grpc.CallOption) (*pb.Track, error) { + return w.Track.EnableAutomation(ctx, in, opts...) +} + +func (w CndWrapper) DisableAutomation(ctx context.Context, in *pb.SwitchAutomationRequest, opts ...grpc.CallOption) (*pb.Track, error) { + return w.Track.DisableAutomation(ctx, in, opts...) +} diff --git a/seaman/server.go b/seaman/server.go index 8e6823c..4f9f5d7 100644 --- a/seaman/server.go +++ b/seaman/server.go @@ -85,6 +85,9 @@ func Run(conf *config.Config) error { socketmodeHandler.HandleInteractionBlockAction( api.ActIdRelease_OK, c.CreatePullRequestForRelease) } + { // broadcast + // TODO + } { // version c := controller.NewVersionController(logger, slackClientFactory) socketmodeHandler.HandleEvents( diff --git a/seaman/view/broadcast.go b/seaman/view/broadcast.go new file mode 100644 index 0000000..f0f31c1 --- /dev/null +++ b/seaman/view/broadcast.go @@ -0,0 +1,90 @@ +package view + +import ( + "fmt" + "strings" + + "github.com/slack-go/slack" + "sigs.k8s.io/yaml" + + pb "github.com/cloudnativedaysjp/cnd-operation-server/pkg/ws-proxy/schema" +) + +func BroadcastListTrack(track []*pb.Track) slack.Msg { + result, _ := broadcastListTrack(track) + return result +} + +func broadcastListTrack(pbTracks []*pb.Track) (slack.Msg, error) { + type trackView struct { + TrackId int32 `json:"trackId"` + TrackName string `json:"trackName"` + ObsHost string `json:"obsHost"` + Enabled bool `json:"enabled"` + } + var track []trackView + for _, pbTrack := range pbTracks { + track = append(track, trackView{pbTrack.TrackId, + pbTrack.TrackName, pbTrack.ObsHost, pbTrack.Enabled}) + } + + data, err := yaml.Marshal(&track) + if err != nil { + return slack.Msg{}, err + } + return castFromStringToMsg(replaceBackquote(fmt.Sprintf(` +{ + "blocks": [ + { + "type": "section", + "text": { + "type": "mrkdwn", + "text": "%s" + } + } + ] +} +`, strings.ReplaceAll(string(data), "\n", "\\n")))) +} + +func BroadcastDisabled(trackName string) slack.Msg { + result, _ := broadcastDisabled(trackName) + return result +} + +func broadcastDisabled(trackName string) (slack.Msg, error) { + return castFromStringToMsg(fmt.Sprintf(` +{ + "blocks": [ + { + "type": "section", + "text": { + "type": "mrkdwn", + "text": "Track %s の自動切り替えを無効化しました" + } + } + ] +} +`, trackName)) +} + +func BroadcastEnabled(trackName string) slack.Msg { + result, _ := broadcastEnabled(trackName) + return result +} + +func broadcastEnabled(trackName string) (slack.Msg, error) { + return castFromStringToMsg(fmt.Sprintf(` +{ + "blocks": [ + { + "type": "section", + "text": { + "type": "mrkdwn", + "text": "Track %s の自動切り替えを有効化しました" + } + } + ] +} +`, trackName)) +} diff --git a/seaman/view/broadcast_test.go b/seaman/view/broadcast_test.go new file mode 100644 index 0000000..e1ccd5a --- /dev/null +++ b/seaman/view/broadcast_test.go @@ -0,0 +1,53 @@ +package view + +import ( + "testing" + + "github.com/google/go-cmp/cmp" + + pb "github.com/cloudnativedaysjp/cnd-operation-server/pkg/ws-proxy/schema" +) + +func Test_broadcastListTrack(t *testing.T) { + t.Run("test", func(t *testing.T) { + expectedStr := replaceBackquote(` +{ + "blocks": [ + { + "type": "section", + "text": { + "type": "mrkdwn", + "text": "- enabled: true\n obsHost: https://a.example.com\n trackId: 101\n trackName: A\n- enabled: false\n obsHost: https://b.example.com\n trackId: 102\n trackName: B\n" + } + } + ] +} +`) + expected, err := castFromStringToMsg(expectedStr) + if err != nil { + t.Fatal(err) + } + track := []*pb.Track{ + { + TrackId: 101, + TrackName: "A", + ObsHost: "https://a.example.com", + Enabled: true, + }, + { + TrackId: 102, + TrackName: "B", + ObsHost: "https://b.example.com", + Enabled: false, + }, + } + got, err := broadcastListTrack(track) + if err != nil { + t.Errorf("error = %v", err) + return + } + if diff := cmp.Diff(expected, got); diff != "" { + t.Errorf(diff) + } + }) +} diff --git a/seaman/view/common.go b/seaman/view/common.go index 6dfb4b0..9fc5df2 100644 --- a/seaman/view/common.go +++ b/seaman/view/common.go @@ -50,6 +50,33 @@ func showCommands(commands map[string]string) (slack.Msg, error) { ))) } +func InvalidArguments(messageTs, message string) slack.Msg { + result, _ := invalidArguments(messageTs, message) + return result +} + +func invalidArguments(messageTs, message string) (slack.Msg, error) { + return castFromMapToMsg( + map[string]interface{}{ + "attachments": []interface{}{ + map[string]interface{}{ + "color": colorCrimson, + "blocks": []interface{}{ + map[string]interface{}{ + "type": "section", + "text": map[string]interface{}{ + "type": "mrkdwn", + "text": fmt.Sprintf("*InvalidArguments*\n"+ + "%s (messageTs: `%s`)", message, messageTs), + }, + }, + }, + }, + }, + }, + ) +} + func SomethingIsWrong(messageTs string) slack.Msg { result, _ := somethingIsWrong(messageTs) return result diff --git a/seaman/view/helper.go b/seaman/view/helper.go index 5371886..0a2a75d 100644 --- a/seaman/view/helper.go +++ b/seaman/view/helper.go @@ -8,6 +8,7 @@ import ( ) const ( + // Color colorLightGray = "#d3d3d3" colorCrimson = "#dc143c" colorDeepSkyBlue = "#00bfff" @@ -35,5 +36,8 @@ func castFromStringToMsg(s string) (slack.Msg, error) { } func replaceBackquote(s string) string { - return strings.ReplaceAll(s, "", "`") + result := s + result = strings.ReplaceAll(result, "", "`") + result = strings.ReplaceAll(result, "", "`") + return result }