diff --git a/.gitignore b/.gitignore index 4fccbf3..62f9f66 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,7 @@ test.py test_client.py vendor/ prod.json +.lain-cache/ # React # See https://help.github.com/ignore-files/ for more about ignoring files. diff --git a/glide.lock b/glide.lock deleted file mode 100644 index d10d3ab..0000000 --- a/glide.lock +++ /dev/null @@ -1,488 +0,0 @@ -hash: a185e3d6e76336b3946c58b48b17317c6037f657888ca0f37c5533de6e53963f -updated: 2018-03-02T14:38:49.051289278+08:00 -imports: -- name: cloud.google.com/go - version: 3b1ae45394a234c385be014e9a488f2bb6eef821 - subpackages: - - compute/metadata - - internal -- name: github.com/asaskevich/govalidator - version: 4b3d68f87f176641ffc147420296013aff66ea32 -- name: github.com/Azure/go-ansiterm - version: d6e3b3328b783f23731bc4d058875b0371ff8109 - subpackages: - - winterm -- name: github.com/codegangsta/inject - version: 33e0aa1cb7c019ccc3fbe049a8262a6403d30504 -- name: github.com/containerd/continuity - version: d8fb8589b0e8e85b8c8bbaa8840226d0dfeb7371 - subpackages: - - pathdriver -- name: github.com/coreos/etcd - version: d267ca9c184e953554257d0acdd1dc9c47d38229 - subpackages: - - client - - pkg/fileutil - - pkg/pathutil - - pkg/tlsutil - - pkg/transport - - pkg/types -- name: github.com/coreos/go-oidc - version: be73733bb8cc830d0205609b95d125215f8e9c70 - subpackages: - - http - - jose - - key - - oauth2 - - oidc -- name: github.com/coreos/go-systemd - version: 48702e0da86bd25e76cfef347e2adeb434a0d0a6 - subpackages: - - daemon - - journal - - util -- name: github.com/coreos/pkg - version: 3ac0863d7acf3bc44daf49afef8919af12f704ef - subpackages: - - capnslog - - health - - httputil - - timeutil -- name: github.com/davecgh/go-spew - version: 5215b55f46b2b919f50a1df0eaa5886afe4e3b3d - subpackages: - - spew -- name: github.com/docker/distribution - version: cd27f179f2c10c5d300e6d09025b538c475b0d51 - subpackages: - - digest - - reference -- name: github.com/docker/docker - version: 5b124d7422c723ae8e403d24afc9e78dc06bbefe - subpackages: - - api/types - - api/types/blkiodev - - api/types/container - - api/types/filters - - api/types/mount - - api/types/network - - api/types/registry - - api/types/strslice - - api/types/swarm - - api/types/swarm/runtime - - api/types/versions - - opts - - pkg/archive - - pkg/fileutils - - pkg/homedir - - pkg/idtools - - pkg/ioutils - - pkg/jsonmessage - - pkg/longpath - - pkg/mount - - pkg/pools - - pkg/stdcopy - - pkg/system - - pkg/term - - pkg/term/windows -- name: github.com/docker/go-connections - version: b7274b134e463148b425fb2851d341ec9ca52901 - subpackages: - - nat -- name: github.com/docker/go-units - version: 47565b4f722fb6ceae66b95f853feed578a4a51c -- name: github.com/emicklei/go-restful - version: 09691a3b6378b740595c1002f40c34dd5f218a22 - subpackages: - - log - - swagger -- name: github.com/fsouza/go-dockerclient - version: ca33ff277b527ce11b793e62f9ba244129b01caf -- name: github.com/ghodss/yaml - version: 73d445a93680fa1a78ae23a5839bad48f32ba1ee -- name: github.com/go-martini/martini - version: 22fa46961aabd2665cf3f1343b146d20028f5071 -- name: github.com/go-openapi/analysis - version: f59a71f0ece6f9dfb438be7f45148f006cbad88e -- name: github.com/go-openapi/errors - version: 7bcb96a367bac6b76e6e42fa84155bb5581dcff8 -- name: github.com/go-openapi/jsonpointer - version: 46af16f9f7b149af66e5d1bd010e3574dc06de98 -- name: github.com/go-openapi/jsonreference - version: 13c6e3589ad90f49bd3e3bbe2c2cb3d7a4142272 -- name: github.com/go-openapi/loads - version: 2a2b323bab96e6b1fdee110e57d959322446e9c9 -- name: github.com/go-openapi/runtime - version: 09fac855d8504674b22594470227bd94e5005025 - subpackages: - - flagext - - logger - - middleware - - middleware/denco - - middleware/header - - middleware/untyped - - security -- name: github.com/go-openapi/spec - version: 1de3e0542de65ad8d75452a595886fdd0befb363 -- name: github.com/go-openapi/strfmt - version: 6d1a47fad79c81e8cd732889cb80e91123951860 -- name: github.com/go-openapi/swag - version: 0d03ad0b6405ada874d59d97c416b5cf4234e154 -- name: github.com/go-openapi/validate - version: 180bba53b98899f743a112e568bed9e2ef31aa20 -- name: github.com/go-sql-driver/mysql - version: bc14601d1bd56421dd60f561e6052c9ed77f9daf -- name: github.com/gogo/protobuf - version: 909568be09de550ed094403c2bf8a261b5bb730a - subpackages: - - proto - - sortkeys -- name: github.com/golang/glog - version: 44145f04b68cf362d9c4df2182967c2275eaefed -- name: github.com/golang/protobuf - version: 925541529c1fa6821df4e44ce2723319eb2be768 - subpackages: - - proto -- name: github.com/google/gofuzz - version: 44d81051d367757e1c7c6a5a86423ece9afcf63c -- name: github.com/gorilla/websocket - version: ea4d1f681babbce9545c9c5f3d5194a789c89f5b -- name: github.com/howeyc/gopass - version: 3ca23474a7c7203e0a0a070fd33508f6efdb9b3d -- name: github.com/imdario/mergo - version: 6633656539c1639d9d78127b7d47c622b5d7b6dc -- name: github.com/jessevdk/go-flags - version: f88afde2fa19a30cf50ba4b05b3d13bc6bae3079 -- name: github.com/jinzhu/gorm - version: 6ed508ec6a4ecb3531899a69cbc746ccf65a4166 - subpackages: - - dialects/mysql -- name: github.com/jinzhu/inflection - version: 1c35d901db3da928c72a72d8458480cc9ade058f -- name: github.com/jonboulle/clockwork - version: 2eee05ed794112d45db504eb05aa693efd2b8b09 -- name: github.com/juju/ratelimit - version: 77ed1c8a01217656d2080ad51981f6e99adaa177 -- name: github.com/kelseyhightower/envconfig - version: 462fda1f11d8cad3660e52737b8beefd27acfb3f -- name: github.com/laincloud/deployd - version: 012a90e8bea174aaff156292bb931bc7c8093eee - subpackages: - - cluster - - engine - - network - - network/calico - - storage - - utils/regex - - utils/units - - utils/util -- name: github.com/laincloud/lainlet - version: 55595b61d3e34e90f10410fa98ae03552ad8d3e6 - subpackages: - - api - - api/v2 - - auth - - client - - store - - watcher - - watcher/config - - watcher/container - - watcher/depends - - watcher/nodes - - watcher/podgroup -- name: github.com/mailru/easyjson - version: 32fa128f234d041f196a9f3e0fea5ac9772c08e1 - subpackages: - - buffer - - jlexer - - jwriter -- name: github.com/Microsoft/go-winio - version: 7da180ee92d8bd8bb8c37fc560e673e6557c392f -- name: github.com/mijia/adoc - version: 1ef227e439ebbac803b4b9ec6f9a111edd4d6831 -- name: github.com/mijia/go-generics - version: 2278a5f0de143e1d17ea16d56e7f85391bdb85a3 -- name: github.com/mijia/sweb - version: 169a3affd5ea43b3aaaa81744a0b86ff89e2b3f3 - subpackages: - - log -- name: github.com/mitchellh/mapstructure - version: 00c29f56e2386353d58c599509e8dc3801b0d716 -- name: github.com/Nvveen/Gotty - version: cd527374f1e5bff4938207604a14f2e38a9cf512 -- name: github.com/opencontainers/go-digest - version: 279bed98673dd5bef374d3b6e4b09e2af76183bf -- name: github.com/opencontainers/image-spec - version: 149252121d044fddff670adcdc67f33148e16226 - subpackages: - - specs-go - - specs-go/v1 -- name: github.com/opencontainers/runc - version: 757e78bebd83acbd1b4436efc04e1bbbaa93f60a - subpackages: - - libcontainer/system - - libcontainer/user -- name: github.com/pkg/errors - version: 30136e27e2ac8d167177e8a583aa4c3fea5be833 -- name: github.com/projectcalico/go-json - version: 6219dc7339ba20ee4c57df0a8baac62317d19cb1 - subpackages: - - json -- name: github.com/projectcalico/go-yaml - version: 955bc3e451ef0c9df8b9113bf2e341139cdafab2 -- name: github.com/projectcalico/go-yaml-wrapper - version: 598e54215bee41a19677faa4f0c32acd2a87eb56 -- name: github.com/projectcalico/libcalico-go - version: aab828ef9fd5405040c36368f866e5ec9ea314a6 - subpackages: - - lib - - lib/api - - lib/api/unversioned - - lib/backend - - lib/backend/api - - lib/backend/compat - - lib/backend/etcd - - lib/backend/extensions - - lib/backend/k8s - - lib/backend/k8s/custom - - lib/backend/k8s/resources - - lib/backend/model - - lib/client - - lib/converter - - lib/errors - - lib/hash - - lib/hwm - - lib/ipip - - lib/net - - lib/numorstring - - lib/scope - - lib/selector - - lib/selector/parser - - lib/selector/tokenizer - - lib/validator -- name: github.com/PuerkitoBio/purell - version: 8a290539e2e8629dbc4e6bad948158f790ec31f4 -- name: github.com/PuerkitoBio/urlesc - version: 5bd2802263f21d8788851d5305584c82a5c75d7e -- name: github.com/satori/go.uuid - version: f58768cc1a7a7e77a3bd49e98cdd21419399b6a3 -- name: github.com/sirupsen/logrus - version: ba1b36c82c5e05c4f912a88eab0dcd91a171688f -- name: github.com/spf13/pflag - version: 08b1a584251b5b62f458943640fc8ebd4d50aaa5 -- name: github.com/tylerb/graceful - version: d72b0151351a13d0421b763b88f791469c4f5dc7 -- name: github.com/ugorji/go - version: ded73eae5db7e7a0ef6f55aace87a2873c5d2b74 - subpackages: - - codec -- name: golang.org/x/crypto - version: 1351f936d976c60a0a48d728281922cf63eafb8d - subpackages: - - bcrypt - - blowfish - - ssh/terminal -- name: golang.org/x/net - version: f2499483f923065a842d38eb4c7f1927e6fc6e6d - subpackages: - - context - - context/ctxhttp - - http2 - - http2/hpack - - idna - - lex/httplex -- name: golang.org/x/oauth2 - version: 3c3a985cb79f52a3190fbc056984415ca6763d01 - subpackages: - - google - - internal - - jws - - jwt -- name: golang.org/x/sys - version: f6cff0780e542efa0c8e864dc8fa522808f6a598 - subpackages: - - unix - - windows -- name: golang.org/x/text - version: 19e51611da83d6be54ddafce4a4af510cb3e9ea4 - subpackages: - - cases - - internal - - internal/tag - - language - - runes - - secure/bidirule - - secure/precis - - transform - - unicode/bidi - - unicode/norm - - width -- name: google.golang.org/appengine - version: 4f7eeb5305a4ba1966344836ba4af9996b7b4e05 - subpackages: - - cloudsql - - internal - - internal/app_identity - - internal/base - - internal/datastore - - internal/log - - internal/modules - - internal/remote_api - - internal/urlfetch - - urlfetch -- name: gopkg.in/go-playground/validator.v8 - version: 5f1438d3fca68893a817e4a66806cea46a9e4ebf -- name: gopkg.in/inf.v0 - version: 3887ee99ecf07df5b447e9b00d9c0b2adaa9f3e4 -- name: gopkg.in/mgo.v2 - version: 3f83fa5005286a7fe593b055f0d7771a7dce4655 - subpackages: - - bson - - internal/json -- name: gopkg.in/tchap/go-patricia.v2 - version: 666120de432aea38ab06bd5c818f04f4129882c9 - subpackages: - - patricia -- name: gopkg.in/yaml.v2 - version: 53feefa2559fb8dfa8d81baad31be332c97d6c77 -- name: k8s.io/apimachinery - version: b317fa7ec8e0e7d1f77ac63bf8c3ec7b29a2a215 - subpackages: - - pkg/api/errors - - pkg/api/meta - - pkg/api/resource - - pkg/apimachinery - - pkg/apimachinery/announced - - pkg/apimachinery/registered - - pkg/apis/meta/v1 - - pkg/apis/meta/v1/unstructured - - pkg/conversion - - pkg/conversion/queryparams - - pkg/fields - - pkg/labels - - pkg/openapi - - pkg/runtime - - pkg/runtime/schema - - pkg/runtime/serializer - - pkg/runtime/serializer/json - - pkg/runtime/serializer/protobuf - - pkg/runtime/serializer/recognizer - - pkg/runtime/serializer/streaming - - pkg/runtime/serializer/versioning - - pkg/selection - - pkg/types - - pkg/util/diff - - pkg/util/errors - - pkg/util/framer - - pkg/util/intstr - - pkg/util/json - - pkg/util/net - - pkg/util/rand - - pkg/util/runtime - - pkg/util/sets - - pkg/util/validation - - pkg/util/validation/field - - pkg/util/wait - - pkg/util/yaml - - pkg/version - - pkg/watch - - third_party/forked/golang/reflect -- name: k8s.io/client-go - version: 4a3ab2f5be5177366f8206fd79ce55ca80e417fa - subpackages: - - discovery - - kubernetes - - kubernetes/scheme - - kubernetes/typed/apps/v1beta1 - - kubernetes/typed/authentication/v1 - - kubernetes/typed/authentication/v1beta1 - - kubernetes/typed/authorization/v1 - - kubernetes/typed/authorization/v1beta1 - - kubernetes/typed/autoscaling/v1 - - kubernetes/typed/autoscaling/v2alpha1 - - kubernetes/typed/batch/v1 - - kubernetes/typed/batch/v2alpha1 - - kubernetes/typed/certificates/v1beta1 - - kubernetes/typed/core/v1 - - kubernetes/typed/extensions/v1beta1 - - kubernetes/typed/policy/v1beta1 - - kubernetes/typed/rbac/v1alpha1 - - kubernetes/typed/rbac/v1beta1 - - kubernetes/typed/settings/v1alpha1 - - kubernetes/typed/storage/v1 - - kubernetes/typed/storage/v1beta1 - - pkg/api - - pkg/api/errors - - pkg/api/install - - pkg/api/meta - - pkg/api/unversioned - - pkg/api/v1 - - pkg/apis/apps - - pkg/apis/apps/install - - pkg/apis/apps/v1beta1 - - pkg/apis/authentication - - pkg/apis/authentication/install - - pkg/apis/authentication/v1 - - pkg/apis/authentication/v1beta1 - - pkg/apis/authorization - - pkg/apis/authorization/install - - pkg/apis/authorization/v1 - - pkg/apis/authorization/v1beta1 - - pkg/apis/autoscaling - - pkg/apis/autoscaling/install - - pkg/apis/autoscaling/v1 - - pkg/apis/autoscaling/v2alpha1 - - pkg/apis/batch - - pkg/apis/batch/install - - pkg/apis/batch/v1 - - pkg/apis/batch/v2alpha1 - - pkg/apis/certificates - - pkg/apis/certificates/install - - pkg/apis/certificates/v1beta1 - - pkg/apis/extensions - - pkg/apis/extensions/install - - pkg/apis/extensions/v1beta1 - - pkg/apis/policy - - pkg/apis/policy/install - - pkg/apis/policy/v1beta1 - - pkg/apis/rbac - - pkg/apis/rbac/install - - pkg/apis/rbac/v1alpha1 - - pkg/apis/rbac/v1beta1 - - pkg/apis/settings - - pkg/apis/settings/install - - pkg/apis/settings/v1alpha1 - - pkg/apis/storage - - pkg/apis/storage/install - - pkg/apis/storage/v1 - - pkg/apis/storage/v1beta1 - - pkg/fields - - pkg/runtime - - pkg/runtime/schema - - pkg/runtime/serializer - - pkg/util - - pkg/util/parsers - - pkg/util/wait - - pkg/version - - pkg/watch - - plugin/pkg/client/auth - - plugin/pkg/client/auth/gcp - - plugin/pkg/client/auth/oidc - - rest - - rest/watch - - third_party/forked/golang/template - - tools/auth - - tools/cache - - tools/clientcmd - - tools/clientcmd/api - - tools/clientcmd/api/latest - - tools/clientcmd/api/v1 - - tools/metrics - - transport - - util/cert - - util/clock - - util/flowcontrol - - util/homedir - - util/integer - - util/jsonpath -testImports: [] diff --git a/glide.yaml b/glide.yaml deleted file mode 100644 index 774208c..0000000 --- a/glide.yaml +++ /dev/null @@ -1,39 +0,0 @@ -package: github.com/laincloud/entry -import: -- package: github.com/fsouza/go-dockerclient - version: ^1.2.0 -- package: github.com/golang/protobuf - version: ^1.0.0 - subpackages: - - proto -- package: github.com/gorilla/websocket - version: ^1.2.0 -- package: github.com/jinzhu/gorm - version: ^1.9.1 - subpackages: - - dialects/mysql -- package: github.com/laincloud/lainlet - version: ^2.3.3 - subpackages: - - client -- package: github.com/mijia/sweb - subpackages: - - log -- package: github.com/satori/go.uuid - version: v1.2.0 -- package: github.com/go-openapi/errors - version: master -- package: github.com/go-openapi/loads - version: master -- package: github.com/go-openapi/runtime - version: master -- package: github.com/go-openapi/spec - version: master -- package: github.com/go-openapi/strfmt - version: master -- package: github.com/go-openapi/swag - version: master -- package: github.com/go-openapi/validate - version: master -- package: github.com/mailru/easyjson - version: master diff --git a/lain.yaml b/lain.yaml index e6e22b0..29d7937 100644 --- a/lain.yaml +++ b/lain.yaml @@ -3,24 +3,28 @@ appname: entry build: base: golang:1.10 prepare: - version: 20180310 script: - # - sed -i 's|deb.debian.org|mirrors.tuna.tsinghua.edu.cn|g' /etc/apt/sources.list - # - sed -i 's|security.debian.org|mirrors.tuna.tsinghua.edu.cn/debian-security|g' /etc/apt/sources.list + - go get -u github.com/golang/dep/cmd/dep + - cp -f /go/bin/dep /usr/local/bin/ + - sed -i 's|deb.debian.org|mirrors.tuna.tsinghua.edu.cn|g' /etc/apt/sources.list + - sed -i 's|security.debian.org|mirrors.tuna.tsinghua.edu.cn/debian-security|g' /etc/apt/sources.list - curl -sL https://deb.nodesource.com/setup_9.x | bash - - - apt-get -y update && apt-get -y install apt-transport-https ca-certificates golang-glide nodejs + - apt-get -y update && apt-get -y install apt-transport-https ca-certificates nodejs - curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - - echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list - apt-get -y update && apt-get -y install yarn - - mkdir -p $GOPATH/src/github.com/laincloud/entry - - cp -rf . $GOPATH/src/github.com/laincloud/entry - - cd $GOPATH/src/github.com/laincloud/entry && glide install - - go install github.com/laincloud/entry/server/gen/cmd/entry-server - - cd $GOPATH/src/github.com/laincloud/entry/frontend/ && yarn install script: - - cp -rf . $GOPATH/src/github.com/laincloud/entry - - go install github.com/laincloud/entry/server/gen/cmd/entry-server - - cd $GOPATH/src/github.com/laincloud/entry/frontend/ && yarn build + - mkdir -p /go/src/github.com/laincloud/entry + - cp -rf server /go/src/github.com/laincloud/entry/ + - cd /go/src/github.com/laincloud/entry/server && dep ensure -v + - time go install -v github.com/laincloud/entry/server/gen/cmd/entry-server + - cd frontend/ && yarn install + - cd frontend/ && yarn build + volumes: + - /go/src + - /go/bin + - /go/pkg/dep/sources + - /root/.cache/go-build test: script: @@ -29,11 +33,11 @@ test: release: dest_base: laincloud/nginx:1.13 copy: - - src: $GOPATH/bin/entry-server + - src: /go/bin/entry-server dest: /lain/app/entry-server - src: nginx.conf dest: /etc/nginx/conf.d/default.conf - - src: $GOPATH/src/github.com/laincloud/entry/frontend/build + - src: frontend/build dest: /usr/share/nginx/html web: # backend @@ -42,7 +46,7 @@ web: # backend healthcheck: /api/ping memory: 256M env: - - LAINLET_PORT=9001 + - LAINLET_PORT=9000 - SWARM_PORT=2376 secret_files: - /lain/app/prod.json diff --git a/server/Gopkg.lock b/server/Gopkg.lock new file mode 100644 index 0000000..2e03748 --- /dev/null +++ b/server/Gopkg.lock @@ -0,0 +1,394 @@ +# This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'. + + +[[projects]] + branch = "master" + name = "github.com/Azure/go-ansiterm" + packages = [ + ".", + "winterm" + ] + revision = "d6e3b3328b783f23731bc4d058875b0371ff8109" + +[[projects]] + name = "github.com/Microsoft/go-winio" + packages = ["."] + revision = "7da180ee92d8bd8bb8c37fc560e673e6557c392f" + version = "v0.4.7" + +[[projects]] + branch = "master" + name = "github.com/Nvveen/Gotty" + packages = ["."] + revision = "cd527374f1e5bff4938207604a14f2e38a9cf512" + +[[projects]] + name = "github.com/PuerkitoBio/purell" + packages = ["."] + revision = "0bcb03f4b4d0a9428594752bd2a3b9aa0a9d4bd4" + version = "v1.1.0" + +[[projects]] + branch = "master" + name = "github.com/PuerkitoBio/urlesc" + packages = ["."] + revision = "de5bf2ad457846296e2031421a34e2568e304e35" + +[[projects]] + name = "github.com/asaskevich/govalidator" + packages = ["."] + revision = "ccb8e960c48f04d6935e72476ae4a51028f9e22f" + version = "v9" + +[[projects]] + name = "github.com/containerd/continuity" + packages = ["pathdriver"] + revision = "d8fb8589b0e8e85b8c8bbaa8840226d0dfeb7371" + +[[projects]] + branch = "master" + name = "github.com/docker/docker" + packages = [ + "api/types", + "api/types/blkiodev", + "api/types/container", + "api/types/filters", + "api/types/mount", + "api/types/network", + "api/types/registry", + "api/types/strslice", + "api/types/swarm", + "api/types/swarm/runtime", + "api/types/versions", + "opts", + "pkg/archive", + "pkg/fileutils", + "pkg/homedir", + "pkg/idtools", + "pkg/ioutils", + "pkg/jsonmessage", + "pkg/longpath", + "pkg/mount", + "pkg/pools", + "pkg/stdcopy", + "pkg/system", + "pkg/term", + "pkg/term/windows" + ] + revision = "6f4bf5629cf030ee9c941534847effdcbdae9790" + +[[projects]] + name = "github.com/docker/go-connections" + packages = ["nat"] + revision = "7beb39f0b969b075d1325fecb092faf27fd357b6" + +[[projects]] + name = "github.com/docker/go-units" + packages = ["."] + revision = "47565b4f722fb6ceae66b95f853feed578a4a51c" + version = "v0.3.3" + +[[projects]] + name = "github.com/fsouza/go-dockerclient" + packages = ["."] + revision = "ca33ff277b527ce11b793e62f9ba244129b01caf" + version = "v1.2.0" + +[[projects]] + branch = "master" + name = "github.com/go-openapi/analysis" + packages = ["."] + revision = "f59a71f0ece6f9dfb438be7f45148f006cbad88e" + +[[projects]] + branch = "master" + name = "github.com/go-openapi/errors" + packages = ["."] + revision = "7bcb96a367bac6b76e6e42fa84155bb5581dcff8" + +[[projects]] + branch = "master" + name = "github.com/go-openapi/jsonpointer" + packages = ["."] + revision = "3a0015ad55fa9873f41605d3e8f28cd279c32ab2" + +[[projects]] + branch = "master" + name = "github.com/go-openapi/jsonreference" + packages = ["."] + revision = "3fb327e6747da3043567ee86abd02bb6376b6be2" + +[[projects]] + branch = "master" + name = "github.com/go-openapi/loads" + packages = ["."] + revision = "2a2b323bab96e6b1fdee110e57d959322446e9c9" + +[[projects]] + branch = "master" + name = "github.com/go-openapi/runtime" + packages = [ + ".", + "flagext", + "logger", + "middleware", + "middleware/denco", + "middleware/header", + "middleware/untyped", + "security" + ] + revision = "62281b694b396a17fe3e4313ee8b0ca2c3cca719" + +[[projects]] + branch = "master" + name = "github.com/go-openapi/spec" + packages = ["."] + revision = "370d9e047557906322be8396e77cb0376be6cb96" + +[[projects]] + branch = "master" + name = "github.com/go-openapi/strfmt" + packages = ["."] + revision = "481808443b00a14745fada967cb5eeff0f9b1df2" + +[[projects]] + branch = "master" + name = "github.com/go-openapi/swag" + packages = ["."] + revision = "811b1089cde9dad18d4d0c2d09fbdbf28dbd27a5" + +[[projects]] + branch = "master" + name = "github.com/go-openapi/validate" + packages = ["."] + revision = "180bba53b98899f743a112e568bed9e2ef31aa20" + +[[projects]] + name = "github.com/go-sql-driver/mysql" + packages = ["."] + revision = "a0583e0143b1624142adab07e0e97fe106d99561" + version = "v1.3" + +[[projects]] + name = "github.com/gogo/protobuf" + packages = ["proto"] + revision = "100ba4e885062801d56799d78530b73b178a78f3" + version = "v0.4" + +[[projects]] + name = "github.com/golang/protobuf" + packages = [ + "proto", + "ptypes", + "ptypes/any", + "ptypes/duration", + "ptypes/timestamp" + ] + revision = "925541529c1fa6821df4e44ce2723319eb2be768" + version = "v1.0.0" + +[[projects]] + name = "github.com/gorilla/websocket" + packages = ["."] + revision = "ea4d1f681babbce9545c9c5f3d5194a789c89f5b" + version = "v1.2.0" + +[[projects]] + name = "github.com/jessevdk/go-flags" + packages = ["."] + revision = "c6ca198ec95c841fdb89fc0de7496fed11ab854e" + version = "v1.4.0" + +[[projects]] + name = "github.com/jinzhu/gorm" + packages = ["."] + revision = "6ed508ec6a4ecb3531899a69cbc746ccf65a4166" + version = "v1.9.1" + +[[projects]] + branch = "master" + name = "github.com/jinzhu/inflection" + packages = ["."] + revision = "04140366298a54a039076d798123ffa108fff46c" + +[[projects]] + name = "github.com/laincloud/lainlet" + packages = [ + "grpcclient", + "message" + ] + revision = "444a2c2634a5ca22ba20e127baf2bd3ae7c8aba0" + version = "v2.4.1" + +[[projects]] + branch = "master" + name = "github.com/mailru/easyjson" + packages = [ + "buffer", + "jlexer", + "jwriter" + ] + revision = "8b799c424f57fa123fc63a99d6383bc6e4c02578" + +[[projects]] + branch = "master" + name = "github.com/mijia/sweb" + packages = ["log"] + revision = "169a3affd5ea43b3aaaa81744a0b86ff89e2b3f3" + +[[projects]] + branch = "master" + name = "github.com/mitchellh/mapstructure" + packages = ["."] + revision = "00c29f56e2386353d58c599509e8dc3801b0d716" + +[[projects]] + name = "github.com/opencontainers/go-digest" + packages = ["."] + revision = "279bed98673dd5bef374d3b6e4b09e2af76183bf" + version = "v1.0.0-rc1" + +[[projects]] + name = "github.com/opencontainers/image-spec" + packages = [ + "specs-go", + "specs-go/v1" + ] + revision = "d60099175f88c47cd379c4738d158884749ed235" + version = "v1.0.1" + +[[projects]] + name = "github.com/opencontainers/runc" + packages = [ + "libcontainer/system", + "libcontainer/user" + ] + revision = "4fc53a81fb7c994640722ac585fa9ca548971871" + version = "v1.0.0-rc5" + +[[projects]] + name = "github.com/pkg/errors" + packages = ["."] + revision = "839d9e913e063e28dfd0e6c7b7512793e0a48be9" + +[[projects]] + name = "github.com/sirupsen/logrus" + packages = ["."] + revision = "f006c2ac4710855cf0f916dd6b77acf6b048dc6e" + version = "v1.0.3" + +[[projects]] + name = "github.com/tylerb/graceful" + packages = ["."] + revision = "4654dfbb6ad53cb5e27f37d99b02e16c1872fbbb" + version = "v1.2.15" + +[[projects]] + branch = "master" + name = "golang.org/x/crypto" + packages = ["ssh/terminal"] + revision = "d6449816ce06963d9d136eee5a56fca5b0616e7e" + +[[projects]] + branch = "master" + name = "golang.org/x/net" + packages = [ + "context", + "context/ctxhttp", + "http2", + "http2/hpack", + "idna", + "internal/timeseries", + "lex/httplex", + "trace" + ] + revision = "61147c48b25b599e5b561d2e9c4f3e1ef489ca41" + +[[projects]] + branch = "master" + name = "golang.org/x/sys" + packages = [ + "unix", + "windows" + ] + revision = "3b87a42e500a6dc65dae1a55d0b641295971163e" + +[[projects]] + name = "golang.org/x/text" + packages = [ + "collate", + "collate/build", + "internal/colltab", + "internal/gen", + "internal/tag", + "internal/triegen", + "internal/ucd", + "language", + "secure/bidirule", + "transform", + "unicode/bidi", + "unicode/cldr", + "unicode/norm", + "unicode/rangetable", + "width" + ] + revision = "f21a4dfb5e38f5895301dc265a8def02365cc3d0" + version = "v0.3.0" + +[[projects]] + branch = "master" + name = "google.golang.org/genproto" + packages = ["googleapis/rpc/status"] + revision = "51d0944304c3cbce4afe9e5247e21100037bff78" + +[[projects]] + name = "google.golang.org/grpc" + packages = [ + ".", + "balancer", + "balancer/base", + "balancer/roundrobin", + "codes", + "connectivity", + "credentials", + "encoding", + "encoding/proto", + "grpclb/grpc_lb_v1/messages", + "grpclog", + "internal", + "keepalive", + "metadata", + "naming", + "peer", + "resolver", + "resolver/dns", + "resolver/passthrough", + "stats", + "status", + "tap", + "transport" + ] + revision = "d11072e7ca9811b1100b80ca0269ac831f06d024" + version = "v1.11.3" + +[[projects]] + branch = "v2" + name = "gopkg.in/mgo.v2" + packages = [ + "bson", + "internal/json" + ] + revision = "3f83fa5005286a7fe593b055f0d7771a7dce4655" + +[[projects]] + name = "gopkg.in/yaml.v2" + packages = ["."] + revision = "5420a8b6744d3b0345ab293f6fcba19c978f1183" + version = "v2.2.1" + +[solve-meta] + analyzer-name = "dep" + analyzer-version = 1 + inputs-digest = "ff040998f9912110ab3a0cdcf5d7eb61406fd919dcb9bc4581b6ebf0fbbfd369" + solver-name = "gps-cdcl" + solver-version = 1 diff --git a/server/Gopkg.toml b/server/Gopkg.toml new file mode 100644 index 0000000..a6dcc30 --- /dev/null +++ b/server/Gopkg.toml @@ -0,0 +1,94 @@ +# Gopkg.toml example +# +# Refer to https://golang.github.io/dep/docs/Gopkg.toml.html +# for detailed Gopkg.toml documentation. +# +# required = ["github.com/user/thing/cmd/thing"] +# ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"] +# +# [[constraint]] +# name = "github.com/user/project" +# version = "1.0.0" +# +# [[constraint]] +# name = "github.com/user/project2" +# branch = "dev" +# source = "github.com/myfork/project2" +# +# [[override]] +# name = "github.com/x/y" +# version = "2.4.0" +# +# [prune] +# non-go = false +# go-tests = true +# unused-packages = true + + +[[constraint]] + name = "github.com/fsouza/go-dockerclient" + version = "1.2.0" + +[[constraint]] + branch = "master" + name = "github.com/go-openapi/errors" + +[[constraint]] + branch = "master" + name = "github.com/go-openapi/loads" + +[[constraint]] + branch = "master" + name = "github.com/go-openapi/runtime" + +[[constraint]] + branch = "master" + name = "github.com/go-openapi/spec" + +[[constraint]] + branch = "master" + name = "github.com/go-openapi/strfmt" + +[[constraint]] + branch = "master" + name = "github.com/go-openapi/swag" + +[[constraint]] + branch = "master" + name = "github.com/go-openapi/validate" + +[[constraint]] + name = "github.com/go-sql-driver/mysql" + version = "1.3.0" + +[[constraint]] + name = "github.com/golang/protobuf" + version = "1.0.0" + +[[constraint]] + name = "github.com/gorilla/websocket" + version = "1.2.0" + +[[constraint]] + name = "github.com/jessevdk/go-flags" + version = "1.4.0" + +[[constraint]] + name = "github.com/jinzhu/gorm" + version = "1.9.1" + +[[constraint]] + name = "github.com/laincloud/lainlet" + version = "2.4.1" + +[[constraint]] + branch = "master" + name = "github.com/mijia/sweb" + +[[constraint]] + name = "github.com/tylerb/graceful" + version = "1.2.15" + +[prune] + go-tests = true + unused-packages = true diff --git a/server/gen/restapi/configure_entry.go b/server/gen/restapi/configure_entry.go index a12ef9f..1097187 100644 --- a/server/gen/restapi/configure_entry.go +++ b/server/gen/restapi/configure_entry.go @@ -75,7 +75,11 @@ func configureAPI(api *operations.EntryAPI) http.Handler { break } } - g := global.NewGlobal(c, db, dockerClient) + g, err := global.New(c, db, dockerClient) + if err != nil { + log.Fatalf("global.New() failed, error: %v.", err) + } + ctx, cancel := context.WithCancel(context.Background()) // configure the api here diff --git a/server/gen/restapi/doc.go b/server/gen/restapi/doc.go index 1a9398e..6686b7e 100644 --- a/server/gen/restapi/doc.go +++ b/server/gen/restapi/doc.go @@ -7,7 +7,7 @@ Package restapi Entry http Host: localhost BasePath: / - Version: 3.1.0 + Version: 3.2.0 Consumes: - application/vnd.laincloud.entry.v3+json diff --git a/server/gen/restapi/embedded_spec.go b/server/gen/restapi/embedded_spec.go index 1720749..b679014 100644 --- a/server/gen/restapi/embedded_spec.go +++ b/server/gen/restapi/embedded_spec.go @@ -30,7 +30,7 @@ func init() { "swagger": "2.0", "info": { "title": "Entry", - "version": "3.1.0" + "version": "3.2.0" }, "paths": { "/api/authorize": { @@ -478,7 +478,7 @@ func init() { "swagger": "2.0", "info": { "title": "Entry", - "version": "3.1.0" + "version": "3.2.0" }, "paths": { "/api/authorize": { diff --git a/server/global/global.go b/server/global/global.go index 3a76a7e..20bb540 100644 --- a/server/global/global.go +++ b/server/global/global.go @@ -8,7 +8,7 @@ import ( "github.com/fsouza/go-dockerclient" "github.com/jinzhu/gorm" - lainlet "github.com/laincloud/lainlet/client" + lainlet "github.com/laincloud/lainlet/grpcclient" "github.com/laincloud/entry/server/config" "github.com/laincloud/entry/server/sso" @@ -25,19 +25,26 @@ type Global struct { SSOClient *sso.Client } -// NewGlobal return an initialized Global struct pointer -func NewGlobal(c *config.Config, db *gorm.DB, dockerClient *docker.Client) *Global { +// New return an initialized Global struct pointer +func New(c *config.Config, db *gorm.DB, dockerClient *docker.Client) (*Global, error) { httpClient := http.Client{ Timeout: 10 * time.Second, } + lainletClient, err := lainlet.New(&lainlet.Config{ + Addr: net.JoinHostPort("lainlet.lain", os.Getenv("LAINLET_PORT")), + }) + if err != nil { + return nil, err + } + return &Global{ Config: c, DB: db, DockerClient: dockerClient, HTTPClient: &httpClient, LAINDomain: os.Getenv("LAIN_DOMAIN"), - LAINLETClient: lainlet.New(net.JoinHostPort("lainlet.lain", os.Getenv("LAINLET_PORT"))), + LAINLETClient: lainletClient, SSOClient: sso.NewClient(c.SSO, &httpClient), - } + }, nil } diff --git a/server/handler/attach.go b/server/handler/attach.go index 0b6c5d4..aaf0c68 100644 --- a/server/handler/attach.go +++ b/server/handler/attach.go @@ -12,8 +12,8 @@ import ( "github.com/gorilla/websocket" "github.com/mijia/sweb/log" - "github.com/laincloud/entry/message" "github.com/laincloud/entry/server/global" + "github.com/laincloud/entry/server/message" "github.com/laincloud/entry/server/models" "github.com/laincloud/entry/server/util" ) diff --git a/server/handler/enter.go b/server/handler/enter.go index 8a7940a..adbf109 100644 --- a/server/handler/enter.go +++ b/server/handler/enter.go @@ -11,10 +11,10 @@ import ( "github.com/fsouza/go-dockerclient" "github.com/gorilla/websocket" - "github.com/laincloud/entry/message" "github.com/mijia/sweb/log" "github.com/laincloud/entry/server/global" + "github.com/laincloud/entry/server/message" "github.com/laincloud/entry/server/models" "github.com/laincloud/entry/server/util" ) diff --git a/server/handler/handle_websocket.go b/server/handler/handle_websocket.go index fca71ad..947e58f 100644 --- a/server/handler/handle_websocket.go +++ b/server/handler/handle_websocket.go @@ -15,8 +15,8 @@ import ( "github.com/gorilla/websocket" "github.com/mijia/sweb/log" - "github.com/laincloud/entry/message" "github.com/laincloud/entry/server/global" + "github.com/laincloud/entry/server/message" "github.com/laincloud/entry/server/models" "github.com/laincloud/entry/server/util" ) diff --git a/server/handler/replay_session.go b/server/handler/replay_session.go index 4f3f4fe..c427cc5 100644 --- a/server/handler/replay_session.go +++ b/server/handler/replay_session.go @@ -13,8 +13,8 @@ import ( "github.com/gorilla/websocket" "github.com/mijia/sweb/log" - "github.com/laincloud/entry/message" "github.com/laincloud/entry/server/global" + "github.com/laincloud/entry/server/message" "github.com/laincloud/entry/server/models" "github.com/laincloud/entry/server/util" ) diff --git a/message/message.pb.go b/server/message/message.pb.go similarity index 100% rename from message/message.pb.go rename to server/message/message.pb.go diff --git a/server/models/session.go b/server/models/session.go index 50b701a..35f2486 100644 --- a/server/models/session.go +++ b/server/models/session.go @@ -92,8 +92,8 @@ func NewSession(conn *websocket.Conn, r *http.Request, g *global.Global) (*Sessi AppName: appName, ProcName: procName, InstanceNo: instanceNo, - ContainerID: container.ContainerID, - NodeIP: container.NodeIP, + ContainerID: container.Id, + NodeIP: container.NodeIp, Status: SessionStatusActive, } log.Infof("A new session: %+v has been created.", s) diff --git a/server/util/auth.go b/server/util/auth.go index 6aa3e88..84cd62f 100644 --- a/server/util/auth.go +++ b/server/util/auth.go @@ -4,7 +4,6 @@ import ( "encoding/json" "errors" "fmt" - "time" "github.com/laincloud/entry/server/global" "github.com/laincloud/entry/server/sso" @@ -22,18 +21,12 @@ var ( // AuthContainer authorizes whether the client with the token has the right to access the application's container func AuthContainer(token, appName string, g *global.Global) (*sso.User, error) { - var ( - data []byte - err error - ) - if data, err = g.LAINLETClient.Get("/v2/configwatcher?target=auth/console", 2*time.Second); err != nil { - return nil, err - } - authDataMap := make(map[string]string) - if err = json.Unmarshal(data, &authDataMap); err != nil { + authConfig, err := g.LAINLETClient.ConfigGet("auth/console") + if err != nil { return nil, err } - if authStr, exist := authDataMap["auth/console"]; exist { + + if authStr, exist := authConfig.Data["auth/console"]; exist { c := ConsoleAuthConf{} if err = json.Unmarshal([]byte(authStr), &c); err != nil { return nil, err diff --git a/server/util/util.go b/server/util/util.go index 21fd999..eb27f3e 100644 --- a/server/util/util.go +++ b/server/util/util.go @@ -1,14 +1,15 @@ package util import ( - "encoding/json" "errors" + "fmt" "net/http" "strconv" "strings" - "time" "unicode/utf8" + "github.com/laincloud/lainlet/message" + "github.com/laincloud/entry/server/global" ) @@ -20,24 +21,8 @@ var ( errContainerNotfound = errors.New("get data successfully but not found the container") ) -type CoreInfo map[string]AppInfo - type ViaMethod int -type Container struct { - ContainerID string `json:"ContainerId"` - NodeIP string `json:"NodeIp"` -} - -type AppInfo struct { - PodInfos []PodInfo `json:"PodInfos"` -} - -type PodInfo struct { - InstanceNo int `json:"InstanceNo"` - Containers []Container `json:"ContainerInfos"` -} - func getAppProcName(key []string) (string, string) { var procName string if len(key) > 0 { @@ -51,26 +36,20 @@ func getAppProcName(key []string) (string, string) { } // GetContainer get container according to appName, procName and instanceNo -func GetContainer(appName, procName, instanceNo string, g *global.Global) (*Container, error) { - var ( - data []byte - err error - ) - if data, err = g.LAINLETClient.Get("v2/coreinfowatcher?appname="+appName, 2*time.Second); err != nil { +func GetContainer(appName, procName, instanceNo string, g *global.Global) (*message.Container, error) { + coreInfo, err := g.LAINLETClient.CoreinfoGet(appName) + if err != nil { return nil, err } - coreInfo := make(CoreInfo) - if err := json.Unmarshal(data, &coreInfo); err != nil { - return nil, err - } - for procFullName, procInfo := range coreInfo { + + for procFullName, procInfo := range coreInfo.Data { curAppName, curProcName := getAppProcName(strings.Split(procFullName, ".")) if curProcName == procName && curAppName == appName { for _, containerInfo := range procInfo.PodInfos { - if strconv.Itoa(containerInfo.InstanceNo) == instanceNo && + if fmt.Sprint(containerInfo.InstanceNo) == instanceNo && len(containerInfo.Containers) > 0 && - containerInfo.Containers[0].ContainerID != "" { - return &containerInfo.Containers[0], nil + containerInfo.Containers[0].Id != "" { + return containerInfo.Containers[0], nil } } } diff --git a/server/util/websocket.go b/server/util/websocket.go index bf40af4..4b44e6f 100644 --- a/server/util/websocket.go +++ b/server/util/websocket.go @@ -4,8 +4,9 @@ import ( "sync" "github.com/gorilla/websocket" - "github.com/laincloud/entry/message" "github.com/mijia/sweb/log" + + "github.com/laincloud/entry/server/message" ) func SendCloseMessage(conn *websocket.Conn, content []byte, msgMarshaller Marshaler, writeLock *sync.Mutex) { diff --git a/swagger.yml b/swagger.yml index d3bdeec..1b7a37a 100644 --- a/swagger.yml +++ b/swagger.yml @@ -2,7 +2,7 @@ swagger: "2.0" info: title: Entry - version: 3.1.0 + version: 3.2.0 schemes: - http