@@ -114,7 +114,6 @@ func main() {
114114 fmt .Println (err )
115115 os .Exit (1 )
116116 }
117-
118117}
119118
120119func backendsAll () {
@@ -155,10 +154,16 @@ func backendsList() {
155154 fmt .Println (unmarshalErr )
156155 return
157156 }
158- backends := f .([]interface {})
157+ backends , ok := f .([]interface {})
158+ if ! ok {
159+ fmt .Printf ("unexpected type: %T" , f )
160+ }
159161
160162 for _ , backendi := range backends {
161- backend := backendi .(map [string ]interface {})
163+ backend , ok := backendi .(map [string ]interface {})
164+ if ! ok {
165+ fmt .Printf ("unexpected type: %T" , backendi )
166+ }
162167 fmt .Println (backend ["name" ].(string ))
163168 }
164169}
@@ -180,12 +185,22 @@ func backendsGet(name string) {
180185 fmt .Println (unmarshalErr )
181186 return
182187 }
183- backends := f .([]interface {})
188+ backends , ok := f .([]interface {})
189+ if ! ok {
190+ fmt .Printf ("unexpected type: %T" , f )
191+ }
184192
185193 for _ , backendi := range backends {
186- backend := backendi .(map [string ]interface {})
194+ backend , ok := backendi .(map [string ]interface {})
195+ if ! ok {
196+ fmt .Printf ("unexpected type: %T" , backendi )
197+ }
187198 if backend ["name" ].(string ) == name {
188- printed , _ := json .MarshalIndent (backend , "" , " " )
199+ printed , err := json .MarshalIndent (backend , "" , " " )
200+ if err != nil {
201+ fmt .Println (err )
202+ return
203+ }
189204 fmt .Println (string (printed ))
190205 return
191206 }
@@ -213,18 +228,7 @@ func certGet(host string) {
213228}
214229
215230func general () {
216- //TODO: refactor to obtain ingress-nginx pod count from the api server
217- /*
218- statusCode, body, requestErr := nginx.NewGetStatusRequest(generalPath)
219- if requestErr != nil {
220- fmt.Println(requestErr)
221- return
222- }
223- if statusCode != 200 {
224- fmt.Printf("Nginx returned code %v\n", statusCode)
225- return
226- }
227- */
231+ // TODO: refactor to obtain ingress-nginx pod count from the api server
228232
229233 var prettyBuffer bytes.Buffer
230234 indentErr := json .Indent (& prettyBuffer , []byte ("{}" ), "" , " " )
0 commit comments