Navigation Menu

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

Adds Gitlab provider #36

Closed
wants to merge 23 commits into from

Conversation

dinosk
Copy link
Contributor

@dinosk dinosk commented Aug 21, 2020

Adds a Gitlab provider based on the one for github.
The mapping between Github and Gitlab entities:

Repo - Project
Org - Group
Team - Group

@dinosk dinosk force-pushed the gitlab-provider-gitlabclient branch from e81b3f1 to 18e1123 Compare August 21, 2020 12:37
@stefanprodan
Copy link
Member

@dinosk we need to change the client options and allow setting a different hostname for SSH, please see fluxcd/flux2#171

@dinosk dinosk force-pushed the gitlab-provider-gitlabclient branch from 18e1123 to a4f925e Compare August 25, 2020 21:01
@dinosk dinosk force-pushed the gitlab-provider-gitlabclient branch from b537af9 to a590802 Compare August 25, 2020 21:08
@dinosk
Copy link
Contributor Author

dinosk commented Aug 25, 2020

we need to change the client options and allow setting a different hostname for SSH, please see fluxcd/toolkit#171

added an sshDomain field in https://github.com/fluxcd/go-git-providers/pull/36/files#diff-427f0edd6e28f8dd9251b1e762ca2b85R62 , will check if there is sth missing for this on the next iteration

@dinosk dinosk marked this pull request as ready for review September 21, 2020 09:59
@dinosk dinosk changed the title Adds gitlabClient interface Adds Gitlab provider Sep 21, 2020
gitlab/auth.go Show resolved Hide resolved
gitlab/auth.go Outdated Show resolved Hide resolved
gitlab/resource_deploykey.go Outdated Show resolved Hide resolved
testRepoName string = "testrepo"
testOrgName string = "GGPGroup"
testSubgroupName string = "ggpsub"
testTeamName string = "GGPGroup2"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should make a note here about which of these are expected to already exist vs. will be created

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added comment.


const (
// DefaultDomain specifies the default domain used as the backend.
DefaultDomain = "gitlab.com"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this seems to need the https:// prefix to work w/ other domains.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But as we're not really passing scheme around maybe the NewClient should append it

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a comment.

@foot
Copy link
Collaborator

foot commented Sep 22, 2020

Works! sans the caching request, our gitlab instance doesn't support that.

$ ginkgo gitlab
Running Suite: GitLab Provider Suite
====================================
Random Seed: 1600782102
Will run 10 of 10 specs

• Failure [3.214 seconds]
GitLab Provider
/Users/simon/src/go-git-providers/gitlab/integration_test.go:125
  should list the available organizations the user has access to [It]
  /Users/simon/src/go-git-providers/gitlab/integration_test.go:200

  Expected
      <int>: 0
  to equal
      <int>: 1

  /Users/simon/src/go-git-providers/gitlab/integration_test.go:246
------------------------------
•••
------------------------------
• [SLOW TEST:5.222 seconds]
GitLab Provider
/Users/simon/src/go-git-providers/gitlab/integration_test.go:125
  should update if the org repo already exists when reconciling
  /Users/simon/src/go-git-providers/gitlab/integration_test.go:301
------------------------------
• [SLOW TEST:16.630 seconds]
GitLab Provider
/Users/simon/src/go-git-providers/gitlab/integration_test.go:125
  should update teams with access and permissions when reconciling
  /Users/simon/src/go-git-providers/gitlab/integration_test.go:344
------------------------------
• [SLOW TEST:6.614 seconds]
GitLab Provider
/Users/simon/src/go-git-providers/gitlab/integration_test.go:125
  should create, delete and reconcile deploy keys
  /Users/simon/src/go-git-providers/gitlab/integration_test.go:439
------------------------------
• [SLOW TEST:10.660 seconds]
GitLab Provider
/Users/simon/src/go-git-providers/gitlab/integration_test.go:125
  should be possible to create a user project
  /Users/simon/src/go-git-providers/gitlab/integration_test.go:501
------------------------------
•
------------------------------
• [SLOW TEST:14.436 seconds]
GitLab Provider
/Users/simon/src/go-git-providers/gitlab/integration_test.go:125
  should update if the user repo already exists when reconciling
  /Users/simon/src/go-git-providers/gitlab/integration_test.go:545
------------------------------
Deleting the user repo:  test-repo-194
Deleting the org repo:  test-org-repo-217
Deleting the shared org repo:  test-shared-org-repo-812


Summarizing 1 Failure:

[Fail] GitLab Provider [It] should list the available organizations the user has access to
/Users/simon/src/go-git-providers/gitlab/integration_test.go:246

Ran 10 of 10 Specs in 67.313 seconds
FAIL! -- 9 Passed | 1 Failed | 0 Pending | 0 Skipped
--- FAIL: TestProvider (67.31s)
2020/09/22 15:42:53 GET https://gitlab.com/api/v4/groups/9146106: 401 {message: 401 Unauthorized}

Ginkgo ran 1 suite in 1m10.758218143s
Test Suite Failed

Copy link
Collaborator

@foot foot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM :)

@dinosk
Copy link
Contributor Author

dinosk commented Sep 24, 2020

Closing this, opened #51 to run the integration tests

@dinosk dinosk closed this Sep 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants