From 632e96ee8e56d88d637c3b7420ad715612ffd24e Mon Sep 17 00:00:00 2001 From: Damien Dassieu Date: Fri, 31 May 2024 12:46:49 +0200 Subject: [PATCH] Split server configs into different confimap --- api/v1/gitremote_types.go | 9 +- api/v1/zz_generated.deepcopy.go | 34 +++--- .../config/bitbucket-configuration.yaml | 6 ++ .../config/github-configuration.yaml | 6 ++ .../config/gitlab-configuration.yaml | 6 ++ .../git-providers-configuration.yaml | 11 -- .../crd/bases/kgio.dams.kgio_gitremotes.yaml | 21 +++- .../kgio.dams.kgio_resourcesinterceptors.yaml | 29 ++++- internal/controller/git_pusher.go | 2 +- internal/controller/gitremote_controller.go | 100 +++++++++--------- .../controller/webhook_request_checker.go | 12 +-- 11 files changed, 145 insertions(+), 91 deletions(-) create mode 100644 chart/0.0.1/templates/config/bitbucket-configuration.yaml create mode 100644 chart/0.0.1/templates/config/github-configuration.yaml create mode 100644 chart/0.0.1/templates/config/gitlab-configuration.yaml delete mode 100644 chart/0.0.1/templates/controller/git-providers-configuration.yaml diff --git a/api/v1/gitremote_types.go b/api/v1/gitremote_types.go index 534a3c3..17fd482 100644 --- a/api/v1/gitremote_types.go +++ b/api/v1/gitremote_types.go @@ -30,13 +30,16 @@ type GitRemoteSpec struct { GitBaseDomainFQDN string `json:"gitBaseDomainFQDN"` // +optional - CustomGitProviderConfigRef corev1.ObjectReference `json:"customGitProviderConfigRef,omitempty"` + CustomGitServerConfigRef corev1.ObjectReference `json:"customGitServerConfigRef,omitempty"` // +optional TestAuthentication bool `json:"testAuthentication,omitempty"` + + // +optional + InsecureSkipTlsVerify bool `json:"insecureSkipTlsVerify,omitempty"` } -type GitProviderConfiguration struct { +type GitServerConfiguration struct { // +optional Inherited bool `json:"inherited,omitempty" yaml:"inherited,omitempty"` //+ optional @@ -91,7 +94,7 @@ type GitRemoteStatus struct { SecretBoundStatus SecretBoundStatus `json:"secretBoundStatus,omitempty"` // +optional - GitProviderConfiguration GitProviderConfiguration `json:"gitProviderConfiguration,omitempty"` + GitServerConfiguration GitServerConfiguration `json:"gitServerConfiguration,omitempty"` } //+kubebuilder:object:root=true diff --git a/api/v1/zz_generated.deepcopy.go b/api/v1/zz_generated.deepcopy.go index 4343cd9..ef66360 100644 --- a/api/v1/zz_generated.deepcopy.go +++ b/api/v1/zz_generated.deepcopy.go @@ -28,21 +28,6 @@ import ( "k8s.io/apimachinery/pkg/runtime/schema" ) -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *GitProviderConfiguration) DeepCopyInto(out *GitProviderConfiguration) { - *out = *in -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GitProviderConfiguration. -func (in *GitProviderConfiguration) DeepCopy() *GitProviderConfiguration { - if in == nil { - return nil - } - out := new(GitProviderConfiguration) - in.DeepCopyInto(out) - return out -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *GitRemote) DeepCopyInto(out *GitRemote) { *out = *in @@ -121,7 +106,7 @@ func (in *GitRemoteList) DeepCopyObject() runtime.Object { func (in *GitRemoteSpec) DeepCopyInto(out *GitRemoteSpec) { *out = *in out.SecretRef = in.SecretRef - out.CustomGitProviderConfigRef = in.CustomGitProviderConfigRef + out.CustomGitServerConfigRef = in.CustomGitServerConfigRef } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GitRemoteSpec. @@ -139,7 +124,7 @@ func (in *GitRemoteStatus) DeepCopyInto(out *GitRemoteStatus) { *out = *in out.ConnexionStatus = in.ConnexionStatus in.LastAuthTime.DeepCopyInto(&out.LastAuthTime) - out.GitProviderConfiguration = in.GitProviderConfiguration + out.GitServerConfiguration = in.GitServerConfiguration } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GitRemoteStatus. @@ -152,6 +137,21 @@ func (in *GitRemoteStatus) DeepCopy() *GitRemoteStatus { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *GitServerConfiguration) DeepCopyInto(out *GitServerConfiguration) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GitServerConfiguration. +func (in *GitServerConfiguration) DeepCopy() *GitServerConfiguration { + if in == nil { + return nil + } + out := new(GitServerConfiguration) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *GitUserBinding) DeepCopyInto(out *GitUserBinding) { *out = *in diff --git a/chart/0.0.1/templates/config/bitbucket-configuration.yaml b/chart/0.0.1/templates/config/bitbucket-configuration.yaml new file mode 100644 index 0000000..9bb8558 --- /dev/null +++ b/chart/0.0.1/templates/config/bitbucket-configuration.yaml @@ -0,0 +1,6 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: bitbucket.org +data: + authenticationEndpoint: https://api.bitbucket.org/2.0/user \ No newline at end of file diff --git a/chart/0.0.1/templates/config/github-configuration.yaml b/chart/0.0.1/templates/config/github-configuration.yaml new file mode 100644 index 0000000..f511b2c --- /dev/null +++ b/chart/0.0.1/templates/config/github-configuration.yaml @@ -0,0 +1,6 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: github.com +data: + authenticationEndpoint: https://api.github.com/user \ No newline at end of file diff --git a/chart/0.0.1/templates/config/gitlab-configuration.yaml b/chart/0.0.1/templates/config/gitlab-configuration.yaml new file mode 100644 index 0000000..02da1ca --- /dev/null +++ b/chart/0.0.1/templates/config/gitlab-configuration.yaml @@ -0,0 +1,6 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: gitlab.com +data: + authenticationEndpoint: https://gitlab.com/api/v4/user \ No newline at end of file diff --git a/chart/0.0.1/templates/controller/git-providers-configuration.yaml b/chart/0.0.1/templates/controller/git-providers-configuration.yaml deleted file mode 100644 index fc3b668..0000000 --- a/chart/0.0.1/templates/controller/git-providers-configuration.yaml +++ /dev/null @@ -1,11 +0,0 @@ -apiVersion: v1 -kind: ConfigMap -metadata: - name: git-providers-configuration -data: - bitbucket.org: | - authenticationEndpoint: https://api.bitbucket.org/2.0/user - github.com: | - authenticationEndpoint: https://api.github.com/user - gitlab.com: | - authenticationEndpoint: https://gitlab.com/api/v4/user \ No newline at end of file diff --git a/config/crd/bases/kgio.dams.kgio_gitremotes.yaml b/config/crd/bases/kgio.dams.kgio_gitremotes.yaml index c363445..98cae7b 100644 --- a/config/crd/bases/kgio.dams.kgio_gitremotes.yaml +++ b/config/crd/bases/kgio.dams.kgio_gitremotes.yaml @@ -39,9 +39,22 @@ spec: spec: description: GitRemoteSpec defines the desired state of GitRemote properties: - customGitProviderConfigRef: + customGitServerConfigRef: description: |- - Reference to a ConfigMap to configuration the behavior of the GitRemote connexion with the distant server + ObjectReference contains enough information to let you inspect or modify the referred object. + --- + New uses of this type are discouraged because of difficulty describing its usage when embedded in APIs. + 1. Ignored fields. It includes many fields which are not generally honored. For instance, ResourceVersion and FieldPath are both very rarely valid in actual usage. + 2. Invalid usage help. It is impossible to add specific help for individual usage. In most embedded usages, there are particular + restrictions like, "must refer only to types A and B" or "UID not honored" or "name must be restricted". + Those cannot be well described when embedded. + 3. Inconsistent validation. Because the usages are different, the validation rules are different by usage, which makes it hard for users to predict what will happen. + 4. The fields are both imprecise and overly precise. Kind is not a precise mapping to a URL. This can produce ambiguity + during interpretation and require a REST mapping. In most cases, the dependency is on the group,resource tuple + and the version of the actual struct is irrelevant. + 5. We cannot easily change it. Because this type is embedded in many locations, updates to this type + will affect numerous schemas. Don't make new APIs embed an underspecified API type they do not control. + Instead of using this type, create a locally provided and used type that is well-focused on your reference. For example, ServiceReferences for admission registration: https://github.com/kubernetes/api/blob/release-1.17/admissionregistration/v1/types.go#L533 . @@ -91,6 +104,8 @@ spec: type: string gitBaseDomainFQDN: type: string + insecureSkipTlsVerify: + type: boolean secretRef: description: |- SecretReference represents a Secret Reference. It has enough information to retrieve secret @@ -123,7 +138,7 @@ spec: status: type: string type: object - gitProviderConfiguration: + gitServerConfiguration: properties: authenticationEndpoint: type: string diff --git a/config/crd/bases/kgio.dams.kgio_resourcesinterceptors.yaml b/config/crd/bases/kgio.dams.kgio_resourcesinterceptors.yaml index 7cb26b7..6248ce0 100644 --- a/config/crd/bases/kgio.dams.kgio_resourcesinterceptors.yaml +++ b/config/crd/bases/kgio.dams.kgio_resourcesinterceptors.yaml @@ -43,7 +43,20 @@ spec: authorizedUsers: items: description: |- - Reference to GitUserBinding objects + ObjectReference contains enough information to let you inspect or modify the referred object. + --- + New uses of this type are discouraged because of difficulty describing its usage when embedded in APIs. + 1. Ignored fields. It includes many fields which are not generally honored. For instance, ResourceVersion and FieldPath are both very rarely valid in actual usage. + 2. Invalid usage help. It is impossible to add specific help for individual usage. In most embedded usages, there are particular + restrictions like, "must refer only to types A and B" or "UID not honored" or "name must be restricted". + Those cannot be well described when embedded. + 3. Inconsistent validation. Because the usages are different, the validation rules are different by usage, which makes it hard for users to predict what will happen. + 4. The fields are both imprecise and overly precise. Kind is not a precise mapping to a URL. This can produce ambiguity + during interpretation and require a REST mapping. In most cases, the dependency is on the group,resource tuple + and the version of the actual struct is irrelevant. + 5. We cannot easily change it. Because this type is embedded in many locations, updates to this type + will affect numerous schemas. Don't make new APIs embed an underspecified API type they do not control. + Instead of using this type, create a locally provided and used type that is well-focused on your reference. For example, ServiceReferences for admission registration: https://github.com/kubernetes/api/blob/release-1.17/admissionregistration/v1/types.go#L533 . @@ -134,7 +147,19 @@ spec: type: string defaultUserBind: description: |- - Reference to a GitUserBinding. If set, this git user will be use to push the resources. + ObjectReference contains enough information to let you inspect or modify the referred object. + --- + New uses of this type are discouraged because of difficulty describing its usage when embedded in APIs. + 1. Ignored fields. It includes many fields which are not generally honored. For instance, ResourceVersion and FieldPath are both very rarely valid in actual usage. + 2. Invalid usage help. It is impossible to add specific help for individual usage. In most embedded usages, there are particular + restrictions like, "must refer only to types A and B" or "UID not honored" or "name must be restricted". + Those cannot be well described when embedded. + 3. Inconsistent validation. Because the usages are different, the validation rules are different by usage, which makes it hard for users to predict what will happen. + 4. The fields are both imprecise and overly precise. Kind is not a precise mapping to a URL. This can produce ambiguity + during interpretation and require a REST mapping. In most cases, the dependency is on the group,resource tuple + and the version of the actual struct is irrelevant. + 5. We cannot easily change it. Because this type is embedded in many locations, updates to this type + will affect numerous schemas. Don't make new APIs embed an underspecified API type they do not control. Instead of using this type, create a locally provided and used type that is well-focused on your reference. diff --git a/internal/controller/git_pusher.go b/internal/controller/git_pusher.go index 7d53fe2..6a839a4 100644 --- a/internal/controller/git_pusher.go +++ b/internal/controller/git_pusher.go @@ -29,7 +29,7 @@ type GitPusher struct { gitEmail string gitToken string operation admissionv1.Operation - remoteConfiguration kgiov1.GitProviderConfiguration + remoteConfiguration kgiov1.GitServerConfiguration } type GitPushResponse struct { diff --git a/internal/controller/gitremote_controller.go b/internal/controller/gitremote_controller.go index af81891..ae04afb 100644 --- a/internal/controller/gitremote_controller.go +++ b/internal/controller/gitremote_controller.go @@ -22,8 +22,8 @@ import ( "fmt" "net/http" "os" + "strings" - "gopkg.in/yaml.v2" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/fields" @@ -57,56 +57,53 @@ func (r *GitRemoteReconciler) updateStatus(ctx context.Context, gitRemote *kgiov return nil } -func (r *GitRemoteReconciler) setProviderConfiguration(ctx context.Context, gitRemote *kgiov1.GitRemote) (kgiov1.GitProviderConfiguration, error) { +func (r *GitRemoteReconciler) setServerConfiguration(ctx context.Context, gitRemote *kgiov1.GitRemote) (kgiov1.GitServerConfiguration, error) { - gpc := kgiov1.GitProviderConfiguration{ - Inherited: false, - CaBundle: "", - InsecureSkipTlsVerify: false, + gpc := &kgiov1.GitServerConfiguration{ + Inherited: false, + AuthenticationEndpoint: "", + CaBundle: "", + InsecureSkipTlsVerify: false, } // STEP 1 : Check the config map ref var cm corev1.ConfigMap - if gitRemote.Spec.CustomGitProviderConfigRef.Name != "" { + if gitRemote.Spec.CustomGitServerConfigRef.Name != "" { // It is defined in the GitRemote object - namespacedName := types.NamespacedName{Namespace: gitRemote.Namespace, Name: gitRemote.Spec.CustomGitProviderConfigRef.Name} + namespacedName := types.NamespacedName{Namespace: gitRemote.Namespace, Name: gitRemote.Spec.CustomGitServerConfigRef.Name} if err := r.Get(ctx, namespacedName, &cm); err != nil { gitRemote.Status.ConnexionStatus.Status = kgiov1.GitConfigNotFound - gitRemote.Status.ConnexionStatus.Details = "ConfigMap name: " + gitRemote.Spec.CustomGitProviderConfigRef.Name - return gpc, err + gitRemote.Status.ConnexionStatus.Details = "ConfigMap name: " + gitRemote.Spec.CustomGitServerConfigRef.Name + return *gpc, err } } else { // It is not defined in the GitRemote object -> look for the default configmap of the operator - namespacedName := types.NamespacedName{Namespace: r.Namespace, Name: gitProvidersConfigMap} + namespacedName := types.NamespacedName{Namespace: r.Namespace, Name: gitRemote.Spec.GitBaseDomainFQDN} if err := r.Get(ctx, namespacedName, &cm); err != nil { gitRemote.Status.ConnexionStatus.Status = kgiov1.GitConfigNotFound - gitRemote.Status.ConnexionStatus.Details = "Configuration reference not found in the current GitRemote; ConfigMap " + gitProvidersConfigMap + " in the namespace of the operator not found as well" - return gpc, err + gitRemote.Status.ConnexionStatus.Details = "Configuration reference not found in the current GitRemote; ConfigMap " + gitRemote.Spec.GitBaseDomainFQDN + " in the namespace of the operator not found as well" + return *gpc, err } gpc.Inherited = true } - // STEP 2 : Build the GitProviderConfiguration + // STEP 2 : Build the GitServerConfiguration // Parse the ConfigMap - providers, err := parseConfigMap(cm) + serverConf, err := parseConfigMap(cm) if err != nil { gitRemote.Status.ConnexionStatus.Status = kgiov1.GitConfigParseError gitRemote.Status.ConnexionStatus.Details = err.Error() - return gpc, err + return *gpc, err } - // Set the conf - for providerName, providerData := range providers { - if gitRemote.Spec.GitBaseDomainFQDN == providerName { - gpc.AuthenticationEndpoint = providerData.AuthenticationEndpoint - gpc.CaBundle = providerData.CaBundle - gpc.InsecureSkipTlsVerify = providerData.InsecureSkipTlsVerify - // .. Future conf - } + if gitRemote.Spec.InsecureSkipTlsVerify != serverConf.InsecureSkipTlsVerify { + serverConf.InsecureSkipTlsVerify = gitRemote.Spec.InsecureSkipTlsVerify } - return gpc, nil + *gpc = serverConf + + return *gpc, nil } // +kubebuilder:rbac:groups=kgio.dams.kgio,resources=gitremotes,verbs=get;list;watch;create;update;patch;delete @@ -143,12 +140,12 @@ func (r *GitRemoteReconciler) Reconcile(ctx context.Context, req ctrl.Request) ( username := string(secret.Data["username"]) // Update configuration - gpc, err := r.setProviderConfiguration(ctx, &gitRemote) + gpc, err := r.setServerConfiguration(ctx, &gitRemote) if err != nil { errUpdate := r.updateStatus(ctx, &gitRemote) return ctrl.Result{}, errUpdate } - gitRemote.Status.GitProviderConfiguration = gpc + gitRemote.Status.GitServerConfiguration = gpc errUpdate := r.updateStatus(ctx, &gitRemote) if errUpdate != nil { return ctrl.Result{}, errUpdate @@ -172,9 +169,9 @@ func (r *GitRemoteReconciler) Reconcile(ctx context.Context, req ctrl.Request) ( if authenticationEndpoint == "" { errMsg := "" if gpc.Inherited { - errMsg = "git provider not found in the " + gitProvidersConfigMap + " ConfigMap in the namespace of the operator" + errMsg = "git provider not found in the " + gitRemote.Spec.GitBaseDomainFQDN + " ConfigMap in the namespace of the operator" } else { - errMsg = "git provider not found in the " + gitRemote.Spec.CustomGitProviderConfigRef.Name + " ConfigMap" + errMsg = "git provider not found in the " + gitRemote.Spec.CustomGitServerConfigRef.Name + " ConfigMap" } gitRemote.Status.ConnexionStatus.Status = kgiov1.GitUnsupported gitRemote.Status.ConnexionStatus.Details = errMsg @@ -187,7 +184,7 @@ func (r *GitRemoteReconciler) Reconcile(ctx context.Context, req ctrl.Request) ( gitReq, err := http.NewRequest("GET", authenticationEndpoint, nil) if err != nil { gitRemote.Status.ConnexionStatus.Status = kgiov1.GitServerError - gitRemote.Status.ConnexionStatus.Details = "Internal operator error : cannot create the http request" + gitRemote.Status.ConnexionStatus.Details = "Internal operator error : cannot create the http request " + err.Error() errUpdate := r.updateStatus(ctx, &gitRemote) return ctrl.Result{}, errUpdate } @@ -196,12 +193,14 @@ func (r *GitRemoteReconciler) Reconcile(ctx context.Context, req ctrl.Request) ( resp, err := httpClient.Do(gitReq) if err != nil { gitRemote.Status.ConnexionStatus.Status = kgiov1.GitServerError - gitRemote.Status.ConnexionStatus.Details = "Internal operator error : the request cannot be processed" + gitRemote.Status.ConnexionStatus.Details = "Internal operator error : the request cannot be processed " + err.Error() errUpdate := r.updateStatus(ctx, &gitRemote) return ctrl.Result{}, errUpdate } defer resp.Body.Close() + gitRemote.Status.ConnexionStatus.Details = "" + // Check the response status code if resp.StatusCode == http.StatusOK { // Authentication successful @@ -234,20 +233,26 @@ func (r *GitRemoteReconciler) Reconcile(ctx context.Context, req ctrl.Request) ( return ctrl.Result{}, nil } -func parseConfigMap(configMap corev1.ConfigMap) (map[string]kgiov1.GitProviderConfiguration, error) { - providers := make(map[string]kgiov1.GitProviderConfiguration) - +func parseConfigMap(configMap corev1.ConfigMap) (kgiov1.GitServerConfiguration, error) { + gitServerConf := &kgiov1.GitServerConfiguration{} for key, value := range configMap.Data { - var gitProvider kgiov1.GitProviderConfiguration - - if err := yaml.Unmarshal([]byte(value), &gitProvider); err != nil { - return nil, errors.New("failed to unmarshal provider data for key " + key + ": " + err.Error()) + switch key { + case "authenticationEndpoint": + gitServerConf.AuthenticationEndpoint = value + case "caBundle": + gitServerConf.CaBundle = value + case "insecureSkipTlsVerify": + if value == "true" { + gitServerConf.InsecureSkipTlsVerify = true + } else { + gitServerConf.InsecureSkipTlsVerify = false + } + default: + return *gitServerConf, errors.New("wrong key " + key + " found in the git server configmap " + configMap.Namespace + "/" + configMap.Name) } - - providers[key] = gitProvider } - return providers, nil + return *gitServerConf, nil } func (r *GitRemoteReconciler) findObjectsForSecret(ctx context.Context, secret client.Object) []reconcile.Request { @@ -321,7 +326,7 @@ func (r *GitRemoteReconciler) gitEndpointsConfigCreation(e event.CreateEvent) bo if !ok { return false } - return configMap.Namespace == r.Namespace && configMap.Name == gitProvidersConfigMap + return configMap.Namespace == r.Namespace && strings.Contains(configMap.Name, ".") } func (r *GitRemoteReconciler) gitEndpointsConfigUpdate(e event.UpdateEvent) bool { @@ -329,7 +334,7 @@ func (r *GitRemoteReconciler) gitEndpointsConfigUpdate(e event.UpdateEvent) bool if !ok { return false } - return configMap.Namespace == r.Namespace && configMap.Name == gitProvidersConfigMap + return configMap.Namespace == r.Namespace && strings.Contains(configMap.Name, ".") } func (r *GitRemoteReconciler) gitEndpointsConfigDeletion(e event.DeleteEvent) bool { @@ -337,13 +342,12 @@ func (r *GitRemoteReconciler) gitEndpointsConfigDeletion(e event.DeleteEvent) bo if !ok { return false } - return configMap.Namespace == r.Namespace && configMap.Name == gitProvidersConfigMap + return configMap.Namespace == r.Namespace && strings.Contains(configMap.Name, ".") } const ( secretRefField = ".spec.secretRef.name" - gitProviderConfigRefField = ".spec.customGitProviderConfigRef.name" - gitProvidersConfigMap = "git-providers-configuration" + gitProviderConfigRefField = ".spec.CustomGitServerConfigRef.name" ) // SetupWithManager sets up the controller with the Manager. @@ -361,10 +365,10 @@ func (r *GitRemoteReconciler) SetupWithManager(mgr ctrl.Manager) error { if err := mgr.GetFieldIndexer().IndexField(context.Background(), &kgiov1.GitRemote{}, gitProviderConfigRefField, func(rawObj client.Object) []string { // Extract the ConfigMap name from the GitRemote Spec, if one is provided gitRemote := rawObj.(*kgiov1.GitRemote) - if gitRemote.Spec.CustomGitProviderConfigRef.Name == "" { + if gitRemote.Spec.CustomGitServerConfigRef.Name == "" { return nil } - return []string{gitRemote.Spec.CustomGitProviderConfigRef.Name} + return []string{gitRemote.Spec.CustomGitServerConfigRef.Name} }); err != nil { return err } diff --git a/internal/controller/webhook_request_checker.go b/internal/controller/webhook_request_checker.go index 2e120e3..d4aefc5 100644 --- a/internal/controller/webhook_request_checker.go +++ b/internal/controller/webhook_request_checker.go @@ -43,7 +43,7 @@ type wrcDetails struct { repoPath string commitHash string gitUser gitUser - remoteConf kgiov1.GitProviderConfiguration + remoteConf kgiov1.GitServerConfiguration pushDetails string } @@ -178,7 +178,7 @@ func (wrc *WebhookRequestChecker) userAllowed(details *wrcDetails) (bool, error) gitEmail: "", gitToken: "", } - remoteConf := &kgiov1.GitProviderConfiguration{ + remoteConf := &kgiov1.GitServerConfiguration{ CaBundle: "", InsecureSkipTlsVerify: false, } @@ -198,7 +198,7 @@ func (wrc *WebhookRequestChecker) userAllowed(details *wrcDetails) (bool, error) // The subject name can not be unique -> in specific conditions, a commit can be done as another user // Need to be studied if gitUserBinding.Spec.Subject.Name == incomingUser.Username { - _, gitUser, err = wrc.searchForGitToken(*gitUserBinding, fqdn, remoteConf) + remoteConf, gitUser, err = wrc.searchForGitToken(*gitUserBinding, fqdn, remoteConf) if err != nil { errMsg := err.Error() details.messageAddition = errMsg @@ -225,7 +225,7 @@ func (wrc *WebhookRequestChecker) userAllowed(details *wrcDetails) (bool, error) return true, nil } -func (wrc *WebhookRequestChecker) searchForGitToken(gub kgiov1.GitUserBinding, fqdn string, remoteConf *kgiov1.GitProviderConfiguration) (*kgiov1.GitProviderConfiguration, *gitUser, error) { +func (wrc *WebhookRequestChecker) searchForGitToken(gub kgiov1.GitUserBinding, fqdn string, remoteConf *kgiov1.GitServerConfiguration) (*kgiov1.GitServerConfiguration, *gitUser, error) { userGitName := "" userGitEmail := "" userGitToken := "" @@ -263,8 +263,8 @@ func (wrc *WebhookRequestChecker) searchForGitToken(gub kgiov1.GitUserBinding, f userGitEmail = gitRemote.Spec.Email - remoteConf.CaBundle = gitRemote.Status.GitProviderConfiguration.CaBundle - remoteConf.InsecureSkipTlsVerify = gitRemote.Status.GitProviderConfiguration.InsecureSkipTlsVerify + remoteConf.CaBundle = gitRemote.Status.GitServerConfiguration.CaBundle + remoteConf.InsecureSkipTlsVerify = gitRemote.Status.GitServerConfiguration.InsecureSkipTlsVerify } }