-
Notifications
You must be signed in to change notification settings - Fork 73
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Convert SSH clone urls to HTTPS #358
Conversation
commands/utils/params.go
Outdated
// Endpoint should empty for default values or start with https scheme. | ||
func verifyValidApiEndpoint(endpoint *string) error { | ||
if *endpoint != "" && !strings.HasPrefix(*endpoint, "https://") { | ||
return errors.New("missing api endpoint scheme") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You need to utilize ErrMissingEnv
here. Returning a regular error will fail the process. Note that we don't want to fail on an empty ApiEndpoint
because, in such cases, froggit-go automatically inserts the default API endpoint for each git provider.
commands/utils/git.go
Outdated
func (gm *GitManager) generateHTTPSCloneUrl() (url string, err error) { | ||
switch gm.git.GitProvider { | ||
case vcsutils.GitHub: | ||
return fmt.Sprintf(githubHttpsFormat, gm.git.RepoOwner, gm.git.RepoName), nil | ||
case vcsutils.GitLab: | ||
return fmt.Sprintf(gitLabHttpsFormat, gm.git.GitProject, gm.git.RepoName), nil | ||
case vcsutils.BitbucketServer: | ||
return fmt.Sprintf(bitbucketServerHttpsFormat, gm.git.ApiEndpoint, gm.git.RepoOwner, gm.git.RepoName), nil | ||
case vcsutils.AzureRepos: | ||
return fmt.Sprintf(azureDevopsHttpsFormat, gm.git.RepoOwner, gm.git.RepoOwner, gm.git.GitProject, gm.git.RepoName), nil | ||
default: | ||
return "", fmt.Errorf("unsupported version control provider: %s", gm.git.GitProvider.String()) | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would not work for on-premises. We need to support such cases based on the given ApiEndpoint
. We can fallback to the cloud format if the ApiEndpoint
is empty.
Certain Git repos remote urls are defined as SSH.
Frogbot uses
JF_GIT_ACCESS
token with sufficient permissions so we don't need to add other auth method, just to replace the remote urls from SSH to HTTPS.