From 3de542e52ee69d5bfe9fd06e9267e36dd1b1b888 Mon Sep 17 00:00:00 2001 From: palytoxin Date: Mon, 25 Jan 2021 15:05:45 +0800 Subject: [PATCH 1/4] mod vendor via go 1.15 --- .bra.toml | 3 ++ vendor/modules.txt | 142 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 145 insertions(+) diff --git a/.bra.toml b/.bra.toml index e009a2b7c..3216404d1 100755 --- a/.bra.toml +++ b/.bra.toml @@ -1,5 +1,6 @@ [run] init_cmds = [ # Commands run in start + ["go", "mod", "vendor"], ["make", "backend"], ["./opendata"] ] @@ -14,6 +15,7 @@ watch_dirs = [ "$WORKDIR/public", "$WORKDIR/custom", "$WORKDIR/web_src", + "$WORKDIR/vendor", ] # Directories to watch watch_exts = [".go", ".ini", ".less"] # Extensions to watch env_files = [] # Load env vars from files @@ -24,6 +26,7 @@ build_delay = 3000 # Minimal interval to Trigger build event interrupt_timout = 15 # Time to wait until force kill graceful_kill = false # Wait for exit and before directly kill cmds = [ # Commands to run + ["go", "mod", "vendor"], ["make", "backend"], ["./opendata"] ] diff --git a/vendor/modules.txt b/vendor/modules.txt index f338f3ffe..c52aefb53 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -1,4 +1,5 @@ # cloud.google.com/go v0.45.0 +## explicit cloud.google.com/go/compute/metadata cloud.google.com/go/iam cloud.google.com/go/internal/optional @@ -7,31 +8,43 @@ cloud.google.com/go/pubsub cloud.google.com/go/pubsub/apiv1 cloud.google.com/go/pubsub/internal/distribution # gitea.com/jolheiser/gitea-vet v0.1.0 +## explicit gitea.com/jolheiser/gitea-vet gitea.com/jolheiser/gitea-vet/checks # gitea.com/lunny/levelqueue v0.3.0 +## explicit gitea.com/lunny/levelqueue # gitea.com/macaron/binding v0.0.0-20190822013154-a5f53841ed2b +## explicit gitea.com/macaron/binding # gitea.com/macaron/cache v0.0.0-20190822004001-a6e7fee4ee76 +## explicit gitea.com/macaron/cache gitea.com/macaron/cache/memcache gitea.com/macaron/cache/redis # gitea.com/macaron/captcha v0.0.0-20190822015246-daa973478bae +## explicit gitea.com/macaron/captcha # gitea.com/macaron/cors v0.0.0-20190826180238-95aec09ea8b4 +## explicit gitea.com/macaron/cors # gitea.com/macaron/csrf v0.0.0-20190822024205-3dc5a4474439 +## explicit gitea.com/macaron/csrf # gitea.com/macaron/gzip v0.0.0-20191118041502-506895b47aae +## explicit gitea.com/macaron/gzip # gitea.com/macaron/i18n v0.0.0-20190822004228-474e714e2223 +## explicit gitea.com/macaron/i18n # gitea.com/macaron/inject v0.0.0-20190805023432-d4c86e31027a +## explicit gitea.com/macaron/inject # gitea.com/macaron/macaron v1.4.0 +## explicit gitea.com/macaron/macaron # gitea.com/macaron/session v0.0.0-20191207215012-613cebf0674d +## explicit gitea.com/macaron/session gitea.com/macaron/session/couchbase gitea.com/macaron/session/memcache @@ -40,10 +53,13 @@ gitea.com/macaron/session/nodb gitea.com/macaron/session/postgres gitea.com/macaron/session/redis # gitea.com/macaron/toolbox v0.0.0-20190822013122-05ff0fc766b7 +## explicit gitea.com/macaron/toolbox # github.com/BurntSushi/toml v0.3.1 +## explicit github.com/BurntSushi/toml # github.com/PuerkitoBio/goquery v1.5.0 +## explicit github.com/PuerkitoBio/goquery # github.com/PuerkitoBio/purell v1.1.1 github.com/PuerkitoBio/purell @@ -52,6 +68,7 @@ github.com/PuerkitoBio/urlesc # github.com/RichardKnop/logging v0.0.0-20181101035820-b1d5d44c82d6 github.com/RichardKnop/logging # github.com/RichardKnop/machinery v1.6.9 +## explicit github.com/RichardKnop/machinery/v1 github.com/RichardKnop/machinery/v1/backends/amqp github.com/RichardKnop/machinery/v1/backends/dynamodb @@ -78,6 +95,7 @@ github.com/RichardKnop/machinery/v1/tracing # github.com/RichardKnop/redsync v1.2.0 github.com/RichardKnop/redsync # github.com/RoaringBitmap/roaring v0.4.23 +## explicit github.com/RoaringBitmap/roaring # github.com/andybalholm/cascadia v1.0.0 github.com/andybalholm/cascadia @@ -129,7 +147,10 @@ github.com/aws/aws-sdk-go/service/sts/stsiface github.com/aymerick/douceur/css # github.com/beorn7/perks v1.0.1 github.com/beorn7/perks/quantile +# github.com/bgentry/speakeasy v0.1.0 +## explicit # github.com/blevesearch/bleve v1.0.7 +## explicit github.com/blevesearch/bleve github.com/blevesearch/bleve/analysis github.com/blevesearch/bleve/analysis/analyzer/custom @@ -191,6 +212,7 @@ github.com/bradfitz/gomemcache/memcache # github.com/chris-ramon/douceur v0.2.0 github.com/chris-ramon/douceur/parser # github.com/couchbase/gomemcached v0.0.0-20191004160342-7b5da2ec40b2 +## explicit github.com/couchbase/gomemcached github.com/couchbase/gomemcached/client # github.com/couchbase/goutils v0.0.0-20191018232750-b49639060d85 @@ -205,20 +227,31 @@ github.com/couchbase/vellum/utf8 github.com/couchbaselabs/go-couchbase # github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d github.com/cpuguy83/go-md2man/v2/md2man +# github.com/cznic/b v0.0.0-20181122101859-a26611c4d92d +## explicit +# github.com/cznic/mathutil v0.0.0-20181122101859-297441e03548 +## explicit +# github.com/cznic/strutil v0.0.0-20181122101858-275e90344537 +## explicit # github.com/davecgh/go-spew v1.1.1 github.com/davecgh/go-spew/spew # github.com/denisenkom/go-mssqldb v0.0.0-20200428022330-06a60b6afbbc +## explicit github.com/denisenkom/go-mssqldb github.com/denisenkom/go-mssqldb/internal/cp github.com/denisenkom/go-mssqldb/internal/decimal github.com/denisenkom/go-mssqldb/internal/querytext # github.com/dgrijalva/jwt-go v3.2.0+incompatible +## explicit github.com/dgrijalva/jwt-go # github.com/dustin/go-humanize v1.0.0 +## explicit github.com/dustin/go-humanize # github.com/editorconfig/editorconfig-core-go/v2 v2.1.1 +## explicit github.com/editorconfig/editorconfig-core-go/v2 # github.com/emirpasic/gods v1.12.0 +## explicit github.com/emirpasic/gods/containers github.com/emirpasic/gods/lists github.com/emirpasic/gods/lists/arraylist @@ -226,7 +259,14 @@ github.com/emirpasic/gods/trees github.com/emirpasic/gods/trees/binaryheap github.com/emirpasic/gods/utils # github.com/ethantkoenig/rupture v0.0.0-20180203182544-0a76f03a811a +## explicit github.com/ethantkoenig/rupture +# github.com/facebookgo/ensure v0.0.0-20160127193407-b4ab57deab51 +## explicit +# github.com/facebookgo/stack v0.0.0-20160209184415-751773369052 +## explicit +# github.com/facebookgo/subset v0.0.0-20150612182917-8dac2c3c4870 +## explicit # github.com/fatih/color v1.9.0 github.com/fatih/color # github.com/fatih/structtag v1.2.0 @@ -234,10 +274,13 @@ github.com/fatih/structtag # github.com/fsnotify/fsnotify v1.4.7 github.com/fsnotify/fsnotify # github.com/gliderlabs/ssh v0.2.2 +## explicit github.com/gliderlabs/ssh # github.com/glycerine/go-unsnap-stream v0.0.0-20190901134440-81cf024a9e0a +## explicit github.com/glycerine/go-unsnap-stream # github.com/go-enry/go-enry/v2 v2.3.0 +## explicit github.com/go-enry/go-enry/v2 github.com/go-enry/go-enry/v2/data github.com/go-enry/go-enry/v2/data/rule @@ -252,12 +295,14 @@ github.com/go-git/gcfg/scanner github.com/go-git/gcfg/token github.com/go-git/gcfg/types # github.com/go-git/go-billy/v5 v5.0.0 +## explicit github.com/go-git/go-billy/v5 github.com/go-git/go-billy/v5/helper/chroot github.com/go-git/go-billy/v5/helper/polyfill github.com/go-git/go-billy/v5/osfs github.com/go-git/go-billy/v5/util # github.com/go-git/go-git/v5 v5.0.0 +## explicit github.com/go-git/go-git/v5 github.com/go-git/go-git/v5/config github.com/go-git/go-git/v5/internal/revision @@ -302,8 +347,10 @@ github.com/go-git/go-git/v5/utils/merkletrie/index github.com/go-git/go-git/v5/utils/merkletrie/internal/frame github.com/go-git/go-git/v5/utils/merkletrie/noder # github.com/go-ini/ini v1.56.0 +## explicit github.com/go-ini/ini # github.com/go-macaron/auth v0.0.0-20161228062157-884c0e6c9b92 +## explicit github.com/go-macaron/auth # github.com/go-macaron/inject v0.0.0-20160627170012-d8a0b8677191 github.com/go-macaron/inject @@ -317,6 +364,7 @@ github.com/go-openapi/inflect # github.com/go-openapi/jsonpointer v0.19.3 github.com/go-openapi/jsonpointer # github.com/go-openapi/jsonreference v0.19.3 +## explicit github.com/go-openapi/jsonreference # github.com/go-openapi/loads v0.19.3 github.com/go-openapi/loads @@ -338,6 +386,7 @@ github.com/go-openapi/swag # github.com/go-openapi/validate v0.19.3 github.com/go-openapi/validate # github.com/go-redis/redis v6.15.2+incompatible +## explicit github.com/go-redis/redis github.com/go-redis/redis/internal github.com/go-redis/redis/internal/consistenthash @@ -346,12 +395,15 @@ github.com/go-redis/redis/internal/pool github.com/go-redis/redis/internal/proto github.com/go-redis/redis/internal/util # github.com/go-resty/resty/v2 v2.3.0 +## explicit github.com/go-resty/resty/v2 # github.com/go-sql-driver/mysql v1.4.1 +## explicit github.com/go-sql-driver/mysql # github.com/go-stack/stack v1.8.0 github.com/go-stack/stack # github.com/go-swagger/go-swagger v0.21.0 +## explicit github.com/go-swagger/go-swagger/cmd/swagger github.com/go-swagger/go-swagger/cmd/swagger/commands github.com/go-swagger/go-swagger/cmd/swagger/commands/diff @@ -361,6 +413,7 @@ github.com/go-swagger/go-swagger/codescan github.com/go-swagger/go-swagger/generator github.com/go-swagger/go-swagger/scan # github.com/gobwas/glob v0.2.3 +## explicit github.com/gobwas/glob github.com/gobwas/glob/compiler github.com/gobwas/glob/match @@ -370,14 +423,17 @@ github.com/gobwas/glob/syntax/lexer github.com/gobwas/glob/util/runes github.com/gobwas/glob/util/strings # github.com/gogs/chardet v0.0.0-20191104214054-4b6791f73a28 +## explicit github.com/gogs/chardet # github.com/gogs/cron v0.0.0-20171120032916-9f6c956d3e14 +## explicit github.com/gogs/cron # github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe github.com/golang-sql/civil # github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6 github.com/golang/groupcache/lru # github.com/golang/protobuf v1.4.1 +## explicit github.com/golang/protobuf/proto github.com/golang/protobuf/protoc-gen-go/descriptor github.com/golang/protobuf/ptypes @@ -391,6 +447,7 @@ github.com/golang/snappy github.com/gomodule/redigo/internal github.com/gomodule/redigo/redis # github.com/google/go-github/v24 v24.0.1 +## explicit github.com/google/go-github/v24/github # github.com/google/go-querystring v1.0.0 github.com/google/go-querystring/query @@ -399,6 +456,7 @@ github.com/google/uuid # github.com/googleapis/gax-go/v2 v2.0.5 github.com/googleapis/gax-go/v2 # github.com/gorilla/context v1.1.1 +## explicit github.com/gorilla/context # github.com/gorilla/css v1.0.0 github.com/gorilla/css/scanner @@ -413,6 +471,7 @@ github.com/gorilla/sessions # github.com/hashicorp/go-cleanhttp v0.5.1 github.com/hashicorp/go-cleanhttp # github.com/hashicorp/go-retryablehttp v0.6.6 +## explicit github.com/hashicorp/go-retryablehttp # github.com/hashicorp/hcl v1.0.0 github.com/hashicorp/hcl @@ -426,10 +485,15 @@ github.com/hashicorp/hcl/json/parser github.com/hashicorp/hcl/json/scanner github.com/hashicorp/hcl/json/token # github.com/huandu/xstrings v1.3.0 +## explicit github.com/huandu/xstrings +# github.com/issue9/assert v1.3.2 +## explicit # github.com/issue9/identicon v1.0.1 +## explicit github.com/issue9/identicon # github.com/jaytaylor/html2text v0.0.0-20160923191438-8fb95d837f7d +## explicit github.com/jaytaylor/html2text # github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 github.com/jbenet/go-context/io @@ -437,15 +501,21 @@ github.com/jbenet/go-context/io github.com/jessevdk/go-flags # github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af github.com/jmespath/go-jmespath +# github.com/jmhodges/levigo v1.0.0 +## explicit +# github.com/joho/godotenv v1.3.0 +## explicit # github.com/json-iterator/go v1.1.9 github.com/json-iterator/go # github.com/kballard/go-shellquote v0.0.0-20170619183022-cd60e84ee657 +## explicit github.com/kballard/go-shellquote # github.com/kelseyhightower/envconfig v1.3.0 github.com/kelseyhightower/envconfig # github.com/kevinburke/ssh_config v0.0.0-20190725054713-01f96b0aa0cd github.com/kevinburke/ssh_config # github.com/keybase/go-crypto v0.0.0-20200123153347-de78d2cb44f4 +## explicit github.com/keybase/go-crypto/brainpool github.com/keybase/go-crypto/cast5 github.com/keybase/go-crypto/curve25519 @@ -460,6 +530,7 @@ github.com/keybase/go-crypto/openpgp/packet github.com/keybase/go-crypto/openpgp/s2k github.com/keybase/go-crypto/rsa # github.com/klauspost/compress v1.10.2 +## explicit github.com/klauspost/compress/flate github.com/klauspost/compress/gzip # github.com/klauspost/cpuid v1.2.3 @@ -469,13 +540,16 @@ github.com/kr/pretty # github.com/kr/text v0.2.0 github.com/kr/text # github.com/lafriks/xormstore v1.3.2 +## explicit github.com/lafriks/xormstore github.com/lafriks/xormstore/util # github.com/lib/pq v1.2.0 +## explicit github.com/lib/pq github.com/lib/pq/oid github.com/lib/pq/scram # github.com/lunny/dingtalk_webhook v0.0.0-20171025031554-e3534c89ef96 +## explicit github.com/lunny/dingtalk_webhook # github.com/lunny/log v0.0.0-20160921050905-7887c61bf0de github.com/lunny/log @@ -488,11 +562,13 @@ github.com/lunny/nodb/store/goleveldb # github.com/magiconair/properties v1.8.1 github.com/magiconair/properties # github.com/mailru/easyjson v0.7.0 +## explicit github.com/mailru/easyjson github.com/mailru/easyjson/buffer github.com/mailru/easyjson/jlexer github.com/mailru/easyjson/jwriter # github.com/markbates/goth v1.61.2 +## explicit github.com/markbates/goth github.com/markbates/goth/gothic github.com/markbates/goth/providers/bitbucket @@ -510,26 +586,35 @@ github.com/markbates/goth/providers/yandex # github.com/mattn/go-colorable v0.1.4 github.com/mattn/go-colorable # github.com/mattn/go-isatty v0.0.11 +## explicit github.com/mattn/go-isatty +# github.com/mattn/go-oci8 v0.0.0-20190320171441-14ba190cf52d +## explicit # github.com/mattn/go-runewidth v0.0.7 github.com/mattn/go-runewidth # github.com/mattn/go-sqlite3 v1.11.0 +## explicit github.com/mattn/go-sqlite3 # github.com/matttproud/golang_protobuf_extensions v1.0.1 github.com/matttproud/golang_protobuf_extensions/pbutil # github.com/mcuadros/go-version v0.0.0-20190308113854-92cdf37c5b75 +## explicit github.com/mcuadros/go-version # github.com/mgechev/dots v0.0.0-20190921121421-c36f7dcfbb81 +## explicit github.com/mgechev/dots # github.com/mgechev/revive v1.0.2 +## explicit github.com/mgechev/revive/formatter github.com/mgechev/revive/lint github.com/mgechev/revive/rule # github.com/microcosm-cc/bluemonday v1.0.3-0.20191119130333-0a75d7616912 +## explicit github.com/microcosm-cc/bluemonday # github.com/minio/md5-simd v1.1.0 github.com/minio/md5-simd # github.com/minio/minio-go v6.0.14+incompatible +## explicit github.com/minio/minio-go github.com/minio/minio-go/pkg/credentials github.com/minio/minio-go/pkg/encrypt @@ -537,6 +622,7 @@ github.com/minio/minio-go/pkg/s3signer github.com/minio/minio-go/pkg/s3utils github.com/minio/minio-go/pkg/set # github.com/minio/minio-go/v6 v6.0.57 +## explicit github.com/minio/minio-go/v6 github.com/minio/minio-go/v6/pkg/credentials github.com/minio/minio-go/v6/pkg/encrypt @@ -547,6 +633,7 @@ github.com/minio/minio-go/v6/pkg/tags # github.com/minio/sha256-simd v0.1.1 github.com/minio/sha256-simd # github.com/mitchellh/go-homedir v1.1.0 +## explicit github.com/mitchellh/go-homedir # github.com/mitchellh/mapstructure v1.1.2 github.com/mitchellh/mapstructure @@ -559,16 +646,21 @@ github.com/mrjones/oauth # github.com/mschoch/smat v0.2.0 github.com/mschoch/smat # github.com/msteinert/pam v0.0.0-20151204160544-02ccfbfaf0cc +## explicit github.com/msteinert/pam # github.com/nfnt/resize v0.0.0-20160724205520-891127d8d1b5 +## explicit github.com/nfnt/resize # github.com/niklasfasching/go-org v0.1.9 +## explicit github.com/niklasfasching/go-org/org # github.com/olekukonko/tablewriter v0.0.4 github.com/olekukonko/tablewriter # github.com/oliamb/cutter v0.2.2 +## explicit github.com/oliamb/cutter # github.com/olivere/elastic/v7 v7.0.9 +## explicit github.com/olivere/elastic/v7 github.com/olivere/elastic/v7/config github.com/olivere/elastic/v7/uritemplates @@ -581,43 +673,58 @@ github.com/pelletier/go-toml # github.com/philhofer/fwd v1.0.0 github.com/philhofer/fwd # github.com/pkg/errors v0.9.1 +## explicit github.com/pkg/errors # github.com/pmezard/go-difflib v1.0.0 github.com/pmezard/go-difflib/difflib # github.com/pquerna/otp v1.2.0 +## explicit github.com/pquerna/otp github.com/pquerna/otp/hotp github.com/pquerna/otp/totp # github.com/prometheus/client_golang v1.1.0 +## explicit github.com/prometheus/client_golang/prometheus github.com/prometheus/client_golang/prometheus/internal github.com/prometheus/client_golang/prometheus/promhttp # github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4 +## explicit github.com/prometheus/client_model/go # github.com/prometheus/common v0.6.0 github.com/prometheus/common/expfmt github.com/prometheus/common/internal/bitbucket.org/ww/goautoneg github.com/prometheus/common/model # github.com/prometheus/procfs v0.0.4 +## explicit github.com/prometheus/procfs github.com/prometheus/procfs/internal/fs github.com/prometheus/procfs/internal/util # github.com/quasoft/websspi v1.0.0 +## explicit github.com/quasoft/websspi github.com/quasoft/websspi/secctx +# github.com/remyoudompheng/bigfft v0.0.0-20190321074620-2f0d2b0e0001 +## explicit +# github.com/robfig/cron v1.2.0 +## explicit # github.com/robfig/cron/v3 v3.0.1 +## explicit github.com/robfig/cron/v3 # github.com/russross/blackfriday/v2 v2.0.1 github.com/russross/blackfriday/v2 # github.com/satori/go.uuid v1.2.0 +## explicit github.com/satori/go.uuid # github.com/sergi/go-diff v1.1.0 +## explicit github.com/sergi/go-diff/diffmatchpatch # github.com/shurcooL/httpfs v0.0.0-20190527155220-6a4d4a70508b +## explicit github.com/shurcooL/httpfs/vfsutil # github.com/shurcooL/sanitized_anchor_name v1.0.0 github.com/shurcooL/sanitized_anchor_name # github.com/shurcooL/vfsgen v0.0.0-20181202132449-6a9ea43bcacd +## explicit github.com/shurcooL/vfsgen # github.com/siddontang/go-snappy v0.0.0-20140704025258-d8f7bb82a96d github.com/siddontang/go-snappy/snappy @@ -637,6 +744,7 @@ github.com/steveyen/gtreap # github.com/streadway/amqp v0.0.0-20190214183023-884228600bc9 github.com/streadway/amqp # github.com/stretchr/testify v1.4.0 +## explicit github.com/stretchr/testify/assert github.com/stretchr/testify/require # github.com/syndtr/goleveldb v1.0.0 @@ -652,28 +760,38 @@ github.com/syndtr/goleveldb/leveldb/opt github.com/syndtr/goleveldb/leveldb/storage github.com/syndtr/goleveldb/leveldb/table github.com/syndtr/goleveldb/leveldb/util +# github.com/tecbot/gorocksdb v0.0.0-20181010114359-8752a9433481 +## explicit # github.com/tinylib/msgp v1.1.2 +## explicit github.com/tinylib/msgp/msgp # github.com/toqueteos/trie v1.0.0 github.com/toqueteos/trie # github.com/toqueteos/webbrowser v1.2.0 github.com/toqueteos/webbrowser # github.com/tstranex/u2f v1.0.0 +## explicit github.com/tstranex/u2f # github.com/unknwon/cae v1.0.0 +## explicit github.com/unknwon/cae github.com/unknwon/cae/zip # github.com/unknwon/com v1.0.1 +## explicit github.com/unknwon/com # github.com/unknwon/i18n v0.0.0-20190805065654-5c6446a380b6 +## explicit github.com/unknwon/i18n # github.com/unknwon/paginater v0.0.0-20151104151617-7748a72e0141 +## explicit github.com/unknwon/paginater # github.com/urfave/cli v1.22.1 +## explicit github.com/urfave/cli # github.com/willf/bitset v1.1.10 github.com/willf/bitset # github.com/xanzy/go-gitlab v0.31.0 +## explicit github.com/xanzy/go-gitlab # github.com/xanzy/ssh-agent v0.2.1 github.com/xanzy/ssh-agent @@ -682,8 +800,10 @@ github.com/xdg/scram # github.com/xdg/stringprep v1.0.0 github.com/xdg/stringprep # github.com/yohcop/openid-go v1.0.0 +## explicit github.com/yohcop/openid-go # github.com/yuin/goldmark v1.1.27 +## explicit github.com/yuin/goldmark github.com/yuin/goldmark/ast github.com/yuin/goldmark/extension @@ -694,6 +814,7 @@ github.com/yuin/goldmark/renderer/html github.com/yuin/goldmark/text github.com/yuin/goldmark/util # github.com/yuin/goldmark-meta v0.0.0-20191126180153-f0638e958b60 +## explicit github.com/yuin/goldmark-meta # go.etcd.io/bbolt v1.3.4 go.etcd.io/bbolt @@ -745,6 +866,7 @@ go.opencensus.io/trace/internal go.opencensus.io/trace/propagation go.opencensus.io/trace/tracestate # golang.org/x/crypto v0.0.0-20200429183012-4b2356b1ed79 +## explicit golang.org/x/crypto/acme golang.org/x/crypto/acme/autocert golang.org/x/crypto/argon2 @@ -772,9 +894,11 @@ golang.org/x/crypto/ssh/agent golang.org/x/crypto/ssh/internal/bcrypt_pbkdf golang.org/x/crypto/ssh/knownhosts # golang.org/x/mod v0.3.0 +## explicit golang.org/x/mod/module golang.org/x/mod/semver # golang.org/x/net v0.0.0-20200513185701-a91f0712d120 +## explicit golang.org/x/net/context golang.org/x/net/context/ctxhttp golang.org/x/net/html @@ -790,6 +914,7 @@ golang.org/x/net/proxy golang.org/x/net/publicsuffix golang.org/x/net/trace # golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d +## explicit golang.org/x/oauth2 golang.org/x/oauth2/google golang.org/x/oauth2/internal @@ -799,6 +924,7 @@ golang.org/x/oauth2/jwt golang.org/x/sync/errgroup golang.org/x/sync/semaphore # golang.org/x/sys v0.0.0-20200509044756-6aff5f38e54f +## explicit golang.org/x/sys/cpu golang.org/x/sys/internal/unsafeheader golang.org/x/sys/unix @@ -806,6 +932,7 @@ golang.org/x/sys/windows golang.org/x/sys/windows/svc golang.org/x/sys/windows/svc/debug # golang.org/x/text v0.3.2 +## explicit golang.org/x/text/encoding golang.org/x/text/encoding/charmap golang.org/x/text/encoding/htmlindex @@ -828,8 +955,10 @@ golang.org/x/text/unicode/bidi golang.org/x/text/unicode/norm golang.org/x/text/width # golang.org/x/time v0.0.0-20200416051211-89c76fbcd5d1 +## explicit golang.org/x/time/rate # golang.org/x/tools v0.0.0-20200515220128-d3bf790afa53 +## explicit golang.org/x/tools/cover golang.org/x/tools/go/analysis golang.org/x/tools/go/analysis/internal/analysisflags @@ -869,6 +998,7 @@ google.golang.org/api/transport/grpc google.golang.org/api/transport/http google.golang.org/api/transport/http/internal/propagation # google.golang.org/appengine v1.6.5 +## explicit google.golang.org/appengine google.golang.org/appengine/cloudsql google.golang.org/appengine/internal @@ -967,32 +1097,44 @@ google.golang.org/protobuf/types/known/durationpb google.golang.org/protobuf/types/known/emptypb google.golang.org/protobuf/types/known/timestamppb # gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc +## explicit gopkg.in/alexcesaro/quotedprintable.v3 # gopkg.in/asn1-ber.v1 v1.0.0-20150924051756-4e86f4367175 +## explicit gopkg.in/asn1-ber.v1 # gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df +## explicit gopkg.in/gomail.v2 # gopkg.in/ini.v1 v1.52.0 +## explicit gopkg.in/ini.v1 # gopkg.in/ldap.v3 v3.0.2 +## explicit gopkg.in/ldap.v3 # gopkg.in/macaron.v1 v1.3.9 +## explicit gopkg.in/macaron.v1 # gopkg.in/testfixtures.v2 v2.5.0 +## explicit gopkg.in/testfixtures.v2 # gopkg.in/toqueteos/substring.v1 v1.0.2 gopkg.in/toqueteos/substring.v1 # gopkg.in/warnings.v0 v0.1.2 gopkg.in/warnings.v0 # gopkg.in/yaml.v2 v2.2.8 +## explicit gopkg.in/yaml.v2 # mvdan.cc/xurls/v2 v2.1.0 +## explicit mvdan.cc/xurls/v2 # strk.kbt.io/projects/go/libravatar v0.0.0-20191008002943-06d1c002b251 +## explicit strk.kbt.io/projects/go/libravatar # xorm.io/builder v0.3.7 +## explicit xorm.io/builder # xorm.io/xorm v1.0.1 +## explicit xorm.io/xorm xorm.io/xorm/caches xorm.io/xorm/contexts From 9f7096326397e4fc14a6290a807ade3d9c19ff38 Mon Sep 17 00:00:00 2001 From: palytoxin Date: Mon, 25 Jan 2021 15:05:52 +0800 Subject: [PATCH 2/4] format code via make fmt --- models/action.go | 30 ++++----- models/attachment.go | 10 +-- models/blockchain.go | 26 ++++---- models/cloudbrain.go | 107 ++++++++++++++++---------------- models/login_source.go | 46 +++++++------- models/repo.go | 10 +-- models/user.go | 6 +- modules/auth/cloudbrain.go | 10 +-- modules/auth/cloudbrain/cloudbrain.go | 38 ++++++------ modules/blockchain/blockchain.go | 12 ++-- modules/blockchain/resty.go | 48 +++++++------- modules/cloudbrain/cloudbrain.go | 48 +++++++------- modules/context/auth.go | 12 ++-- modules/minio_ext/api-error-response.go | 3 + modules/minio_ext/api-list.go | 1 - modules/minio_ext/api-s3-datatypes.go | 2 +- modules/minio_ext/api.go | 23 +++---- modules/minio_ext/object.go | 3 + modules/setting/setting.go | 28 ++++----- modules/storage/minio_ext.go | 2 +- modules/worker/task.go | 2 +- routers/repo/attachment.go | 64 +++++++++---------- routers/repo/blockchain.go | 54 ++++++++-------- routers/repo/cloudbrain.go | 22 +++---- routers/repo/dir.go | 8 +-- routers/routes/routes.go | 2 +- 26 files changed, 309 insertions(+), 308 deletions(-) diff --git a/models/action.go b/models/action.go index a29ed343d..ab7d576e8 100755 --- a/models/action.go +++ b/models/action.go @@ -55,21 +55,21 @@ const ( // repository. It implemented interface base.Actioner so that can be // used in template render. type Action struct { - ID int64 `xorm:"pk autoincr"` - UserID int64 `xorm:"INDEX"` // Receiver user id. - OpType ActionType - ActUserID int64 `xorm:"INDEX"` // Action user id. - ActUser *User `xorm:"-"` - RepoID int64 `xorm:"INDEX"` - Repo *Repository `xorm:"-"` - CommentID int64 `xorm:"INDEX"` - Comment *Comment `xorm:"-"` - IsDeleted bool `xorm:"INDEX NOT NULL DEFAULT false"` - RefName string - IsPrivate bool `xorm:"INDEX NOT NULL DEFAULT false"` - IsTransformed bool `xorm:"INDEX NOT NULL DEFAULT false"` - Content string `xorm:"TEXT"` - CreatedUnix timeutil.TimeStamp `xorm:"INDEX created"` + ID int64 `xorm:"pk autoincr"` + UserID int64 `xorm:"INDEX"` // Receiver user id. + OpType ActionType + ActUserID int64 `xorm:"INDEX"` // Action user id. + ActUser *User `xorm:"-"` + RepoID int64 `xorm:"INDEX"` + Repo *Repository `xorm:"-"` + CommentID int64 `xorm:"INDEX"` + Comment *Comment `xorm:"-"` + IsDeleted bool `xorm:"INDEX NOT NULL DEFAULT false"` + RefName string + IsPrivate bool `xorm:"INDEX NOT NULL DEFAULT false"` + IsTransformed bool `xorm:"INDEX NOT NULL DEFAULT false"` + Content string `xorm:"TEXT"` + CreatedUnix timeutil.TimeStamp `xorm:"INDEX created"` } // GetOpType gets the ActionType of this action. diff --git a/models/attachment.go b/models/attachment.go index 063230e57..f08063b83 100755 --- a/models/attachment.go +++ b/models/attachment.go @@ -46,7 +46,7 @@ type Attachment struct { type AttachmentUsername struct { Attachment `xorm:"extends"` - Name string + Name string } func (a *Attachment) AfterUpdate() { @@ -359,7 +359,7 @@ func GetAllPublicAttachments() ([]*AttachmentUsername, error) { func getAllPublicAttachments(e Engine) ([]*AttachmentUsername, error) { attachments := make([]*AttachmentUsername, 0, 10) - if err := e.Table("attachment").Join("LEFT", "`user`", "attachment.uploader_id " + + if err := e.Table("attachment").Join("LEFT", "`user`", "attachment.uploader_id "+ "= `user`.id").Where("decompress_state= ? and is_private= ?", DecompressStateDone, false).Find(&attachments); err != nil { return nil, err } @@ -377,7 +377,7 @@ func GetPrivateAttachments(username string) ([]*AttachmentUsername, error) { func getPrivateAttachments(e Engine, userID int64) ([]*AttachmentUsername, error) { attachments := make([]*AttachmentUsername, 0, 10) - if err := e.Table("attachment").Join("LEFT", "`user`", "attachment.uploader_id " + + if err := e.Table("attachment").Join("LEFT", "`user`", "attachment.uploader_id "+ "= `user`.id").Where("decompress_state= ? and uploader_id= ?", DecompressStateDone, userID).Find(&attachments); err != nil { return nil, err } @@ -401,11 +401,11 @@ func GetAllUserAttachments(userID int64) ([]*AttachmentUsername, error) { return append(attachsPub, attachsPri...), nil } - */ +*/ func getAllUserAttachments(e Engine, userID int64) ([]*AttachmentUsername, error) { attachments := make([]*AttachmentUsername, 0, 10) - if err := e.Table("attachment").Join("LEFT", "`user`", "attachment.uploader_id " + + if err := e.Table("attachment").Join("LEFT", "`user`", "attachment.uploader_id "+ "= `user`.id").Where("decompress_state= ? and (uploader_id= ? or is_private = ?)", DecompressStateDone, userID, false).Find(&attachments); err != nil { return nil, err } diff --git a/models/blockchain.go b/models/blockchain.go index a84636a5b..f5ba8e1b6 100755 --- a/models/blockchain.go +++ b/models/blockchain.go @@ -7,24 +7,26 @@ import ( ) type BlockChainCommitStatus int + const ( BlockChainCommitInit BlockChainCommitStatus = iota BlockChainCommitSuccess BlockChainCommitFailed ) + type BlockChain struct { - ID int64 `xorm:"pk autoincr"` - CommitID string `xorm:"INDEX NOT NULL"` - Contributor string `xorm:"INDEX NOT NULL"` - ContractAddress string `xorm:"INDEX NOT NULL"` - Status BlockChainCommitStatus `xorm:"INDEX NOT NULL DEFAULT 0"` - Amount int64 `xorm:"INDEX"` - UserID int64 `xorm:"INDEX"` - RepoID int64 `xorm:"INDEX"` - TransactionHash string `xorm:"INDEX"` - CreatedUnix timeutil.TimeStamp `xorm:"created"` - UpdatedUnix timeutil.TimeStamp `xorm:"updated"` - DeletedAt time.Time `xorm:"deleted"` + ID int64 `xorm:"pk autoincr"` + CommitID string `xorm:"INDEX NOT NULL"` + Contributor string `xorm:"INDEX NOT NULL"` + ContractAddress string `xorm:"INDEX NOT NULL"` + Status BlockChainCommitStatus `xorm:"INDEX NOT NULL DEFAULT 0"` + Amount int64 `xorm:"INDEX"` + UserID int64 `xorm:"INDEX"` + RepoID int64 `xorm:"INDEX"` + TransactionHash string `xorm:"INDEX"` + CreatedUnix timeutil.TimeStamp `xorm:"created"` + UpdatedUnix timeutil.TimeStamp `xorm:"updated"` + DeletedAt time.Time `xorm:"deleted"` User *User `xorm:"-"` Repo *Repository `xorm:"-"` diff --git a/models/cloudbrain.go b/models/cloudbrain.go index 7244bc3ab..182a13a61 100755 --- a/models/cloudbrain.go +++ b/models/cloudbrain.go @@ -22,25 +22,25 @@ const ( JobFailed CloudbrainStatus = "FAILED" JobRunning CloudbrainStatus = "RUNNING" - JobTypeDebug JobType = "DEBUG" - JobTypeBenchmark JobType = "BENCHMARK" + JobTypeDebug JobType = "DEBUG" + JobTypeBenchmark JobType = "BENCHMARK" ) type Cloudbrain struct { ID int64 `xorm:"pk autoincr"` JobID string `xorm:"INDEX NOT NULL"` - JobType string `xorm:"INDEX NOT NULL DEFAULT 'DEBUG'"` - JobName string `xorm:"INDEX"` - Status string `xorm:"INDEX"` - UserID int64 `xorm:"INDEX"` - RepoID int64 `xorm:"INDEX"` - SubTaskName string `xorm:"INDEX"` + JobType string `xorm:"INDEX NOT NULL DEFAULT 'DEBUG'"` + JobName string `xorm:"INDEX"` + Status string `xorm:"INDEX"` + UserID int64 `xorm:"INDEX"` + RepoID int64 `xorm:"INDEX"` + SubTaskName string `xorm:"INDEX"` ContainerID string ContainerIp string CreatedUnix timeutil.TimeStamp `xorm:"INDEX created"` UpdatedUnix timeutil.TimeStamp `xorm:"INDEX updated"` - DeletedAt time.Time `xorm:"deleted"` - CanDebug bool `xorm:"-"` + DeletedAt time.Time `xorm:"deleted"` + CanDebug bool `xorm:"-"` User *User `xorm:"-"` Repo *Repository `xorm:"-"` @@ -64,17 +64,17 @@ type TaskRole struct { Command string `json:"command"` NeedIBDevice bool `json:"needIBDevice"` IsMainRole bool `json:"isMainRole"` - UseNNI bool `json:"useNNI"` + UseNNI bool `json:"useNNI"` } type StHostPath struct { - Path string `json:"path"` - MountPath string `json:"mountPath"` - ReadOnly bool `json:"readOnly"` + Path string `json:"path"` + MountPath string `json:"mountPath"` + ReadOnly bool `json:"readOnly"` } type Volume struct { - HostPath StHostPath `json:"hostPath"` + HostPath StHostPath `json:"hostPath"` } type CreateJobParams struct { @@ -87,9 +87,9 @@ type CreateJobParams struct { } type CreateJobResult struct { - Code string `json:"code"` - Msg string `json:"msg"` - Payload map[string]interface{} `json:"payload"` + Code string `json:"code"` + Msg string `json:"msg"` + Payload map[string]interface{} `json:"payload"` } type GetJobResult struct { @@ -99,8 +99,8 @@ type GetJobResult struct { } type GetImagesResult struct { - Code string `json:"code"` - Msg string `json:"msg"` + Code string `json:"code"` + Msg string `json:"msg"` Payload map[string]*ImageInfo `json:"payload"` } @@ -131,24 +131,23 @@ type TaskPod struct { ExitCode int `json:"exitCode"` ExitDiagnostics string `json:"exitDiagnostics"` RetriedCount int `json:"retriedCount"` - StartTime string - FinishedTime string + StartTime string + FinishedTime string } `json:"taskStatuses"` } - type TaskInfo struct { - Username string `json:"username"` - TaskName string `json:"task_name"` - CodeName string `json:"code_name"` + Username string `json:"username"` + TaskName string `json:"task_name"` + CodeName string `json:"code_name"` } func ConvertToTaskPod(input map[string]interface{}) (TaskPod, error) { data, _ := json.Marshal(input) var taskPod TaskPod err := json.Unmarshal(data, &taskPod) - taskPod.TaskStatuses[0].StartTime = time.Unix(taskPod.TaskStatuses[0].StartAt.Unix() + 8*3600, 0).UTC().Format("2006-01-02 15:04:05") - taskPod.TaskStatuses[0].FinishedTime = time.Unix(taskPod.TaskStatuses[0].FinishedAt.Unix() + 8*3600, 0).UTC().Format("2006-01-02 15:04:05") + taskPod.TaskStatuses[0].StartTime = time.Unix(taskPod.TaskStatuses[0].StartAt.Unix()+8*3600, 0).UTC().Format("2006-01-02 15:04:05") + taskPod.TaskStatuses[0].FinishedTime = time.Unix(taskPod.TaskStatuses[0].FinishedAt.Unix()+8*3600, 0).UTC().Format("2006-01-02 15:04:05") return taskPod, err } @@ -173,8 +172,8 @@ type JobResultPayload struct { AppExitDiagnostics string `json:"appExitDiagnostics"` AppExitType interface{} `json:"appExitType"` VirtualCluster string `json:"virtualCluster"` - StartTime string - EndTime string + StartTime string + EndTime string } `json:"jobStatus"` TaskRoles map[string]interface{} `json:"taskRoles"` Resource struct { @@ -220,42 +219,42 @@ func ConvertToJobResultPayload(input map[string]interface{}) (JobResultPayload, type ImagesResultPayload struct { Images []struct { - ID int `json:"id"` - Name string `json:"name"` - Place string `json:"place"` - Description string `json:"description"` - Provider string `json:"provider"` - Createtime string `json:"createtime"` - Remark string `json:"remark"` + ID int `json:"id"` + Name string `json:"name"` + Place string `json:"place"` + Description string `json:"description"` + Provider string `json:"provider"` + Createtime string `json:"createtime"` + Remark string `json:"remark"` } `json:"taskStatuses"` } type ImageInfo struct { - ID int `json:"id"` - Name string `json:"name"` - Place string `json:"place"` - Description string `json:"description"` - Provider string `json:"provider"` - Createtime string `json:"createtime"` - Remark string `json:"remark"` - PlaceView string + ID int `json:"id"` + Name string `json:"name"` + Place string `json:"place"` + Description string `json:"description"` + Provider string `json:"provider"` + Createtime string `json:"createtime"` + Remark string `json:"remark"` + PlaceView string } type CommitImageParams struct { - Ip string `json:"ip"` - TaskContainerId string `json:"taskContainerId"` - ImageTag string `json:"imageTag"` - ImageDescription string `json:"imageDescription"` + Ip string `json:"ip"` + TaskContainerId string `json:"taskContainerId"` + ImageTag string `json:"imageTag"` + ImageDescription string `json:"imageDescription"` } type CommitImageResult struct { - Code string `json:"code"` - Msg string `json:"msg"` - Payload map[string]interface{} `json:"payload"` + Code string `json:"code"` + Msg string `json:"msg"` + Payload map[string]interface{} `json:"payload"` } type StopJobResult struct { - Code string `json:"code"` - Msg string `json:"msg"` + Code string `json:"code"` + Msg string `json:"msg"` } func Cloudbrains(opts *CloudbrainsOptions) ([]*Cloudbrain, int64, error) { diff --git a/models/login_source.go b/models/login_source.go index 7153606a9..ca2aa5a4d 100755 --- a/models/login_source.go +++ b/models/login_source.go @@ -32,25 +32,25 @@ type LoginType int // Note: new type must append to the end of list to maintain compatibility. const ( - LoginNoType LoginType = iota - LoginPlain // 1 - LoginLDAP // 2 - LoginSMTP // 3 - LoginPAM // 4 - LoginDLDAP // 5 - LoginOAuth2 // 6 - LoginSSPI // 7 - LoginCloudBrain // 8 + LoginNoType LoginType = iota + LoginPlain // 1 + LoginLDAP // 2 + LoginSMTP // 3 + LoginPAM // 4 + LoginDLDAP // 5 + LoginOAuth2 // 6 + LoginSSPI // 7 + LoginCloudBrain // 8 ) // LoginNames contains the name of LoginType values. var LoginNames = map[LoginType]string{ - LoginLDAP: "LDAP (via BindDN)", - LoginDLDAP: "LDAP (simple auth)", // Via direct bind - LoginSMTP: "SMTP", - LoginPAM: "PAM", - LoginOAuth2: "OAuth2", - LoginSSPI: "SPNEGO with SSPI", + LoginLDAP: "LDAP (via BindDN)", + LoginDLDAP: "LDAP (simple auth)", // Via direct bind + LoginSMTP: "SMTP", + LoginPAM: "PAM", + LoginOAuth2: "OAuth2", + LoginSSPI: "SPNEGO with SSPI", LoginCloudBrain: "Cloud Brain", } @@ -849,14 +849,14 @@ func LoginViaCloudBrain(user *User, login, password string, source *LoginSource) } user = &User{ - LowerName: strings.ToLower(login), - Name: login, - Email: cloudBrainUser.Email, - LoginType: source.Type, - LoginSource: source.ID, - LoginName: login, - IsActive: true, - Token: token, + LowerName: strings.ToLower(login), + Name: login, + Email: cloudBrainUser.Email, + LoginType: source.Type, + LoginSource: source.ID, + LoginName: login, + IsActive: true, + Token: token, } err = CreateUser(user) diff --git a/models/repo.go b/models/repo.go index 7cda4ce8a..166097e44 100755 --- a/models/repo.go +++ b/models/repo.go @@ -144,7 +144,7 @@ const ( ) const ( - RepoBlockChainInit RepoBlockChainStatus = iota + RepoBlockChainInit RepoBlockChainStatus = iota RepoBlockChainSuccess RepoBlockChainFailed ) @@ -204,9 +204,9 @@ type Repository struct { Avatar string `xorm:"VARCHAR(64)"` //blockchain - ContractAddress string `xorm:"INDEX"` - Balance int64 `xorm:"NOT NULL DEFAULT 0"` - BlockChainStatus RepoBlockChainStatus `xorm:"NOT NULL DEFAULT 0"` + ContractAddress string `xorm:"INDEX"` + Balance int64 `xorm:"NOT NULL DEFAULT 0"` + BlockChainStatus RepoBlockChainStatus `xorm:"NOT NULL DEFAULT 0"` CreatedUnix timeutil.TimeStamp `xorm:"INDEX created"` UpdatedUnix timeutil.TimeStamp `xorm:"INDEX updated"` @@ -1408,7 +1408,7 @@ func updateRepository(e Engine, repo *Repository, visibilityChanged bool) (err e repo.Description = repo.Description[:255] } - */ + */ if len(repo.Website) > 255 { repo.Website = repo.Website[:255] } diff --git a/models/user.go b/models/user.go index 2b1195179..e076949ec 100755 --- a/models/user.go +++ b/models/user.go @@ -171,11 +171,11 @@ type User struct { Theme string `xorm:"NOT NULL DEFAULT ''"` //CloudBrain - Token string `xorm:"VARCHAR(1024)"` + Token string `xorm:"VARCHAR(1024)"` //BlockChain - PublicKey string `xorm` - PrivateKey string `xorm` + PublicKey string `xorm` + PrivateKey string `xorm` } // SearchOrganizationsOptions options to filter organizations diff --git a/modules/auth/cloudbrain.go b/modules/auth/cloudbrain.go index ce2733afb..2b150cf75 100755 --- a/modules/auth/cloudbrain.go +++ b/modules/auth/cloudbrain.go @@ -7,16 +7,16 @@ import ( // CreateDatasetForm form for dataset page type CreateCloudBrainForm struct { - JobName string `form:"job_name" binding:"Required"` - Image string `form:"image" binding:"Required"` - Command string `form:"command" binding:"Required"` + JobName string `form:"job_name" binding:"Required"` + Image string `form:"image" binding:"Required"` + Command string `form:"command" binding:"Required"` Attachment string `form:"attachment" binding:"Required"` - JobType string `form:"job_type" binding:"Required"` + JobType string `form:"job_type" binding:"Required"` } type CommitImageCloudBrainForm struct { Description string `form:"description" binding:"Required"` - Tag string `form:"tag" binding:"Required"` + Tag string `form:"tag" binding:"Required"` } func (f *CreateCloudBrainForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors { diff --git a/modules/auth/cloudbrain/cloudbrain.go b/modules/auth/cloudbrain/cloudbrain.go index 4020faa5f..acab326b7 100755 --- a/modules/auth/cloudbrain/cloudbrain.go +++ b/modules/auth/cloudbrain/cloudbrain.go @@ -12,7 +12,7 @@ import ( ) const ( - UrlToken = "/rest-server/api/v1/token/" + UrlToken = "/rest-server/api/v1/token/" UrlGetUserInfo = "/rest-server/api/v1/user/" TokenTypeBear = "Bearer " @@ -21,29 +21,29 @@ const ( ) type RespAuth struct { - AccessToken string `json:"access_token"` - RefreshToken string `json:"refresh_token"` - TokenType string `json:"token_type"` - ExpiresIn int `json:"expires_in"` - Error string `json:"error"` + AccessToken string `json:"access_token"` + RefreshToken string `json:"refresh_token"` + TokenType string `json:"token_type"` + ExpiresIn int `json:"expires_in"` + Error string `json:"error"` ErrorDescription string `json:"error_description"` } type RespToken struct { - Code string `json:"code"` - Message string `json:"msg"` + Code string `json:"code"` + Message string `json:"msg"` Payload PayloadToken `json:"payload"` } type PayloadToken struct { Username string `json:"username"` - Token string `json:"token"` - IsAdmin bool `json:"admin"` + Token string `json:"token"` + IsAdmin bool `json:"admin"` } type RespUserInfo struct { - Code string `json:"code"` - Message string `json:"msg"` + Code string `json:"code"` + Message string `json:"msg"` Payload PayloadUserInfo `json:"payload"` } @@ -57,13 +57,13 @@ type StUserInfo struct { type CloudBrainUser struct { UserName string `json:"username"` - Email string `json:"email"` + Email string `json:"email"` } func UserValidate(username string, password string) (string, error) { values := map[string]string{"username": username, "password": password} jsonValue, _ := json.Marshal(values) - resp, err := http.Post(setting.RestServerHost + UrlToken, + resp, err := http.Post(setting.RestServerHost+UrlToken, "application/json", bytes.NewBuffer(jsonValue)) if err != nil { @@ -73,7 +73,7 @@ func UserValidate(username string, password string) (string, error) { defer resp.Body.Close() - body,err := ioutil.ReadAll(resp.Body) + body, err := ioutil.ReadAll(resp.Body) if err != nil { log.Error("read resp body failed:" + err.Error()) return "", err @@ -98,14 +98,14 @@ func GetUserInfo(username string, token string) (*CloudBrainUser, error) { user := &CloudBrainUser{} client := &http.Client{} - reqHttp,err := http.NewRequest("GET", setting.RestServerHost + UrlGetUserInfo + username, strings.NewReader("")) + reqHttp, err := http.NewRequest("GET", setting.RestServerHost+UrlGetUserInfo+username, strings.NewReader("")) if err != nil { log.Error("new req failed:", err.Error()) return nil, err } - reqHttp.Header.Set("Authorization", TokenTypeBear + token) - resp,err := client.Do(reqHttp) + reqHttp.Header.Set("Authorization", TokenTypeBear+token) + resp, err := client.Do(reqHttp) if err != nil { log.Error("req rest-server failed:", err.Error()) return nil, err @@ -113,7 +113,7 @@ func GetUserInfo(username string, token string) (*CloudBrainUser, error) { defer resp.Body.Close() - body,err := ioutil.ReadAll(resp.Body) + body, err := ioutil.ReadAll(resp.Body) if err != nil { log.Error("read resp body failed:", err.Error()) return nil, err diff --git a/modules/blockchain/blockchain.go b/modules/blockchain/blockchain.go index 6ebf701da..00aeb8808 100755 --- a/modules/blockchain/blockchain.go +++ b/modules/blockchain/blockchain.go @@ -1,14 +1,12 @@ package blockchain const ( - Command = `pip3 install jupyterlab==2.2.5 -i https://pypi.tuna.tsinghua.edu.cn/simple;service ssh stop;jupyter lab --no-browser --ip=0.0.0.0 --allow-root --notebook-dir="/code" --port=80 --LabApp.token="" --LabApp.allow_origin="self https://cloudbrain.pcl.ac.cn"` - CodeMountPath = "/code" - DataSetMountPath = "/dataset" - ModelMountPath = "/model" + Command = `pip3 install jupyterlab==2.2.5 -i https://pypi.tuna.tsinghua.edu.cn/simple;service ssh stop;jupyter lab --no-browser --ip=0.0.0.0 --allow-root --notebook-dir="/code" --port=80 --LabApp.token="" --LabApp.allow_origin="self https://cloudbrain.pcl.ac.cn"` + CodeMountPath = "/code" + DataSetMountPath = "/dataset" + ModelMountPath = "/model" BenchMarkMountPath = "/benchmark" - TaskInfoName = "/taskInfo" + TaskInfoName = "/taskInfo" SubTaskName = "task1" - - ) diff --git a/modules/blockchain/resty.go b/modules/blockchain/resty.go index 060d63144..47fe11ddb 100755 --- a/modules/blockchain/resty.go +++ b/modules/blockchain/resty.go @@ -13,9 +13,9 @@ var ( const ( UrlCreateAccount = "createAccount" - UrlGetBalance = "getBalance" - UrlNewRepo = "newRepo" - UrlContribute = "contribute" + UrlGetBalance = "getBalance" + UrlNewRepo = "newRepo" + UrlContribute = "contribute" ActionCommit = "commit" @@ -23,27 +23,27 @@ const ( ) type CreateAccountResult struct { - Code int `json:"code"` - Msg string `json:"message"` - Payload map[string]interface{} `json:"data"` + Code int `json:"code"` + Msg string `json:"message"` + Payload map[string]interface{} `json:"data"` } type GetBalanceResult struct { - Code int `json:"code"` - Msg string `json:"message"` - Payload map[string]interface{} `json:"data"` + Code int `json:"code"` + Msg string `json:"message"` + Payload map[string]interface{} `json:"data"` } type NewRepoResult struct { - Code int `json:"code"` - Msg string `json:"message"` + Code int `json:"code"` + Msg string `json:"message"` //Data string `json:"data"` } type ContributeResult struct { - Code int `json:"code"` - Msg string `json:"message"` - Payload map[string]interface{} `json:"data"` + Code int `json:"code"` + Msg string `json:"message"` + Payload map[string]interface{} `json:"data"` } func getRestyClient() *resty.Client { @@ -80,9 +80,9 @@ func NewRepo(repoID, publicKey, repoName string) (*NewRepoResult, error) { res, err := client.R(). SetHeader("Accept", "application/json"). SetQueryParams(map[string]string{ - "repoId" : repoID, - "creator" : publicKey, - "repoName" : repoName, + "repoId": repoID, + "creator": publicKey, + "repoName": repoName, }). SetResult(&result). Get(setting.BlockChainHost + UrlNewRepo) @@ -105,8 +105,8 @@ func GetBalance(contractAddress, contributor string) (*GetBalanceResult, error) res, err := client.R(). SetHeader("Accept", "application/json"). SetQueryParams(map[string]string{ - "contractAddress" : contractAddress, - "contributor" : contributor, + "contractAddress": contractAddress, + "contributor": contributor, }). SetResult(&result). Get(setting.BlockChainHost + UrlGetBalance) @@ -129,11 +129,11 @@ func Contribute(contractAddress, contributor, action, commitId string, codeLine res, err := client.R(). SetHeader("Accept", "application/json"). SetQueryParams(map[string]string{ - "contractAddress" : contractAddress, - "contributor" : contributor, - "action" : action, - "commitId": commitId, - "amount": string(codeLine), + "contractAddress": contractAddress, + "contributor": contributor, + "action": action, + "commitId": commitId, + "amount": string(codeLine), }). SetResult(&result). Get(setting.BlockChainHost + UrlContribute) diff --git a/modules/cloudbrain/cloudbrain.go b/modules/cloudbrain/cloudbrain.go index dccbee5c6..dedfb55f6 100755 --- a/modules/cloudbrain/cloudbrain.go +++ b/modules/cloudbrain/cloudbrain.go @@ -10,12 +10,12 @@ import ( ) const ( - Command = `pip3 install jupyterlab==2.2.5 -i https://pypi.tuna.tsinghua.edu.cn/simple;service ssh stop;jupyter lab --no-browser --ip=0.0.0.0 --allow-root --notebook-dir="/code" --port=80 --LabApp.token="" --LabApp.allow_origin="self https://cloudbrain.pcl.ac.cn"` - CodeMountPath = "/code" - DataSetMountPath = "/dataset" - ModelMountPath = "/model" + Command = `pip3 install jupyterlab==2.2.5 -i https://pypi.tuna.tsinghua.edu.cn/simple;service ssh stop;jupyter lab --no-browser --ip=0.0.0.0 --allow-root --notebook-dir="/code" --port=80 --LabApp.token="" --LabApp.allow_origin="self https://cloudbrain.pcl.ac.cn"` + CodeMountPath = "/code" + DataSetMountPath = "/dataset" + ModelMountPath = "/model" BenchMarkMountPath = "/benchmark" - TaskInfoName = "/taskInfo" + TaskInfoName = "/taskInfo" SubTaskName = "task1" @@ -46,36 +46,36 @@ func GenerateTask(ctx *context.Context, jobName, image, command, uuid, codePath, Command: command, NeedIBDevice: false, IsMainRole: false, - UseNNI: false, + UseNNI: false, }, }, Volumes: []models.Volume{ { HostPath: models.StHostPath{ - Path: codePath, - MountPath: CodeMountPath, - ReadOnly: false, + Path: codePath, + MountPath: CodeMountPath, + ReadOnly: false, }, }, { HostPath: models.StHostPath{ - Path: dataActualPath, - MountPath: DataSetMountPath, - ReadOnly: true, + Path: dataActualPath, + MountPath: DataSetMountPath, + ReadOnly: true, }, }, { HostPath: models.StHostPath{ - Path: modelPath, - MountPath: ModelMountPath, - ReadOnly: false, + Path: modelPath, + MountPath: ModelMountPath, + ReadOnly: false, }, }, { HostPath: models.StHostPath{ - Path: benchmarkPath, - MountPath: BenchMarkMountPath, - ReadOnly: true, + Path: benchmarkPath, + MountPath: BenchMarkMountPath, + ReadOnly: true, }, }, }, @@ -91,13 +91,13 @@ func GenerateTask(ctx *context.Context, jobName, image, command, uuid, codePath, var jobID = jobResult.Payload["jobId"].(string) err = models.CreateCloudbrain(&models.Cloudbrain{ - Status: string(models.JobWaiting), - UserID: ctx.User.ID, - RepoID: ctx.Repo.Repository.ID, - JobID: jobID, - JobName: jobName, + Status: string(models.JobWaiting), + UserID: ctx.User.ID, + RepoID: ctx.Repo.Repository.ID, + JobID: jobID, + JobName: jobName, SubTaskName: SubTaskName, - JobType: jobType, + JobType: jobType, }) if err != nil { diff --git a/modules/context/auth.go b/modules/context/auth.go index 34b74523d..6aee002b5 100755 --- a/modules/context/auth.go +++ b/modules/context/auth.go @@ -21,10 +21,10 @@ import ( // ToggleOptions contains required or check options type ToggleOptions struct { - SignInRequired bool - SignOutRequired bool - AdminRequired bool - DisableCSRF bool + SignInRequired bool + SignOutRequired bool + AdminRequired bool + DisableCSRF bool BasicAuthRequired bool } @@ -149,7 +149,7 @@ func basicAuth(ctx *Context) bool { var siteAuth = base64.StdEncoding.EncodeToString([]byte(setting.CBAuthUser + ":" + setting.CBAuthPassword)) auth := ctx.Req.Header.Get("Authorization") - if !marc_auth.SecureCompare(auth, "Basic " + siteAuth) { + if !marc_auth.SecureCompare(auth, "Basic "+siteAuth) { return false } @@ -158,6 +158,6 @@ func basicAuth(ctx *Context) bool { } func basicUnauthorized(res http.ResponseWriter) { - res.Header().Set("WWW-Authenticate", "Basic realm=\"" + marc_auth.BasicRealm + "\"") + res.Header().Set("WWW-Authenticate", "Basic realm=\""+marc_auth.BasicRealm+"\"") http.Error(res, "Not Authorized", http.StatusUnauthorized) } diff --git a/modules/minio_ext/api-error-response.go b/modules/minio_ext/api-error-response.go index b515c829c..5dee08500 100755 --- a/modules/minio_ext/api-error-response.go +++ b/modules/minio_ext/api-error-response.go @@ -27,9 +27,11 @@ type ErrorResponse struct { func (e ErrorResponse) Error() string { return e.Message } + const ( reportIssue = "Please report this issue at https://github.com/minio/minio/issues." ) + // httpRespToErrorResponse returns a new encoded ErrorResponse // structure as error. func httpRespToErrorResponse(resp *http.Response, bucketName, objectName string) error { @@ -122,6 +124,7 @@ func ToErrorResponse(err error) ErrorResponse { return ErrorResponse{} } } + // ErrInvalidArgument - Invalid argument response. func ErrInvalidArgument(message string) error { return ErrorResponse{ diff --git a/modules/minio_ext/api-list.go b/modules/minio_ext/api-list.go index 5904431e7..b9dc27cb5 100755 --- a/modules/minio_ext/api-list.go +++ b/modules/minio_ext/api-list.go @@ -38,7 +38,6 @@ func (c Client) ListObjectParts(bucketName, objectName, uploadID string) (partsI return partsInfo, nil } - // listObjectPartsQuery (List Parts query) // - lists some or all (up to 1000) parts that have been uploaded // for a specific multipart upload diff --git a/modules/minio_ext/api-s3-datatypes.go b/modules/minio_ext/api-s3-datatypes.go index df13ca380..37412dbbb 100755 --- a/modules/minio_ext/api-s3-datatypes.go +++ b/modules/minio_ext/api-s3-datatypes.go @@ -68,4 +68,4 @@ type ListObjectPartsResult struct { ObjectParts []ObjectPart `xml:"Part"` EncodingType string -} \ No newline at end of file +} diff --git a/modules/minio_ext/api.go b/modules/minio_ext/api.go index d3d7272e5..79583b99b 100755 --- a/modules/minio_ext/api.go +++ b/modules/minio_ext/api.go @@ -142,7 +142,6 @@ func (r *lockedRandSource) Seed(seed int64) { r.lk.Unlock() } - // Different types of url lookup supported by the server.Initialized to BucketLookupAuto const ( BucketLookupAuto BucketLookupType = iota @@ -904,8 +903,7 @@ func (c Client) newRequest(method string, metadata requestMetadata) (req *http.R return req, nil } - -func (c Client) GenUploadPartSignedUrl(uploadID string, bucketName string, objectName string, partNumber int, size int64, expires time.Duration, bucketLocation string) (string, error){ +func (c Client) GenUploadPartSignedUrl(uploadID string, bucketName string, objectName string, partNumber int, size int64, expires time.Duration, bucketLocation string) (string, error) { signedUrl := "" // Input validation. @@ -939,17 +937,17 @@ func (c Client) GenUploadPartSignedUrl(uploadID string, bucketName string, objec customHeader := make(http.Header) reqMetadata := requestMetadata{ - presignURL: true, - bucketName: bucketName, - objectName: objectName, - queryValues: urlValues, - customHeader: customHeader, + presignURL: true, + bucketName: bucketName, + objectName: objectName, + queryValues: urlValues, + customHeader: customHeader, //contentBody: reader, - contentLength: size, + contentLength: size, //contentMD5Base64: md5Base64, //contentSHA256Hex: sha256Hex, - expires: int64(expires/time.Second), - bucketLocation: bucketLocation, + expires: int64(expires / time.Second), + bucketLocation: bucketLocation, } req, err := c.newRequest("PUT", reqMetadata) @@ -959,10 +957,9 @@ func (c Client) GenUploadPartSignedUrl(uploadID string, bucketName string, objec } signedUrl = req.URL.String() - return signedUrl,nil + return signedUrl, nil } - // executeMethod - instantiates a given method, and retries the // request upon any error up to maxRetries attempts in a binomially // delayed manner using a standard back off algorithm. diff --git a/modules/minio_ext/object.go b/modules/minio_ext/object.go index 3a075e457..12fed7d5c 100755 --- a/modules/minio_ext/object.go +++ b/modules/minio_ext/object.go @@ -8,10 +8,12 @@ import ( // StringMap represents map with custom UnmarshalXML type StringMap map[string]string + // CommonPrefix container for prefix response. type CommonPrefix struct { Prefix string } + // ObjectInfo container for object metadata. type ObjectInfo struct { // An ETag is optionally set to md5sum of an object. In case of multipart objects, @@ -44,6 +46,7 @@ type ObjectInfo struct { // Error Err error `json:"-"` } + // ListBucketResult container for listObjects response. type ListBucketResult struct { // A response can contain CommonPrefixes only if you have diff --git a/modules/setting/setting.go b/modules/setting/setting.go index f3888b9e7..c11c70ccc 100755 --- a/modules/setting/setting.go +++ b/modules/setting/setting.go @@ -427,26 +427,26 @@ var ( ResultBackend string //decompress config - DecompressAddress string - AuthUser string - AuthPassword string + DecompressAddress string + AuthUser string + AuthPassword string //cloudbrain config - CBAuthUser string - CBAuthPassword string - RestServerHost string - JobPath string - JobType string - DebugServerHost string + CBAuthUser string + CBAuthPassword string + RestServerHost string + JobPath string + JobType string + DebugServerHost string //benchmark config - IsBenchmarkEnabled bool - BenchmarkCode string - BenchmarkServerHost string + IsBenchmarkEnabled bool + BenchmarkCode string + BenchmarkServerHost string //blockchain config - BlockChainHost string - CommitValidDate string + BlockChainHost string + CommitValidDate string ) // DateLang transforms standard language locale name to corresponding value in datetime plugin. diff --git a/modules/storage/minio_ext.go b/modules/storage/minio_ext.go index e110138f7..2f738ebad 100755 --- a/modules/storage/minio_ext.go +++ b/modules/storage/minio_ext.go @@ -150,7 +150,7 @@ func CompleteMultiPartUpload(uuid string, uploadID string) (string, error) { for _, partInfo := range partInfos { complMultipartUpload.Parts = append(complMultipartUpload.Parts, miniov6.CompletePart{ PartNumber: partInfo.PartNumber, - ETag: partInfo.ETag, + ETag: partInfo.ETag, }) } diff --git a/modules/worker/task.go b/modules/worker/task.go index 48ba32c3e..ceb305ca1 100755 --- a/modules/worker/task.go +++ b/modules/worker/task.go @@ -14,7 +14,7 @@ const ( ) func SendDecompressTask(ctx context.Context, uuid string) error { - args := []tasks.Arg{{Name: "uuid", Type: "string", Value: uuid},{}} + args := []tasks.Arg{{Name: "uuid", Type: "string", Value: uuid}, {}} task, err := tasks.NewSignature(DecompressTaskName, args) if err != nil { log.Error("NewSignature failed:", err.Error()) diff --git a/routers/repo/attachment.go b/routers/repo/attachment.go index f474f88d6..0258a5373 100755 --- a/routers/repo/attachment.go +++ b/routers/repo/attachment.go @@ -30,10 +30,10 @@ const ( ) type CloudBrainDataset struct { - UUID string `json:"id"` - Name string `json:"name"` - Path string `json:"place"` - UserName string `json:"provider"` + UUID string `json:"id"` + Name string `json:"name"` + Path string `json:"place"` + UserName string `json:"provider"` CreateTime string `json:"created_at"` } @@ -402,13 +402,13 @@ func GetSuccessChunks(ctx *context.Context) { if attach == nil { ctx.JSON(200, map[string]string{ - "uuid": fileChunk.UUID, - "uploaded": strconv.Itoa(fileChunk.IsUploaded), - "uploadID": fileChunk.UploadID, - "chunks": string(chunks), - "attachID": "0", - "datasetID": "0", - "fileName": "", + "uuid": fileChunk.UUID, + "uploaded": strconv.Itoa(fileChunk.IsUploaded), + "uploadID": fileChunk.UploadID, + "chunks": string(chunks), + "attachID": "0", + "datasetID": "0", + "fileName": "", "datasetName": "", }) return @@ -421,13 +421,13 @@ func GetSuccessChunks(ctx *context.Context) { } ctx.JSON(200, map[string]string{ - "uuid": fileChunk.UUID, - "uploaded": strconv.Itoa(fileChunk.IsUploaded), - "uploadID": fileChunk.UploadID, - "chunks": string(chunks), - "attachID": strconv.Itoa(int(attachID)), - "datasetID": strconv.Itoa(int(attach.DatasetID)), - "fileName": attach.Name, + "uuid": fileChunk.UUID, + "uploaded": strconv.Itoa(fileChunk.IsUploaded), + "uploadID": fileChunk.UploadID, + "chunks": string(chunks), + "attachID": strconv.Itoa(int(attachID)), + "datasetID": strconv.Itoa(int(attach.DatasetID)), + "fileName": attach.Name, "datasetName": dataset.Title, }) @@ -624,13 +624,13 @@ func HandleUnDecompressAttachment() { return } -func QueryAllPublicDataset(ctx *context.Context){ +func QueryAllPublicDataset(ctx *context.Context) { attachs, err := models.GetAllPublicAttachments() if err != nil { ctx.JSON(200, map[string]string{ "result_code": "-1", - "error_msg": err.Error(), - "data": "", + "error_msg": err.Error(), + "data": "", }) return } @@ -638,14 +638,14 @@ func QueryAllPublicDataset(ctx *context.Context){ queryDatasets(ctx, attachs) } -func QueryPrivateDataset(ctx *context.Context){ +func QueryPrivateDataset(ctx *context.Context) { username := ctx.Params(":username") attachs, err := models.GetPrivateAttachments(username) if err != nil { ctx.JSON(200, map[string]string{ "result_code": "-1", - "error_msg": err.Error(), - "data": "", + "error_msg": err.Error(), + "data": "", }) return } @@ -663,14 +663,14 @@ func queryDatasets(ctx *context.Context, attachs []*models.AttachmentUsername) { log.Info("dataset is null") ctx.JSON(200, map[string]string{ "result_code": "0", - "error_msg": "", - "data": "", + "error_msg": "", + "data": "", }) return } for _, attch := range attachs { - has,err := storage.Attachments.HasObject(models.AttachmentRelativePath(attch.UUID)) + has, err := storage.Attachments.HasObject(models.AttachmentRelativePath(attch.UUID)) if err != nil || !has { continue } @@ -686,21 +686,21 @@ func queryDatasets(ctx *context.Context, attachs []*models.AttachmentUsername) { attch.CreatedUnix.Format("2006-01-02 03:04:05 PM")}) } - data,err := json.Marshal(datasets) + data, err := json.Marshal(datasets) if err != nil { log.Error("json.Marshal failed:", err.Error()) ctx.JSON(200, map[string]string{ "result_code": "-1", - "error_msg": err.Error(), - "data": "", + "error_msg": err.Error(), + "data": "", }) return } ctx.JSON(200, map[string]string{ "result_code": "0", - "error_msg": "", - "data": string(data), + "error_msg": "", + "data": string(data), }) return } diff --git a/routers/repo/blockchain.go b/routers/repo/blockchain.go index 9aa705574..cb7e5a196 100755 --- a/routers/repo/blockchain.go +++ b/routers/repo/blockchain.go @@ -12,13 +12,13 @@ import ( ) type BlockChainInitNotify struct { - RepoId int64 `json:"repoId"` - ContractAddress string `json:"contractAddress"` + RepoId int64 `json:"repoId"` + ContractAddress string `json:"contractAddress"` } type BlockChainCommitNotify struct { - CommitID string `json:"commitId"` - TransactionHash string `json:"txHash"` + CommitID string `json:"commitId"` + TransactionHash string `json:"txHash"` } func HandleBlockChainInitNotify(ctx *context.Context) { @@ -30,8 +30,8 @@ func HandleBlockChainInitNotify(ctx *context.Context) { if err != nil { log.Error("GetRepositoryByID failed:", err.Error()) ctx.JSON(200, map[string]string{ - "code" : "-1", - "message" : "internal error", + "code": "-1", + "message": "internal error", }) return } @@ -39,8 +39,8 @@ func HandleBlockChainInitNotify(ctx *context.Context) { if repo.BlockChainStatus == models.RepoBlockChainSuccess && len(repo.ContractAddress) != 0 { log.Error("the repo has been RepoBlockChainSuccess:", req.RepoId) ctx.JSON(200, map[string]string{ - "code" : "-1", - "message" : "the repo has been RepoBlockChainSuccess", + "code": "-1", + "message": "the repo has been RepoBlockChainSuccess", }) return } @@ -51,14 +51,14 @@ func HandleBlockChainInitNotify(ctx *context.Context) { if err = models.UpdateRepositoryCols(repo, "block_chain_status", "contract_address"); err != nil { log.Error("UpdateRepositoryCols failed:", err.Error()) ctx.JSON(200, map[string]string{ - "code" : "-1", - "message" : "internal error", + "code": "-1", + "message": "internal error", }) return } ctx.JSON(200, map[string]string{ - "code": "0", + "code": "0", "message": "", }) } @@ -69,8 +69,8 @@ func HandleBlockChainCommitNotify(ctx *context.Context) { if err := json.Unmarshal(data, &req); err != nil { log.Error("json.Unmarshal failed:", err.Error()) ctx.JSON(200, map[string]string{ - "code" : "-1", - "message" : "response data error", + "code": "-1", + "message": "response data error", }) return } @@ -79,8 +79,8 @@ func HandleBlockChainCommitNotify(ctx *context.Context) { if err != nil { log.Error("GetRepositoryByID failed:", err.Error()) ctx.JSON(200, map[string]string{ - "code" : "-1", - "message" : "internal error", + "code": "-1", + "message": "internal error", }) return } @@ -88,8 +88,8 @@ func HandleBlockChainCommitNotify(ctx *context.Context) { if blockChain.Status == models.BlockChainCommitSuccess { log.Error("the commit has been BlockChainCommitReady:", blockChain.RepoID) ctx.JSON(200, map[string]string{ - "code" : "-1", - "message" : "the commit has been BlockChainCommitReady", + "code": "-1", + "message": "the commit has been BlockChainCommitReady", }) return } @@ -100,14 +100,14 @@ func HandleBlockChainCommitNotify(ctx *context.Context) { if err = models.UpdateBlockChainCols(blockChain, "status", "transaction_hash"); err != nil { log.Error("UpdateBlockChainCols failed:", err.Error()) ctx.JSON(200, map[string]string{ - "code" : "-1", - "message" : "internal error", + "code": "-1", + "message": "internal error", }) return } ctx.JSON(200, map[string]string{ - "code": "0", + "code": "0", "message": "", }) } @@ -226,13 +226,13 @@ func HandleUnTransformedActions() { } blockChain := models.BlockChain{ - CommitID : commit.Sha1, - Contributor : user.PublicKey, - ContractAddress : repo.ContractAddress, - Status : models.BlockChainCommitInit, - Amount : 1, - UserID : action.UserID, - RepoID : action.RepoID, + CommitID: commit.Sha1, + Contributor: user.PublicKey, + ContractAddress: repo.ContractAddress, + Status: models.BlockChainCommitInit, + Amount: 1, + UserID: action.UserID, + RepoID: action.RepoID, } _, err = models.InsertBlockChain(&blockChain) if err != nil { diff --git a/routers/repo/cloudbrain.go b/routers/repo/cloudbrain.go index d22d44ced..5b19166be 100755 --- a/routers/repo/cloudbrain.go +++ b/routers/repo/cloudbrain.go @@ -55,7 +55,7 @@ func CloudBrainIndex(ctx *context.Context) { timestamp := time.Now().Unix() for i, task := range ciTasks { - if task.Status == string(models.JobRunning) && (timestamp - int64(task.CreatedUnix) > 30){ + if task.Status == string(models.JobRunning) && (timestamp-int64(task.CreatedUnix) > 30) { ciTasks[i].CanDebug = true } else { ciTasks[i].CanDebug = false @@ -90,9 +90,9 @@ func CloudBrainNew(ctx *context.Context) { ctx.Data["error"] = err.Error() } - for i,payload := range result.Payload { - if strings.HasPrefix(result.Payload[i].Place,"192.168") { - result.Payload[i].PlaceView = payload.Place[strings.Index(payload.Place, "/"): len(payload.Place)] + for i, payload := range result.Payload { + if strings.HasPrefix(result.Payload[i].Place, "192.168") { + result.Payload[i].PlaceView = payload.Place[strings.Index(payload.Place, "/"):len(payload.Place)] } else { result.Payload[i].PlaceView = payload.Place } @@ -205,29 +205,29 @@ func CloudBrainCommitImage(ctx *context.Context, form auth.CommitImageCloudBrain if err != nil { ctx.JSON(200, map[string]string{ "result_code": "-1", - "error_msg": "GetCloudbrainByJobID failed", + "error_msg": "GetCloudbrainByJobID failed", }) return } err = cloudbrain.CommitImage(jobID, models.CommitImageParams{ - Ip: task.ContainerIp, - TaskContainerId: task.ContainerID, - ImageDescription: form.Description, - ImageTag: form.Tag, + Ip: task.ContainerIp, + TaskContainerId: task.ContainerID, + ImageDescription: form.Description, + ImageTag: form.Tag, }) if err != nil { log.Error("CommitImage(%s) failed:", task.JobName, err.Error()) ctx.JSON(200, map[string]string{ "result_code": "-1", - "error_msg": "CommitImage failed", + "error_msg": "CommitImage failed", }) return } ctx.JSON(200, map[string]string{ "result_code": "0", - "error_msg": "", + "error_msg": "", }) } diff --git a/routers/repo/dir.go b/routers/repo/dir.go index a44227c66..388af34ec 100755 --- a/routers/repo/dir.go +++ b/routers/repo/dir.go @@ -21,15 +21,15 @@ const ( type FileInfo struct { FileName string `json:"FileName"` ModTime string `json:"ModTime"` - IsDir bool `json:"IsDir"` - Size int64 `json:"Size"` + IsDir bool `json:"IsDir"` + Size int64 `json:"Size"` ParenDir string `json:"ParenDir"` UUID string `json:"UUID"` } type RespGetDirs struct { ResultCode string `json:"resultCode"` - FileInfos string `json:"fileInfos"` + FileInfos string `json:"fileInfos"` } func DirIndex(ctx *context.Context) { @@ -80,7 +80,7 @@ func DirIndex(ctx *context.Context) { ctx.HTML(200, tplDirIndex) } -func getDirs(uuid string, parentDir string) (string,error) { +func getDirs(uuid string, parentDir string) (string, error) { var dirs string var req string if parentDir == "" { diff --git a/routers/routes/routes.go b/routers/routes/routes.go index 3d797a1e7..cfb730490 100755 --- a/routers/routes/routes.go +++ b/routers/routes/routes.go @@ -245,7 +245,7 @@ func RegisterRoutes(m *macaron.Macaron) { ignSignIn := context.Toggle(&context.ToggleOptions{SignInRequired: setting.Service.RequireSignInView}) ignSignInAndCsrf := context.Toggle(&context.ToggleOptions{DisableCSRF: true}) reqSignOut := context.Toggle(&context.ToggleOptions{SignOutRequired: true}) - reqBasicAuth := context.Toggle(&context.ToggleOptions{BasicAuthRequired:true}) + reqBasicAuth := context.Toggle(&context.ToggleOptions{BasicAuthRequired: true}) bindIgnErr := binding.BindIgnErr validation.AddBindingRules() From 23e05b4b056a60bcedaddeebd5d2c96776fc59c7 Mon Sep 17 00:00:00 2001 From: palytoxin Date: Tue, 26 Jan 2021 00:22:12 +0800 Subject: [PATCH 3/4] auto increase cnt via git-upload-pack hook --- models/repo.go | 16 +++++++++++++++- routers/private/serv.go | 6 ++++++ routers/repo/http.go | 4 ++++ 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/models/repo.go b/models/repo.go index 166097e44..9095bbda8 100755 --- a/models/repo.go +++ b/models/repo.go @@ -6,12 +6,14 @@ package models import ( - "code.gitea.io/gitea/modules/blockchain" "context" "crypto/md5" "errors" "fmt" "html/template" + "sync" + + "code.gitea.io/gitea/modules/blockchain" // Needed for jpeg support _ "image/jpeg" @@ -208,6 +210,9 @@ type Repository struct { Balance int64 `xorm:"NOT NULL DEFAULT 0"` BlockChainStatus RepoBlockChainStatus `xorm:"NOT NULL DEFAULT 0"` + // git clone total count + CloneCnt int64 `xorm:"NOT NULL DEFAULT 0"` + CreatedUnix timeutil.TimeStamp `xorm:"INDEX created"` UpdatedUnix timeutil.TimeStamp `xorm:"INDEX updated"` } @@ -2397,6 +2402,15 @@ func (repo *Repository) GetTreePathLock(treePath string) (*LFSLock, error) { return nil, nil } +var lck sync.Mutex + +func (repo *Repository) IncreaseCloneCnt() { + lck.Lock() + defer lck.Unlock() + repo.CloneCnt++ + _ = UpdateRepositoryCols(repo, "clone_cnt") +} + func updateRepositoryCols(e Engine, repo *Repository, cols ...string) error { _, err := e.ID(repo.ID).Cols(cols...).Update(repo) return err diff --git a/routers/private/serv.go b/routers/private/serv.go index d5b5fcc8f..f405d1d75 100644 --- a/routers/private/serv.go +++ b/routers/private/serv.go @@ -126,6 +126,12 @@ func ServCommand(ctx *macaron.Context) { } } + for _, verb := range ctx.QueryStrings("verb") { // clone_cnt + if verb == "git-upload-pack" { + go repo.IncreaseCloneCnt() + } + } + if repoExist { repo.OwnerName = ownerName results.RepoID = repo.ID diff --git a/routers/repo/http.go b/routers/repo/http.go index 650642a58..ed6276466 100644 --- a/routers/repo/http.go +++ b/routers/repo/http.go @@ -313,6 +313,10 @@ func HTTP(ctx *context.Context) { environ = append(environ, models.ProtectedBranchRepoID+fmt.Sprintf("=%d", repo.ID)) + if service == "git-upload-pack" { // clone_cnt + go repo.IncreaseCloneCnt() + } + w := ctx.Resp r := ctx.Req.Request cfg := &serviceConfig{ From 8588070e25c56921b4f01bf11948406b8646dd38 Mon Sep 17 00:00:00 2001 From: palytoxin Date: Tue, 26 Jan 2021 16:20:51 +0800 Subject: [PATCH 4/4] show download cnt in repo page (git-update-pack) --- options/locale/locale_en-US.ini | 1 + options/locale/locale_zh-CN.ini | 1 + templates/repo/sub_menu.tmpl | 3 +++ 3 files changed, 5 insertions(+) diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index edb3b2ce0..16a739406 100644 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -747,6 +747,7 @@ cloudbrain=cloudbrain cloudbrain.new=New cloudbrain cloudbrain.desc=cloudbrain cloudbrain.cancel=Cancel +clone_cnt=download template.items = Template Items template.git_content = Git Content (Default Branch) diff --git a/options/locale/locale_zh-CN.ini b/options/locale/locale_zh-CN.ini index 0398d5655..c2f37b976 100755 --- a/options/locale/locale_zh-CN.ini +++ b/options/locale/locale_zh-CN.ini @@ -753,6 +753,7 @@ cloudbrain.new=新建任务 cloudbrain.desc=云脑功能 cloudbrain.cancel=取消 cloudbrain.commit_image=提交 +clone_cnt=次下载 template.items=模板选项 template.git_content=Git数据(默认分支) diff --git a/templates/repo/sub_menu.tmpl b/templates/repo/sub_menu.tmpl index cd000d474..d1b73a9b0 100644 --- a/templates/repo/sub_menu.tmpl +++ b/templates/repo/sub_menu.tmpl @@ -13,6 +13,9 @@ + {{end}}