-
Notifications
You must be signed in to change notification settings - Fork 7
/
gitea.go
38 lines (33 loc) · 1013 Bytes
/
gitea.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
package main
import (
"os"
"github.com/jonhadfield/githosts-utils"
"gitlab.com/tozd/go/errors"
)
func Gitea(backupDir string) *ProviderBackupResults {
logger.Println("backing up Gitea repos")
giteaHost, err := githosts.NewGiteaHost(githosts.NewGiteaHostInput{
Caller: appName,
HTTPClient: httpClient,
APIURL: os.Getenv(envGiteaAPIURL),
DiffRemoteMethod: os.Getenv(envGiteaCompare),
BackupDir: backupDir,
Token: os.Getenv(envGiteaToken),
Orgs: getOrgsListFromEnvVar(envGiteaOrgs),
BackupsToRetain: getBackupsToRetain(envGiteaBackups),
LogLevel: getLogLevel(),
})
if err != nil {
return &ProviderBackupResults{
Provider: providerNameGitea,
Results: githosts.ProviderBackupResult{
BackupResults: []githosts.RepoBackupResults{},
Error: errors.Wrap(err, "failed to create Gitea host"),
},
}
}
return &ProviderBackupResults{
Provider: providerNameGitea,
Results: giteaHost.Backup(),
}
}