File tree Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -152,8 +152,30 @@ func backfillConsoleContext(man *manifest.ProjectManifest) error {
152152 return fmt .Errorf ("found non-ssh upstream url %s, please reclone the repo with SSH and retry" , url )
153153 }
154154
155+ if err := verifySSHKey (contents , url ); err != nil {
156+ return err
157+ }
158+
155159 console ["repo_url" ] = url
156160 console ["private_key" ] = contents
157161 ctx .Configuration ["console" ] = console
158162 return ctx .Write (path )
159163}
164+
165+ func verifySSHKey (key , url string ) error {
166+ dir , err := os .MkdirTemp ("" , "repo" )
167+ if err != nil {
168+ return err
169+ }
170+ defer func (path string ) {
171+ err := os .RemoveAll (path )
172+ if err != nil {
173+ return
174+ }
175+ }(dir )
176+ auth , _ := git .SSHAuth ("git" , key , "" )
177+ if _ , err := git .Clone (auth , url , dir ); err != nil {
178+ return err
179+ }
180+ return nil
181+ }
You can’t perform that action at this time.
0 commit comments