Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add gitlab provider #22

Closed
wants to merge 61 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
56346e1
fix: gitlab get scopes added
omri2001 Jun 12, 2024
0e4b733
fix: finished newgitlabClient
omri2001 Jun 12, 2024
a01a407
fix: ListFiles complete
omri2001 Jun 12, 2024
c53f18b
fix: get File and getFiles
omri2001 Jun 12, 2024
058756e
fix: SetStatus + PinkHook
omri2001 Jun 12, 2024
05bec39
fix: set and del webhook done
omri2001 Jun 14, 2024
a3e6600
fix: small change setWebhook
omri2001 Jun 14, 2024
5dcb125
fix: done handlePaylod
omri2001 Jun 18, 2024
fbd0096
fix: pr review changes and fixed scopes
omri2001 Jun 19, 2024
97207c8
fix: first test done
omri2001 Jun 27, 2024
04c9619
fix: some pr changes resolving
omri2001 Jun 27, 2024
748a633
docs: added provider and url to chart
omri2001 Jun 29, 2024
e7908e2
fix: done utils tests
omri2001 Jun 29, 2024
446bb17
fix: started gitlab tests
omri2001 Jun 29, 2024
eeaa407
fix: added some more tests and fixing bugs
omri2001 Aug 2, 2024
48ad3d7
fix: finished tests now runnning qa
omri2001 Aug 4, 2024
b177656
fix: added some docs
omri2001 Aug 4, 2024
650a79f
fix: added some validations and docs
omri2001 Aug 4, 2024
3ec833a
fix: argo ingress
omri2001 Oct 26, 2024
fbd8249
fix: gitlab init ruby script
omri2001 Nov 10, 2024
453d7dc
ci: add gitlab local support
GoshaDo Nov 10, 2024
6a0fa69
ci: add gitlab local support
GoshaDo Nov 10, 2024
9388bd3
ci: fix e2e service account permissions
GoshaDo Nov 10, 2024
052d92a
fix: gitlab setup script
omri2001 Nov 10, 2024
bb2a407
ci: change rules to working branch
omri2001 Nov 10, 2024
7f2134c
ci: start work on actions
omri2001 Nov 10, 2024
5cdc590
fix: cleaning up
omri2001 Nov 11, 2024
16ad014
fix: context and git provider factory
GoshaDo Nov 10, 2024
7f8b51c
fix: add context
GoshaDo Nov 10, 2024
e04c95b
fix: changes to make it work
omri2001 Nov 11, 2024
e65d39e
ci: add local gitlab at localhost:8080 (#24)
GoshaDo Nov 10, 2024
8fe8df4
fix: changes to make it work
omri2001 Nov 13, 2024
baa6f24
fix: pipe works, small fixes left
omri2001 Nov 16, 2024
3adf727
fix: pipe works, small fixes left
omri2001 Nov 16, 2024
443b950
test: fixed unit tests
omri2001 Nov 21, 2024
faaf16c
test: running e2e
omri2001 Nov 21, 2024
aff7f4a
test: running e2e
omri2001 Nov 21, 2024
03182b4
test: gitlab e2e check
omri2001 Nov 22, 2024
acd6564
fix: gitlab unsetting webhook
omri2001 Nov 22, 2024
02eb9f2
fix: pr changes
omri2001 Nov 23, 2024
0bdabd0
fix: gitlab ruby init script finished
omri2001 Nov 28, 2024
4eb5bac
fix: gitlab init change
omri2001 Nov 30, 2024
76a8b2b
docs: updated docs for gitlab
omri2001 Nov 30, 2024
0ed2975
fix: gitlab script cleanup
omri2001 Dec 1, 2024
987efb9
fix: some space
omri2001 Dec 2, 2024
a01ee2c
ci: changed running branch for testing
omri2001 Dec 2, 2024
13074d2
ci: changed order of jobs in e2e
omri2001 Dec 2, 2024
9afa0ef
ci: e2e to run on branch
omri2001 Dec 2, 2024
29fb625
test: gitlab e2e test
omri2001 Dec 4, 2024
2d7b38f
test: gitlab e2e test
omri2001 Dec 4, 2024
d266bf0
test: gitlab e2e test
omri2001 Dec 4, 2024
b29bdef
test: gitlab e2e test
omri2001 Dec 4, 2024
efa172e
test: gitlab e2e test
omri2001 Dec 4, 2024
62ac8f5
test: fix gitlab test
omri2001 Dec 5, 2024
8eeca89
fix: gitlab rails script
omri2001 Dec 6, 2024
f3d6896
ci: e2e test revert to main
omri2001 Dec 6, 2024
641fff4
ci: e2e check on main
omri2001 Dec 6, 2024
447c263
ci: parallel e2e jobs
omri2001 Dec 24, 2024
4e31509
fix: gitlab e2e
omri2001 Dec 24, 2024
a629573
fix: e2e tests
omri2001 Dec 24, 2024
6507792
docs: align with main
GoshaDo Dec 24, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix: started gitlab tests
  • Loading branch information
omri2001 committed Dec 2, 2024
commit 446bb17d00577ac6f49f47bb8270264278885c2e
3 changes: 2 additions & 1 deletion pkg/git_provider/gitlab.go
Original file line number Diff line number Diff line change
@@ -58,7 +58,8 @@ func (c *GitlabClientImpl) ListFiles(ctx *context.Context, repo string, branch s
Ref: &branch,
Path: &path,}

dirFiles, resp, err := c.client.Repositories.ListTree(repo, opt)
projectName := fmt.Sprintf("%s/%s", c.cfg.GitProviderConfig.OrgName ,repo)
dirFiles, resp, err := c.client.Repositories.ListTree(projectName, opt)


if err != nil {
72 changes: 72 additions & 0 deletions pkg/git_provider/gitlab_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
package git_provider

import (
"fmt"
"net/http"
"testing"

"github.com/quickube/piper/pkg/conf"
assertion "github.com/stretchr/testify/assert"
"github.com/xanzy/go-gitlab"
"golang.org/x/net/context"
)

func TestGitlabListFiles(t *testing.T) {
// Prepare
mux, client := setupGitlab(t)

repoContent := &gitlab.TreeNode{
Type: "file",
Name: "exit.yaml",
Path: ".workflows/exit.yaml",
}

repoContent2 := &gitlab.TreeNode{
Type: "file",
Name: "main.yaml",
Path: ".workflows/main.yaml",
}

treeNodes := []gitlab.TreeNode{*repoContent, *repoContent2}
expectedRef := "branch1"
project := "project1"

c := GitlabClientImpl{
client: client,
cfg: &conf.GlobalConfig{
GitProviderConfig: conf.GitProviderConfig{
OrgLevelWebhook: true,
OrgName: "group1",
RepoList: project,
},
},
}
projectUrl := fmt.Sprintf("/api/v4/projects/%s/%s/repository/tree",c.cfg.GitProviderConfig.OrgName, project)
mux.HandleFunc(projectUrl, func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "GET")
ref := r.URL.Query().Get("ref")

// Check if the ref value matches the expected value
if ref != expectedRef {
http.Error(w, "Invalid ref value", http.StatusBadRequest)
return
}
mockHTTPResponse(t, w, treeNodes)
})


ctx := context.Background()

// Execute
actualContent, err := c.ListFiles(&ctx, project, expectedRef, ".workflows")

var expectedFilesNames []string
for _, file := range treeNodes{
expectedFilesNames = append(expectedFilesNames, file.Name)
}

// Assert
assert := assertion.New(t)
assert.NotNil(t, err)
assert.Equal(expectedFilesNames, actualContent)
}