From f707193e9098c3c04e6f93dd7af7b3567fdabfbe Mon Sep 17 00:00:00 2001 From: Sunny Date: Mon, 23 Jan 2023 15:44:07 +0000 Subject: [PATCH] Update git dependencies for bearer token support Also update API spec to mention bearer token field in git secret. Signed-off-by: Sunny --- api/v1beta2/gitrepository_types.go | 2 +- .../bases/source.toolkit.fluxcd.io_gitrepositories.yaml | 5 +++-- controllers/gitrepository_controller_test.go | 3 +++ docs/api/source.md | 4 ++-- go.mod | 4 ++-- go.sum | 8 ++++---- 6 files changed, 15 insertions(+), 11 deletions(-) diff --git a/api/v1beta2/gitrepository_types.go b/api/v1beta2/gitrepository_types.go index 0827737d6..f85191e87 100644 --- a/api/v1beta2/gitrepository_types.go +++ b/api/v1beta2/gitrepository_types.go @@ -55,7 +55,7 @@ type GitRepositorySpec struct { // SecretRef specifies the Secret containing authentication credentials for // the GitRepository. // For HTTPS repositories the Secret must contain 'username' and 'password' - // fields. + // fields for basic auth or 'bearerToken' field for token auth. // For SSH repositories the Secret must contain 'identity' // and 'known_hosts' fields. // +optional diff --git a/config/crd/bases/source.toolkit.fluxcd.io_gitrepositories.yaml b/config/crd/bases/source.toolkit.fluxcd.io_gitrepositories.yaml index f22c42398..8a4c80e05 100644 --- a/config/crd/bases/source.toolkit.fluxcd.io_gitrepositories.yaml +++ b/config/crd/bases/source.toolkit.fluxcd.io_gitrepositories.yaml @@ -492,8 +492,9 @@ spec: secretRef: description: SecretRef specifies the Secret containing authentication credentials for the GitRepository. For HTTPS repositories the Secret - must contain 'username' and 'password' fields. For SSH repositories - the Secret must contain 'identity' and 'known_hosts' fields. + must contain 'username' and 'password' fields for basic auth or + 'bearerToken' field for token auth. For SSH repositories the Secret + must contain 'identity' and 'known_hosts' fields. properties: name: description: Name of the referent. diff --git a/controllers/gitrepository_controller_test.go b/controllers/gitrepository_controller_test.go index 7ecab241f..0db3b856a 100644 --- a/controllers/gitrepository_controller_test.go +++ b/controllers/gitrepository_controller_test.go @@ -331,6 +331,9 @@ func TestGitRepositoryReconciler_reconcileSource_authStrategy(t *testing.T) { *conditions.UnknownCondition(meta.ReadyCondition, meta.ProgressingReason, "foo"), }, }, + // TODO: Add test case for HTTPS with bearer token auth secret. It + // depends on gitkit to have support for bearer token based + // authentication. { name: "SSH with private key secret makes Reconciling=True", protocol: "ssh", diff --git a/docs/api/source.md b/docs/api/source.md index 628de7c62..e98b1aa3f 100644 --- a/docs/api/source.md +++ b/docs/api/source.md @@ -322,7 +322,7 @@ github.com/fluxcd/pkg/apis/meta.LocalObjectReference

SecretRef specifies the Secret containing authentication credentials for the GitRepository. For HTTPS repositories the Secret must contain ‘username’ and ‘password’ -fields. +fields for basic auth or ‘bearerToken’ field for token auth. For SSH repositories the Secret must contain ‘identity’ and ‘known_hosts’ fields.

@@ -1748,7 +1748,7 @@ github.com/fluxcd/pkg/apis/meta.LocalObjectReference

SecretRef specifies the Secret containing authentication credentials for the GitRepository. For HTTPS repositories the Secret must contain ‘username’ and ‘password’ -fields. +fields for basic auth or ‘bearerToken’ field for token auth. For SSH repositories the Secret must contain ‘identity’ and ‘known_hosts’ fields.

diff --git a/go.mod b/go.mod index 075a4a4d4..09bffff39 100644 --- a/go.mod +++ b/go.mod @@ -24,8 +24,8 @@ require ( github.com/fluxcd/go-git/v5 v5.0.0-20221206140629-ec778c2c37df github.com/fluxcd/pkg/apis/event v0.2.0 github.com/fluxcd/pkg/apis/meta v0.18.0 - github.com/fluxcd/pkg/git v0.7.0 - github.com/fluxcd/pkg/git/gogit v0.4.0 + github.com/fluxcd/pkg/git v0.8.0 + github.com/fluxcd/pkg/git/gogit v0.5.0 github.com/fluxcd/pkg/gittestserver v0.8.0 github.com/fluxcd/pkg/helmtestserver v0.10.0 github.com/fluxcd/pkg/lockedfile v0.1.0 diff --git a/go.sum b/go.sum index 64a3e69e5..9f7fd3afb 100644 --- a/go.sum +++ b/go.sum @@ -535,10 +535,10 @@ github.com/fluxcd/pkg/apis/event v0.2.0 h1:cmAtkZfoEaNVYegI4SFM8XstdRAil3O9AoP+8 github.com/fluxcd/pkg/apis/event v0.2.0/go.mod h1:OyzKqs90J+MK7rQaEOFMMCkALpPkfmxlkabgyY2wSFQ= github.com/fluxcd/pkg/apis/meta v0.18.0 h1:s0LeulWcQ4DxVX6805vgDTxlA6bAYk+Lq1QHSnNdqLM= github.com/fluxcd/pkg/apis/meta v0.18.0/go.mod h1:pYvXRFi1UKNNrGR34jw3uqOnMXw9X6dTkML8j5Z7tis= -github.com/fluxcd/pkg/git v0.7.0 h1:sQHRpFMcOzEdqlyGMjFv2LKMdcoE5xeUr2UcRrsLRG8= -github.com/fluxcd/pkg/git v0.7.0/go.mod h1:3deiLPws4DSQ3hqwtQd7Dt66GXTN/4RcT/yHAljXaHo= -github.com/fluxcd/pkg/git/gogit v0.4.0 h1:u2Rcd/jHdvXUfgv72CES5Gq/nxAp/PblgrBDAm8ZQtQ= -github.com/fluxcd/pkg/git/gogit v0.4.0/go.mod h1:fMBM6efbAPqDEoU2M/ve+P3b/oQCuwRbia4bn9006jM= +github.com/fluxcd/pkg/git v0.8.0 h1:7mIbdqSf+qXwY17+A+Kge2yWIJCMJ1p1DiBDGnKRohg= +github.com/fluxcd/pkg/git v0.8.0/go.mod h1:3deiLPws4DSQ3hqwtQd7Dt66GXTN/4RcT/yHAljXaHo= +github.com/fluxcd/pkg/git/gogit v0.5.0 h1:3Fzx2W16K/37ZHT6WmLFuRYgs+CGvzka+dwY7ktoxJE= +github.com/fluxcd/pkg/git/gogit v0.5.0/go.mod h1:cqoJhKXCmWuN2ezD/2ECUYwR8gR7svMRJoHRr9VyTQc= github.com/fluxcd/pkg/gittestserver v0.8.0 h1:YrYe63KScKlLxx0GAiQthx2XqHDx0vKitIIx4JnDtIo= github.com/fluxcd/pkg/gittestserver v0.8.0/go.mod h1:/LI/xKMrnQbIsTDnTyABQ71iaYhFIZ8fb4cvY7WAlBU= github.com/fluxcd/pkg/helmtestserver v0.10.0 h1:/cnx1D6/cln7v06iXZMLeshl82mV1wv3OVZoBE9Bbm4=