Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions cmd/pgmanager/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import (

// Packages
kong "github.com/alecthomas/kong"
httpclient "github.com/mutablelogic/go-pg/pkg/manager/httpclient"
client "github.com/mutablelogic/go-client"
httpclient "github.com/mutablelogic/go-pg/pkg/manager/httpclient"
)

///////////////////////////////////////////////////////////////////////////////
Expand All @@ -23,7 +23,7 @@ type Globals struct {
// HTTP server options
HTTP struct {
Prefix string `name:"prefix" help:"HTTP path prefix" default:"/api/v1"`
Listen string `name:"http" help:"HTTP Listen address" default:":8080"`
Addr string `name:"addr" env:"PG_ADDR" help:"HTTP Listen address" default:":8080"`
} `embed:"" prefix:"http."`

// Private fields
Expand All @@ -44,6 +44,7 @@ type CLI struct {
SettingCommands
StatementCommands
TablespaceCommands
VersionCommands
}

///////////////////////////////////////////////////////////////////////////////
Expand All @@ -68,7 +69,7 @@ func main() {
// PRIVATE METHODS

func (g *Globals) Client() (*httpclient.Client, error) {
host, port, err := net.SplitHostPort(g.HTTP.Listen)
host, port, err := net.SplitHostPort(g.HTTP.Addr)
if err != nil {
return nil, err
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/pgmanager/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,12 @@ func (cmd *RunServer) Run(ctx *Globals) error {
}

// Create a HTTP server
server, err := httpserver.New(ctx.HTTP.Listen, router, tlsconfig)
server, err := httpserver.New(ctx.HTTP.Addr, router, tlsconfig)
if err != nil {
return err
}

// Run the server
fmt.Println("Starting server on", ctx.HTTP.Listen)
fmt.Println("Starting server on", ctx.HTTP.Addr)
return server.Run(ctx.ctx)
}
39 changes: 39 additions & 0 deletions cmd/pgmanager/version.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package main

import (
"fmt"

// Packages
"github.com/mutablelogic/go-pg/pkg/version"
)

///////////////////////////////////////////////////////////////////////////////
// TYPES

type VersionCommands struct {
Version VersionCommand `cmd:"version" help:"Print version information"`
}

type VersionCommand struct{}

///////////////////////////////////////////////////////////////////////////////
// PUBLIC METHODS

func (cmd *VersionCommand) Run(g *Globals) error {
if version.GitSource != "" {
fmt.Printf("%s@%s\n\n", version.GitSource, version.Version())
} else {
fmt.Printf("pgmanager %s\n\n", version.Version())
}
if version.GitHash != "" {
fmt.Printf("Commit: %s\n", version.GitHash)
}
if version.GitBranch != "" {
fmt.Printf("Branch: %s\n", version.GitBranch)
}
if version.GoBuildTime != "" {
fmt.Printf("Build Time: %s\n", version.GoBuildTime)
}
fmt.Printf("Compiler: %s\n", version.Compiler())
return nil
}