diff --git a/.gitignore b/.gitignore index 087275e..f432141 100644 --- a/.gitignore +++ b/.gitignore @@ -104,6 +104,9 @@ venv.bak/ # mkdocs documentation /site +#mirrord config +.mirrord + # mypy .mypy_cache/ *.iml diff --git a/gitlab.values.yaml b/gitlab.values.yaml index 931efdc..502b522 100644 --- a/gitlab.values.yaml +++ b/gitlab.values.yaml @@ -14,6 +14,10 @@ gitlab: ingress: requireBasePath: false global: + gitlab: + license: + key: license_key + secret: gitlab-license hosts: domain: localhost https: false diff --git a/pkg/git_provider/gitlab.go b/pkg/git_provider/gitlab.go index 18d9c55..d79fd1c 100644 --- a/pkg/git_provider/gitlab.go +++ b/pkg/git_provider/gitlab.go @@ -177,8 +177,8 @@ func (c *GitlabClientImpl) SetWebhook(ctx *context.Context, repo *string) (*Hook if !ok { addProjectHookOpts := gitlab.AddProjectHookOptions{ - URL: gitlab.Ptr(c.cfg.GitProviderConfig.WebhookURL), - Token: gitlab.Ptr(c.cfg.GitProviderConfig.WebhookSecret), + URL: &c.cfg.GitProviderConfig.WebhookURL, + Token: &c.cfg.GitProviderConfig.WebhookSecret, MergeRequestsEvents: gitlab.Ptr(true), PushEvents: gitlab.Ptr(true), ReleasesEvents: gitlab.Ptr(true), @@ -186,6 +186,7 @@ func (c *GitlabClientImpl) SetWebhook(ctx *context.Context, repo *string) (*Hook } gitlabHook, resp, err := c.client.Projects.AddProjectHook(projectId, &addProjectHookOpts, gitlab.WithContext(*ctx)) if err != nil { + log.Println("url", *addProjectHookOpts.URL, projectId, *addProjectHookOpts.Token) return nil, fmt.Errorf("failed to add project hook ,%d", err) } if resp.StatusCode != 201 { @@ -273,8 +274,6 @@ func (c *GitlabClientImpl) HandlePayload(ctx *context.Context, request *http.Req UserEmail: e.UserEmail, OwnerID: int64(e.UserID), } - log.Println(e.Project.Name) - case *gitlab.MergeEvent: webhookPayload = WebhookPayload{ Event: "merge_request", @@ -345,29 +344,30 @@ func (c *GitlabClientImpl) SetStatus(ctx *context.Context, repo *string, commit } func (c *GitlabClientImpl) PingHook(ctx *context.Context, hook *HookWithStatus) error { - if c.cfg.OrgLevelWebhook && hook.RepoName != nil { - return fmt.Errorf("trying to ping repo scope webhook while configured for org level webhook. repo: %s", *hook.RepoName) - } - if hook.RepoName == nil { - _, resp, err := c.client.Groups.GetGroupHook(c.cfg.OrgName, int(hook.HookID), nil, gitlab.WithContext(*ctx)) - if err != nil { - return err - } - - if resp.StatusCode == http.StatusNotFound { - return fmt.Errorf("unable to find organization webhook for hookID: %d", hook.HookID) - } - } else { - projectId := GetProjectId(ctx, c, hook.RepoName) - _, resp, err := c.client.Projects.GetProjectHook(projectId, int(hook.HookID), nil, gitlab.WithContext(*ctx)) - if err != nil { - return err - } - - if resp.StatusCode == http.StatusNotFound { - return fmt.Errorf("unable to find repo webhook for repo:%s hookID: %d", *hook.RepoName, hook.HookID) - } - } - - return nil + panic("implement me") + // + //if c.cfg.OrgLevelWebhook && hook.RepoName != nil { + // return fmt.Errorf("trying to ping repo scope webhook while configured for org level webhook. repo: %s", *hook.RepoName) + //} + //if hook.RepoName == nil { + // _, resp, err := c.client.Groups.GetGroupHook(c.cfg.OrgName, int(hook.HookID), nil, gitlab.WithContext(*ctx)) + // if err != nil { + // return err + // } + // if resp.StatusCode == http.StatusNotFound { + // return fmt.Errorf("unable to find organization webhook for hookID: %d", hook.HookID) + // } + //} else { + // projectId := GetProjectId(ctx, c, hook.RepoName) + // _, resp, err := c.client.Projects.GetProjectHook(projectId, int(hook.HookID), nil, gitlab.WithContext(*ctx)) + // if err != nil { + // return err + // } + // + // if resp.StatusCode == http.StatusNotFound { + // return fmt.Errorf("unable to find repo webhook for repo:%s hookID: %d", *hook.RepoName, hook.HookID) + // } + //} + // + //return nil } diff --git a/scripts/gitlab-setup.rb b/scripts/gitlab-setup.rb index 73c9911..95cae39 100644 --- a/scripts/gitlab-setup.rb +++ b/scripts/gitlab-setup.rb @@ -15,6 +15,10 @@ puts "TOKEN: #{token.token}" + +#enable the Admin->Network->Outbound requests -> allow for webhooks +ApplicationSetting.current.update!(allow_local_requests_from_web_hooks_and_services: true) + # #create new group # Group.create!(name: "Pied Pipers", path: "pied-pipers") # g = Group.find_by(name: "Pied Pipers") diff --git a/scripts/init-gitlab.sh b/scripts/init-gitlab.sh index 8662bf5..fa48340 100644 --- a/scripts/init-gitlab.sh +++ b/scripts/init-gitlab.sh @@ -2,6 +2,8 @@ set -o errexit if [ -z "$(helm list -n gitlab | grep gitlab)" ]; then + #start gitlab namespace + kubectl create namespace gitlab # 8. Install gitlab helm repo add gitlab https://charts.gitlab.io/ helm upgrade --install gitlab --create-namespace -n gitlab gitlab/gitlab -f gitlab.values.yaml