(w http.ResponseWriter, r *http.Request)
| 219 | } |
| 220 | |
| 221 | func (h *handler) returnConfig(w http.ResponseWriter, r *http.Request) { |
| 222 | profile := "" |
| 223 | retConfig := &returnConfig{ |
| 224 | AnalyticsEnabled: h.analyticsEnabled, |
| 225 | Profile: profile, |
| 226 | WorkingDirectory: h.ctx.WorkingDir(), |
| 227 | KubeContexts: h.kubeContexts, |
| 228 | } |
| 229 | if h.ctx.Config() != nil { |
| 230 | retConfig.RawConfig = h.ctx.Config().Raw() |
| 231 | retConfig.Config = h.ctx.Config().Config() |
| 232 | retConfig.LocalCache = localCache{ |
| 233 | Vars: h.ctx.Config().Variables(), |
| 234 | LastContext: h.ctx.Config().LocalCache().GetLastContext(), |
| 235 | } |
| 236 | } |
| 237 | if h.ctx.KubeClient() != nil { |
| 238 | retConfig.KubeNamespace = h.ctx.KubeClient().Namespace() |
| 239 | retConfig.KubeContext = h.ctx.KubeClient().CurrentContext() |
| 240 | } |
| 241 | |
| 242 | s, err := yaml.Marshal(retConfig) |
| 243 | if err != nil { |
| 244 | http.Error(w, err.Error(), http.StatusInternalServerError) |
| 245 | return |
| 246 | } |
| 247 | |
| 248 | var data interface{} |
| 249 | if err := yamlutil.Unmarshal([]byte(s), &data); err != nil { |
| 250 | http.Error(w, err.Error(), http.StatusInternalServerError) |
| 251 | return |
| 252 | } |
| 253 | |
| 254 | data = yamlutil.Convert(data) |
| 255 | |
| 256 | b, err := json.Marshal(data) |
| 257 | if err != nil { |
| 258 | http.Error(w, err.Error(), http.StatusInternalServerError) |
| 259 | return |
| 260 | } |
| 261 | |
| 262 | w.Header().Set("Content-Type", "application/json") |
| 263 | _, _ = w.Write(b) |
| 264 | } |
| 265 | |
| 266 | func (h *handler) request(w http.ResponseWriter, r *http.Request) { |
| 267 | resource, ok := r.URL.Query()["resource"] |
nothing calls this directly
no test coverage detected