1package core
2
3import "fmt"
4
5// BridgeParams holds parameters to simplify the bridge configuration without
6// having to make terminal prompts.
7type BridgeParams struct {
8 URL string // complete URL of a repo (Gitea, Github, Gitlab, , Launchpad)
9 BaseURL string // base URL for self-hosted instance ( , , Gitlab, Jira, )
10 Login string // username for the passed credential (Gitea, Github, Gitlab, Jira, )
11 CredPrefix string // ID prefix of the credential to use (Gitea, Github, Gitlab, Jira, )
12 TokenRaw string // pre-existing token to use (Gitea, Github, Gitlab, , )
13 Owner string // owner of the repo ( , Github, , , )
14 Project string // name of the repo or project key ( , Github, , Jira, Launchpad)
15}
16
17func (BridgeParams) fieldWarning(field string, target string) string {
18 switch field {
19 case "URL":
20 return fmt.Sprintf("warning: --url is ineffective for a %s bridge", target)
21 case "BaseURL":
22 return fmt.Sprintf("warning: --base-url is ineffective for a %s bridge", target)
23 case "Login":
24 return fmt.Sprintf("warning: --login is ineffective for a %s bridge", target)
25 case "CredPrefix":
26 return fmt.Sprintf("warning: --credential is ineffective for a %s bridge", target)
27 case "TokenRaw":
28 return fmt.Sprintf("warning: tokens are ineffective for a %s bridge", target)
29 case "Owner":
30 return fmt.Sprintf("warning: --owner is ineffective for a %s bridge", target)
31 case "Project":
32 return fmt.Sprintf("warning: --project is ineffective for a %s bridge", target)
33 default:
34 panic("unknown field")
35 }
36}