(apiBase string)
| 133 | } |
| 134 | |
| 135 | func normalizeSecretSetAPIHost(apiBase string) string { |
| 136 | raw := strings.TrimSpace(apiBase) |
| 137 | if raw == "" { |
| 138 | return "" |
| 139 | } |
| 140 | |
| 141 | candidates := []string{raw} |
| 142 | if !strings.Contains(raw, "://") { |
| 143 | candidates = append(candidates, "https://"+raw) |
| 144 | } |
| 145 | for _, candidate := range candidates { |
| 146 | parsed, err := url.Parse(candidate) |
| 147 | if err != nil || parsed.Hostname() == "" { |
| 148 | continue |
| 149 | } |
| 150 | if parsed.Hostname() == "api.github.com" { |
| 151 | return "github.com" |
| 152 | } |
| 153 | return parsed.Hostname() |
| 154 | } |
| 155 | |
| 156 | legacy := stringutil.ExtractDomainFromURL(raw) |
| 157 | if legacy == "api.github.com" { |
| 158 | return "github.com" |
| 159 | } |
| 160 | return legacy |
| 161 | } |
| 162 | |
| 163 | func resolveSecretValueForSet(fromEnv, fromFlag string) (string, error) { |
| 164 | if fromEnv != "" { |
no test coverage detected