MCPcopy Create free account
hub / github.com/devspace-sh/devspace / switchURLType

Function switchURLType

pkg/devspace/dependency/util/util.go:68–79  ·  view source on GitHub ↗

switch https <-> ssh urls

(gitPath string)

Source from the content-addressed store, hash-verified

66
67// switch https <-> ssh urls
68func switchURLType(gitPath string) string {
69 var newGitURL string
70 if strings.HasPrefix(gitPath, "https") {
71 splitURL := strings.Split(gitPath, "/")
72 newGitURL = fmt.Sprintf("git@%s:%s", splitURL[2], strings.Join(splitURL[3:], "/"))
73 } else {
74 splitURL := strings.Split(gitPath, "@")
75 replacedURL := strings.ReplaceAll(splitURL[1], ":", "/")
76 newGitURL = fmt.Sprintf("https://%s", replacedURL)
77 }
78 return newGitURL
79}
80
81func DownloadDependency(ctx context.Context, workingDirectory string, source *latest.SourceConfig, log log.Logger) (configPath string, err error) {
82 downloadMutex.Lock()

Callers 2

TestSwitchURLTypeFunction · 0.85
DownloadDependencyFunction · 0.85

Calls

no outgoing calls

Tested by 1

TestSwitchURLTypeFunction · 0.68