Remove all legacy config
This commit is contained in:
@ -12,13 +12,58 @@ const (
|
||||
DefaultCloneProto CloneProto = CloneProtoSSH
|
||||
)
|
||||
|
||||
type RemoteType string
|
||||
type RemoteTypes []RemoteType
|
||||
|
||||
// Register remote types here and also add a case
|
||||
// to func GetRemoteTypeFromString
|
||||
var (
|
||||
RemoteTypeGitlab RemoteType = "gitlab"
|
||||
RemoteTypeGitea RemoteType = "gitea"
|
||||
RemoteTypesAll RemoteTypes = []RemoteType{
|
||||
RemoteTypeGitea,
|
||||
RemoteTypeGitlab,
|
||||
}
|
||||
)
|
||||
|
||||
func GetRemoteTypeFromString(remoteType string) RemoteType {
|
||||
var rt RemoteType
|
||||
switch remoteType {
|
||||
case RemoteTypeGitea.String():
|
||||
rt = RemoteTypeGitea
|
||||
case RemoteTypeGitlab.String():
|
||||
rt = RemoteTypeGitlab
|
||||
}
|
||||
return rt
|
||||
}
|
||||
|
||||
func (rt *RemoteTypes) Strings() []string {
|
||||
rtStrings := make([]string, len(*rt))
|
||||
for i, t := range *rt {
|
||||
rtStrings[i] = string(t)
|
||||
}
|
||||
return rtStrings
|
||||
}
|
||||
|
||||
func (rt *RemoteType) String() string {
|
||||
return string(*rt)
|
||||
}
|
||||
|
||||
// Globally shared info for all remote types
|
||||
// Stub package to prevent import cycle
|
||||
type RemoteInfo struct {
|
||||
Ctx context.Context // Base context for all API calls
|
||||
Host string // Host as URL with protocol (e.g. https://gitlab.com)
|
||||
Name string // Human-friendly name for remote
|
||||
Token string // API token for remote
|
||||
Type string // Remote type (e.g. gitlab, gitea)
|
||||
CloneProto CloneProto // CloneProto (ssh or http) determines what url to use for git clone
|
||||
Host string // Host as URL with protocol (e.g. https://gitlab.com)
|
||||
Name string // Human-friendly name for remote
|
||||
Token string // API token for remote
|
||||
Type RemoteType // Remote type (e.g. gitlab, gitea)
|
||||
CloneProto CloneProto // CloneProto (ssh or http) determines what url to use for git clone
|
||||
ctx context.Context
|
||||
}
|
||||
|
||||
func (ri *RemoteInfo) SetContext(ctx context.Context) {
|
||||
ri.ctx = ctx
|
||||
}
|
||||
|
||||
func (ri *RemoteInfo) Context() context.Context {
|
||||
return ri.ctx
|
||||
}
|
||||
|
Reference in New Issue
Block a user