Use serror.NewStalling() and small PR fixes
This ensures that the event, notification and log are configured correctly. Signed-off-by: Paulo Gomes <paulo.gomes@weave.works>
This commit is contained in:
parent
6b04907f5f
commit
e87997c117
|
@ -442,7 +442,7 @@ func (r *GitRepositoryReconciler) reconcileSource(ctx context.Context,
|
||||||
conditions.Delete(obj, sourcev1.SourceVerifiedCondition)
|
conditions.Delete(obj, sourcev1.SourceVerifiedCondition)
|
||||||
}
|
}
|
||||||
|
|
||||||
var data map[string][]byte
|
var authData map[string][]byte
|
||||||
if obj.Spec.SecretRef != nil {
|
if obj.Spec.SecretRef != nil {
|
||||||
// Attempt to retrieve secret
|
// Attempt to retrieve secret
|
||||||
name := types.NamespacedName{
|
name := types.NamespacedName{
|
||||||
|
@ -459,7 +459,7 @@ func (r *GitRepositoryReconciler) reconcileSource(ctx context.Context,
|
||||||
// Return error as the world as observed may change
|
// Return error as the world as observed may change
|
||||||
return sreconcile.ResultEmpty, e
|
return sreconcile.ResultEmpty, e
|
||||||
}
|
}
|
||||||
data = secret.Data
|
authData = secret.Data
|
||||||
}
|
}
|
||||||
|
|
||||||
u, err := url.Parse(obj.Spec.URL)
|
u, err := url.Parse(obj.Spec.URL)
|
||||||
|
@ -473,8 +473,7 @@ func (r *GitRepositoryReconciler) reconcileSource(ctx context.Context,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Configure authentication strategy to access the source
|
// Configure authentication strategy to access the source
|
||||||
authOpts, err := git.NewAuthOptions(*u, data)
|
authOpts, err := git.NewAuthOptions(*u, authData)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
e := serror.NewGeneric(
|
e := serror.NewGeneric(
|
||||||
fmt.Errorf("failed to configure authentication options: %w", err),
|
fmt.Errorf("failed to configure authentication options: %w", err),
|
||||||
|
@ -483,15 +482,6 @@ func (r *GitRepositoryReconciler) reconcileSource(ctx context.Context,
|
||||||
conditions.MarkTrue(obj, sourcev1.FetchFailedCondition, e.Reason, e.Err.Error())
|
conditions.MarkTrue(obj, sourcev1.FetchFailedCondition, e.Reason, e.Err.Error())
|
||||||
return sreconcile.ResultEmpty, e
|
return sreconcile.ResultEmpty, e
|
||||||
}
|
}
|
||||||
if err != nil {
|
|
||||||
e := serror.NewGeneric(
|
|
||||||
fmt.Errorf("failed to configure auth strategy for Git implementation '%s': %w", obj.Spec.GitImplementation, err),
|
|
||||||
sourcev1.AuthenticationFailedReason,
|
|
||||||
)
|
|
||||||
conditions.MarkTrue(obj, sourcev1.FetchFailedCondition, e.Reason, e.Err.Error())
|
|
||||||
// Return error as the contents of the secret may change
|
|
||||||
return sreconcile.ResultEmpty, e
|
|
||||||
}
|
|
||||||
|
|
||||||
// Fetch the included artifact metadata.
|
// Fetch the included artifact metadata.
|
||||||
artifacts, err := r.fetchIncludes(ctx, obj)
|
artifacts, err := r.fetchIncludes(ctx, obj)
|
||||||
|
@ -771,17 +761,17 @@ func (r *GitRepositoryReconciler) gitCheckout(ctx context.Context,
|
||||||
switch obj.Spec.GitImplementation {
|
switch obj.Spec.GitImplementation {
|
||||||
case sourcev1.LibGit2Implementation:
|
case sourcev1.LibGit2Implementation:
|
||||||
gitReader, err = libgit2.NewClient(dir, authOpts)
|
gitReader, err = libgit2.NewClient(dir, authOpts)
|
||||||
case sourcev1.GoGitImplementation, "":
|
case sourcev1.GoGitImplementation:
|
||||||
gitReader, err = gogit.NewClient(dir, authOpts)
|
gitReader, err = gogit.NewClient(dir, authOpts)
|
||||||
default:
|
default:
|
||||||
err = fmt.Errorf("invalid Git implementation: %s", obj.Spec.GitImplementation)
|
err = fmt.Errorf("invalid Git implementation: %s", obj.Spec.GitImplementation)
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// Do not return err as recovery without changes is impossible.
|
// Do not return err as recovery without changes is impossible.
|
||||||
e := &serror.Stalling{
|
e := serror.NewStalling(
|
||||||
Err: fmt.Errorf("failed to create Git client for implementation '%s': %w", obj.Spec.GitImplementation, err),
|
fmt.Errorf("failed to create Git client for implementation '%s': %w", obj.Spec.GitImplementation, err),
|
||||||
Reason: sourcev1.GitOperationFailedReason,
|
sourcev1.GitOperationFailedReason,
|
||||||
}
|
)
|
||||||
conditions.MarkTrue(obj, sourcev1.FetchFailedCondition, e.Reason, e.Err.Error())
|
conditions.MarkTrue(obj, sourcev1.FetchFailedCondition, e.Reason, e.Err.Error())
|
||||||
return nil, e
|
return nil, e
|
||||||
}
|
}
|
||||||
|
|
14
go.mod
14
go.mod
|
@ -27,23 +27,15 @@ require (
|
||||||
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.1.0
|
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.1.0
|
||||||
github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v0.4.1
|
github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v0.4.1
|
||||||
github.com/Masterminds/semver/v3 v3.1.1
|
github.com/Masterminds/semver/v3 v3.1.1
|
||||||
// github.com/ProtonMail/go-crypto is a fork of golang.org/x/crypto
|
|
||||||
// maintained by the ProtonMail team to continue to support the openpgp
|
|
||||||
// module, after the Go team decided to no longer maintain it.
|
|
||||||
// When in doubt (and not using openpgp), use /x/crypto.
|
|
||||||
github.com/ProtonMail/go-crypto v0.0.0-20220930113650-c6815a8c17ad // indirect
|
|
||||||
github.com/cyphar/filepath-securejoin v0.2.3
|
github.com/cyphar/filepath-securejoin v0.2.3
|
||||||
github.com/distribution/distribution/v3 v3.0.0-20221019080424-fb2188868d77
|
github.com/distribution/distribution/v3 v3.0.0-20221019080424-fb2188868d77
|
||||||
github.com/docker/cli v20.10.20+incompatible
|
github.com/docker/cli v20.10.20+incompatible
|
||||||
github.com/docker/go-units v0.5.0
|
github.com/docker/go-units v0.5.0
|
||||||
github.com/elazarl/goproxy v0.0.0-20221015165544-a0805db90819 // indirect
|
|
||||||
github.com/fluxcd/gitkit v0.6.0 // indirect
|
|
||||||
github.com/fluxcd/pkg/apis/meta v0.17.0
|
github.com/fluxcd/pkg/apis/meta v0.17.0
|
||||||
github.com/fluxcd/pkg/git v0.6.1
|
github.com/fluxcd/pkg/git v0.6.1
|
||||||
github.com/fluxcd/pkg/git/gogit v0.0.0-20221026111216-11a3405b2580
|
github.com/fluxcd/pkg/git/gogit v0.0.0-20221026111216-11a3405b2580
|
||||||
github.com/fluxcd/pkg/git/libgit2 v0.0.0-20221026111216-11a3405b2580
|
github.com/fluxcd/pkg/git/libgit2 v0.0.0-20221026111216-11a3405b2580
|
||||||
github.com/fluxcd/pkg/gittestserver v0.7.0
|
github.com/fluxcd/pkg/gittestserver v0.7.0
|
||||||
github.com/fluxcd/pkg/gitutil v0.2.0 // indirect
|
|
||||||
github.com/fluxcd/pkg/helmtestserver v0.9.0
|
github.com/fluxcd/pkg/helmtestserver v0.9.0
|
||||||
github.com/fluxcd/pkg/lockedfile v0.1.0
|
github.com/fluxcd/pkg/lockedfile v0.1.0
|
||||||
github.com/fluxcd/pkg/masktoken v0.2.0
|
github.com/fluxcd/pkg/masktoken v0.2.0
|
||||||
|
@ -72,7 +64,6 @@ require (
|
||||||
github.com/sirupsen/logrus v1.9.0
|
github.com/sirupsen/logrus v1.9.0
|
||||||
github.com/spf13/pflag v1.0.5
|
github.com/spf13/pflag v1.0.5
|
||||||
golang.org/x/crypto v0.1.0
|
golang.org/x/crypto v0.1.0
|
||||||
golang.org/x/net v0.1.0 // indirect
|
|
||||||
golang.org/x/sync v0.1.0
|
golang.org/x/sync v0.1.0
|
||||||
google.golang.org/api v0.100.0
|
google.golang.org/api v0.100.0
|
||||||
gotest.tools v2.2.0+incompatible
|
gotest.tools v2.2.0+incompatible
|
||||||
|
@ -110,6 +101,7 @@ require (
|
||||||
github.com/Masterminds/sprig/v3 v3.2.2 // indirect
|
github.com/Masterminds/sprig/v3 v3.2.2 // indirect
|
||||||
github.com/Masterminds/squirrel v1.5.3 // indirect
|
github.com/Masterminds/squirrel v1.5.3 // indirect
|
||||||
github.com/Microsoft/go-winio v0.6.0 // indirect
|
github.com/Microsoft/go-winio v0.6.0 // indirect
|
||||||
|
github.com/ProtonMail/go-crypto v0.0.0-20220930113650-c6815a8c17ad // indirect
|
||||||
github.com/Shopify/logrus-bugsnag v0.0.0-20171204204709-577dee27f20d // indirect
|
github.com/Shopify/logrus-bugsnag v0.0.0-20171204204709-577dee27f20d // indirect
|
||||||
github.com/ThalesIgnite/crypto11 v1.2.5 // indirect
|
github.com/ThalesIgnite/crypto11 v1.2.5 // indirect
|
||||||
github.com/acomagu/bufpipe v1.0.3 // indirect
|
github.com/acomagu/bufpipe v1.0.3 // indirect
|
||||||
|
@ -175,6 +167,7 @@ require (
|
||||||
github.com/docker/go-metrics v0.0.1 // indirect
|
github.com/docker/go-metrics v0.0.1 // indirect
|
||||||
github.com/docker/libtrust v0.0.0-20160708172513-aabc10ec26b7 // indirect
|
github.com/docker/libtrust v0.0.0-20160708172513-aabc10ec26b7 // indirect
|
||||||
github.com/dustin/go-humanize v1.0.0 // indirect
|
github.com/dustin/go-humanize v1.0.0 // indirect
|
||||||
|
github.com/elazarl/goproxy v0.0.0-20221015165544-a0805db90819 // indirect
|
||||||
github.com/emicklei/go-restful/v3 v3.9.0 // indirect
|
github.com/emicklei/go-restful/v3 v3.9.0 // indirect
|
||||||
github.com/emirpasic/gods v1.18.1 // indirect
|
github.com/emirpasic/gods v1.18.1 // indirect
|
||||||
github.com/envoyproxy/go-control-plane v0.10.2-0.20220325020618-49ff273808a1 // indirect
|
github.com/envoyproxy/go-control-plane v0.10.2-0.20220325020618-49ff273808a1 // indirect
|
||||||
|
@ -184,7 +177,9 @@ require (
|
||||||
github.com/exponent-io/jsonpath v0.0.0-20151013193312-d6023ce2651d // indirect
|
github.com/exponent-io/jsonpath v0.0.0-20151013193312-d6023ce2651d // indirect
|
||||||
github.com/fatih/color v1.13.0 // indirect
|
github.com/fatih/color v1.13.0 // indirect
|
||||||
github.com/felixge/httpsnoop v1.0.3 // indirect
|
github.com/felixge/httpsnoop v1.0.3 // indirect
|
||||||
|
github.com/fluxcd/gitkit v0.6.0 // indirect
|
||||||
github.com/fluxcd/pkg/apis/acl v0.1.0 // indirect
|
github.com/fluxcd/pkg/apis/acl v0.1.0 // indirect
|
||||||
|
github.com/fluxcd/pkg/gitutil v0.2.0 // indirect
|
||||||
github.com/fluxcd/pkg/http/transport v0.1.0 // indirect
|
github.com/fluxcd/pkg/http/transport v0.1.0 // indirect
|
||||||
github.com/fsnotify/fsnotify v1.5.4 // indirect
|
github.com/fsnotify/fsnotify v1.5.4 // indirect
|
||||||
github.com/fullstorydev/grpcurl v1.8.7 // indirect
|
github.com/fullstorydev/grpcurl v1.8.7 // indirect
|
||||||
|
@ -377,6 +372,7 @@ require (
|
||||||
go.uber.org/zap v1.23.0 // indirect
|
go.uber.org/zap v1.23.0 // indirect
|
||||||
golang.org/x/exp v0.0.0-20220823124025-807a23277127 // indirect
|
golang.org/x/exp v0.0.0-20220823124025-807a23277127 // indirect
|
||||||
golang.org/x/mod v0.6.0 // indirect
|
golang.org/x/mod v0.6.0 // indirect
|
||||||
|
golang.org/x/net v0.1.0 // indirect
|
||||||
golang.org/x/oauth2 v0.1.0 // indirect
|
golang.org/x/oauth2 v0.1.0 // indirect
|
||||||
golang.org/x/sys v0.1.0 // indirect
|
golang.org/x/sys v0.1.0 // indirect
|
||||||
golang.org/x/term v0.1.0 // indirect
|
golang.org/x/term v0.1.0 // indirect
|
||||||
|
|
Loading…
Reference in New Issue