Skip to content

Commit 3855434

Browse files
committed
fix docs, error handling and managed proxy auth
Signed-off-by: Sanskar Jaiswal <[email protected]>
1 parent 9e28d66 commit 3855434

File tree

7 files changed

+7
-15
lines changed

7 files changed

+7
-15
lines changed

controllers/gitrepository_controller.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -735,7 +735,7 @@ func (r *GitRepositoryReconciler) gitCheckout(ctx context.Context,
735735
// managed GIT transport only affects the libgit2 implementation
736736
if managed.Enabled() && obj.Spec.GitImplementation == sourcev1.LibGit2Implementation {
737737
// We set the TransportOptionsURL of this set of authentication options here by constructing
738-
// a unique ID that won't clash in a multi tenant environment. This unique ID is used by
738+
// a unique URL that won't clash in a multi tenant environment. This unique URL is used by
739739
// libgit2 managed transports. This enables us to bypass the inbuilt credentials callback in
740740
// libgit2, which is inflexible and unstable.
741741
if strings.HasPrefix(obj.Spec.URL, "http") {
@@ -745,7 +745,7 @@ func (r *GitRepositoryReconciler) gitCheckout(ctx context.Context,
745745
} else {
746746
e := &serror.Stalling{
747747
Err: fmt.Errorf("git repository URL has invalid transport type: '%s'", obj.Spec.URL),
748-
Reason: sourcev1.GitOperationFailedReason,
748+
Reason: sourcev1.URLInvalidReason,
749749
}
750750
return nil, e
751751
}

internal/features/features.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ func Enabled(feature string) (bool, error) {
6767
}
6868

6969
// Disable disables the specified feature. If the feature is not
70-
// present, it's a no-op
70+
// present, it's a no-op.
7171
func Disable(feature string) {
7272
if _, ok := features[feature]; ok {
7373
features[feature] = false

main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ func main() {
316316
if optimize, _ := feathelper.Enabled(features.OptimizedGitClones); optimize {
317317
features.Disable(features.OptimizedGitClones)
318318
setupLog.Info(
319-
"disabling optimzied git clones; git clones can only be optimized when using managed transort",
319+
"disabling optimized git clones; git clones can only be optimized when using managed transport",
320320
)
321321
}
322322
}

pkg/git/libgit2/managed/http.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -212,12 +212,6 @@ func createClientRequest(targetURL string, action git2go.SmartServiceAction,
212212
if authOpts != nil {
213213
if len(authOpts.Username) > 0 {
214214
req.SetBasicAuth(authOpts.Username, authOpts.Password)
215-
if t.Proxy != nil {
216-
t.ProxyConnectHeader.Set(
217-
"Authorization",
218-
"Basic "+basicAuth(authOpts.Username, authOpts.Password),
219-
)
220-
}
221215
}
222216
if len(authOpts.CAFile) > 0 {
223217
certPool := x509.NewCertPool()

pkg/git/libgit2/managed/options.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ type TransportOptions struct {
3232
}
3333

3434
var (
35-
// transportOpts maps a unique url to a set of transport options.
35+
// transportOpts maps a unique URL to a set of transport options.
3636
transportOpts = make(map[string]TransportOptions, 0)
3737
m sync.RWMutex
3838
)

pkg/git/libgit2/managed_test.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -472,8 +472,6 @@ func Test_ManagedHTTPCheckout(t *testing.T) {
472472
g.Expect(err).ToNot(HaveOccurred())
473473
defer server.StopHTTP()
474474

475-
// Force managed transport to be enabled
476-
477475
repoPath := "test.git"
478476
err = server.InitRepo("../testdata/git/repo", git.DefaultBranch, repoPath)
479477
g.Expect(err).ToNot(HaveOccurred())

pkg/git/strategy/proxy/strategy_proxy_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -320,10 +320,10 @@ func TestCheckoutStrategyForImplementation_Proxied(t *testing.T) {
320320
defer proxyServer.Close()
321321

322322
// Set the proxy env vars for both HTTP and HTTPS because go-git caches them.
323-
os.Setenv("HTTPS_PROXY", fmt.Sprintf("http://%s", proxyAddr))
323+
os.Setenv("HTTPS_PROXY", fmt.Sprintf("http://smth:else@%s", proxyAddr))
324324
defer os.Unsetenv("HTTPS_PROXY")
325325

326-
os.Setenv("HTTP_PROXY", fmt.Sprintf("http://%s", proxyAddr))
326+
os.Setenv("HTTP_PROXY", fmt.Sprintf("http://smth:else@%s", proxyAddr))
327327
defer os.Unsetenv("HTTP_PROXY")
328328

329329
os.Setenv("NO_PROXY", "*.0.2.1")

0 commit comments

Comments
 (0)