diff --git a/bin/gitlab-backup-cli b/bin/gitlab-backup-cli index 6ddfd5d49d02514223cfd491336ba7a4c06fc7ac..37524e2766f5fb1a6b5f91332ffbb350eaa51462 100755 --- a/bin/gitlab-backup-cli +++ b/bin/gitlab-backup-cli @@ -3,12 +3,12 @@ $:.unshift File.expand_path("../../lib", __FILE__) -# We require APP_PATH when the rails environment is required only, -# this allows for faster CLI execution when rails is not needed +# GITLAB_PATH points to the Rails.root, which the tool can use to load +# the Rails environment when necessary or to help find configuration files +# when used with GDK GITLAB_PATH = File.expand_path('../', __dir__) require_relative '../config/boot' - require 'gitlab/backup/cli' Gitlab::Backup::Cli::Runner.start(ARGV) diff --git a/config/initializers/1_settings.rb b/config/initializers/1_settings.rb index c38415601ec6c2a3a021bb9652d51357d7c299ff..ceffdb59a7498e8721e07285d6eb87437dd3997a 100644 --- a/config/initializers/1_settings.rb +++ b/config/initializers/1_settings.rb @@ -6,6 +6,7 @@ # Default settings Settings['shared'] ||= {} +# If you are changing default storage paths, then you must change them in the gitlab-backup-cli gem as well Settings.shared['path'] = Settings.absolute(Settings.shared['path'] || "shared") Settings['encrypted_settings'] ||= {} @@ -265,6 +266,7 @@ # Settings['gitlab_ci'] ||= {} Settings.gitlab_ci['shared_runners_enabled'] = true if Settings.gitlab_ci['shared_runners_enabled'].nil? +# If you are changing default storage paths, then you must change them in the gitlab-backup-cli gem as well Settings.gitlab_ci['builds_path'] = Settings.absolute(Settings.gitlab_ci['builds_path'] || "builds/") Settings.gitlab_ci['url'] ||= Settings.__send__(:build_gitlab_ci_url) Settings.gitlab_ci['server_fqdn'] ||= Settings.__send__(:build_ci_server_fqdn) @@ -274,6 +276,7 @@ # Settings['ci_secure_files'] ||= {} Settings.ci_secure_files['enabled'] = true if Settings.ci_secure_files['enabled'].nil? +# If you are changing default storage paths, then you must change them in the gitlab-backup-cli gem as well Settings.ci_secure_files['storage_path'] = Settings.absolute(Settings.ci_secure_files['storage_path'] || File.join(Settings.shared['path'], "ci_secure_files")) Settings.ci_secure_files['object_store'] = ObjectStoreSettings.legacy_parse(Settings.ci_secure_files['object_store'], 'secure_files') @@ -297,6 +300,7 @@ # Settings['artifacts'] ||= {} Settings.artifacts['enabled'] = true if Settings.artifacts['enabled'].nil? +# If you are changing default storage paths, then you must change them in the gitlab-backup-cli gem as well Settings.artifacts['storage_path'] = Settings.absolute(Settings.artifacts.values_at('path', 'storage_path').compact.first || File.join(Settings.shared['path'], "artifacts")) # Settings.artifact['path'] is deprecated, use `storage_path` instead Settings.artifacts['path'] = Settings.artifacts['storage_path'] @@ -314,6 +318,7 @@ Settings.registry['key'] ||= nil Settings.registry['issuer'] ||= nil Settings.registry['host_port'] ||= [Settings.registry['host'], Settings.registry['port']].compact.join(':') +# If you are changing default storage paths, then you must change them in the gitlab-backup-cli gem as well Settings.registry['path'] = Settings.absolute(Settings.registry['path'] || File.join(Settings.shared['path'], 'registry')) Settings.registry['notifications'] ||= [] @@ -333,6 +338,7 @@ Settings['pages'] = ::Gitlab::Pages::Settings.new(Settings.pages) # For path access detection https://gitlab.com/gitlab-org/gitlab/-/issues/230702 Settings.pages['enabled'] = false if Settings.pages['enabled'].nil? Settings.pages['access_control'] = false if Settings.pages['access_control'].nil? +# If you are changing default storage paths, then you must change them in the gitlab-backup-cli gem as well Settings.pages['path'] = Settings.absolute(Settings.pages['path'] || File.join(Settings.shared['path'], "pages")) Settings.pages['https'] = false if Settings.pages['https'].nil? Settings.pages['host'] ||= "example.com" @@ -348,6 +354,7 @@ Settings.pages['storage_path'] = Settings.pages['path'] Settings.pages['object_store'] = ObjectStoreSettings.legacy_parse(Settings.pages['object_store'], 'pages') Settings.pages['local_store'] ||= {} +# If you are changing default storage paths, then you must change them in the gitlab-backup-cli gem as well Settings.pages['local_store']['path'] = Settings.absolute(Settings.pages['local_store']['path'] || File.join(Settings.shared['path'], "pages")) Settings.pages['local_store']['enabled'] = true if Settings.pages['local_store']['enabled'].nil? Settings.pages['namespace_in_path'] = false if Settings.pages['namespace_in_path'].nil? @@ -387,6 +394,7 @@ Settings['external_diffs'] ||= {} Settings.external_diffs['enabled'] = false if Settings.external_diffs['enabled'].nil? Settings.external_diffs['when'] = 'always' if Settings.external_diffs['when'].nil? +# If you are changing default storage paths, then you must change them in the gitlab-backup-cli gem as well Settings.external_diffs['storage_path'] = Settings.absolute(Settings.external_diffs['storage_path'] || File.join(Settings.shared['path'], 'external-diffs')) Settings.external_diffs['object_store'] = ObjectStoreSettings.legacy_parse(Settings.external_diffs['object_store'], 'external_diffs') @@ -395,6 +403,7 @@ # Settings['lfs'] ||= {} Settings.lfs['enabled'] = true if Settings.lfs['enabled'].nil? +# If you are changing default storage paths, then you must change them in the gitlab-backup-cli gem as well Settings.lfs['storage_path'] = Settings.absolute(Settings.lfs['storage_path'] || File.join(Settings.shared['path'], "lfs-objects")) Settings.lfs['object_store'] = ObjectStoreSettings.legacy_parse(Settings.lfs['object_store'], 'lfs') @@ -413,6 +422,7 @@ Settings['packages'] ||= {} Settings.packages['enabled'] = true if Settings.packages['enabled'].nil? Settings.packages['dpkg_deb_path'] = '/usr/bin/dpkg-deb' if Settings.packages['dpkg_deb_path'].nil? +# If you are changing default storage paths, then you must change them in the gitlab-backup-cli gem as well Settings.packages['storage_path'] = Settings.absolute(Settings.packages['storage_path'] || File.join(Settings.shared['path'], "packages")) Settings.packages['object_store'] = ObjectStoreSettings.legacy_parse(Settings.packages['object_store'], 'packages') @@ -421,6 +431,7 @@ # Settings['dependency_proxy'] ||= {} Settings.dependency_proxy['enabled'] = true if Settings.dependency_proxy['enabled'].nil? +# If you are changing default storage paths, then you must change them in the gitlab-backup-cli gem as well Settings.dependency_proxy['storage_path'] = Settings.absolute(Settings.dependency_proxy['storage_path'] || File.join(Settings.shared['path'], "dependency_proxy")) Settings.dependency_proxy['object_store'] = ObjectStoreSettings.legacy_parse(Settings.dependency_proxy['object_store'], 'dependency_proxy') @@ -435,6 +446,7 @@ # Settings['terraform_state'] ||= {} Settings.terraform_state['enabled'] = true if Settings.terraform_state['enabled'].nil? +# If you are changing default storage paths, then you must change them in the gitlab-backup-cli gem as well Settings.terraform_state['storage_path'] = Settings.absolute(Settings.terraform_state['storage_path'] || File.join(Settings.shared['path'], "terraform_state")) Settings.terraform_state['object_store'] = ObjectStoreSettings.legacy_parse(Settings.terraform_state['object_store'], 'terraform_state') diff --git a/gems/gitlab-backup-cli/bin/console b/gems/gitlab-backup-cli/bin/console index 0cd1d6c57f511bdc5ac22fa8b0371054b9fcdb76..e2eaca601675756ede765c466a5e36e58a102397 100755 --- a/gems/gitlab-backup-cli/bin/console +++ b/gems/gitlab-backup-cli/bin/console @@ -1,13 +1,13 @@ #!/usr/bin/env ruby # frozen_string_literal: true +# GITLAB_PATH points to the Rails.root, which the tool can use to load +# the Rails environment when necessary or to help find configuration files +# when used with GDK +GITLAB_PATH = File.expand_path(File.join(__dir__, '../../../')) + require "bundler/setup" require "gitlab/backup/cli" -# You can add fixtures and/or initialization code here to make experimenting -# with your gem easier. You can also use a different console, if you like. - -GITLAB_PATH = File.expand_path(File.join(__dir__, '../../../')) - require "irb" IRB.start(__FILE__)