31 lines
628 B
Go
31 lines
628 B
Go
package projects
|
|
|
|
import (
|
|
"os"
|
|
|
|
"gitlab.sweetwater.com/it/devops/tools/gitlab-project-manager/internal/gitlab"
|
|
)
|
|
|
|
func (c *Cache) GoTo(project *gitlab.Project) {
|
|
pPath := c.path + "/" + project.SanitizedPath()
|
|
|
|
c.log.Debug("Going to project", c.log.Args(
|
|
"project", project.String(),
|
|
"path", pPath,
|
|
))
|
|
|
|
if _, err := os.Stat(pPath); err != nil {
|
|
c.log.Info("Preparing project path")
|
|
c.PrepProjectPath(pPath)
|
|
}
|
|
}
|
|
|
|
func (c *Cache) PrepProjectPath(path string) {
|
|
if err := os.MkdirAll(path, 0750); err != nil {
|
|
c.log.Fatal("Failed to prepare project path", c.log.Args(
|
|
"path", path,
|
|
"error", err,
|
|
))
|
|
}
|
|
}
|