@@ -21,28 +21,28 @@ import (
2121)
2222
2323type Client struct {
24- Id string
25- SessionId string
24+ ID string
25+ SessionID string
2626 Version string
27- AppId string
27+ AppID string
2828 Track string
2929 config * serverConfig
3030 errorRate int
3131 pingsRemaining int
3232 lock * lock.Lock
3333}
3434
35- func (c * Client ) Log (format string , v ... interface {}) {
36- format = c .Id + ": " + format
37- fmt .Printf (format , v ... )
35+ func (c * Client ) Logf (format string , args ... interface {}) {
36+ format = c .ID + ": " + format
37+ fmt .Printf (format , args ... )
3838}
3939
4040func (c * Client ) failed (tag string , err error ) {
41- c .Log ("%s %v\n " , tag , err )
41+ c .Logf ("%s %v\n " , tag , err )
4242 c .MakeRequest ("3" , "0" , false , false )
4343}
4444
45- func (c * Client ) getCodebaseUrl (uc * omaha.UpdateCheck ) string {
45+ func (c * Client ) getCodebaseURL (uc * omaha.UpdateCheck ) string {
4646 return uc .Urls .Urls [0 ].CodeBase + uc .Manifest .Packages .Packages [0 ].Name
4747}
4848
@@ -61,9 +61,9 @@ func (c *Client) RequestLock() {
6161
6262func (c * Client ) OmahaRequest (otype , result string , updateCheck , isPing bool ) * omaha.Request {
6363 req := omaha .NewRequest ("lsb" , "CoreOS" , "" , "" )
64- app := req .AddApp (c .AppId , c .Version )
65- app .MachineID = c .Id
66- app .BootId = c .SessionId
64+ app := req .AddApp (c .AppID , c .Version )
65+ app .MachineID = c .ID
66+ app .BootId = c .SessionID
6767 app .Track = c .Track
6868 app .OEM = Flags .OEM
6969
@@ -113,15 +113,15 @@ func (c *Client) MakeRequest(otype, result string, updateCheck, isPing bool) (*o
113113
114114 if Flags .verbose {
115115 raw , _ := xml .MarshalIndent (req , "" , " " )
116- c .Log ("request: %s\n " , string (raw ))
116+ c .Logf ("request: %s\n " , string (raw ))
117117 raw , _ = xml .MarshalIndent (oresp , "" , " " )
118- c .Log ("response: %s\n " , string (raw ))
118+ c .Logf ("response: %s\n " , string (raw ))
119119 }
120120
121121 return oresp , nil
122122}
123123
124- // Sleep between n and m seconds
124+ // Loop between n and m seconds
125125func (c * Client ) Loop (n , m int ) {
126126 interval := constant .InitialInterval
127127 for {
@@ -133,15 +133,15 @@ func (c *Client) Loop(n, m int) {
133133 }
134134 uc := resp .Apps [0 ].UpdateCheck
135135 if uc .Status != "ok" {
136- c .Log ("update check status: %s\n " , uc .Status )
136+ c .Logf ("update check status: %s\n " , uc .Status )
137137 } else {
138- url := c .getCodebaseUrl (uc )
138+ url := c .getCodebaseURL (uc )
139139 if ! strings .Contains (url , "deis" ) {
140140 c .failed ("Wrong Url" , err )
141141 continue
142142 }
143143 c .MakeRequest ("13" , "1" , false , false )
144- err = c .downloadFromUrl (url , "/tmp/deis.tar.gz" )
144+ err = c .downloadFromURL (url , "/tmp/deis.tar.gz" )
145145 if err != nil {
146146 c .failed ("Download failed" , err )
147147 continue
@@ -181,7 +181,7 @@ func (c *Client) SetVersion(resp *omaha.Response) {
181181 // A field can potentially be nil.
182182 defer func () {
183183 if err := recover (); err != nil {
184- c .Log ("%s: error setting version: %v" , c .Id , err )
184+ c .Logf ("%s: error setting version: %v" , c .ID , err )
185185 }
186186 }()
187187 uc := resp .Apps [0 ].UpdateCheck
@@ -191,9 +191,9 @@ func (c *Client) SetVersion(resp *omaha.Response) {
191191 c .failed ("update failed" , err )
192192 return
193193 }
194- c .Log ("Installation done " )
194+ c .Logf ("Installation done " )
195195 c .MakeRequest ("2" , "1" , false , false )
196- c .Log ("Update done " )
196+ c .Logf ("Update done " )
197197 c .MakeRequest ("3" , "1" , false , false )
198198 // installed
199199
@@ -204,7 +204,7 @@ func (c *Client) SetVersion(resp *omaha.Response) {
204204 time .Sleep (1 * time .Second )
205205 }
206206
207- c .Log ("updated from %s to %s\n " , c .Version , uc .Manifest .Version )
207+ c .Logf ("updated from %s to %s\n " , c .Version , uc .Manifest .Version )
208208
209209 c .Version = uc .Manifest .Version
210210 utils .PutVersion (c .Version )
@@ -214,7 +214,7 @@ func (c *Client) SetVersion(resp *omaha.Response) {
214214 log .Println (err )
215215 }
216216
217- c .SessionId = uuid .New ()
217+ c .SessionID = uuid .New ()
218218}
219219
220220func (c * Client ) Update () (err error ) {
@@ -250,7 +250,7 @@ func (c *Client) Update() (err error) {
250250 return nil
251251}
252252
253- func (c * Client ) downloadFromUrl (url , filePath string ) (err error ) {
253+ func (c * Client ) downloadFromURL (url , filePath string ) (err error ) {
254254 fmt .Printf ("Downloading %s to %s\n " , url , filePath )
255255
256256 output , err := os .Create (filePath )
0 commit comments