Delay creation of Gitea client TBC
This commit is contained in:
parent
ea7367ec08
commit
8764edad99
@ -2,6 +2,7 @@ package gitearemote
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/url"
|
||||
|
||||
"code.gitea.io/sdk/gitea"
|
||||
"gitlab.sweetwater.com/it/devops/tools/gitlab-project-manager/internal/remotes/info"
|
||||
@ -25,19 +26,25 @@ func (r *GiteaRemote) String() string {
|
||||
r.GetInfo().Name, r.GetInfo().Host, r.GetInfo().CloneProto)
|
||||
}
|
||||
|
||||
func NewGiteaRemote(remoteInfo *info.RemoteInfo) (*GiteaRemote, error) {
|
||||
client, err := gitea.NewClient(remoteInfo.Host,
|
||||
gitea.SetContext(remoteInfo.Context()),
|
||||
gitea.SetToken(remoteInfo.Token),
|
||||
// Prepares the Gitea api client
|
||||
func (r *GiteaRemote) setClient() error {
|
||||
var err error
|
||||
r.api, err = gitea.NewClient(r.info.Host,
|
||||
gitea.SetContext(r.info.Context()),
|
||||
gitea.SetToken(r.info.Token),
|
||||
)
|
||||
return err
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
// Does not prepare the client due to the Gitea client making an initial
|
||||
// http connection. API client to be set on-demand
|
||||
func NewGiteaRemote(remoteInfo *info.RemoteInfo) (*GiteaRemote, error) {
|
||||
if _, err := url.Parse(remoteInfo.Host); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
giteaRemote := &GiteaRemote{
|
||||
info: remoteInfo,
|
||||
api: client,
|
||||
}
|
||||
|
||||
return giteaRemote, nil
|
||||
|
Loading…
Reference in New Issue
Block a user