Skip to content

Commit 88fec8e

Browse files
author
Paulo Gomes
authored
Merge pull request #412 from pjbgf/update-deps
Decommission libgit2 Unmanaged Transport
2 parents 34a10c0 + 4a8ddfa commit 88fec8e

File tree

7 files changed

+103
-119
lines changed

7 files changed

+103
-119
lines changed

api/go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ go 1.18
44

55
require (
66
github.com/fluxcd/pkg/apis/meta v0.14.2
7-
github.com/fluxcd/source-controller/api v0.25.9
8-
k8s.io/apimachinery v0.24.1
7+
github.com/fluxcd/source-controller/api v0.26.0
8+
k8s.io/apimachinery v0.24.3
99
sigs.k8s.io/controller-runtime v0.11.2
1010
)
1111

api/go.sum

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ github.com/fluxcd/pkg/apis/acl v0.0.3 h1:Lw0ZHdpnO4G7Zy9KjrzwwBmDZQuy4qEjaU/RvA6
2121
github.com/fluxcd/pkg/apis/acl v0.0.3/go.mod h1:XPts6lRJ9C9fIF9xVWofmQwftvhY25n1ps7W9xw0XLU=
2222
github.com/fluxcd/pkg/apis/meta v0.14.2 h1:/Hf7I/Vz01vv3m7Qx7DtQvrzAL1oVt0MJcLb/I1Y1HE=
2323
github.com/fluxcd/pkg/apis/meta v0.14.2/go.mod h1:ijZ61VG/8T3U17gj0aFL3fdtZL+mulD6V8VrLLUCAgM=
24-
github.com/fluxcd/source-controller/api v0.25.9 h1:hdaBYYNuW3qTcXRMfrxO5paK+UVFL9ApZS495nd7K2w=
25-
github.com/fluxcd/source-controller/api v0.25.9/go.mod h1:/e7YRDOqb8z8I3N8ifbDF1mknf8zFsoADtS/Q93iWPs=
24+
github.com/fluxcd/source-controller/api v0.26.0 h1:DOf9R7YLV0lNiIRnaYg5bh8fGbIB6zGbK5vFqejeSAk=
25+
github.com/fluxcd/source-controller/api v0.26.0/go.mod h1:1W0Xx/GpZ14Z/sOltxjsQKXeCv8zxAqSivbX9e4s+H8=
2626
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
2727
github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
2828
github.com/fsnotify/fsnotify v1.5.1 h1:mZcQUHVQUQWoPXXtuf9yuEXKudkV2sx1E06UadKWpgI=
@@ -232,8 +232,8 @@ gopkg.in/yaml.v3 v3.0.0/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
232232
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
233233
honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
234234
k8s.io/api v0.23.5 h1:zno3LUiMubxD/V1Zw3ijyKO3wxrhbUF1Ck+VjBvfaoA=
235-
k8s.io/apimachinery v0.24.1 h1:ShD4aDxTQKN5zNf8K1RQ2u98ELLdIW7jEnlO9uAMX/I=
236-
k8s.io/apimachinery v0.24.1/go.mod h1:82Bi4sCzVBdpYjyI4jY6aHX+YCUchUIrZrXKedjd2UM=
235+
k8s.io/apimachinery v0.24.3 h1:hrFiNSA2cBZqllakVYyH/VyEh4B581bQRmqATJSeQTg=
236+
k8s.io/apimachinery v0.24.3/go.mod h1:82Bi4sCzVBdpYjyI4jY6aHX+YCUchUIrZrXKedjd2UM=
237237
k8s.io/gengo v0.0.0-20210813121822-485abfe95c7c/go.mod h1:FiNAH4ZV3gBg2Kwh89tzAEV2be7d5xI0vBa/VySYy3E=
238238
k8s.io/klog/v2 v2.0.0/go.mod h1:PBfzABfn139FHAV07az/IF9Wp1bkk3vpT2XSJ76fSDE=
239239
k8s.io/klog/v2 v2.2.0/go.mod h1:Od+F08eJP+W3HUb4pSrPpgp9DGU4GzlpG/TmITuYh/Y=

controllers/imageupdateautomation_controller.go

