@@ -64,6 +64,20 @@ func GetDependencyPath(workingDirectory string, source *latest.SourceConfig) (co
6464 return getDependencyConfigPath (localPath , source )
6565}
6666
67+ // switch https <-> ssh urls
68+ func 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+
6781func DownloadDependency (ctx context.Context , workingDirectory string , source * latest.SourceConfig , log log.Logger ) (configPath string , err error ) {
6882 downloadMutex .Lock ()
6983 defer downloadMutex .Unlock ()
@@ -110,7 +124,17 @@ func DownloadDependency(ctx context.Context, workingDirectory string, source *la
110124 return getDependencyConfigPath (localPath , source )
111125 }
112126
113- return "" , errors .Wrap (err , "clone repository" )
127+ err = repo .Clone (ctx , git.CloneOptions {
128+ URL : switchURLType (gitPath ),
129+ Tag : source .Tag ,
130+ Branch : source .Branch ,
131+ Commit : source .Revision ,
132+ Args : source .CloneArgs ,
133+ DisableShallow : source .DisableShallow ,
134+ })
135+ if err != nil {
136+ return "" , errors .Wrap (err , "clone repository" )
137+ }
114138 }
115139
116140 log .Debugf ("Pulled %s" , gitPath )
0 commit comments