MCPcopy Create free account
hub / github.com/cloud66-oss/starter / analyze

Method analyze

api.go:258–297  ·  view source on GitHub ↗
(w rest.ResponseWriter, r *rest.Request)

Source from the content-addressed store, hash-verified

256}
257
258func (a *API) analyze(w rest.ResponseWriter, r *rest.Request) {
259 /*
260 payload:
261 {
262 "path": "...", //path to the project to be examined
263 "generate": "dockerfile,service,docker-compose" //files to generate
264 }
265
266 response:
267 {
268 "Ok": true,
269 "Language": "ruby",
270 "Framework": "rails",
271 "Warnings": null,
272 "Dockerfile": "...",
273 "Service": "...",
274 "DockerCompose": "..."
275 }
276 */
277
278 type payload struct {
279 Path string `json:"path"`
280 Generate string `json:"generate"`
281 }
282 var request payload
283 err := r.DecodeJsonPayload(&request)
284 if err != nil {
285 a.Error(w, err.Error(), 7, http.StatusInternalServerError)
286 return
287 }
288 path := request.Path
289 generate := request.Generate
290 analysis := analyze_sourcecode(config, path, generate, "", "")
291 if analysis != nil {
292 w.WriteJson(analysis)
293 } else {
294 a.Error(w, "No supported language and/or framework detected", 6, http.StatusOK)
295 }
296
297}
298
299func analyze_sourcecode(config *Config, path string, generate string, git_repo string, git_branch string) *analysisResult {
300

Callers

nothing calls this directly

Calls 2

ErrorMethod · 0.95
analyze_sourcecodeFunction · 0.85

Tested by

no test coverage detected