Skip to content

Commit b85f636

Browse files
authored
Merge pull request #181 from alvarolop/feature/upgrade-gitlab-18
⚡️ Move from DC deployment for GitLab 12 to certified operator for GitLab 18 ⚡️
2 parents 058a9af + 13f140a commit b85f636

16 files changed

Lines changed: 152 additions & 632 deletions

File tree

codereadyworkspaces/stack/VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
VERSION=3.0.19
1+
VERSION=3.0.20

codereadyworkspaces/stack/root/usr/local/bin/user-functions.sh

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,42 @@
22

33
export GITLAB_PAT=
44

5-
# Generate a new Gilab Personal Access Token
5+
# Generate a new GitLab Personal Access Token
66
gitlab_pat() {
7+
# checks
8+
[ -z "$GIT_SERVER" ] && echo "Warning: must supply GIT_SERVER in env" && return
9+
[ -z "$GITLAB_USER" ] && echo "Warning: must supply GITLAB_USER in env" && return
10+
[ -z "$GITLAB_PASSWORD" ] && echo "Warning: must supply GITLAB_PASSWORD in env" && return
11+
gitlabEncodedPassword=$(echo ${GITLAB_PASSWORD} | perl -MURI::Escape -ne 'chomp;print uri_escape($_)')
12+
# get csrf from login page
13+
gitlab_basic_auth_string="Basic $(echo -n ${GITLAB_USER}:${gitlabEncodedPassword} | base64)"
14+
body_header=$(curl -k -L -s -H "Authorization: ${gitlab_basic_auth_string}" -c /tmp/cookies.txt -i "https://${GIT_SERVER}/users/sign_in")
15+
csrf_token=$(echo $body_header | perl -ne 'print "$1\n" if /name="authenticity_token"[[:blank:]]value="(.+?)"/' | sed -n 1p)
16+
# login
17+
curl -k -s -H "Authorization: ${gitlab_basic_auth_string}" -b /tmp/cookies.txt -c /tmp/cookies.txt -i "https://${GIT_SERVER}/users/auth/ldapmain/callback" \
18+
--data "username=${GITLAB_USER}&password=${gitlabEncodedPassword}" \
19+
--data-urlencode "authenticity_token=${csrf_token}" \
20+
> /dev/null
21+
# generate personal access token form
22+
body_header=$(curl -k -L -H "Authorization: ${gitlab_basic_auth_string}" -H 'user-agent: curl' -b /tmp/cookies.txt -i "https://${GIT_SERVER}/-/user_settings/personal_access_tokens" -s)
23+
csrf_token=$(echo "$body_header" | perl -ne 'print "$1\n" if /csrf-token"[[:blank:]]content="(.+?)"/' | sed -n 1p)
24+
# create personal access token
25+
body_header=$(curl -k -s -L -H "Authorization: ${gitlab_basic_auth_string}" -b /tmp/cookies.txt "https://${GIT_SERVER}/-/user_settings/personal_access_tokens" \
26+
--data-urlencode "authenticity_token=${csrf_token}" \
27+
--data 'personal_access_token[name]='"${GITLAB_USER}"'&personal_access_token[expires_at]=&personal_access_token[scopes][]=api' \
28+
-w "\nHTTP_STATUS:%{http_code}")
29+
http_status=$(echo "$body_header" | grep "HTTP_STATUS" | cut -d: -f2)
30+
body_header=$(echo "$body_header" | sed '/HTTP_STATUS/d')
31+
# Extract token from JSON response (GitLab 18 returns JSON) - tokens can contain dots
32+
GITLAB_PAT=$(echo "$body_header" | perl -ne 'if (/"token"[[:blank:]]*:[[:blank:]]*"([^"]+)"/) { print "$1\n"; exit; }' | sed -n 1p)
33+
export GITLAB_PAT
34+
echo $GITLAB_PAT
35+
}
36+
37+
38+
# Generate a new GitLab Personal Access Token (old version)
39+
# This script is left here for retro-compatibility with older versions of GitLab.
40+
gitlab_pat_old() {
741
# checks
842
[ -z "$GIT_SERVER" ] && echo "Warning: must supply GIT_SERVER in env" && return
943
[ -z "$GITLAB_USER" ] && echo "Warning: must supply GITLAB_USER in env" && return
@@ -34,4 +68,4 @@ gitlab_pat() {
3468
--data 'personal_access_token[name]='"${GITLAB_USER}"'&personal_access_token[expires_at]=&personal_access_token[scopes][]=api')
3569
GITLAB_PAT=$(echo $body_header | perl -ne 'print "$1\n" if /created-personal-access-token"[[:blank:]]value="(.+?)"/' | sed -n 1p)
3670
echo $GITLAB_PAT
37-
}
71+
}

codereadyworkspaces/tl500-devfile-v2.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ components:
9696
name: ide-8084
9797
protocol: http
9898
targetPort: 8084
99-
image: 'quay.io/rht-labs/stack-tl500:3.0.19'
99+
image: 'quay.io/rht-labs/stack-tl500:3.0.20'
100100
memoryLimit: 2Gi
101101
mountSources: true
102102
sourceMapping: /projects

tooling/charts/tl500-base/templates/gitlab/anyuid-scc.yaml

Lines changed: 0 additions & 14 deletions
This file was deleted.

0 commit comments

Comments
 (0)