Project API `mirror` works initially despite of not having a Premium license
Recently, someone raised an issue in the Terraform GitLab Provider that when they use the gitlab_project
resource (using the GitLab Projects REST API) the behavior for mirror
is weird in that it's only properly applied after the second apply
.
Now, to make this a little bit easier I've come up with the following minimal snippet directly using the REST API (no provider involved) to reproduce this issue:
project=$(curl -X POST "https://gitlab.com/api/v4/projects" --header "PRIVATE-TOKEN: $GITLAB_TOKEN" --header "Content-Type: application/json" --data '
{
"name": "issue-1119",
"visibility": "public",
"import_url": "https://github.com/timofurrer/test.git",
"mirror": true,
"mirror_trigger_builds": true
}
' )
project_id=$(echo "$project" | jq -r '.id')
curl -X GET "https://gitlab.com/api/v4/projects/$project_id" --header "PRIVATE-TOKEN: $GITLAB_TOKEN" | jq
(curl
and jq
are required and the GITLAB_TOKEN
env variable with api
scope)
(btw. the mirror
field according to the docs is a GitLab Premium feature)
Given a Premium License (Ultimate in my case on a local GitLab instance) everything works as expected, as-in the GET
call on the last line returns "mirror": true
- but apparently (I can't reproduce, but someone else confirms) when having a Premium license on gitlab.com, only after a while the GET
API returns the mirror .. is this a background operation?.
Given no Premium License (e.g. using my user on gitlab.com) and running the above shell snippet the behavior is weird, because the project can properly be created using "mirror": true
and the repository content is actually being mirrored), but the GET
call will return no "mirror"
field in the response at all.
Also in the UI the Mirroring repositories
table is empty:
I would have expected either of these scenarios when having no Premium license:
- the
POST
call doesn't work, becausemirror
is given, but a Premium feature - the
POST
call works, and theGET
call responds themirror
field properly and also shows the mirror in theMirroring repositories
table in the settings UI)
Can someone share some insights how this is supposed to work? Is the docs wrong and it's not actually a Premium feature? Is the API / UI wrong? Something else I'm missing?
/cc @nagyv-gitlab @nmezzopera could you help me triaging this?