From 2bea900a74e03ccd2e38c0180819dacc07dac7c9 Mon Sep 17 00:00:00 2001
From: ale <ale@incal.net>
Date: Thu, 15 Oct 2015 12:00:23 +0000
Subject: [PATCH] do not export internal types

---
 node/doc.go            |  4 +++-
 node/icecast.go        | 20 ++++++++++----------
 node/icecast_config.go | 10 +++++-----
 node/icecast_test.go   |  2 +-
 node/node.go           |  4 ++--
 node/node_test.go      |  4 ++--
 6 files changed, 23 insertions(+), 21 deletions(-)

diff --git a/node/doc.go b/node/doc.go
index 17645cdd..d01ccb89 100644
--- a/node/doc.go
+++ b/node/doc.go
@@ -1,4 +1,6 @@
-// The 'node' supervisor is the daemon that controls the Icecast
+// Package node implements the Icecast node supervisor.
+//
+// The node supervisor is the daemon that controls the Icecast
 // server, updating its configuration according to what is stored in
 // the distributed database (etcd).
 //
diff --git a/node/icecast.go b/node/icecast.go
index a9c0bc30..8fe19d8a 100644
--- a/node/icecast.go
+++ b/node/icecast.go
@@ -47,21 +47,21 @@ type icecastStatusUnparsed struct {
 	Mounts  []icecastMountStatusUnparsed `xml:"mount"`
 }
 
