Remove all legacy config
This commit is contained in:
@ -4,7 +4,6 @@ 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"
|
||||
)
|
||||
|
||||
@ -13,46 +12,12 @@ 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
|
||||
}
|
||||
|
||||
func (r *GitlabRemote) GetType() string {
|
||||
return r.info.Type
|
||||
return r.info.Type.String()
|
||||
}
|
||||
|
||||
func (r *GitlabRemote) String() string {
|
||||
|
@ -120,6 +120,6 @@ func (r *GitlabRemote) GetProjectLanguages(project *gitlab.Project) *projects.Pr
|
||||
|
||||
func (r *GitlabRemote) GetDefaultRequestOptions() []gitlab.RequestOptionFunc {
|
||||
requestOpts := make([]gitlab.RequestOptionFunc, 1)
|
||||
requestOpts[0] = gitlab.WithContext(r.GetInfo().Ctx)
|
||||
requestOpts[0] = gitlab.WithContext(r.GetInfo().Context())
|
||||
return requestOpts
|
||||
}
|
||||
|
@ -54,7 +54,7 @@ func (r *GitlabRemote) StreamProjects(pi *load.ProgressInfo, opts *remote.Remote
|
||||
|
||||
// We're done when we have it all or our context is done
|
||||
// or we've hit our total pages
|
||||
if r.info.Ctx.Err() != nil || resp.NextPage == 0 {
|
||||
if r.info.Context().Err() != nil || resp.NextPage == 0 {
|
||||
break
|
||||
} else if opts.Page == endPage {
|
||||
break
|
||||
|
Reference in New Issue
Block a user