Skip to content

Commit

Permalink
Resolve concurrent map write error in remote git resolver
Browse files Browse the repository at this point in the history
- Move logic that can cause concurrent map writes to an init function
  • Loading branch information
tomkennedy513 committed Jun 6, 2023
1 parent 44ebcf9 commit 493be17
Showing 1 changed file with 8 additions and 13 deletions.
21 changes: 8 additions & 13 deletions pkg/git/remote_git_resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,20 @@ const defaultRemote = "origin"

type remoteGitResolver struct{}

func init() {
httpsTransport, err := getHttpsTransport()
if err != nil {
return
}
client.InstallProtocol("https", httpsTransport)
}

func (*remoteGitResolver) Resolve(auth transport.AuthMethod, sourceConfig corev1alpha1.SourceConfig) (corev1alpha1.ResolvedSourceConfig, error) {
remote := gogit.NewRemote(memory.NewStorage(), &config.RemoteConfig{
Name: defaultRemote,
URLs: []string{sourceConfig.Git.URL},
})

httpsTransport, err := getHttpsTransport()
if err != nil {
return corev1alpha1.ResolvedSourceConfig{
Git: &corev1alpha1.ResolvedGitSource{
URL: sourceConfig.Git.URL,
Revision: sourceConfig.Git.Revision,
Type: corev1alpha1.Unknown,
SubPath: sourceConfig.SubPath,
},
}, nil
}
client.InstallProtocol("https", httpsTransport)

refs, err := remote.List(&gogit.ListOptions{
Auth: auth,
})
Expand Down

0 comments on commit 493be17

Please sign in to comment.