remove globals.Buildarch from codebase
All checks were successful
check / check (push) Successful in 6s
All checks were successful
check / check (push) Successful in 6s
Remove the Buildarch field from the globals package variable, struct, and constructor. Remove all references in main.go (including the runtime import), logger startup output, and test setup across globals, logger, database, and webhook_db_manager packages. closes #30
This commit is contained in:
@@ -1,8 +1,6 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"runtime"
|
|
||||||
|
|
||||||
"go.uber.org/fx"
|
"go.uber.org/fx"
|
||||||
"sneak.berlin/go/webhooker/internal/config"
|
"sneak.berlin/go/webhooker/internal/config"
|
||||||
"sneak.berlin/go/webhooker/internal/database"
|
"sneak.berlin/go/webhooker/internal/database"
|
||||||
@@ -25,7 +23,6 @@ var (
|
|||||||
func main() {
|
func main() {
|
||||||
globals.Appname = appname
|
globals.Appname = appname
|
||||||
globals.Version = version
|
globals.Version = version
|
||||||
globals.Buildarch = runtime.GOARCH
|
|
||||||
|
|
||||||
fx.New(
|
fx.New(
|
||||||
fx.Provide(
|
fx.Provide(
|
||||||
|
|||||||
@@ -17,7 +17,6 @@ func TestDatabaseConnection(t *testing.T) {
|
|||||||
// Create globals
|
// Create globals
|
||||||
globals.Appname = "webhooker-test"
|
globals.Appname = "webhooker-test"
|
||||||
globals.Version = "test"
|
globals.Version = "test"
|
||||||
globals.Buildarch = "test"
|
|
||||||
|
|
||||||
g, err := globals.New(lc)
|
g, err := globals.New(lc)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ func setupTestWebhookDBManager(t *testing.T) (*WebhookDBManager, *fxtest.Lifecyc
|
|||||||
|
|
||||||
globals.Appname = "webhooker-test"
|
globals.Appname = "webhooker-test"
|
||||||
globals.Version = "test"
|
globals.Version = "test"
|
||||||
globals.Buildarch = "test"
|
|
||||||
|
|
||||||
g, err := globals.New(lc)
|
g, err := globals.New(lc)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|||||||
@@ -6,23 +6,20 @@ import (
|
|||||||
|
|
||||||
// these get populated from main() and copied into the Globals object.
|
// these get populated from main() and copied into the Globals object.
|
||||||
var (
|
var (
|
||||||
Appname string
|
Appname string
|
||||||
Version string
|
Version string
|
||||||
Buildarch string
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type Globals struct {
|
type Globals struct {
|
||||||
Appname string
|
Appname string
|
||||||
Version string
|
Version string
|
||||||
Buildarch string
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// nolint:revive // lc parameter is required by fx even if unused
|
// nolint:revive // lc parameter is required by fx even if unused
|
||||||
func New(lc fx.Lifecycle) (*Globals, error) {
|
func New(lc fx.Lifecycle) (*Globals, error) {
|
||||||
n := &Globals{
|
n := &Globals{
|
||||||
Appname: Appname,
|
Appname: Appname,
|
||||||
Buildarch: Buildarch,
|
Version: Version,
|
||||||
Version: Version,
|
|
||||||
}
|
}
|
||||||
return n, nil
|
return n, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ func TestNew(t *testing.T) {
|
|||||||
// Set test values
|
// Set test values
|
||||||
Appname = "test-app"
|
Appname = "test-app"
|
||||||
Version = "1.0.0"
|
Version = "1.0.0"
|
||||||
Buildarch = "test-arch"
|
|
||||||
|
|
||||||
lc := fxtest.NewLifecycle(t)
|
lc := fxtest.NewLifecycle(t)
|
||||||
globals, err := New(lc)
|
globals, err := New(lc)
|
||||||
@@ -24,7 +23,4 @@ func TestNew(t *testing.T) {
|
|||||||
if globals.Version != "1.0.0" {
|
if globals.Version != "1.0.0" {
|
||||||
t.Errorf("Version = %v, want %v", globals.Version, "1.0.0")
|
t.Errorf("Version = %v, want %v", globals.Version, "1.0.0")
|
||||||
}
|
}
|
||||||
if globals.Buildarch != "test-arch" {
|
|
||||||
t.Errorf("Buildarch = %v, want %v", globals.Buildarch, "test-arch")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -82,7 +82,6 @@ func (l *Logger) Identify() {
|
|||||||
l.logger.Info("starting",
|
l.logger.Info("starting",
|
||||||
"appname", l.params.Globals.Appname,
|
"appname", l.params.Globals.Appname,
|
||||||
"version", l.params.Globals.Version,
|
"version", l.params.Globals.Version,
|
||||||
"buildarch", l.params.Globals.Buildarch,
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ func TestNew(t *testing.T) {
|
|||||||
// Set up globals
|
// Set up globals
|
||||||
globals.Appname = "test-app"
|
globals.Appname = "test-app"
|
||||||
globals.Version = "1.0.0"
|
globals.Version = "1.0.0"
|
||||||
globals.Buildarch = "test-arch"
|
|
||||||
|
|
||||||
lc := fxtest.NewLifecycle(t)
|
lc := fxtest.NewLifecycle(t)
|
||||||
g, err := globals.New(lc)
|
g, err := globals.New(lc)
|
||||||
@@ -40,7 +39,6 @@ func TestEnableDebugLogging(t *testing.T) {
|
|||||||
// Set up globals
|
// Set up globals
|
||||||
globals.Appname = "test-app"
|
globals.Appname = "test-app"
|
||||||
globals.Version = "1.0.0"
|
globals.Version = "1.0.0"
|
||||||
globals.Buildarch = "test-arch"
|
|
||||||
|
|
||||||
lc := fxtest.NewLifecycle(t)
|
lc := fxtest.NewLifecycle(t)
|
||||||
g, err := globals.New(lc)
|
g, err := globals.New(lc)
|
||||||
|
|||||||
Reference in New Issue
Block a user