diff options
author | Shinya Maeda <shinya@gitlab.com> | 2018-10-03 10:33:33 +0900 |
---|---|---|
committer | Shinya Maeda <shinya@gitlab.com> | 2018-10-03 10:33:33 +0900 |
commit | 41fe9edcf75a96db2f29c172828e6adf0ca5b0c9 (patch) | |
tree | 905817422a31aafb8b4cc7981abaddf613f466e0 /lib | |
parent | e5e307dd75f74c5e98b039332c58170dc9c2735f (diff) | |
parent | 42822a7d45f063804fe04f44e15cf04549460ae7 (diff) | |
download | gitlab-ce-41fe9edcf75a96db2f29c172828e6adf0ca5b0c9.tar.gz |
Merge branch 'master-ce' into scheduled-manual-jobs
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gitlab.rb | 4 | ||||
-rw-r--r-- | lib/gitlab/ci/config/entry/reports.rb | 3 | ||||
-rw-r--r-- | lib/gitlab/kubernetes/helm/api.rb | 18 | ||||
-rw-r--r-- | lib/gitlab/kubernetes/helm/upgrade_command.rb | 71 |
4 files changed, 95 insertions, 1 deletions
diff --git a/lib/gitlab.rb b/lib/gitlab.rb index ab6b609d099..7790534d5d7 100644 --- a/lib/gitlab.rb +++ b/lib/gitlab.rb @@ -47,4 +47,8 @@ module Gitlab def self.dev_env_or_com? Rails.env.development? || org? || com? end + + def self.pre_release? + VERSION.include?('pre') + end end diff --git a/lib/gitlab/ci/config/entry/reports.rb b/lib/gitlab/ci/config/entry/reports.rb index 7bc482a6f48..98f12c226b3 100644 --- a/lib/gitlab/ci/config/entry/reports.rb +++ b/lib/gitlab/ci/config/entry/reports.rb @@ -11,7 +11,7 @@ module Gitlab include Validatable include Attributable - ALLOWED_KEYS = %i[junit sast dependency_scanning container_scanning dast].freeze + ALLOWED_KEYS = %i[junit codequality sast dependency_scanning container_scanning dast].freeze attributes ALLOWED_KEYS @@ -21,6 +21,7 @@ module Gitlab with_options allow_nil: true do validates :junit, array_of_strings_or_string: true + validates :codequality, array_of_strings_or_string: true validates :sast, array_of_strings_or_string: true validates :dependency_scanning, array_of_strings_or_string: true validates :container_scanning, array_of_strings_or_string: true diff --git a/lib/gitlab/kubernetes/helm/api.rb b/lib/gitlab/kubernetes/helm/api.rb index 2dd74c68075..e21bc531444 100644 --- a/lib/gitlab/kubernetes/helm/api.rb +++ b/lib/gitlab/kubernetes/helm/api.rb @@ -17,6 +17,12 @@ module Gitlab kubeclient.create_pod(command.pod_resource) end + def update(command) + namespace.ensure_exists! + update_config_map(command) + kubeclient.create_pod(command.pod_resource) + end + ## # Returns Pod phase # @@ -36,6 +42,12 @@ module Gitlab kubeclient.delete_pod(pod_name, namespace.name) end + def get_config_map(config_map_name) + namespace.ensure_exists! + + kubeclient.get_config_map(config_map_name, namespace.name) + end + private attr_reader :kubeclient, :namespace @@ -46,6 +58,12 @@ module Gitlab end end + def update_config_map(command) + command.config_map_resource.tap do |config_map_resource| + kubeclient.update_config_map(config_map_resource) + end + end + def create_service_account(command) command.service_account_resource.tap do |service_account_resource| break unless service_account_resource diff --git a/lib/gitlab/kubernetes/helm/upgrade_command.rb b/lib/gitlab/kubernetes/helm/upgrade_command.rb new file mode 100644 index 00000000000..74188046739 --- /dev/null +++ b/lib/gitlab/kubernetes/helm/upgrade_command.rb @@ -0,0 +1,71 @@ +# frozen_string_literal: true + +module Gitlab + module Kubernetes + module Helm + class UpgradeCommand + include BaseCommand + + attr_reader :name, :chart, :version, :repository, :files + + def initialize(name, chart:, files:, rbac:, version: nil, repository: nil) + @name = name + @chart = chart + @rbac = rbac + @version = version + @files = files + @repository = repository + end + + def generate_script + super + [ + init_command, + repository_command, + script_command + ].compact.join("\n") + end + + def rbac? + @rbac + end + + def pod_name + "upgrade-#{name}" + end + + private + + def init_command + 'helm init --client-only >/dev/null' + end + + def repository_command + "helm repo add #{name} #{repository}" if repository + end + + def script_command + upgrade_flags = "#{optional_version_flag}#{optional_tls_flags}" \ + " --reset-values" \ + " --install" \ + " --namespace #{::Gitlab::Kubernetes::Helm::NAMESPACE}" \ + " -f /data/helm/#{name}/config/values.yaml" + + "helm upgrade #{name} #{chart}#{upgrade_flags} >/dev/null\n" + end + + def optional_version_flag + " --version #{version}" if version + end + + def optional_tls_flags + return unless files.key?(:'ca.pem') + + " --tls" \ + " --tls-ca-cert #{files_dir}/ca.pem" \ + " --tls-cert #{files_dir}/cert.pem" \ + " --tls-key #{files_dir}/key.pem" + end + end + end + end +end |