From 6cc7c66c0e98abb6f87ee9d70be6b161484b2bf2 Mon Sep 17 00:00:00 2001 From: Lennart Fleischmann Date: Mon, 12 Sep 2022 17:42:30 +0200 Subject: [PATCH] refactor: rename private api references --- backend/README.md | 10 +++++----- backend/cmd/serve/{private.go => admin.go} | 8 ++++---- backend/cmd/serve/all.go | 4 ++-- backend/cmd/serve/root.go | 2 +- backend/config/config.go | 12 ++++++------ backend/docs/Config.md | 8 ++++---- backend/server/admin_router.go | 2 +- backend/server/server.go | 6 +++--- deploy/docker-compose/quickstart.yaml | 2 +- deploy/k8s/base/deployment.yaml | 4 ++-- deploy/k8s/base/services.yaml | 6 +++--- 11 files changed, 32 insertions(+), 32 deletions(-) rename backend/cmd/serve/{private.go => admin.go} (72%) diff --git a/backend/README.md b/backend/README.md index f245c4916..390c6eb21 100644 --- a/backend/README.md +++ b/backend/README.md @@ -120,22 +120,22 @@ The service is now available at `localhost:8000`. ## Advanced Usage -### Start private API +### Start admin API -In the usage section above we only started the public API. Use the command below to start the private API. The default +In the usage section above we only started the public API. Use the command below to start the admin API. The default port is `8001`, but can be [customized](./docs/Config.md) in the config. ```shell -serve private +serve admin ``` -Use this command to start the public and private API together: +Use this command to start the public and admin API together: ````shell serve all ```` -> **Warning** The private API must be protected by an access management system. +> **Warning** The admin API must be protected by an access management system. ### Supported Databases diff --git a/backend/cmd/serve/private.go b/backend/cmd/serve/admin.go similarity index 72% rename from backend/cmd/serve/private.go rename to backend/cmd/serve/admin.go index 4bdb86e1e..737d1cdac 100644 --- a/backend/cmd/serve/private.go +++ b/backend/cmd/serve/admin.go @@ -13,10 +13,10 @@ import ( "sync" ) -func NewServePrivateCommand(config *config.Config) *cobra.Command { +func NewServeAdminCommand(config *config.Config) *cobra.Command { return &cobra.Command{ - Use: "private", - Short: "Start the private portion of the hanko server", + Use: "admin", + Short: "Start the admin portion of the hanko server", Long: ``, Run: func(cmd *cobra.Command, args []string) { persister, err := persistence.New(config.Database) @@ -26,7 +26,7 @@ func NewServePrivateCommand(config *config.Config) *cobra.Command { var wg sync.WaitGroup wg.Add(1) - go server.StartPrivate(config, &wg, persister) + go server.StartAdmin(config, &wg, persister) wg.Wait() }, diff --git a/backend/cmd/serve/all.go b/backend/cmd/serve/all.go index b10965bcb..47e86b86f 100644 --- a/backend/cmd/serve/all.go +++ b/backend/cmd/serve/all.go @@ -16,7 +16,7 @@ import ( func NewServeAllCommand(config *config.Config) *cobra.Command { return &cobra.Command{ Use: "all", - Short: "Start the public and private portion of the hanko server", + Short: "Start the public and admin portion of the hanko server", Long: ``, Run: func(cmd *cobra.Command, args []string) { persister, err := persistence.New(config.Database) @@ -27,7 +27,7 @@ func NewServeAllCommand(config *config.Config) *cobra.Command { wg.Add(2) go server.StartPublic(config, &wg, persister) - go server.StartPrivate(config, &wg, persister) + go server.StartAdmin(config, &wg, persister) wg.Wait() }, diff --git a/backend/cmd/serve/root.go b/backend/cmd/serve/root.go index dfaa48105..215c50f72 100644 --- a/backend/cmd/serve/root.go +++ b/backend/cmd/serve/root.go @@ -21,6 +21,6 @@ func RegisterCommands(parent *cobra.Command, config *config.Config) { cmd := NewServeCommand() parent.AddCommand(cmd) cmd.AddCommand(NewServePublicCommand(config)) - cmd.AddCommand(NewServePrivateCommand(config)) + cmd.AddCommand(NewServeAdminCommand(config)) cmd.AddCommand(NewServeAllCommand(config)) } diff --git a/backend/config/config.go b/backend/config/config.go index 889486df2..13d3d5ea5 100644 --- a/backend/config/config.go +++ b/backend/config/config.go @@ -58,7 +58,7 @@ func DefaultConfig() *Config { Public: ServerSettings{ Address: ":8000", }, - Private: ServerSettings{ + Admin: ServerSettings{ Address: ":8001", }, }, @@ -125,10 +125,10 @@ func (c *Config) Validate() error { return nil } -// Server contains the setting for the public and private server +// Server contains the setting for the public and admin server type Server struct { - Public ServerSettings `yaml:"public" json:"public" koanf:"public"` - Private ServerSettings `yaml:"private" json:"private" koanf:"private"` + Public ServerSettings `yaml:"public" json:"public" koanf:"public"` + Admin ServerSettings `yaml:"admin" json:"admin" koanf:"admin"` } func (s *Server) Validate() error { @@ -136,9 +136,9 @@ func (s *Server) Validate() error { if err != nil { return fmt.Errorf("error validating public server settings: %w", err) } - err = s.Private.Validate() + err = s.Admin.Validate() if err != nil { - return fmt.Errorf("error validating private server settings: %w", err) + return fmt.Errorf("error validating admin server settings: %w", err) } return nil } diff --git a/backend/docs/Config.md b/backend/docs/Config.md index 8b0e36ca6..d2af8cc14 100644 --- a/backend/docs/Config.md +++ b/backend/docs/Config.md @@ -42,14 +42,14 @@ server: expose_headers: - "" max_age: 0 - ## private ## + ## admin ## # - # Configuration for the private API. + # Configuration for the admin API. # - private: + admin: ## address ## # - # The address the private API will listen and handle requests on. + # The address the admin API will listen and handle requests on. # address: ":8001" ## database ## diff --git a/backend/server/admin_router.go b/backend/server/admin_router.go index 29f46eb94..e6397bd81 100644 --- a/backend/server/admin_router.go +++ b/backend/server/admin_router.go @@ -9,7 +9,7 @@ import ( hankoMiddleware "github.com/teamhanko/hanko/backend/server/middleware" ) -func NewPrivateRouter(persister persistence.Persister) *echo.Echo { +func NewAdminRouter(persister persistence.Persister) *echo.Echo { e := echo.New() e.HideBanner = true diff --git a/backend/server/server.go b/backend/server/server.go index 94115d67f..2b951ceeb 100644 --- a/backend/server/server.go +++ b/backend/server/server.go @@ -12,8 +12,8 @@ func StartPublic(cfg *config.Config, wg *sync.WaitGroup, persister persistence.P router.Logger.Fatal(router.Start(cfg.Server.Public.Address)) } -func StartPrivate(cfg *config.Config, wg *sync.WaitGroup, persister persistence.Persister) { +func StartAdmin(cfg *config.Config, wg *sync.WaitGroup, persister persistence.Persister) { defer wg.Done() - router := NewPrivateRouter(persister) - router.Logger.Fatal(router.Start(cfg.Server.Private.Address)) + router := NewAdminRouter(persister) + router.Logger.Fatal(router.Start(cfg.Server.Admin.Address)) } diff --git a/deploy/docker-compose/quickstart.yaml b/deploy/docker-compose/quickstart.yaml index 04323f25b..15d03db77 100644 --- a/deploy/docker-compose/quickstart.yaml +++ b/deploy/docker-compose/quickstart.yaml @@ -19,7 +19,7 @@ services: build: ../../backend ports: - '8000:8000' # public - - '8001:8001' # private + - '8001:8001' # admin restart: unless-stopped command: serve --config /etc/config/config.yaml all volumes: diff --git a/deploy/k8s/base/deployment.yaml b/deploy/k8s/base/deployment.yaml index 6c0f12657..d5f1a5d40 100644 --- a/deploy/k8s/base/deployment.yaml +++ b/deploy/k8s/base/deployment.yaml @@ -25,7 +25,7 @@ spec: - containerPort: 8000 name: public - containerPort: 8001 - name: private + name: admin volumeMounts: - mountPath: /etc/config name: hanko-config @@ -42,4 +42,4 @@ spec: volumes: - name: hanko-config configMap: - name: hanko-config \ No newline at end of file + name: hanko-config diff --git a/deploy/k8s/base/services.yaml b/deploy/k8s/base/services.yaml index 8c711d5a3..ecb83708c 100644 --- a/deploy/k8s/base/services.yaml +++ b/deploy/k8s/base/services.yaml @@ -15,13 +15,13 @@ spec: apiVersion: v1 kind: Service metadata: - name: hanko-private + name: hanko-admin namespace: hanko spec: selector: app: hanko ports: - port: 80 - targetPort: private + targetPort: admin protocol: TCP - name: http \ No newline at end of file + name: http