| 297 | } |
| 298 | |
| 299 | func analyze_sourcecode(config *Config, path string, generate string, git_repo string, git_branch string) *analysisResult { |
| 300 | |
| 301 | result, err := analyze( |
| 302 | false, |
| 303 | path, |
| 304 | config.template_path, |
| 305 | "production", |
| 306 | true, |
| 307 | true, |
| 308 | generate, |
| 309 | git_repo, |
| 310 | git_branch, |
| 311 | true) |
| 312 | |
| 313 | if err != nil { |
| 314 | common.PrintL0("%v", err.Error()) |
| 315 | return result |
| 316 | } |
| 317 | |
| 318 | if result.Ok { |
| 319 | //always read the Dockerfile |
| 320 | dockerfile, e := ioutil.ReadFile(path + "/Dockerfile") |
| 321 | if e != nil { |
| 322 | // catch error |
| 323 | result.Dockerfile = "" |
| 324 | } else { |
| 325 | result.Dockerfile = string(dockerfile) |
| 326 | } |
| 327 | |
| 328 | if strings.Contains(generate, "service") { |
| 329 | serviceymlfile, e := ioutil.ReadFile(path + "/service.yml") |
| 330 | if e != nil { |
| 331 | // catch error |
| 332 | result.Service = "" |
| 333 | } else { |
| 334 | result.Service = string(serviceymlfile) |
| 335 | } |
| 336 | } |
| 337 | if strings.Contains(generate, "docker-compose") { |
| 338 | dockercomposeymlfile, e := ioutil.ReadFile(path + "/docker-compose.yml") |
| 339 | if e != nil { |
| 340 | // catch error |
| 341 | result.DockerCompose = "" |
| 342 | } else { |
| 343 | result.DockerCompose = string(dockercomposeymlfile) |
| 344 | } |
| 345 | } |
| 346 | |
| 347 | } |
| 348 | return result |
| 349 | } |
| 350 | func unzip(src, dest string) error { |
| 351 | |
| 352 | var filenames []string |