From 70b5eb8e1f220a2849a6759eda321205fcb79111 Mon Sep 17 00:00:00 2001
From: Niall Sheridan <nsheridan@gmail.com>
Date: Sat, 20 Aug 2016 20:38:08 +0100
Subject: [PATCH] Use references to config structs

---
 cmd/cashierd/main.go         |  8 ++++----
 server/config/config.go      | 16 ++++++++--------
 server/config/config_test.go |  6 +++---
 3 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/cmd/cashierd/main.go b/cmd/cashierd/main.go
index a989e127..e82cbc7a 100644
--- a/cmd/cashierd/main.go
+++ b/cmd/cashierd/main.go
@@ -315,8 +315,8 @@ func main() {
 	if err != nil {
 		log.Fatal(err)
 	}
-	fs.Register(&config.AWS)
-	signer, err := signer.New(&config.SSH)
+	fs.Register(config.AWS)
+	signer, err := signer.New(config.SSH)
 	if err != nil {
 		log.Fatal(err)
 	}
@@ -324,9 +324,9 @@ func main() {
 	var authprovider auth.Provider
 	switch config.Auth.Provider {
 	case "google":
-		authprovider, err = google.New(&config.Auth)
+		authprovider, err = google.New(config.Auth)
 	case "github":
-		authprovider, err = github.New(&config.Auth)
+		authprovider, err = github.New(config.Auth)
 	default:
 		log.Fatalln("Unknown provider %s", config.Auth.Provider)
 	}
diff --git a/server/config/config.go b/server/config/config.go
index dc5e0c50..fb64f6cc 100644
--- a/server/config/config.go
+++ b/server/config/config.go
@@ -10,10 +10,10 @@ import (
 
 // Config holds the server configuration.
 type Config struct {
-	Server Server `mapstructure:"server"`
-	Auth   Auth   `mapstructure:"auth"`
-	SSH    SSH    `mapstructure:"ssh"`
-	AWS    AWS    `mapstructure:"aws"`
+	Server *Server `mapstructure:"server"`
+	Auth   *Auth   `mapstructure:"auth"`
+	SSH    *SSH    `mapstructure:"ssh"`
+	AWS    *AWS    `mapstructure:"aws"`
 }
 
 // unmarshalled holds the raw config.
@@ -96,9 +96,9 @@ func ReadConfig(r io.Reader) (*Config, error) {
 		return nil, err
 	}
 	return &Config{
-		Server: u.Server[0],
-		Auth:   u.Auth[0],
-		SSH:    u.SSH[0],
-		AWS:    u.AWS[0],
+		Server: &u.Server[0],
+		Auth:   &u.Auth[0],
+		SSH:    &u.SSH[0],
+		AWS:    &u.AWS[0],
 	}, nil
 }
diff --git a/server/config/config_test.go b/server/config/config_test.go
index 5752ad0b..982e6e6b 100644
--- a/server/config/config_test.go
+++ b/server/config/config_test.go
@@ -16,7 +16,7 @@ func TestServerConfig(t *testing.T) {
 		t.Fatal(err)
 	}
 	server := c.Server
-	a.IsType(server, Server{})
+	a.IsType(server, &Server{})
 	a.True(server.UseTLS)
 	a.Equal(server.TLSKey, "server.key")
 	a.Equal(server.TLSCert, "server.crt")
@@ -32,7 +32,7 @@ func TestAuthConfig(t *testing.T) {
 		t.Fatal(err)
 	}
 	auth := c.Auth
-	a.IsType(auth, Auth{})
+	a.IsType(auth, &Auth{})
 	a.Equal(auth.Provider, "google")
 	a.Equal(auth.ProviderOpts, map[string]string{"domain": "example.com"})
 	a.Equal(auth.OauthClientID, "client_id")
@@ -47,7 +47,7 @@ func TestSSHConfig(t *testing.T) {
 		t.Fatal(err)
 	}
 	ssh := c.SSH
-	a.IsType(ssh, SSH{})
+	a.IsType(ssh, &SSH{})
 	a.Equal(ssh.SigningKey, "signing_key")
 	a.Equal(ssh.AdditionalPrincipals, []string{"ec2-user", "ubuntu"})
 	a.Equal(ssh.Permissions, []string{"permit-pty", "permit-X11-forwarding", "permit-port-forwarding", "permit-user-rc"})
-- 
GitLab