diff options
author | Toon Claes <toon@gitlab.com> | 2019-05-09 21:09:24 +0300 |
---|---|---|
committer | Toon Claes <toon@gitlab.com> | 2019-07-01 14:40:21 +0300 |
commit | 8464bb690b02e63dfd2bcf49a7eb345ad5a31bf7 (patch) | |
tree | a48541110dc3d90da92757ba8bf73fbdf742927f | |
parent | 9a502f63bc9427e75d2e5316f9a66ba2c9c86534 (diff) |
More Auto DevOps tweaks
This might be less DRY, but it's a lot easier to read.
-rw-r--r-- | Procfile.erb | 4 | ||||
-rw-r--r-- | gdk-defaults.yml.erb | 20 | ||||
-rw-r--r-- | lib/gdk/config_file.rb | 15 |
3 files changed, 26 insertions, 13 deletions
diff --git a/Procfile.erb b/Procfile.erb index 672b37372a1..a1beea0c9dc 100644 --- a/Procfile.erb +++ b/Procfile.erb @@ -15,7 +15,7 @@ postgresql: exec support/postgresql-signal-wrapper <%= config.postgresql.bin_dir # Geo # <%= '#' unless config.geo.enabled %>postgresql-geo: exec support/postgresql-signal-wrapper <%= config.postgresql.bin_dir %>/postgres -D <%= config.postgresql.geo_dir %>/data -k <%= config.postgresql.geo_dir %> -h '' -<%= '#' unless config.geo.enabled %>geo-cursor: exec /usr/bin/env RAILS_ENV=development RAILS_RELATIVE_URL_ROOT=$relative_url_root support/exec-cd gitlab/bin ./geo_log_cursor +<%= '#' unless config.geo.enabled %>geo-cursor: exec /usr/bin/env RAILS_ENV=development RAILS_RELATIVE_URL_ROOT=$relative_url_root support/geo-logcursor # Backend services # @@ -27,7 +27,7 @@ rails-background-jobs: exec /usr/bin/env SIDEKIQ_LOG_ARGUMENTS=1 RAILS_ENV=devel # webpack: exec /usr/bin/env NODE_ENV=development DEV_SERVER_PORT=<%= config.webpack.port %> DEV_SERVER_HOST=$host support/exec-cd gitlab yarn dev-server rails-web: exec /usr/bin/env RAILS_ENV=development RAILS_RELATIVE_URL_ROOT=$relative_url_root support/exec-cd gitlab bin/web start_foreground -<%= '#' unless config.gitlab_pages.enabled %>gitlab-pages: exec gitlab-pages/bin/gitlab-pages -listen-http ":<%= config.gitlab_pages.port %>" -artifacts-server http://localhost:443/api/v4 -pages-root <%= config.gdk_root %>/gitlab/shared/pages/ -pages-domain 127.0.0.1.xip.io +<%= '#' unless config.gitlab_pages.enabled %>gitlab-pages: exec gitlab-pages/bin/gitlab-pages -listen-http ":<%= config.gitlab_pages.port %>" -artifacts-server <%= config.https ? 'https' : 'http' %>://<%= config.hostname %>:<%= config.port %>/api/v4 -pages-root <%= config.gdk_root %>/gitlab/shared/pages/ -pages-domain 127.0.0.1.xip.io # Docker # diff --git a/gdk-defaults.yml.erb b/gdk-defaults.yml.erb index dc881bc4b3e..9e4dcb8ea39 100644 --- a/gdk-defaults.yml.erb +++ b/gdk-defaults.yml.erb @@ -1,5 +1,5 @@ # This file contains the defaults for GDK -# It is a YAML file, but it will be parsed by ERB first +# It is a YAML file, but it will be processed as ERB first repositories: gitlab: https://gitlab.com/gitlab-org/gitlab-ce.git @@ -11,9 +11,16 @@ repositories: gitlab_docs: https://gitlab.com/gitlab-com/gitlab-docs.git gdk_root: <%= cmd!('pwd') %> +#<% if config.auto_devops.enabled %> +hostname: <%= "#{config.auto_devops.gitlab.port}.qa-tunnel.gitlab.info" %> +port: 443 +https: true +#<% else %> hostname: <%= read!('hostname') || 'localhost' %> port: <%= read!('port') || 3000 %> https: <%= read!('https_enabled') || false %> +#<% end %> + relative_url_root: <%= read!('relative_url_root') || nil %> username: <%= cmd!('whoami') %> @@ -21,10 +28,17 @@ webpack: port: <%= read!('webpack_port') || 3808 %> registry: - enabled: <%= config.auto_devops.enabled || read!('registry_enabled') || false %> +#<% if config.auto_devops.enabled %> + enabled: true + host: <%= "#{config.auto_devops.registry.port}.qa-tunnel.gitlab.info" %> + port: <%= config.auto_devops.registry.port %> + external_port: 443 +#<% else %> + enabled: <%= read!('registry_enabled') || false %> host: 127.0.0.1 port: <%= read!('registry_port') || 5000 %> external_port: 5000 +#<% end %> object_store: enabled: <%= read!('object_store_enabled') || false %> @@ -39,7 +53,7 @@ auto_devops: gitlab: port: <%= read_or_write!('auto_devops_gitlab_port', rand(20000..24999)) %> registry: - port: <%= config.auto_devops.gitlab.port.to_i + 5000 %> + port: <%= read!('auto_devops_registry_port') || (config.auto_devops.gitlab.port.to_i + 5000) %> geo: enabled: false diff --git a/lib/gdk/config_file.rb b/lib/gdk/config_file.rb index 161884cdce8..d29cb28cbd8 100644 --- a/lib/gdk/config_file.rb +++ b/lib/gdk/config_file.rb @@ -12,10 +12,9 @@ module GDK load! File.read(file) # Run in a loop for variables that refer other variables - loop do - load! ERB.new(data.to_yaml).result(config_binding) - - break unless data.to_yaml =~ /<%=.*%>/ + # See https://stackoverflow.com/a/7235513/89376 + while /<%=.*%>/.match(data) + load! ERB.new(data).result(config_binding) end end @@ -31,13 +30,13 @@ module GDK end def read!(filename) - File.read(filename) + File.read(filename).chomp rescue Errno::ENOENT nil end def read_or_write!(filename, value) - File.read(filename) + File.read(filename).chomp rescue Errno::ENOENT File.write(filename, value) value @@ -48,8 +47,8 @@ module GDK attr_reader :data def load!(data) - @data = YAML.safe_load(data) - @config = hashes2ostruct(@data) + @data = data + @config = hashes2ostruct(YAML.safe_load(@data)) end # From: https://www.dribin.org/dave/blog/archives/2006/11/17/hashes_to_ostruct/ |