From 9fc6484600d439a60dab4a3dc6489e4c8507f8cc Mon Sep 17 00:00:00 2001 From: Moby von Briesen Date: Thu, 5 May 2022 10:03:51 -0400 Subject: [PATCH] private/apigen: Reorganize and rename files Change-Id: I430d620bb0940f2186cb884b00cb5eb9729b9744 --- private/apigen/common.go | 30 +++++++++++++++++++ private/apigen/{api.go => gogen.go} | 27 ++--------------- .../console/consoleweb/consoleapi/gen/main.go | 2 +- 3 files changed, 33 insertions(+), 26 deletions(-) create mode 100644 private/apigen/common.go rename private/apigen/{api.go => gogen.go} (92%) diff --git a/private/apigen/common.go b/private/apigen/common.go new file mode 100644 index 000000000..df5f5accf --- /dev/null +++ b/private/apigen/common.go @@ -0,0 +1,30 @@ +// Copyright (C) 2022 Storj Labs, Inc. +// See LICENSE for copying information. + +package apigen + +import ( + "storj.io/storj/private/api" +) + +// API represents specific API's configuration. +type API struct { + Version string + Description string + PackageName string + Auth api.Auth + EndpointGroups []*EndpointGroup +} + +// Group adds new endpoints group to API. +func (a *API) Group(name, prefix string) *EndpointGroup { + group := &EndpointGroup{ + Name: name, + Prefix: prefix, + Endpoints: make(map[PathMethod]*Endpoint), + } + + a.EndpointGroups = append(a.EndpointGroups, group) + + return group +} diff --git a/private/apigen/api.go b/private/apigen/gogen.go similarity index 92% rename from private/apigen/api.go rename to private/apigen/gogen.go index de2071295..cc4c5aaef 100644 --- a/private/apigen/api.go +++ b/private/apigen/gogen.go @@ -17,33 +17,10 @@ import ( "golang.org/x/text/language" "storj.io/common/uuid" - "storj.io/storj/private/api" ) -// API represents specific API's configuration. -type API struct { - Version string - Description string - PackageName string - Auth api.Auth - EndpointGroups []*EndpointGroup -} - -// Group adds new endpoints group to API. -func (a *API) Group(name, prefix string) *EndpointGroup { - group := &EndpointGroup{ - Name: name, - Prefix: prefix, - Endpoints: make(map[PathMethod]*Endpoint), - } - - a.EndpointGroups = append(a.EndpointGroups, group) - - return group -} - -// MustWrite writes generated code into a file. -func (a *API) MustWrite(path string) { +// MustWriteGo writes generated Go code into a file. +func (a *API) MustWriteGo(path string) { generated, err := a.generateGo() if err != nil { panic(errs.Wrap(err)) diff --git a/satellite/console/consoleweb/consoleapi/gen/main.go b/satellite/console/consoleweb/consoleapi/gen/main.go index 2954d7920..40db4fc93 100644 --- a/satellite/console/consoleweb/consoleapi/gen/main.go +++ b/satellite/console/consoleweb/consoleapi/gen/main.go @@ -79,5 +79,5 @@ func main() { }) } - a.MustWrite("satellite/console/consoleweb/consoleapi/api.gen.go") + a.MustWriteGo("satellite/console/consoleweb/consoleapi/api.gen.go") }