renames some elements

This commit is contained in:
Paul 2019-07-14 19:32:47 +02:00
parent 6640e8af17
commit fdecb51bcc
2 changed files with 9 additions and 11 deletions

View File

@ -16,7 +16,7 @@ import (
)
// GetConfig fetch configuration
func GetConfig(config *Config) error {
func (config *Config) GetConfig() error {
var configfile string
var globalconfig GlobalConfig
@ -84,11 +84,10 @@ func GetReposFromGitHub(config *Config) ([]GitHubRepo, error) {
var repolist []GitHubRepo
var repo []GitHubRepo
fmt.Println("Getting GitHub starred repos")
for num := 1; num <= config.githubconfig.PageNum; num++ {
url := fmt.Sprintf(config.githubconfig.StarsPages, config.githubconfig.AuthUsername, config.githubconfig.MaxPerPage, num)
fmt.Println(url)
fmt.Println("Getting GitHub starred repos")
resp, err := InvokeGitHub(config, url)
if err != nil {
return nil, err
@ -170,7 +169,7 @@ func CheckGogsExistingRepo(config *Config, repo GitHubRepo) (bool, error) {
}
// GetGogsUserUID get the logued user identifier
func GetGogsUserUID(config *Config) error {
func (config *Config) GetGogsUserUID() error {
var gogsorg GogsOrg
gogsrepourl := fmt.Sprintf(config.gogsconfig.OrgsURLTmpl, config.gogsconfig.DestUsername)
@ -209,18 +208,18 @@ func GetGogsUserUID(config *Config) error {
// RunMigration run threads for migration
func RunMigration(config *Config, repolist []GitHubRepo) {
jobs := make(chan GitHubRepo)
repochan := make(chan GitHubRepo)
done := make(chan bool)
var wg sync.WaitGroup
for thr := range make([]int, config.globalconfig.Threads) {
go MigrateReposToGogs(config, &wg, jobs, done, thr)
go MigrateReposToGogs(config, &wg, repochan, done, thr)
}
for _, repo := range repolist {
jobs <- repo
repochan <- repo
}
close(jobs)
close(repochan)
<-done
wg.Wait()
}
@ -257,7 +256,6 @@ func MigrateReposToGogs(config *Config, wg *sync.WaitGroup, jobs chan GitHubRepo
if err != nil {
return err
}
fmt.Println(fmt.Sprintf("Repo %s migrated with status code %d on gogs webservice", elem.Name, resp.StatusCode))
if resp.StatusCode != 201 {
err = fmt.Errorf("Error when migrating repo %s to gogs with status code %d on gogs webservice", elem.Name, resp.StatusCode)
log.Println(err)

View File

@ -8,12 +8,12 @@ func main() {
var config Config
var err error
err = GetConfig(&config)
err = config.GetConfig()
if err != nil {
log.Fatal(err)
}
err = GetGogsUserUID(&config)
err = config.GetGogsUserUID()
if err != nil {
log.Fatal(err)
}