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

Unable to create a top level group in self-hosted GitLab #108

Closed
BillKlineVT opened this issue Oct 16, 2023 · 6 comments
Closed

Unable to create a top level group in self-hosted GitLab #108

BillKlineVT opened this issue Oct 16, 2023 · 6 comments
Labels
bug Something isn't working

Comments

@BillKlineVT
Copy link

What happened?

Using the Group Managed Resource, I am unable to create a group at the top level of GitLab (self-hosted 16.4.1) group hierarchy (i.e. with no Parent ID or Parent ID Reference). I looked at the API spec and it does not appear that parentID is a required field.

Group YAML:

apiVersion: groups.gitlab.crossplane.io/v1alpha1
kind: Group
metadata:
  name: root-test
spec:
  forProvider:
    name: "Root Test"
    path: "root-test"
    description: "root group."
    sharedWithGroups:
  providerConfigRef:
    name: gitlab-provider
  # a reference to a Kubernetes secret to which the controller will write the runnersToken
  writeConnectionSecretToRef:
    name: gitlab-group-root
    namespace: crossplane-system

Error shown when kubectl describe the resource: cannot resolve references: mg.Spec.ForProvider.ParentID: strconv.Atoi: parsing "": invalid syntax

I also tried to include parentID with 0 as the value. Using 0 returns a "404 Group not found" type error.

Notes:

  • I was able to successfully create a subgroup of an existing group (by providing the parentID integer), so I have confirmed the connection to my GitLab instance is valid.
  • I did see a similar bug ticket that was written/closed: unable to create a top-level group at gitlab.com #22, but that was related to the gitlab.com SaaS only.

How can we reproduce it?

cat << EOF > gitlabGroup.yaml
apiVersion: groups.gitlab.crossplane.io/v1alpha1
kind: Group
metadata:
  name: root-test
spec:
  forProvider:
    name: "Root Test"
    path: "root-test"
    description: "root group."
    sharedWithGroups:
  providerConfigRef:
    name: gitlab-provider
  # a reference to a Kubernetes secret to which the controller will write the runnersToken
  writeConnectionSecretToRef:
    name: gitlab-group-root
    namespace: crossplane-system
EOF

kubectl apply -f gitlabGroup.yaml

What environment did it happen in?

Crossplane version: v1.13.2
Crossplane Provider GitLab version: v0.5.0
Cloud provider or hardware configuration: minikube on a local VM
Kubernetes version: 1.27.4
Kubernetes distribution: minikube
OS: Ubuntu

@BillKlineVT BillKlineVT added the bug Something isn't working label Oct 16, 2023
@agardnerIT
Copy link

agardnerIT commented Nov 16, 2023

Me too. I'm spinning up a demo system, so all I really want to do is create n admin users.

That may not be possible though (I'm guessing) so then I want a single group users and to add n users to that group:

---
apiVersion: groups.gitlab.crossplane.io/v1alpha1
kind: Group
metadata:
  name: users
spec:
  forProvider:
    name: "All Users"
    path: "users"
    description: "All users are in this group"
  providerConfigRef:
    name: gitlab-provider
  writeConnectionSecretToRef:
    name: gitlab-group-users
    namespace: crossplane
---
apiVersion: groups.gitlab.crossplane.io/v1alpha1
kind: Member
metadata:
  name: user1
spec:
  forProvider:
    groupIdRef:
      name: users
    userID: 100
    userName: user1
    accessLevel: 50
  providerConfigRef:
    name: gitlab-provider
  writeConnectionSecretToRef:
    name: gitlab-group-user1
    namespace: crossplane

The equivalent curl of what I'm trying to accomplish would be:

curl -X POST \
-d '{"name": "user1", "password": "***", "username": "user1", "email": "[email protected]" }' \
-H "Content-Type: application/json" \
-H "PRIVATE-TOKEN: ****" \
"https://gitlab.example.com/api/v4/users"

@BillKlineVT
Copy link
Author

It seems like the error is coming from this block of code, which implies that ParentID is not being set to nil by default when not including it in the Group spec.

@BillKlineVT
Copy link
Author

Excuse the stream of consciousness, but it looks like I missed that parentIDRef.name is marked as a required field per the api spec. What would that need to be set to for a top level group?

@olzemal
Copy link

olzemal commented Mar 5, 2024

Looks like this was fixed by #118

@BillKlineVT
Copy link
Author

Looks like this was fixed by #118

Thanks for the heads up @olzemal ! I just confirmed that this now works - can create a top level group in self-hosted GitLab using the provider-gitlab v0.6.1

@MisterMX
Copy link
Collaborator

Closing, since the issue is fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants