diff --git a/Makefile b/Makefile index e7e0c787..e482ddc5 100644 --- a/Makefile +++ b/Makefile @@ -8,18 +8,18 @@ TMPDIR := $(shell mktemp -d) STACKER := $(shell which stacker) .PHONY: all -all: doc binary binary-minimal debug test test-clean check +all: swagger binary binary-minimal debug test test-clean check .PHONY: binary-minimal -binary-minimal: doc +binary-minimal: swagger go build -tags minimal,containers_image_openpgp -v -ldflags "-X github.com/anuvu/zot/pkg/api.Commit=${COMMIT} -X github.com/anuvu/zot/pkg/api.BinaryType=minimal" -o bin/zot-minimal ./cmd/zot .PHONY: binary -binary: doc +binary: swagger go build -tags extended,containers_image_openpgp -v -ldflags "-X github.com/anuvu/zot/pkg/api.Commit=${COMMIT} -X github.com/anuvu/zot/pkg/api.BinaryType=extended" -o bin/zot ./cmd/zot .PHONY: debug -debug: doc +debug: swagger go build -tags extended,containers_image_openpgp -v -gcflags all='-N -l' -ldflags "-X github.com/anuvu/zot/pkg/api.Commit=${COMMIT} -X github.com/anuvu/zot/pkg/api.BinaryType=extended" -o bin/zot-debug ./cmd/zot .PHONY: test @@ -42,12 +42,12 @@ check: ./golangcilint.yaml golangci-lint --version || curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s v1.26.0 golangci-lint --config ./golangcilint.yaml run --enable-all --build-tags extended,containers_image_openpgp ./cmd/... ./pkg/... -docs/docs.go: +swagger/docs.go: swag -v || go install github.com/swaggo/swag/cmd/swag - swag init -g pkg/api/routes.go + swag init -o swagger -g pkg/api/routes.go -.PHONY: doc -doc: docs/docs.go +.PHONY: swagger +swagger: swagger/docs.go .PHONY: update-licenses update-licenses: diff --git a/docs/README.md b/docs/README.md new file mode 100644 index 00000000..e69de29b diff --git a/pkg/api/routes.go b/pkg/api/routes.go index 5b310ca4..fbf6e630 100644 --- a/pkg/api/routes.go +++ b/pkg/api/routes.go @@ -21,11 +21,11 @@ import ( "strconv" "strings" - _ "github.com/anuvu/zot/docs" // as required by swaggo "github.com/anuvu/zot/errors" ext "github.com/anuvu/zot/pkg/extensions" "github.com/anuvu/zot/pkg/log" "github.com/anuvu/zot/pkg/storage" + _ "github.com/anuvu/zot/swagger" // as required by swaggo "github.com/gorilla/mux" jsoniter "github.com/json-iterator/go" ispec "github.com/opencontainers/image-spec/specs-go/v1" @@ -93,7 +93,7 @@ func (rh *RouteHandler) SetupRoutes() { g.HandleFunc("/", rh.CheckVersionSupport).Methods("GET") } - // swagger docs "/swagger/v2/index.html" + // swagger swagger "/swagger/v2/index.html" rh.c.Router.PathPrefix("/swagger/v2/").Methods("GET").Handler(httpSwagger.WrapHandler) // Setup Extensions Routes if rh.c.Config != nil && rh.c.Config.Extensions != nil { diff --git a/docs/docs.go b/swagger/docs.go similarity index 99% rename from docs/docs.go rename to swagger/docs.go index 7296e3b4..657b7ad1 100644 --- a/docs/docs.go +++ b/swagger/docs.go @@ -2,7 +2,7 @@ // This file was generated by swaggo/swag at // 2019-12-11 12:03:05.055900322 -0800 PST m=+0.052058015 -package docs +package swagger import ( "bytes" diff --git a/docs/docs_test.go b/swagger/docs_test.go similarity index 70% rename from docs/docs_test.go rename to swagger/docs_test.go index 8aca42e8..0264c274 100644 --- a/docs/docs_test.go +++ b/swagger/docs_test.go @@ -1,15 +1,15 @@ -package docs_test +package swagger_test import ( "testing" - "github.com/anuvu/zot/docs" + "github.com/anuvu/zot/swagger" . "github.com/smartystreets/goconvey/convey" ) func TestDocs(t *testing.T) { Convey("Read docs", t, func() { - s := docs.New() + s := swagger.New() So(s.ReadDoc(), ShouldNotBeEmpty) }) } diff --git a/docs/swagger.json b/swagger/swagger.json similarity index 100% rename from docs/swagger.json rename to swagger/swagger.json diff --git a/docs/swagger.yaml b/swagger/swagger.yaml similarity index 100% rename from docs/swagger.yaml rename to swagger/swagger.yaml