Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorToon Claes <toon@gitlab.com>2019-07-01 14:28:46 +0300
committerToon Claes <toon@gitlab.com>2019-07-03 12:30:45 +0300
commitab3d30c768cdccabf8007ab40eaa0dd6de940314 (patch)
tree340d33505a17ef5fd20ca52b0b15e8e626afb540
parent507bbeb743e7884a9210d148f6d976ad6be96a78 (diff)
Dump settings from Rakefile
Add 2 new targets: - gdk.example.yml: Dumps the default configuration to file - dump_config: Dumps the current configuration to stdout
-rw-r--r--Rakefile19
-rw-r--r--gdk.example.yml61
-rw-r--r--lib/gdk/config_settings.rb53
3 files changed, 118 insertions, 15 deletions
diff --git a/Rakefile b/Rakefile
index 988e9165ed1..a4dea22ef3d 100644
--- a/Rakefile
+++ b/Rakefile
@@ -8,10 +8,29 @@ def config
@config ||= GDK::Config.new
end
+desc 'Dump the configured settings'
+task 'dump_config' do
+ GDK::Config.new.dump!(STDOUT)
+end
+
+desc 'Generate an example config file with all the defaults'
+file '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' }
+ config.define_method(:username) { 'git' }
+ config.define_method(:read!) { |_| nil }
+
+ config.new(yaml: {}).dump!(file)
+ end
+end
+
+desc 'Generate Procfile for Foreman'
file 'Procfile' => ['Procfile.erb', GDK::Config::FILE] do |t|
GDK::ErbRenderer.new(t.source, t.name).safe_render!
end
+desc 'Generate nginx configuration'
file 'nginx/conf/nginx.conf' => ['nginx/conf/nginx.conf.erb', GDK::Config::FILE] do |t|
GDK::ErbRenderer.new(t.source, t.name).safe_render!
end
diff --git a/gdk.example.yml b/gdk.example.yml
new file mode 100644
index 00000000000..0d93f817c14
--- /dev/null
+++ b/gdk.example.yml
@@ -0,0 +1,61 @@
+---
+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:
+ 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
+git:
+ bin: "/usr/bin/git"
+nginx:
+ workhorse_port: 3333
+ enabled: false
+ bin: '/usr/sbin/nginx'
+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"
+ geo_dir: "/home/git/gdk/postgresql-geo"
+hostname: localhost
+sshd:
+ bin: '/usr/sbin/sshd'
diff --git a/lib/gdk/config_settings.rb b/lib/gdk/config_settings.rb
index 055886c026a..37a6ffd0b2c 100644
--- a/lib/gdk/config_settings.rb
+++ b/lib/gdk/config_settings.rb
@@ -6,7 +6,7 @@ module GDK
class ConfigSettings
SettingUndefined = Class.new(StandardError)
- attr_accessor :parent, :yaml
+ attr_reader :parent, :yaml, :key
def self.method_missing(name, *args, &blk)
if !args.empty?
@@ -21,24 +21,35 @@ module GDK
sub = Class.new(ConfigSettings)
blk.call(sub)
- sub.new(parent: self, yaml: yaml.fetch(name.to_s, {}))
+ sub.new(parent: self, yaml: yaml.fetch(name.to_s, {}), key: [key, name].compact.join('.'))
end
else
raise SettingUndefined, "Could not find the setting '#{name}'"
end
end
- # Provide a shorter form for `config.setting.enabled` as `config.setting?`
- def method_missing(method_name, *args, &blk)
- enabled = enabled_value(method_name)
+ def initialize(parent: nil, yaml: nil, key: nil)
+ @parent = parent
+ @key = key
+ @yaml = yaml || load_yaml!
+ end
- return super if enabled.nil?
+ def dump!(file = nil)
+ base_methods = ConfigSettings.new.methods
- enabled
- end
+ yaml = (methods - base_methods).inject({}) do |hash, method|
+ value = public_send(method)
+ if value.is_a?(ConfigSettings)
+ hash[method.to_s] = value.dump!
+ else
+ hash[method.to_s] = value
+ end
+ hash
+ end
- def respond_to_missing?(method_name, include_private = false)
- !enabled_value(method_name).nil? || super
+ file.puts(yaml.to_yaml) if file
+
+ yaml
end
def cmd!(cmd)
@@ -58,16 +69,28 @@ module GDK
value
end
- def initialize(parent: nil, yaml: nil)
- @parent = parent
- @yaml = yaml || load_yaml!
- end
-
def root
parent&.root || self
end
alias_method :config, :root
+ def inspect
+ "#<GDK::ConfigSettings key:#{key}>"
+ end
+
+ # Provide a shorter form for `config.setting.enabled` as `config.setting?`
+ def method_missing(method_name, *args, &blk)
+ enabled = enabled_value(method_name)
+
+ return super if enabled.nil?
+
+ enabled
+ end
+
+ def respond_to_missing?(method_name, include_private = false)
+ !enabled_value(method_name).nil? || super
+ end
+
private
def enabled_value(method_name)