|
@ -11,16 +11,16 @@ const MirrorModePrivateAndPublic = "PRIVATE_AND_PUBLIC" |
|
|
|
|
|
|
|
|
type Config struct { |
|
|
type Config struct { |
|
|
MirrorMode string |
|
|
MirrorMode string |
|
|
Gitea GiteaConfig |
|
|
|
|
|
Github GithubConfig |
|
|
|
|
|
|
|
|
Gitea Gitea |
|
|
|
|
|
Github Github |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
type GiteaConfig struct { |
|
|
|
|
|
GiteaUrl string |
|
|
|
|
|
GiteaToken string |
|
|
|
|
|
|
|
|
type Gitea struct { |
|
|
|
|
|
Url string |
|
|
|
|
|
Token string |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
type GithubConfig struct { |
|
|
|
|
|
|
|
|
type Github struct { |
|
|
Username string |
|
|
Username string |
|
|
Token *string |
|
|
Token *string |
|
|
} |
|
|
} |
|
@ -48,29 +48,29 @@ func Read() (*Config, error) { |
|
|
}, nil |
|
|
}, nil |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func readGiteaConfig() (GiteaConfig, error) { |
|
|
|
|
|
|
|
|
func readGiteaConfig() (Gitea, error) { |
|
|
url, a := os.LookupEnv("GITEA_URL") |
|
|
url, a := os.LookupEnv("GITEA_URL") |
|
|
if !a { |
|
|
if !a { |
|
|
return GiteaConfig{}, errors.New("missing mandatory parameter GITEA_URL, please specify your target gitea instance") |
|
|
|
|
|
|
|
|
return Gitea{}, errors.New("missing mandatory parameter GITEA_URL, please specify your target gitea instance") |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
token, a := os.LookupEnv("GITEA_TOKEN") |
|
|
token, a := os.LookupEnv("GITEA_TOKEN") |
|
|
if !a { |
|
|
if !a { |
|
|
return GiteaConfig{}, errors.New("missing mandatory parameter GITEA_TOKEN, please specify your gitea application token") |
|
|
|
|
|
|
|
|
return Gitea{}, errors.New("missing mandatory parameter GITEA_TOKEN, please specify your gitea application token") |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
return GiteaConfig{ |
|
|
|
|
|
GiteaUrl: url, |
|
|
|
|
|
GiteaToken: token, |
|
|
|
|
|
|
|
|
return Gitea{ |
|
|
|
|
|
Url: url, |
|
|
|
|
|
Token: token, |
|
|
}, nil |
|
|
}, nil |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func readGithubConfig() (GithubConfig, error) { |
|
|
|
|
|
|
|
|
func readGithubConfig() (Github, error) { |
|
|
username, present := os.LookupEnv("GITHUB_USERNAME") |
|
|
username, present := os.LookupEnv("GITHUB_USERNAME") |
|
|
|
|
|
|
|
|
if !present { |
|
|
if !present { |
|
|
return GithubConfig{}, errors.New("") |
|
|
|
|
|
|
|
|
return Github{}, errors.New("") |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
var token *string = nil |
|
|
var token *string = nil |
|
@ -78,7 +78,7 @@ func readGithubConfig() (GithubConfig, error) { |
|
|
token = &val |
|
|
token = &val |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
return GithubConfig{ |
|
|
|
|
|
|
|
|
return Github{ |
|
|
Username: username, |
|
|
Username: username, |
|
|
Token: token, |
|
|
Token: token, |
|
|
}, nil |
|
|
}, nil |
|
|