3 Commits

Author SHA1 Message Date
87344dd601 version: KongVersionCmd type 2025-04-12 00:24:19 -07:00
39e6611602 build: update goreleaser 2025-04-12 00:23:33 -07:00
355d246010 depenv: implement UnmarshalText 2025-04-12 00:22:57 -07:00
3 changed files with 33 additions and 7 deletions

View File

@@ -1,6 +1,9 @@
package depenv package depenv
import "os" import (
"fmt"
"os"
)
var manageServers = map[DeploymentEnvironment]string{ var manageServers = map[DeploymentEnvironment]string{
DeployDevel: "https://manage.askdev.grundclock.com", DeployDevel: "https://manage.askdev.grundclock.com",
@@ -65,3 +68,16 @@ func (d DeploymentEnvironment) APIHost() string {
func (d DeploymentEnvironment) ManageURL(path string) string { func (d DeploymentEnvironment) ManageURL(path string) string {
return manageServers[d] + path return manageServers[d] + path
} }
func (d *DeploymentEnvironment) UnmarshalText(text []byte) error {
s := string(text)
if s == "" {
return nil
}
env := DeploymentEnvironmentFromString(s)
if env == DeployUndefined {
return fmt.Errorf("invalid deployment environment: %s", s)
}
*d = env
return nil
}

View File

@@ -2,7 +2,7 @@
set -euo pipefail set -euo pipefail
go install github.com/goreleaser/goreleaser/v2@v2.5.1 go install github.com/goreleaser/goreleaser/v2@v2.8.2
if [ ! -z "${harbor_username:-}" ]; then if [ ! -z "${harbor_username:-}" ]; then
DOCKER_FILE=~/.docker/config.json DOCKER_FILE=~/.docker/config.json

View File

@@ -13,10 +13,12 @@ import (
) )
// VERSION has the current software version (set in the build process) // VERSION has the current software version (set in the build process)
var VERSION string var (
var buildTime string VERSION string
var gitVersion string buildTime string
var gitModified bool gitVersion string
gitModified bool
)
var info Info var info Info
@@ -28,7 +30,6 @@ type Info struct {
} }
func init() { func init() {
info.BuildTime = buildTime info.BuildTime = buildTime
info.GitRev = gitVersion info.GitRev = gitVersion
@@ -90,6 +91,15 @@ func VersionCmd(name string) *cobra.Command {
return versionCmd return versionCmd
} }
type KongVersionCmd struct {
Name string `kong:"-"`
}
func (cmd *KongVersionCmd) Run() error {
fmt.Printf("%s %s\n", cmd.Name, Version())
return nil
}
func RegisterMetric(name string, registry prometheus.Registerer) { func RegisterMetric(name string, registry prometheus.Registerer) {
if len(name) > 0 { if len(name) > 0 {
name = strings.ReplaceAll(name, "-", "_") name = strings.ReplaceAll(name, "-", "_")