Commit 7ff25a26 authored by Toon Claes's avatar Toon Claes

Small tweaks in gdk.example.yml generation

Add a method to find the executable that returns `nil` when not found
so a default can be set.
parent 809da1d0
......@@ -3,6 +3,8 @@
$LOAD_PATH.unshift('.')
require 'lib/gdk'
require 'rake/clean'
CLOBBER.include 'gdk.example.yml', 'Procfile', 'nginx/conf/nginx.conf'
def config
@config ||= GDK::Config.new
......@@ -14,7 +16,7 @@ task 'dump_config' do
end
desc 'Generate an example config file with all the defaults'
file 'gdk.example.yml' do |t|
file 'gdk.example.yml' => 'clobber:gdk.example.yml' do |t|
File.open(t.name, File::CREAT|File::TRUNC|File::WRONLY) do |file|
config = Class.new(GDK::Config)
config.define_method(:gdk_root) { '/home/git/gdk' }
......@@ -25,6 +27,10 @@ file 'gdk.example.yml' do |t|
end
end
task 'clobber:gdk.example.yml' do |t|
Rake::Cleaner.cleanup_files([t.name])
end
desc 'Generate Procfile for Foreman'
file 'Procfile' => ['Procfile.erb', GDK::Config::FILE] do |t|
GDK::ErbRenderer.new(t.source, t.name).safe_render!
......
---
gdk_root: "/home/git/gdk"
username: git
repositories:
gitlab: https://gitlab.com/gitlab-org/gitlab-ce.git
gitlab_shell: https://gitlab.com/gitlab-org/gitlab-shell.git
gitlab_workhorse: https://gitlab.com/gitlab-org/gitlab-workhorse.git
gitaly: https://gitlab.com/gitlab-org/gitaly.git
gitaly_proto: https://gitlab.com/gitlab-org/gitaly-proto.git
gitlab_pages: https://gitlab.com/gitlab-org/gitlab-pages.git
gitlab_docs: https://gitlab.com/gitlab-com/gitlab-docs.git
gitaly:
assembly_dir: "/home/git/gdk/gitaly/assembly"
gitlab_pages:
port: 3034
enabled: true
port: 3000
registry:
port: 5000
enabled: false
host: 127.0.0.1
external_port: 5000
https: false
relative_url_root:
webpack:
port: 3806
object_store:
port: 9000
enabled: false
geo:
enabled: false
auto_devops:
enabled: false
gitlab:
port: 20000
enabled: false
registry:
port: 25000
tracer:
build_tags: tracer_static tracer_static_jaeger
jaeger:
version: 1.10.1
enabled: true
elasticsearch:
version: 6.5.1
checksum: 5903e1913a7c96aad96a8227517c40490825f672
version: 6.5.1
gdk_root: "/home/git/gdk"
geo:
enabled: false
git:
bin: "/usr/bin/git"
gitaly:
assembly_dir: "/home/git/gdk/gitaly/assembly"
gitlab_pages:
enabled: true
port: 3034
hostname: localhost
https:
enabled: true
nginx:
bin: "/usr/sbin/nginx"
enabled: false
http:
enabled: false
port: 80
ssl:
certificate: localhost.crt
workhorse_port: 3333
object_store:
enabled: false
bin: '/usr/sbin/nginx'
port: 9000
port: 3000
postgresql:
bin_dir: "/usr/lib/postgresql/9.6/bin"
dir: "/home/git/gdk/postgresql"
replication_user: gitlab_replication
data_dir: "/home/git/gdk/postgresql/data"
replica_dir: "/home/git/gdk/postgresql-replica"
dir: "/home/git/gdk/postgresql"
geo_dir: "/home/git/gdk/postgresql-geo"
hostname: localhost
replica_dir: "/home/git/gdk/postgresql-replica"
replication_user: gitlab_replication
protocol: https
registry:
enabled: false
external_port: 5000
host: 127.0.0.1
port: 5000
relative_url_root:
repositories:
gitaly: https://gitlab.com/gitlab-org/gitaly.git
gitaly_proto: https://gitlab.com/gitlab-org/gitaly-proto.git
gitlab: https://gitlab.com/gitlab-org/gitlab-ce.git
gitlab_docs: https://gitlab.com/gitlab-com/gitlab-docs.git
gitlab_pages: https://gitlab.com/gitlab-org/gitlab-pages.git
gitlab_shell: https://gitlab.com/gitlab-org/gitlab-shell.git
gitlab_workhorse: https://gitlab.com/gitlab-org/gitlab-workhorse.git
sshd:
bin: '/usr/sbin/sshd'
bin: "/usr/sbin/sshd"
tracer:
build_tags: tracer_static tracer_static_jaeger
jaeger:
enabled: true
version: 1.10.1
username: git
webpack:
port: 3806
......@@ -16,7 +16,7 @@ module GDK
r.gitlab_docs 'https://gitlab.com/gitlab-com/gitlab-docs.git'
end
gdk_root { cmd!('pwd') }
gdk_root { ENV['PWD'] }
hostname do
next "#{config.auto_devops.gitlab.port}.qa-tunnel.gitlab.info" if config.auto_devops.enabled
......@@ -38,7 +38,7 @@ module GDK
protocol { config.https? ? 'https' : 'http' }
relative_url_root { read!('relative_url_root') || nil }
username { cmd!('whoami') }
username { ENV['USERNAME'] }
webpack do |w|
w.port { read!('webpack_port') || 3808 }
......@@ -131,11 +131,11 @@ module GDK
end
sshd do |s|
s.bin { cmd!('which sshd') }
s.bin { find_executable!('sshd') || '/usr/sbin/sshd' }
end
git do |g|
g.bin { cmd!('which git') }
g.bin { find_executable!('git') }
end
end
end
......@@ -37,7 +37,7 @@ module GDK
def dump!(file = nil)
base_methods = ConfigSettings.new.methods
yaml = (methods - base_methods).inject({}) do |hash, method|
yaml = (methods - base_methods).sort.inject({}) do |hash, method|
value = public_send(method)
if value.is_a?(ConfigSettings)
hash[method.to_s] = value.dump!
......@@ -56,6 +56,11 @@ module GDK
`#{cmd}`.chomp
end
def find_executable!(bin)
result = cmd!("which #{bin}")
result.empty? ? nil : result
end
def read!(filename)
sanitized_read!(filename)
rescue Errno::ENOENT
......
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