GitRepo: Remove provider default value from API
For backwards compatibility, remove the default value for GitRepository
provider. An empty provider value will still be considered as the
default provider.
Signed-off-by: Sunny <github@darkowlzz.space>
(cherry picked from commit db42b07914
)
This commit is contained in:
parent
e6e2b159fc
commit
0e4f558bd1
|
@ -91,7 +91,6 @@ type GitRepositorySpec struct {
|
|||
// Provider used for authentication, can be 'azure', 'generic'.
|
||||
// When not specified, defaults to 'generic'.
|
||||
// +kubebuilder:validation:Enum=generic;azure
|
||||
// +kubebuilder:default:=generic
|
||||
// +optional
|
||||
Provider string `json:"provider,omitempty"`
|
||||
|
||||
|
@ -303,6 +302,14 @@ func (in *GitRepository) GetArtifact() *Artifact {
|
|||
return in.Status.Artifact
|
||||
}
|
||||
|
||||
// GetProvider returns the Git authentication provider.
|
||||
func (v *GitRepository) GetProvider() string {
|
||||
if v.Spec.Provider == "" {
|
||||
return GitProviderGeneric
|
||||
}
|
||||
return v.Spec.Provider
|
||||
}
|
||||
|
||||
// GetMode returns the declared GitVerificationMode, or a ModeGitHEAD default.
|
||||
func (v *GitRepositoryVerification) GetMode() GitVerificationMode {
|
||||
if v.Mode.Valid() {
|
||||
|
|
|
@ -104,7 +104,6 @@ spec:
|
|||
pattern: ^([0-9]+(\.[0-9]+)?(ms|s|m|h))+$
|
||||
type: string
|
||||
provider:
|
||||
default: generic
|
||||
description: |-
|
||||
Provider used for authentication, can be 'azure', 'generic'.
|
||||
When not specified, defaults to 'generic'.
|
||||
|
|
|
@ -650,14 +650,12 @@ func (r *GitRepositoryReconciler) getAuthOpts(ctx context.Context, obj *sourcev1
|
|||
}
|
||||
|
||||
// Configure provider authentication if specified in spec
|
||||
if obj.Spec.Provider != "" && obj.Spec.Provider != sourcev1.GitProviderGeneric {
|
||||
if obj.Spec.Provider == sourcev1.GitProviderAzure {
|
||||
authOpts.ProviderOpts = &git.ProviderOptions{
|
||||
Name: obj.Spec.Provider,
|
||||
AzureOpts: []azure.OptFunc{
|
||||
azure.WithAzureDevOpsScope(),
|
||||
},
|
||||
}
|
||||
if obj.GetProvider() == sourcev1.GitProviderAzure {
|
||||
authOpts.ProviderOpts = &git.ProviderOptions{
|
||||
Name: obj.GetProvider(),
|
||||
AzureOpts: []azure.OptFunc{
|
||||
azure.WithAzureDevOpsScope(),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue