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

@ -1,24 +1,15 @@
package remote
import (
"context"
"fmt"
"net"
"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"
)
type RemoteInfo struct {
Ctx context.Context
Host string
Name string
Token string
CloneProto config.CloneProto
}
const defNetDialTimeoutSecs = 3
// Any remote needs to be able to return
@ -26,8 +17,9 @@ const defNetDialTimeoutSecs = 3
// stream all projects along with updates to channels
// provided by *load.ProgressInfo
type Remote interface {
GetInfo() *RemoteInfo // Returns basic RemoteInfo struct
String() string // String info for remote
GetInfo() *info.RemoteInfo // Returns basic RemoteInfo struct
GetType() string // Returns the remote type (e.g. GitLab, Gitea)
GetNumProjects(*RemoteQueryOpts) int // Returns total number of accessible projects
StreamProjects(*load.ProgressInfo, *RemoteQueryOpts) // Streams projects to chans provided in load.ProgressInfo
}
@ -35,9 +27,9 @@ type Remote interface {
func IsAlive(remote Remote) bool {
var port int
switch remote.GetInfo().CloneProto {
case config.CloneProtoHTTP:
case info.CloneProtoHTTP:
port = 443
case config.CloneProtoSSH:
case info.CloneProtoSSH:
port = 22
}