Skip to content

Commit 819322c

Browse files
committed
Fix compatibility with go-git v6 alpha.2 transport API
The v6 alpha.2 release includes a major refactor of the plumbing/transport API. The Auth field in CloneOptions has been replaced with ClientOptions, and authentication is now configured via client.WithHTTPAuth(). Changes: - Replace Auth field with ClientOptions in CloneOptions - Update getAuth to getClientOptions, returning []client.Option - Use client.WithHTTPAuth() for HTTP basic authentication - Import plumbing/client instead of plumbing/transport
1 parent 88d3e85 commit 819322c

1 file changed

Lines changed: 13 additions & 9 deletions

File tree

internal/git/manager.go

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
"github.com/functions-dev/func-operator/internal/monitoring"
1111
"github.com/go-git/go-git/v6"
1212
"github.com/go-git/go-git/v6/plumbing"
13-
"github.com/go-git/go-git/v6/plumbing/transport"
13+
"github.com/go-git/go-git/v6/plumbing/client"
1414
"github.com/go-git/go-git/v6/plumbing/transport/http"
1515
"github.com/prometheus/client_golang/prometheus"
1616
)
@@ -49,7 +49,7 @@ func (m *managerImpl) CloneRepository(ctx context.Context, repoUrl, subPath, ref
4949
ReferenceName: plumbing.ReferenceName(reference),
5050
SingleBranch: true,
5151
Depth: 1,
52-
Auth: m.getAuth(auth),
52+
ClientOptions: m.getClientOptions(auth),
5353
})
5454
if err != nil {
5555
return nil, fmt.Errorf("failed to clone repo: %w", err)
@@ -68,19 +68,23 @@ func (m *managerImpl) CloneRepository(ctx context.Context, repoUrl, subPath, ref
6868
}, nil
6969
}
7070

71-
func (m *managerImpl) getAuth(authSecret map[string][]byte) transport.AuthMethod {
71+
func (m *managerImpl) getClientOptions(authSecret map[string][]byte) []client.Option {
7272
if len(authSecret) == 0 {
7373
return nil
7474
} else if token, ok := authSecret["token"]; ok {
75-
return &http.BasicAuth{
76-
Username: "empty", // can be anything except an empty string
77-
Password: string(token),
75+
return []client.Option{
76+
client.WithHTTPAuth(&http.BasicAuth{
77+
Username: "empty", // can be anything except an empty string
78+
Password: string(token),
79+
}),
7880
}
7981
} else if username, ok := authSecret["username"]; ok {
8082
if password, ok := authSecret["password"]; ok {
81-
return &http.BasicAuth{
82-
Username: string(username),
83-
Password: string(password),
83+
return []client.Option{
84+
client.WithHTTPAuth(&http.BasicAuth{
85+
Username: string(username),
86+
Password: string(password),
87+
}),
8488
}
8589
}
8690
return nil

0 commit comments

Comments
 (0)