From 78ed610b50fa85cb1201d78624c3c5e6b7620f84 Mon Sep 17 00:00:00 2001 From: Kristoffer Dalby Date: Sun, 5 Jun 2022 17:47:26 +0200 Subject: [PATCH] Switch config to pointer --- app.go | 4 ++-- app_test.go | 2 +- machine_test.go | 12 ++++++------ 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/app.go b/app.go index c835013e..01528fb9 100644 --- a/app.go +++ b/app.go @@ -71,7 +71,7 @@ const ( // Headscale represents the base app of the service. type Headscale struct { - cfg Config + cfg *Config db *gorm.DB dbString string dbType string @@ -115,7 +115,7 @@ func LookupTLSClientAuthMode(mode string) (tls.ClientAuthType, bool) { } } -func NewHeadscale(cfg Config) (*Headscale, error) { +func NewHeadscale(cfg *Config) (*Headscale, error) { privKey, err := readOrCreatePrivateKey(cfg.PrivateKeyPath) if err != nil { return nil, fmt.Errorf("failed to read or create private key: %w", err) diff --git a/app_test.go b/app_test.go index 96036a1d..170db482 100644 --- a/app_test.go +++ b/app_test.go @@ -46,7 +46,7 @@ func (s *Suite) ResetDB(c *check.C) { } app = Headscale{ - cfg: cfg, + cfg: &cfg, dbType: "sqlite3", dbString: tmpDir + "/headscale_test.db", } diff --git a/machine_test.go b/machine_test.go index 0fb3ed78..bde96057 100644 --- a/machine_test.go +++ b/machine_test.go @@ -821,7 +821,7 @@ func TestHeadscale_GenerateGivenName(t *testing.T) { { name: "simple machine name generation", h: &Headscale{ - cfg: Config{ + cfg: &Config{ OIDC: OIDCConfig{ StripEmaildomain: true, }, @@ -836,7 +836,7 @@ func TestHeadscale_GenerateGivenName(t *testing.T) { { name: "machine name with 53 chars", h: &Headscale{ - cfg: Config{ + cfg: &Config{ OIDC: OIDCConfig{ StripEmaildomain: true, }, @@ -851,7 +851,7 @@ func TestHeadscale_GenerateGivenName(t *testing.T) { { name: "machine name with 60 chars", h: &Headscale{ - cfg: Config{ + cfg: &Config{ OIDC: OIDCConfig{ StripEmaildomain: true, }, @@ -866,7 +866,7 @@ func TestHeadscale_GenerateGivenName(t *testing.T) { { name: "machine name with 63 chars", h: &Headscale{ - cfg: Config{ + cfg: &Config{ OIDC: OIDCConfig{ StripEmaildomain: true, }, @@ -881,7 +881,7 @@ func TestHeadscale_GenerateGivenName(t *testing.T) { { name: "machine name with 64 chars", h: &Headscale{ - cfg: Config{ + cfg: &Config{ OIDC: OIDCConfig{ StripEmaildomain: true, }, @@ -896,7 +896,7 @@ func TestHeadscale_GenerateGivenName(t *testing.T) { { name: "machine name with 73 chars", h: &Headscale{ - cfg: Config{ + cfg: &Config{ OIDC: OIDCConfig{ StripEmaildomain: true, },