* add basic gitignore

* init go mod

* add semrel and badges

* add error pkg

* added config pkg

* added main cmd structure

* return error on file not found and added log ids and messages

* add todo for error_creator.go
This commit is contained in:
livio-a 2020-03-19 14:39:06 +01:00 committed by GitHub
parent 661bcfbdec
commit 87d5cd3f09
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
41 changed files with 1523 additions and 1 deletions

23
.gitignore vendored Normal file
View File

@ -0,0 +1,23 @@
# Binaries for programs and plugins
*.exe
*.exe~
*.dll
*.so
*.dylib
# Test binary, build with `go test -c`
*.test
# Coverage
coverage.txt
# Output of the go coverage tool, specifically when used with LiteIDE
*.out
#Debug
__debug_bin
debug
# IDE
.idea
.vscode

11
.releaserc.js Normal file
View File

@ -0,0 +1,11 @@
module.exports = {
branch: 'master',
plugins: [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
"@semantic-release/github",
["@semantic-release/exec", {
"prepareCmd": "echo '::set-env name=CAOS_NEXT_VERSION::v${nextRelease.version}'"
}],
]
};

View File

@ -1 +1,7 @@
# zitadel
# zitadel
![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)
![Release Badge](https://github.com/caos/zitadel/workflows/Test,%20Build,%20Release/badge.svg)
[![GitHub license](https://img.shields.io/github/license/caos/zitadel)](https://github.com/caos/zitadel/blob/master/LICENSE)
[![GitHub release](https://img.shields.io/github/release/caos/zitadel)](https://github.com/caos/zitadel/releases/)

55
cmd/zitadel/main.go Normal file
View File

@ -0,0 +1,55 @@
package main
import (
"context"
"flag"
"github.com/caos/logging"
"github.com/caos/zitadel/internal/config"
"github.com/caos/zitadel/pkg/admin"
"github.com/caos/zitadel/pkg/auth"
"github.com/caos/zitadel/pkg/eventstore"
"github.com/caos/zitadel/pkg/management"
)
type Config struct {
Eventstore eventstore.Config
Management management.Config
Auth auth.Config
Admin admin.Config
}
func main() {
configPath := flag.String("config-file", "/zitadel/config/startup.yaml", "path to the config file")
eventstoreEnabled := flag.Bool("eventstore", true, "enable eventstore")
managementEnabled := flag.Bool("management", true, "enable management api")
authEnabled := flag.Bool("auth", true, "enable auth api")
adminEnabled := flag.Bool("admin", true, "enable admin api")
flag.Parse()
conf := new(Config)
err := config.Read(conf, *configPath)
logging.Log("MAIN-FaF2r").OnError(err).Fatal("cannot read config")
ctx := context.Background()
if *eventstoreEnabled {
err = eventstore.Start(ctx, conf.Eventstore)
logging.Log("MAIN-sj2Sd").OnError(err).Fatal("error starting eventstore")
}
if *managementEnabled {
err = management.Start(ctx, conf.Management)
logging.Log("MAIN-39Nv5").OnError(err).Fatal("error starting management api")
}
if *authEnabled {
err = auth.Start(ctx, conf.Auth)
logging.Log("MAIN-x0nD2").OnError(err).Fatal("error starting auth api")
}
if *adminEnabled {
err = admin.Start(ctx, conf.Admin)
logging.Log("MAIN-0na71").OnError(err).Fatal("error starting admin api")
}
<-ctx.Done()
logging.Log("MAIN-s8d2h").Info("stopping zitadel")
}

12
go.mod Normal file
View File

@ -0,0 +1,12 @@
module github.com/caos/zitadel
go 1.14
require (
github.com/BurntSushi/toml v0.3.1
github.com/caos/logging v0.0.0-20191210002624-b3260f690a6a
github.com/caos/utils v0.0.0-20200305060859-ac2fa70f313e // indirect
github.com/ghodss/yaml v1.0.0
golang.org/x/sys v0.0.0-20200317113312-5766fd39f98d // indirect
gopkg.in/yaml.v2 v2.2.8 // indirect
)

289
go.sum Normal file
View File

@ -0,0 +1,289 @@
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSRU=
cloud.google.com/go v0.44.1/go.mod h1:iSa0KzasP4Uvy3f1mN/7PiObzGgflwredwwASm/v6AU=
cloud.google.com/go v0.44.2/go.mod h1:60680Gw3Yr4ikxnPRS/oxxkBccT6SA1yMk63TGekxKY=
cloud.google.com/go v0.45.1/go.mod h1:RpBamKRgapWJb87xiFSdk4g1CME7QZg3uwTez+TSTjc=
cloud.google.com/go v0.46.3/go.mod h1:a6bKKbmY7er1mI7TEI4lsAkts/mkhTSZK8w33B4RAg0=
cloud.google.com/go v0.50.0/go.mod h1:r9sluTvynVuxRIOHXQEHMFffphuXHOMZMycpNR5e6To=
cloud.google.com/go v0.53.0/go.mod h1:fp/UouUEsRkN6ryDKNW/Upv/JBKnv6WDthjR6+vze6M=
cloud.google.com/go/bigquery v1.0.1/go.mod h1:i/xbL2UlR5RvWAURpBYZTtm/cXjCha9lbfbpx4poX+o=
cloud.google.com/go/bigquery v1.3.0/go.mod h1:PjpwJnslEMmckchkHFfq+HTD2DmtT67aNFKH1/VBDHE=
cloud.google.com/go/datastore v1.0.0/go.mod h1:LXYbyblFSglQ5pkeyhO+Qmw7ukd3C+pD7TKLgZqpHYE=
cloud.google.com/go/pubsub v1.0.1/go.mod h1:R0Gpsv3s54REJCy4fxDixWD93lHJMoZTyQ2kNxGRt3I=
cloud.google.com/go/pubsub v1.1.0/go.mod h1:EwwdRX2sKPjnvnqCa270oGRyludottCI76h+R3AArQw=
cloud.google.com/go/storage v1.0.0/go.mod h1:IhtSnM/ZTZV8YYJWCY8RULGVqBDmpoyjwiyrjsg+URw=
cloud.google.com/go/storage v1.5.0/go.mod h1:tpKbwo567HUNpVclU5sGELwQWBDZ8gh0ZeosJ0Rtdos=
contrib.go.opencensus.io/exporter/stackdriver v0.13.0/go.mod h1:z2tyTZtPmQ2HvWH4cOmVDgtY+1lomfKdbLnkJvZdc8c=
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
github.com/VictoriaMetrics/fastcache v1.5.7/go.mod h1:ptDBkNMQI4RtmVo8VS/XwRY6RoTu1dAWCbrk+6WsEM8=
github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156/go.mod h1:Cb/ax3seSYIx7SuZdm2G2xzfwmv3TPSk2ucNfQESPXM=
github.com/allegro/bigcache v1.2.1/go.mod h1:Cb/ax3seSYIx7SuZdm2G2xzfwmv3TPSk2ucNfQESPXM=
github.com/antihax/optional v0.0.0-20180407024304-ca021399b1a6/go.mod h1:V8iCPQYkqmusNa815XgQio277wI47sdRh1dUOLdyC6Q=
github.com/aws/aws-sdk-go v1.23.20/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo=
github.com/aws/aws-sdk-go v1.29.16/go.mod h1:1KvfttTE3SPKMpo8g2c6jL3ZKfXtFvKscTgahTma5Xg=
github.com/caos/logging v0.0.0-20191210002624-b3260f690a6a h1:HOU/3xL/afsZ+2aCstfJlrzRkwYMTFR1TIEgps5ny8s=
github.com/caos/logging v0.0.0-20191210002624-b3260f690a6a/go.mod h1:9LKiDE2ChuGv6CHYif/kiugrfEXu9AwDiFWSreX7Wp0=
github.com/caos/utils v0.0.0-20200305060859-ac2fa70f313e h1:QSbTeoLPW7c1rWNJA2GOKunDJnRAfyg8+cb73qMYESM=
github.com/caos/utils v0.0.0-20200305060859-ac2fa70f313e/go.mod h1:CLEkNe7rs12GkdBWZxadA/mFiKeF6HzuA1BOKq+fX+Y=
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI=
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU=
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk=
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU=
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk=
github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg=
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4=
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y=
github.com/golang/mock v1.4.0/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw=
github.com/golang/mock v1.4.1/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw=
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw=
github.com/golang/protobuf v1.3.4/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw=
github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs=
github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc=
github.com/google/pprof v0.0.0-20190515194954-54271f7e092f/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc=
github.com/google/pprof v0.0.0-20200212024743-f11f1df84d12/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM=
github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg=
github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk=
github.com/grpc-ecosystem/go-grpc-middleware v1.2.0/go.mod h1:mJzapYve32yjrKlk9GbyCZHuPgZsrbyIbyKhSzOpg6s=
github.com/grpc-ecosystem/grpc-gateway v1.13.0/go.mod h1:8XEsbTttt/W+VvjtQhLACqCisSPWTxCZ7sBRjU6iH9c=
github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k=
github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU=
github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk=
github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q=
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
github.com/konsorten/go-windows-terminal-sequences v1.0.2 h1:DB17ag19krx9CFsz4o3enTrPXyIXCl+2iCXH/aMAp9s=
github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ=
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
github.com/rs/cors v1.7.0/go.mod h1:gFx+x8UowdsKA9AchylcLynDq+nNFfI8FkUZdN/jGCU=
github.com/sirupsen/logrus v1.4.2 h1:SPIRibHv4MatM3XXNO2BJeFLZwZ2LvZgfQ5+UNI2im4=
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/stretchr/testify v1.5.1 h1:nOGnQDM7FYENwehXlg/kFVnos3rEvtKTjRvOWSzb6H4=
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU=
go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8=
go.opencensus.io v0.22.1/go.mod h1:Ap50jQcDJrx6rB6VgeeFPtuPIf3wMRvRfrfYDO6+BmA=
go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0=
go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8=
golang.org/x/exp v0.0.0-20190829153037-c13cbed26979/go.mod h1:86+5VVa7VpoJ4kLfm080zCjGlMRFzhUhsZKEZO7MGek=
golang.org/x/exp v0.0.0-20191030013958-a1ab85dbe136/go.mod h1:JXzH8nQsPlswgeRAPE3MuO9GYsAcnJvJ4vnMwN/5qkY=
golang.org/x/exp v0.0.0-20191129062945-2f5052295587/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4=
golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4=
golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM=
golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js=
golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
golang.org/x/lint v0.0.0-20190409202823-959b441ac422/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
golang.org/x/lint v0.0.0-20190909230951-414d861bb4ac/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f/go.mod h1:5qLYkcX4OjUUV8bRuDixDT3tpyyb+LUpUlRWLxfhWrs=
golang.org/x/lint v0.0.0-20200130185559-910be7a94367/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY=
golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE=
golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o=
golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc=
golang.org/x/mod v0.1.0/go.mod h1:0QHyrYULN0/3qlju5TqG8bIK38QM8yzMo5ekMj3DlcY=
golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg=
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190501004415-9ce7a6920f09/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20190724013045-ca1201d0de80/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20190923162816-aa69164e4478/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20191002035440-2ec189313ef0/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20200301022130-244492dfa37a/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
golang.org/x/oauth2 v0.0.0-20191202225959-858c2ad4c8b6/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191206220618-eeba5f6aabab h1:FvshnhkKW+LO3HWHodML8kuVX8rnJTxKm9dFPuI68UM=
golang.org/x/sys v0.0.0-20191206220618-eeba5f6aabab/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191228213918-04cbcbbfeed8/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200212091648-12a6c2dcc1e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200317113312-5766fd39f98d h1:62ap6LNOjDU6uGmKXHJbSfciMoV+FeI1sRXx/pLDL44=
golang.org/x/sys v0.0.0-20200317113312-5766fd39f98d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY=
golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
golang.org/x/tools v0.0.0-20190312151545-0bb0c0a6e846/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
golang.org/x/tools v0.0.0-20190506145303-2d16b83fe98c/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
golang.org/x/tools v0.0.0-20190628153133-6cdbf07be9d0/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
golang.org/x/tools v0.0.0-20190816200558-6889da9d5479/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20190911174233-4f2ddba30aff/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20191010075000-0337d82405ff/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20191012152004-8de300cfc20a/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20191113191852-77e3bb0ad9e7/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20191115202509-3a792d9c32b2/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20191125144606-a911d9008d1f/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20191216173652-a0e659d51361/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
golang.org/x/tools v0.0.0-20191227053925-7b8e75db28f4/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
golang.org/x/tools v0.0.0-20200207183749-b753a1ba74fa/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
golang.org/x/tools v0.0.0-20200212150539-ea181f53ac56/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE=
google.golang.org/api v0.7.0/go.mod h1:WtwebWUNSVBH/HAw79HIFXZNqEvBhG+Ra+ax0hx3E3M=
google.golang.org/api v0.8.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg=
google.golang.org/api v0.9.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg=
google.golang.org/api v0.10.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg=
google.golang.org/api v0.13.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI=
google.golang.org/api v0.14.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI=
google.golang.org/api v0.15.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI=
google.golang.org/api v0.17.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE=
google.golang.org/api v0.20.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE=
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0=
google.golang.org/appengine v1.6.2/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0=
google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
google.golang.org/genproto v0.0.0-20190418145605-e7d98fc518a7/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
google.golang.org/genproto v0.0.0-20190425155659-357c62f0e4bb/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
google.golang.org/genproto v0.0.0-20190502173448-54afdca5d873/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
google.golang.org/genproto v0.0.0-20190801165951-fa694d86fc64/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc=
google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc=
google.golang.org/genproto v0.0.0-20190911173649-1774047e7e51/go.mod h1:IbNlFCBrqXvoKpeg0TB2l7cyZUmoaFKYIwrEpbDKLA8=
google.golang.org/genproto v0.0.0-20190927181202-20e1ac93f88c/go.mod h1:IbNlFCBrqXvoKpeg0TB2l7cyZUmoaFKYIwrEpbDKLA8=
google.golang.org/genproto v0.0.0-20191108220845-16a3f7862a1a/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc=
google.golang.org/genproto v0.0.0-20191115194625-c23dd37a84c9/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc=
google.golang.org/genproto v0.0.0-20191216164720-4f79533eabd1/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc=
google.golang.org/genproto v0.0.0-20191230161307-f3c370f40bfb/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc=
google.golang.org/genproto v0.0.0-20200212174721-66ed5ce911ce/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
google.golang.org/genproto v0.0.0-20200303153909-beee998c1893/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38=
google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM=
google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg=
google.golang.org/grpc v1.23.1/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg=
google.golang.org/grpc v1.24.0/go.mod h1:XDChyiUovWa60DnaeDeZmSW86xtLtjtZbwvSiRnRtcA=
google.golang.org/grpc v1.26.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
google.golang.org/grpc v1.27.1/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.7 h1:VUgggvou5XRW9mHwD/yXxIYSMtY0zoKQf/v226p2nyo=
gopkg.in/yaml.v2 v2.2.7/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10=
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=
rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8=
rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0=
rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA=

92
internal/config/config.go Normal file
View File

@ -0,0 +1,92 @@
package config
import (
"encoding/json"
"io/ioutil"
"os"
"path/filepath"
"github.com/BurntSushi/toml"
"github.com/ghodss/yaml"
"github.com/caos/zitadel/internal/errors"
)
type Reader interface {
Unmarshal(data []byte, o interface{}) error
}
type ValidatableConfiguration interface {
Validate() error
}
type ReaderFunc func(data []byte, o interface{}) error
func (c ReaderFunc) Unmarshal(data []byte, o interface{}) error {
return c(data, o)
}
var (
JSONReader = ReaderFunc(json.Unmarshal)
TOMLReader = ReaderFunc(toml.Unmarshal)
YAMLReader = ReaderFunc(func(y []byte, o interface{}) error {
return yaml.Unmarshal(y, o)
})
)
// Read deserializes each config file to the target obj
// using a Reader (depending on file extension)
// env vars are replaced in the config file as well as the file path
func Read(obj interface{}, configFiles ...string) error {
for _, cf := range configFiles {
configReader, err := configReaderForFile(cf)
if err != nil {
return err
}
if err := readConfigFile(configReader, cf, obj); err != nil {
return err
}
}
if validatable, ok := obj.(ValidatableConfiguration); ok {
if err := validatable.Validate(); err != nil {
return err
}
}
return nil
}
func readConfigFile(configReader Reader, configFile string, obj interface{}) error {
configFile = os.ExpandEnv(configFile)
if _, err := os.Stat(configFile); err != nil {
return errors.ThrowNotFoundf(err, "CONFI-Hs93M", "config file %s does not exist", configFile)
}
configStr, err := ioutil.ReadFile(configFile)
if err != nil {
return errors.ThrowInternalf(err, "CONFI-nJk2a", "failed to read config file %s", configFile)
}
configStr = []byte(os.ExpandEnv(string(configStr)))
if err := configReader.Unmarshal(configStr, obj); err != nil {
return errors.ThrowInternalf(err, "CONFI-2Mc3c", "error parse config file %s", configFile)
}
return nil
}
func configReaderForFile(configFile string) (Reader, error) {
ext := filepath.Ext(configFile)
switch ext {
case ".yaml", ".yml":
return YAMLReader, nil
case ".json":
return JSONReader, nil
case ".toml":
return TOMLReader, nil
}
return nil, errors.ThrowUnimplementedf(nil, "file extension (%s) not supported", ext)
}

View File

@ -0,0 +1,32 @@
package errors
import "fmt"
var (
_ AlreadyExists = (*AlreadyExistsError)(nil)
_ Error = (*AlreadyExistsError)(nil)
)
type AlreadyExists interface {
error
IsAlreadyExists()
}
type AlreadyExistsError struct {
*CaosError
}
func ThrowAlreadyExists(parent error, id, message string) error {
return &AlreadyExistsError{createCaosError(parent, id, message)}
}
func ThrowAlreadyExistsf(parent error, id, format string, a ...interface{}) error {
return &AlreadyExistsError{createCaosError(parent, id, fmt.Sprintf(format, a...))}
}
func (err *AlreadyExistsError) IsAlreadyExists() {}
func IsErrorAlreadyExists(err error) bool {
_, ok := err.(AlreadyExists)
return ok
}

View File

@ -0,0 +1,34 @@
package errors_test
import (
"errors"
"testing"
"github.com/stretchr/testify/assert"
caos_errs "github.com/caos/utils/errors"
)
func TestAlreadyExistsError(t *testing.T) {
var alreadyExistsError interface{}
alreadyExistsError = new(caos_errs.AlreadyExistsError)
_, ok := alreadyExistsError.(caos_errs.AlreadyExists)
assert.True(t, ok)
}
func TestThrowAlreadyExistsf(t *testing.T) {
err := caos_errs.ThrowAlreadyExistsf(nil, "id", "msg")
_, ok := err.(*caos_errs.AlreadyExistsError)
assert.True(t, ok)
}
func TestIsErrorAlreadyExists(t *testing.T) {
err := caos_errs.ThrowAlreadyExists(nil, "id", "msg")
ok := caos_errs.IsErrorAlreadyExists(err)
assert.True(t, ok)
err = errors.New("Already Exists!")
ok = caos_errs.IsErrorAlreadyExists(err)
assert.False(t, ok)
}

View File

@ -0,0 +1,48 @@
package errors
import (
"fmt"
)
var _ Error = (*CaosError)(nil)
type CaosError struct {
Parent error
Message string
ID string
}
func ThrowError(parent error, id, message string) error {
return createCaosError(parent, id, message)
}
func createCaosError(parent error, id, message string) *CaosError {
return &CaosError{
Parent: parent,
ID: id,
Message: message,
}
}
func (err *CaosError) Error() string {
if err.Parent != nil {
return fmt.Sprintf("ID=%s Message=%s Parent=(%v)", err.ID, err.Message, err.Parent)
}
return fmt.Sprintf("ID=%s Message=%s", err.ID, err.Message)
}
func (err *CaosError) Unwrap() error {
return err.GetParent()
}
func (err *CaosError) GetParent() error {
return err.Parent
}
func (err *CaosError) GetMessage() string {
return err.Message
}
func (err *CaosError) GetID() string {
return err.ID
}

View File

@ -0,0 +1,19 @@
package errors_test
import (
"testing"
"github.com/stretchr/testify/assert"
caos_errs "github.com/caos/utils/errors"
)
func TestErrorMethod(t *testing.T) {
err := caos_errs.ThrowError(nil, "id", "msg")
expected := "ID=id Message=msg"
assert.Equal(t, expected, err.Error())
err = caos_errs.ThrowError(err, "subID", "subMsg")
subExptected := "ID=subID Message=subMsg Parent=(ID=id Message=msg)"
assert.Equal(t, subExptected, err.Error())
}

View File

@ -0,0 +1,34 @@
package errors
import (
"fmt"
)
var (
_ DeadlineExceeded = (*DeadlineExceededError)(nil)
_ Error = (*DeadlineExceededError)(nil)
)
type DeadlineExceeded interface {
error
IsDeadlineExceeded()
}
type DeadlineExceededError struct {
*CaosError
}
func ThrowDeadlineExceeded(parent error, id, message string) error {
return &DeadlineExceededError{createCaosError(parent, id, message)}
}
func ThrowDeadlineExceededf(parent error, id, format string, a ...interface{}) error {
return ThrowDeadlineExceeded(parent, id, fmt.Sprintf(format, a...))
}
func (err *DeadlineExceededError) IsDeadlineExceeded() {}
func IsDeadlineExceeded(err error) bool {
_, ok := err.(DeadlineExceeded)
return ok
}

View File

@ -0,0 +1,33 @@
package errors_test
import (
"errors"
"testing"
"github.com/stretchr/testify/assert"
caos_errs "github.com/caos/utils/errors"
)
func TestDeadlineExceededError(t *testing.T) {
var err interface{}
err = new(caos_errs.DeadlineExceededError)
_, ok := err.(caos_errs.DeadlineExceeded)
assert.True(t, ok)
}
func TestThrowDeadlineExceededf(t *testing.T) {
err := caos_errs.ThrowDeadlineExceededf(nil, "id", "msg")
_, ok := err.(*caos_errs.DeadlineExceededError)
assert.True(t, ok)
}
func TestIsDeadlineExceeded(t *testing.T) {
err := caos_errs.ThrowDeadlineExceeded(nil, "id", "msg")
ok := caos_errs.IsDeadlineExceeded(err)
assert.True(t, ok)
err = errors.New("I am found!")
ok = caos_errs.IsDeadlineExceeded(err)
assert.False(t, ok)
}

18
internal/errors/error.go Normal file
View File

@ -0,0 +1,18 @@
package errors
import (
"strings"
)
// Error is a stdlib error extension.
// It contains parameters to identify errors through all application layers
type Error interface {
GetParent() error
GetMessage() string
GetID() string
}
// Contains compares the error message with needle
func Contains(err error, needle string) bool {
return err != nil && strings.Contains(err.Error(), needle)
}

View File

@ -0,0 +1,19 @@
package errors_test
import (
"errors"
"testing"
"github.com/stretchr/testify/assert"
caos_errors "github.com/caos/utils/errors"
)
func TestContains(t *testing.T) {
err := errors.New("hello world")
world := caos_errors.Contains(err, "hello")
assert.True(t, world)
mars := caos_errors.Contains(err, "mars")
assert.False(t, mars)
}

View File

@ -0,0 +1,34 @@
package errors
import (
"fmt"
)
var (
_ {{.ErrorName}} = (*{{.ErrorName}}Error)(nil)
_ Error = (*{{.ErrorName}}Error)(nil)
)
type {{.ErrorName}} interface {
error
Is{{.ErrorName}}()
}
type {{.ErrorName}}Error struct {
*CaosError
}
func Throw{{.ErrorName}}(parent error, id, message string) error {
return &{{.ErrorName}}Error{createCaosError(parent, id, message)}
}
func Throw{{.ErrorName}}f(parent error, id, format string, a ...interface{}) error {
return Throw{{.ErrorName}}(parent, id, fmt.Sprintf(format, a...))
}
func (err *{{.ErrorName}}Error) Is{{.ErrorName}}() {}
func Is{{.ErrorName}}(err error) bool {
_, ok := err.({{.ErrorName}})
return ok
}

View File

@ -0,0 +1,75 @@
//go generate
package main
import (
"flag"
"fmt"
"html/template"
"log"
"os"
"strings"
)
func main() {
errorName := readErrorName()
errorName = validateErrorName(errorName)
data := &Data{
ErrorName: errorName,
}
errorFile := data.createFile("error.go.tmpl")
data.createTemplate("error.go.tmpl", errorFile)
if err := errorFile.Close(); err != nil {
log.Fatal(err)
}
testFile := data.createFile("error_test.go.tmpl")
data.createTemplate("error_test.go.tmpl", testFile)
if err := testFile.Close(); err != nil {
log.Fatal(err)
}
fmt.Print(`
!!!!!
Add status mapping in grpc/errors/caos_errors.go //TODO: fix path when pkg exists
!!!!!`)
}
type Data struct {
ErrorName string
}
func (data *Data) createFile(tmplName string) *os.File {
filename := strings.Replace(tmplName, "error", strings.ToLower(data.ErrorName), 1)
filename = filename[:len(filename)-5]
filePath := fmt.Sprintf("../%s", filename)
file, err := os.Create(filePath)
if err != nil {
log.Fatalf("unable to create file (%s): %v", filePath, err)
}
return file
}
func (data *Data) createTemplate(templateName string, file *os.File) {
tmpl := template.Must(template.New(templateName).ParseFiles(templateName))
if err := tmpl.Execute(file, data); err != nil {
log.Fatal("unable to execute tmpl: ", err)
}
}
func readErrorName() (errorName string) {
flag.StringVar(&errorName, "Name", "", "Type of the error (e.g. Internal)")
flag.Parse()
return errorName
}
func validateErrorName(errorName string) string {
if errorName == "" {
log.Fatal("pass argument name")
}
if strings.Contains(errorName, " ") || strings.Contains(errorName, ".") {
log.Fatal("name cannot contain spaces or points")
}
return strings.Title(errorName)
}

View File

@ -0,0 +1,5 @@
type {{.ErrorName}} interface {
error
Is{{.ErrorName}}()
}

View File

@ -0,0 +1,33 @@
package errors_test
import (
"errors"
"testing"
"github.com/stretchr/testify/assert"
caos_errs "github.com/caos/utils/errors"
)
func Test{{.ErrorName}}Error(t *testing.T) {
var err interface{}
err = new(caos_errs.{{.ErrorName}}Error)
_, ok := err.(caos_errs.{{.ErrorName}})
assert.True(t, ok)
}
func TestThrow{{.ErrorName}}f(t *testing.T) {
err := caos_errs.Throw{{.ErrorName}}f(nil, "id", "msg")
_, ok := err.(*caos_errs.{{.ErrorName}}Error)
assert.True(t, ok)
}
func TestIs{{.ErrorName}}(t *testing.T) {
err := caos_errs.Throw{{.ErrorName}}(nil, "id", "msg")
ok := caos_errs.Is{{.ErrorName}}(err)
assert.True(t, ok)
err = errors.New("I am found!")
ok = caos_errs.Is{{.ErrorName}}(err)
assert.False(t, ok)
}

View File

@ -0,0 +1,34 @@
package errors
import (
"fmt"
)
var (
_ Internal = (*InternalError)(nil)
_ Error = (*InternalError)(nil)
)
type Internal interface {
error
IsInternal()
}
type InternalError struct {
*CaosError
}
func ThrowInternal(parent error, id, message string) error {
return &InternalError{createCaosError(parent, id, message)}
}
func ThrowInternalf(parent error, id, format string, a ...interface{}) error {
return ThrowInternal(parent, id, fmt.Sprintf(format, a...))
}
func (err *InternalError) IsInternal() {}
func IsInternal(err error) bool {
_, ok := err.(Internal)
return ok
}

View File

@ -0,0 +1,33 @@
package errors_test
import (
"errors"
"testing"
"github.com/stretchr/testify/assert"
caos_errs "github.com/caos/utils/errors"
)
func TestInternalError(t *testing.T) {
var err interface{}
err = new(caos_errs.InternalError)
_, ok := err.(caos_errs.Internal)
assert.True(t, ok)
}
func TestThrowInternalf(t *testing.T) {
err := caos_errs.ThrowInternalf(nil, "id", "msg")
_, ok := err.(*caos_errs.InternalError)
assert.True(t, ok)
}
func TestIsInternal(t *testing.T) {
err := caos_errs.ThrowInternal(nil, "id", "msg")
ok := caos_errs.IsInternal(err)
assert.True(t, ok)
err = errors.New("I am found!")
ok = caos_errs.IsInternal(err)
assert.False(t, ok)
}

View File

@ -0,0 +1,32 @@
package errors
import "fmt"
var (
_ InvalidArgument = (*InvalidArgumentError)(nil)
_ Error = (*InvalidArgumentError)(nil)
)
type InvalidArgument interface {
error
IsInvalidArgument()
}
type InvalidArgumentError struct {
*CaosError
}
func ThrowInvalidArgument(parent error, id, message string) error {
return &InvalidArgumentError{createCaosError(parent, id, message)}
}
func ThrowInvalidArgumentf(parent error, id, format string, a ...interface{}) error {
return ThrowInvalidArgument(parent, id, fmt.Sprintf(format, a...))
}
func (err *InvalidArgumentError) IsInvalidArgument() {}
func IsErrorInvalidArgument(err error) bool {
_, ok := err.(InvalidArgument)
return ok
}

View File

@ -0,0 +1,33 @@
package errors_test
import (
"errors"
"testing"
"github.com/stretchr/testify/assert"
caos_errs "github.com/caos/utils/errors"
)
func TestInvalidArgumentError(t *testing.T) {
var invalidArgumentError interface{}
invalidArgumentError = new(caos_errs.InvalidArgumentError)
_, ok := invalidArgumentError.(caos_errs.InvalidArgument)
assert.True(t, ok)
}
func TestThrowInvalidArgumentf(t *testing.T) {
err := caos_errs.ThrowInvalidArgumentf(nil, "id", "msg")
_, ok := err.(*caos_errs.InvalidArgumentError)
assert.True(t, ok)
}
func TestIsErrorInvalidArgument(t *testing.T) {
err := caos_errs.ThrowInvalidArgument(nil, "id", "msg")
ok := caos_errs.IsErrorInvalidArgument(err)
assert.True(t, ok)
err = errors.New("I am invalid!")
ok = caos_errs.IsErrorInvalidArgument(err)
assert.False(t, ok)
}

View File

@ -0,0 +1,27 @@
package errors
import "fmt"
type NotFound interface {
error
IsNotFound()
}
type NotFoundError struct {
*CaosError
}
func ThrowNotFound(parent error, id, message string) error {
return &NotFoundError{createCaosError(parent, id, message)}
}
func ThrowNotFoundf(parent error, id, format string, a ...interface{}) error {
return ThrowNotFound(parent, id, fmt.Sprintf(format, a...))
}
func (err *NotFoundError) IsNotFound() {}
func IsNotFound(err error) bool {
_, ok := err.(NotFound)
return ok
}

View File

@ -0,0 +1,33 @@
package errors_test
import (
"errors"
"testing"
"github.com/stretchr/testify/assert"
caos_errs "github.com/caos/utils/errors"
)
func TestNotFoundError(t *testing.T) {
var notFoundError interface{}
notFoundError = new(caos_errs.NotFoundError)
_, ok := notFoundError.(caos_errs.NotFound)
assert.True(t, ok)
}
func TestThrowNotFoundf(t *testing.T) {
err := caos_errs.ThrowNotFoundf(nil, "id", "msg")
_, ok := err.(*caos_errs.NotFoundError)
assert.True(t, ok)
}
func TestIsNotFound(t *testing.T) {
err := caos_errs.ThrowNotFound(nil, "id", "msg")
ok := caos_errs.IsNotFound(err)
assert.True(t, ok)
err = errors.New("I am found!")
ok = caos_errs.IsNotFound(err)
assert.False(t, ok)
}

View File

@ -0,0 +1,34 @@
package errors
import (
"fmt"
)
var (
_ PermissionDenied = (*PermissionDeniedError)(nil)
_ Error = (*PermissionDeniedError)(nil)
)
type PermissionDenied interface {
error
IsPermissionDenied()
}
type PermissionDeniedError struct {
*CaosError
}
func ThrowPermissionDenied(parent error, id, message string) error {
return &PermissionDeniedError{createCaosError(parent, id, message)}
}
func ThrowPermissionDeniedf(parent error, id, format string, a ...interface{}) error {
return ThrowPermissionDenied(parent, id, fmt.Sprintf(format, a...))
}
func (err *PermissionDeniedError) IsPermissionDenied() {}
func IsPermissionDenied(err error) bool {
_, ok := err.(PermissionDenied)
return ok
}

View File

@ -0,0 +1,33 @@
package errors_test
import (
"errors"
"testing"
"github.com/stretchr/testify/assert"
caos_errs "github.com/caos/utils/errors"
)
func TestPermissionDeniedError(t *testing.T) {
var err interface{}
err = new(caos_errs.PermissionDeniedError)
_, ok := err.(caos_errs.PermissionDenied)
assert.True(t, ok)
}
func TestThrowPermissionDeniedf(t *testing.T) {
err := caos_errs.ThrowPermissionDeniedf(nil, "id", "msg")
_, ok := err.(*caos_errs.PermissionDeniedError)
assert.True(t, ok)
}
func TestIsPermissionDenied(t *testing.T) {
err := caos_errs.ThrowPermissionDenied(nil, "id", "msg")
ok := caos_errs.IsPermissionDenied(err)
assert.True(t, ok)
err = errors.New("I am found!")
ok = caos_errs.IsPermissionDenied(err)
assert.False(t, ok)
}

View File

@ -0,0 +1,34 @@
package errors
import (
"fmt"
)
var (
_ PreconditionFailed = (*PreconditionFailedError)(nil)
_ Error = (*PreconditionFailedError)(nil)
)
type PreconditionFailed interface {
error
IsPreconditionFailed()
}
type PreconditionFailedError struct {
*CaosError
}
func ThrowPreconditionFailed(parent error, id, message string) error {
return &PreconditionFailedError{createCaosError(parent, id, message)}
}
func ThrowPreconditionFailedf(parent error, id, format string, a ...interface{}) error {
return ThrowPreconditionFailed(parent, id, fmt.Sprintf(format, a...))
}
func (err *PreconditionFailedError) IsPreconditionFailed() {}
func IsPreconditionFailed(err error) bool {
_, ok := err.(PreconditionFailed)
return ok
}

View File

@ -0,0 +1,33 @@
package errors_test
import (
"errors"
"testing"
"github.com/stretchr/testify/assert"
caos_errs "github.com/caos/utils/errors"
)
func TestPreconditionFailedError(t *testing.T) {
var err interface{}
err = new(caos_errs.PreconditionFailedError)
_, ok := err.(caos_errs.PreconditionFailed)
assert.True(t, ok)
}
func TestThrowPreconditionFailedf(t *testing.T) {
err := caos_errs.ThrowPreconditionFailedf(nil, "id", "msg")
_, ok := err.(*caos_errs.PreconditionFailedError)
assert.True(t, ok)
}
func TestIsPreconditionFailed(t *testing.T) {
err := caos_errs.ThrowPreconditionFailed(nil, "id", "msg")
ok := caos_errs.IsPreconditionFailed(err)
assert.True(t, ok)
err = errors.New("Precondition failed!")
ok = caos_errs.IsPreconditionFailed(err)
assert.False(t, ok)
}

View File

@ -0,0 +1,34 @@
package errors
import (
"fmt"
)
var (
_ Unauthenticated = (*UnauthenticatedError)(nil)
_ Error = (*UnauthenticatedError)(nil)
)
type Unauthenticated interface {
error
IsUnauthenticated()
}
type UnauthenticatedError struct {
*CaosError
}
func ThrowUnauthenticated(parent error, id, message string) error {
return &UnauthenticatedError{createCaosError(parent, id, message)}
}
func ThrowUnauthenticatedf(parent error, id, format string, a ...interface{}) error {
return ThrowUnauthenticated(parent, id, fmt.Sprintf(format, a...))
}
func (err *UnauthenticatedError) IsUnauthenticated() {}
func IsUnauthenticated(err error) bool {
_, ok := err.(Unauthenticated)
return ok
}

View File

@ -0,0 +1,33 @@
package errors_test
import (
"errors"
"testing"
"github.com/stretchr/testify/assert"
caos_errs "github.com/caos/utils/errors"
)
func TestUnauthenticatedError(t *testing.T) {
var err interface{}
err = new(caos_errs.UnauthenticatedError)
_, ok := err.(caos_errs.Unauthenticated)
assert.True(t, ok)
}
func TestThrowUnauthenticatedf(t *testing.T) {
err := caos_errs.ThrowUnauthenticatedf(nil, "id", "msg")
_, ok := err.(*caos_errs.UnauthenticatedError)
assert.True(t, ok)
}
func TestIsUnauthenticated(t *testing.T) {
err := caos_errs.ThrowUnauthenticated(nil, "id", "msg")
ok := caos_errs.IsUnauthenticated(err)
assert.True(t, ok)
err = errors.New("I am found!")
ok = caos_errs.IsUnauthenticated(err)
assert.False(t, ok)
}

View File

@ -0,0 +1,34 @@
package errors
import (
"fmt"
)
var (
_ Unavailable = (*UnavailableError)(nil)
_ Error = (*UnavailableError)(nil)
)
type Unavailable interface {
error
IsUnavailable()
}
type UnavailableError struct {
*CaosError
}
func ThrowUnavailable(parent error, id, message string) error {
return &UnavailableError{createCaosError(parent, id, message)}
}
func ThrowUnavailablef(parent error, id, format string, a ...interface{}) error {
return ThrowUnavailable(parent, id, fmt.Sprintf(format, a...))
}
func (err *UnavailableError) IsUnavailable() {}
func IsUnavailable(err error) bool {
_, ok := err.(Unavailable)
return ok
}

View File

@ -0,0 +1,33 @@
package errors_test
import (
"errors"
"testing"
"github.com/stretchr/testify/assert"
caos_errs "github.com/caos/utils/errors"
)
func TestUnavailableError(t *testing.T) {
var err interface{}
err = new(caos_errs.UnavailableError)
_, ok := err.(caos_errs.Unavailable)
assert.True(t, ok)
}
func TestThrowUnavailablef(t *testing.T) {
err := caos_errs.ThrowUnavailablef(nil, "id", "msg")
_, ok := err.(*caos_errs.UnavailableError)
assert.True(t, ok)
}
func TestIsUnavailable(t *testing.T) {
err := caos_errs.ThrowUnavailable(nil, "id", "msg")
ok := caos_errs.IsUnavailable(err)
assert.True(t, ok)
err = errors.New("I am found!")
ok = caos_errs.IsUnavailable(err)
assert.False(t, ok)
}

View File

@ -0,0 +1,34 @@
package errors
import (
"fmt"
)
var (
_ Unimplemented = (*UnimplementedError)(nil)
_ Error = (*UnimplementedError)(nil)
)
type Unimplemented interface {
error
IsUnimplemented()
}
type UnimplementedError struct {
*CaosError
}
func ThrowUnimplemented(parent error, id, message string) error {
return &UnimplementedError{createCaosError(parent, id, message)}
}
func ThrowUnimplementedf(parent error, id, format string, a ...interface{}) error {
return ThrowUnimplemented(parent, id, fmt.Sprintf(format, a...))
}
func (err *UnimplementedError) IsUnimplemented() {}
func IsUnimplemented(err error) bool {
_, ok := err.(Unimplemented)
return ok
}

View File

@ -0,0 +1,33 @@
package errors_test
import (
"errors"
"testing"
"github.com/stretchr/testify/assert"
caos_errs "github.com/caos/utils/errors"
)
func TestUnimplementedError(t *testing.T) {
var unimplementedError interface{}
unimplementedError = new(caos_errs.UnimplementedError)
_, ok := unimplementedError.(caos_errs.Unimplemented)
assert.True(t, ok)
}
func TestThrowUnimplementedf(t *testing.T) {
err := caos_errs.ThrowUnimplementedf(nil, "id", "msg")
_, ok := err.(*caos_errs.UnimplementedError)
assert.True(t, ok)
}
func TestIsUnimplemented(t *testing.T) {
err := caos_errs.ThrowUnimplemented(nil, "id", "msg")
ok := caos_errs.IsUnimplemented(err)
assert.True(t, ok)
err = errors.New("I am found!")
ok = caos_errs.IsUnimplemented(err)
assert.False(t, ok)
}

View File

@ -0,0 +1,34 @@
package errors
import (
"fmt"
)
var (
_ Unknown = (*UnknownError)(nil)
_ Error = (*UnknownError)(nil)
)
type Unknown interface {
error
IsUnknown()
}
type UnknownError struct {
*CaosError
}
func ThrowUnknown(parent error, id, message string) error {
return &UnknownError{createCaosError(parent, id, message)}
}
func ThrowUnknownf(parent error, id, format string, a ...interface{}) error {
return ThrowUnknown(parent, id, fmt.Sprintf(format, a...))
}
func (err *UnknownError) IsUnknown() {}
func IsUnknown(err error) bool {
_, ok := err.(Unknown)
return ok
}

View File

@ -0,0 +1,33 @@
package errors_test
import (
"errors"
"testing"
"github.com/stretchr/testify/assert"
caos_errs "github.com/caos/utils/errors"
)
func TestUnknownError(t *testing.T) {
var err interface{}
err = new(caos_errs.UnknownError)
_, ok := err.(caos_errs.Unknown)
assert.True(t, ok)
}
func TestThrowUnknownf(t *testing.T) {
err := caos_errs.ThrowUnknownf(nil, "id", "msg")
_, ok := err.(*caos_errs.UnknownError)
assert.True(t, ok)
}
func TestIsUnknown(t *testing.T) {
err := caos_errs.ThrowUnknown(nil, "id", "msg")
ok := caos_errs.IsUnknown(err)
assert.True(t, ok)
err = errors.New("I am found!")
ok = caos_errs.IsUnknown(err)
assert.False(t, ok)
}

14
pkg/admin/admin.go Normal file
View File

@ -0,0 +1,14 @@
package admin
import (
"context"
"github.com/caos/zitadel/internal/errors"
)
type Config struct {
}
func Start(ctx context.Context, config Config) error {
return errors.ThrowUnimplemented(nil, "ADMIN-n8vw5", "not implemented yet") //TODO: implement
}

14
pkg/auth/auth.go Normal file
View File

@ -0,0 +1,14 @@
package auth
import (
"context"
"github.com/caos/zitadel/internal/errors"
)
type Config struct {
}
func Start(ctx context.Context, config Config) error {
return errors.ThrowUnimplemented(nil, "AUTH-l7Hdx", "not implemented yet") //TODO: implement
}

View File

@ -0,0 +1,14 @@
package eventstore
import (
"context"
"github.com/caos/zitadel/internal/errors"
)
type Config struct {
}
func Start(ctx context.Context, config Config) error {
return errors.ThrowUnimplemented(nil, "EVENT-1hfiu", "not implemented yet") //TODO: implement
}

View File

@ -0,0 +1,14 @@
package management
import (
"context"
"github.com/caos/zitadel/internal/errors"
)
type Config struct {
}
func Start(ctx context.Context, config Config) error {
return errors.ThrowUnimplemented(nil, "MANAG-h3k3x", "not implemented yet") //TODO: implement
}