Move RemoteInfo and CloneProto to info package

This commit is contained in:
2024-01-17 08:13:58 -05:00
parent 1e4e9147f1
commit f33199bd7b
12 changed files with 100 additions and 58 deletions

View File

@ -4,24 +4,28 @@ import (
"fmt"
"github.com/xanzy/go-gitlab"
"gitlab.sweetwater.com/it/devops/tools/gitlab-project-manager/internal/remotes/remote"
"gitlab.sweetwater.com/it/devops/tools/gitlab-project-manager/internal/remotes/info"
)
type GitlabRemote struct {
info *remote.RemoteInfo
info *info.RemoteInfo
api *gitlab.Client
}
func (r *GitlabRemote) GetInfo() *remote.RemoteInfo {
func (r *GitlabRemote) GetInfo() *info.RemoteInfo {
return r.info
}
func (r *GitlabRemote) GetType() string {
return r.info.Type
}
func (r *GitlabRemote) String() string {
return fmt.Sprintf("GitLab %s (%s), clone proto %s",
r.GetInfo().Name, r.GetInfo().Host, r.GetInfo().CloneProto)
}
func NewGitlabRemote(remoteInfo *remote.RemoteInfo) (*GitlabRemote, error) {
func NewGitlabRemote(remoteInfo *info.RemoteInfo) (*GitlabRemote, error) {
api, err := NewGitlabApi(remoteInfo)
if err != nil {
return nil, err

View File

@ -5,6 +5,7 @@ import (
"github.com/pterm/pterm"
"github.com/xanzy/go-gitlab"
"gitlab.sweetwater.com/it/devops/tools/gitlab-project-manager/internal/remotes/info"
"gitlab.sweetwater.com/it/devops/tools/gitlab-project-manager/internal/remotes/projects"
"gitlab.sweetwater.com/it/devops/tools/gitlab-project-manager/internal/remotes/remote"
)
@ -22,10 +23,10 @@ var (
defApiWaitMax time.Duration = 5 * time.Second
)
func NewGitlabApi(info *remote.RemoteInfo) (*gitlab.Client, error) {
func NewGitlabApi(remoteInfo *info.RemoteInfo) (*gitlab.Client, error) {
client, err := gitlab.NewClient(
info.Token,
gitlab.WithBaseURL(info.Host),
remoteInfo.Token,
gitlab.WithBaseURL(remoteInfo.Host),
gitlab.WithCustomRetryWaitMinMax(defApiWaitMin, defApiWaitMax),
)
if err != nil {