-type IcecastStatus struct {
+type icecastStatus struct {
 	Mounts []autoradio.IcecastMountStatus
 	Up     bool
 }
 
 type icecastController struct {
 	config *icecastConfig
-	status *IcecastStatus
+	status *icecastStatus
 	stop   chan bool
 }
 
-func NewIcecastController(publicIp string, maxClients int) *icecastController {
+func newIcecastController(publicIP string, maxClients int) *icecastController {
 	return &icecastController{
-		config: newIcecastConfig(publicIp, maxClients),
-		status: &IcecastStatus{},
+		config: newIcecastConfig(publicIP, maxClients),
+		status: &icecastStatus{},
 	}
 }
 
@@ -138,13 +138,13 @@ func (ic *icecastController) Update(conf *clusterConfig, isMaster bool, masterAd
 	return nil
 }
 
-func (ic *icecastController) GetStatus() *IcecastStatus {
+func (ic *icecastController) GetStatus() *icecastStatus {
 	return ic.status
 }
 
 func (ic *icecastController) Run(stop chan bool) {
 	t := time.NewTicker(3 * time.Second)
-	downStatus := &IcecastStatus{}
+	downStatus := &icecastStatus{}
 	for {
 		select {
 		case <-t.C:
@@ -162,7 +162,7 @@ func (ic *icecastController) Run(stop chan bool) {
 	}
 }
 
-func (ic *icecastController) fetchStatus() (*IcecastStatus, error) {
+func (ic *icecastController) fetchStatus() (*icecastStatus, error) {
 	resp, err := http.Get(fmt.Sprintf("http://localhost:%d%s", autoradio.IcecastPort, statusPage))
 	if err != nil {
 		return nil, err
@@ -171,7 +171,7 @@ func (ic *icecastController) fetchStatus() (*IcecastStatus, error) {
 	return ic.parseStatusPage(resp.Body)
 }
 
-func (ic *icecastController) parseStatusPage(input io.Reader) (*IcecastStatus, error) {
+func (ic *icecastController) parseStatusPage(input io.Reader) (*icecastStatus, error) {
 	var ustatus icecastStatusUnparsed
 	if err := xml.NewDecoder(input).Decode(&ustatus); err != nil {
 		return nil, err
@@ -191,7 +191,7 @@ func (ic *icecastController) parseStatusPage(input io.Reader) (*IcecastStatus, e
 		return 0
 	}
 
-	status := IcecastStatus{
+	status := icecastStatus{
 		Up:     true,
 		Mounts: make([]autoradio.IcecastMountStatus, 0, len(ustatus.Mounts)),
 	}
diff --git a/node/icecast_config.go b/node/icecast_config.go
index be855363..c080de2d 100644
--- a/node/icecast_config.go
+++ b/node/icecast_config.go
@@ -136,7 +136,7 @@ type icecastConfig struct {
 // to a file for persistence. It is not really meant to be used by the
 // operator.
 //
-func newIcecastConfig(publicIp string, maxClients int) *icecastConfig {
+func newIcecastConfig(publicIP string, maxClients int) *icecastConfig {
 	// We don't use the global source password, but icecast is
 	// happier if it's set, so we just use a random password every
 	// time.
@@ -159,7 +159,7 @@ func newIcecastConfig(publicIp string, maxClients int) *icecastConfig {
 			AdminUser:      "admin",
 			AdminPassword:  adminPw,
 		},
-		Hostname:  publicIp,
+		Hostname:  publicIP,
 		Fileserve: 1,
 		Paths: icePathsConfig{
 			Basedir:   "/usr/share/icecast2",
@@ -270,7 +270,7 @@ func (l mountList) Less(i, j int) bool {
 // masterelection state. This will clear the Mounts and Relays fields
 // and set them to new values. The mounts are sorted by name so that
 // the XML representation generated by Encode() is consistent.
-func (ic *icecastConfig) Update(config *clusterConfig, isMaster bool, masterAddr string) {
+func (c *icecastConfig) Update(config *clusterConfig, isMaster bool, masterAddr string) {
 	var mounts []iceMountConfig
 	var relays []iceRelayConfig
 
@@ -290,6 +290,6 @@ func (ic *icecastConfig) Update(config *clusterConfig, isMaster bool, masterAddr
 		}
 	}
 
-	ic.Mounts = mounts
-	ic.Relays = relays
+	c.Mounts = mounts
+	c.Relays = relays
 }
diff --git a/node/icecast_test.go b/node/icecast_test.go
index 983dc507..16b87e66 100644
--- a/node/icecast_test.go
+++ b/node/icecast_test.go
@@ -9,7 +9,7 @@ func TestIcecast_TestParseStatusPage(t *testing.T) {
 	xml := `<?xml version="1.0"?>
 <status><mount name="/test.ogg"><listeners>3</listeners><bitrate/><quality/><video-quality/><frame-size/><frame-rate/></mount></status>`
 
-	ic := NewIcecastController("1.2.3.4", 1000)
+	ic := newIcecastController("1.2.3.4", 1000)
 	result, err := ic.parseStatusPage(strings.NewReader(xml))
 	if err != nil {
 		t.Fatal(err)
diff --git a/node/node.go b/node/node.go
index dfdc0f74..4af9f0ef 100644
--- a/node/node.go
+++ b/node/node.go
@@ -134,7 +134,7 @@ func (c *configWatcher) Delete(key string) {
 // replace real processes with mocks while testing.
 type controller interface {
 	Update(*clusterConfig, bool, net.IP) error
-	GetStatus() *IcecastStatus
+	GetStatus() *icecastStatus
 	Run(chan bool)
 }
 
@@ -229,7 +229,7 @@ func NewRadioNode(name string, ips []net.IP, netDev string, bwLimit float64, max
 			uint64(*masterElectionTTL),
 			mech),
 		syncer:  newConfigWatcher(client, config, upch),
-		icecast: NewIcecastController(name, maxListeners*2),
+		icecast: newIcecastController(name, maxListeners*2),
 		transcoderFn: func(p *liquidsoapParams) (transcodingController, error) {
 			return newLiquidsoap(p)
 		},
diff --git a/node/node_test.go b/node/node_test.go
index 856e1cc2..1d91318b 100644
--- a/node/node_test.go
+++ b/node/node_test.go
@@ -30,8 +30,8 @@ func (m *mockController) Update(conf *clusterConfig, isMaster bool, masterAddr n
 	return nil
 }
 
-func (m *mockController) GetStatus() *IcecastStatus {
-	return &IcecastStatus{Up: true}
+func (m *mockController) GetStatus() *icecastStatus {
+	return &icecastStatus{Up: true}
 }
 
 type mockTranscoder struct {
-- 
GitLab