Lines changed: 28 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ import (
6262
"github.com/fluxcd/pkg/runtime/predicates"
6363
sourcev1 "github.com/fluxcd/source-controller/api/v1beta2"
6464
"github.com/fluxcd/source-controller/pkg/git"
65-
gitlibgit2 "github.com/fluxcd/source-controller/pkg/git/libgit2"
6665
"github.com/fluxcd/source-controller/pkg/git/libgit2/managed"
6766
gitstrat "github.com/fluxcd/source-controller/pkg/git/strategy"
6867

@@ -270,21 +269,18 @@ func (r *ImageUpdateAutomationReconciler) Reconcile(ctx context.Context, req ctr
270269
return failWithError(err)
271270
}
272271

273-
// managed GIT transport only affects the libgit2 implementation
274-
if managed.Enabled() {
275-
// We set the TransportOptionsURL of this set of authentication options here by constructing
276-
// a unique URL that won't clash in a multi tenant environment. This unique URL is used by
277-
// libgit2 managed transports. This enables us to bypass the inbuilt credentials callback in
278-
// libgit2, which is inflexible and unstable.
279-
// NB: The Transport Options URL must be unique, therefore it must use the object under
280-
// reconciliation details, instead of the repository it depends on.
281-
if strings.HasPrefix(origin.Spec.URL, "http") {
282-
access.auth.TransportOptionsURL = fmt.Sprintf("http://%s/%s/%d", auto.Name, auto.UID, auto.Generation)
283-
} else if strings.HasPrefix(origin.Spec.URL, "ssh") {
284-
access.auth.TransportOptionsURL = fmt.Sprintf("ssh://%s/%s/%d", auto.Name, auto.UID, auto.Generation)
285-
} else {
286-
return failWithError(fmt.Errorf("git repository URL '%s' has invalid transport type, supported types are: http, https, ssh", origin.Spec.URL))
287-
}
272+
// We set the TransportOptionsURL of this set of authentication options here by constructing
273+
// a unique URL that won't clash in a multi tenant environment. This unique URL is used by
274+
// libgit2 managed transports. This enables us to bypass the inbuilt credentials callback in
275+
// libgit2, which is inflexible and unstable.
276+
// NB: The Transport Options URL must be unique, therefore it must use the object under
277+
// reconciliation details, instead of the repository it depends on.
278+
if strings.HasPrefix(origin.Spec.URL, "http") {
279+
access.auth.TransportOptionsURL = fmt.Sprintf("http://%s/%s/%d", auto.Name, auto.UID, auto.Generation)
280+
} else if strings.HasPrefix(origin.Spec.URL, "ssh") {
281+
access.auth.TransportOptionsURL = fmt.Sprintf("ssh://%s/%s/%d", auto.Name, auto.UID, auto.Generation)
282+
} else {
283+
return failWithError(fmt.Errorf("git repository URL '%s' has invalid transport type, supported types are: http, https, ssh", origin.Spec.URL))
288284
}
289285

290286
// Use the git operations timeout for the repo.
@@ -296,19 +292,17 @@ func (r *ImageUpdateAutomationReconciler) Reconcile(ctx context.Context, req ctr
296292
}
297293
defer repo.Free()
298294

299-
if managed.Enabled() {
300-
// Checkout removes TransportOptions before returning, therefore this
301-
// must happen after cloneInto.
302-
// TODO(pjbgf): Git consolidation should improve the API workflow.
303-
managed.AddTransportOptions(access.auth.TransportOptionsURL, managed.TransportOptions{
304-
TargetURL: origin.Spec.URL,
305-
AuthOpts: access.auth,
306-
ProxyOptions: &libgit2.ProxyOptions{Type: libgit2.ProxyTypeAuto},
307-
Context: cloneCtx,
308-
})
295+
// Checkout removes TransportOptions before returning, therefore this
296+
// must happen after cloneInto.
297+
// TODO(pjbgf): Git consolidation should improve the API workflow.
298+
managed.AddTransportOptions(access.auth.TransportOptionsURL, managed.TransportOptions{
299+
TargetURL: origin.Spec.URL,
300+
AuthOpts: access.auth,
301+
ProxyOptions: &libgit2.ProxyOptions{Type: libgit2.ProxyTypeAuto},
302+
Context: cloneCtx,
303+
})
309304

310-
defer managed.RemoveTransportOptions(access.auth.TransportOptionsURL)
311-
}
305+
defer managed.RemoveTransportOptions(access.auth.TransportOptionsURL)
312306

313307
// When there's a push spec, the pushed-to branch is where commits
314308
// shall be made
@@ -554,10 +548,6 @@ func (r *ImageUpdateAutomationReconciler) getRepoAccess(ctx context.Context, rep
554548
return access, nil
555549
}
556550

557-
func (r repoAccess) remoteCallbacks(ctx context.Context) libgit2.RemoteCallbacks {
558-
return gitlibgit2.RemoteCallbacks(ctx, r.auth)
559-
}
560-
561551
// cloneInto clones the upstream repository at the `ref` given (which
562552
// can be `nil`). It returns a `*libgit2.Repository` since that is used
563553
// for committing changes.
@@ -763,12 +753,9 @@ func switchToBranch(repo *libgit2.Repository, ctx context.Context, branch string
763753
}
764754
defer origin.Free()
765755

766-
callbacks := access.remoteCallbacks(ctx)
767-
if managed.Enabled() {
768-
// Override callbacks with dummy ones as they are not needed within Managed Transport.
769-
// However, not setting them may lead to git2go panicing.
770-
callbacks = managed.RemoteCallbacks()
771-
}
756+
// Override callbacks with dummy ones as they are not needed within Managed Transport.
757+
// However, not setting them may lead to git2go panicing.
758+
callbacks := managed.RemoteCallbacks()
772759

773760
// Force the fetching of the remote branch.
774761
err = origin.Fetch([]string{branch}, &libgit2.FetchOptions{
@@ -866,12 +853,9 @@ func push(ctx context.Context, path, branch string, access repoAccess) error {
866853
}
867854
defer origin.Free()
868855

869-
callbacks := access.remoteCallbacks(ctx)
870-
if managed.Enabled() {
871-
// Override callbacks with dummy ones as they are not needed within Managed Transport.
872-
// However, not setting them may lead to git2go panicing.
873-
callbacks = managed.RemoteCallbacks()
874-
}
856+
// Override callbacks with dummy ones as they are not needed within Managed Transport.
857+
// However, not setting them may lead to git2go panicing.
858+
callbacks := managed.RemoteCallbacks()
875859

876860
// calling repo.Push will succeed even if a reference update is
877861
// rejected; to detect this case, this callback is supplied.

go.mod

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -16,30 +16,30 @@ replace github.com/libgit2/git2go/v33 => github.com/pjbgf/git2go/v33 v33.0.9-not
1616

1717
require (
1818
github.com/Masterminds/sprig/v3 v3.2.2
19-
github.com/ProtonMail/go-crypto v0.0.0-20220714114130-e85cedf506cd
19+
github.com/ProtonMail/go-crypto v0.0.0-20220730123233-d6ffb7692adf
2020
github.com/cyphar/filepath-securejoin v0.2.3
2121
github.com/fluxcd/image-automation-controller/api v0.23.5
22-
github.com/fluxcd/image-reflector-controller/api v0.19.3
22+
github.com/fluxcd/image-reflector-controller/api v0.20.0
2323
github.com/fluxcd/pkg/apis/acl v0.0.3
2424
github.com/fluxcd/pkg/apis/meta v0.14.2
2525
github.com/fluxcd/pkg/gittestserver v0.6.0
2626
github.com/fluxcd/pkg/runtime v0.16.2
2727
github.com/fluxcd/pkg/ssh v0.5.0
28-
github.com/fluxcd/source-controller v0.25.10
29-
github.com/fluxcd/source-controller/api v0.25.10
28+
github.com/fluxcd/source-controller v0.26.0
29+
github.com/fluxcd/source-controller/api v0.26.0
3030
github.com/go-logr/logr v1.2.3
3131
github.com/google/go-containerregistry v0.11.0
3232
github.com/libgit2/git2go/v33 v33.0.9
3333
github.com/onsi/gomega v1.20.0
3434
github.com/otiai10/copy v1.7.0
3535
github.com/spf13/pflag v1.0.5
3636
golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa
37-
k8s.io/api v0.24.2
38-
k8s.io/apimachinery v0.24.2
39-
k8s.io/client-go v0.24.2
40-
k8s.io/kube-openapi v0.0.0-20220627174259-011e075b9cb8
37+
k8s.io/api v0.24.3
38+
k8s.io/apimachinery v0.24.3
39+
k8s.io/client-go v0.24.3
40+
k8s.io/kube-openapi v0.0.0-20220803164354-a70c9af30aea
4141
sigs.k8s.io/controller-runtime v0.11.2
42-
sigs.k8s.io/kustomize/kyaml v0.13.7
42+
sigs.k8s.io/kustomize/kyaml v0.13.9
4343
)
4444

4545
// Fix CVE-2022-28948
@@ -56,12 +56,11 @@ require (
5656
github.com/Masterminds/goutils v1.1.1 // indirect
5757
github.com/Masterminds/semver/v3 v3.1.1 // indirect
5858
github.com/Microsoft/go-winio v0.5.2 // indirect
59-
github.com/PuerkitoBio/purell v1.1.1 // indirect
60-
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect
6159
github.com/acomagu/bufpipe v1.0.3 // indirect
6260
github.com/asaskevich/govalidator v0.0.0-20200428143746-21a406dcc535 // indirect
6361
github.com/beorn7/perks v1.0.1 // indirect
6462
github.com/cespare/xxhash/v2 v2.1.2 // indirect
63+
github.com/cloudflare/circl v1.1.0 // indirect
6564
github.com/davecgh/go-spew v1.1.1 // indirect
6665
github.com/emicklei/go-restful/v3 v3.8.0 // indirect
6766
github.com/emirpasic/gods v1.18.1 // indirect
@@ -76,13 +75,13 @@ require (
7675
github.com/go-git/go-git/v5 v5.4.2 // indirect
7776
github.com/go-logr/zapr v1.2.0 // indirect
7877
github.com/go-openapi/jsonpointer v0.19.5 // indirect
79-
github.com/go-openapi/jsonreference v0.19.5 // indirect
80-
github.com/go-openapi/swag v0.19.14 // indirect
78+
github.com/go-openapi/jsonreference v0.20.0 // indirect
79+
github.com/go-openapi/swag v0.21.1 // indirect
8180
github.com/gofrs/uuid v4.2.0+incompatible // indirect
8281
github.com/gogo/protobuf v1.3.2 // indirect
8382
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
8483
github.com/golang/protobuf v1.5.2 // indirect
85-
github.com/google/gnostic v0.5.7-v3refs // indirect
84+
github.com/google/gnostic v0.6.9 // indirect
8685
github.com/google/go-cmp v0.5.8 // indirect
8786
github.com/google/gofuzz v1.2.0 // indirect
8887
github.com/google/uuid v1.3.0 // indirect
@@ -96,7 +95,7 @@ require (
9695
github.com/josharian/intern v1.0.0 // indirect
9796
github.com/json-iterator/go v1.1.12 // indirect
9897
github.com/kevinburke/ssh_config v1.2.0 // indirect
99-
github.com/mailru/easyjson v0.7.6 // indirect
98+
github.com/mailru/easyjson v0.7.7 // indirect
10099
github.com/matryer/is v1.4.0 // indirect
101100
github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 // indirect
102101
github.com/mitchellh/copystructure v1.2.0 // indirect
@@ -118,16 +117,16 @@ require (
118117
github.com/spf13/cast v1.4.1 // indirect
119118
github.com/spf13/cobra v1.5.0 // indirect
120119
github.com/xanzy/ssh-agent v0.3.1 // indirect
121-
github.com/xlab/treeprint v0.0.0-20181112141820-a009c3971eca // indirect
120+
github.com/xlab/treeprint v1.1.0 // indirect
122121
go.uber.org/atomic v1.7.0 // indirect
123122
go.uber.org/multierr v1.6.0 // indirect
124123
go.uber.org/zap v1.21.0 // indirect
125124
golang.org/x/net v0.0.0-20220708220712-1185a9018129 // indirect
126125
golang.org/x/oauth2 v0.0.0-20220718184931-c8730f7fcb92 // indirect
127126
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8 // indirect
128-
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 // indirect
127+
golang.org/x/term v0.0.0-20220526004731-065cf7ba2467 // indirect
129128
golang.org/x/text v0.3.7 // indirect
130-
golang.org/x/time v0.0.0-20220210224613-90d013bbcef8 // indirect
129+
golang.org/x/time v0.0.0-20220411224347-583f2d630306 // indirect
131130
gomodules.xyz/jsonpatch/v2 v2.2.0 // indirect
132131
google.golang.org/appengine v1.6.7 // indirect
133132
google.golang.org/protobuf v1.28.0 // indirect
@@ -140,7 +139,7 @@ require (
140139
k8s.io/klog/v2 v2.60.1 // indirect
141140
k8s.io/utils v0.0.0-20220210201930-3a6ce19ff2f9 // indirect
142141
sigs.k8s.io/cli-utils v0.31.2 // indirect
143-
sigs.k8s.io/json v0.0.0-20211208200746-9f7c6b3444d2 // indirect
144-
sigs.k8s.io/structured-merge-diff/v4 v4.2.1 // indirect
142+
sigs.k8s.io/json v0.0.0-20220525155127-227cbc7cc124 // indirect
143+
sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect
145144
sigs.k8s.io/yaml v1.3.0 // indirect
146145
)

0 commit comments

Comments
 (0)