diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index ed6abd47e47be7936fc1466635f47b83ec2371bd..25823df699d0519220e5109e1034a4a3f147bc98 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -6,7 +6,7 @@ name: CI # events but only for the main branch on: push: - branches: [ main, openapi] + branches: [ main, openapi ] pull_request: branches: [ main, openapi ] @@ -21,6 +21,16 @@ jobs: steps: # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - uses: actions/checkout@v2 + # Download go-swagger + - name: download go-swagger + run: | + curl -Lsq https://github.com/go-swagger/go-swagger/releases/download/v0.25.0/swagger_linux_amd64 -o $GITHUB_WORKSPACE/swagger + chmod +x $GITHUB_WORKSPACE/swagger + - name: Validate OpenAPI with Swagger + run: $GITHUB_WORKSPACE/swagger validate openapi.yaml + # Make it + - name: Build + run: make -C $GITHUB_WORKSPACE all # Lint it - name: golangci-lint uses: golangci/golangci-lint-action@v2 @@ -36,6 +46,5 @@ jobs: GOROOT: "" with: args: ./... - - name: Swagger - uses: docker://quay.io/goswagger/swagger - run: swagger validate openapi.yaml + - name: Ensure no files were modified as a result of the build + run: git update-index --refresh && git diff-index --quiet HEAD -- diff --git a/.gitignore b/.gitignore index aa8f8907975e3523319e434ccc399e7236a222e8..dfc24c29570fb3446b4c6025635bb3a529aa7663 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,8 @@ .idea/* .vscode/* -cli +/cli logid rekor-cli rekor-server -server +/server +swagger \ No newline at end of file diff --git a/Makefile b/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..ad3317a727b2c0999454158f26de56c1f29ab83b --- /dev/null +++ b/Makefile @@ -0,0 +1,28 @@ +.PHONY: all test clean lint gosec + +GENSRCS := $(shell find pkg/generated -name "*.go"|grep -v "configure_rekor_server.go") +SRCS := $(wildcard cmd/**/**.go) ${GENSRCS} $(shell find pkg -name "*.go"|grep -v "pkg/generated") pkg/generated/restapi/configure_rekor_server.go + +all: cli server + +$(GENSRCS): openapi.yaml + swagger generate client -f openapi.yaml -q -t pkg/generated --additional-initialism=PKI + swagger generate server -f openapi.yaml -q -t pkg/generated --additional-initialism=PKI --exclude-main -A rekor_server --exclude-spec --flag-strategy=pflag + +lint: $(SRCS) + $(GOBIN)/golangci-lint run -v ./... + +gosec: $(SRCS) + $(GOBIN)/gosec ./... + +cli: $(SRCS) + go build ./cmd/cli + +server: $(SRCS) + go build ./cmd/server + +test: + go test ./... + +clean: + rm -rf cli server diff --git a/cmd/cli/app/log_info.go b/cmd/cli/app/log_info.go new file mode 100644 index 0000000000000000000000000000000000000000..d2132e2866dd2456e22424389649678dc102c13e --- /dev/null +++ b/cmd/cli/app/log_info.go @@ -0,0 +1,57 @@ +/* +Copyright © 2020 Bob Callaway <bcallawa@redhat.com> + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +package app + +import ( + "fmt" + "net/url" + + "github.com/projectrekor/rekor/pkg/generated/client" + "github.com/projectrekor/rekor/pkg/log" + "github.com/spf13/cobra" + "github.com/spf13/viper" +) + +// verifyCmd represents the get command +var logInfoCmd = &cobra.Command{ + Use: "loginfo", + Short: "Rekor loginfo command", + Long: `Prints info about the transparency log`, + Run: func(cmd *cobra.Command, args []string) { + log := log.Logger + rekorServer := viper.GetString("rekor_server") + + url, err := url.Parse(rekorServer) + if err != nil { + log.Fatal(err) + } + + tc := client.DefaultTransportConfig().WithHost(url.Host) + rc := client.NewHTTPClientWithConfig(nil, tc) + + result, err := rc.Tlog.GetLogInfo(nil) + if err != nil { + log.Fatal(err) + } + + logInfo := result.GetPayload() + fmt.Printf("Tree Size: %v, Root Hash: %v\n", *logInfo.TreeSize, *logInfo.RootHash) + }, +} + +func init() { + rootCmd.AddCommand(logInfoCmd) +} diff --git a/cmd/server/app/serve.go b/cmd/server/app/serve.go index 962d9f4cb37b8b78d907ead17bb12b162749ea20..7888786e5dbe7dec927c867082286ea90e73342a 100644 --- a/cmd/server/app/serve.go +++ b/cmd/server/app/serve.go @@ -17,10 +17,13 @@ limitations under the License. package app import ( - "log" + "github.com/go-openapi/loads" + "github.com/projectrekor/rekor/pkg/generated/restapi/operations" + "github.com/projectrekor/rekor/pkg/log" - "github.com/projectrekor/rekor/pkg/api" + "github.com/projectrekor/rekor/pkg/generated/restapi" "github.com/spf13/cobra" + "github.com/spf13/viper" ) // serveCmd represents the serve command @@ -29,15 +32,18 @@ var serveCmd = &cobra.Command{ Short: "start http server with configured api", Long: `Starts a http server and serves the configured api`, Run: func(cmd *cobra.Command, args []string) { - server, err := api.NewServer() - if err != nil { - log.Fatal(err) + + doc, _ := loads.Embedded(restapi.SwaggerJSON, restapi.FlatSwaggerJSON) + server := restapi.NewServer(operations.NewRekorServerAPI(doc)) + server.Host = viper.GetString("rekor_server.address") + server.Port = int(viper.GetUint("rekor_server.port")) + server.ConfigureAPI() + if err := server.Serve(); err != nil { + log.Logger.Fatal(err) } - server.Start() }, } func init() { rootCmd.AddCommand(serveCmd) - //viper.SetDefault("port", "localhost:3000") } diff --git a/go.mod b/go.mod index 6e1245fa681e1b4625f640783d522dcf60e3345c..f6ad081b0707668ca0ce2084dddecbf9aa29f58f 100644 --- a/go.mod +++ b/go.mod @@ -6,17 +6,26 @@ require ( github.com/coreos/bbolt v1.3.3 // indirect github.com/coreos/etcd v3.3.18+incompatible // indirect github.com/go-chi/chi v4.1.2+incompatible + github.com/go-openapi/errors v0.19.9 + github.com/go-openapi/loads v0.19.7 + github.com/go-openapi/runtime v0.19.24 + github.com/go-openapi/spec v0.19.15 + github.com/go-openapi/strfmt v0.19.11 + github.com/go-openapi/swag v0.19.12 + github.com/go-openapi/validate v0.19.15 github.com/golang/protobuf v1.4.2 github.com/google/certificate-transparency-go v1.1.0 // indirect github.com/google/trillian v1.3.10 github.com/mitchellh/go-homedir v1.1.0 github.com/prometheus/common v0.10.0 github.com/spf13/cobra v1.0.0 + github.com/spf13/pflag v1.0.5 github.com/spf13/viper v1.7.1 go.etcd.io/etcd v3.3.25+incompatible // indirect go.uber.org/goleak v1.1.10 go.uber.org/zap v1.16.0 - golang.org/x/crypto v0.0.0-20200311171314-f7b00557c8c4 + golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9 + golang.org/x/net v0.0.0-20201110031124-69a78807bb2b golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a google.golang.org/appengine v1.6.6 google.golang.org/grpc v1.32.0 diff --git a/go.sum b/go.sum index 791cea8bf28dfbfdf519c5d219f9951f9796ac3d..a989bb248d4261d05c9a6d6b8c6a449448f3a927 100644 --- a/go.sum +++ b/go.sum @@ -49,22 +49,36 @@ github.com/Masterminds/sprig v2.22.0+incompatible h1:z4yfnGrZ7netVz+0EDJ0Wi+5VZC github.com/Masterminds/sprig v2.22.0+incompatible/go.mod h1:y6hNFY5UBTIWBxnzTeuNhlNS5hqE0NB0E6fgfo2Br3o= github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= github.com/OpenPeeDeeP/depguard v1.0.0/go.mod h1:7/4sitnI9YlQgTLLk734QlzXT8DuHVnAyztLplQjk+o= +github.com/PuerkitoBio/purell v1.1.0/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0= +github.com/PuerkitoBio/purell v1.1.1 h1:WEQqlqaGbrPkxLJWfBwQmfEAE1Z7ONdDLqrN38tNFfI= +github.com/PuerkitoBio/purell v1.1.1/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0= +github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 h1:d+Bc7a5rLufV/sSk/8dngufqelfh6jnri85riMAaF/M= +github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE= github.com/StackExchange/wmi v0.0.0-20180116203802-5d049714c4a6/go.mod h1:3eOhrUMpNV+6aFIbp5/iudMxNCF27Vw2OZgy4xEx0Fg= +github.com/agnivade/levenshtein v1.0.1/go.mod h1:CURSv5d9Uaml+FovSIICkLbAUZ9S4RqaHDIsdSBg7lM= github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751 h1:JYp7IbQjafoB+tBA3gMyHYHrpOtNuDiK/uB5uXxq5wM= github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4 h1:Hs82Z41s6SdL1CELW+XaDYmOH4hkBN4/N9og/AsOv7E= github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= +github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883/go.mod h1:rCTlJbsFo29Kk6CurOXKm700vrz8f0KW0JNfpkRJY/8= github.com/antihax/optional v0.0.0-20180407024304-ca021399b1a6/go.mod h1:V8iCPQYkqmusNa815XgQio277wI47sdRh1dUOLdyC6Q= github.com/aokoli/goutils v1.0.1/go.mod h1:SijmP0QR8LtwsmDs8Yii5Z/S4trXFGFC2oO5g9DP+DQ= github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o= github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8= github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY= github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= +github.com/asaskevich/govalidator v0.0.0-20180720115003-f9ffefc3facf/go.mod h1:lB+ZfQJz7igIIfQNfa7Ml4HSf2uFQQRzpGGRXenZAgY= +github.com/asaskevich/govalidator v0.0.0-20190424111038-f61b66f89f4a/go.mod h1:lB+ZfQJz7igIIfQNfa7Ml4HSf2uFQQRzpGGRXenZAgY= +github.com/asaskevich/govalidator v0.0.0-20200108200545-475eaeb16496/go.mod h1:oGkLhpf+kjZl6xBf758TQhh5XrAeiJv/7FRz/2spLIg= +github.com/asaskevich/govalidator v0.0.0-20200428143746-21a406dcc535/go.mod h1:oGkLhpf+kjZl6xBf758TQhh5XrAeiJv/7FRz/2spLIg= +github.com/asaskevich/govalidator v0.0.0-20200907205600-7a23bdc65eef h1:46PFijGLmAjMPwCCCo7Jf0W6f9slllCkkv7vyc1yOSg= +github.com/asaskevich/govalidator v0.0.0-20200907205600-7a23bdc65eef/go.mod h1:WaHUgvxTVq04UNunO+XhnAqY/wQc+bxr74GqbsZ/Jqw= github.com/aws/aws-sdk-go v1.19.18/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo= github.com/aws/aws-sdk-go v1.23.20/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo= github.com/aws/aws-sdk-go v1.25.37/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo= +github.com/aws/aws-sdk-go v1.34.28/go.mod h1:H7NKnBqNVzoTJpGfLrQkkD+ytBA93eiDYi/+8rV9s48= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= @@ -108,6 +122,7 @@ github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:ma github.com/cpuguy83/go-md2man/v2 v2.0.0 h1:EoUDS0afbrsXAZ9YQ9jdu/mZ2sXgT1/2yyNng4PGlyM= github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY= +github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v0.0.0-20161028175848-04cdfd42973b/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= 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= @@ -115,6 +130,9 @@ github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs github.com/dgrijalva/jwt-go v3.2.0+incompatible h1:7qlOGliEKZXTDg6OTjfoBKDXWrumCAMpl/TFQ4/5kLM= github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no= +github.com/docker/go-units v0.3.3/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= +github.com/docker/go-units v0.4.0 h1:3uh0PgVws3nIA0Q+MwDC8yjEPf9zjRfZZWXZYDct3Tw= +github.com/docker/go-units v0.4.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= github.com/dustin/go-humanize v0.0.0-20171111073723-bb3d318650d4/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo= github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= @@ -131,6 +149,8 @@ github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMo github.com/fullstorydev/grpcurl v1.6.0 h1:p8BB6VZF8O7w6MxGr3KJ9E6EVKaswCevSALK6FBtMzA= github.com/fullstorydev/grpcurl v1.6.0/go.mod h1:ZQ+ayqbKMJNhzLmbpCiurTVlaK2M/3nqZCxaQ2Ze/sM= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= +github.com/globalsign/mgo v0.0.0-20180905125535-1ca0a4f7cbcb/go.mod h1:xkRDCp4j0OGD1HRkm4kmhM+pmpv3AKq5SU7GMg4oO/Q= +github.com/globalsign/mgo v0.0.0-20181015135952-eeefdecb41b8/go.mod h1:xkRDCp4j0OGD1HRkm4kmhM+pmpv3AKq5SU7GMg4oO/Q= github.com/go-chi/chi v1.5.0 h1:2ZcJZozJ+rj6BA0c19ffBUGXEKAT/aOLOtQjD46vBRA= github.com/go-chi/chi v1.5.0/go.mod h1:REp24E+25iKvxgeTfHmdUoL5x15kBiDBlnIl5bCwe2k= github.com/go-chi/chi v4.1.2+incompatible h1:fGFk2Gmi/YKXk0OmGfBh0WgmN3XB8lVnEyNz34tQRec= @@ -145,10 +165,89 @@ github.com/go-lintpack/lintpack v0.5.2/go.mod h1:NwZuYi2nUHho8XEIZ6SIxihrnPoqBTD github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= github.com/go-ole/go-ole v1.2.1/go.mod h1:7FAglXiTm7HKlQRDeOQ6ZNUHidzCWXuZWq/1dTyBNF8= +github.com/go-openapi/analysis v0.0.0-20180825180245-b006789cd277/go.mod h1:k70tL6pCuVxPJOHXQ+wIac1FUrvNkHolPie/cLEU6hI= +github.com/go-openapi/analysis v0.17.0/go.mod h1:IowGgpVeD0vNm45So8nr+IcQ3pxVtpRoBWb8PVZO0ik= +github.com/go-openapi/analysis v0.18.0/go.mod h1:IowGgpVeD0vNm45So8nr+IcQ3pxVtpRoBWb8PVZO0ik= +github.com/go-openapi/analysis v0.19.2/go.mod h1:3P1osvZa9jKjb8ed2TPng3f0i/UY9snX6gxi44djMjk= +github.com/go-openapi/analysis v0.19.4/go.mod h1:3P1osvZa9jKjb8ed2TPng3f0i/UY9snX6gxi44djMjk= +github.com/go-openapi/analysis v0.19.5/go.mod h1:hkEAkxagaIvIP7VTn8ygJNkd4kAYON2rCu0v0ObL0AU= +github.com/go-openapi/analysis v0.19.10/go.mod h1:qmhS3VNFxBlquFJ0RGoDtylO9y4pgTAUNE9AEEMdlJQ= +github.com/go-openapi/analysis v0.19.16 h1:Ub9e++M8sDwtHD+S587TYi+6ANBG1NRYGZDihqk0SaY= +github.com/go-openapi/analysis v0.19.16/go.mod h1:GLInF007N83Ad3m8a/CbQ5TPzdnGT7workfHwuVjNVk= +github.com/go-openapi/errors v0.17.0/go.mod h1:LcZQpmvG4wyF5j4IhA73wkLFQg+QJXOQHVjmcZxhka0= +github.com/go-openapi/errors v0.18.0/go.mod h1:LcZQpmvG4wyF5j4IhA73wkLFQg+QJXOQHVjmcZxhka0= +github.com/go-openapi/errors v0.19.2/go.mod h1:qX0BLWsyaKfvhluLejVpVNwNRdXZhEbTA4kxxpKBC94= +github.com/go-openapi/errors v0.19.3/go.mod h1:qX0BLWsyaKfvhluLejVpVNwNRdXZhEbTA4kxxpKBC94= +github.com/go-openapi/errors v0.19.6/go.mod h1:cM//ZKUKyO06HSwqAelJ5NsEMMcpa6VpXe8DOa1Mi1M= +github.com/go-openapi/errors v0.19.7/go.mod h1:cM//ZKUKyO06HSwqAelJ5NsEMMcpa6VpXe8DOa1Mi1M= +github.com/go-openapi/errors v0.19.8/go.mod h1:cM//ZKUKyO06HSwqAelJ5NsEMMcpa6VpXe8DOa1Mi1M= +github.com/go-openapi/errors v0.19.9 h1:9SnKdGhiPZHF3ttwFMiCBEb8jQ4IDdrK+5+a0oTygA4= +github.com/go-openapi/errors v0.19.9/go.mod h1:cM//ZKUKyO06HSwqAelJ5NsEMMcpa6VpXe8DOa1Mi1M= +github.com/go-openapi/jsonpointer v0.17.0/go.mod h1:cOnomiV+CVVwFLk0A/MExoFMjwdsUdVpsRhURCKh+3M= +github.com/go-openapi/jsonpointer v0.18.0/go.mod h1:cOnomiV+CVVwFLk0A/MExoFMjwdsUdVpsRhURCKh+3M= +github.com/go-openapi/jsonpointer v0.19.2/go.mod h1:3akKfEdA7DF1sugOqz1dVQHBcuDBPKZGEoHC/NkiQRg= +github.com/go-openapi/jsonpointer v0.19.3/go.mod h1:Pl9vOtqEWErmShwVjC8pYs9cog34VGT37dQOVbmoatg= +github.com/go-openapi/jsonpointer v0.19.5 h1:gZr+CIYByUqjcgeLXnQu2gHYQC9o73G2XUeOFYEICuY= +github.com/go-openapi/jsonpointer v0.19.5/go.mod h1:Pl9vOtqEWErmShwVjC8pYs9cog34VGT37dQOVbmoatg= +github.com/go-openapi/jsonreference v0.17.0/go.mod h1:g4xxGn04lDIRh0GJb5QlpE3HfopLOL6uZrK/VgnsK9I= +github.com/go-openapi/jsonreference v0.18.0/go.mod h1:g4xxGn04lDIRh0GJb5QlpE3HfopLOL6uZrK/VgnsK9I= +github.com/go-openapi/jsonreference v0.19.2/go.mod h1:jMjeRr2HHw6nAVajTXJ4eiUwohSTlpa0o73RUL1owJc= +github.com/go-openapi/jsonreference v0.19.3/go.mod h1:rjx6GuL8TTa9VaixXglHmQmIL98+wF9xc8zWvFonSJ8= +github.com/go-openapi/jsonreference v0.19.5 h1:1WJP/wi4OjB4iV8KVbH73rQaoialJrqv8gitZLxGLtM= +github.com/go-openapi/jsonreference v0.19.5/go.mod h1:RdybgQwPxbL4UEjuAruzK1x3nE69AqPYEJeo/TWfEeg= +github.com/go-openapi/loads v0.17.0/go.mod h1:72tmFy5wsWx89uEVddd0RjRWPZm92WRLhf7AC+0+OOU= +github.com/go-openapi/loads v0.18.0/go.mod h1:72tmFy5wsWx89uEVddd0RjRWPZm92WRLhf7AC+0+OOU= +github.com/go-openapi/loads v0.19.0/go.mod h1:72tmFy5wsWx89uEVddd0RjRWPZm92WRLhf7AC+0+OOU= +github.com/go-openapi/loads v0.19.2/go.mod h1:QAskZPMX5V0C2gvfkGZzJlINuP7Hx/4+ix5jWFxsNPs= +github.com/go-openapi/loads v0.19.3/go.mod h1:YVfqhUCdahYwR3f3iiwQLhicVRvLlU/WO5WPaZvcvSI= +github.com/go-openapi/loads v0.19.5/go.mod h1:dswLCAdonkRufe/gSUC3gN8nTSaB9uaS2es0x5/IbjY= +github.com/go-openapi/loads v0.19.6/go.mod h1:brCsvE6j8mnbmGBh103PT/QLHfbyDxA4hsKvYBNEGVc= +github.com/go-openapi/loads v0.19.7 h1:6cALLpCAq4tYhaic7TMbEzjv8vq/wg+0AFivNy/Bma8= +github.com/go-openapi/loads v0.19.7/go.mod h1:brCsvE6j8mnbmGBh103PT/QLHfbyDxA4hsKvYBNEGVc= +github.com/go-openapi/runtime v0.0.0-20180920151709-4f900dc2ade9/go.mod h1:6v9a6LTXWQCdL8k1AO3cvqx5OtZY/Y9wKTgaoP6YRfA= +github.com/go-openapi/runtime v0.19.0/go.mod h1:OwNfisksmmaZse4+gpV3Ne9AyMOlP1lt4sK4FXt0O64= +github.com/go-openapi/runtime v0.19.4/go.mod h1:X277bwSUBxVlCYR3r7xgZZGKVvBd/29gLDlFGtJ8NL4= +github.com/go-openapi/runtime v0.19.15/go.mod h1:dhGWCTKRXlAfGnQG0ONViOZpjfg0m2gUt9nTQPQZuoo= +github.com/go-openapi/runtime v0.19.16/go.mod h1:5P9104EJgYcizotuXhEuUrzVc+j1RiSjahULvYmlv98= +github.com/go-openapi/runtime v0.19.24 h1:TqagMVlRAOTwllE/7hNKx6rQ10O6T8ZzeJdMjSTKaD4= +github.com/go-openapi/runtime v0.19.24/go.mod h1:Lm9YGCeecBnUUkFTxPC4s1+lwrkJ0pthx8YvyjCfkgk= +github.com/go-openapi/spec v0.17.0/go.mod h1:XkF/MOi14NmjsfZ8VtAKf8pIlbZzyoTvZsdfssdxcBI= +github.com/go-openapi/spec v0.18.0/go.mod h1:XkF/MOi14NmjsfZ8VtAKf8pIlbZzyoTvZsdfssdxcBI= +github.com/go-openapi/spec v0.19.2/go.mod h1:sCxk3jxKgioEJikev4fgkNmwS+3kuYdJtcsZsD5zxMY= +github.com/go-openapi/spec v0.19.3/go.mod h1:FpwSN1ksY1eteniUU7X0N/BgJ7a4WvBFVA8Lj9mJglo= +github.com/go-openapi/spec v0.19.6/go.mod h1:Hm2Jr4jv8G1ciIAo+frC/Ft+rR2kQDh8JHKHb3gWUSk= +github.com/go-openapi/spec v0.19.8/go.mod h1:Hm2Jr4jv8G1ciIAo+frC/Ft+rR2kQDh8JHKHb3gWUSk= +github.com/go-openapi/spec v0.19.15 h1:uxh8miNJEfMm8l8ekpY7i39LcORm1xSRtoipEGl1JPk= +github.com/go-openapi/spec v0.19.15/go.mod h1:+81FIL1JwC5P3/Iuuozq3pPE9dXdIEGxFutcFKaVbmU= +github.com/go-openapi/strfmt v0.17.0/go.mod h1:P82hnJI0CXkErkXi8IKjPbNBM6lV6+5pLP5l494TcyU= +github.com/go-openapi/strfmt v0.18.0/go.mod h1:P82hnJI0CXkErkXi8IKjPbNBM6lV6+5pLP5l494TcyU= +github.com/go-openapi/strfmt v0.19.0/go.mod h1:+uW+93UVvGGq2qGaZxdDeJqSAqBqBdl+ZPMF/cC8nDY= +github.com/go-openapi/strfmt v0.19.2/go.mod h1:0yX7dbo8mKIvc3XSKp7MNfxw4JytCfCD6+bY1AVL9LU= +github.com/go-openapi/strfmt v0.19.3/go.mod h1:0yX7dbo8mKIvc3XSKp7MNfxw4JytCfCD6+bY1AVL9LU= +github.com/go-openapi/strfmt v0.19.4/go.mod h1:eftuHTlB/dI8Uq8JJOyRlieZf+WkkxUuk0dgdHXr2Qk= +github.com/go-openapi/strfmt v0.19.5/go.mod h1:eftuHTlB/dI8Uq8JJOyRlieZf+WkkxUuk0dgdHXr2Qk= +github.com/go-openapi/strfmt v0.19.11 h1:0+YvbNh05rmBkgztd6zHp4OCFn7Mtu30bn46NQo2ZRw= +github.com/go-openapi/strfmt v0.19.11/go.mod h1:UukAYgTaQfqJuAFlNxxMWNvMYiwiXtLsF2VwmoFtbtc= +github.com/go-openapi/swag v0.17.0/go.mod h1:AByQ+nYG6gQg71GINrmuDXCPWdL640yX49/kXLo40Tg= +github.com/go-openapi/swag v0.18.0/go.mod h1:AByQ+nYG6gQg71GINrmuDXCPWdL640yX49/kXLo40Tg= +github.com/go-openapi/swag v0.19.2/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh66Z9tfKk= +github.com/go-openapi/swag v0.19.5/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh66Z9tfKk= +github.com/go-openapi/swag v0.19.7/go.mod h1:ao+8BpOPyKdpQz3AOJfbeEVpLmWAvlT1IfTe5McPyhY= +github.com/go-openapi/swag v0.19.9/go.mod h1:ao+8BpOPyKdpQz3AOJfbeEVpLmWAvlT1IfTe5McPyhY= +github.com/go-openapi/swag v0.19.12 h1:Bc0bnY2c3AoF7Gc+IMIAQQsD8fLHjHpc19wXvYuayQI= +github.com/go-openapi/swag v0.19.12/go.mod h1:eFdyEBkTdoAf/9RXBvj4cr1nH7GD8Kzo5HTt47gr72M= +github.com/go-openapi/validate v0.18.0/go.mod h1:Uh4HdOzKt19xGIGm1qHf/ofbX1YQ4Y+MYsct2VUrAJ4= +github.com/go-openapi/validate v0.19.2/go.mod h1:1tRCw7m3jtI8eNWEEliiAqUIcBztB2KDnRCRMUi7GTA= +github.com/go-openapi/validate v0.19.3/go.mod h1:90Vh6jjkTn+OT1Eefm0ZixWNFjhtOH7vS9k0lo6zwJo= +github.com/go-openapi/validate v0.19.10/go.mod h1:RKEZTUWDkxKQxN2jDT7ZnZi2bhZlbNMAuKvKB+IaGx8= +github.com/go-openapi/validate v0.19.12/go.mod h1:Rzou8hA/CBw8donlS6WNEUQupNvUZ0waH08tGe6kAQ4= +github.com/go-openapi/validate v0.19.15 h1:oUHZO8jD7p5oRLANlXF0U8ic9ePBUkDQyRZdN0EhL6M= +github.com/go-openapi/validate v0.19.15/go.mod h1:tbn/fdOwYHgrhPBzidZfJC2MIVvs9GA7monOmWBbeCI= github.com/go-redis/redis v6.15.8+incompatible/go.mod h1:NAIEuMOZ/fxfXJIrKDQDz8wamY7mA7PouImQ2Jvg6kA= github.com/go-sql-driver/mysql v1.4.1/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w= github.com/go-sql-driver/mysql v1.5.0 h1:ozyZYNQW3x3HtqT1jira07DN2PArx2v7/mN66gGcHOs= github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= +github.com/go-stack/stack v1.8.0 h1:5SgMzNM5HxrEjV0ww2lTmX6E2Izsfxas4+YHWRs3Lsk= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= github.com/go-toolsmith/astcast v1.0.0/go.mod h1:mt2OdQTeAQcY4DQgPSArJjHCcOwlX+Wl/kwN+LbLGQ4= github.com/go-toolsmith/astcopy v1.0.0/go.mod h1:vrgyG+5Bxrnz4MZWPF+pI4R8h3qKRjjyvV/DSez4WVQ= @@ -163,6 +262,30 @@ github.com/go-toolsmith/pkgload v0.0.0-20181119091011-e9e65178eee8/go.mod h1:WoM github.com/go-toolsmith/pkgload v1.0.0/go.mod h1:5eFArkbO80v7Z0kdngIxsRXRMTaX4Ilcwuh3clNrQJc= github.com/go-toolsmith/strparse v1.0.0/go.mod h1:YI2nUKP9YGZnL/L1/DLFBfixrcjslWct4wyljWhSRy8= github.com/go-toolsmith/typep v1.0.0/go.mod h1:JSQCQMUPdRlMZFswiq3TGpNp1GMktqkR2Ns5AIQkATU= +github.com/gobuffalo/attrs v0.0.0-20190224210810-a9411de4debd/go.mod h1:4duuawTqi2wkkpB4ePgWMaai6/Kc6WEz83bhFwpHzj0= +github.com/gobuffalo/depgen v0.0.0-20190329151759-d478694a28d3/go.mod h1:3STtPUQYuzV0gBVOY3vy6CfMm/ljR4pABfrTeHNLHUY= +github.com/gobuffalo/depgen v0.1.0/go.mod h1:+ifsuy7fhi15RWncXQQKjWS9JPkdah5sZvtHc2RXGlg= +github.com/gobuffalo/envy v1.6.15/go.mod h1:n7DRkBerg/aorDM8kbduw5dN3oXGswK5liaSCx4T5NI= +github.com/gobuffalo/envy v1.7.0/go.mod h1:n7DRkBerg/aorDM8kbduw5dN3oXGswK5liaSCx4T5NI= +github.com/gobuffalo/flect v0.1.0/go.mod h1:d2ehjJqGOH/Kjqcoz+F7jHTBbmDb38yXA598Hb50EGs= +github.com/gobuffalo/flect v0.1.1/go.mod h1:8JCgGVbRjJhVgD6399mQr4fx5rRfGKVzFjbj6RE/9UI= +github.com/gobuffalo/flect v0.1.3/go.mod h1:8JCgGVbRjJhVgD6399mQr4fx5rRfGKVzFjbj6RE/9UI= +github.com/gobuffalo/genny v0.0.0-20190329151137-27723ad26ef9/go.mod h1:rWs4Z12d1Zbf19rlsn0nurr75KqhYp52EAGGxTbBhNk= +github.com/gobuffalo/genny v0.0.0-20190403191548-3ca520ef0d9e/go.mod h1:80lIj3kVJWwOrXWWMRzzdhW3DsrdjILVil/SFKBzF28= +github.com/gobuffalo/genny v0.1.0/go.mod h1:XidbUqzak3lHdS//TPu2OgiFB+51Ur5f7CSnXZ/JDvo= +github.com/gobuffalo/genny v0.1.1/go.mod h1:5TExbEyY48pfunL4QSXxlDOmdsD44RRq4mVZ0Ex28Xk= +github.com/gobuffalo/gitgen v0.0.0-20190315122116-cc086187d211/go.mod h1:vEHJk/E9DmhejeLeNt7UVvlSGv3ziL+djtTr3yyzcOw= +github.com/gobuffalo/gogen v0.0.0-20190315121717-8f38393713f5/go.mod h1:V9QVDIxsgKNZs6L2IYiGR8datgMhB577vzTDqypH360= +github.com/gobuffalo/gogen v0.1.0/go.mod h1:8NTelM5qd8RZ15VjQTFkAW6qOMx5wBbW4dSCS3BY8gg= +github.com/gobuffalo/gogen v0.1.1/go.mod h1:y8iBtmHmGc4qa3urIyo1shvOD8JftTtfcKi+71xfDNE= +github.com/gobuffalo/logger v0.0.0-20190315122211-86e12af44bc2/go.mod h1:QdxcLw541hSGtBnhUc4gaNIXRjiDppFGaDqzbrBd3v8= +github.com/gobuffalo/mapi v1.0.1/go.mod h1:4VAGh89y6rVOvm5A8fKFxYG+wIW6LO1FMTG9hnKStFc= +github.com/gobuffalo/mapi v1.0.2/go.mod h1:4VAGh89y6rVOvm5A8fKFxYG+wIW6LO1FMTG9hnKStFc= +github.com/gobuffalo/packd v0.0.0-20190315124812-a385830c7fc0/go.mod h1:M2Juc+hhDXf/PnmBANFCqx4DM3wRbgDvnVWeG2RIxq4= +github.com/gobuffalo/packd v0.1.0/go.mod h1:M2Juc+hhDXf/PnmBANFCqx4DM3wRbgDvnVWeG2RIxq4= +github.com/gobuffalo/packr/v2 v2.0.9/go.mod h1:emmyGweYTm6Kdper+iywB6YK5YzuKchGtJQZ0Odn4pQ= +github.com/gobuffalo/packr/v2 v2.2.0/go.mod h1:CaAwI0GPIAv+5wKLtv8Afwl+Cm78K/I/VCm/3ptBN+0= +github.com/gobuffalo/syncx v0.0.0-20190224160051-33c29581e754/go.mod h1:HhnNqWY95UYwwW3uSASeV7vtgYkT2t16hJgV3AEPUpw= github.com/gobwas/glob v0.2.3/go.mod h1:d3Ez4x06l9bZtSvzIay5+Yzi0fmZzPgnTbPcKjJAkT8= github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4= @@ -202,6 +325,7 @@ github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvq github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= github.com/golang/protobuf v1.4.2 h1:+Z5KGCizgyZCbGh1KZqA0fcLLkwbsjIzS4aV2v7wJX0= github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= +github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/golangci/check v0.0.0-20180506172741-cfe4005ccda2/go.mod h1:k9Qvh+8juN+UKMCS/3jFtGICgW8O96FVaZsaxdzDkR4= github.com/golangci/dupl v0.0.0-20180902072040-3e9179ac440a/go.mod h1:ryS0uhF+x9jgbj/N71xsEqODy9BN81/GonCZiOzirOk= github.com/golangci/errcheck v0.0.0-20181223084120-ef45e06d44b6/go.mod h1:DbHgvLiFKX1Sh2T1w8Q/h4NAI8MHIpzCdnBUDTXU3I0= @@ -232,6 +356,7 @@ github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.4.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.0 h1:/QaMHBdZ26BB3SSst0Iwl10Epc+xhTquomWX0oZEB6w= github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= github.com/google/monologue v0.0.0-20190606152607-4b11a32b5934/go.mod h1:6NTfaQoUpg5QmPsCUWLR3ig33FHrKXhTtWzF0DVdmuk= @@ -308,8 +433,13 @@ github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANyt github.com/jhump/protoreflect v1.6.1 h1:4/2yi5LyDPP7nN+Hiird1SAJ6YoxUm13/oxHGRnbPd8= github.com/jhump/protoreflect v1.6.1/go.mod h1:RZQ/lnuN+zqeRVpQigTwO6o0AJUkxbnSnpuG7toUTG4= github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k= +github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo= +github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U= +github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg= github.com/jonboulle/clockwork v0.1.0 h1:VKV+ZcuP6l3yW9doeqz6ziZGgcynBVQO+obU0+0hcPo= github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo= +github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY= +github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y= github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= github.com/json-iterator/go v1.1.7/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/json-iterator/go v1.1.10 h1:Kz6Cvnvv2wGdaG/V8yMvfkmNiXq9Ya2KUv4rouJJr68= @@ -320,12 +450,15 @@ github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7 github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= github.com/juju/ratelimit v1.0.1/go.mod h1:qapgC/Gy+xNh9UxzV13HGGl/6UXNN+ct+vwSgWNm/qk= github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= +github.com/karrick/godirwalk v1.8.0/go.mod h1:H5KPZjojv4lE+QYImBI8xVtrBRgYrIVsaRPx4tDPEn4= +github.com/karrick/godirwalk v1.10.3/go.mod h1:RoGL9dQei4vP9ilrpETWE8CLOZ1kiN0LhBygSwrAsHA= github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q= github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00= github.com/kisielk/gotool v0.0.0-20161130080628-0de1eaf82fa3/go.mod h1:jxZFDH7ILpTPQTk+E2s+z4CUas9lVNjIuKR4c5/zKgM= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/klauspost/compress v1.4.0/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A= github.com/klauspost/compress v1.4.1/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A= +github.com/klauspost/compress v1.9.5/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A= github.com/klauspost/cpuid v0.0.0-20180405133222-e7e905edc00e/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgoMS4s3ek= github.com/klauspost/cpuid v1.2.0/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgoMS4s3ek= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= @@ -335,8 +468,10 @@ github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFB github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/pty v1.1.5/go.mod h1:9r2w37qlBe7rQ6e1fg1S/9xpWHSnaqNdHD3WcMdbPDA= github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= github.com/letsencrypt/pkcs11key v2.0.1-0.20170608213348-396559074696+incompatible/go.mod h1:iGYXKqDXt0cpBthCHdr9ZdsQwyGlYFh/+8xa4WzIQ34= github.com/letsencrypt/pkcs11key/v4 v4.0.0/go.mod h1:EFUvBDay26dErnNb70Nd0/VW3tJiIbETBPTl9ATXQag= @@ -347,6 +482,15 @@ github.com/magiconair/properties v1.7.6/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czP github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= github.com/magiconair/properties v1.8.1 h1:ZC2Vc7/ZFkGmsVC9KvOjumD+G5lXy2RtTKyzRKO2BQ4= github.com/magiconair/properties v1.8.1/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= +github.com/mailru/easyjson v0.0.0-20180823135443-60711f1a8329/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= +github.com/mailru/easyjson v0.0.0-20190312143242-1de009706dbe/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= +github.com/mailru/easyjson v0.0.0-20190614124828-94de47d64c63/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= +github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= +github.com/mailru/easyjson v0.7.1/go.mod h1:KAzv3t3aY1NaHWoQz1+4F1ccyAH66Jk7yos7ldAVICs= +github.com/mailru/easyjson v0.7.6 h1:8yTIVnZgCoiM1TgqoeTl+LfU5Jg6/xL3QhGQnimLYnA= +github.com/mailru/easyjson v0.7.6/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= +github.com/markbates/oncer v0.0.0-20181203154359-bf2de49a0be2/go.mod h1:Ld9puTsIW75CHf65OeIOkyKbteujpZVXDpWK6YGZbxE= +github.com/markbates/safe v1.0.1/go.mod h1:nAqgmRi7cY2nqMc92/bSEeQA+R4OheNU2T1kNSCBdG0= github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= github.com/mattn/go-colorable v0.1.4 h1:snbPLB8fVfU9iwbbo30TPtbLRzwWu6aJS6Xh4eaaviA= github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= @@ -380,6 +524,10 @@ github.com/mitchellh/mapstructure v0.0.0-20160808181253-ca63d7c062ee/go.mod h1:F github.com/mitchellh/mapstructure v0.0.0-20180220230111-00c29f56e238/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= github.com/mitchellh/mapstructure v1.1.2 h1:fmNYVwqnSfB9mZU6OS2O6GsXM+wcskZDuKQzvN1EDeE= github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= +github.com/mitchellh/mapstructure v1.3.2/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= +github.com/mitchellh/mapstructure v1.3.3/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= +github.com/mitchellh/mapstructure v1.4.0 h1:7ks8ZkOP5/ujthUsT07rNv+nkLXCQWKNHuwzOAesEks= +github.com/mitchellh/mapstructure v1.4.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= github.com/mitchellh/reflectwalk v1.0.0/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= github.com/mitchellh/reflectwalk v1.0.1 h1:FVzMWA5RllMAKIdUSC8mdWo3XtwoecrH79BY70sEEpE= github.com/mitchellh/reflectwalk v1.0.1/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= @@ -390,6 +538,7 @@ github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lN github.com/modern-go/reflect2 v1.0.1 h1:9f412s+6RmYXLWZSEzVVgPGK7C2PphHj5RJrvfx9AWI= github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826/go.mod h1:TaXosZuwdSHYgviHp1DAtfrULt5eUgsSMsZf+YrPgl8= +github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe/go.mod h1:wL8QJuTMNUDYhXwkmfOly8iTdp5TEcJFWZD2D7SIkUc= github.com/mozilla/tls-observatory v0.0.0-20180409132520-8791a200eb40/go.mod h1:SrKMQvPiws7F7iqYp8/TX+IhxCYhzr6N/1yb8cwHsGk= github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= github.com/mwitkow/go-proto-validators v0.0.0-20180403085117-0950a7990007/go.mod h1:m2XC9Qq0AlmmVksL6FktJCdTYyLk7V3fKyp0sl1yWQo= @@ -397,6 +546,7 @@ github.com/mwitkow/go-proto-validators v0.2.0 h1:F6LFfmgVnfULfaRsQWBbe7F7ocuHCr9 github.com/mwitkow/go-proto-validators v0.2.0/go.mod h1:ZfA1hW+UH/2ZHOWvQ3HnQaU0DtnpXu850MZiy+YUgcc= github.com/nbutton23/zxcvbn-go v0.0.0-20160627004424-a22cb81b2ecd/go.mod h1:o96djdrsSGy3AWPyBgZMAGfxZNfgntdJG+11KU4QvbU= github.com/nbutton23/zxcvbn-go v0.0.0-20171102151520-eafdab6b0663/go.mod h1:o96djdrsSGy3AWPyBgZMAGfxZNfgntdJG+11KU4QvbU= +github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= github.com/nishanths/predeclared v0.0.0-20190419143655-18a43bb90ffc/go.mod h1:62PewwiQTlm/7Rj+cxVYqZvDIUc+JjZq6GHAC1fsObQ= github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U= github.com/olekukonko/tablewriter v0.0.0-20170122224234-a0225b3f23b5/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo= @@ -411,12 +561,17 @@ github.com/onsi/gomega v1.4.2/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1Cpa github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= +github.com/pborman/uuid v1.2.0/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtPdI/k= github.com/pelletier/go-toml v1.1.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= github.com/pelletier/go-toml v1.2.0 h1:T5zMGML61Wp+FlcbWjRDT7yAxhJNAiPPLOFECq181zc= github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= +github.com/pelletier/go-toml v1.4.0/go.mod h1:PN7xzY2wHTK0K9p34ErDQMlFxa51Fk0OUruD3k1mMwo= +github.com/pelletier/go-toml v1.7.0 h1:7utD74fnzVc/cpcyy8sjrlFr5vYpypUixARcHIMIGuI= +github.com/pelletier/go-toml v1.7.0/go.mod h1:vwGMzjaWMwyfHwgIBhI2YUM4fB6nL6lVAvS1LBMMhTE= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I= 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 v0.0.0-20151028094244-d8ed2627bdf0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= @@ -453,6 +608,7 @@ github.com/quasilyte/go-consistent v0.0.0-20190521200055-c6f3937de18c/go.mod h1: github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg= github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= github.com/rogpeppe/go-internal v1.1.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= +github.com/rogpeppe/go-internal v1.2.2/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/rs/cors v1.6.0/go.mod h1:gFx+x8UowdsKA9AchylcLynDq+nNFfI8FkUZdN/jGCU= github.com/russross/blackfriday v1.5.2 h1:HyvC0ARfnZBqnXwABFeSZHpKvJHJJfPz81GNueLj0oo= @@ -471,6 +627,8 @@ github.com/shurcooL/sanitized_anchor_name v1.0.0 h1:PdmoCO6wvbs+7yrJyMORt4/BmY5I github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= github.com/sirupsen/logrus v1.0.5/go.mod h1:pMByvHTf9Beacp5x1UXfOR9xyW/9antXMhjMPG0dEzc= github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= +github.com/sirupsen/logrus v1.4.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= +github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q= github.com/sirupsen/logrus v1.4.2 h1:SPIRibHv4MatM3XXNO2BJeFLZwZ2LvZgfQ5+UNI2im4= github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykElWQ6/NYmHa3jpm/yHnI4xSofP+UP6SpjHcSeM= @@ -507,13 +665,16 @@ github.com/spf13/viper v1.7.1 h1:pM5oEahlgWv/WnHXpgbKz7iLIxRf65tye2Ci+XFK5sk= github.com/spf13/viper v1.7.1/go.mod h1:8WkrPz2fc9jxqZNCJI/76HCieCp4Q8HaLFoCha5qpdg= 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/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE= github.com/stretchr/testify v0.0.0-20170130113145-4d4bfba8f1d1/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= 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 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= +github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s= github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw= +github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk= github.com/timakin/bodyclose v0.0.0-20190721030226-87058b9bfcec/go.mod h1:Qimiffbc6q9tBWlVV6x0P9sat/ao1xEkREYPPj9hphk= github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5 h1:LnC5Kc/wtumK+WB441p7ynQJzVuNRJiqddSIE3IlSEQ= @@ -529,6 +690,9 @@ github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyC github.com/valyala/fasthttp v1.2.0/go.mod h1:4vX61m6KN+xDduDNwXrhIAVZaZaZiQ1luJk8LWSxF3s= github.com/valyala/quicktemplate v1.1.1/go.mod h1:EH+4AkTd43SvgIbQHYu59/cJyxDoOVRUAfrukLPuGJ4= github.com/valyala/tcplisten v0.0.0-20161114210144-ceec8f93295a/go.mod h1:v3UYOV9WzVtRmSR+PDvWpU/qWl4Wa5LApYYX4ZtKbio= +github.com/vektah/gqlparser v1.1.2/go.mod h1:1ycwN7Ij5njmMkPPAOaRFY4rET2Enx7IkVv3vaXspKw= +github.com/xdg/scram v0.0.0-20180814205039-7eeb5667e42c/go.mod h1:lB8K/P019DLNhemzwFU4jHLhdvlE6uDZjXFejJXr49I= +github.com/xdg/stringprep v0.0.0-20180714160509-73f8eece6fdc/go.mod h1:Jhud4/sHMO4oL310DaZAKk9ZaJ08SJfe+sJh0HrGL1Y= github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2 h1:eY9dn8+vbi4tKz5Qo6v2eYzo7kUS51QINcR5jNpbZS8= github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU= github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q= @@ -544,6 +708,12 @@ go.etcd.io/etcd v3.3.17+incompatible h1:g8iRku1SID8QAW8cDlV0L/PkZlw63LSiYEHYHoE6 go.etcd.io/etcd v3.3.17+incompatible/go.mod h1:yaeTdrJi5lOmYerz05bd8+V7KubZs8YSFZfzsF9A6aI= go.etcd.io/etcd v3.3.25+incompatible h1:V1RzkZJj9LqsJRy+TUBgpWSbZXITLB819lstuTFoZOY= go.etcd.io/etcd v3.3.25+incompatible/go.mod h1:yaeTdrJi5lOmYerz05bd8+V7KubZs8YSFZfzsF9A6aI= +go.mongodb.org/mongo-driver v1.0.3/go.mod h1:u7ryQJ+DOzQmeO7zB6MHyr8jkEQvC8vH7qLUO4lqsUM= +go.mongodb.org/mongo-driver v1.1.1/go.mod h1:u7ryQJ+DOzQmeO7zB6MHyr8jkEQvC8vH7qLUO4lqsUM= +go.mongodb.org/mongo-driver v1.3.0/go.mod h1:MSWZXKOynuguX+JSvwP8i+58jYCXxbia8HS3gZBapIE= +go.mongodb.org/mongo-driver v1.3.4/go.mod h1:MSWZXKOynuguX+JSvwP8i+58jYCXxbia8HS3gZBapIE= +go.mongodb.org/mongo-driver v1.4.3 h1:moga+uhicpVshTyaqY9L23E6QqwcHRUv1sqyOsoyOO8= +go.mongodb.org/mongo-driver v1.4.3/go.mod h1:WcMNYLx/IlOxLe6JRJiv2uXuCz6zBLndR4SoGjYphSc= 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= @@ -577,12 +747,19 @@ golang.org/x/crypto v0.0.0-20181029021203-45a5f77698d3/go.mod h1:6SG95UA2DQfeDnf golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190313024323-a1f597ede03a/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20190320223903-b7391e95e576/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20190422162423-af44ce270edf/go.mod h1:WFFai1msRO1wXaEeE5yQxYXgSfI8pQAWXbQop6sCtWE= golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20190530122614-20be4c3c3ed5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20190611184440-5c40567a22f8/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20190617133340-57b3e21c3d56/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191029031824-8986dd9e96cf/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200311171314-f7b00557c8c4 h1:QmwruyY+bKbDDL0BaglrbZABEali68eoMFhTZpCjYVA= golang.org/x/crypto v0.0.0-20200311171314-f7b00557c8c4/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9 h1:psW17arqaxU48Z5kZ0CQnkZWQJsqcURM6tKiBApRjXI= +golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20201124201722-c8d3bf9c5392 h1:xYJJ3S178yv++9zXV/hnr29plCAGO9vAFG9dorqaFQc= 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= @@ -619,6 +796,7 @@ golang.org/x/net v0.0.0-20170915142106-8351a756f30f/go.mod h1:mL1N/T3taQHkDXs73r golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180911220305-26e67e76b6c3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20181005035420-146acd28ed58/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20181023162649-9b4f9f5ad519/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20181201002055-351d144fa1fc/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -626,6 +804,7 @@ golang.org/x/net v0.0.0-20181220203305-927f97764cc3/go.mod h1:mL1N/T3taQHkDXs73r 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-20190320064053-1272bf9dcd53/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= @@ -636,6 +815,7 @@ golang.org/x/net v0.0.0-20190620200207-3b0461eec859 h1:R/3boaszxrf1GEUWTVDzSKVwL 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-20190813141303-74dc4d7220e7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297/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= @@ -650,6 +830,9 @@ golang.org/x/net v0.0.0-20200506145744-7e3656a0809f/go.mod h1:qpuaurCH72eLCgpAm/ golang.org/x/net v0.0.0-20200513185701-a91f0712d120/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/net v0.0.0-20200520182314-0ba52f642ac2 h1:eDrdRpKgkcCqKZQwyZRyeFZgfqt37SL7Kv3tok06cKE= golang.org/x/net v0.0.0-20200520182314-0ba52f642ac2/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20200602114024-627f9648deb9/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20201110031124-69a78807bb2b h1:uwuIcX0g4Yl1NC5XAz37xsr2lTtcqevgzYNVt49waME= +golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= 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-20190402181905-9f3314589c9a/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -679,11 +862,16 @@ golang.org/x/sys v0.0.0-20181205085412-a5c9d58dba9a/go.mod h1:STP8DvDyc/dI5b8T5h golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/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-20190321052220-f7bb7a8bee54/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190403152447-81d4e9dc473e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190419153524-e8e3143a4f4a/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-20190531175056-4c3a928424d2/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190616124812-15dcb6c0061f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0 h1:HyfiK1WMnHj5FXFXatD+Qs1A/xC2Run6RzeW1SyHxpc= 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= @@ -708,12 +896,17 @@ golang.org/x/sys v0.0.0-20200515095857-1151b9dac4a9/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20200523222454-059865788121/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200615200032-f1bc736245b1 h1:ogLJMz+qpzav7lGMh10LMvAkM/fAoGlaiiHYiFYdm80= golang.org/x/sys v0.0.0-20200615200032-f1bc736245b1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f h1:+Nyd8tzPX9R7BWHguqsrbFdRx3WQ/1ib8I44HXV5yTA= +golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.0.0-20170915090833-1cbadb444a80/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 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.4 h1:0YWbFKbhXG/wIiuHDSKpS0Iy7FSA+u45VtBMfQcFTTc= +golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= 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= @@ -727,6 +920,7 @@ golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563/go.mod h1:n7NCudcB/nEzxVGm golang.org/x/tools v0.0.0-20181117154741-2ddaf7f79a09/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190110163146-51295c7ec13a/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190121143147-24cd39ecf745/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190125232054-d66bd3c5d5a6/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-20190311215038-5c2858a9cfe5/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= @@ -734,11 +928,17 @@ golang.org/x/tools v0.0.0-20190312151545-0bb0c0a6e846/go.mod h1:LCzVGOaR6xXOjkQ3 golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190322203728-c1a832b0ad89/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190329151228-23e29df326fe/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190416151739-9c9e1878f421/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190420181800-aa740d480789/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-20190521203540-521d6ed310dd/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= +golang.org/x/tools v0.0.0-20190531172133-b3315ee88b7d/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= +golang.org/x/tools v0.0.0-20190614205625-5aca471b1d59/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= +golang.org/x/tools v0.0.0-20190617190820-da514acc4774/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= @@ -858,6 +1058,7 @@ gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8 gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/cheggaaa/pb.v1 v1.0.25/go.mod h1:V/YB90LKu/1FcN3WVnfiiE5oMCibMjukxqG/qStrOgw= gopkg.in/cheggaaa/pb.v1 v1.0.28 h1:n1tBJnnK2r7g9OW2btFH91V92STTUevLXYFb8gy9EMk= gopkg.in/cheggaaa/pb.v1 v1.0.28/go.mod h1:V/YB90LKu/1FcN3WVnfiiE5oMCibMjukxqG/qStrOgw= @@ -877,6 +1078,13 @@ gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.5/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.6 h1:97YCGUei5WVbkKfogoJQsLwUJ17cWvpLrgNvlcbxikE= gopkg.in/yaml.v2 v2.2.6/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= +gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.0-20200605160147-a5ece683394c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= 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= diff --git a/openapi.yaml b/openapi.yaml index bc3290d2a81e0b125f200c331ba03cde7b2954f4..a2aa6bbfa209787ec975a934983bbefd61f24d03 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -16,7 +16,7 @@ paths: description: Returns the current root hash and size of the merkle tree used to store the log entries. operationId: getLogInfo tags: - - tLog + - tlog responses: 200: description: A JSON object with the root hash and tree size as properties @@ -31,7 +31,7 @@ paths: description: Returns a list of hashes for specified tree sizes that can be used to confirm the consistency of the transparency log operationId: getLogProof tags: - - tLog + - tlog parameters: - in: query name: firstSize @@ -377,4 +377,4 @@ responses: InternalServerError: description: There was an internal error in the server while processing the request schema: - $ref: "#/definitions/Error" \ No newline at end of file + $ref: "#/definitions/Error" diff --git a/pkg/api/api.go b/pkg/api/api.go index 9ab339406f1a998b45d32d7fbedac3f1dff5d1d5..e0979a46a326f6bf8109f06a1d0755f848db1b8a 100644 --- a/pkg/api/api.go +++ b/pkg/api/api.go @@ -336,6 +336,7 @@ func New() (*chi.Mux, error) { router.Post("/api/v1/latest", wrap(api.getLatestHandler)) router.Get("/api/v1/getleaf", wrap(api.getLeafByIndexHandler)) router.Get("/api/v1//ping", api.ping) + return router, nil } diff --git a/pkg/api/entries.go b/pkg/api/entries.go new file mode 100644 index 0000000000000000000000000000000000000000..401a66fd2384b0875f4f7f9c96a13dbb011429aa --- /dev/null +++ b/pkg/api/entries.go @@ -0,0 +1,70 @@ +/* +Copyright © 2020 Bob Callaway <bcallawa@redhat.com> + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +package api + +import ( + "encoding/hex" + "net/http" + + "github.com/projectrekor/rekor/pkg/log" + + "github.com/projectrekor/rekor/pkg/generated/models" + + "github.com/go-openapi/runtime/middleware" + "github.com/projectrekor/rekor/pkg/generated/restapi/operations/entries" +) + +func GetLogEntryByIndexHandler(params entries.GetLogEntryByIndexParams) middleware.Responder { + api, _ := NewAPI() + + server := serverInstance(api.logClient, api.tLogID) + resp, err := server.getLeafByIndex(api.tLogID, params.LogIndex) + log.RequestIDLogger(params.HTTPRequest).Infof("index requested :%v", params.LogIndex) + if err != nil { + return entries.NewGetLogEntryByIndexDefault(http.StatusInternalServerError).WithPayload(errorMsg("title", "type", err.Error(), http.StatusInternalServerError)) + } + + leaves := resp.getLeafByIndexResult.GetLeaves() + if len(leaves) > 1 { + return entries.NewGetLogEntryByIndexDefault(http.StatusInternalServerError).WithPayload(errorMsg("title", "type", err.Error(), http.StatusInternalServerError)) + } else if len(leaves) == 0 { + return entries.NewGetLogEntryByIndexNotFound() + } + + leaf := leaves[0] + logEntry := models.LogEntry{ + hex.EncodeToString(leaf.MerkleLeafHash): models.LogEntryAnon{ + LogIndex: &leaf.LeafIndex, + }, + } + return entries.NewGetLogEntryByIndexOK().WithPayload(logEntry) +} + +func CreateLogEntryHandler(params entries.CreateLogEntryParams) middleware.Responder { + return middleware.NotImplemented("operation entries.CreateLogEntry has not yet been implemented") +} + +func GetLogEntryByUUIDHandler(params entries.GetLogEntryByUUIDParams) middleware.Responder { + return middleware.NotImplemented("operation entries.GetLogEntryByUUID has not yet been implemented") +} + +func GetLogEntryProofHandler(params entries.GetLogEntryProofParams) middleware.Responder { + return middleware.NotImplemented("operation entries.GetLogEntryProof has not yet been implemented") +} + +func SearchLogQueryHandler(params entries.SearchLogQueryParams) middleware.Responder { + return middleware.NotImplemented("operation entries.SearchLogQuery has not yet been implemented") +} diff --git a/pkg/api/error.go b/pkg/api/error.go new file mode 100644 index 0000000000000000000000000000000000000000..f620aeb1044772733b594c3813bcafbd3f343489 --- /dev/null +++ b/pkg/api/error.go @@ -0,0 +1,29 @@ +/* +Copyright © 2020 Bob Callaway <bcallawa@redhat.com> + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +package api + +import "github.com/projectrekor/rekor/pkg/generated/models" + +func errorMsg(Type, Title, Detail string, Code int) *models.Error { + i64Code := int64(Code) + errObj := models.Error{ + Type: &Type, + Title: &Title, + Status: &i64Code, + Detail: Detail, + } + return &errObj +} diff --git a/pkg/api/server.go b/pkg/api/server.go deleted file mode 100644 index a2850f16ffd10b89ae7e915e47b369de5eefc15a..0000000000000000000000000000000000000000 --- a/pkg/api/server.go +++ /dev/null @@ -1,72 +0,0 @@ -/* -Copyright © 2020 Luke Hinds <lhinds@redhat.com> - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package api - -import ( - "context" - "fmt" - "net/http" - "os" - "os/signal" - - "github.com/projectrekor/rekor/pkg/log" - "github.com/spf13/viper" -) - -// Server provides an http.Server. -type Server struct { - *http.Server -} - -// NewServer creates and configures an APIServer serving all application routes. -func NewServer() (*Server, error) { - api, err := New() - if err != nil { - return nil, err - } - - addr := fmt.Sprintf("%s:%d", - viper.GetString("rekor_server.address"), - viper.GetUint("rekor_server.port")) - - srv := http.Server{ - Addr: addr, - Handler: api, - } - - return &Server{&srv}, nil -} - -func (srv *Server) Start() { - log.Logger.Info("Starting server...") - go func() { - if err := srv.ListenAndServe(); err != http.ErrServerClosed { - panic(err) - } - }() - log.Logger.Infof("Listening on %s", srv.Addr) - - quit := make(chan os.Signal, 1) - signal.Notify(quit, os.Interrupt) - sig := <-quit - log.Logger.Info("Shutting down server... Reason:", sig) - - if err := srv.Shutdown(context.Background()); err != nil { - panic(err) - } - log.Logger.Info("Server gracefully stopped") -} diff --git a/pkg/api/tlog.go b/pkg/api/tlog.go new file mode 100644 index 0000000000000000000000000000000000000000..7916510bf4b079320db87085033d6fbf9aa5ae47 --- /dev/null +++ b/pkg/api/tlog.go @@ -0,0 +1,56 @@ +/* +Copyright © 2020 Bob Callaway <bcallawa@redhat.com> + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +package api + +import ( + "encoding/hex" + "net/http" + + "github.com/projectrekor/rekor/pkg/generated/models" + + "github.com/go-openapi/runtime/middleware" + ttypes "github.com/google/trillian/types" + "github.com/projectrekor/rekor/pkg/generated/restapi/operations/tlog" +) + +func GetLogInfoHandler(params tlog.GetLogInfoParams) middleware.Responder { + api, _ := NewAPI() + + server := serverInstance(api.logClient, api.tLogID) + + resp, err := server.getLatest(api.tLogID, 0) + if err != nil { + return tlog.NewGetLogInfoDefault(http.StatusInternalServerError).WithPayload(errorMsg("title", "type", err.Error(), http.StatusInternalServerError)) + } + + var root ttypes.LogRootV1 + if err := root.UnmarshalBinary(resp.getLatestResult.SignedLogRoot.LogRoot); err != nil { + return tlog.NewGetLogInfoDefault(http.StatusInternalServerError).WithPayload(errorMsg("title", "type", err.Error(), http.StatusInternalServerError)) + } + + hashString := hex.EncodeToString(root.RootHash) + treeSize := int64(root.TreeSize) + + logInfo := models.LogInfo{ + RootHash: &hashString, + TreeSize: &treeSize, + } + return tlog.NewGetLogInfoOK().WithPayload(&logInfo) +} + +func GetLogProofHandler(params tlog.GetLogProofParams) middleware.Responder { + return middleware.NotImplemented("getLogProof not yet implemented") +} diff --git a/pkg/generated/client/entries/create_log_entry_parameters.go b/pkg/generated/client/entries/create_log_entry_parameters.go new file mode 100644 index 0000000000000000000000000000000000000000..dbe53d5250385d99c1bd5439404e9b937f8bca12 --- /dev/null +++ b/pkg/generated/client/entries/create_log_entry_parameters.go @@ -0,0 +1,135 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package entries + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" + + "github.com/projectrekor/rekor/pkg/generated/models" +) + +// NewCreateLogEntryParams creates a new CreateLogEntryParams object +// with the default values initialized. +func NewCreateLogEntryParams() *CreateLogEntryParams { + var () + return &CreateLogEntryParams{ + + timeout: cr.DefaultTimeout, + } +} + +// NewCreateLogEntryParamsWithTimeout creates a new CreateLogEntryParams object +// with the default values initialized, and the ability to set a timeout on a request +func NewCreateLogEntryParamsWithTimeout(timeout time.Duration) *CreateLogEntryParams { + var () + return &CreateLogEntryParams{ + + timeout: timeout, + } +} + +// NewCreateLogEntryParamsWithContext creates a new CreateLogEntryParams object +// with the default values initialized, and the ability to set a context for a request +func NewCreateLogEntryParamsWithContext(ctx context.Context) *CreateLogEntryParams { + var () + return &CreateLogEntryParams{ + + Context: ctx, + } +} + +// NewCreateLogEntryParamsWithHTTPClient creates a new CreateLogEntryParams object +// with the default values initialized, and the ability to set a custom HTTPClient for a request +func NewCreateLogEntryParamsWithHTTPClient(client *http.Client) *CreateLogEntryParams { + var () + return &CreateLogEntryParams{ + HTTPClient: client, + } +} + +/*CreateLogEntryParams contains all the parameters to send to the API endpoint +for the create log entry operation typically these are written to a http.Request +*/ +type CreateLogEntryParams struct { + + /*ProposedEntry*/ + ProposedEntry *models.ProposedEntry + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithTimeout adds the timeout to the create log entry params +func (o *CreateLogEntryParams) WithTimeout(timeout time.Duration) *CreateLogEntryParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the create log entry params +func (o *CreateLogEntryParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the create log entry params +func (o *CreateLogEntryParams) WithContext(ctx context.Context) *CreateLogEntryParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the create log entry params +func (o *CreateLogEntryParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the create log entry params +func (o *CreateLogEntryParams) WithHTTPClient(client *http.Client) *CreateLogEntryParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the create log entry params +func (o *CreateLogEntryParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithProposedEntry adds the proposedEntry to the create log entry params +func (o *CreateLogEntryParams) WithProposedEntry(proposedEntry *models.ProposedEntry) *CreateLogEntryParams { + o.SetProposedEntry(proposedEntry) + return o +} + +// SetProposedEntry adds the proposedEntry to the create log entry params +func (o *CreateLogEntryParams) SetProposedEntry(proposedEntry *models.ProposedEntry) { + o.ProposedEntry = proposedEntry +} + +// WriteToRequest writes these params to a swagger request +func (o *CreateLogEntryParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + if o.ProposedEntry != nil { + if err := r.SetBodyParam(o.ProposedEntry); err != nil { + return err + } + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/pkg/generated/client/entries/create_log_entry_responses.go b/pkg/generated/client/entries/create_log_entry_responses.go new file mode 100644 index 0000000000000000000000000000000000000000..44b689b0989f2db47956fe349cac230be752157e --- /dev/null +++ b/pkg/generated/client/entries/create_log_entry_responses.go @@ -0,0 +1,167 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package entries + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/projectrekor/rekor/pkg/generated/models" +) + +// CreateLogEntryReader is a Reader for the CreateLogEntry structure. +type CreateLogEntryReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *CreateLogEntryReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 201: + result := NewCreateLogEntryCreated() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewCreateLogEntryBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + result := NewCreateLogEntryDefault(response.Code()) + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + if response.Code()/100 == 2 { + return result, nil + } + return nil, result + } +} + +// NewCreateLogEntryCreated creates a CreateLogEntryCreated with default headers values +func NewCreateLogEntryCreated() *CreateLogEntryCreated { + return &CreateLogEntryCreated{} +} + +/*CreateLogEntryCreated handles this case with default header values. + +Returns the entry created in the transparency log +*/ +type CreateLogEntryCreated struct { + /*URI location of log entry + */ + Location strfmt.URI + + Payload models.LogEntry +} + +func (o *CreateLogEntryCreated) Error() string { + return fmt.Sprintf("[POST /api/v1/log/entries][%d] createLogEntryCreated %+v", 201, o.Payload) +} + +func (o *CreateLogEntryCreated) GetPayload() models.LogEntry { + return o.Payload +} + +func (o *CreateLogEntryCreated) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // response header Location + + location, err := formats.Parse("uri", response.GetHeader("Location")) + if err != nil { + return errors.InvalidType("Location", "header", "strfmt.URI", response.GetHeader("Location")) + } + o.Location = *(location.(*strfmt.URI)) + + // response payload + if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewCreateLogEntryBadRequest creates a CreateLogEntryBadRequest with default headers values +func NewCreateLogEntryBadRequest() *CreateLogEntryBadRequest { + return &CreateLogEntryBadRequest{} +} + +/*CreateLogEntryBadRequest handles this case with default header values. + +The content supplied to the server was invalid +*/ +type CreateLogEntryBadRequest struct { + Payload *models.Error +} + +func (o *CreateLogEntryBadRequest) Error() string { + return fmt.Sprintf("[POST /api/v1/log/entries][%d] createLogEntryBadRequest %+v", 400, o.Payload) +} + +func (o *CreateLogEntryBadRequest) GetPayload() *models.Error { + return o.Payload +} + +func (o *CreateLogEntryBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewCreateLogEntryDefault creates a CreateLogEntryDefault with default headers values +func NewCreateLogEntryDefault(code int) *CreateLogEntryDefault { + return &CreateLogEntryDefault{ + _statusCode: code, + } +} + +/*CreateLogEntryDefault handles this case with default header values. + +There was an internal error in the server while processing the request +*/ +type CreateLogEntryDefault struct { + _statusCode int + + Payload *models.Error +} + +// Code gets the status code for the create log entry default response +func (o *CreateLogEntryDefault) Code() int { + return o._statusCode +} + +func (o *CreateLogEntryDefault) Error() string { + return fmt.Sprintf("[POST /api/v1/log/entries][%d] createLogEntry default %+v", o._statusCode, o.Payload) +} + +func (o *CreateLogEntryDefault) GetPayload() *models.Error { + return o.Payload +} + +func (o *CreateLogEntryDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/pkg/generated/client/entries/entries_client.go b/pkg/generated/client/entries/entries_client.go new file mode 100644 index 0000000000000000000000000000000000000000..e34df29b532be030546c0d4c5015956b89e6f754 --- /dev/null +++ b/pkg/generated/client/entries/entries_client.go @@ -0,0 +1,214 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package entries + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" +) + +// New creates a new entries API client. +func New(transport runtime.ClientTransport, formats strfmt.Registry) ClientService { + return &Client{transport: transport, formats: formats} +} + +/* +Client for entries API +*/ +type Client struct { + transport runtime.ClientTransport + formats strfmt.Registry +} + +// ClientService is the interface for Client methods +type ClientService interface { + CreateLogEntry(params *CreateLogEntryParams) (*CreateLogEntryCreated, error) + + GetLogEntryByIndex(params *GetLogEntryByIndexParams) (*GetLogEntryByIndexOK, error) + + GetLogEntryByUUID(params *GetLogEntryByUUIDParams) (*GetLogEntryByUUIDOK, error) + + GetLogEntryProof(params *GetLogEntryProofParams) (*GetLogEntryProofOK, error) + + SearchLogQuery(params *SearchLogQueryParams) (*SearchLogQueryOK, error) + + SetTransport(transport runtime.ClientTransport) +} + +/* + CreateLogEntry creates an entry in the transparency log + + Creates an entry in the transparency log for a detached signature, public key, and content. Items can be included in the request or fetched by the server when URLs are specified. + +*/ +func (a *Client) CreateLogEntry(params *CreateLogEntryParams) (*CreateLogEntryCreated, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewCreateLogEntryParams() + } + + result, err := a.transport.Submit(&runtime.ClientOperation{ + ID: "createLogEntry", + Method: "POST", + PathPattern: "/api/v1/log/entries", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &CreateLogEntryReader{formats: a.formats}, + Context: params.Context, + Client: params.HTTPClient, + }) + if err != nil { + return nil, err + } + success, ok := result.(*CreateLogEntryCreated) + if ok { + return success, nil + } + // unexpected success response + unexpectedSuccess := result.(*CreateLogEntryDefault) + return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code()) +} + +/* + GetLogEntryByIndex retrieves an entry from the transparency log if it exists by index +*/ +func (a *Client) GetLogEntryByIndex(params *GetLogEntryByIndexParams) (*GetLogEntryByIndexOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewGetLogEntryByIndexParams() + } + + result, err := a.transport.Submit(&runtime.ClientOperation{ + ID: "getLogEntryByIndex", + Method: "GET", + PathPattern: "/api/v1/log/entries", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &GetLogEntryByIndexReader{formats: a.formats}, + Context: params.Context, + Client: params.HTTPClient, + }) + if err != nil { + return nil, err + } + success, ok := result.(*GetLogEntryByIndexOK) + if ok { + return success, nil + } + // unexpected success response + unexpectedSuccess := result.(*GetLogEntryByIndexDefault) + return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code()) +} + +/* + GetLogEntryByUUID retrieves an entry from the transparency log if it exists by UUID +*/ +func (a *Client) GetLogEntryByUUID(params *GetLogEntryByUUIDParams) (*GetLogEntryByUUIDOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewGetLogEntryByUUIDParams() + } + + result, err := a.transport.Submit(&runtime.ClientOperation{ + ID: "getLogEntryByUUID", + Method: "GET", + PathPattern: "/api/v1/log/entries/{entryUUID}", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &GetLogEntryByUUIDReader{formats: a.formats}, + Context: params.Context, + Client: params.HTTPClient, + }) + if err != nil { + return nil, err + } + success, ok := result.(*GetLogEntryByUUIDOK) + if ok { + return success, nil + } + // unexpected success response + unexpectedSuccess := result.(*GetLogEntryByUUIDDefault) + return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code()) +} + +/* + GetLogEntryProof gets information required to generate an inclusion proof for a specified entry in the transparency log + + Returns root hash, tree size, and a list of hashes that can be used to calculate proof of an entry being included in the transparency log +*/ +func (a *Client) GetLogEntryProof(params *GetLogEntryProofParams) (*GetLogEntryProofOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewGetLogEntryProofParams() + } + + result, err := a.transport.Submit(&runtime.ClientOperation{ + ID: "getLogEntryProof", + Method: "GET", + PathPattern: "/api/v1/log/entries/{entryUUID}/proof", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &GetLogEntryProofReader{formats: a.formats}, + Context: params.Context, + Client: params.HTTPClient, + }) + if err != nil { + return nil, err + } + success, ok := result.(*GetLogEntryProofOK) + if ok { + return success, nil + } + // unexpected success response + unexpectedSuccess := result.(*GetLogEntryProofDefault) + return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code()) +} + +/* + SearchLogQuery searches transparency log for one or more log entries +*/ +func (a *Client) SearchLogQuery(params *SearchLogQueryParams) (*SearchLogQueryOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewSearchLogQueryParams() + } + + result, err := a.transport.Submit(&runtime.ClientOperation{ + ID: "searchLogQuery", + Method: "POST", + PathPattern: "/api/v1/log/entries/retrieve", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &SearchLogQueryReader{formats: a.formats}, + Context: params.Context, + Client: params.HTTPClient, + }) + if err != nil { + return nil, err + } + success, ok := result.(*SearchLogQueryOK) + if ok { + return success, nil + } + // unexpected success response + unexpectedSuccess := result.(*SearchLogQueryDefault) + return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code()) +} + +// SetTransport changes the transport on the client +func (a *Client) SetTransport(transport runtime.ClientTransport) { + a.transport = transport +} diff --git a/pkg/generated/client/entries/get_log_entry_by_index_parameters.go b/pkg/generated/client/entries/get_log_entry_by_index_parameters.go new file mode 100644 index 0000000000000000000000000000000000000000..1fca34e25506a60a9d2f06e1029fd55a4929098e --- /dev/null +++ b/pkg/generated/client/entries/get_log_entry_by_index_parameters.go @@ -0,0 +1,140 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package entries + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewGetLogEntryByIndexParams creates a new GetLogEntryByIndexParams object +// with the default values initialized. +func NewGetLogEntryByIndexParams() *GetLogEntryByIndexParams { + var () + return &GetLogEntryByIndexParams{ + + timeout: cr.DefaultTimeout, + } +} + +// NewGetLogEntryByIndexParamsWithTimeout creates a new GetLogEntryByIndexParams object +// with the default values initialized, and the ability to set a timeout on a request +func NewGetLogEntryByIndexParamsWithTimeout(timeout time.Duration) *GetLogEntryByIndexParams { + var () + return &GetLogEntryByIndexParams{ + + timeout: timeout, + } +} + +// NewGetLogEntryByIndexParamsWithContext creates a new GetLogEntryByIndexParams object +// with the default values initialized, and the ability to set a context for a request +func NewGetLogEntryByIndexParamsWithContext(ctx context.Context) *GetLogEntryByIndexParams { + var () + return &GetLogEntryByIndexParams{ + + Context: ctx, + } +} + +// NewGetLogEntryByIndexParamsWithHTTPClient creates a new GetLogEntryByIndexParams object +// with the default values initialized, and the ability to set a custom HTTPClient for a request +func NewGetLogEntryByIndexParamsWithHTTPClient(client *http.Client) *GetLogEntryByIndexParams { + var () + return &GetLogEntryByIndexParams{ + HTTPClient: client, + } +} + +/*GetLogEntryByIndexParams contains all the parameters to send to the API endpoint +for the get log entry by index operation typically these are written to a http.Request +*/ +type GetLogEntryByIndexParams struct { + + /*LogIndex + specifies the index of the entry in the transparency log to be retrieved + + */ + LogIndex int64 + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithTimeout adds the timeout to the get log entry by index params +func (o *GetLogEntryByIndexParams) WithTimeout(timeout time.Duration) *GetLogEntryByIndexParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the get log entry by index params +func (o *GetLogEntryByIndexParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the get log entry by index params +func (o *GetLogEntryByIndexParams) WithContext(ctx context.Context) *GetLogEntryByIndexParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the get log entry by index params +func (o *GetLogEntryByIndexParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the get log entry by index params +func (o *GetLogEntryByIndexParams) WithHTTPClient(client *http.Client) *GetLogEntryByIndexParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the get log entry by index params +func (o *GetLogEntryByIndexParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithLogIndex adds the logIndex to the get log entry by index params +func (o *GetLogEntryByIndexParams) WithLogIndex(logIndex int64) *GetLogEntryByIndexParams { + o.SetLogIndex(logIndex) + return o +} + +// SetLogIndex adds the logIndex to the get log entry by index params +func (o *GetLogEntryByIndexParams) SetLogIndex(logIndex int64) { + o.LogIndex = logIndex +} + +// WriteToRequest writes these params to a swagger request +func (o *GetLogEntryByIndexParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + // query param logIndex + qrLogIndex := o.LogIndex + qLogIndex := swag.FormatInt64(qrLogIndex) + if qLogIndex != "" { + if err := r.SetQueryParam("logIndex", qLogIndex); err != nil { + return err + } + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/pkg/generated/client/entries/get_log_entry_by_index_responses.go b/pkg/generated/client/entries/get_log_entry_by_index_responses.go new file mode 100644 index 0000000000000000000000000000000000000000..0f1171917332c943a6ccbd614272386243582e53 --- /dev/null +++ b/pkg/generated/client/entries/get_log_entry_by_index_responses.go @@ -0,0 +1,154 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package entries + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/projectrekor/rekor/pkg/generated/models" +) + +// GetLogEntryByIndexReader is a Reader for the GetLogEntryByIndex structure. +type GetLogEntryByIndexReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *GetLogEntryByIndexReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewGetLogEntryByIndexOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 404: + result := NewGetLogEntryByIndexNotFound() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + result := NewGetLogEntryByIndexDefault(response.Code()) + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + if response.Code()/100 == 2 { + return result, nil + } + return nil, result + } +} + +// NewGetLogEntryByIndexOK creates a GetLogEntryByIndexOK with default headers values +func NewGetLogEntryByIndexOK() *GetLogEntryByIndexOK { + return &GetLogEntryByIndexOK{} +} + +/*GetLogEntryByIndexOK handles this case with default header values. + +the entry in the transparency log requested +*/ +type GetLogEntryByIndexOK struct { + Payload models.LogEntry +} + +func (o *GetLogEntryByIndexOK) Error() string { + return fmt.Sprintf("[GET /api/v1/log/entries][%d] getLogEntryByIndexOK %+v", 200, o.Payload) +} + +func (o *GetLogEntryByIndexOK) GetPayload() models.LogEntry { + return o.Payload +} + +func (o *GetLogEntryByIndexOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // response payload + if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewGetLogEntryByIndexNotFound creates a GetLogEntryByIndexNotFound with default headers values +func NewGetLogEntryByIndexNotFound() *GetLogEntryByIndexNotFound { + return &GetLogEntryByIndexNotFound{} +} + +/*GetLogEntryByIndexNotFound handles this case with default header values. + +The content requested could not be found +*/ +type GetLogEntryByIndexNotFound struct { + Payload *models.Error +} + +func (o *GetLogEntryByIndexNotFound) Error() string { + return fmt.Sprintf("[GET /api/v1/log/entries][%d] getLogEntryByIndexNotFound %+v", 404, o.Payload) +} + +func (o *GetLogEntryByIndexNotFound) GetPayload() *models.Error { + return o.Payload +} + +func (o *GetLogEntryByIndexNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewGetLogEntryByIndexDefault creates a GetLogEntryByIndexDefault with default headers values +func NewGetLogEntryByIndexDefault(code int) *GetLogEntryByIndexDefault { + return &GetLogEntryByIndexDefault{ + _statusCode: code, + } +} + +/*GetLogEntryByIndexDefault handles this case with default header values. + +There was an internal error in the server while processing the request +*/ +type GetLogEntryByIndexDefault struct { + _statusCode int + + Payload *models.Error +} + +// Code gets the status code for the get log entry by index default response +func (o *GetLogEntryByIndexDefault) Code() int { + return o._statusCode +} + +func (o *GetLogEntryByIndexDefault) Error() string { + return fmt.Sprintf("[GET /api/v1/log/entries][%d] getLogEntryByIndex default %+v", o._statusCode, o.Payload) +} + +func (o *GetLogEntryByIndexDefault) GetPayload() *models.Error { + return o.Payload +} + +func (o *GetLogEntryByIndexDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/pkg/generated/client/entries/get_log_entry_by_uuid_parameters.go b/pkg/generated/client/entries/get_log_entry_by_uuid_parameters.go new file mode 100644 index 0000000000000000000000000000000000000000..995d8963a96c224398bfdc62be4425d88a1ca008 --- /dev/null +++ b/pkg/generated/client/entries/get_log_entry_by_uuid_parameters.go @@ -0,0 +1,135 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package entries + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" +) + +// NewGetLogEntryByUUIDParams creates a new GetLogEntryByUUIDParams object +// with the default values initialized. +func NewGetLogEntryByUUIDParams() *GetLogEntryByUUIDParams { + var () + return &GetLogEntryByUUIDParams{ + + timeout: cr.DefaultTimeout, + } +} + +// NewGetLogEntryByUUIDParamsWithTimeout creates a new GetLogEntryByUUIDParams object +// with the default values initialized, and the ability to set a timeout on a request +func NewGetLogEntryByUUIDParamsWithTimeout(timeout time.Duration) *GetLogEntryByUUIDParams { + var () + return &GetLogEntryByUUIDParams{ + + timeout: timeout, + } +} + +// NewGetLogEntryByUUIDParamsWithContext creates a new GetLogEntryByUUIDParams object +// with the default values initialized, and the ability to set a context for a request +func NewGetLogEntryByUUIDParamsWithContext(ctx context.Context) *GetLogEntryByUUIDParams { + var () + return &GetLogEntryByUUIDParams{ + + Context: ctx, + } +} + +// NewGetLogEntryByUUIDParamsWithHTTPClient creates a new GetLogEntryByUUIDParams object +// with the default values initialized, and the ability to set a custom HTTPClient for a request +func NewGetLogEntryByUUIDParamsWithHTTPClient(client *http.Client) *GetLogEntryByUUIDParams { + var () + return &GetLogEntryByUUIDParams{ + HTTPClient: client, + } +} + +/*GetLogEntryByUUIDParams contains all the parameters to send to the API endpoint +for the get log entry by UUID operation typically these are written to a http.Request +*/ +type GetLogEntryByUUIDParams struct { + + /*EntryUUID + the UUID of the entry to be retrieved from the log. The UUID is also the merkle tree hash of the entry. + + */ + EntryUUID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithTimeout adds the timeout to the get log entry by UUID params +func (o *GetLogEntryByUUIDParams) WithTimeout(timeout time.Duration) *GetLogEntryByUUIDParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the get log entry by UUID params +func (o *GetLogEntryByUUIDParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the get log entry by UUID params +func (o *GetLogEntryByUUIDParams) WithContext(ctx context.Context) *GetLogEntryByUUIDParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the get log entry by UUID params +func (o *GetLogEntryByUUIDParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the get log entry by UUID params +func (o *GetLogEntryByUUIDParams) WithHTTPClient(client *http.Client) *GetLogEntryByUUIDParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the get log entry by UUID params +func (o *GetLogEntryByUUIDParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithEntryUUID adds the entryUUID to the get log entry by UUID params +func (o *GetLogEntryByUUIDParams) WithEntryUUID(entryUUID string) *GetLogEntryByUUIDParams { + o.SetEntryUUID(entryUUID) + return o +} + +// SetEntryUUID adds the entryUuid to the get log entry by UUID params +func (o *GetLogEntryByUUIDParams) SetEntryUUID(entryUUID string) { + o.EntryUUID = entryUUID +} + +// WriteToRequest writes these params to a swagger request +func (o *GetLogEntryByUUIDParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + // path param entryUUID + if err := r.SetPathParam("entryUUID", o.EntryUUID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/pkg/generated/client/entries/get_log_entry_by_uuid_responses.go b/pkg/generated/client/entries/get_log_entry_by_uuid_responses.go new file mode 100644 index 0000000000000000000000000000000000000000..fc70d606babf8c6bc191aedfdb6a731f2f1adaee --- /dev/null +++ b/pkg/generated/client/entries/get_log_entry_by_uuid_responses.go @@ -0,0 +1,154 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package entries + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/projectrekor/rekor/pkg/generated/models" +) + +// GetLogEntryByUUIDReader is a Reader for the GetLogEntryByUUID structure. +type GetLogEntryByUUIDReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *GetLogEntryByUUIDReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewGetLogEntryByUUIDOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 404: + result := NewGetLogEntryByUUIDNotFound() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + result := NewGetLogEntryByUUIDDefault(response.Code()) + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + if response.Code()/100 == 2 { + return result, nil + } + return nil, result + } +} + +// NewGetLogEntryByUUIDOK creates a GetLogEntryByUUIDOK with default headers values +func NewGetLogEntryByUUIDOK() *GetLogEntryByUUIDOK { + return &GetLogEntryByUUIDOK{} +} + +/*GetLogEntryByUUIDOK handles this case with default header values. + +the entry in the transparency log requested +*/ +type GetLogEntryByUUIDOK struct { + Payload models.LogEntry +} + +func (o *GetLogEntryByUUIDOK) Error() string { + return fmt.Sprintf("[GET /api/v1/log/entries/{entryUUID}][%d] getLogEntryByUuidOK %+v", 200, o.Payload) +} + +func (o *GetLogEntryByUUIDOK) GetPayload() models.LogEntry { + return o.Payload +} + +func (o *GetLogEntryByUUIDOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // response payload + if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewGetLogEntryByUUIDNotFound creates a GetLogEntryByUUIDNotFound with default headers values +func NewGetLogEntryByUUIDNotFound() *GetLogEntryByUUIDNotFound { + return &GetLogEntryByUUIDNotFound{} +} + +/*GetLogEntryByUUIDNotFound handles this case with default header values. + +The content requested could not be found +*/ +type GetLogEntryByUUIDNotFound struct { + Payload *models.Error +} + +func (o *GetLogEntryByUUIDNotFound) Error() string { + return fmt.Sprintf("[GET /api/v1/log/entries/{entryUUID}][%d] getLogEntryByUuidNotFound %+v", 404, o.Payload) +} + +func (o *GetLogEntryByUUIDNotFound) GetPayload() *models.Error { + return o.Payload +} + +func (o *GetLogEntryByUUIDNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewGetLogEntryByUUIDDefault creates a GetLogEntryByUUIDDefault with default headers values +func NewGetLogEntryByUUIDDefault(code int) *GetLogEntryByUUIDDefault { + return &GetLogEntryByUUIDDefault{ + _statusCode: code, + } +} + +/*GetLogEntryByUUIDDefault handles this case with default header values. + +There was an internal error in the server while processing the request +*/ +type GetLogEntryByUUIDDefault struct { + _statusCode int + + Payload *models.Error +} + +// Code gets the status code for the get log entry by UUID default response +func (o *GetLogEntryByUUIDDefault) Code() int { + return o._statusCode +} + +func (o *GetLogEntryByUUIDDefault) Error() string { + return fmt.Sprintf("[GET /api/v1/log/entries/{entryUUID}][%d] getLogEntryByUUID default %+v", o._statusCode, o.Payload) +} + +func (o *GetLogEntryByUUIDDefault) GetPayload() *models.Error { + return o.Payload +} + +func (o *GetLogEntryByUUIDDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/pkg/generated/client/entries/get_log_entry_proof_parameters.go b/pkg/generated/client/entries/get_log_entry_proof_parameters.go new file mode 100644 index 0000000000000000000000000000000000000000..2fef4ed453a58679d9f974429a299a86300c0198 --- /dev/null +++ b/pkg/generated/client/entries/get_log_entry_proof_parameters.go @@ -0,0 +1,135 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package entries + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" +) + +// NewGetLogEntryProofParams creates a new GetLogEntryProofParams object +// with the default values initialized. +func NewGetLogEntryProofParams() *GetLogEntryProofParams { + var () + return &GetLogEntryProofParams{ + + timeout: cr.DefaultTimeout, + } +} + +// NewGetLogEntryProofParamsWithTimeout creates a new GetLogEntryProofParams object +// with the default values initialized, and the ability to set a timeout on a request +func NewGetLogEntryProofParamsWithTimeout(timeout time.Duration) *GetLogEntryProofParams { + var () + return &GetLogEntryProofParams{ + + timeout: timeout, + } +} + +// NewGetLogEntryProofParamsWithContext creates a new GetLogEntryProofParams object +// with the default values initialized, and the ability to set a context for a request +func NewGetLogEntryProofParamsWithContext(ctx context.Context) *GetLogEntryProofParams { + var () + return &GetLogEntryProofParams{ + + Context: ctx, + } +} + +// NewGetLogEntryProofParamsWithHTTPClient creates a new GetLogEntryProofParams object +// with the default values initialized, and the ability to set a custom HTTPClient for a request +func NewGetLogEntryProofParamsWithHTTPClient(client *http.Client) *GetLogEntryProofParams { + var () + return &GetLogEntryProofParams{ + HTTPClient: client, + } +} + +/*GetLogEntryProofParams contains all the parameters to send to the API endpoint +for the get log entry proof operation typically these are written to a http.Request +*/ +type GetLogEntryProofParams struct { + + /*EntryUUID + the UUID of the entry for which the inclusion proof information should be returned + + */ + EntryUUID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithTimeout adds the timeout to the get log entry proof params +func (o *GetLogEntryProofParams) WithTimeout(timeout time.Duration) *GetLogEntryProofParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the get log entry proof params +func (o *GetLogEntryProofParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the get log entry proof params +func (o *GetLogEntryProofParams) WithContext(ctx context.Context) *GetLogEntryProofParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the get log entry proof params +func (o *GetLogEntryProofParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the get log entry proof params +func (o *GetLogEntryProofParams) WithHTTPClient(client *http.Client) *GetLogEntryProofParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the get log entry proof params +func (o *GetLogEntryProofParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithEntryUUID adds the entryUUID to the get log entry proof params +func (o *GetLogEntryProofParams) WithEntryUUID(entryUUID string) *GetLogEntryProofParams { + o.SetEntryUUID(entryUUID) + return o +} + +// SetEntryUUID adds the entryUuid to the get log entry proof params +func (o *GetLogEntryProofParams) SetEntryUUID(entryUUID string) { + o.EntryUUID = entryUUID +} + +// WriteToRequest writes these params to a swagger request +func (o *GetLogEntryProofParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + // path param entryUUID + if err := r.SetPathParam("entryUUID", o.EntryUUID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/pkg/generated/client/entries/get_log_entry_proof_responses.go b/pkg/generated/client/entries/get_log_entry_proof_responses.go new file mode 100644 index 0000000000000000000000000000000000000000..ff21afd92d14a05e6bb172caf661a098bee4fb2b --- /dev/null +++ b/pkg/generated/client/entries/get_log_entry_proof_responses.go @@ -0,0 +1,156 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package entries + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/projectrekor/rekor/pkg/generated/models" +) + +// GetLogEntryProofReader is a Reader for the GetLogEntryProof structure. +type GetLogEntryProofReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *GetLogEntryProofReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewGetLogEntryProofOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 404: + result := NewGetLogEntryProofNotFound() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + result := NewGetLogEntryProofDefault(response.Code()) + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + if response.Code()/100 == 2 { + return result, nil + } + return nil, result + } +} + +// NewGetLogEntryProofOK creates a GetLogEntryProofOK with default headers values +func NewGetLogEntryProofOK() *GetLogEntryProofOK { + return &GetLogEntryProofOK{} +} + +/*GetLogEntryProofOK handles this case with default header values. + +Information needed for a client to compute the inclusion proof +*/ +type GetLogEntryProofOK struct { + Payload *models.InclusionProof +} + +func (o *GetLogEntryProofOK) Error() string { + return fmt.Sprintf("[GET /api/v1/log/entries/{entryUUID}/proof][%d] getLogEntryProofOK %+v", 200, o.Payload) +} + +func (o *GetLogEntryProofOK) GetPayload() *models.InclusionProof { + return o.Payload +} + +func (o *GetLogEntryProofOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.InclusionProof) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewGetLogEntryProofNotFound creates a GetLogEntryProofNotFound with default headers values +func NewGetLogEntryProofNotFound() *GetLogEntryProofNotFound { + return &GetLogEntryProofNotFound{} +} + +/*GetLogEntryProofNotFound handles this case with default header values. + +The content requested could not be found +*/ +type GetLogEntryProofNotFound struct { + Payload *models.Error +} + +func (o *GetLogEntryProofNotFound) Error() string { + return fmt.Sprintf("[GET /api/v1/log/entries/{entryUUID}/proof][%d] getLogEntryProofNotFound %+v", 404, o.Payload) +} + +func (o *GetLogEntryProofNotFound) GetPayload() *models.Error { + return o.Payload +} + +func (o *GetLogEntryProofNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewGetLogEntryProofDefault creates a GetLogEntryProofDefault with default headers values +func NewGetLogEntryProofDefault(code int) *GetLogEntryProofDefault { + return &GetLogEntryProofDefault{ + _statusCode: code, + } +} + +/*GetLogEntryProofDefault handles this case with default header values. + +There was an internal error in the server while processing the request +*/ +type GetLogEntryProofDefault struct { + _statusCode int + + Payload *models.Error +} + +// Code gets the status code for the get log entry proof default response +func (o *GetLogEntryProofDefault) Code() int { + return o._statusCode +} + +func (o *GetLogEntryProofDefault) Error() string { + return fmt.Sprintf("[GET /api/v1/log/entries/{entryUUID}/proof][%d] getLogEntryProof default %+v", o._statusCode, o.Payload) +} + +func (o *GetLogEntryProofDefault) GetPayload() *models.Error { + return o.Payload +} + +func (o *GetLogEntryProofDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/pkg/generated/client/entries/search_log_query_parameters.go b/pkg/generated/client/entries/search_log_query_parameters.go new file mode 100644 index 0000000000000000000000000000000000000000..69070851eb64aef360c4b14774c69079ce33daec --- /dev/null +++ b/pkg/generated/client/entries/search_log_query_parameters.go @@ -0,0 +1,135 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package entries + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" + + "github.com/projectrekor/rekor/pkg/generated/models" +) + +// NewSearchLogQueryParams creates a new SearchLogQueryParams object +// with the default values initialized. +func NewSearchLogQueryParams() *SearchLogQueryParams { + var () + return &SearchLogQueryParams{ + + timeout: cr.DefaultTimeout, + } +} + +// NewSearchLogQueryParamsWithTimeout creates a new SearchLogQueryParams object +// with the default values initialized, and the ability to set a timeout on a request +func NewSearchLogQueryParamsWithTimeout(timeout time.Duration) *SearchLogQueryParams { + var () + return &SearchLogQueryParams{ + + timeout: timeout, + } +} + +// NewSearchLogQueryParamsWithContext creates a new SearchLogQueryParams object +// with the default values initialized, and the ability to set a context for a request +func NewSearchLogQueryParamsWithContext(ctx context.Context) *SearchLogQueryParams { + var () + return &SearchLogQueryParams{ + + Context: ctx, + } +} + +// NewSearchLogQueryParamsWithHTTPClient creates a new SearchLogQueryParams object +// with the default values initialized, and the ability to set a custom HTTPClient for a request +func NewSearchLogQueryParamsWithHTTPClient(client *http.Client) *SearchLogQueryParams { + var () + return &SearchLogQueryParams{ + HTTPClient: client, + } +} + +/*SearchLogQueryParams contains all the parameters to send to the API endpoint +for the search log query operation typically these are written to a http.Request +*/ +type SearchLogQueryParams struct { + + /*Entry*/ + Entry *models.SearchLogQuery + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithTimeout adds the timeout to the search log query params +func (o *SearchLogQueryParams) WithTimeout(timeout time.Duration) *SearchLogQueryParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the search log query params +func (o *SearchLogQueryParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the search log query params +func (o *SearchLogQueryParams) WithContext(ctx context.Context) *SearchLogQueryParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the search log query params +func (o *SearchLogQueryParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the search log query params +func (o *SearchLogQueryParams) WithHTTPClient(client *http.Client) *SearchLogQueryParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the search log query params +func (o *SearchLogQueryParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithEntry adds the entry to the search log query params +func (o *SearchLogQueryParams) WithEntry(entry *models.SearchLogQuery) *SearchLogQueryParams { + o.SetEntry(entry) + return o +} + +// SetEntry adds the entry to the search log query params +func (o *SearchLogQueryParams) SetEntry(entry *models.SearchLogQuery) { + o.Entry = entry +} + +// WriteToRequest writes these params to a swagger request +func (o *SearchLogQueryParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + if o.Entry != nil { + if err := r.SetBodyParam(o.Entry); err != nil { + return err + } + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/pkg/generated/client/entries/search_log_query_responses.go b/pkg/generated/client/entries/search_log_query_responses.go new file mode 100644 index 0000000000000000000000000000000000000000..aad8d56a43d2147e20b1c0d7d9ba6217ecfd75ad --- /dev/null +++ b/pkg/generated/client/entries/search_log_query_responses.go @@ -0,0 +1,115 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package entries + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/projectrekor/rekor/pkg/generated/models" +) + +// SearchLogQueryReader is a Reader for the SearchLogQuery structure. +type SearchLogQueryReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *SearchLogQueryReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewSearchLogQueryOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + default: + result := NewSearchLogQueryDefault(response.Code()) + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + if response.Code()/100 == 2 { + return result, nil + } + return nil, result + } +} + +// NewSearchLogQueryOK creates a SearchLogQueryOK with default headers values +func NewSearchLogQueryOK() *SearchLogQueryOK { + return &SearchLogQueryOK{} +} + +/*SearchLogQueryOK handles this case with default header values. + +Returns zero or more entries from the transparency log, according to how many were included in request query +*/ +type SearchLogQueryOK struct { + Payload []models.LogEntry +} + +func (o *SearchLogQueryOK) Error() string { + return fmt.Sprintf("[POST /api/v1/log/entries/retrieve][%d] searchLogQueryOK %+v", 200, o.Payload) +} + +func (o *SearchLogQueryOK) GetPayload() []models.LogEntry { + return o.Payload +} + +func (o *SearchLogQueryOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // response payload + if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewSearchLogQueryDefault creates a SearchLogQueryDefault with default headers values +func NewSearchLogQueryDefault(code int) *SearchLogQueryDefault { + return &SearchLogQueryDefault{ + _statusCode: code, + } +} + +/*SearchLogQueryDefault handles this case with default header values. + +There was an internal error in the server while processing the request +*/ +type SearchLogQueryDefault struct { + _statusCode int + + Payload *models.Error +} + +// Code gets the status code for the search log query default response +func (o *SearchLogQueryDefault) Code() int { + return o._statusCode +} + +func (o *SearchLogQueryDefault) Error() string { + return fmt.Sprintf("[POST /api/v1/log/entries/retrieve][%d] searchLogQuery default %+v", o._statusCode, o.Payload) +} + +func (o *SearchLogQueryDefault) GetPayload() *models.Error { + return o.Payload +} + +func (o *SearchLogQueryDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/pkg/generated/client/rekor_client.go b/pkg/generated/client/rekor_client.go new file mode 100644 index 0000000000000000000000000000000000000000..3174b295f0675201f22b4e1a4eea44f4af83fdeb --- /dev/null +++ b/pkg/generated/client/rekor_client.go @@ -0,0 +1,117 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package client + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/runtime" + httptransport "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" + + "github.com/projectrekor/rekor/pkg/generated/client/entries" + "github.com/projectrekor/rekor/pkg/generated/client/tlog" +) + +// Default rekor HTTP client. +var Default = NewHTTPClient(nil) + +const ( + // DefaultHost is the default Host + // found in Meta (info) section of spec file + DefaultHost string = "localhost" + // DefaultBasePath is the default BasePath + // found in Meta (info) section of spec file + DefaultBasePath string = "/" +) + +// DefaultSchemes are the default schemes found in Meta (info) section of spec file +var DefaultSchemes = []string{"http"} + +// NewHTTPClient creates a new rekor HTTP client. +func NewHTTPClient(formats strfmt.Registry) *Rekor { + return NewHTTPClientWithConfig(formats, nil) +} + +// NewHTTPClientWithConfig creates a new rekor HTTP client, +// using a customizable transport config. +func NewHTTPClientWithConfig(formats strfmt.Registry, cfg *TransportConfig) *Rekor { + // ensure nullable parameters have default + if cfg == nil { + cfg = DefaultTransportConfig() + } + + // create transport and client + transport := httptransport.New(cfg.Host, cfg.BasePath, cfg.Schemes) + return New(transport, formats) +} + +// New creates a new rekor client +func New(transport runtime.ClientTransport, formats strfmt.Registry) *Rekor { + // ensure nullable parameters have default + if formats == nil { + formats = strfmt.Default + } + + cli := new(Rekor) + cli.Transport = transport + cli.Entries = entries.New(transport, formats) + cli.Tlog = tlog.New(transport, formats) + return cli +} + +// DefaultTransportConfig creates a TransportConfig with the +// default settings taken from the meta section of the spec file. +func DefaultTransportConfig() *TransportConfig { + return &TransportConfig{ + Host: DefaultHost, + BasePath: DefaultBasePath, + Schemes: DefaultSchemes, + } +} + +// TransportConfig contains the transport related info, +// found in the meta section of the spec file. +type TransportConfig struct { + Host string + BasePath string + Schemes []string +} + +// WithHost overrides the default host, +// provided by the meta section of the spec file. +func (cfg *TransportConfig) WithHost(host string) *TransportConfig { + cfg.Host = host + return cfg +} + +// WithBasePath overrides the default basePath, +// provided by the meta section of the spec file. +func (cfg *TransportConfig) WithBasePath(basePath string) *TransportConfig { + cfg.BasePath = basePath + return cfg +} + +// WithSchemes overrides the default schemes, +// provided by the meta section of the spec file. +func (cfg *TransportConfig) WithSchemes(schemes []string) *TransportConfig { + cfg.Schemes = schemes + return cfg +} + +// Rekor is a client for rekor +type Rekor struct { + Entries entries.ClientService + + Tlog tlog.ClientService + + Transport runtime.ClientTransport +} + +// SetTransport changes the transport on the client and all its subresources +func (c *Rekor) SetTransport(transport runtime.ClientTransport) { + c.Transport = transport + c.Entries.SetTransport(transport) + c.Tlog.SetTransport(transport) +} diff --git a/pkg/generated/client/tlog/get_log_info_parameters.go b/pkg/generated/client/tlog/get_log_info_parameters.go new file mode 100644 index 0000000000000000000000000000000000000000..e9fdc8e8f04660e8e8203ace8140515f3fbddd07 --- /dev/null +++ b/pkg/generated/client/tlog/get_log_info_parameters.go @@ -0,0 +1,112 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package tlog + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" +) + +// NewGetLogInfoParams creates a new GetLogInfoParams object +// with the default values initialized. +func NewGetLogInfoParams() *GetLogInfoParams { + + return &GetLogInfoParams{ + + timeout: cr.DefaultTimeout, + } +} + +// NewGetLogInfoParamsWithTimeout creates a new GetLogInfoParams object +// with the default values initialized, and the ability to set a timeout on a request +func NewGetLogInfoParamsWithTimeout(timeout time.Duration) *GetLogInfoParams { + + return &GetLogInfoParams{ + + timeout: timeout, + } +} + +// NewGetLogInfoParamsWithContext creates a new GetLogInfoParams object +// with the default values initialized, and the ability to set a context for a request +func NewGetLogInfoParamsWithContext(ctx context.Context) *GetLogInfoParams { + + return &GetLogInfoParams{ + + Context: ctx, + } +} + +// NewGetLogInfoParamsWithHTTPClient creates a new GetLogInfoParams object +// with the default values initialized, and the ability to set a custom HTTPClient for a request +func NewGetLogInfoParamsWithHTTPClient(client *http.Client) *GetLogInfoParams { + + return &GetLogInfoParams{ + HTTPClient: client, + } +} + +/*GetLogInfoParams contains all the parameters to send to the API endpoint +for the get log info operation typically these are written to a http.Request +*/ +type GetLogInfoParams struct { + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithTimeout adds the timeout to the get log info params +func (o *GetLogInfoParams) WithTimeout(timeout time.Duration) *GetLogInfoParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the get log info params +func (o *GetLogInfoParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the get log info params +func (o *GetLogInfoParams) WithContext(ctx context.Context) *GetLogInfoParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the get log info params +func (o *GetLogInfoParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the get log info params +func (o *GetLogInfoParams) WithHTTPClient(client *http.Client) *GetLogInfoParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the get log info params +func (o *GetLogInfoParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WriteToRequest writes these params to a swagger request +func (o *GetLogInfoParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/pkg/generated/client/tlog/get_log_info_responses.go b/pkg/generated/client/tlog/get_log_info_responses.go new file mode 100644 index 0000000000000000000000000000000000000000..ecb0821e53eb60fff63cbf074f3bcec0e00c55b7 --- /dev/null +++ b/pkg/generated/client/tlog/get_log_info_responses.go @@ -0,0 +1,117 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package tlog + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/projectrekor/rekor/pkg/generated/models" +) + +// GetLogInfoReader is a Reader for the GetLogInfo structure. +type GetLogInfoReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *GetLogInfoReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewGetLogInfoOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + default: + result := NewGetLogInfoDefault(response.Code()) + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + if response.Code()/100 == 2 { + return result, nil + } + return nil, result + } +} + +// NewGetLogInfoOK creates a GetLogInfoOK with default headers values +func NewGetLogInfoOK() *GetLogInfoOK { + return &GetLogInfoOK{} +} + +/*GetLogInfoOK handles this case with default header values. + +A JSON object with the root hash and tree size as properties +*/ +type GetLogInfoOK struct { + Payload *models.LogInfo +} + +func (o *GetLogInfoOK) Error() string { + return fmt.Sprintf("[GET /api/v1/log][%d] getLogInfoOK %+v", 200, o.Payload) +} + +func (o *GetLogInfoOK) GetPayload() *models.LogInfo { + return o.Payload +} + +func (o *GetLogInfoOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.LogInfo) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewGetLogInfoDefault creates a GetLogInfoDefault with default headers values +func NewGetLogInfoDefault(code int) *GetLogInfoDefault { + return &GetLogInfoDefault{ + _statusCode: code, + } +} + +/*GetLogInfoDefault handles this case with default header values. + +There was an internal error in the server while processing the request +*/ +type GetLogInfoDefault struct { + _statusCode int + + Payload *models.Error +} + +// Code gets the status code for the get log info default response +func (o *GetLogInfoDefault) Code() int { + return o._statusCode +} + +func (o *GetLogInfoDefault) Error() string { + return fmt.Sprintf("[GET /api/v1/log][%d] getLogInfo default %+v", o._statusCode, o.Payload) +} + +func (o *GetLogInfoDefault) GetPayload() *models.Error { + return o.Payload +} + +func (o *GetLogInfoDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/pkg/generated/client/tlog/get_log_proof_parameters.go b/pkg/generated/client/tlog/get_log_proof_parameters.go new file mode 100644 index 0000000000000000000000000000000000000000..4e97a443bf81892958c7aa369de56fc16d84a670 --- /dev/null +++ b/pkg/generated/client/tlog/get_log_proof_parameters.go @@ -0,0 +1,185 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package tlog + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewGetLogProofParams creates a new GetLogProofParams object +// with the default values initialized. +func NewGetLogProofParams() *GetLogProofParams { + var ( + firstSizeDefault = int64(0) + ) + return &GetLogProofParams{ + FirstSize: &firstSizeDefault, + + timeout: cr.DefaultTimeout, + } +} + +// NewGetLogProofParamsWithTimeout creates a new GetLogProofParams object +// with the default values initialized, and the ability to set a timeout on a request +func NewGetLogProofParamsWithTimeout(timeout time.Duration) *GetLogProofParams { + var ( + firstSizeDefault = int64(0) + ) + return &GetLogProofParams{ + FirstSize: &firstSizeDefault, + + timeout: timeout, + } +} + +// NewGetLogProofParamsWithContext creates a new GetLogProofParams object +// with the default values initialized, and the ability to set a context for a request +func NewGetLogProofParamsWithContext(ctx context.Context) *GetLogProofParams { + var ( + firstSizeDefault = int64(0) + ) + return &GetLogProofParams{ + FirstSize: &firstSizeDefault, + + Context: ctx, + } +} + +// NewGetLogProofParamsWithHTTPClient creates a new GetLogProofParams object +// with the default values initialized, and the ability to set a custom HTTPClient for a request +func NewGetLogProofParamsWithHTTPClient(client *http.Client) *GetLogProofParams { + var ( + firstSizeDefault = int64(0) + ) + return &GetLogProofParams{ + FirstSize: &firstSizeDefault, + HTTPClient: client, + } +} + +/*GetLogProofParams contains all the parameters to send to the API endpoint +for the get log proof operation typically these are written to a http.Request +*/ +type GetLogProofParams struct { + + /*FirstSize + The size of the tree that you wish to prove consistency from (0 means the beginning of the log) Defaults to 0 if not specified + + + */ + FirstSize *int64 + /*LastSize + The size of the tree that you wish to prove consistency to + + */ + LastSize int64 + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithTimeout adds the timeout to the get log proof params +func (o *GetLogProofParams) WithTimeout(timeout time.Duration) *GetLogProofParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the get log proof params +func (o *GetLogProofParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the get log proof params +func (o *GetLogProofParams) WithContext(ctx context.Context) *GetLogProofParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the get log proof params +func (o *GetLogProofParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the get log proof params +func (o *GetLogProofParams) WithHTTPClient(client *http.Client) *GetLogProofParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the get log proof params +func (o *GetLogProofParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithFirstSize adds the firstSize to the get log proof params +func (o *GetLogProofParams) WithFirstSize(firstSize *int64) *GetLogProofParams { + o.SetFirstSize(firstSize) + return o +} + +// SetFirstSize adds the firstSize to the get log proof params +func (o *GetLogProofParams) SetFirstSize(firstSize *int64) { + o.FirstSize = firstSize +} + +// WithLastSize adds the lastSize to the get log proof params +func (o *GetLogProofParams) WithLastSize(lastSize int64) *GetLogProofParams { + o.SetLastSize(lastSize) + return o +} + +// SetLastSize adds the lastSize to the get log proof params +func (o *GetLogProofParams) SetLastSize(lastSize int64) { + o.LastSize = lastSize +} + +// WriteToRequest writes these params to a swagger request +func (o *GetLogProofParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + if o.FirstSize != nil { + + // query param firstSize + var qrFirstSize int64 + if o.FirstSize != nil { + qrFirstSize = *o.FirstSize + } + qFirstSize := swag.FormatInt64(qrFirstSize) + if qFirstSize != "" { + if err := r.SetQueryParam("firstSize", qFirstSize); err != nil { + return err + } + } + + } + + // query param lastSize + qrLastSize := o.LastSize + qLastSize := swag.FormatInt64(qrLastSize) + if qLastSize != "" { + if err := r.SetQueryParam("lastSize", qLastSize); err != nil { + return err + } + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/pkg/generated/client/tlog/get_log_proof_responses.go b/pkg/generated/client/tlog/get_log_proof_responses.go new file mode 100644 index 0000000000000000000000000000000000000000..d99b1d82e1ce9ebfebbe52f8e4ba552a0633e4ea --- /dev/null +++ b/pkg/generated/client/tlog/get_log_proof_responses.go @@ -0,0 +1,117 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package tlog + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/projectrekor/rekor/pkg/generated/models" +) + +// GetLogProofReader is a Reader for the GetLogProof structure. +type GetLogProofReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *GetLogProofReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewGetLogProofOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + default: + result := NewGetLogProofDefault(response.Code()) + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + if response.Code()/100 == 2 { + return result, nil + } + return nil, result + } +} + +// NewGetLogProofOK creates a GetLogProofOK with default headers values +func NewGetLogProofOK() *GetLogProofOK { + return &GetLogProofOK{} +} + +/*GetLogProofOK handles this case with default header values. + +All hashes required to compute the consistency proof +*/ +type GetLogProofOK struct { + Payload *models.ConsistencyProof +} + +func (o *GetLogProofOK) Error() string { + return fmt.Sprintf("[GET /api/v1/log/proof][%d] getLogProofOK %+v", 200, o.Payload) +} + +func (o *GetLogProofOK) GetPayload() *models.ConsistencyProof { + return o.Payload +} + +func (o *GetLogProofOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.ConsistencyProof) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewGetLogProofDefault creates a GetLogProofDefault with default headers values +func NewGetLogProofDefault(code int) *GetLogProofDefault { + return &GetLogProofDefault{ + _statusCode: code, + } +} + +/*GetLogProofDefault handles this case with default header values. + +There was an internal error in the server while processing the request +*/ +type GetLogProofDefault struct { + _statusCode int + + Payload *models.Error +} + +// Code gets the status code for the get log proof default response +func (o *GetLogProofDefault) Code() int { + return o._statusCode +} + +func (o *GetLogProofDefault) Error() string { + return fmt.Sprintf("[GET /api/v1/log/proof][%d] getLogProof default %+v", o._statusCode, o.Payload) +} + +func (o *GetLogProofDefault) GetPayload() *models.Error { + return o.Payload +} + +func (o *GetLogProofDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/pkg/generated/client/tlog/tlog_client.go b/pkg/generated/client/tlog/tlog_client.go new file mode 100644 index 0000000000000000000000000000000000000000..d542788059ed2f2e4d11f4c403b5d00057f5ebdb --- /dev/null +++ b/pkg/generated/client/tlog/tlog_client.go @@ -0,0 +1,108 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package tlog + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" +) + +// New creates a new tlog API client. +func New(transport runtime.ClientTransport, formats strfmt.Registry) ClientService { + return &Client{transport: transport, formats: formats} +} + +/* +Client for tlog API +*/ +type Client struct { + transport runtime.ClientTransport + formats strfmt.Registry +} + +// ClientService is the interface for Client methods +type ClientService interface { + GetLogInfo(params *GetLogInfoParams) (*GetLogInfoOK, error) + + GetLogProof(params *GetLogProofParams) (*GetLogProofOK, error) + + SetTransport(transport runtime.ClientTransport) +} + +/* + GetLogInfo gets information about the current state of the transparency log + + Returns the current root hash and size of the merkle tree used to store the log entries. +*/ +func (a *Client) GetLogInfo(params *GetLogInfoParams) (*GetLogInfoOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewGetLogInfoParams() + } + + result, err := a.transport.Submit(&runtime.ClientOperation{ + ID: "getLogInfo", + Method: "GET", + PathPattern: "/api/v1/log", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &GetLogInfoReader{formats: a.formats}, + Context: params.Context, + Client: params.HTTPClient, + }) + if err != nil { + return nil, err + } + success, ok := result.(*GetLogInfoOK) + if ok { + return success, nil + } + // unexpected success response + unexpectedSuccess := result.(*GetLogInfoDefault) + return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code()) +} + +/* + GetLogProof gets information required to generate a consistency proof for the transparency log + + Returns a list of hashes for specified tree sizes that can be used to confirm the consistency of the transparency log +*/ +func (a *Client) GetLogProof(params *GetLogProofParams) (*GetLogProofOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewGetLogProofParams() + } + + result, err := a.transport.Submit(&runtime.ClientOperation{ + ID: "getLogProof", + Method: "GET", + PathPattern: "/api/v1/log/proof", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &GetLogProofReader{formats: a.formats}, + Context: params.Context, + Client: params.HTTPClient, + }) + if err != nil { + return nil, err + } + success, ok := result.(*GetLogProofOK) + if ok { + return success, nil + } + // unexpected success response + unexpectedSuccess := result.(*GetLogProofDefault) + return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code()) +} + +// SetTransport changes the transport on the client +func (a *Client) SetTransport(transport runtime.ClientTransport) { + a.transport = transport +} diff --git a/pkg/generated/models/consistency_proof.go b/pkg/generated/models/consistency_proof.go new file mode 100644 index 0000000000000000000000000000000000000000..2da0f59e3e0a90e6377bb1d847da07cb3f548852 --- /dev/null +++ b/pkg/generated/models/consistency_proof.go @@ -0,0 +1,108 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "strconv" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// ConsistencyProof consistency proof +// +// swagger:model ConsistencyProof +type ConsistencyProof struct { + + // The hash value stored at the root of the merkle tree at the first size specified + // Required: true + FirstRootHash *string `json:"firstRootHash"` + + // hashes + // Required: true + Hashes []string `json:"hashes"` + + // The hash value stored at the root of the merkle tree at the last size specified + // Required: true + LastRootHash *string `json:"lastRootHash"` +} + +// Validate validates this consistency proof +func (m *ConsistencyProof) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateFirstRootHash(formats); err != nil { + res = append(res, err) + } + + if err := m.validateHashes(formats); err != nil { + res = append(res, err) + } + + if err := m.validateLastRootHash(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *ConsistencyProof) validateFirstRootHash(formats strfmt.Registry) error { + + if err := validate.Required("firstRootHash", "body", m.FirstRootHash); err != nil { + return err + } + + return nil +} + +func (m *ConsistencyProof) validateHashes(formats strfmt.Registry) error { + + if err := validate.Required("hashes", "body", m.Hashes); err != nil { + return err + } + + for i := 0; i < len(m.Hashes); i++ { + + if err := validate.Pattern("hashes"+"."+strconv.Itoa(i), "body", string(m.Hashes[i]), `^[0-9a-fA-F]{64}$`); err != nil { + return err + } + + } + + return nil +} + +func (m *ConsistencyProof) validateLastRootHash(formats strfmt.Registry) error { + + if err := validate.Required("lastRootHash", "body", m.LastRootHash); err != nil { + return err + } + + return nil +} + +// MarshalBinary interface implementation +func (m *ConsistencyProof) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *ConsistencyProof) UnmarshalBinary(b []byte) error { + var res ConsistencyProof + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/pkg/generated/models/error.go b/pkg/generated/models/error.go new file mode 100644 index 0000000000000000000000000000000000000000..38b8459dcdf94dc695cf13c6a742899e3a44c21e --- /dev/null +++ b/pkg/generated/models/error.go @@ -0,0 +1,101 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// Error error +// +// swagger:model Error +type Error struct { + + // detail + Detail string `json:"detail,omitempty"` + + // status + // Required: true + Status *int64 `json:"status"` + + // title + // Required: true + Title *string `json:"title"` + + // type + // Required: true + Type *string `json:"type"` +} + +// Validate validates this error +func (m *Error) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateStatus(formats); err != nil { + res = append(res, err) + } + + if err := m.validateTitle(formats); err != nil { + res = append(res, err) + } + + if err := m.validateType(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *Error) validateStatus(formats strfmt.Registry) error { + + if err := validate.Required("status", "body", m.Status); err != nil { + return err + } + + return nil +} + +func (m *Error) validateTitle(formats strfmt.Registry) error { + + if err := validate.Required("title", "body", m.Title); err != nil { + return err + } + + return nil +} + +func (m *Error) validateType(formats strfmt.Registry) error { + + if err := validate.Required("type", "body", m.Type); err != nil { + return err + } + + return nil +} + +// MarshalBinary interface implementation +func (m *Error) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *Error) UnmarshalBinary(b []byte) error { + var res Error + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/pkg/generated/models/inclusion_proof.go b/pkg/generated/models/inclusion_proof.go new file mode 100644 index 0000000000000000000000000000000000000000..061f59d3f3d6210937189fc57a1f5c9eb2595503 --- /dev/null +++ b/pkg/generated/models/inclusion_proof.go @@ -0,0 +1,130 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "strconv" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// InclusionProof inclusion proof +// +// swagger:model InclusionProof +type InclusionProof struct { + + // A list of hashes required to compute the inclusion proof, sorted in order from leaf to root + // Required: true + Hashes []string `json:"hashes"` + + // The index of the entry in the transparency log + // Required: true + LogIndex *int64 `json:"logIndex"` + + // The hash value stored at the root of the merkle tree + // Required: true + // Pattern: ^[0-9a-fA-F]{64}$ + RootHash *string `json:"rootHash"` + + // The size of the merkle tree at the time the inclusion proof was generated + // Required: true + TreeSize *int64 `json:"treeSize"` +} + +// Validate validates this inclusion proof +func (m *InclusionProof) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateHashes(formats); err != nil { + res = append(res, err) + } + + if err := m.validateLogIndex(formats); err != nil { + res = append(res, err) + } + + if err := m.validateRootHash(formats); err != nil { + res = append(res, err) + } + + if err := m.validateTreeSize(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *InclusionProof) validateHashes(formats strfmt.Registry) error { + + if err := validate.Required("hashes", "body", m.Hashes); err != nil { + return err + } + + for i := 0; i < len(m.Hashes); i++ { + + if err := validate.Pattern("hashes"+"."+strconv.Itoa(i), "body", string(m.Hashes[i]), `^[0-9a-fA-F]{64}$`); err != nil { + return err + } + + } + + return nil +} + +func (m *InclusionProof) validateLogIndex(formats strfmt.Registry) error { + + if err := validate.Required("logIndex", "body", m.LogIndex); err != nil { + return err + } + + return nil +} + +func (m *InclusionProof) validateRootHash(formats strfmt.Registry) error { + + if err := validate.Required("rootHash", "body", m.RootHash); err != nil { + return err + } + + if err := validate.Pattern("rootHash", "body", string(*m.RootHash), `^[0-9a-fA-F]{64}$`); err != nil { + return err + } + + return nil +} + +func (m *InclusionProof) validateTreeSize(formats strfmt.Registry) error { + + if err := validate.Required("treeSize", "body", m.TreeSize); err != nil { + return err + } + + return nil +} + +// MarshalBinary interface implementation +func (m *InclusionProof) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *InclusionProof) UnmarshalBinary(b []byte) error { + var res InclusionProof + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/pkg/generated/models/log_entry.go b/pkg/generated/models/log_entry.go new file mode 100644 index 0000000000000000000000000000000000000000..acb8df58e82bfeec2207b5553ced16e561072520 --- /dev/null +++ b/pkg/generated/models/log_entry.go @@ -0,0 +1,233 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// LogEntry log entry +// +// swagger:model LogEntry +type LogEntry map[string]LogEntryAnon + +// Validate validates this log entry +func (m LogEntry) Validate(formats strfmt.Registry) error { + var res []error + + for k := range m { + + if swag.IsZero(m[k]) { // not required + continue + } + if val, ok := m[k]; ok { + if err := val.Validate(formats); err != nil { + return err + } + } + + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// LogEntryAnon log entry anon +// +// swagger:model LogEntryAnon +type LogEntryAnon struct { + + // extra data + ExtraData map[string]string `json:"extraData,omitempty"` + + // log index + // Required: true + LogIndex *int64 `json:"logIndex"` + + // signature + // Required: true + Signature *LogEntryAnonSignature `json:"signature"` + + // signed content s h a256 + // Required: true + // Pattern: ^[0-9a-fA-F]{64}$ + SignedContentSHA256 *string `json:"signedContentSHA256"` +} + +// Validate validates this log entry anon +func (m *LogEntryAnon) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateLogIndex(formats); err != nil { + res = append(res, err) + } + + if err := m.validateSignature(formats); err != nil { + res = append(res, err) + } + + if err := m.validateSignedContentSHA256(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *LogEntryAnon) validateLogIndex(formats strfmt.Registry) error { + + if err := validate.Required("logIndex", "body", m.LogIndex); err != nil { + return err + } + + return nil +} + +func (m *LogEntryAnon) validateSignature(formats strfmt.Registry) error { + + if err := validate.Required("signature", "body", m.Signature); err != nil { + return err + } + + if m.Signature != nil { + if err := m.Signature.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("signature") + } + return err + } + } + + return nil +} + +func (m *LogEntryAnon) validateSignedContentSHA256(formats strfmt.Registry) error { + + if err := validate.Required("signedContentSHA256", "body", m.SignedContentSHA256); err != nil { + return err + } + + if err := validate.Pattern("signedContentSHA256", "body", string(*m.SignedContentSHA256), `^[0-9a-fA-F]{64}$`); err != nil { + return err + } + + return nil +} + +// MarshalBinary interface implementation +func (m *LogEntryAnon) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *LogEntryAnon) UnmarshalBinary(b []byte) error { + var res LogEntryAnon + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} + +// LogEntryAnonSignature log entry anon signature +// +// swagger:model LogEntryAnonSignature +type LogEntryAnonSignature struct { + + // content + // Required: true + // Format: byte + Content *strfmt.Base64 `json:"content"` + + // format + // Required: true + Format SupportedPKIFormats `json:"format"` + + // public key + // Required: true + // Format: byte + PublicKey *strfmt.Base64 `json:"publicKey"` +} + +// Validate validates this log entry anon signature +func (m *LogEntryAnonSignature) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateContent(formats); err != nil { + res = append(res, err) + } + + if err := m.validateFormat(formats); err != nil { + res = append(res, err) + } + + if err := m.validatePublicKey(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *LogEntryAnonSignature) validateContent(formats strfmt.Registry) error { + + if err := validate.Required("signature"+"."+"content", "body", m.Content); err != nil { + return err + } + + return nil +} + +func (m *LogEntryAnonSignature) validateFormat(formats strfmt.Registry) error { + + if err := m.Format.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("signature" + "." + "format") + } + return err + } + + return nil +} + +func (m *LogEntryAnonSignature) validatePublicKey(formats strfmt.Registry) error { + + if err := validate.Required("signature"+"."+"publicKey", "body", m.PublicKey); err != nil { + return err + } + + return nil +} + +// MarshalBinary interface implementation +func (m *LogEntryAnonSignature) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *LogEntryAnonSignature) UnmarshalBinary(b []byte) error { + var res LogEntryAnonSignature + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/pkg/generated/models/log_info.go b/pkg/generated/models/log_info.go new file mode 100644 index 0000000000000000000000000000000000000000..9ad8adf5855dcb5c40eb27faffab95e88e41992c --- /dev/null +++ b/pkg/generated/models/log_info.go @@ -0,0 +1,81 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// LogInfo log info +// +// swagger:model LogInfo +type LogInfo struct { + + // The current hash value stored at the root of the merkle tree + // Required: true + RootHash *string `json:"rootHash"` + + // The current number of nodes in the merkle tree + // Required: true + TreeSize *int64 `json:"treeSize"` +} + +// Validate validates this log info +func (m *LogInfo) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateRootHash(formats); err != nil { + res = append(res, err) + } + + if err := m.validateTreeSize(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *LogInfo) validateRootHash(formats strfmt.Registry) error { + + if err := validate.Required("rootHash", "body", m.RootHash); err != nil { + return err + } + + return nil +} + +func (m *LogInfo) validateTreeSize(formats strfmt.Registry) error { + + if err := validate.Required("treeSize", "body", m.TreeSize); err != nil { + return err + } + + return nil +} + +// MarshalBinary interface implementation +func (m *LogInfo) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *LogInfo) UnmarshalBinary(b []byte) error { + var res LogInfo + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/pkg/generated/models/proposed_entry.go b/pkg/generated/models/proposed_entry.go new file mode 100644 index 0000000000000000000000000000000000000000..8363b65bac4cc1357be14ed1346e07c93659bbc0 --- /dev/null +++ b/pkg/generated/models/proposed_entry.go @@ -0,0 +1,350 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// ProposedEntry proposed entry +// +// swagger:model ProposedEntry +type ProposedEntry struct { + + // data + Data *ProposedEntryData `json:"data,omitempty"` + + // signature + Signature *ProposedEntrySignature `json:"signature,omitempty"` +} + +// Validate validates this proposed entry +func (m *ProposedEntry) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateData(formats); err != nil { + res = append(res, err) + } + + if err := m.validateSignature(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *ProposedEntry) validateData(formats strfmt.Registry) error { + + if swag.IsZero(m.Data) { // not required + return nil + } + + if m.Data != nil { + if err := m.Data.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("data") + } + return err + } + } + + return nil +} + +func (m *ProposedEntry) validateSignature(formats strfmt.Registry) error { + + if swag.IsZero(m.Signature) { // not required + return nil + } + + if m.Signature != nil { + if err := m.Signature.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("signature") + } + return err + } + } + + return nil +} + +// MarshalBinary interface implementation +func (m *ProposedEntry) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *ProposedEntry) UnmarshalBinary(b []byte) error { + var res ProposedEntry + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} + +// ProposedEntryData proposed entry data +// +// swagger:model ProposedEntryData +type ProposedEntryData struct { + + // Base64-encoded content. + // The 'url' and 'content' properties are mutually exclusive. + // + // Format: byte + Content strfmt.Base64 `json:"content,omitempty"` + + // The SHA256 hash of the content located at the URL specified in the 'url' parameter. This property is required when 'url' is specified, and ignored when 'content' is specified. + // + // Pattern: ^[0-9a-fA-F]{64}$ + Sha256 string `json:"sha256,omitempty"` + + // The URL where the content refered to in the signature property is located. When specifying 'url', you must also specify the 'sha256' property. + // The 'url' and 'content' properties are mutually exclusive. + // + // Format: uri + URL strfmt.URI `json:"url,omitempty"` +} + +// Validate validates this proposed entry data +func (m *ProposedEntryData) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateSha256(formats); err != nil { + res = append(res, err) + } + + if err := m.validateURL(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *ProposedEntryData) validateSha256(formats strfmt.Registry) error { + + if swag.IsZero(m.Sha256) { // not required + return nil + } + + if err := validate.Pattern("data"+"."+"sha256", "body", string(m.Sha256), `^[0-9a-fA-F]{64}$`); err != nil { + return err + } + + return nil +} + +func (m *ProposedEntryData) validateURL(formats strfmt.Registry) error { + + if swag.IsZero(m.URL) { // not required + return nil + } + + if err := validate.FormatOf("data"+"."+"url", "body", "uri", m.URL.String(), formats); err != nil { + return err + } + + return nil +} + +// MarshalBinary interface implementation +func (m *ProposedEntryData) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *ProposedEntryData) UnmarshalBinary(b []byte) error { + var res ProposedEntryData + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} + +// ProposedEntrySignature proposed entry signature +// +// swagger:model ProposedEntrySignature +type ProposedEntrySignature struct { + + // content + // Format: byte + Content strfmt.Base64 `json:"content,omitempty"` + + // format + // Required: true + Format SupportedPKIFormats `json:"format"` + + // public key + // Required: true + PublicKey *ProposedEntrySignaturePublicKey `json:"publicKey"` + + // url + // Format: uri + URL strfmt.URI `json:"url,omitempty"` +} + +// Validate validates this proposed entry signature +func (m *ProposedEntrySignature) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateFormat(formats); err != nil { + res = append(res, err) + } + + if err := m.validatePublicKey(formats); err != nil { + res = append(res, err) + } + + if err := m.validateURL(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *ProposedEntrySignature) validateFormat(formats strfmt.Registry) error { + + if err := m.Format.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("signature" + "." + "format") + } + return err + } + + return nil +} + +func (m *ProposedEntrySignature) validatePublicKey(formats strfmt.Registry) error { + + if err := validate.Required("signature"+"."+"publicKey", "body", m.PublicKey); err != nil { + return err + } + + if m.PublicKey != nil { + if err := m.PublicKey.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("signature" + "." + "publicKey") + } + return err + } + } + + return nil +} + +func (m *ProposedEntrySignature) validateURL(formats strfmt.Registry) error { + + if swag.IsZero(m.URL) { // not required + return nil + } + + if err := validate.FormatOf("signature"+"."+"url", "body", "uri", m.URL.String(), formats); err != nil { + return err + } + + return nil +} + +// MarshalBinary interface implementation +func (m *ProposedEntrySignature) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *ProposedEntrySignature) UnmarshalBinary(b []byte) error { + var res ProposedEntrySignature + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} + +// ProposedEntrySignaturePublicKey proposed entry signature public key +// +// swagger:model ProposedEntrySignaturePublicKey +type ProposedEntrySignaturePublicKey struct { + + // Base64-encoded content of the public key. This public key needs to be the pair of the private key used to generate the detached signature found in the 'signature' property. + // The 'url' and 'content' properties are mutually exclusive. + // + // Format: byte + Content strfmt.Base64 `json:"content,omitempty"` + + // The URL where the public key can be found. This public key needs to be the pair of the private key used to generate the detached signature found in the 'signature' property. + // The 'url' and 'content' properties are mutually exclusive. + // + // Format: uri + URL strfmt.URI `json:"url,omitempty"` +} + +// Validate validates this proposed entry signature public key +func (m *ProposedEntrySignaturePublicKey) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateURL(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *ProposedEntrySignaturePublicKey) validateURL(formats strfmt.Registry) error { + + if swag.IsZero(m.URL) { // not required + return nil + } + + if err := validate.FormatOf("signature"+"."+"publicKey"+"."+"url", "body", "uri", m.URL.String(), formats); err != nil { + return err + } + + return nil +} + +// MarshalBinary interface implementation +func (m *ProposedEntrySignaturePublicKey) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *ProposedEntrySignaturePublicKey) UnmarshalBinary(b []byte) error { + var res ProposedEntrySignaturePublicKey + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/pkg/generated/models/search_log_query.go b/pkg/generated/models/search_log_query.go new file mode 100644 index 0000000000000000000000000000000000000000..2264b19023a38316a5e5c683f8318f0b4e08a7a7 --- /dev/null +++ b/pkg/generated/models/search_log_query.go @@ -0,0 +1,115 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "strconv" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// SearchLogQuery search log query +// +// swagger:model SearchLogQuery +type SearchLogQuery struct { + + // entries + Entries []LogEntry `json:"entries"` + + // entry u UI ds + EntryUUIDs []string `json:"entryUUIDs"` + + // log indexes + LogIndexes []int64 `json:"logIndexes"` +} + +// Validate validates this search log query +func (m *SearchLogQuery) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateEntries(formats); err != nil { + res = append(res, err) + } + + if err := m.validateEntryUUIDs(formats); err != nil { + res = append(res, err) + } + + if err := m.validateLogIndexes(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *SearchLogQuery) validateEntries(formats strfmt.Registry) error { + + if swag.IsZero(m.Entries) { // not required + return nil + } + + for i := 0; i < len(m.Entries); i++ { + + if err := m.Entries[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("entries" + "." + strconv.Itoa(i)) + } + return err + } + + } + + return nil +} + +func (m *SearchLogQuery) validateEntryUUIDs(formats strfmt.Registry) error { + + if swag.IsZero(m.EntryUUIDs) { // not required + return nil + } + + for i := 0; i < len(m.EntryUUIDs); i++ { + + } + + return nil +} + +func (m *SearchLogQuery) validateLogIndexes(formats strfmt.Registry) error { + + if swag.IsZero(m.LogIndexes) { // not required + return nil + } + + for i := 0; i < len(m.LogIndexes); i++ { + + } + + return nil +} + +// MarshalBinary interface implementation +func (m *SearchLogQuery) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *SearchLogQuery) UnmarshalBinary(b []byte) error { + var res SearchLogQuery + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/pkg/generated/models/supported_pki_formats.go b/pkg/generated/models/supported_pki_formats.go new file mode 100644 index 0000000000000000000000000000000000000000..7904c216f6c06fcaa593913c0cdaa85ad8b5be8c --- /dev/null +++ b/pkg/generated/models/supported_pki_formats.go @@ -0,0 +1,60 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "encoding/json" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/validate" +) + +// SupportedPKIFormats This represents the tokens that indicate the format of the PKI artifacts supported by the server +// +// swagger:model SupportedPKIFormats +type SupportedPKIFormats string + +const ( + + // SupportedPKIFormatsPgp captures enum value "pgp" + SupportedPKIFormatsPgp SupportedPKIFormats = "pgp" +) + +// for schema +var supportedPkiFormatsEnum []interface{} + +func init() { + var res []SupportedPKIFormats + if err := json.Unmarshal([]byte(`["pgp"]`), &res); err != nil { + panic(err) + } + for _, v := range res { + supportedPkiFormatsEnum = append(supportedPkiFormatsEnum, v) + } +} + +func (m SupportedPKIFormats) validateSupportedPKIFormatsEnum(path, location string, value SupportedPKIFormats) error { + if err := validate.EnumCase(path, location, value, supportedPkiFormatsEnum, true); err != nil { + return err + } + return nil +} + +// Validate validates this supported PKI formats +func (m SupportedPKIFormats) Validate(formats strfmt.Registry) error { + var res []error + + // value enum + if err := m.validateSupportedPKIFormatsEnum("", "body", m); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/pkg/generated/restapi/configure_rekor_server.go b/pkg/generated/restapi/configure_rekor_server.go new file mode 100644 index 0000000000000000000000000000000000000000..2bf3de1be3b7e7ce16ab4125a54c3b59fe7219a0 --- /dev/null +++ b/pkg/generated/restapi/configure_rekor_server.go @@ -0,0 +1,94 @@ +// This file is safe to edit. Once it exists it will not be overwritten + +package restapi + +import ( + "crypto/tls" + "net/http" + + "github.com/go-chi/chi/middleware" + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + + pkgapi "github.com/projectrekor/rekor/pkg/api" + "github.com/projectrekor/rekor/pkg/generated/restapi/operations" + "github.com/projectrekor/rekor/pkg/generated/restapi/operations/entries" + "github.com/projectrekor/rekor/pkg/generated/restapi/operations/tlog" + "github.com/projectrekor/rekor/pkg/log" +) + +//go:generate swagger generate server --target ../../generated --name RekorServer --spec ../../../openapi.yaml --principal interface{} --exclude-main + +func configureFlags(api *operations.RekorServerAPI) { + // api.CommandLineOptionsGroups = []swag.CommandLineOptionsGroup{ ... } +} + +func configureAPI(api *operations.RekorServerAPI) http.Handler { + // configure the api here + api.ServeError = errors.ServeError + + // Set your custom logger if needed. Default one is log.Printf + // Expected interface func(string, ...interface{}) + // + // Example: + // api.Logger = log.Printf + api.Logger = log.Logger.Infof + + api.UseSwaggerUI() + // To continue using redoc as your UI, uncomment the following line + // api.UseRedoc() + + api.JSONConsumer = runtime.JSONConsumer() + + api.JSONProducer = runtime.JSONProducer() + + api.EntriesCreateLogEntryHandler = entries.CreateLogEntryHandlerFunc(pkgapi.CreateLogEntryHandler) + api.EntriesGetLogEntryByIndexHandler = entries.GetLogEntryByIndexHandlerFunc(pkgapi.GetLogEntryByIndexHandler) + api.EntriesGetLogEntryByUUIDHandler = entries.GetLogEntryByUUIDHandlerFunc(pkgapi.GetLogEntryByUUIDHandler) + api.EntriesGetLogEntryProofHandler = entries.GetLogEntryProofHandlerFunc(pkgapi.GetLogEntryProofHandler) + api.EntriesSearchLogQueryHandler = entries.SearchLogQueryHandlerFunc(pkgapi.SearchLogQueryHandler) + + api.TlogGetLogInfoHandler = tlog.GetLogInfoHandlerFunc(pkgapi.GetLogInfoHandler) + api.TlogGetLogProofHandler = tlog.GetLogProofHandlerFunc(pkgapi.GetLogProofHandler) + + api.PreServerShutdown = func() {} + + api.ServerShutdown = func() {} + + return setupGlobalMiddleware(api.Serve(setupMiddlewares)) +} + +// The TLS configuration before HTTPS server starts. +func configureTLS(tlsConfig *tls.Config) { + // Make all necessary changes to the TLS configuration here. +} + +// As soon as server is initialized but not run yet, this function will be called. +// If you need to modify a config, store server instance to stop it individually later, this is the place. +// This function can be called multiple times, depending on the number of serving schemes. +// scheme value will be set accordingly: "http", "https" or "unix" +func configureServer(s *http.Server, scheme, addr string) { +} + +// The middleware configuration is for the handler executors. These do not apply to the swagger.json document. +// The middleware executes after routing but before authentication, binding and validation +func setupMiddlewares(handler http.Handler) http.Handler { + return handler +} + +// The middleware configuration happens before anything, this middleware also applies to serving the swagger.json document. +// So this is a good place to plug in a panic handling middleware, logging and metrics +func setupGlobalMiddleware(handler http.Handler) http.Handler { + returnHandler := middleware.RequestID(handler) + returnHandler = middleware.Logger(returnHandler) + returnHandler = middleware.Recoverer(returnHandler) + return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + ctx := r.Context() + r = r.WithContext(log.WithRequestID(ctx, middleware.GetReqID(ctx))) + defer func() { + _ = log.RequestIDLogger(r).Sync() + }() + + returnHandler.ServeHTTP(w, r) + }) +} diff --git a/pkg/generated/restapi/doc.go b/pkg/generated/restapi/doc.go new file mode 100644 index 0000000000000000000000000000000000000000..00e833068eb2b8eeb06bef3e1fc03353f630fa14 --- /dev/null +++ b/pkg/generated/restapi/doc.go @@ -0,0 +1,19 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Package restapi Rekor +// +// Rekor is a cryptographically secure, immutable transparency log for signed software releases. +// Schemes: +// http +// Host: localhost +// BasePath: / +// Version: 0.0.1 +// +// Consumes: +// - application/json +// +// Produces: +// - application/json +// +// swagger:meta +package restapi diff --git a/pkg/generated/restapi/embedded_spec.go b/pkg/generated/restapi/embedded_spec.go new file mode 100644 index 0000000000000000000000000000000000000000..8156b904884504c6418db40a19ada705d748be85 --- /dev/null +++ b/pkg/generated/restapi/embedded_spec.go @@ -0,0 +1,1151 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package restapi + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "encoding/json" +) + +var ( + // SwaggerJSON embedded version of the swagger document used at generation time + SwaggerJSON json.RawMessage + // FlatSwaggerJSON embedded flattened version of the swagger document used at generation time + FlatSwaggerJSON json.RawMessage +) + +func init() { + SwaggerJSON = json.RawMessage([]byte(`{ + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "swagger": "2.0", + "info": { + "description": "Rekor is a cryptographically secure, immutable transparency log for signed software releases.", + "title": "Rekor", + "version": "0.0.1" + }, + "paths": { + "/api/v1/log": { + "get": { + "description": "Returns the current root hash and size of the merkle tree used to store the log entries.", + "tags": [ + "tlog" + ], + "summary": "Get information about the current state of the transparency log", + "operationId": "getLogInfo", + "responses": { + "200": { + "description": "A JSON object with the root hash and tree size as properties", + "schema": { + "$ref": "#/definitions/LogInfo" + } + }, + "default": { + "$ref": "#/responses/InternalServerError" + } + } + } + }, + "/api/v1/log/entries": { + "get": { + "tags": [ + "entries" + ], + "summary": "Retrieves an entry from the transparency log (if it exists) by index", + "operationId": "getLogEntryByIndex", + "parameters": [ + { + "type": "integer", + "description": "specifies the index of the entry in the transparency log to be retrieved", + "name": "logIndex", + "in": "query", + "required": true + } + ], + "responses": { + "200": { + "description": "the entry in the transparency log requested", + "schema": { + "$ref": "#/definitions/LogEntry" + } + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/InternalServerError" + } + } + }, + "post": { + "description": "Creates an entry in the transparency log for a detached signature, public key, and content. Items can be included in the request or fetched by the server when URLs are specified.\n", + "tags": [ + "entries" + ], + "summary": "Creates an entry in the transparency log", + "operationId": "createLogEntry", + "parameters": [ + { + "name": "proposedEntry", + "in": "body", + "schema": { + "$ref": "#/definitions/ProposedEntry" + } + } + ], + "responses": { + "201": { + "description": "Returns the entry created in the transparency log", + "schema": { + "$ref": "#/definitions/LogEntry" + }, + "headers": { + "Location": { + "type": "string", + "format": "uri", + "description": "URI location of log entry" + } + } + }, + "400": { + "$ref": "#/responses/BadContent" + }, + "default": { + "$ref": "#/responses/InternalServerError" + } + } + } + }, + "/api/v1/log/entries/retrieve": { + "post": { + "tags": [ + "entries" + ], + "summary": "Searches transparency log for one or more log entries", + "operationId": "searchLogQuery", + "parameters": [ + { + "name": "entry", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/SearchLogQuery" + } + } + ], + "responses": { + "200": { + "description": "Returns zero or more entries from the transparency log, according to how many were included in request query", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/LogEntry" + } + } + }, + "default": { + "$ref": "#/responses/InternalServerError" + } + } + } + }, + "/api/v1/log/entries/{entryUUID}": { + "get": { + "tags": [ + "entries" + ], + "summary": "Retrieves an entry from the transparency log (if it exists) by UUID", + "operationId": "getLogEntryByUUID", + "parameters": [ + { + "type": "string", + "description": "the UUID of the entry to be retrieved from the log. The UUID is also the merkle tree hash of the entry.", + "name": "entryUUID", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "the entry in the transparency log requested", + "schema": { + "$ref": "#/definitions/LogEntry" + } + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/InternalServerError" + } + } + } + }, + "/api/v1/log/entries/{entryUUID}/proof": { + "get": { + "description": "Returns root hash, tree size, and a list of hashes that can be used to calculate proof of an entry being included in the transparency log", + "tags": [ + "entries" + ], + "summary": "Get information required to generate an inclusion proof for a specified entry in the transparency log", + "operationId": "getLogEntryProof", + "parameters": [ + { + "type": "string", + "description": "the UUID of the entry for which the inclusion proof information should be returned", + "name": "entryUUID", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "Information needed for a client to compute the inclusion proof", + "schema": { + "$ref": "#/definitions/InclusionProof" + } + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/InternalServerError" + } + } + } + }, + "/api/v1/log/proof": { + "get": { + "description": "Returns a list of hashes for specified tree sizes that can be used to confirm the consistency of the transparency log", + "tags": [ + "tlog" + ], + "summary": "Get information required to generate a consistency proof for the transparency log", + "operationId": "getLogProof", + "parameters": [ + { + "type": "integer", + "default": 0, + "description": "The size of the tree that you wish to prove consistency from (0 means the beginning of the log) Defaults to 0 if not specified\n", + "name": "firstSize", + "in": "query" + }, + { + "type": "integer", + "description": "The size of the tree that you wish to prove consistency to", + "name": "lastSize", + "in": "query", + "required": true + } + ], + "responses": { + "200": { + "description": "All hashes required to compute the consistency proof", + "schema": { + "$ref": "#/definitions/ConsistencyProof" + } + }, + "default": { + "$ref": "#/responses/InternalServerError" + } + } + } + } + }, + "definitions": { + "ConsistencyProof": { + "type": "object", + "required": [ + "firstRootHash", + "lastRootHash", + "hashes" + ], + "properties": { + "firstRootHash": { + "description": "The hash value stored at the root of the merkle tree at the first size specified", + "type": "string" + }, + "hashes": { + "type": "array", + "items": { + "type": "string", + "pattern": "^[0-9a-fA-F]{64}$" + } + }, + "lastRootHash": { + "description": "The hash value stored at the root of the merkle tree at the last size specified", + "type": "string" + } + } + }, + "Error": { + "type": "object", + "required": [ + "type", + "title", + "status" + ], + "properties": { + "detail": { + "type": "string" + }, + "status": { + "type": "integer" + }, + "title": { + "type": "string" + }, + "type": { + "type": "string" + } + } + }, + "InclusionProof": { + "type": "object", + "required": [ + "logIndex", + "rootHash", + "treeSize", + "hashes" + ], + "properties": { + "hashes": { + "description": "A list of hashes required to compute the inclusion proof, sorted in order from leaf to root", + "type": "array", + "items": { + "description": "SHA256 hash value expressed in hexadecimal format", + "type": "string", + "pattern": "^[0-9a-fA-F]{64}$" + } + }, + "logIndex": { + "description": "The index of the entry in the transparency log", + "type": "integer" + }, + "rootHash": { + "description": "The hash value stored at the root of the merkle tree", + "type": "string", + "pattern": "^[0-9a-fA-F]{64}$" + }, + "treeSize": { + "description": "The size of the merkle tree at the time the inclusion proof was generated", + "type": "integer" + } + } + }, + "LogEntry": { + "type": "object", + "additionalProperties": { + "type": "object", + "required": [ + "logIndex", + "signature", + "signedContentSHA256" + ], + "properties": { + "extraData": { + "type": "object", + "additionalProperties": { + "type": "string" + } + }, + "logIndex": { + "type": "integer" + }, + "signature": { + "type": "object", + "required": [ + "format", + "content", + "publicKey" + ], + "properties": { + "content": { + "type": "string", + "format": "byte" + }, + "format": { + "$ref": "#/definitions/SupportedPKIFormats" + }, + "publicKey": { + "type": "string", + "format": "byte" + } + } + }, + "signedContentSHA256": { + "type": "string", + "pattern": "^[0-9a-fA-F]{64}$" + } + } + } + }, + "LogInfo": { + "type": "object", + "required": [ + "rootHash", + "treeSize" + ], + "properties": { + "rootHash": { + "description": "The current hash value stored at the root of the merkle tree", + "type": "string" + }, + "treeSize": { + "description": "The current number of nodes in the merkle tree", + "type": "integer" + } + } + }, + "ProposedEntry": { + "type": "object", + "properties": { + "data": { + "type": "object", + "properties": { + "content": { + "description": "Base64-encoded content.\nThe 'url' and 'content' properties are mutually exclusive.\n", + "type": "string", + "format": "byte" + }, + "sha256": { + "description": "The SHA256 hash of the content located at the URL specified in the 'url' parameter. This property is required when 'url' is specified, and ignored when 'content' is specified.\n", + "type": "string", + "pattern": "^[0-9a-fA-F]{64}$" + }, + "url": { + "description": "The URL where the content refered to in the signature property is located. When specifying 'url', you must also specify the 'sha256' property.\nThe 'url' and 'content' properties are mutually exclusive.\n", + "type": "string", + "format": "uri" + } + } + }, + "signature": { + "type": "object", + "required": [ + "format", + "publicKey" + ], + "properties": { + "content": { + "type": "string", + "format": "byte" + }, + "format": { + "$ref": "#/definitions/SupportedPKIFormats" + }, + "publicKey": { + "type": "object", + "properties": { + "content": { + "description": "Base64-encoded content of the public key. This public key needs to be the pair of the private key used to generate the detached signature found in the 'signature' property.\nThe 'url' and 'content' properties are mutually exclusive.\n", + "type": "string", + "format": "byte" + }, + "url": { + "description": "The URL where the public key can be found. This public key needs to be the pair of the private key used to generate the detached signature found in the 'signature' property.\nThe 'url' and 'content' properties are mutually exclusive.\n", + "type": "string", + "format": "uri" + } + } + }, + "url": { + "type": "string", + "format": "uri" + } + } + } + } + }, + "SearchLogQuery": { + "type": "object", + "properties": { + "entries": { + "type": "array", + "items": { + "minItems": 1, + "$ref": "#/definitions/LogEntry" + } + }, + "entryUUIDs": { + "type": "array", + "items": { + "type": "string", + "minItems": 1 + } + }, + "logIndexes": { + "type": "array", + "items": { + "type": "integer", + "minItems": 1 + } + } + } + }, + "SupportedPKIFormats": { + "description": "This represents the tokens that indicate the format of the PKI artifacts supported by the server", + "type": "string", + "enum": [ + "pgp" + ] + } + }, + "responses": { + "BadContent": { + "description": "The content supplied to the server was invalid", + "schema": { + "$ref": "#/definitions/Error" + } + }, + "InternalServerError": { + "description": "There was an internal error in the server while processing the request", + "schema": { + "$ref": "#/definitions/Error" + } + }, + "NotFound": { + "description": "The content requested could not be found", + "schema": { + "$ref": "#/definitions/Error" + } + } + } +}`)) + FlatSwaggerJSON = json.RawMessage([]byte(`{ + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "swagger": "2.0", + "info": { + "description": "Rekor is a cryptographically secure, immutable transparency log for signed software releases.", + "title": "Rekor", + "version": "0.0.1" + }, + "paths": { + "/api/v1/log": { + "get": { + "description": "Returns the current root hash and size of the merkle tree used to store the log entries.", + "tags": [ + "tlog" + ], + "summary": "Get information about the current state of the transparency log", + "operationId": "getLogInfo", + "responses": { + "200": { + "description": "A JSON object with the root hash and tree size as properties", + "schema": { + "$ref": "#/definitions/LogInfo" + } + }, + "default": { + "description": "There was an internal error in the server while processing the request", + "schema": { + "$ref": "#/definitions/Error" + } + } + } + } + }, + "/api/v1/log/entries": { + "get": { + "tags": [ + "entries" + ], + "summary": "Retrieves an entry from the transparency log (if it exists) by index", + "operationId": "getLogEntryByIndex", + "parameters": [ + { + "type": "integer", + "description": "specifies the index of the entry in the transparency log to be retrieved", + "name": "logIndex", + "in": "query", + "required": true + } + ], + "responses": { + "200": { + "description": "the entry in the transparency log requested", + "schema": { + "$ref": "#/definitions/LogEntry" + } + }, + "404": { + "description": "The content requested could not be found", + "schema": { + "$ref": "#/definitions/Error" + } + }, + "default": { + "description": "There was an internal error in the server while processing the request", + "schema": { + "$ref": "#/definitions/Error" + } + } + } + }, + "post": { + "description": "Creates an entry in the transparency log for a detached signature, public key, and content. Items can be included in the request or fetched by the server when URLs are specified.\n", + "tags": [ + "entries" + ], + "summary": "Creates an entry in the transparency log", + "operationId": "createLogEntry", + "parameters": [ + { + "name": "proposedEntry", + "in": "body", + "schema": { + "$ref": "#/definitions/ProposedEntry" + } + } + ], + "responses": { + "201": { + "description": "Returns the entry created in the transparency log", + "schema": { + "$ref": "#/definitions/LogEntry" + }, + "headers": { + "Location": { + "type": "string", + "format": "uri", + "description": "URI location of log entry" + } + } + }, + "400": { + "description": "The content supplied to the server was invalid", + "schema": { + "$ref": "#/definitions/Error" + } + }, + "default": { + "description": "There was an internal error in the server while processing the request", + "schema": { + "$ref": "#/definitions/Error" + } + } + } + } + }, + "/api/v1/log/entries/retrieve": { + "post": { + "tags": [ + "entries" + ], + "summary": "Searches transparency log for one or more log entries", + "operationId": "searchLogQuery", + "parameters": [ + { + "name": "entry", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/SearchLogQuery" + } + } + ], + "responses": { + "200": { + "description": "Returns zero or more entries from the transparency log, according to how many were included in request query", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/LogEntry" + } + } + }, + "default": { + "description": "There was an internal error in the server while processing the request", + "schema": { + "$ref": "#/definitions/Error" + } + } + } + } + }, + "/api/v1/log/entries/{entryUUID}": { + "get": { + "tags": [ + "entries" + ], + "summary": "Retrieves an entry from the transparency log (if it exists) by UUID", + "operationId": "getLogEntryByUUID", + "parameters": [ + { + "type": "string", + "description": "the UUID of the entry to be retrieved from the log. The UUID is also the merkle tree hash of the entry.", + "name": "entryUUID", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "the entry in the transparency log requested", + "schema": { + "$ref": "#/definitions/LogEntry" + } + }, + "404": { + "description": "The content requested could not be found", + "schema": { + "$ref": "#/definitions/Error" + } + }, + "default": { + "description": "There was an internal error in the server while processing the request", + "schema": { + "$ref": "#/definitions/Error" + } + } + } + } + }, + "/api/v1/log/entries/{entryUUID}/proof": { + "get": { + "description": "Returns root hash, tree size, and a list of hashes that can be used to calculate proof of an entry being included in the transparency log", + "tags": [ + "entries" + ], + "summary": "Get information required to generate an inclusion proof for a specified entry in the transparency log", + "operationId": "getLogEntryProof", + "parameters": [ + { + "type": "string", + "description": "the UUID of the entry for which the inclusion proof information should be returned", + "name": "entryUUID", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "Information needed for a client to compute the inclusion proof", + "schema": { + "$ref": "#/definitions/InclusionProof" + } + }, + "404": { + "description": "The content requested could not be found", + "schema": { + "$ref": "#/definitions/Error" + } + }, + "default": { + "description": "There was an internal error in the server while processing the request", + "schema": { + "$ref": "#/definitions/Error" + } + } + } + } + }, + "/api/v1/log/proof": { + "get": { + "description": "Returns a list of hashes for specified tree sizes that can be used to confirm the consistency of the transparency log", + "tags": [ + "tlog" + ], + "summary": "Get information required to generate a consistency proof for the transparency log", + "operationId": "getLogProof", + "parameters": [ + { + "minimum": 0, + "type": "integer", + "default": 0, + "description": "The size of the tree that you wish to prove consistency from (0 means the beginning of the log) Defaults to 0 if not specified\n", + "name": "firstSize", + "in": "query" + }, + { + "minimum": 0, + "type": "integer", + "description": "The size of the tree that you wish to prove consistency to", + "name": "lastSize", + "in": "query", + "required": true + } + ], + "responses": { + "200": { + "description": "All hashes required to compute the consistency proof", + "schema": { + "$ref": "#/definitions/ConsistencyProof" + } + }, + "default": { + "description": "There was an internal error in the server while processing the request", + "schema": { + "$ref": "#/definitions/Error" + } + } + } + } + } + }, + "definitions": { + "ConsistencyProof": { + "type": "object", + "required": [ + "firstRootHash", + "lastRootHash", + "hashes" + ], + "properties": { + "firstRootHash": { + "description": "The hash value stored at the root of the merkle tree at the first size specified", + "type": "string" + }, + "hashes": { + "type": "array", + "items": { + "type": "string", + "pattern": "^[0-9a-fA-F]{64}$" + } + }, + "lastRootHash": { + "description": "The hash value stored at the root of the merkle tree at the last size specified", + "type": "string" + } + } + }, + "Error": { + "type": "object", + "required": [ + "type", + "title", + "status" + ], + "properties": { + "detail": { + "type": "string" + }, + "status": { + "type": "integer" + }, + "title": { + "type": "string" + }, + "type": { + "type": "string" + } + } + }, + "InclusionProof": { + "type": "object", + "required": [ + "logIndex", + "rootHash", + "treeSize", + "hashes" + ], + "properties": { + "hashes": { + "description": "A list of hashes required to compute the inclusion proof, sorted in order from leaf to root", + "type": "array", + "items": { + "description": "SHA256 hash value expressed in hexadecimal format", + "type": "string", + "pattern": "^[0-9a-fA-F]{64}$" + } + }, + "logIndex": { + "description": "The index of the entry in the transparency log", + "type": "integer" + }, + "rootHash": { + "description": "The hash value stored at the root of the merkle tree", + "type": "string", + "pattern": "^[0-9a-fA-F]{64}$" + }, + "treeSize": { + "description": "The size of the merkle tree at the time the inclusion proof was generated", + "type": "integer" + } + } + }, + "LogEntry": { + "type": "object", + "additionalProperties": { + "$ref": "#/definitions/LogEntryAnon" + } + }, + "LogEntryAnon": { + "type": "object", + "required": [ + "logIndex", + "signature", + "signedContentSHA256" + ], + "properties": { + "extraData": { + "type": "object", + "additionalProperties": { + "type": "string" + } + }, + "logIndex": { + "type": "integer" + }, + "signature": { + "type": "object", + "required": [ + "format", + "content", + "publicKey" + ], + "properties": { + "content": { + "type": "string", + "format": "byte" + }, + "format": { + "$ref": "#/definitions/SupportedPKIFormats" + }, + "publicKey": { + "type": "string", + "format": "byte" + } + } + }, + "signedContentSHA256": { + "type": "string", + "pattern": "^[0-9a-fA-F]{64}$" + } + } + }, + "LogEntryAnonSignature": { + "type": "object", + "required": [ + "format", + "content", + "publicKey" + ], + "properties": { + "content": { + "type": "string", + "format": "byte" + }, + "format": { + "$ref": "#/definitions/SupportedPKIFormats" + }, + "publicKey": { + "type": "string", + "format": "byte" + } + } + }, + "LogInfo": { + "type": "object", + "required": [ + "rootHash", + "treeSize" + ], + "properties": { + "rootHash": { + "description": "The current hash value stored at the root of the merkle tree", + "type": "string" + }, + "treeSize": { + "description": "The current number of nodes in the merkle tree", + "type": "integer" + } + } + }, + "ProposedEntry": { + "type": "object", + "properties": { + "data": { + "type": "object", + "properties": { + "content": { + "description": "Base64-encoded content.\nThe 'url' and 'content' properties are mutually exclusive.\n", + "type": "string", + "format": "byte" + }, + "sha256": { + "description": "The SHA256 hash of the content located at the URL specified in the 'url' parameter. This property is required when 'url' is specified, and ignored when 'content' is specified.\n", + "type": "string", + "pattern": "^[0-9a-fA-F]{64}$" + }, + "url": { + "description": "The URL where the content refered to in the signature property is located. When specifying 'url', you must also specify the 'sha256' property.\nThe 'url' and 'content' properties are mutually exclusive.\n", + "type": "string", + "format": "uri" + } + } + }, + "signature": { + "type": "object", + "required": [ + "format", + "publicKey" + ], + "properties": { + "content": { + "type": "string", + "format": "byte" + }, + "format": { + "$ref": "#/definitions/SupportedPKIFormats" + }, + "publicKey": { + "type": "object", + "properties": { + "content": { + "description": "Base64-encoded content of the public key. This public key needs to be the pair of the private key used to generate the detached signature found in the 'signature' property.\nThe 'url' and 'content' properties are mutually exclusive.\n", + "type": "string", + "format": "byte" + }, + "url": { + "description": "The URL where the public key can be found. This public key needs to be the pair of the private key used to generate the detached signature found in the 'signature' property.\nThe 'url' and 'content' properties are mutually exclusive.\n", + "type": "string", + "format": "uri" + } + } + }, + "url": { + "type": "string", + "format": "uri" + } + } + } + } + }, + "ProposedEntryData": { + "type": "object", + "properties": { + "content": { + "description": "Base64-encoded content.\nThe 'url' and 'content' properties are mutually exclusive.\n", + "type": "string", + "format": "byte" + }, + "sha256": { + "description": "The SHA256 hash of the content located at the URL specified in the 'url' parameter. This property is required when 'url' is specified, and ignored when 'content' is specified.\n", + "type": "string", + "pattern": "^[0-9a-fA-F]{64}$" + }, + "url": { + "description": "The URL where the content refered to in the signature property is located. When specifying 'url', you must also specify the 'sha256' property.\nThe 'url' and 'content' properties are mutually exclusive.\n", + "type": "string", + "format": "uri" + } + } + }, + "ProposedEntrySignature": { + "type": "object", + "required": [ + "format", + "publicKey" + ], + "properties": { + "content": { + "type": "string", + "format": "byte" + }, + "format": { + "$ref": "#/definitions/SupportedPKIFormats" + }, + "publicKey": { + "type": "object", + "properties": { + "content": { + "description": "Base64-encoded content of the public key. This public key needs to be the pair of the private key used to generate the detached signature found in the 'signature' property.\nThe 'url' and 'content' properties are mutually exclusive.\n", + "type": "string", + "format": "byte" + }, + "url": { + "description": "The URL where the public key can be found. This public key needs to be the pair of the private key used to generate the detached signature found in the 'signature' property.\nThe 'url' and 'content' properties are mutually exclusive.\n", + "type": "string", + "format": "uri" + } + } + }, + "url": { + "type": "string", + "format": "uri" + } + } + }, + "ProposedEntrySignaturePublicKey": { + "type": "object", + "properties": { + "content": { + "description": "Base64-encoded content of the public key. This public key needs to be the pair of the private key used to generate the detached signature found in the 'signature' property.\nThe 'url' and 'content' properties are mutually exclusive.\n", + "type": "string", + "format": "byte" + }, + "url": { + "description": "The URL where the public key can be found. This public key needs to be the pair of the private key used to generate the detached signature found in the 'signature' property.\nThe 'url' and 'content' properties are mutually exclusive.\n", + "type": "string", + "format": "uri" + } + } + }, + "SearchLogQuery": { + "type": "object", + "properties": { + "entries": { + "type": "array", + "items": { + "minItems": 1, + "$ref": "#/definitions/LogEntry" + } + }, + "entryUUIDs": { + "type": "array", + "items": { + "type": "string", + "minItems": 1 + } + }, + "logIndexes": { + "type": "array", + "items": { + "type": "integer", + "minItems": 1 + } + } + } + }, + "SupportedPKIFormats": { + "description": "This represents the tokens that indicate the format of the PKI artifacts supported by the server", + "type": "string", + "enum": [ + "pgp" + ] + } + }, + "responses": { + "BadContent": { + "description": "The content supplied to the server was invalid", + "schema": { + "$ref": "#/definitions/Error" + } + }, + "InternalServerError": { + "description": "There was an internal error in the server while processing the request", + "schema": { + "$ref": "#/definitions/Error" + } + }, + "NotFound": { + "description": "The content requested could not be found", + "schema": { + "$ref": "#/definitions/Error" + } + } + } +}`)) +} diff --git a/pkg/generated/restapi/operations/entries/create_log_entry.go b/pkg/generated/restapi/operations/entries/create_log_entry.go new file mode 100644 index 0000000000000000000000000000000000000000..1be94cd002996cf78cbe40e0538374fbcb7cdc54 --- /dev/null +++ b/pkg/generated/restapi/operations/entries/create_log_entry.go @@ -0,0 +1,61 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package entries + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// CreateLogEntryHandlerFunc turns a function with the right signature into a create log entry handler +type CreateLogEntryHandlerFunc func(CreateLogEntryParams) middleware.Responder + +// Handle executing the request and returning a response +func (fn CreateLogEntryHandlerFunc) Handle(params CreateLogEntryParams) middleware.Responder { + return fn(params) +} + +// CreateLogEntryHandler interface for that can handle valid create log entry params +type CreateLogEntryHandler interface { + Handle(CreateLogEntryParams) middleware.Responder +} + +// NewCreateLogEntry creates a new http.Handler for the create log entry operation +func NewCreateLogEntry(ctx *middleware.Context, handler CreateLogEntryHandler) *CreateLogEntry { + return &CreateLogEntry{Context: ctx, Handler: handler} +} + +/*CreateLogEntry swagger:route POST /api/v1/log/entries entries createLogEntry + +Creates an entry in the transparency log + +Creates an entry in the transparency log for a detached signature, public key, and content. Items can be included in the request or fetched by the server when URLs are specified. + + +*/ +type CreateLogEntry struct { + Context *middleware.Context + Handler CreateLogEntryHandler +} + +func (o *CreateLogEntry) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewCreateLogEntryParams() + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/pkg/generated/restapi/operations/entries/create_log_entry_parameters.go b/pkg/generated/restapi/operations/entries/create_log_entry_parameters.go new file mode 100644 index 0000000000000000000000000000000000000000..e65c60c00a1e29d31b62c888d6d3e1d90a3c218a --- /dev/null +++ b/pkg/generated/restapi/operations/entries/create_log_entry_parameters.go @@ -0,0 +1,69 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package entries + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + + "github.com/projectrekor/rekor/pkg/generated/models" +) + +// NewCreateLogEntryParams creates a new CreateLogEntryParams object +// no default values defined in spec. +func NewCreateLogEntryParams() CreateLogEntryParams { + + return CreateLogEntryParams{} +} + +// CreateLogEntryParams contains all the bound params for the create log entry operation +// typically these are obtained from a http.Request +// +// swagger:parameters createLogEntry +type CreateLogEntryParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + In: body + */ + ProposedEntry *models.ProposedEntry +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewCreateLogEntryParams() beforehand. +func (o *CreateLogEntryParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.ProposedEntry + if err := route.Consumer.Consume(r.Body, &body); err != nil { + res = append(res, errors.NewParseError("proposedEntry", "body", "", err)) + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.ProposedEntry = &body + } + } + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/pkg/generated/restapi/operations/entries/create_log_entry_responses.go b/pkg/generated/restapi/operations/entries/create_log_entry_responses.go new file mode 100644 index 0000000000000000000000000000000000000000..93b97ef25369ffffca100855b1306f650298d3fe --- /dev/null +++ b/pkg/generated/restapi/operations/entries/create_log_entry_responses.go @@ -0,0 +1,186 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package entries + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/projectrekor/rekor/pkg/generated/models" +) + +// CreateLogEntryCreatedCode is the HTTP code returned for type CreateLogEntryCreated +const CreateLogEntryCreatedCode int = 201 + +/*CreateLogEntryCreated Returns the entry created in the transparency log + +swagger:response createLogEntryCreated +*/ +type CreateLogEntryCreated struct { + /*URI location of log entry + + */ + Location strfmt.URI `json:"Location"` + + /* + In: Body + */ + Payload models.LogEntry `json:"body,omitempty"` +} + +// NewCreateLogEntryCreated creates CreateLogEntryCreated with default headers values +func NewCreateLogEntryCreated() *CreateLogEntryCreated { + + return &CreateLogEntryCreated{} +} + +// WithLocation adds the location to the create log entry created response +func (o *CreateLogEntryCreated) WithLocation(location strfmt.URI) *CreateLogEntryCreated { + o.Location = location + return o +} + +// SetLocation sets the location to the create log entry created response +func (o *CreateLogEntryCreated) SetLocation(location strfmt.URI) { + o.Location = location +} + +// WithPayload adds the payload to the create log entry created response +func (o *CreateLogEntryCreated) WithPayload(payload models.LogEntry) *CreateLogEntryCreated { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create log entry created response +func (o *CreateLogEntryCreated) SetPayload(payload models.LogEntry) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateLogEntryCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Location + + location := o.Location.String() + if location != "" { + rw.Header().Set("Location", location) + } + + rw.WriteHeader(201) + payload := o.Payload + if payload == nil { + // return empty map + payload = models.LogEntry{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// CreateLogEntryBadRequestCode is the HTTP code returned for type CreateLogEntryBadRequest +const CreateLogEntryBadRequestCode int = 400 + +/*CreateLogEntryBadRequest The content supplied to the server was invalid + +swagger:response createLogEntryBadRequest +*/ +type CreateLogEntryBadRequest struct { + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateLogEntryBadRequest creates CreateLogEntryBadRequest with default headers values +func NewCreateLogEntryBadRequest() *CreateLogEntryBadRequest { + + return &CreateLogEntryBadRequest{} +} + +// WithPayload adds the payload to the create log entry bad request response +func (o *CreateLogEntryBadRequest) WithPayload(payload *models.Error) *CreateLogEntryBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create log entry bad request response +func (o *CreateLogEntryBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateLogEntryBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/*CreateLogEntryDefault There was an internal error in the server while processing the request + +swagger:response createLogEntryDefault +*/ +type CreateLogEntryDefault struct { + _statusCode int + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateLogEntryDefault creates CreateLogEntryDefault with default headers values +func NewCreateLogEntryDefault(code int) *CreateLogEntryDefault { + if code <= 0 { + code = 500 + } + + return &CreateLogEntryDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the create log entry default response +func (o *CreateLogEntryDefault) WithStatusCode(code int) *CreateLogEntryDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the create log entry default response +func (o *CreateLogEntryDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithPayload adds the payload to the create log entry default response +func (o *CreateLogEntryDefault) WithPayload(payload *models.Error) *CreateLogEntryDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create log entry default response +func (o *CreateLogEntryDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateLogEntryDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/pkg/generated/restapi/operations/entries/create_log_entry_urlbuilder.go b/pkg/generated/restapi/operations/entries/create_log_entry_urlbuilder.go new file mode 100644 index 0000000000000000000000000000000000000000..1f6fa22e2a46dd72d3e4fc7db5e508677830a505 --- /dev/null +++ b/pkg/generated/restapi/operations/entries/create_log_entry_urlbuilder.go @@ -0,0 +1,84 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package entries + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" +) + +// CreateLogEntryURL generates an URL for the create log entry operation +type CreateLogEntryURL struct { + _basePath string +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateLogEntryURL) WithBasePath(bp string) *CreateLogEntryURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateLogEntryURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *CreateLogEntryURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/api/v1/log/entries" + + _basePath := o._basePath + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *CreateLogEntryURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *CreateLogEntryURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *CreateLogEntryURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on CreateLogEntryURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on CreateLogEntryURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *CreateLogEntryURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/pkg/generated/restapi/operations/entries/get_log_entry_by_index.go b/pkg/generated/restapi/operations/entries/get_log_entry_by_index.go new file mode 100644 index 0000000000000000000000000000000000000000..36f93b1ecb22651428adc75fa5aaba5c611de58a --- /dev/null +++ b/pkg/generated/restapi/operations/entries/get_log_entry_by_index.go @@ -0,0 +1,58 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package entries + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetLogEntryByIndexHandlerFunc turns a function with the right signature into a get log entry by index handler +type GetLogEntryByIndexHandlerFunc func(GetLogEntryByIndexParams) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetLogEntryByIndexHandlerFunc) Handle(params GetLogEntryByIndexParams) middleware.Responder { + return fn(params) +} + +// GetLogEntryByIndexHandler interface for that can handle valid get log entry by index params +type GetLogEntryByIndexHandler interface { + Handle(GetLogEntryByIndexParams) middleware.Responder +} + +// NewGetLogEntryByIndex creates a new http.Handler for the get log entry by index operation +func NewGetLogEntryByIndex(ctx *middleware.Context, handler GetLogEntryByIndexHandler) *GetLogEntryByIndex { + return &GetLogEntryByIndex{Context: ctx, Handler: handler} +} + +/*GetLogEntryByIndex swagger:route GET /api/v1/log/entries entries getLogEntryByIndex + +Retrieves an entry from the transparency log (if it exists) by index + +*/ +type GetLogEntryByIndex struct { + Context *middleware.Context + Handler GetLogEntryByIndexHandler +} + +func (o *GetLogEntryByIndex) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewGetLogEntryByIndexParams() + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/pkg/generated/restapi/operations/entries/get_log_entry_by_index_parameters.go b/pkg/generated/restapi/operations/entries/get_log_entry_by_index_parameters.go new file mode 100644 index 0000000000000000000000000000000000000000..266d5e66170a9de0edd2e886699e00822e7879d4 --- /dev/null +++ b/pkg/generated/restapi/operations/entries/get_log_entry_by_index_parameters.go @@ -0,0 +1,87 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package entries + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// NewGetLogEntryByIndexParams creates a new GetLogEntryByIndexParams object +// no default values defined in spec. +func NewGetLogEntryByIndexParams() GetLogEntryByIndexParams { + + return GetLogEntryByIndexParams{} +} + +// GetLogEntryByIndexParams contains all the bound params for the get log entry by index operation +// typically these are obtained from a http.Request +// +// swagger:parameters getLogEntryByIndex +type GetLogEntryByIndexParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*specifies the index of the entry in the transparency log to be retrieved + Required: true + In: query + */ + LogIndex int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetLogEntryByIndexParams() beforehand. +func (o *GetLogEntryByIndexParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + qLogIndex, qhkLogIndex, _ := qs.GetOK("logIndex") + if err := o.bindLogIndex(qLogIndex, qhkLogIndex, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindLogIndex binds and validates parameter LogIndex from query. +func (o *GetLogEntryByIndexParams) bindLogIndex(rawData []string, hasKey bool, formats strfmt.Registry) error { + if !hasKey { + return errors.Required("logIndex", "query", rawData) + } + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // AllowEmptyValue: false + if err := validate.RequiredString("logIndex", "query", raw); err != nil { + return err + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("logIndex", "query", "int64", raw) + } + o.LogIndex = value + + return nil +} diff --git a/pkg/generated/restapi/operations/entries/get_log_entry_by_index_responses.go b/pkg/generated/restapi/operations/entries/get_log_entry_by_index_responses.go new file mode 100644 index 0000000000000000000000000000000000000000..2c080213490e2858444c6ea9b184bc6b555ba135 --- /dev/null +++ b/pkg/generated/restapi/operations/entries/get_log_entry_by_index_responses.go @@ -0,0 +1,163 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package entries + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/projectrekor/rekor/pkg/generated/models" +) + +// GetLogEntryByIndexOKCode is the HTTP code returned for type GetLogEntryByIndexOK +const GetLogEntryByIndexOKCode int = 200 + +/*GetLogEntryByIndexOK the entry in the transparency log requested + +swagger:response getLogEntryByIndexOK +*/ +type GetLogEntryByIndexOK struct { + + /* + In: Body + */ + Payload models.LogEntry `json:"body,omitempty"` +} + +// NewGetLogEntryByIndexOK creates GetLogEntryByIndexOK with default headers values +func NewGetLogEntryByIndexOK() *GetLogEntryByIndexOK { + + return &GetLogEntryByIndexOK{} +} + +// WithPayload adds the payload to the get log entry by index o k response +func (o *GetLogEntryByIndexOK) WithPayload(payload models.LogEntry) *GetLogEntryByIndexOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get log entry by index o k response +func (o *GetLogEntryByIndexOK) SetPayload(payload models.LogEntry) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetLogEntryByIndexOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty map + payload = models.LogEntry{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// GetLogEntryByIndexNotFoundCode is the HTTP code returned for type GetLogEntryByIndexNotFound +const GetLogEntryByIndexNotFoundCode int = 404 + +/*GetLogEntryByIndexNotFound The content requested could not be found + +swagger:response getLogEntryByIndexNotFound +*/ +type GetLogEntryByIndexNotFound struct { + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetLogEntryByIndexNotFound creates GetLogEntryByIndexNotFound with default headers values +func NewGetLogEntryByIndexNotFound() *GetLogEntryByIndexNotFound { + + return &GetLogEntryByIndexNotFound{} +} + +// WithPayload adds the payload to the get log entry by index not found response +func (o *GetLogEntryByIndexNotFound) WithPayload(payload *models.Error) *GetLogEntryByIndexNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get log entry by index not found response +func (o *GetLogEntryByIndexNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetLogEntryByIndexNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/*GetLogEntryByIndexDefault There was an internal error in the server while processing the request + +swagger:response getLogEntryByIndexDefault +*/ +type GetLogEntryByIndexDefault struct { + _statusCode int + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetLogEntryByIndexDefault creates GetLogEntryByIndexDefault with default headers values +func NewGetLogEntryByIndexDefault(code int) *GetLogEntryByIndexDefault { + if code <= 0 { + code = 500 + } + + return &GetLogEntryByIndexDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get log entry by index default response +func (o *GetLogEntryByIndexDefault) WithStatusCode(code int) *GetLogEntryByIndexDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get log entry by index default response +func (o *GetLogEntryByIndexDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithPayload adds the payload to the get log entry by index default response +func (o *GetLogEntryByIndexDefault) WithPayload(payload *models.Error) *GetLogEntryByIndexDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get log entry by index default response +func (o *GetLogEntryByIndexDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetLogEntryByIndexDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/pkg/generated/restapi/operations/entries/get_log_entry_by_index_urlbuilder.go b/pkg/generated/restapi/operations/entries/get_log_entry_by_index_urlbuilder.go new file mode 100644 index 0000000000000000000000000000000000000000..f331a7724301668ec51df7c7981c28711725270d --- /dev/null +++ b/pkg/generated/restapi/operations/entries/get_log_entry_by_index_urlbuilder.go @@ -0,0 +1,99 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package entries + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + + "github.com/go-openapi/swag" +) + +// GetLogEntryByIndexURL generates an URL for the get log entry by index operation +type GetLogEntryByIndexURL struct { + LogIndex int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetLogEntryByIndexURL) WithBasePath(bp string) *GetLogEntryByIndexURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetLogEntryByIndexURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetLogEntryByIndexURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/api/v1/log/entries" + + _basePath := o._basePath + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + logIndexQ := swag.FormatInt64(o.LogIndex) + if logIndexQ != "" { + qs.Set("logIndex", logIndexQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetLogEntryByIndexURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetLogEntryByIndexURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetLogEntryByIndexURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetLogEntryByIndexURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetLogEntryByIndexURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetLogEntryByIndexURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/pkg/generated/restapi/operations/entries/get_log_entry_by_uuid.go b/pkg/generated/restapi/operations/entries/get_log_entry_by_uuid.go new file mode 100644 index 0000000000000000000000000000000000000000..91b83564647d6b34e17c4fff6424997e5dc24081 --- /dev/null +++ b/pkg/generated/restapi/operations/entries/get_log_entry_by_uuid.go @@ -0,0 +1,58 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package entries + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetLogEntryByUUIDHandlerFunc turns a function with the right signature into a get log entry by UUID handler +type GetLogEntryByUUIDHandlerFunc func(GetLogEntryByUUIDParams) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetLogEntryByUUIDHandlerFunc) Handle(params GetLogEntryByUUIDParams) middleware.Responder { + return fn(params) +} + +// GetLogEntryByUUIDHandler interface for that can handle valid get log entry by UUID params +type GetLogEntryByUUIDHandler interface { + Handle(GetLogEntryByUUIDParams) middleware.Responder +} + +// NewGetLogEntryByUUID creates a new http.Handler for the get log entry by UUID operation +func NewGetLogEntryByUUID(ctx *middleware.Context, handler GetLogEntryByUUIDHandler) *GetLogEntryByUUID { + return &GetLogEntryByUUID{Context: ctx, Handler: handler} +} + +/*GetLogEntryByUUID swagger:route GET /api/v1/log/entries/{entryUUID} entries getLogEntryByUuid + +Retrieves an entry from the transparency log (if it exists) by UUID + +*/ +type GetLogEntryByUUID struct { + Context *middleware.Context + Handler GetLogEntryByUUIDHandler +} + +func (o *GetLogEntryByUUID) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewGetLogEntryByUUIDParams() + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/pkg/generated/restapi/operations/entries/get_log_entry_by_uuid_parameters.go b/pkg/generated/restapi/operations/entries/get_log_entry_by_uuid_parameters.go new file mode 100644 index 0000000000000000000000000000000000000000..d63c07a6c00eb99ccdc6124c416dde0ce8daf7f6 --- /dev/null +++ b/pkg/generated/restapi/operations/entries/get_log_entry_by_uuid_parameters.go @@ -0,0 +1,72 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package entries + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" +) + +// NewGetLogEntryByUUIDParams creates a new GetLogEntryByUUIDParams object +// no default values defined in spec. +func NewGetLogEntryByUUIDParams() GetLogEntryByUUIDParams { + + return GetLogEntryByUUIDParams{} +} + +// GetLogEntryByUUIDParams contains all the bound params for the get log entry by UUID operation +// typically these are obtained from a http.Request +// +// swagger:parameters getLogEntryByUUID +type GetLogEntryByUUIDParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*the UUID of the entry to be retrieved from the log. The UUID is also the merkle tree hash of the entry. + Required: true + In: path + */ + EntryUUID string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetLogEntryByUUIDParams() beforehand. +func (o *GetLogEntryByUUIDParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + rEntryUUID, rhkEntryUUID, _ := route.Params.GetOK("entryUUID") + if err := o.bindEntryUUID(rEntryUUID, rhkEntryUUID, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindEntryUUID binds and validates parameter EntryUUID from path. +func (o *GetLogEntryByUUIDParams) bindEntryUUID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + o.EntryUUID = raw + + return nil +} diff --git a/pkg/generated/restapi/operations/entries/get_log_entry_by_uuid_responses.go b/pkg/generated/restapi/operations/entries/get_log_entry_by_uuid_responses.go new file mode 100644 index 0000000000000000000000000000000000000000..d61d6d59b7491cedc10cc256ada457050305df0a --- /dev/null +++ b/pkg/generated/restapi/operations/entries/get_log_entry_by_uuid_responses.go @@ -0,0 +1,163 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package entries + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/projectrekor/rekor/pkg/generated/models" +) + +// GetLogEntryByUUIDOKCode is the HTTP code returned for type GetLogEntryByUUIDOK +const GetLogEntryByUUIDOKCode int = 200 + +/*GetLogEntryByUUIDOK the entry in the transparency log requested + +swagger:response getLogEntryByUuidOK +*/ +type GetLogEntryByUUIDOK struct { + + /* + In: Body + */ + Payload models.LogEntry `json:"body,omitempty"` +} + +// NewGetLogEntryByUUIDOK creates GetLogEntryByUUIDOK with default headers values +func NewGetLogEntryByUUIDOK() *GetLogEntryByUUIDOK { + + return &GetLogEntryByUUIDOK{} +} + +// WithPayload adds the payload to the get log entry by Uuid o k response +func (o *GetLogEntryByUUIDOK) WithPayload(payload models.LogEntry) *GetLogEntryByUUIDOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get log entry by Uuid o k response +func (o *GetLogEntryByUUIDOK) SetPayload(payload models.LogEntry) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetLogEntryByUUIDOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty map + payload = models.LogEntry{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// GetLogEntryByUUIDNotFoundCode is the HTTP code returned for type GetLogEntryByUUIDNotFound +const GetLogEntryByUUIDNotFoundCode int = 404 + +/*GetLogEntryByUUIDNotFound The content requested could not be found + +swagger:response getLogEntryByUuidNotFound +*/ +type GetLogEntryByUUIDNotFound struct { + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetLogEntryByUUIDNotFound creates GetLogEntryByUUIDNotFound with default headers values +func NewGetLogEntryByUUIDNotFound() *GetLogEntryByUUIDNotFound { + + return &GetLogEntryByUUIDNotFound{} +} + +// WithPayload adds the payload to the get log entry by Uuid not found response +func (o *GetLogEntryByUUIDNotFound) WithPayload(payload *models.Error) *GetLogEntryByUUIDNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get log entry by Uuid not found response +func (o *GetLogEntryByUUIDNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetLogEntryByUUIDNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/*GetLogEntryByUUIDDefault There was an internal error in the server while processing the request + +swagger:response getLogEntryByUuidDefault +*/ +type GetLogEntryByUUIDDefault struct { + _statusCode int + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetLogEntryByUUIDDefault creates GetLogEntryByUUIDDefault with default headers values +func NewGetLogEntryByUUIDDefault(code int) *GetLogEntryByUUIDDefault { + if code <= 0 { + code = 500 + } + + return &GetLogEntryByUUIDDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get log entry by UUID default response +func (o *GetLogEntryByUUIDDefault) WithStatusCode(code int) *GetLogEntryByUUIDDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get log entry by UUID default response +func (o *GetLogEntryByUUIDDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithPayload adds the payload to the get log entry by UUID default response +func (o *GetLogEntryByUUIDDefault) WithPayload(payload *models.Error) *GetLogEntryByUUIDDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get log entry by UUID default response +func (o *GetLogEntryByUUIDDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetLogEntryByUUIDDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/pkg/generated/restapi/operations/entries/get_log_entry_by_uuid_urlbuilder.go b/pkg/generated/restapi/operations/entries/get_log_entry_by_uuid_urlbuilder.go new file mode 100644 index 0000000000000000000000000000000000000000..1848618083e8f90a82118259aad9086e2e6ef671 --- /dev/null +++ b/pkg/generated/restapi/operations/entries/get_log_entry_by_uuid_urlbuilder.go @@ -0,0 +1,96 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package entries + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// GetLogEntryByUUIDURL generates an URL for the get log entry by UUID operation +type GetLogEntryByUUIDURL struct { + EntryUUID string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetLogEntryByUUIDURL) WithBasePath(bp string) *GetLogEntryByUUIDURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetLogEntryByUUIDURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetLogEntryByUUIDURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/api/v1/log/entries/{entryUUID}" + + entryUUID := o.EntryUUID + if entryUUID != "" { + _path = strings.Replace(_path, "{entryUUID}", entryUUID, -1) + } else { + return nil, errors.New("entryUuid is required on GetLogEntryByUUIDURL") + } + + _basePath := o._basePath + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetLogEntryByUUIDURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetLogEntryByUUIDURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetLogEntryByUUIDURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetLogEntryByUUIDURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetLogEntryByUUIDURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetLogEntryByUUIDURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/pkg/generated/restapi/operations/entries/get_log_entry_proof.go b/pkg/generated/restapi/operations/entries/get_log_entry_proof.go new file mode 100644 index 0000000000000000000000000000000000000000..aee2bd29e7662c44ddc16769f81bbe7741f071de --- /dev/null +++ b/pkg/generated/restapi/operations/entries/get_log_entry_proof.go @@ -0,0 +1,60 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package entries + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetLogEntryProofHandlerFunc turns a function with the right signature into a get log entry proof handler +type GetLogEntryProofHandlerFunc func(GetLogEntryProofParams) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetLogEntryProofHandlerFunc) Handle(params GetLogEntryProofParams) middleware.Responder { + return fn(params) +} + +// GetLogEntryProofHandler interface for that can handle valid get log entry proof params +type GetLogEntryProofHandler interface { + Handle(GetLogEntryProofParams) middleware.Responder +} + +// NewGetLogEntryProof creates a new http.Handler for the get log entry proof operation +func NewGetLogEntryProof(ctx *middleware.Context, handler GetLogEntryProofHandler) *GetLogEntryProof { + return &GetLogEntryProof{Context: ctx, Handler: handler} +} + +/*GetLogEntryProof swagger:route GET /api/v1/log/entries/{entryUUID}/proof entries getLogEntryProof + +Get information required to generate an inclusion proof for a specified entry in the transparency log + +Returns root hash, tree size, and a list of hashes that can be used to calculate proof of an entry being included in the transparency log + +*/ +type GetLogEntryProof struct { + Context *middleware.Context + Handler GetLogEntryProofHandler +} + +func (o *GetLogEntryProof) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewGetLogEntryProofParams() + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/pkg/generated/restapi/operations/entries/get_log_entry_proof_parameters.go b/pkg/generated/restapi/operations/entries/get_log_entry_proof_parameters.go new file mode 100644 index 0000000000000000000000000000000000000000..f850062dfd037a265635db123fb1a3732a160a88 --- /dev/null +++ b/pkg/generated/restapi/operations/entries/get_log_entry_proof_parameters.go @@ -0,0 +1,72 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package entries + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" +) + +// NewGetLogEntryProofParams creates a new GetLogEntryProofParams object +// no default values defined in spec. +func NewGetLogEntryProofParams() GetLogEntryProofParams { + + return GetLogEntryProofParams{} +} + +// GetLogEntryProofParams contains all the bound params for the get log entry proof operation +// typically these are obtained from a http.Request +// +// swagger:parameters getLogEntryProof +type GetLogEntryProofParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*the UUID of the entry for which the inclusion proof information should be returned + Required: true + In: path + */ + EntryUUID string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetLogEntryProofParams() beforehand. +func (o *GetLogEntryProofParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + rEntryUUID, rhkEntryUUID, _ := route.Params.GetOK("entryUUID") + if err := o.bindEntryUUID(rEntryUUID, rhkEntryUUID, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindEntryUUID binds and validates parameter EntryUUID from path. +func (o *GetLogEntryProofParams) bindEntryUUID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + o.EntryUUID = raw + + return nil +} diff --git a/pkg/generated/restapi/operations/entries/get_log_entry_proof_responses.go b/pkg/generated/restapi/operations/entries/get_log_entry_proof_responses.go new file mode 100644 index 0000000000000000000000000000000000000000..f649382626dabe715fa91f6b6c3b7b879db88ed7 --- /dev/null +++ b/pkg/generated/restapi/operations/entries/get_log_entry_proof_responses.go @@ -0,0 +1,160 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package entries + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/projectrekor/rekor/pkg/generated/models" +) + +// GetLogEntryProofOKCode is the HTTP code returned for type GetLogEntryProofOK +const GetLogEntryProofOKCode int = 200 + +/*GetLogEntryProofOK Information needed for a client to compute the inclusion proof + +swagger:response getLogEntryProofOK +*/ +type GetLogEntryProofOK struct { + + /* + In: Body + */ + Payload *models.InclusionProof `json:"body,omitempty"` +} + +// NewGetLogEntryProofOK creates GetLogEntryProofOK with default headers values +func NewGetLogEntryProofOK() *GetLogEntryProofOK { + + return &GetLogEntryProofOK{} +} + +// WithPayload adds the payload to the get log entry proof o k response +func (o *GetLogEntryProofOK) WithPayload(payload *models.InclusionProof) *GetLogEntryProofOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get log entry proof o k response +func (o *GetLogEntryProofOK) SetPayload(payload *models.InclusionProof) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetLogEntryProofOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetLogEntryProofNotFoundCode is the HTTP code returned for type GetLogEntryProofNotFound +const GetLogEntryProofNotFoundCode int = 404 + +/*GetLogEntryProofNotFound The content requested could not be found + +swagger:response getLogEntryProofNotFound +*/ +type GetLogEntryProofNotFound struct { + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetLogEntryProofNotFound creates GetLogEntryProofNotFound with default headers values +func NewGetLogEntryProofNotFound() *GetLogEntryProofNotFound { + + return &GetLogEntryProofNotFound{} +} + +// WithPayload adds the payload to the get log entry proof not found response +func (o *GetLogEntryProofNotFound) WithPayload(payload *models.Error) *GetLogEntryProofNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get log entry proof not found response +func (o *GetLogEntryProofNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetLogEntryProofNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/*GetLogEntryProofDefault There was an internal error in the server while processing the request + +swagger:response getLogEntryProofDefault +*/ +type GetLogEntryProofDefault struct { + _statusCode int + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetLogEntryProofDefault creates GetLogEntryProofDefault with default headers values +func NewGetLogEntryProofDefault(code int) *GetLogEntryProofDefault { + if code <= 0 { + code = 500 + } + + return &GetLogEntryProofDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get log entry proof default response +func (o *GetLogEntryProofDefault) WithStatusCode(code int) *GetLogEntryProofDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get log entry proof default response +func (o *GetLogEntryProofDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithPayload adds the payload to the get log entry proof default response +func (o *GetLogEntryProofDefault) WithPayload(payload *models.Error) *GetLogEntryProofDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get log entry proof default response +func (o *GetLogEntryProofDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetLogEntryProofDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/pkg/generated/restapi/operations/entries/get_log_entry_proof_urlbuilder.go b/pkg/generated/restapi/operations/entries/get_log_entry_proof_urlbuilder.go new file mode 100644 index 0000000000000000000000000000000000000000..98ba67de4ff43d9ba4f488829d471bd3a86b53b7 --- /dev/null +++ b/pkg/generated/restapi/operations/entries/get_log_entry_proof_urlbuilder.go @@ -0,0 +1,96 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package entries + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// GetLogEntryProofURL generates an URL for the get log entry proof operation +type GetLogEntryProofURL struct { + EntryUUID string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetLogEntryProofURL) WithBasePath(bp string) *GetLogEntryProofURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetLogEntryProofURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetLogEntryProofURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/api/v1/log/entries/{entryUUID}/proof" + + entryUUID := o.EntryUUID + if entryUUID != "" { + _path = strings.Replace(_path, "{entryUUID}", entryUUID, -1) + } else { + return nil, errors.New("entryUuid is required on GetLogEntryProofURL") + } + + _basePath := o._basePath + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetLogEntryProofURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetLogEntryProofURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetLogEntryProofURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetLogEntryProofURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetLogEntryProofURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetLogEntryProofURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/pkg/generated/restapi/operations/entries/search_log_query.go b/pkg/generated/restapi/operations/entries/search_log_query.go new file mode 100644 index 0000000000000000000000000000000000000000..744c69d461deb84ec8cff70c54de70e5d7d303e8 --- /dev/null +++ b/pkg/generated/restapi/operations/entries/search_log_query.go @@ -0,0 +1,58 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package entries + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// SearchLogQueryHandlerFunc turns a function with the right signature into a search log query handler +type SearchLogQueryHandlerFunc func(SearchLogQueryParams) middleware.Responder + +// Handle executing the request and returning a response +func (fn SearchLogQueryHandlerFunc) Handle(params SearchLogQueryParams) middleware.Responder { + return fn(params) +} + +// SearchLogQueryHandler interface for that can handle valid search log query params +type SearchLogQueryHandler interface { + Handle(SearchLogQueryParams) middleware.Responder +} + +// NewSearchLogQuery creates a new http.Handler for the search log query operation +func NewSearchLogQuery(ctx *middleware.Context, handler SearchLogQueryHandler) *SearchLogQuery { + return &SearchLogQuery{Context: ctx, Handler: handler} +} + +/*SearchLogQuery swagger:route POST /api/v1/log/entries/retrieve entries searchLogQuery + +Searches transparency log for one or more log entries + +*/ +type SearchLogQuery struct { + Context *middleware.Context + Handler SearchLogQueryHandler +} + +func (o *SearchLogQuery) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewSearchLogQueryParams() + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/pkg/generated/restapi/operations/entries/search_log_query_parameters.go b/pkg/generated/restapi/operations/entries/search_log_query_parameters.go new file mode 100644 index 0000000000000000000000000000000000000000..edcddbabace489132623f56de7ccce9a8f9a0d07 --- /dev/null +++ b/pkg/generated/restapi/operations/entries/search_log_query_parameters.go @@ -0,0 +1,77 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package entries + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + + "github.com/projectrekor/rekor/pkg/generated/models" +) + +// NewSearchLogQueryParams creates a new SearchLogQueryParams object +// no default values defined in spec. +func NewSearchLogQueryParams() SearchLogQueryParams { + + return SearchLogQueryParams{} +} + +// SearchLogQueryParams contains all the bound params for the search log query operation +// typically these are obtained from a http.Request +// +// swagger:parameters searchLogQuery +type SearchLogQueryParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Entry *models.SearchLogQuery +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewSearchLogQueryParams() beforehand. +func (o *SearchLogQueryParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.SearchLogQuery + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("entry", "body", "")) + } else { + res = append(res, errors.NewParseError("entry", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Entry = &body + } + } + } else { + res = append(res, errors.Required("entry", "body", "")) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/pkg/generated/restapi/operations/entries/search_log_query_responses.go b/pkg/generated/restapi/operations/entries/search_log_query_responses.go new file mode 100644 index 0000000000000000000000000000000000000000..6857ce8153bfd06a665021c79576d8a40e72e584 --- /dev/null +++ b/pkg/generated/restapi/operations/entries/search_log_query_responses.go @@ -0,0 +1,119 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package entries + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/projectrekor/rekor/pkg/generated/models" +) + +// SearchLogQueryOKCode is the HTTP code returned for type SearchLogQueryOK +const SearchLogQueryOKCode int = 200 + +/*SearchLogQueryOK Returns zero or more entries from the transparency log, according to how many were included in request query + +swagger:response searchLogQueryOK +*/ +type SearchLogQueryOK struct { + + /* + In: Body + */ + Payload []models.LogEntry `json:"body,omitempty"` +} + +// NewSearchLogQueryOK creates SearchLogQueryOK with default headers values +func NewSearchLogQueryOK() *SearchLogQueryOK { + + return &SearchLogQueryOK{} +} + +// WithPayload adds the payload to the search log query o k response +func (o *SearchLogQueryOK) WithPayload(payload []models.LogEntry) *SearchLogQueryOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the search log query o k response +func (o *SearchLogQueryOK) SetPayload(payload []models.LogEntry) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *SearchLogQueryOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = make([]models.LogEntry, 0, 50) + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +/*SearchLogQueryDefault There was an internal error in the server while processing the request + +swagger:response searchLogQueryDefault +*/ +type SearchLogQueryDefault struct { + _statusCode int + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewSearchLogQueryDefault creates SearchLogQueryDefault with default headers values +func NewSearchLogQueryDefault(code int) *SearchLogQueryDefault { + if code <= 0 { + code = 500 + } + + return &SearchLogQueryDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the search log query default response +func (o *SearchLogQueryDefault) WithStatusCode(code int) *SearchLogQueryDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the search log query default response +func (o *SearchLogQueryDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithPayload adds the payload to the search log query default response +func (o *SearchLogQueryDefault) WithPayload(payload *models.Error) *SearchLogQueryDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the search log query default response +func (o *SearchLogQueryDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *SearchLogQueryDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/pkg/generated/restapi/operations/entries/search_log_query_urlbuilder.go b/pkg/generated/restapi/operations/entries/search_log_query_urlbuilder.go new file mode 100644 index 0000000000000000000000000000000000000000..d0d92d4b133d699ddde55a895b0b3974e0d0240a --- /dev/null +++ b/pkg/generated/restapi/operations/entries/search_log_query_urlbuilder.go @@ -0,0 +1,84 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package entries + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" +) + +// SearchLogQueryURL generates an URL for the search log query operation +type SearchLogQueryURL struct { + _basePath string +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *SearchLogQueryURL) WithBasePath(bp string) *SearchLogQueryURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *SearchLogQueryURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *SearchLogQueryURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/api/v1/log/entries/retrieve" + + _basePath := o._basePath + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *SearchLogQueryURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *SearchLogQueryURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *SearchLogQueryURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on SearchLogQueryURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on SearchLogQueryURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *SearchLogQueryURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/pkg/generated/restapi/operations/rekor_server_api.go b/pkg/generated/restapi/operations/rekor_server_api.go new file mode 100644 index 0000000000000000000000000000000000000000..53d504de7f09a36f5d22a24f7b2b589f80b2d037 --- /dev/null +++ b/pkg/generated/restapi/operations/rekor_server_api.go @@ -0,0 +1,373 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package operations + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "net/http" + "strings" + + "github.com/go-openapi/errors" + "github.com/go-openapi/loads" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/runtime/security" + "github.com/go-openapi/spec" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/projectrekor/rekor/pkg/generated/restapi/operations/entries" + "github.com/projectrekor/rekor/pkg/generated/restapi/operations/tlog" +) + +// NewRekorServerAPI creates a new RekorServer instance +func NewRekorServerAPI(spec *loads.Document) *RekorServerAPI { + return &RekorServerAPI{ + handlers: make(map[string]map[string]http.Handler), + formats: strfmt.Default, + defaultConsumes: "application/json", + defaultProduces: "application/json", + customConsumers: make(map[string]runtime.Consumer), + customProducers: make(map[string]runtime.Producer), + PreServerShutdown: func() {}, + ServerShutdown: func() {}, + spec: spec, + useSwaggerUI: false, + ServeError: errors.ServeError, + BasicAuthenticator: security.BasicAuth, + APIKeyAuthenticator: security.APIKeyAuth, + BearerAuthenticator: security.BearerAuth, + + JSONConsumer: runtime.JSONConsumer(), + + JSONProducer: runtime.JSONProducer(), + + EntriesCreateLogEntryHandler: entries.CreateLogEntryHandlerFunc(func(params entries.CreateLogEntryParams) middleware.Responder { + return middleware.NotImplemented("operation entries.CreateLogEntry has not yet been implemented") + }), + EntriesGetLogEntryByIndexHandler: entries.GetLogEntryByIndexHandlerFunc(func(params entries.GetLogEntryByIndexParams) middleware.Responder { + return middleware.NotImplemented("operation entries.GetLogEntryByIndex has not yet been implemented") + }), + EntriesGetLogEntryByUUIDHandler: entries.GetLogEntryByUUIDHandlerFunc(func(params entries.GetLogEntryByUUIDParams) middleware.Responder { + return middleware.NotImplemented("operation entries.GetLogEntryByUUID has not yet been implemented") + }), + EntriesGetLogEntryProofHandler: entries.GetLogEntryProofHandlerFunc(func(params entries.GetLogEntryProofParams) middleware.Responder { + return middleware.NotImplemented("operation entries.GetLogEntryProof has not yet been implemented") + }), + TlogGetLogInfoHandler: tlog.GetLogInfoHandlerFunc(func(params tlog.GetLogInfoParams) middleware.Responder { + return middleware.NotImplemented("operation tlog.GetLogInfo has not yet been implemented") + }), + TlogGetLogProofHandler: tlog.GetLogProofHandlerFunc(func(params tlog.GetLogProofParams) middleware.Responder { + return middleware.NotImplemented("operation tlog.GetLogProof has not yet been implemented") + }), + EntriesSearchLogQueryHandler: entries.SearchLogQueryHandlerFunc(func(params entries.SearchLogQueryParams) middleware.Responder { + return middleware.NotImplemented("operation entries.SearchLogQuery has not yet been implemented") + }), + } +} + +/*RekorServerAPI Rekor is a cryptographically secure, immutable transparency log for signed software releases. */ +type RekorServerAPI struct { + spec *loads.Document + context *middleware.Context + handlers map[string]map[string]http.Handler + formats strfmt.Registry + customConsumers map[string]runtime.Consumer + customProducers map[string]runtime.Producer + defaultConsumes string + defaultProduces string + Middleware func(middleware.Builder) http.Handler + useSwaggerUI bool + + // BasicAuthenticator generates a runtime.Authenticator from the supplied basic auth function. + // It has a default implementation in the security package, however you can replace it for your particular usage. + BasicAuthenticator func(security.UserPassAuthentication) runtime.Authenticator + // APIKeyAuthenticator generates a runtime.Authenticator from the supplied token auth function. + // It has a default implementation in the security package, however you can replace it for your particular usage. + APIKeyAuthenticator func(string, string, security.TokenAuthentication) runtime.Authenticator + // BearerAuthenticator generates a runtime.Authenticator from the supplied bearer token auth function. + // It has a default implementation in the security package, however you can replace it for your particular usage. + BearerAuthenticator func(string, security.ScopedTokenAuthentication) runtime.Authenticator + + // JSONConsumer registers a consumer for the following mime types: + // - application/json + JSONConsumer runtime.Consumer + + // JSONProducer registers a producer for the following mime types: + // - application/json + JSONProducer runtime.Producer + + // EntriesCreateLogEntryHandler sets the operation handler for the create log entry operation + EntriesCreateLogEntryHandler entries.CreateLogEntryHandler + // EntriesGetLogEntryByIndexHandler sets the operation handler for the get log entry by index operation + EntriesGetLogEntryByIndexHandler entries.GetLogEntryByIndexHandler + // EntriesGetLogEntryByUUIDHandler sets the operation handler for the get log entry by UUID operation + EntriesGetLogEntryByUUIDHandler entries.GetLogEntryByUUIDHandler + // EntriesGetLogEntryProofHandler sets the operation handler for the get log entry proof operation + EntriesGetLogEntryProofHandler entries.GetLogEntryProofHandler + // TlogGetLogInfoHandler sets the operation handler for the get log info operation + TlogGetLogInfoHandler tlog.GetLogInfoHandler + // TlogGetLogProofHandler sets the operation handler for the get log proof operation + TlogGetLogProofHandler tlog.GetLogProofHandler + // EntriesSearchLogQueryHandler sets the operation handler for the search log query operation + EntriesSearchLogQueryHandler entries.SearchLogQueryHandler + // ServeError is called when an error is received, there is a default handler + // but you can set your own with this + ServeError func(http.ResponseWriter, *http.Request, error) + + // PreServerShutdown is called before the HTTP(S) server is shutdown + // This allows for custom functions to get executed before the HTTP(S) server stops accepting traffic + PreServerShutdown func() + + // ServerShutdown is called when the HTTP(S) server is shut down and done + // handling all active connections and does not accept connections any more + ServerShutdown func() + + // Custom command line argument groups with their descriptions + CommandLineOptionsGroups []swag.CommandLineOptionsGroup + + // User defined logger function. + Logger func(string, ...interface{}) +} + +// UseRedoc for documentation at /docs +func (o *RekorServerAPI) UseRedoc() { + o.useSwaggerUI = false +} + +// UseSwaggerUI for documentation at /docs +func (o *RekorServerAPI) UseSwaggerUI() { + o.useSwaggerUI = true +} + +// SetDefaultProduces sets the default produces media type +func (o *RekorServerAPI) SetDefaultProduces(mediaType string) { + o.defaultProduces = mediaType +} + +// SetDefaultConsumes returns the default consumes media type +func (o *RekorServerAPI) SetDefaultConsumes(mediaType string) { + o.defaultConsumes = mediaType +} + +// SetSpec sets a spec that will be served for the clients. +func (o *RekorServerAPI) SetSpec(spec *loads.Document) { + o.spec = spec +} + +// DefaultProduces returns the default produces media type +func (o *RekorServerAPI) DefaultProduces() string { + return o.defaultProduces +} + +// DefaultConsumes returns the default consumes media type +func (o *RekorServerAPI) DefaultConsumes() string { + return o.defaultConsumes +} + +// Formats returns the registered string formats +func (o *RekorServerAPI) Formats() strfmt.Registry { + return o.formats +} + +// RegisterFormat registers a custom format validator +func (o *RekorServerAPI) RegisterFormat(name string, format strfmt.Format, validator strfmt.Validator) { + o.formats.Add(name, format, validator) +} + +// Validate validates the registrations in the RekorServerAPI +func (o *RekorServerAPI) Validate() error { + var unregistered []string + + if o.JSONConsumer == nil { + unregistered = append(unregistered, "JSONConsumer") + } + + if o.JSONProducer == nil { + unregistered = append(unregistered, "JSONProducer") + } + + if o.EntriesCreateLogEntryHandler == nil { + unregistered = append(unregistered, "entries.CreateLogEntryHandler") + } + if o.EntriesGetLogEntryByIndexHandler == nil { + unregistered = append(unregistered, "entries.GetLogEntryByIndexHandler") + } + if o.EntriesGetLogEntryByUUIDHandler == nil { + unregistered = append(unregistered, "entries.GetLogEntryByUUIDHandler") + } + if o.EntriesGetLogEntryProofHandler == nil { + unregistered = append(unregistered, "entries.GetLogEntryProofHandler") + } + if o.TlogGetLogInfoHandler == nil { + unregistered = append(unregistered, "tlog.GetLogInfoHandler") + } + if o.TlogGetLogProofHandler == nil { + unregistered = append(unregistered, "tlog.GetLogProofHandler") + } + if o.EntriesSearchLogQueryHandler == nil { + unregistered = append(unregistered, "entries.SearchLogQueryHandler") + } + + if len(unregistered) > 0 { + return fmt.Errorf("missing registration: %s", strings.Join(unregistered, ", ")) + } + + return nil +} + +// ServeErrorFor gets a error handler for a given operation id +func (o *RekorServerAPI) ServeErrorFor(operationID string) func(http.ResponseWriter, *http.Request, error) { + return o.ServeError +} + +// AuthenticatorsFor gets the authenticators for the specified security schemes +func (o *RekorServerAPI) AuthenticatorsFor(schemes map[string]spec.SecurityScheme) map[string]runtime.Authenticator { + return nil +} + +// Authorizer returns the registered authorizer +func (o *RekorServerAPI) Authorizer() runtime.Authorizer { + return nil +} + +// ConsumersFor gets the consumers for the specified media types. +// MIME type parameters are ignored here. +func (o *RekorServerAPI) ConsumersFor(mediaTypes []string) map[string]runtime.Consumer { + result := make(map[string]runtime.Consumer, len(mediaTypes)) + for _, mt := range mediaTypes { + switch mt { + case "application/json": + result["application/json"] = o.JSONConsumer + } + + if c, ok := o.customConsumers[mt]; ok { + result[mt] = c + } + } + return result +} + +// ProducersFor gets the producers for the specified media types. +// MIME type parameters are ignored here. +func (o *RekorServerAPI) ProducersFor(mediaTypes []string) map[string]runtime.Producer { + result := make(map[string]runtime.Producer, len(mediaTypes)) + for _, mt := range mediaTypes { + switch mt { + case "application/json": + result["application/json"] = o.JSONProducer + } + + if p, ok := o.customProducers[mt]; ok { + result[mt] = p + } + } + return result +} + +// HandlerFor gets a http.Handler for the provided operation method and path +func (o *RekorServerAPI) HandlerFor(method, path string) (http.Handler, bool) { + if o.handlers == nil { + return nil, false + } + um := strings.ToUpper(method) + if _, ok := o.handlers[um]; !ok { + return nil, false + } + if path == "/" { + path = "" + } + h, ok := o.handlers[um][path] + return h, ok +} + +// Context returns the middleware context for the rekor server API +func (o *RekorServerAPI) Context() *middleware.Context { + if o.context == nil { + o.context = middleware.NewRoutableContext(o.spec, o, nil) + } + + return o.context +} + +func (o *RekorServerAPI) initHandlerCache() { + o.Context() // don't care about the result, just that the initialization happened + if o.handlers == nil { + o.handlers = make(map[string]map[string]http.Handler) + } + + if o.handlers["POST"] == nil { + o.handlers["POST"] = make(map[string]http.Handler) + } + o.handlers["POST"]["/api/v1/log/entries"] = entries.NewCreateLogEntry(o.context, o.EntriesCreateLogEntryHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/api/v1/log/entries"] = entries.NewGetLogEntryByIndex(o.context, o.EntriesGetLogEntryByIndexHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/api/v1/log/entries/{entryUUID}"] = entries.NewGetLogEntryByUUID(o.context, o.EntriesGetLogEntryByUUIDHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/api/v1/log/entries/{entryUUID}/proof"] = entries.NewGetLogEntryProof(o.context, o.EntriesGetLogEntryProofHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/api/v1/log"] = tlog.NewGetLogInfo(o.context, o.TlogGetLogInfoHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/api/v1/log/proof"] = tlog.NewGetLogProof(o.context, o.TlogGetLogProofHandler) + if o.handlers["POST"] == nil { + o.handlers["POST"] = make(map[string]http.Handler) + } + o.handlers["POST"]["/api/v1/log/entries/retrieve"] = entries.NewSearchLogQuery(o.context, o.EntriesSearchLogQueryHandler) +} + +// Serve creates a http handler to serve the API over HTTP +// can be used directly in http.ListenAndServe(":8000", api.Serve(nil)) +func (o *RekorServerAPI) Serve(builder middleware.Builder) http.Handler { + o.Init() + + if o.Middleware != nil { + return o.Middleware(builder) + } + if o.useSwaggerUI { + return o.context.APIHandlerSwaggerUI(builder) + } + return o.context.APIHandler(builder) +} + +// Init allows you to just initialize the handler cache, you can then recompose the middleware as you see fit +func (o *RekorServerAPI) Init() { + if len(o.handlers) == 0 { + o.initHandlerCache() + } +} + +// RegisterConsumer allows you to add (or override) a consumer for a media type. +func (o *RekorServerAPI) RegisterConsumer(mediaType string, consumer runtime.Consumer) { + o.customConsumers[mediaType] = consumer +} + +// RegisterProducer allows you to add (or override) a producer for a media type. +func (o *RekorServerAPI) RegisterProducer(mediaType string, producer runtime.Producer) { + o.customProducers[mediaType] = producer +} + +// AddMiddlewareFor adds a http middleware to existing handler +func (o *RekorServerAPI) AddMiddlewareFor(method, path string, builder middleware.Builder) { + um := strings.ToUpper(method) + if path == "/" { + path = "" + } + o.Init() + if h, ok := o.handlers[um][path]; ok { + o.handlers[method][path] = builder(h) + } +} diff --git a/pkg/generated/restapi/operations/tlog/get_log_info.go b/pkg/generated/restapi/operations/tlog/get_log_info.go new file mode 100644 index 0000000000000000000000000000000000000000..1b1b68753f2c651163067759007f731ac1ffaa35 --- /dev/null +++ b/pkg/generated/restapi/operations/tlog/get_log_info.go @@ -0,0 +1,60 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package tlog + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetLogInfoHandlerFunc turns a function with the right signature into a get log info handler +type GetLogInfoHandlerFunc func(GetLogInfoParams) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetLogInfoHandlerFunc) Handle(params GetLogInfoParams) middleware.Responder { + return fn(params) +} + +// GetLogInfoHandler interface for that can handle valid get log info params +type GetLogInfoHandler interface { + Handle(GetLogInfoParams) middleware.Responder +} + +// NewGetLogInfo creates a new http.Handler for the get log info operation +func NewGetLogInfo(ctx *middleware.Context, handler GetLogInfoHandler) *GetLogInfo { + return &GetLogInfo{Context: ctx, Handler: handler} +} + +/*GetLogInfo swagger:route GET /api/v1/log tlog getLogInfo + +Get information about the current state of the transparency log + +Returns the current root hash and size of the merkle tree used to store the log entries. + +*/ +type GetLogInfo struct { + Context *middleware.Context + Handler GetLogInfoHandler +} + +func (o *GetLogInfo) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewGetLogInfoParams() + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/pkg/generated/restapi/operations/tlog/get_log_info_parameters.go b/pkg/generated/restapi/operations/tlog/get_log_info_parameters.go new file mode 100644 index 0000000000000000000000000000000000000000..7bb583e685aace5f57c76739b9bb9043fe64f799 --- /dev/null +++ b/pkg/generated/restapi/operations/tlog/get_log_info_parameters.go @@ -0,0 +1,45 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package tlog + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" +) + +// NewGetLogInfoParams creates a new GetLogInfoParams object +// no default values defined in spec. +func NewGetLogInfoParams() GetLogInfoParams { + + return GetLogInfoParams{} +} + +// GetLogInfoParams contains all the bound params for the get log info operation +// typically these are obtained from a http.Request +// +// swagger:parameters getLogInfo +type GetLogInfoParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetLogInfoParams() beforehand. +func (o *GetLogInfoParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/pkg/generated/restapi/operations/tlog/get_log_info_responses.go b/pkg/generated/restapi/operations/tlog/get_log_info_responses.go new file mode 100644 index 0000000000000000000000000000000000000000..2a62d2269b01ada7270193f866f12f6a9be2bab0 --- /dev/null +++ b/pkg/generated/restapi/operations/tlog/get_log_info_responses.go @@ -0,0 +1,116 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package tlog + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/projectrekor/rekor/pkg/generated/models" +) + +// GetLogInfoOKCode is the HTTP code returned for type GetLogInfoOK +const GetLogInfoOKCode int = 200 + +/*GetLogInfoOK A JSON object with the root hash and tree size as properties + +swagger:response getLogInfoOK +*/ +type GetLogInfoOK struct { + + /* + In: Body + */ + Payload *models.LogInfo `json:"body,omitempty"` +} + +// NewGetLogInfoOK creates GetLogInfoOK with default headers values +func NewGetLogInfoOK() *GetLogInfoOK { + + return &GetLogInfoOK{} +} + +// WithPayload adds the payload to the get log info o k response +func (o *GetLogInfoOK) WithPayload(payload *models.LogInfo) *GetLogInfoOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get log info o k response +func (o *GetLogInfoOK) SetPayload(payload *models.LogInfo) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetLogInfoOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/*GetLogInfoDefault There was an internal error in the server while processing the request + +swagger:response getLogInfoDefault +*/ +type GetLogInfoDefault struct { + _statusCode int + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetLogInfoDefault creates GetLogInfoDefault with default headers values +func NewGetLogInfoDefault(code int) *GetLogInfoDefault { + if code <= 0 { + code = 500 + } + + return &GetLogInfoDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get log info default response +func (o *GetLogInfoDefault) WithStatusCode(code int) *GetLogInfoDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get log info default response +func (o *GetLogInfoDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithPayload adds the payload to the get log info default response +func (o *GetLogInfoDefault) WithPayload(payload *models.Error) *GetLogInfoDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get log info default response +func (o *GetLogInfoDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetLogInfoDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/pkg/generated/restapi/operations/tlog/get_log_info_urlbuilder.go b/pkg/generated/restapi/operations/tlog/get_log_info_urlbuilder.go new file mode 100644 index 0000000000000000000000000000000000000000..97c65e0d084668182bf05030e47deb11a6a8afc8 --- /dev/null +++ b/pkg/generated/restapi/operations/tlog/get_log_info_urlbuilder.go @@ -0,0 +1,84 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package tlog + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" +) + +// GetLogInfoURL generates an URL for the get log info operation +type GetLogInfoURL struct { + _basePath string +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetLogInfoURL) WithBasePath(bp string) *GetLogInfoURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetLogInfoURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetLogInfoURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/api/v1/log" + + _basePath := o._basePath + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetLogInfoURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetLogInfoURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetLogInfoURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetLogInfoURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetLogInfoURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetLogInfoURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/pkg/generated/restapi/operations/tlog/get_log_proof.go b/pkg/generated/restapi/operations/tlog/get_log_proof.go new file mode 100644 index 0000000000000000000000000000000000000000..1f24160471774130f6b74b9a2759b1ec1c5848df --- /dev/null +++ b/pkg/generated/restapi/operations/tlog/get_log_proof.go @@ -0,0 +1,60 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package tlog + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetLogProofHandlerFunc turns a function with the right signature into a get log proof handler +type GetLogProofHandlerFunc func(GetLogProofParams) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetLogProofHandlerFunc) Handle(params GetLogProofParams) middleware.Responder { + return fn(params) +} + +// GetLogProofHandler interface for that can handle valid get log proof params +type GetLogProofHandler interface { + Handle(GetLogProofParams) middleware.Responder +} + +// NewGetLogProof creates a new http.Handler for the get log proof operation +func NewGetLogProof(ctx *middleware.Context, handler GetLogProofHandler) *GetLogProof { + return &GetLogProof{Context: ctx, Handler: handler} +} + +/*GetLogProof swagger:route GET /api/v1/log/proof tlog getLogProof + +Get information required to generate a consistency proof for the transparency log + +Returns a list of hashes for specified tree sizes that can be used to confirm the consistency of the transparency log + +*/ +type GetLogProof struct { + Context *middleware.Context + Handler GetLogProofHandler +} + +func (o *GetLogProof) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewGetLogProofParams() + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/pkg/generated/restapi/operations/tlog/get_log_proof_parameters.go b/pkg/generated/restapi/operations/tlog/get_log_proof_parameters.go new file mode 100644 index 0000000000000000000000000000000000000000..ddd46718264c43ad880623b7acec7d70f6bce096 --- /dev/null +++ b/pkg/generated/restapi/operations/tlog/get_log_proof_parameters.go @@ -0,0 +1,159 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package tlog + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// NewGetLogProofParams creates a new GetLogProofParams object +// with the default values initialized. +func NewGetLogProofParams() GetLogProofParams { + + var ( + // initialize parameters with default values + + firstSizeDefault = int64(0) + ) + + return GetLogProofParams{ + FirstSize: &firstSizeDefault, + } +} + +// GetLogProofParams contains all the bound params for the get log proof operation +// typically these are obtained from a http.Request +// +// swagger:parameters getLogProof +type GetLogProofParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*The size of the tree that you wish to prove consistency from (0 means the beginning of the log) Defaults to 0 if not specified + + Minimum: 0 + In: query + Default: 0 + */ + FirstSize *int64 + /*The size of the tree that you wish to prove consistency to + Required: true + Minimum: 0 + In: query + */ + LastSize int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetLogProofParams() beforehand. +func (o *GetLogProofParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + qFirstSize, qhkFirstSize, _ := qs.GetOK("firstSize") + if err := o.bindFirstSize(qFirstSize, qhkFirstSize, route.Formats); err != nil { + res = append(res, err) + } + + qLastSize, qhkLastSize, _ := qs.GetOK("lastSize") + if err := o.bindLastSize(qLastSize, qhkLastSize, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindFirstSize binds and validates parameter FirstSize from query. +func (o *GetLogProofParams) bindFirstSize(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewGetLogProofParams() + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("firstSize", "query", "int64", raw) + } + o.FirstSize = &value + + if err := o.validateFirstSize(formats); err != nil { + return err + } + + return nil +} + +// validateFirstSize carries on validations for parameter FirstSize +func (o *GetLogProofParams) validateFirstSize(formats strfmt.Registry) error { + + if err := validate.MinimumInt("firstSize", "query", int64(*o.FirstSize), 0, false); err != nil { + return err + } + + return nil +} + +// bindLastSize binds and validates parameter LastSize from query. +func (o *GetLogProofParams) bindLastSize(rawData []string, hasKey bool, formats strfmt.Registry) error { + if !hasKey { + return errors.Required("lastSize", "query", rawData) + } + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // AllowEmptyValue: false + if err := validate.RequiredString("lastSize", "query", raw); err != nil { + return err + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("lastSize", "query", "int64", raw) + } + o.LastSize = value + + if err := o.validateLastSize(formats); err != nil { + return err + } + + return nil +} + +// validateLastSize carries on validations for parameter LastSize +func (o *GetLogProofParams) validateLastSize(formats strfmt.Registry) error { + + if err := validate.MinimumInt("lastSize", "query", int64(o.LastSize), 0, false); err != nil { + return err + } + + return nil +} diff --git a/pkg/generated/restapi/operations/tlog/get_log_proof_responses.go b/pkg/generated/restapi/operations/tlog/get_log_proof_responses.go new file mode 100644 index 0000000000000000000000000000000000000000..1e842ea43fab581b50e5d5b337cc636073e00683 --- /dev/null +++ b/pkg/generated/restapi/operations/tlog/get_log_proof_responses.go @@ -0,0 +1,116 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package tlog + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/projectrekor/rekor/pkg/generated/models" +) + +// GetLogProofOKCode is the HTTP code returned for type GetLogProofOK +const GetLogProofOKCode int = 200 + +/*GetLogProofOK All hashes required to compute the consistency proof + +swagger:response getLogProofOK +*/ +type GetLogProofOK struct { + + /* + In: Body + */ + Payload *models.ConsistencyProof `json:"body,omitempty"` +} + +// NewGetLogProofOK creates GetLogProofOK with default headers values +func NewGetLogProofOK() *GetLogProofOK { + + return &GetLogProofOK{} +} + +// WithPayload adds the payload to the get log proof o k response +func (o *GetLogProofOK) WithPayload(payload *models.ConsistencyProof) *GetLogProofOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get log proof o k response +func (o *GetLogProofOK) SetPayload(payload *models.ConsistencyProof) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetLogProofOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/*GetLogProofDefault There was an internal error in the server while processing the request + +swagger:response getLogProofDefault +*/ +type GetLogProofDefault struct { + _statusCode int + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetLogProofDefault creates GetLogProofDefault with default headers values +func NewGetLogProofDefault(code int) *GetLogProofDefault { + if code <= 0 { + code = 500 + } + + return &GetLogProofDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get log proof default response +func (o *GetLogProofDefault) WithStatusCode(code int) *GetLogProofDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get log proof default response +func (o *GetLogProofDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithPayload adds the payload to the get log proof default response +func (o *GetLogProofDefault) WithPayload(payload *models.Error) *GetLogProofDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get log proof default response +func (o *GetLogProofDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetLogProofDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/pkg/generated/restapi/operations/tlog/get_log_proof_urlbuilder.go b/pkg/generated/restapi/operations/tlog/get_log_proof_urlbuilder.go new file mode 100644 index 0000000000000000000000000000000000000000..47b99f8ed734c2e6d33f01def44649509293d231 --- /dev/null +++ b/pkg/generated/restapi/operations/tlog/get_log_proof_urlbuilder.go @@ -0,0 +1,108 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package tlog + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + + "github.com/go-openapi/swag" +) + +// GetLogProofURL generates an URL for the get log proof operation +type GetLogProofURL struct { + FirstSize *int64 + LastSize int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetLogProofURL) WithBasePath(bp string) *GetLogProofURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetLogProofURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetLogProofURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/api/v1/log/proof" + + _basePath := o._basePath + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var firstSizeQ string + if o.FirstSize != nil { + firstSizeQ = swag.FormatInt64(*o.FirstSize) + } + if firstSizeQ != "" { + qs.Set("firstSize", firstSizeQ) + } + + lastSizeQ := swag.FormatInt64(o.LastSize) + if lastSizeQ != "" { + qs.Set("lastSize", lastSizeQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetLogProofURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetLogProofURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetLogProofURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetLogProofURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetLogProofURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetLogProofURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/pkg/generated/restapi/server.go b/pkg/generated/restapi/server.go new file mode 100644 index 0000000000000000000000000000000000000000..7cbba7806c1afb36ed5d4d649492f69fdbac6514 --- /dev/null +++ b/pkg/generated/restapi/server.go @@ -0,0 +1,615 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package restapi + +import ( + "context" + "crypto/tls" + "crypto/x509" + "errors" + "fmt" + "io/ioutil" + "log" + "net" + "net/http" + "os" + "os/signal" + "strconv" + "sync" + "sync/atomic" + "syscall" + "time" + + "github.com/go-openapi/runtime/flagext" + "github.com/go-openapi/swag" + flag "github.com/spf13/pflag" + "golang.org/x/net/netutil" + + "github.com/projectrekor/rekor/pkg/generated/restapi/operations" +) + +const ( + schemeHTTP = "http" + schemeHTTPS = "https" + schemeUnix = "unix" +) + +var defaultSchemes []string + +func init() { + defaultSchemes = []string{ + schemeHTTP, + } +} + +var ( + enabledListeners []string + cleanupTimeout time.Duration + gracefulTimeout time.Duration + maxHeaderSize flagext.ByteSize + + socketPath string + + host string + port int + listenLimit int + keepAlive time.Duration + readTimeout time.Duration + writeTimeout time.Duration + + tlsHost string + tlsPort int + tlsListenLimit int + tlsKeepAlive time.Duration + tlsReadTimeout time.Duration + tlsWriteTimeout time.Duration + tlsCertificate string + tlsCertificateKey string + tlsCACertificate string +) + +func init() { + maxHeaderSize = flagext.ByteSize(1000000) + + flag.StringSliceVar(&enabledListeners, "scheme", defaultSchemes, "the listeners to enable, this can be repeated and defaults to the schemes in the swagger spec") + + flag.DurationVar(&cleanupTimeout, "cleanup-timeout", 10*time.Second, "grace period for which to wait before killing idle connections") + flag.DurationVar(&gracefulTimeout, "graceful-timeout", 15*time.Second, "grace period for which to wait before shutting down the server") + flag.Var(&maxHeaderSize, "max-header-size", "controls the maximum number of bytes the server will read parsing the request header's keys and values, including the request line. It does not limit the size of the request body") + + flag.StringVar(&socketPath, "socket-path", "/var/run/todo-list.sock", "the unix socket to listen on") + + flag.StringVar(&host, "host", "localhost", "the IP to listen on") + flag.IntVar(&port, "port", 0, "the port to listen on for insecure connections, defaults to a random value") + flag.IntVar(&listenLimit, "listen-limit", 0, "limit the number of outstanding requests") + flag.DurationVar(&keepAlive, "keep-alive", 3*time.Minute, "sets the TCP keep-alive timeouts on accepted connections. It prunes dead TCP connections ( e.g. closing laptop mid-download)") + flag.DurationVar(&readTimeout, "read-timeout", 30*time.Second, "maximum duration before timing out read of the request") + flag.DurationVar(&writeTimeout, "write-timeout", 30*time.Second, "maximum duration before timing out write of the response") + + flag.StringVar(&tlsHost, "tls-host", "localhost", "the IP to listen on") + flag.IntVar(&tlsPort, "tls-port", 0, "the port to listen on for secure connections, defaults to a random value") + flag.StringVar(&tlsCertificate, "tls-certificate", "", "the certificate file to use for secure connections") + flag.StringVar(&tlsCertificateKey, "tls-key", "", "the private key file to use for secure connections (without passphrase)") + flag.StringVar(&tlsCACertificate, "tls-ca", "", "the certificate authority certificate file to be used with mutual tls auth") + flag.IntVar(&tlsListenLimit, "tls-listen-limit", 0, "limit the number of outstanding requests") + flag.DurationVar(&tlsKeepAlive, "tls-keep-alive", 3*time.Minute, "sets the TCP keep-alive timeouts on accepted connections. It prunes dead TCP connections ( e.g. closing laptop mid-download)") + flag.DurationVar(&tlsReadTimeout, "tls-read-timeout", 30*time.Second, "maximum duration before timing out read of the request") + flag.DurationVar(&tlsWriteTimeout, "tls-write-timeout", 30*time.Second, "maximum duration before timing out write of the response") +} + +func stringEnvOverride(orig string, def string, keys ...string) string { + for _, k := range keys { + if os.Getenv(k) != "" { + return os.Getenv(k) + } + } + if def != "" && orig == "" { + return def + } + return orig +} + +func intEnvOverride(orig int, def int, keys ...string) int { + for _, k := range keys { + if os.Getenv(k) != "" { + v, err := strconv.Atoi(os.Getenv(k)) + if err != nil { + fmt.Fprintln(os.Stderr, k, "is not a valid number") + os.Exit(1) + } + return v + } + } + if def != 0 && orig == 0 { + return def + } + return orig +} + +// NewServer creates a new api rekor server server but does not configure it +func NewServer(api *operations.RekorServerAPI) *Server { + s := new(Server) + + s.EnabledListeners = enabledListeners + s.CleanupTimeout = cleanupTimeout + s.GracefulTimeout = gracefulTimeout + s.MaxHeaderSize = maxHeaderSize + s.SocketPath = socketPath + s.Host = stringEnvOverride(host, "", "HOST") + s.Port = intEnvOverride(port, 0, "PORT") + s.ListenLimit = listenLimit + s.KeepAlive = keepAlive + s.ReadTimeout = readTimeout + s.WriteTimeout = writeTimeout + s.TLSHost = stringEnvOverride(tlsHost, s.Host, "TLS_HOST", "HOST") + s.TLSPort = intEnvOverride(tlsPort, 0, "TLS_PORT") + s.TLSCertificate = stringEnvOverride(tlsCertificate, "", "TLS_CERTIFICATE") + s.TLSCertificateKey = stringEnvOverride(tlsCertificateKey, "", "TLS_PRIVATE_KEY") + s.TLSCACertificate = stringEnvOverride(tlsCACertificate, "", "TLS_CA_CERTIFICATE") + s.TLSListenLimit = tlsListenLimit + s.TLSKeepAlive = tlsKeepAlive + s.TLSReadTimeout = tlsReadTimeout + s.TLSWriteTimeout = tlsWriteTimeout + s.shutdown = make(chan struct{}) + s.api = api + s.interrupt = make(chan os.Signal, 1) + return s +} + +// ConfigureAPI configures the API and handlers. +func (s *Server) ConfigureAPI() { + if s.api != nil { + s.handler = configureAPI(s.api) + } +} + +// ConfigureFlags configures the additional flags defined by the handlers. Needs to be called before the parser.Parse +func (s *Server) ConfigureFlags() { + if s.api != nil { + configureFlags(s.api) + } +} + +// Server for the rekor server API +type Server struct { + EnabledListeners []string + CleanupTimeout time.Duration + GracefulTimeout time.Duration + MaxHeaderSize flagext.ByteSize + + SocketPath string + domainSocketL net.Listener + + Host string + Port int + ListenLimit int + KeepAlive time.Duration + ReadTimeout time.Duration + WriteTimeout time.Duration + httpServerL net.Listener + + TLSHost string + TLSPort int + TLSCertificate string + TLSCertificateKey string + TLSCACertificate string + TLSListenLimit int + TLSKeepAlive time.Duration + TLSReadTimeout time.Duration + TLSWriteTimeout time.Duration + httpsServerL net.Listener + + api *operations.RekorServerAPI + handler http.Handler + hasListeners bool + shutdown chan struct{} + shuttingDown int32 + interrupted bool + interrupt chan os.Signal +} + +// Logf logs message either via defined user logger or via system one if no user logger is defined. +func (s *Server) Logf(f string, args ...interface{}) { + if s.api != nil && s.api.Logger != nil { + s.api.Logger(f, args...) + } else { + log.Printf(f, args...) + } +} + +// Fatalf logs message either via defined user logger or via system one if no user logger is defined. +// Exits with non-zero status after printing +func (s *Server) Fatalf(f string, args ...interface{}) { + if s.api != nil && s.api.Logger != nil { + s.api.Logger(f, args...) + os.Exit(1) + } else { + log.Fatalf(f, args...) + } +} + +// SetAPI configures the server with the specified API. Needs to be called before Serve +func (s *Server) SetAPI(api *operations.RekorServerAPI) { + if api == nil { + s.api = nil + s.handler = nil + return + } + + s.api = api + s.handler = configureAPI(api) +} + +func (s *Server) hasScheme(scheme string) bool { + schemes := s.EnabledListeners + if len(schemes) == 0 { + schemes = defaultSchemes + } + + for _, v := range schemes { + if v == scheme { + return true + } + } + return false +} + +// Serve the api +func (s *Server) Serve() (err error) { + if !s.hasListeners { + if err = s.Listen(); err != nil { + return err + } + } + + // set default handler, if none is set + if s.handler == nil { + if s.api == nil { + return errors.New("can't create the default handler, as no api is set") + } + + s.SetHandler(s.api.Serve(nil)) + } + + wg := new(sync.WaitGroup) + once := new(sync.Once) + signalNotify(s.interrupt) + go handleInterrupt(once, s) + + servers := []*http.Server{} + + if s.hasScheme(schemeUnix) { + domainSocket := new(http.Server) + domainSocket.MaxHeaderBytes = int(s.MaxHeaderSize) + domainSocket.Handler = s.handler + if int64(s.CleanupTimeout) > 0 { + domainSocket.IdleTimeout = s.CleanupTimeout + } + + configureServer(domainSocket, "unix", string(s.SocketPath)) + + servers = append(servers, domainSocket) + wg.Add(1) + s.Logf("Serving rekor server at unix://%s", s.SocketPath) + go func(l net.Listener) { + defer wg.Done() + if err := domainSocket.Serve(l); err != nil && err != http.ErrServerClosed { + s.Fatalf("%v", err) + } + s.Logf("Stopped serving rekor server at unix://%s", s.SocketPath) + }(s.domainSocketL) + } + + if s.hasScheme(schemeHTTP) { + httpServer := new(http.Server) + httpServer.MaxHeaderBytes = int(s.MaxHeaderSize) + httpServer.ReadTimeout = s.ReadTimeout + httpServer.WriteTimeout = s.WriteTimeout + httpServer.SetKeepAlivesEnabled(int64(s.KeepAlive) > 0) + if s.ListenLimit > 0 { + s.httpServerL = netutil.LimitListener(s.httpServerL, s.ListenLimit) + } + + if int64(s.CleanupTimeout) > 0 { + httpServer.IdleTimeout = s.CleanupTimeout + } + + httpServer.Handler = s.handler + + configureServer(httpServer, "http", s.httpServerL.Addr().String()) + + servers = append(servers, httpServer) + wg.Add(1) + s.Logf("Serving rekor server at http://%s", s.httpServerL.Addr()) + go func(l net.Listener) { + defer wg.Done() + if err := httpServer.Serve(l); err != nil && err != http.ErrServerClosed { + s.Fatalf("%v", err) + } + s.Logf("Stopped serving rekor server at http://%s", l.Addr()) + }(s.httpServerL) + } + + if s.hasScheme(schemeHTTPS) { + httpsServer := new(http.Server) + httpsServer.MaxHeaderBytes = int(s.MaxHeaderSize) + httpsServer.ReadTimeout = s.TLSReadTimeout + httpsServer.WriteTimeout = s.TLSWriteTimeout + httpsServer.SetKeepAlivesEnabled(int64(s.TLSKeepAlive) > 0) + if s.TLSListenLimit > 0 { + s.httpsServerL = netutil.LimitListener(s.httpsServerL, s.TLSListenLimit) + } + if int64(s.CleanupTimeout) > 0 { + httpsServer.IdleTimeout = s.CleanupTimeout + } + httpsServer.Handler = s.handler + + // Inspired by https://blog.bracebin.com/achieving-perfect-ssl-labs-score-with-go + httpsServer.TLSConfig = &tls.Config{ + // Causes servers to use Go's default ciphersuite preferences, + // which are tuned to avoid attacks. Does nothing on clients. + PreferServerCipherSuites: true, + // Only use curves which have assembly implementations + // https://github.com/golang/go/tree/master/src/crypto/elliptic + CurvePreferences: []tls.CurveID{tls.CurveP256}, + // Use modern tls mode https://wiki.mozilla.org/Security/Server_Side_TLS#Modern_compatibility + NextProtos: []string{"h2", "http/1.1"}, + // https://www.owasp.org/index.php/Transport_Layer_Protection_Cheat_Sheet#Rule_-_Only_Support_Strong_Protocols + MinVersion: tls.VersionTLS12, + // These ciphersuites support Forward Secrecy: https://en.wikipedia.org/wiki/Forward_secrecy + CipherSuites: []uint16{ + tls.TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384, + tls.TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384, + tls.TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, + tls.TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, + tls.TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305, + tls.TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305, + }, + } + + // build standard config from server options + if s.TLSCertificate != "" && s.TLSCertificateKey != "" { + httpsServer.TLSConfig.Certificates = make([]tls.Certificate, 1) + httpsServer.TLSConfig.Certificates[0], err = tls.LoadX509KeyPair(s.TLSCertificate, s.TLSCertificateKey) + if err != nil { + return err + } + } + + if s.TLSCACertificate != "" { + // include specified CA certificate + caCert, caCertErr := ioutil.ReadFile(s.TLSCACertificate) + if caCertErr != nil { + return caCertErr + } + caCertPool := x509.NewCertPool() + ok := caCertPool.AppendCertsFromPEM(caCert) + if !ok { + return fmt.Errorf("cannot parse CA certificate") + } + httpsServer.TLSConfig.ClientCAs = caCertPool + httpsServer.TLSConfig.ClientAuth = tls.RequireAndVerifyClientCert + } + + // call custom TLS configurator + configureTLS(httpsServer.TLSConfig) + + if len(httpsServer.TLSConfig.Certificates) == 0 && httpsServer.TLSConfig.GetCertificate == nil { + // after standard and custom config are passed, this ends up with no certificate + if s.TLSCertificate == "" { + if s.TLSCertificateKey == "" { + s.Fatalf("the required flags `--tls-certificate` and `--tls-key` were not specified") + } + s.Fatalf("the required flag `--tls-certificate` was not specified") + } + if s.TLSCertificateKey == "" { + s.Fatalf("the required flag `--tls-key` was not specified") + } + // this happens with a wrong custom TLS configurator + s.Fatalf("no certificate was configured for TLS") + } + + // must have at least one certificate or panics + httpsServer.TLSConfig.BuildNameToCertificate() + + configureServer(httpsServer, "https", s.httpsServerL.Addr().String()) + + servers = append(servers, httpsServer) + wg.Add(1) + s.Logf("Serving rekor server at https://%s", s.httpsServerL.Addr()) + go func(l net.Listener) { + defer wg.Done() + if err := httpsServer.Serve(l); err != nil && err != http.ErrServerClosed { + s.Fatalf("%v", err) + } + s.Logf("Stopped serving rekor server at https://%s", l.Addr()) + }(tls.NewListener(s.httpsServerL, httpsServer.TLSConfig)) + } + + wg.Add(1) + go s.handleShutdown(wg, &servers) + + wg.Wait() + return nil +} + +// Listen creates the listeners for the server +func (s *Server) Listen() error { + if s.hasListeners { // already done this + return nil + } + + if s.hasScheme(schemeHTTPS) { + // Use http host if https host wasn't defined + if s.TLSHost == "" { + s.TLSHost = s.Host + } + // Use http listen limit if https listen limit wasn't defined + if s.TLSListenLimit == 0 { + s.TLSListenLimit = s.ListenLimit + } + // Use http tcp keep alive if https tcp keep alive wasn't defined + if int64(s.TLSKeepAlive) == 0 { + s.TLSKeepAlive = s.KeepAlive + } + // Use http read timeout if https read timeout wasn't defined + if int64(s.TLSReadTimeout) == 0 { + s.TLSReadTimeout = s.ReadTimeout + } + // Use http write timeout if https write timeout wasn't defined + if int64(s.TLSWriteTimeout) == 0 { + s.TLSWriteTimeout = s.WriteTimeout + } + } + + if s.hasScheme(schemeUnix) { + domSockListener, err := net.Listen("unix", string(s.SocketPath)) + if err != nil { + return err + } + s.domainSocketL = domSockListener + } + + if s.hasScheme(schemeHTTP) { + listener, err := net.Listen("tcp", net.JoinHostPort(s.Host, strconv.Itoa(s.Port))) + if err != nil { + return err + } + + h, p, err := swag.SplitHostPort(listener.Addr().String()) + if err != nil { + return err + } + s.Host = h + s.Port = p + s.httpServerL = listener + } + + if s.hasScheme(schemeHTTPS) { + tlsListener, err := net.Listen("tcp", net.JoinHostPort(s.TLSHost, strconv.Itoa(s.TLSPort))) + if err != nil { + return err + } + + sh, sp, err := swag.SplitHostPort(tlsListener.Addr().String()) + if err != nil { + return err + } + s.TLSHost = sh + s.TLSPort = sp + s.httpsServerL = tlsListener + } + + s.hasListeners = true + return nil +} + +// Shutdown server and clean up resources +func (s *Server) Shutdown() error { + if atomic.CompareAndSwapInt32(&s.shuttingDown, 0, 1) { + close(s.shutdown) + } + return nil +} + +func (s *Server) handleShutdown(wg *sync.WaitGroup, serversPtr *[]*http.Server) { + // wg.Done must occur last, after s.api.ServerShutdown() + // (to preserve old behaviour) + defer wg.Done() + + <-s.shutdown + + servers := *serversPtr + + ctx, cancel := context.WithTimeout(context.TODO(), s.GracefulTimeout) + defer cancel() + + // first execute the pre-shutdown hook + s.api.PreServerShutdown() + + shutdownChan := make(chan bool) + for i := range servers { + server := servers[i] + go func() { + var success bool + defer func() { + shutdownChan <- success + }() + if err := server.Shutdown(ctx); err != nil { + // Error from closing listeners, or context timeout: + s.Logf("HTTP server Shutdown: %v", err) + } else { + success = true + } + }() + } + + // Wait until all listeners have successfully shut down before calling ServerShutdown + success := true + for range servers { + success = success && <-shutdownChan + } + if success { + s.api.ServerShutdown() + } +} + +// GetHandler returns a handler useful for testing +func (s *Server) GetHandler() http.Handler { + return s.handler +} + +// SetHandler allows for setting a http handler on this server +func (s *Server) SetHandler(handler http.Handler) { + s.handler = handler +} + +// UnixListener returns the domain socket listener +func (s *Server) UnixListener() (net.Listener, error) { + if !s.hasListeners { + if err := s.Listen(); err != nil { + return nil, err + } + } + return s.domainSocketL, nil +} + +// HTTPListener returns the http listener +func (s *Server) HTTPListener() (net.Listener, error) { + if !s.hasListeners { + if err := s.Listen(); err != nil { + return nil, err + } + } + return s.httpServerL, nil +} + +// TLSListener returns the https listener +func (s *Server) TLSListener() (net.Listener, error) { + if !s.hasListeners { + if err := s.Listen(); err != nil { + return nil, err + } + } + return s.httpsServerL, nil +} + +func handleInterrupt(once *sync.Once, s *Server) { + once.Do(func() { + for range s.interrupt { + if s.interrupted { + s.Logf("Server already shutting down") + continue + } + s.interrupted = true + s.Logf("Shutting down... ") + if err := s.Shutdown(); err != nil { + s.Logf("HTTP server Shutdown: %v", err) + } + } + }) +} + +func signalNotify(interrupt chan<- os.Signal) { + signal.Notify(interrupt, syscall.SIGINT, syscall.SIGTERM) +}