-
Notifications
You must be signed in to change notification settings - Fork 7
/
github.go
41 lines (35 loc) · 1.11 KB
/
github.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"
"github.com/jonhadfield/githosts-utils"
"gitlab.com/tozd/go/errors"
)
func GitHub(backupDir string) *ProviderBackupResults {
logger.Println("backing up GitHub repos")
githubHost, err := githosts.NewGitHubHost(githosts.NewGitHubHostInput{
Caller: appName,
HTTPClient: httpClient,
APIURL: os.Getenv(envGitHubAPIURL),
DiffRemoteMethod: os.Getenv(envGitHubCompare),
BackupDir: backupDir,
Token: os.Getenv(envGitHubToken),
Orgs: getOrgsListFromEnvVar(envGitHubOrgs),
BackupsToRetain: getBackupsToRetain(envGitHubBackups),
SkipUserRepos: envTrue(envGitHubSkipUserRepos),
LimitUserOwned: envTrue(envGitHubLimitUserOwned),
LogLevel: getLogLevel(),
})
if err != nil {
return &ProviderBackupResults{
Provider: providerNameGitHub,
Results: githosts.ProviderBackupResult{
BackupResults: []githosts.RepoBackupResults{},
Error: errors.Wrap(err, "failed to create GitHub host"),
},
}
}
return &ProviderBackupResults{
Provider: providerNameGitHub,
Results: githubHost.Backup(),
}
}