-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor and bump githosts-utils depdencency.
- Loading branch information
1 parent
2845006
commit 235eba6
Showing
11 changed files
with
253 additions
and
156 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package main | ||
|
||
import ( | ||
"os" | ||
|
||
"gitlab.com/tozd/go/errors" | ||
|
||
"github.com/jonhadfield/githosts-utils" | ||
) | ||
|
||
func Bitbucket(backupDir string) *ProviderBackupResults { | ||
logger.Println("backing up BitBucket repos") | ||
|
||
bitbucketHost, err := githosts.NewBitBucketHost(githosts.NewBitBucketHostInput{ | ||
Caller: appName, | ||
APIURL: os.Getenv(envBitBucketAPIURL), | ||
DiffRemoteMethod: os.Getenv(envBitBucketCompare), | ||
BackupDir: backupDir, | ||
User: os.Getenv(envBitBucketUser), | ||
Key: os.Getenv(envBitBucketKey), | ||
Secret: os.Getenv(envBitBucketSecret), | ||
BackupsToRetain: getBackupsToRetain(envBitBucketBackups), | ||
LogLevel: getLogLevel(), | ||
}) | ||
if err != nil { | ||
return &ProviderBackupResults{ | ||
Provider: providerNameBitBucket, | ||
Results: githosts.ProviderBackupResult{ | ||
BackupResults: []githosts.RepoBackupResults{}, | ||
Error: errors.Wrap(err, "failed to create BitBucket host"), | ||
}, | ||
} | ||
} | ||
|
||
return &ProviderBackupResults{ | ||
Provider: providerNameBitBucket, | ||
Results: bitbucketHost.Backup(), | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
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, | ||
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(), | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
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, | ||
APIURL: os.Getenv(envGitHubAPIURL), | ||
DiffRemoteMethod: os.Getenv(envGitHubCompare), | ||
BackupDir: backupDir, | ||
Token: os.Getenv(envGitHubToken), | ||
Orgs: getOrgsListFromEnvVar(envGitHubOrgs), | ||
BackupsToRetain: getBackupsToRetain(envGitHubBackups), | ||
SkipUserRepos: envTrue(envGitHubSkipUserRepos), | ||
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(), | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
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, | ||
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(), | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.