-
Notifications
You must be signed in to change notification settings - Fork 7
/
gitlab.go
41 lines (34 loc) · 1.08 KB
/
gitlab.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package main
import (
"os"
"gitlab.com/tozd/go/errors"
"github.com/jonhadfield/githosts-utils"
)
func Gitlab(backupDir string) *ProviderBackupResults {
logger.Println("backing up GitLab repos")
var gitlabHost *githosts.GitLabHost
gitlabHost, err := githosts.NewGitLabHost(githosts.NewGitLabHostInput{
Caller: appName,
HTTPClient: httpClient,
APIURL: os.Getenv(envGitLabAPIURL),
DiffRemoteMethod: os.Getenv(envGitLabCompare),
BackupDir: backupDir,
Token: os.Getenv(envGitLabToken),
BackupsToRetain: getBackupsToRetain(envGitLabBackups),
ProjectMinAccessLevel: getProjectMinimumAccessLevel(),
LogLevel: getLogLevel(),
})
if err != nil {
return &ProviderBackupResults{
Provider: providerNameGitLab,
Results: githosts.ProviderBackupResult{
BackupResults: []githosts.RepoBackupResults{},
Error: errors.Wrap(err, "failed to create GitLab host"),
},
}
}
return &ProviderBackupResults{
Provider: providerNameGitLab,
Results: gitlabHost.Backup(),
}
}