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>
This commit is contained in:
parent
1f150c552f
commit
db42b07914
|
@ -91,7 +91,6 @@ type GitRepositorySpec struct {
|
||||||
// Provider used for authentication, can be 'azure', 'generic'.
|
// Provider used for authentication, can be 'azure', 'generic'.
|
||||||
// When not specified, defaults to 'generic'.
|
// When not specified, defaults to 'generic'.
|
||||||
// +kubebuilder:validation:Enum=generic;azure
|
// +kubebuilder:validation:Enum=generic;azure
|
||||||
// +kubebuilder:default:=generic
|
|
||||||
// +optional
|
// +optional
|
||||||
Provider string `json:"provider,omitempty"`
|
Provider string `json:"provider,omitempty"`
|
||||||
|
|
||||||
|
@ -303,6 +302,14 @@ func (in *GitRepository) GetArtifact() *Artifact {
|
||||||
return in.Status.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.
|
// GetMode returns the declared GitVerificationMode, or a ModeGitHEAD default.
|
||||||
func (v *GitRepositoryVerification) GetMode() GitVerificationMode {
|
func (v *GitRepositoryVerification) GetMode() GitVerificationMode {
|
||||||
if v.Mode.Valid() {
|
if v.Mode.Valid() {
|
||||||
|
|
|
@ -104,7 +104,6 @@ spec:
|
||||||
pattern: ^([0-9]+(\.[0-9]+)?(ms|s|m|h))+$
|
pattern: ^([0-9]+(\.[0-9]+)?(ms|s|m|h))+$
|
||||||
type: string
|
type: string
|
||||||
provider:
|
provider:
|
||||||
default: generic
|
|
||||||
description: |-
|
description: |-
|
||||||
Provider used for authentication, can be 'azure', 'generic'.
|
Provider used for authentication, can be 'azure', 'generic'.
|
||||||
When not specified, defaults to '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
|
// Configure provider authentication if specified in spec
|
||||||
if obj.Spec.Provider != "" && obj.Spec.Provider != sourcev1.GitProviderGeneric {
|
if obj.GetProvider() == sourcev1.GitProviderAzure {
|
||||||
if obj.Spec.Provider == sourcev1.GitProviderAzure {
|
authOpts.ProviderOpts = &git.ProviderOptions{
|
||||||
authOpts.ProviderOpts = &git.ProviderOptions{
|
Name: obj.GetProvider(),
|
||||||
Name: obj.Spec.Provider,
|
AzureOpts: []azure.OptFunc{
|
||||||
AzureOpts: []azure.OptFunc{
|
azure.WithAzureDevOpsScope(),
|
||||||
azure.WithAzureDevOpsScope(),
|
},
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue