From 702f599f5f89ecf73aad28654feb27dca7be7469 Mon Sep 17 00:00:00 2001 From: Ryan D McGuire Date: Wed, 17 Jan 2024 10:06:20 -0500 Subject: [PATCH] Move from --gitlab flags to global --remote flags --- cmd/cache_dump.go | 17 ++++--- cmd/cache_load.go | 3 +- cmd/project.go | 7 +-- cmd/project_go.go | 4 +- cmd/project_list.go | 4 +- cmd/project_open.go | 4 +- cmd/project_run.go | 4 +- cmd/project_show.go | 4 +- cmd/root.go | 17 +++++++ cmd/util_completion.go | 18 +------- cmd/util_fzf.go | 14 +++--- cmd/util_init.go | 76 +++++++------------------------ internal/cache/cache.go | 16 +++---- internal/cache/cache_load.go | 13 ++++-- internal/cache/cache_projects.go | 4 +- internal/cache/projects_alias.go | 4 +- internal/remotes/gitea/gitea.go | 25 ++++++++++ internal/remotes/gitlab/gitlab.go | 35 ++++++++++++++ internal/remotes/remote/remote.go | 4 ++ 19 files changed, 152 insertions(+), 121 deletions(-) diff --git a/cmd/cache_dump.go b/cmd/cache_dump.go index 526c40a..ce4b00a 100644 --- a/cmd/cache_dump.go +++ b/cmd/cache_dump.go @@ -13,13 +13,16 @@ var dumpCmd = &cobra.Command{ Long: `Dumps cache to display`, PreRun: runCacheCmd, PostRun: postCacheCmd, - Run: func(cmd *cobra.Command, args []string) { - if conf.Dump.Full { - fmt.Println(projectCache.DumpString(true, searchStringFromArgs(args))) - } else { - plog.Info(projectCache.String()) - } - }, + Run: runCacheDunpCmd, +} + +func runCacheDunpCmd(cmd *cobra.Command, args []string) { + remotes := viper.GetStringSlice("remote") + if conf.Dump.Full { + fmt.Println(projectCache.DumpString(true, searchStringFromArgs(args), remotes...)) + } else { + plog.Info(projectCache.String()) + } } func init() { diff --git a/cmd/cache_load.go b/cmd/cache_load.go index 205a86f..6bd5afc 100644 --- a/cmd/cache_load.go +++ b/cmd/cache_load.go @@ -17,7 +17,8 @@ wants to find a new project.`, } func loadCache(cmd *cobra.Command, args []string) { - projectCache.Refresh() + remotes := viper.GetStringSlice("remote") + projectCache.Refresh(remotes...) } func init() { diff --git a/cmd/project.go b/cmd/project.go index 182ec85..ff68511 100644 --- a/cmd/project.go +++ b/cmd/project.go @@ -20,11 +20,11 @@ var projectCmd = &cobra.Command{ } func getProject(args []string) *projects.Project { - gitlabs := viper.GetStringSlice("project.gitlabs") + remotes := viper.GetStringSlice("remote") fzfOpts := &fzfProjectOpts{ Ctx: rootCmd.Context(), Search: searchStringFromArgs(args), - Gitlabs: gitlabs, + Remotes: remotes, } project := fzfFindProject(fzfOpts) @@ -57,9 +57,6 @@ func postProjectCmd(cmd *cobra.Command, args []string) { func init() { rootCmd.AddCommand(projectCmd) - projectCmd.PersistentFlags().StringArray("gitlab", []string{}, "Specify gitlab remote, provide flag multiple times") - projectCmd.RegisterFlagCompletionFunc("gitlab", validGitlabRemotesFunc) - viper.BindPFlag("project.gitlabs", projectCmd.Flag("gitlab")) } func mustHaveProjects(cmd *cobra.Command, args []string) { diff --git a/cmd/project_go.go b/cmd/project_go.go index 41e266a..120abb6 100644 --- a/cmd/project_go.go +++ b/cmd/project_go.go @@ -21,12 +21,12 @@ var projectGoCmd = &cobra.Command{ } func projectGoCmdRun(cmd *cobra.Command, args []string) { - gitlabs := viper.GetStringSlice("project.gitlabs") + remotes := viper.GetStringSlice("remote") fzfOpts := &fzfProjectOpts{ Ctx: cmd.Context(), Search: searchStringFromArgs(args), MustHaveAlias: true, - Gitlabs: gitlabs, + Remotes: remotes, } project := fzfSearchProjectAliases(fzfOpts) diff --git a/cmd/project_list.go b/cmd/project_list.go index 532ff38..b8e4272 100644 --- a/cmd/project_list.go +++ b/cmd/project_list.go @@ -16,8 +16,8 @@ var projectListCmd = &cobra.Command{ } func projectListCmdRun(cmd *cobra.Command, args []string) { - gitlabs := viper.GetStringSlice("project.gitlabs") - fmt.Println(projectCache.DumpString(viper.GetBool("project.list.all"), searchStringFromArgs(args), gitlabs...)) + remotes := viper.GetStringSlice("remote") + fmt.Println(projectCache.DumpString(viper.GetBool("project.list.all"), searchStringFromArgs(args), remotes...)) } func init() { diff --git a/cmd/project_open.go b/cmd/project_open.go index f991fba..7033529 100644 --- a/cmd/project_open.go +++ b/cmd/project_open.go @@ -51,11 +51,11 @@ func projectOpenCmdRun(cmd *cobra.Command, args []string) { plog.Fatal("No usable editor found") } - gitlabs := viper.GetStringSlice("project.gitlabs") + remotes := viper.GetStringSlice("remote") fzfOpts := &fzfProjectOpts{ Ctx: cmd.Context(), Search: searchStringFromArgs(args), - Gitlabs: gitlabs, + Remotes: remotes, } project := fzfCwdOrSearchProjectAliases(fzfOpts) if project == nil { diff --git a/cmd/project_run.go b/cmd/project_run.go index e78f728..f727818 100644 --- a/cmd/project_run.go +++ b/cmd/project_run.go @@ -18,11 +18,11 @@ var projectRunCmd = &cobra.Command{ } func projectRunCmdRun(cmd *cobra.Command, args []string) { - gitlabs := viper.GetStringSlice("project.gitlabs") + remotes := viper.GetStringSlice("remote") fzfOpts := &fzfProjectOpts{ Ctx: cmd.Context(), Search: searchStringFromArgs(args), - Gitlabs: gitlabs, + Remotes: remotes, } project := fzfCwdOrSearchProjectAliases(fzfOpts) if project == nil { diff --git a/cmd/project_show.go b/cmd/project_show.go index df73185..cd18157 100644 --- a/cmd/project_show.go +++ b/cmd/project_show.go @@ -23,11 +23,11 @@ func projectShowCmdRun(cmd *cobra.Command, args []string) { var project *projects.Project var inCwd bool - gitlabs := viper.GetStringSlice("project.gitlabs") + remotes := viper.GetStringSlice("remote") fzfOpts := &fzfProjectOpts{ Ctx: cmd.Context(), Search: searchStringFromArgs(args), - Gitlabs: gitlabs, + Remotes: remotes, } // Try to find project from current directory diff --git a/cmd/root.go b/cmd/root.go index d2d4d82..58c53a8 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -10,6 +10,8 @@ import ( "github.com/spf13/cobra" "github.com/spf13/viper" "gitlab.sweetwater.com/it/devops/tools/gitlab-project-manager/internal/config" + gitearemote "gitlab.sweetwater.com/it/devops/tools/gitlab-project-manager/internal/remotes/gitea" + gitlabremote "gitlab.sweetwater.com/it/devops/tools/gitlab-project-manager/internal/remotes/gitlab" ) var conf config.Config @@ -47,6 +49,7 @@ func init() { cobra.EnableTraverseRunHooks = true cobra.OnInitialize(initConfig) + // Global flags rootCmd.PersistentFlags().String("config", "", "config file (default is "+defConfigPath+")") rootCmd.PersistentFlags().String("projectPath", "", @@ -56,7 +59,9 @@ func init() { rootCmd.PersistentFlags().StringSlice("remote", []string{}, "Specify remotes by host for any sub-command. Provide multiple times or comma delimited.") + // Flag autocompletion rootCmd.RegisterFlagCompletionFunc("logLevel", validLogLevelsFunc) + rootCmd.RegisterFlagCompletionFunc("remote", validRemotesFunc) viper.BindPFlags(rootCmd.PersistentFlags()) } @@ -106,6 +111,7 @@ func initConfig() { } checkConfigPerms(viper.ConfigFileUsed()) // Abort on world-readable config + setConfigFields() // Final chance to update config struct plog.Debug("Configuration loaded", plog.Args("conf", conf)) } @@ -127,6 +133,17 @@ func getPtermLogLevel(level string) pterm.LogLevel { return pLevel } +// Do any post-processing of configuration here +func setConfigFields() { + // Load Gitlabs + glRemotes := gitlabremote.GitlabRemote{} + conf.Remotes = append(conf.Remotes, glRemotes.GetInfos(conf)...) + + // Load Giteas + giteaRemotes := gitearemote.GiteaRemote{} + conf.Remotes = append(conf.Remotes, giteaRemotes.GetInfos(conf)...) +} + // Don't allow world-readable configuration func checkConfigPerms(file string) { stat, err := os.Stat(file) diff --git a/cmd/util_completion.go b/cmd/util_completion.go index fece2d3..e07b2b5 100644 --- a/cmd/util_completion.go +++ b/cmd/util_completion.go @@ -29,22 +29,8 @@ func validProjectsOrAliasesFunc(cmd *cobra.Command, args []string, toComplete st func validRemotesFunc(cmd *cobra.Command, args []string, toComplete string) ( []string, cobra.ShellCompDirective) { - var ttlRemotes int - ttlRemotes += len(conf.Gitlabs) - ttlRemotes += len(conf.Giteas) - remotes := make([]string, 0, ttlRemotes) - for _, remote := range conf.Gitlabs { - if strings.HasPrefix(remote.Host, toComplete) { - remotes = append(remotes, remote.Host) - } - } - return remotes, cobra.ShellCompDirectiveNoFileComp -} - -func validGitlabRemotesFunc(cmd *cobra.Command, args []string, toComplete string) ( - []string, cobra.ShellCompDirective) { - remotes := make([]string, 0, len(conf.Gitlabs)) - for _, remote := range conf.Gitlabs { + remotes := make([]string, 0, len(conf.Remotes)) + for _, remote := range conf.Remotes { if strings.HasPrefix(remote.Host, toComplete) { remotes = append(remotes, remote.Host) } diff --git a/cmd/util_fzf.go b/cmd/util_fzf.go index 43f0235..7462caa 100644 --- a/cmd/util_fzf.go +++ b/cmd/util_fzf.go @@ -13,7 +13,7 @@ type fzfProjectOpts struct { Ctx context.Context Search string MustHaveAlias bool - Gitlabs []string + Remotes []string } // This will try to find a project by alias if a search term @@ -52,7 +52,7 @@ func fzfCwdOrSearchProjectAliases(opts *fzfProjectOpts) *projects.Project { func fzfSearchProjectAliases(opts *fzfProjectOpts) *projects.Project { var project *projects.Project var alias *cache.ProjectAlias - if alias = projectCache.GetAliasByName(opts.Search, opts.Gitlabs...); alias != nil { + if alias = projectCache.GetAliasByName(opts.Search, opts.Remotes...); alias != nil { project = projectCache.GetProjectByAlias(alias) plog.Info("Perfect alias match... flawless") } else { @@ -130,8 +130,8 @@ func fzfProject(opts *fzfProjectOpts) (*projects.Project, error) { } else { searchableProjects = projectCache.Projects } - // Filter out unwanted gitlabs if provided - searchableProjects = filterProjectsWithGitlabs(searchableProjects, opts.Gitlabs...) + // Filter out unwanted remotes if provided + searchableProjects = filterProjectsWithRemotes(searchableProjects, opts.Remotes...) return fzfProjectFromProjects(opts, searchableProjects) } @@ -162,11 +162,11 @@ func fzfPreviewWindow(i, w, h int) string { return projectCache.ProjectString(p) } -func filterProjectsWithGitlabs(gitProjects []*projects.Project, gitlabs ...string) []*projects.Project { +func filterProjectsWithRemotes(gitProjects []*projects.Project, remotes ...string) []*projects.Project { filteredProjects := make([]*projects.Project, 0, len(gitProjects)) - if len(gitlabs) > 0 { + if len(remotes) > 0 { for _, p := range gitProjects { - if slices.Contains(gitlabs, p.Remote) { + if slices.Contains(remotes, p.Remote) { filteredProjects = append(filteredProjects, p) } } diff --git a/cmd/util_init.go b/cmd/util_init.go index 097f61c..cedc4b8 100644 --- a/cmd/util_init.go +++ b/cmd/util_init.go @@ -12,7 +12,6 @@ import ( "gitlab.sweetwater.com/it/devops/tools/gitlab-project-manager/internal/remotes" gitearemote "gitlab.sweetwater.com/it/devops/tools/gitlab-project-manager/internal/remotes/gitea" gitlabremote "gitlab.sweetwater.com/it/devops/tools/gitlab-project-manager/internal/remotes/gitlab" - "gitlab.sweetwater.com/it/devops/tools/gitlab-project-manager/internal/remotes/info" "gitlab.sweetwater.com/it/devops/tools/gitlab-project-manager/internal/remotes/remote" "golang.org/x/sys/unix" ) @@ -28,12 +27,7 @@ func initProjectCache(cmd *cobra.Command, args []string) { conf.Cache.File = conf.ProjectPath + "/.cache.yaml" gitRemotes := remotes.NewRemotes() - - // Load GitLabs - gitRemotes.AddRemotes(getGitLabRemotes(cmd)...) - - // Load Giteas - gitRemotes.AddRemotes(getGiteaRemotes(cmd)...) + gitRemotes.AddRemotes(getRemotes(cmd)...) cacheOpts := &cache.CacheOpts{ ProjectsPath: conf.ProjectPath, @@ -56,68 +50,30 @@ func initProjectCache(cmd *cobra.Command, args []string) { plog.Debug("Remotes Loaded", plog.Args("remotes", cacheOpts.Remotes)) } -// Loads all configured giteas -func getGiteaRemotes(cmd *cobra.Command) []remote.Remote { +// Generically loads remotes from info.RemoteInfo in config.Remotes +func getRemotes(cmd *cobra.Command) []remote.Remote { gitRemotes := make([]remote.Remote, 0) - for _, gitea := range conf.Giteas { - if gitea.CloneProto == "" { - gitea.CloneProto = info.DefaultCloneProto + for _, r := range conf.Remotes { + r.Ctx = cmd.Context() + var gitRemote remote.Remote + var err error + switch r.Type { + case "gitlab": + gitRemote, err = gitlabremote.NewGitlabRemote(&r) + case "gitea": + gitRemote, err = gitearemote.NewGiteaRemote(&r) } - giteaRemote, err := gitearemote.NewGiteaRemote(&info.RemoteInfo{ - Ctx: cmd.Context(), - Host: gitea.Host, - Name: gitea.Name, - Token: gitea.Token, - Type: "gitea", - CloneProto: gitea.CloneProto, - }) if err != nil { - plog.Error("Failed to prepare Gitea remote", plog.Args("error", err)) + plog.Error("Failed to prepare remote", plog.Args( + "error", err, + "type", r.Type)) } else { - gitRemotes = append(gitRemotes, giteaRemote) + gitRemotes = append(gitRemotes, gitRemote) } } return gitRemotes } -// Loads all configured gitlabs, including as defined by legacy -// top-level keys -func getGitLabRemotes(cmd *cobra.Command) []remote.Remote { - gitRemotes := make([]remote.Remote, 0) - - // Support legacy keys - if conf.GitlabHost != "" && conf.GitlabToken != "" { - conf.Gitlabs = append(conf.Gitlabs, config.GitlabConfig{ - Host: conf.GitlabHost, - Name: conf.GitlabHost, - Token: conf.GitlabToken, - CloneProto: info.CloneProtoSSH, - }) - } - - // Load Gitlabs - for _, gl := range conf.Gitlabs { - if gl.CloneProto == "" { - gl.CloneProto = info.DefaultCloneProto - } - gitlabRemote, err := gitlabremote.NewGitlabRemote(&info.RemoteInfo{ - Ctx: cmd.Context(), - Host: gl.Host, - Name: gl.Name, - Token: gl.Token, - Type: "gitlab", - CloneProto: gl.CloneProto, - }) - if err != nil { - plog.Error("Failed to prepare GitLab remote", plog.Args("error", err)) - } else { - gitRemotes = append(gitRemotes, gitlabRemote) - } - } - - return gitRemotes -} - func postProjectCache(cmd *cobra.Command, args []string) { projectCache.Write() } diff --git a/internal/cache/cache.go b/internal/cache/cache.go index ef7958d..7177084 100644 --- a/internal/cache/cache.go +++ b/internal/cache/cache.go @@ -17,7 +17,7 @@ type Cache struct { Projects []*projects.Project Aliases []*ProjectAlias Updated time.Time - Remotes *remotes.Remotes + remotes *remotes.Remotes config *config.Config readFromFile bool lock *sync.Mutex // Lock the entire cache @@ -138,22 +138,22 @@ func (c *Cache) Clear(clearAliases bool) { c.clear(clearAliases) } -func (c *Cache) refresh() { +func (c *Cache) refresh(remotes ...string) { c.log.Info("Loading project cache, this may take a while\n") defer c.setUpdated() // Fix any dangling aliases // For backwards-compatibility only c.setAliasRemotes() // Retrieve and add/update projects - c.LoadRemotes() + c.LoadRemotes(remotes...) } // Iterates through all GitLab projects the user has access to, updating // the project cache where necessary -func (c *Cache) Refresh() { +func (c *Cache) Refresh(remotes ...string) { c.lock.Lock() defer c.lock.Unlock() - c.refresh() + c.refresh(remotes...) } func (c *Cache) String() string { @@ -161,9 +161,9 @@ func (c *Cache) String() string { c.Updated.String(), len(c.Projects), len(c.Aliases), - len(*c.Remotes), + len(*c.remotes), ) - for _, r := range *c.Remotes { + for _, r := range *c.remotes { cacheString += " " + r.GetInfo().Host } return cacheString @@ -202,7 +202,7 @@ func NewProjectCache(opts *CacheOpts) (*Cache, error) { lock: &sync.Mutex{}, contentLock: &sync.Mutex{}, log: opts.Logger, - Remotes: opts.Remotes, + remotes: opts.Remotes, path: opts.ProjectsPath, } diff --git a/internal/cache/cache_load.go b/internal/cache/cache_load.go index 03e588c..4265ca0 100644 --- a/internal/cache/cache_load.go +++ b/internal/cache/cache_load.go @@ -8,17 +8,24 @@ import ( "gitlab.sweetwater.com/it/devops/tools/gitlab-project-manager/internal/remotes" "gitlab.sweetwater.com/it/devops/tools/gitlab-project-manager/internal/remotes/load" "gitlab.sweetwater.com/it/devops/tools/gitlab-project-manager/internal/remotes/remote" + "golang.org/x/exp/slices" ) -func (c *Cache) LoadRemotes() { +func (c *Cache) LoadRemotes(gitRemotes ...string) { wg := &sync.WaitGroup{} writer := pterm.DefaultMultiPrinter - for _, r := range *c.Remotes { + for _, r := range *c.remotes { + // Don't bother if it's dead or the user has provided + // one or more remotes via --remote flag(s) if !remote.IsAlive(r) { c.log.Error("Skipping load of remote, not alive", c.log.Args( + "remote", r.String())) + continue + } else if !slices.Contains(gitRemotes, r.GetInfo().Host) { + c.log.Debug("Skipping remote not in --remote list", c.log.Args( "remote", r.String(), - )) + "remotes", gitRemotes)) continue } diff --git a/internal/cache/cache_projects.go b/internal/cache/cache_projects.go index f743c3e..b0cf424 100644 --- a/internal/cache/cache_projects.go +++ b/internal/cache/cache_projects.go @@ -43,7 +43,7 @@ func (c *Cache) AddProjects(gitProjects ...*projects.Project) { // This command will only dump projects that have // been cloned locally. Setting all to true will list all projects -func (c *Cache) DumpString(all bool, search string, gitlabs ...string) string { +func (c *Cache) DumpString(all bool, search string, remotes ...string) string { str := strings.Builder{} var term string if all { @@ -56,7 +56,7 @@ func (c *Cache) DumpString(all bool, search string, gitlabs ...string) string { for _, project := range projects { if !all && !c.IsProjectCloned(project) { continue - } else if len(gitlabs) > 0 && !slices.Contains(gitlabs, project.Remote) { + } else if len(remotes) > 0 && !slices.Contains(remotes, project.Remote) { continue } str.WriteString(" - " + pterm.FgLightBlue.Sprint(project.Name) + " (") diff --git a/internal/cache/projects_alias.go b/internal/cache/projects_alias.go index 5f11692..1e79ddf 100644 --- a/internal/cache/projects_alias.go +++ b/internal/cache/projects_alias.go @@ -71,9 +71,9 @@ func (c *Cache) AliasStrings(prefix string) []string { return aliases } -func (c *Cache) GetAliasByName(name string, gitlabs ...string) *ProjectAlias { +func (c *Cache) GetAliasByName(name string, remotes ...string) *ProjectAlias { for _, a := range c.Aliases { - if len(gitlabs) > 0 && !slices.Contains(gitlabs, a.Remote) { + if len(remotes) > 0 && !slices.Contains(remotes, a.Remote) { continue } if name == a.Alias { diff --git a/internal/remotes/gitea/gitea.go b/internal/remotes/gitea/gitea.go index 9b92e2b..91a04c6 100644 --- a/internal/remotes/gitea/gitea.go +++ b/internal/remotes/gitea/gitea.go @@ -4,6 +4,7 @@ import ( "fmt" "code.gitea.io/sdk/gitea" + "gitlab.sweetwater.com/it/devops/tools/gitlab-project-manager/internal/config" "gitlab.sweetwater.com/it/devops/tools/gitlab-project-manager/internal/remotes/info" ) @@ -12,6 +13,30 @@ type GiteaRemote struct { api *gitea.Client } +func (r *GiteaRemote) GetInfos(conf config.Config) []info.RemoteInfo { + // Prepare infos + infos := make([]info.RemoteInfo, len(conf.Giteas)) + for i, g := range conf.Giteas { + // Set Defaults + proto := info.CloneProtoSSH + if g.CloneProto == info.CloneProtoHTTP { + proto = info.CloneProtoHTTP + } + if g.Name == "" { + g.Name = g.Host + } + + infos[i] = info.RemoteInfo{ + Host: g.Host, + Name: g.Name, + Type: "gitea", + Token: g.Token, + CloneProto: proto, + } + } + return infos +} + func (r *GiteaRemote) GetInfo() *info.RemoteInfo { return r.info } diff --git a/internal/remotes/gitlab/gitlab.go b/internal/remotes/gitlab/gitlab.go index 538a6df..2e1f57f 100644 --- a/internal/remotes/gitlab/gitlab.go +++ b/internal/remotes/gitlab/gitlab.go @@ -4,6 +4,7 @@ import ( "fmt" "github.com/xanzy/go-gitlab" + "gitlab.sweetwater.com/it/devops/tools/gitlab-project-manager/internal/config" "gitlab.sweetwater.com/it/devops/tools/gitlab-project-manager/internal/remotes/info" ) @@ -12,6 +13,40 @@ type GitlabRemote struct { api *gitlab.Client } +func (r *GitlabRemote) GetInfos(conf config.Config) []info.RemoteInfo { + // Support legacy fields + if conf.GitlabHost != "" && conf.GitlabToken != "" { + conf.Gitlabs = append(conf.Gitlabs, config.GitlabConfig{ + Host: conf.GitlabHost, + Name: conf.GitlabHost, + Token: conf.GitlabToken, + CloneProto: info.CloneProtoSSH, + }) + } + + // Prepare infos + infos := make([]info.RemoteInfo, len(conf.Gitlabs)) + for i, g := range conf.Gitlabs { + // Set Defaults + proto := info.CloneProtoSSH + if g.CloneProto == info.CloneProtoHTTP { + proto = info.CloneProtoHTTP + } + if g.Name == "" { + g.Name = g.Host + } + + infos[i] = info.RemoteInfo{ + Host: g.Host, + Name: g.Name, + Type: "gitlab", + Token: g.Token, + CloneProto: proto, + } + } + return infos +} + func (r *GitlabRemote) GetInfo() *info.RemoteInfo { return r.info } diff --git a/internal/remotes/remote/remote.go b/internal/remotes/remote/remote.go index c7c33e1..8b14061 100644 --- a/internal/remotes/remote/remote.go +++ b/internal/remotes/remote/remote.go @@ -6,6 +6,7 @@ import ( "net/url" "time" + "gitlab.sweetwater.com/it/devops/tools/gitlab-project-manager/internal/config" "gitlab.sweetwater.com/it/devops/tools/gitlab-project-manager/internal/remotes/info" "gitlab.sweetwater.com/it/devops/tools/gitlab-project-manager/internal/remotes/load" ) @@ -17,6 +18,9 @@ const defNetDialTimeoutSecs = 3 // stream all projects along with updates to channels // provided by *load.ProgressInfo type Remote interface { + // Helper to process configs. + // Realistically, conf.Gitlabs and conf.Giteas should be conf.Remotes + GetInfos(config.Config) []info.RemoteInfo String() string // String info for remote GetInfo() *info.RemoteInfo // Returns basic RemoteInfo struct GetType() string // Returns the remote type (e.g. GitLab, Gitea)