portainer-devtool/go/configs/repository.go

55 lines
1.2 KiB
Go
Raw Normal View History

package configs
import (
"fmt"
"io/fs"
"log"
"ocl/portainer-devtool/utils"
"path/filepath"
)
func (config *Config) configureRepositories() {
if config.RepositoryConfig == nil {
config.RepositoryConfig = make(map[string]RepositoryConfig)
}
for {
if !utils.PromptConfirm("Set up new repository") {
break
}
repoConfig := RepositoryConfig{}
repoConfig.Name = utils.Prompt("Name")
repoConfig.URL = utils.Prompt("URL")
repoConfig.Directory = utils.Prompt("Directory")
config.RepositoryConfig[repoConfig.Name] = repoConfig
}
utils.HighlightPrint("Configure repositories completed")
}
func (config *Config) generateRepositoriesBasedOnProjectPath(projectPath string) error {
filepath.WalkDir(projectPath, func(path string, d fs.DirEntry, err error) error {
if err != nil {
log.Printf("fail to walk in the project path %s, error: %v\n", projectPath, err)
return err
}
if utils.MatchPathLength(projectPath, path, 1) {
fmt.Println(path)
// posLastSeparator := strings.LastIndex(path, string(filepath.Separator))
// repoName := path[posLastSeparator+1:]
// repoConfig := RepositoryConfig{
// Name: repoName,
// // URL:
// }
// config.RepositoryConfig[repoName] =
}
return nil
})
return nil
}