| 400 | } |
| 401 | |
| 402 | func (c *Celer) CloneConf(url, branch string, force bool) error { |
| 403 | if err := buildtools.CheckTools(c, "git"); err != nil { |
| 404 | return err |
| 405 | } |
| 406 | |
| 407 | confDir := filepath.Join(dirs.WorkspaceDir, "conf") |
| 408 | if fileio.PathExists(confDir) { |
| 409 | modified, err := git.IsModified(confDir) |
| 410 | if err != nil { |
| 411 | return err |
| 412 | } |
| 413 | if modified && !force { |
| 414 | return fmt.Errorf("conf repo has local modifications, update is skipped ... 🚩 you can try with --force/-f 🚩") |
| 415 | } |
| 416 | |
| 417 | if err := git.UpdateRepo("conf repo", branch, confDir, force); err != nil { |
| 418 | return fmt.Errorf("update conf repo -> %w", err) |
| 419 | } |
| 420 | } else { |
| 421 | // Clone conf repo. |
| 422 | if err := git.CloneRepo("[clone conf repo]", "conf repo", url, branch, 0, confDir); err != nil { |
| 423 | return fmt.Errorf("clone conf repo -> %w", err) |
| 424 | } |
| 425 | |
| 426 | if err := c.readOrCreate(); err != nil { |
| 427 | return err |
| 428 | } |
| 429 | |
| 430 | c.Main.ConfRepo = url |
| 431 | if err := c.save(); err != nil { |
| 432 | return err |
| 433 | } |
| 434 | } |
| 435 | |
| 436 | return nil |
| 437 | } |
| 438 | |
| 439 | func (c *Celer) portsRepoUrl() string { |
| 440 | portsRepo := os.Getenv("CELER_PORTS_REPO") |