Skip to content
Snippets Groups Projects

Add registry-database import command to gitlab-ctl

Merged João Pereira requested to merge registry-import-command into master
2 files
+ 104
0
Compare changes
  • Side-by-side
  • Inline
Files
2
require 'optparse'
module Import
CMD_NAME = 'import'.freeze
SUMMARY_WIDTH = 40
DESC_INDENT = 45
def self.indent(str, len)
str.gsub(/%%/, ' ' * len)
end
USAGE ||= <<~EOS.freeze
Manage migrations
Usage:
gitlab-ctl registry-database import [options]
Options:
-B, --common-blobs import all blob metadata from common storage
-c, --row-count count and log number of rows across relevant database tables on (pre)import completion
-d, --dry-run do not commit changes to the database
-e, --require-empty-database abort import if the database is not empty
-p, --pre-import import immutable repository-scoped data to speed up a following import
-r, --all-repositories import all repository-scoped data
-h, --help help for import
-1, --step-one pre-import perform step one of a multi-step import: alias for pre-import
-2, --step-two all-repositories perform step two of a multi-step import: alias for all-repositories
-3, --step-three common-blobs perform step three of a multi-step import: alias for common-blobs
EOS
def self.parse_options!(args, options, option_parser)
return unless args.include? CMD_NAME
loop do
break if args.shift == CMD_NAME
end
OptionParser.new do |opts|
opts.on('-h', '--help', 'Usage help') do
option_parser.set_summary_width(SUMMARY_WIDTH)
Kernel.puts USAGE
Kernel.exit 0
end
end.order! args
option_parser.on('-B', '--common-blobs', 'import all blob metadata from common storage') do
options[:common_blobs] = '--common-blobs'
end
option_parser.on('-c' , '--row-count', 'count and log number of rows across relevant database tables on (pre)import completion') do
options[:row_count] = '--row-count'
end
option_parser.on('-d', '--dry-run', 'do not commit changes to the database') do
options[:dry_run] = '--dry-run'
end
option_parser.on('-e', '--require-empty-database', 'abort import if the database is not empty') do
options[:empty] = '--require-empty-database'
end
option_parser.on('-p', '--pre-import', 'import immutable repository-scoped data to speed up a following import') do
options[:pre_import] = '--pre-import'
end
option_parser.on('-r', '--all-repositories', 'import all repository-scoped data') do
options[:all_repositories] = '--all-repositories'
end
option_parser.on('-1' , '--step-one', 'perform step one of a multi-step import: alias for pre-import') do
options[:step_one] = '--step-one'
end
option_parser.on('-2' , '--step-two', 'perform step two of a multi-step import: alias for all-repositories') do
options[:step_two] = '--step-two'
end
option_parser.on('-3' , '--step-three', 'perform step three of a multi-step import: alias for common-blobs') do
options[:step_three] = '--step-three'
end
needs_stop!(options)
options
end
def self.needs_stop!(options)
options[:needs_stop] = true unless options.has_key? :dry_run
end
end
Loading