summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/api/internal/base.rb2
-rw-r--r--lib/api/releases.rb2
-rw-r--r--lib/backup/repository.rb34
-rw-r--r--lib/gitlab/ci/templates/Deploy-ECS.gitlab-ci.yml36
-rw-r--r--lib/gitlab/shell.rb100
-rw-r--r--lib/system_check/gitlab_shell_check.rb2
-rw-r--r--lib/tasks/gitlab/info.rake9
7 files changed, 83 insertions, 102 deletions
diff --git a/lib/api/internal/base.rb b/lib/api/internal/base.rb
index cca037b0705..9c37b610cca 100644
--- a/lib/api/internal/base.rb
+++ b/lib/api/internal/base.rb
@@ -40,7 +40,7 @@ module API
# Stores some Git-specific env thread-safely
env = parse_env
- Gitlab::Git::HookEnv.set(gl_repository, env) if project
+ Gitlab::Git::HookEnv.set(gl_repository, env) if container
actor.update_last_used_at!
access_checker = access_checker_for(actor, params[:protocol])
diff --git a/lib/api/releases.rb b/lib/api/releases.rb
index 6e7a99bf0bb..1be263ac80d 100644
--- a/lib/api/releases.rb
+++ b/lib/api/releases.rb
@@ -46,7 +46,7 @@ module API
params do
requires :tag_name, type: String, desc: 'The name of the tag', as: :tag
optional :name, type: String, desc: 'The name of the release'
- requires :description, type: String, desc: 'The release notes'
+ optional :description, type: String, desc: 'The release notes'
optional :ref, type: String, desc: 'The commit sha or branch name'
optional :assets, type: Hash do
optional :links, type: Array do
diff --git a/lib/backup/repository.rb b/lib/backup/repository.rb
index 123a695be13..1c5108b12ab 100644
--- a/lib/backup/repository.rb
+++ b/lib/backup/repository.rb
@@ -4,7 +4,6 @@ require 'yaml'
module Backup
class Repository
- include Gitlab::ShellAdapter
attr_reader :progress
def initialize(progress)
@@ -71,23 +70,14 @@ module Backup
def restore
Project.find_each(batch_size: 1000) do |project|
progress.print " * #{project.full_path} ... "
- path_to_project_bundle = path_to_bundle(project)
- project.repository.remove rescue nil
- restore_repo_success = nil
-
- if File.exist?(path_to_project_bundle)
+ restore_repo_success =
begin
- project.repository.create_from_bundle(path_to_project_bundle)
- restore_custom_hooks(project)
- restore_repo_success = true
- rescue => e
- restore_repo_success = false
- progress.puts "Error: #{e}".color(:red)
+ try_restore_repository(project)
+ rescue => err
+ progress.puts "Error: #{err}".color(:red)
+ false
end
- else
- restore_repo_success = gitlab_shell.create_project_repository(project)
- end
if restore_repo_success
progress.puts "[DONE]".color(:green)
@@ -118,6 +108,20 @@ module Backup
protected
+ def try_restore_repository(project)
+ path_to_project_bundle = path_to_bundle(project)
+ project.repository.remove rescue nil
+
+ if File.exist?(path_to_project_bundle)
+ project.repository.create_from_bundle(path_to_project_bundle)
+ restore_custom_hooks(project)
+ else
+ project.repository.create_repository
+ end
+
+ true
+ end
+
def path_to_bundle(project)
File.join(backup_repos_path, project.disk_path + '.bundle')
end
diff --git a/lib/gitlab/ci/templates/Deploy-ECS.gitlab-ci.yml b/lib/gitlab/ci/templates/Deploy-ECS.gitlab-ci.yml
new file mode 100644
index 00000000000..ecca1731579
--- /dev/null
+++ b/lib/gitlab/ci/templates/Deploy-ECS.gitlab-ci.yml
@@ -0,0 +1,36 @@
+stages:
+ - build
+ - test
+ - review
+ - deploy
+ - production
+
+include:
+ - template: Jobs/Build.gitlab-ci.yml
+
+.deploy_to_ecs:
+ image: registry.gitlab.com/gitlab-org/cloud-deploy:latest
+ script:
+ - ecs update-task-definition
+
+review:
+ extends: .deploy_to_ecs
+ stage: review
+ environment:
+ name: review/$CI_COMMIT_REF_NAME
+ only:
+ refs:
+ - branches
+ - tags
+ except:
+ refs:
+ - master
+
+production:
+ extends: .deploy_to_ecs
+ stage: production
+ environment:
+ name: production
+ only:
+ refs:
+ - master
diff --git a/lib/gitlab/shell.rb b/lib/gitlab/shell.rb
index e7158148b59..6053ad8d08e 100644
--- a/lib/gitlab/shell.rb
+++ b/lib/gitlab/shell.rb
@@ -6,8 +6,6 @@ require 'securerandom'
module Gitlab
class Shell
- GITLAB_SHELL_ENV_VARS = %w(GIT_TERMINAL_PROMPT).freeze
-
Error = Class.new(StandardError)
class << self
@@ -36,8 +34,31 @@ module Gitlab
.join('GITLAB_SHELL_VERSION')).strip
end
+ # Return GitLab shell version
+ #
+ # @return [String] version
+ def version
+ @version ||= File.read(gitlab_shell_version_file).chomp if File.readable?(gitlab_shell_version_file)
+ end
+
+ # Return a SSH url for a given project path
+ #
+ # @param [String] full_path project path (URL)
+ # @return [String] SSH URL
+ def url_to_repo(full_path)
+ Gitlab.config.gitlab_shell.ssh_path_prefix + "#{full_path}.git"
+ end
+
private
+ def gitlab_shell_path
+ File.expand_path(Gitlab.config.gitlab_shell.path)
+ end
+
+ def gitlab_shell_version_file
+ File.join(gitlab_shell_path, 'VERSION')
+ end
+
# Create (if necessary) and link the secret token file
def generate_and_link_secret_token
secret_file = Gitlab.config.gitlab_shell.secret_file
@@ -56,47 +77,6 @@ module Gitlab
end
end
- # Initialize a new project repository using a Project model
- #
- # @param [Project] project
- # @return [Boolean] whether repository could be created
- def create_project_repository(project)
- create_repository(project.repository_storage, project.disk_path, project.full_path)
- end
-
- # Initialize a new wiki repository using a Project model
- #
- # @param [Project] project
- # @return [Boolean] whether repository could be created
- def create_wiki_repository(project)
- create_repository(project.repository_storage, project.wiki.disk_path, project.wiki.full_path)
- end
-
- # Init new repository
- #
- # @example Create a repository
- # create_repository("default", "path/to/gitlab-ci", "gitlab/gitlab-ci")
- #
- # @param [String] storage the shard key
- # @param [String] disk_path project path on disk
- # @param [String] gl_project_path project name
- # @return [Boolean] whether repository could be created
- def create_repository(storage, disk_path, gl_project_path)
- relative_path = disk_path.dup
- relative_path << '.git' unless relative_path.end_with?('.git')
-
- # During creation of a repository, gl_repository may not be known
- # because that depends on a yet-to-be assigned project ID in the
- # database (e.g. project-1234), so for now it is blank.
- repository = Gitlab::Git::Repository.new(storage, relative_path, '', gl_project_path)
- wrapped_gitaly_errors { repository.gitaly_repository_client.create_repository }
-
- true
- rescue => err # Once the Rugged codes gets removes this can be improved
- Rails.logger.error("Failed to add repository #{storage}/#{disk_path}: #{err}") # rubocop:disable Gitlab/RailsLogger
- false
- end
-
# Import wiki repository from external service
#
# @param [Project] project
@@ -238,25 +218,6 @@ module Gitlab
false
end
- # Return a SSH url for a given project path
- #
- # @param [String] full_path project path (URL)
- # @return [String] SSH URL
- def url_to_repo(full_path)
- Gitlab.config.gitlab_shell.ssh_path_prefix + "#{full_path}.git"
- end
-
- # Return GitLab shell version
- #
- # @return [String] version
- def version
- gitlab_shell_version_file = "#{gitlab_shell_path}/VERSION"
-
- if File.readable?(gitlab_shell_version_file)
- File.read(gitlab_shell_version_file).chomp
- end
- end
-
# Check if repository exists on disk
#
# @example Check if repository exists
@@ -271,23 +232,8 @@ module Gitlab
false
end
- # Return hooks folder path used by projects
- #
- # @return [String] path
- def hooks_path
- File.join(gitlab_shell_path, 'hooks')
- end
-
protected
- def gitlab_shell_path
- File.expand_path(Gitlab.config.gitlab_shell.path)
- end
-
- def gitlab_shell_user_home
- File.expand_path("~#{Gitlab.config.gitlab_shell.ssh_user}")
- end
-
def full_path(storage, dir_name)
raise ArgumentError.new("Directory name can't be blank") if dir_name.blank?
diff --git a/lib/system_check/gitlab_shell_check.rb b/lib/system_check/gitlab_shell_check.rb
index 31c4ec33247..f539719ce87 100644
--- a/lib/system_check/gitlab_shell_check.rb
+++ b/lib/system_check/gitlab_shell_check.rb
@@ -50,7 +50,7 @@ module SystemCheck
end
def gitlab_shell_version
- Gitlab::Shell.new.version
+ Gitlab::Shell.version
end
end
end
diff --git a/lib/tasks/gitlab/info.rake b/lib/tasks/gitlab/info.rake
index 5809f632c5a..d85c8fc7949 100644
--- a/lib/tasks/gitlab/info.rake
+++ b/lib/tasks/gitlab/info.rake
@@ -82,15 +82,10 @@ namespace :gitlab do
puts "Using Omniauth:\t#{Gitlab::Auth.omniauth_enabled? ? "yes".color(:green) : "no"}"
puts "Omniauth Providers: #{omniauth_providers.join(', ')}" if Gitlab::Auth.omniauth_enabled?
- # check Gitolite version
- gitlab_shell_version_file = "#{Gitlab.config.gitlab_shell.path}/VERSION"
- if File.readable?(gitlab_shell_version_file)
- gitlab_shell_version = File.read(gitlab_shell_version_file)
- end
-
+ # check Gitlab Shell version
puts ""
puts "GitLab Shell".color(:yellow)
- puts "Version:\t#{gitlab_shell_version || "unknown".color(:red)}"
+ puts "Version:\t#{Gitlab::Shell.version || "unknown".color(:red)}"
puts "Repository storage paths:"
Gitlab::GitalyClient::StorageSettings.allow_disk_access do
Gitlab.config.repositories.storages.each do |name, repository_storage|