Commit 15c793db authored by Zeger-Jan van de Weg's avatar Zeger-Jan van de Weg

Writing of the gitlab.yml uses Ruby now

Prior to this change, `ed` was used and the syntax and language are very
complete, but hard to understand what's going on. This limits the
ability to contribute. Also more involved logic is now hard to get
rigth and understand/maintain later.

This change does have the side effect that setting the correct value in
GitLabs `config/gitlab.yml.example` does not propegate by default to
everyones machine.
parent 79a74549
......@@ -34,7 +34,6 @@ https = $(shell (${auto_devops_enabled} && echo 'true') || cat https_enabled 2>/
relative_url_root = $(shell cat relative_url_root 2>/dev/null || echo '')
username = $(shell whoami)
sshd_bin = $(shell which sshd)
git_bin = $(shell which git)
webpack_port = $(shell cat webpack_port 2>/dev/null || echo '3808')
registry_enabled = $(shell cat registry_enabled 2>/dev/null || echo 'false')
registry_host = $(if $(filter true,$(auto_devops_enabled)),"$(auto_devops_registry_port).qa-tunnel.gitlab.info",$(shell cat registry_host 2>/dev/null || echo '127.0.0.1'))
......@@ -93,10 +92,6 @@ auto_devops_registry_port: auto_devops_gitlab_port
expr ${auto_devops_gitlab_port} + 5000 > $@
gitlab/config/gitlab.yml: gitlab/config/gitlab.yml.example auto_devops_enabled auto_devops_gitlab_port auto_devops_registry_port
bin/safe-sed "$@" \
-e "s|/home/git|${gitlab_development_root}|g"\
-e "s|/usr/bin/git|${git_bin}|"\
"$<"
hostname=${hostname} port=${port} relative_url_root=${relative_url_root}\
https=${https}\
webpack_port=${webpack_port}\
......@@ -104,7 +99,7 @@ gitlab/config/gitlab.yml: gitlab/config/gitlab.yml.example auto_devops_enabled a
registry_enabled=${registry_enabled} registry_port=${registry_port}\
object_store_enabled=${object_store_enabled} object_store_port=${object_store_port}\
gitlab_pages_port=${gitlab_pages_port}\
support/edit-gitlab.yml gitlab/config/gitlab.yml
support/edit-gitlab-yml gitlab/config/gitlab.yml
gitlab/config/database.yml: database.yml.example
bin/safe-sed "$@" \
......
#!/usr/bin/env ruby
require 'erb'
require 'etc'
def main(file_path, template)
File.open(file_path, 'w') { |f| f.puts template.result(binding) }
end
def env_or_default(key, default)
ENV[key] || default
end
raw_template = File.read(File.join(__dir__, 'templates', 'gitlab.yml.erb'))
TEMPLATE = ERB.new(raw_template)
GDK_ROOT = Dir.pwd
GIT_BIN = `which git`
file_name = ARGV.first
abort "no file name as argument found" unless file_name
main(ARGV.first, TEMPLATE)
#!/bin/sh
# This script will edit the file named as the first argument in-place.
ed -s "$1" <<EOF
/host:/c
host: ${hostname:-localhost}
.
/port:/c
port: ${port:-3000}
.
/https:/c
https: ${https:-false}
.
/relative_url_root:/c
relative_url_root: "${relative_url_root}"
.
/ user:/c
user: $(whoami)
.
/^ gitlab_shell:/
a
ssh_port: 2222
ssh_host: localhost
.
/ webpack:/
a
dev_server:
enabled: true
host: localhost
port: ${webpack_port:-3808}
.
1
/^ gitaly:/
/^ enabled:/
c
enabled: true
.
1
/^ gitaly_address:/
c
gitaly_address: unix:$(pwd)/gitaly.socket
.
1
/^ gitaly:/
/^ client_path:/
c
client_path: $(pwd)/gitaly/bin
.
/^ registry:/
a
enabled: ${registry_enabled:-false}
host: ${registry_host:-127.0.0.1}
port: ${registry_external_port:-5000}
api_url: http://127.0.0.1:${registry_port:-5000}/
key: ../localhost.key
path: ../registry/storage/
issuer: gitlab-issuer
.
1
/^ artifacts:/
/^ enabled:/
c
enabled: true
.
a
object_store:
enabled: ${object_store_enabled:=false}
remote_directory: artifacts
connection:
provider: AWS
aws_access_key_id: minio
aws_secret_access_key: gdk-minio
region: gdk
endpoint: 'http://127.0.0.1:${object_store_port:-9000}'
path_style: true
.
1
/^ lfs:/
/^ enabled:/
c
enabled: true
.
/^ object_store:/
/^ enabled:/
c
enabled: ${object_store_enabled:=false}
direct_upload: true
.
/^ remote_directory:/
c
remote_directory: lfs-objects
.
/^ connection:/
/^ aws_access_key_id:/
c
aws_access_key_id: minio
.
/^ aws_secret_access_key:/
c
aws_secret_access_key: gdk-minio
.
/^ region:/
c
region: gdk
endpoint: 'http://127.0.0.1:${object_store_port:-9000}'
path_style: true
.
1
/^ uploads:/
/^ object_store:/
/^ enabled:/
c
enabled: ${object_store_enabled:=false}
.
/^ remote_directory:/
c
remote_directory: uploads
.
/^ connection:/
/^ aws_access_key_id:/
c
aws_access_key_id: minio
.
/^ aws_secret_access_key:/
c
aws_secret_access_key: gdk-minio
.
/^ region:/
c
region: gdk
endpoint: 'http://127.0.0.1:${object_store_port:-9000}'
path_style: true
.
1
/^ packages:/
/^ enabled:/
c
enabled: true
.
/^ object_store:/
/^ enabled:/
c
enabled: ${object_store_enabled:=false}
direct_upload: true
.
/^ remote_directory:/
c
remote_directory: packages
.
/^ connection:/
/^ aws_access_key_id:/
c
aws_access_key_id: minio
.
/^ aws_secret_access_key:/
c
aws_secret_access_key: gdk-minio
.
/^ region:/
c
region: gdk
endpoint: 'http://127.0.0.1:${object_store_port:-9000}'
path_style: true
.
1
/^ pages:/
/^ enabled:/
c
enabled: true
.
/^ host:/
c
host: 127.0.0.1.xip.io
.
/^ port:/
c
port: ${gitlab_pages_port:-3010}
.
1
/^test:/
/^ gitlab:/
/ user:/c
user: $(whoami)
.
wq
EOF
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment