@@ -130,33 +130,35 @@ type statsRequest struct {
130130 Subcontainers bool `json:"subcontainers,omitempty"`
131131}
132132
133- // Get stats for all non-Kubernetes containers.
134- func (self * KubeletClient ) GetAllRawContainers (host Host , start , end time.Time ) ([]cadvisor.ContainerInfo , error ) {
135- scheme := "http"
133+ func (self * KubeletClient ) getScheme () string {
136134 if self .config != nil && self .config .EnableHttps {
137- scheme = "https"
135+ return "https"
136+ } else {
137+ return "http"
138138 }
139+ }
139140
141+ func (self * KubeletClient ) getUrl (host Host , path string ) string {
140142 url := url.URL {
141- Scheme : scheme ,
143+ Scheme : self . getScheme () ,
142144 Host : host .String (),
143- Path : "/stats/container/" ,
145+ Path : path ,
144146 }
145147
146- return self .getAllContainers (url .String (), start , end )
148+ return url .String ()
149+ }
150+
151+ // Get stats for all non-Kubernetes containers.
152+ func (self * KubeletClient ) GetAllRawContainers (host Host , start , end time.Time ) ([]cadvisor.ContainerInfo , error ) {
153+ url := self .getUrl (host , "/stats/container/" )
154+
155+ return self .getAllContainers (url , start , end )
147156}
148157
149158func (self * KubeletClient ) GetSummary (host Host ) (* stats.Summary , error ) {
150- url := url.URL {
151- Scheme : "http" ,
152- Host : host .String (),
153- Path : "/stats/summary/" ,
154- }
155- if self .config != nil && self .config .EnableHttps {
156- url .Scheme = "https"
157- }
159+ url := self .getUrl (host , "/stats/summary/" )
158160
159- req , err := http .NewRequest ("GET" , url . String () , nil )
161+ req , err := http .NewRequest ("GET" , url , nil )
160162 if err != nil {
161163 return nil , err
162164 }
0 commit comments