Skip to content
Snippets Groups Projects
Commit cc502768 authored by John Jarvis's avatar John Jarvis
Browse files

Merge commit '207d3100' into 11-9-stable-prepare-rc4

parents 3190b498 207d3100
No related branches found
No related tags found
No related merge requests found
Showing
with 100 additions and 232 deletions
Loading
@@ -17,7 +17,7 @@ class Projects::ApplicationController < ApplicationController
Loading
@@ -17,7 +17,7 @@ class Projects::ApplicationController < ApplicationController
   
def project def project
return @project if @project return @project if @project
return nil unless params[:project_id] || params[:id] return unless params[:project_id] || params[:id]
   
path = File.join(params[:namespace_id], params[:project_id] || params[:id]) path = File.join(params[:namespace_id], params[:project_id] || params[:id])
auth_proc = ->(project) { !project.pending_delete? } auth_proc = ->(project) { !project.pending_delete? }
Loading
Loading
Loading
@@ -90,65 +90,21 @@ class Projects::BlobController < Projects::ApplicationController
Loading
@@ -90,65 +90,21 @@ class Projects::BlobController < Projects::ApplicationController
def diff def diff
apply_diff_view_cookie! apply_diff_view_cookie!
   
@blob.load_all_data! @form = Blobs::UnfoldPresenter.new(blob, params.to_unsafe_h)
@lines = @blob.present.highlight.lines
@form = UnfoldForm.new(params.to_unsafe_h)
@lines = @lines[@form.since - 1..@form.to - 1].map(&:html_safe)
if @form.bottom?
@match_line = ''
else
lines_length = @lines.length - 1
line = [@form.since, lines_length].join(',')
@match_line = "@@ -#{line}+#{line} @@"
end
   
# We can keep only 'render_diff_lines' from this conditional when # keep only json rendering when
# https://gitlab.com/gitlab-org/gitlab-ce/issues/44988 is done # https://gitlab.com/gitlab-org/gitlab-ce/issues/44988 is done
if rendered_for_merge_request? if rendered_for_merge_request?
render_diff_lines render json: DiffLineSerializer.new.represent(@form.diff_lines)
else else
@lines = @form.lines
@match_line = @form.match_line_text
render layout: false render layout: false
end end
end end
   
private private
   
# Converts a String array to Gitlab::Diff::Line array
def render_diff_lines
@lines.map! do |line|
# These are marked as context lines but are loaded from blobs.
# We also have context lines loaded from diffs in other places.
diff_line = Gitlab::Diff::Line.new(line, nil, nil, nil, nil)
diff_line.rich_text = line
diff_line
end
add_match_line
render json: DiffLineSerializer.new.represent(@lines)
end
def add_match_line
return unless @form.unfold?
if @form.bottom? && @form.to < @blob.lines.size
old_pos = @form.to - @form.offset
new_pos = @form.to
elsif @form.since != 1
old_pos = new_pos = @form.since
end
# Match line is not needed when it reaches the top limit or bottom limit of the file.
return unless new_pos
@match_line = Gitlab::Diff::Line.new(@match_line, 'match', nil, old_pos, new_pos)
@form.bottom? ? @lines.push(@match_line) : @lines.unshift(@match_line)
end
def blob def blob
@blob ||= @repository.blob_at(@commit.id, @path) @blob ||= @repository.blob_at(@commit.id, @path)
   
Loading
@@ -231,6 +187,8 @@ class Projects::BlobController < Projects::ApplicationController
Loading
@@ -231,6 +187,8 @@ class Projects::BlobController < Projects::ApplicationController
end end
   
def validate_diff_params def validate_diff_params
return if params[:full]
if [:since, :to, :offset].any? { |key| params[key].blank? } if [:since, :to, :offset].any? { |key| params[key].blank? }
head :ok head :ok
end end
Loading
Loading
Loading
@@ -46,8 +46,8 @@ class Projects::MergeRequests::DiffsController < Projects::MergeRequests::Applic
Loading
@@ -46,8 +46,8 @@ class Projects::MergeRequests::DiffsController < Projects::MergeRequests::Applic
   
# rubocop: disable CodeReuse/ActiveRecord # rubocop: disable CodeReuse/ActiveRecord
def commit def commit
return nil unless commit_id = params[:commit_id].presence return unless commit_id = params[:commit_id].presence
return nil unless @merge_request.all_commits.exists?(sha: commit_id) return unless @merge_request.all_commits.exists?(sha: commit_id)
   
@commit ||= @project.commit(commit_id) @commit ||= @project.commit(commit_id)
end end
Loading
Loading
Loading
@@ -18,6 +18,7 @@ class Projects::MergeRequestsController < Projects::MergeRequests::ApplicationCo
Loading
@@ -18,6 +18,7 @@ class Projects::MergeRequestsController < Projects::MergeRequests::ApplicationCo
   
before_action only: [:show] do before_action only: [:show] do
push_frontend_feature_flag(:diff_tree_filtering, default_enabled: true) push_frontend_feature_flag(:diff_tree_filtering, default_enabled: true)
push_frontend_feature_flag(:expand_diff_full_file)
end end
   
def index def index
Loading
Loading
Loading
@@ -28,13 +28,13 @@ class UploadsController < ApplicationController
Loading
@@ -28,13 +28,13 @@ class UploadsController < ApplicationController
end end
   
def find_model def find_model
return nil unless params[:id] return unless params[:id]
   
upload_model_class.find(params[:id]) upload_model_class.find(params[:id])
end end
   
def authorize_access! def authorize_access!
return nil unless model return unless model
   
authorized = authorized =
case model case model
Loading
@@ -54,7 +54,7 @@ class UploadsController < ApplicationController
Loading
@@ -54,7 +54,7 @@ class UploadsController < ApplicationController
end end
   
def authorize_create_access! def authorize_create_access!
return nil unless model return unless model
   
# for now we support only personal snippets comments # for now we support only personal snippets comments
authorized = can?(current_user, :comment_personal_snippet, model) authorized = can?(current_user, :comment_personal_snippet, model)
Loading
Loading
Loading
@@ -69,6 +69,8 @@ class SnippetsFinder < UnionFinder
Loading
@@ -69,6 +69,8 @@ class SnippetsFinder < UnionFinder
base.with_optional_visibility(visibility_from_scope).fresh base.with_optional_visibility(visibility_from_scope).fresh
end end
   
private
# Produces a query that retrieves snippets from multiple projects. # Produces a query that retrieves snippets from multiple projects.
# #
# The resulting query will, depending on the user's permissions, include the # The resulting query will, depending on the user's permissions, include the
Loading
Loading
Loading
@@ -74,7 +74,7 @@ module MarkupHelper
Loading
@@ -74,7 +74,7 @@ module MarkupHelper
# the tag contents are truncated without removing the closing tag. # the tag contents are truncated without removing the closing tag.
def first_line_in_markdown(object, attribute, max_chars = nil, options = {}) def first_line_in_markdown(object, attribute, max_chars = nil, options = {})
md = markdown_field(object, attribute, options) md = markdown_field(object, attribute, options)
return nil unless md.present? return unless md.present?
   
tags = %w(a gl-emoji b pre code p span) tags = %w(a gl-emoji b pre code p span)
tags << 'img' if options[:allow_images] tags << 'img' if options[:allow_images]
Loading
Loading
Loading
@@ -29,7 +29,7 @@ module MergeRequestsHelper
Loading
@@ -29,7 +29,7 @@ module MergeRequestsHelper
   
def ci_build_details_path(merge_request) def ci_build_details_path(merge_request)
build_url = merge_request.source_project.ci_service.build_page(merge_request.diff_head_sha, merge_request.source_branch) build_url = merge_request.source_project.ci_service.build_page(merge_request.diff_head_sha, merge_request.source_branch)
return nil unless build_url return unless build_url
   
parsed_url = URI.parse(build_url) parsed_url = URI.parse(build_url)
   
Loading
@@ -92,7 +92,7 @@ module MergeRequestsHelper
Loading
@@ -92,7 +92,7 @@ module MergeRequestsHelper
end end
   
def version_index(merge_request_diff) def version_index(merge_request_diff)
return nil if @merge_request_diffs.empty? return if @merge_request_diffs.empty?
   
@merge_request_diffs.size - @merge_request_diffs.index(merge_request_diff) @merge_request_diffs.size - @merge_request_diffs.index(merge_request_diff)
end end
Loading
@@ -149,7 +149,7 @@ module MergeRequestsHelper
Loading
@@ -149,7 +149,7 @@ module MergeRequestsHelper
   
def merge_request_source_project_for_project(project = @project) def merge_request_source_project_for_project(project = @project)
unless can?(current_user, :create_merge_request_in, project) unless can?(current_user, :create_merge_request_in, project)
return nil return
end end
   
if can?(current_user, :create_merge_request_from, project) if can?(current_user, :create_merge_request_from, project)
Loading
Loading
Loading
@@ -122,7 +122,7 @@ module NotesHelper
Loading
@@ -122,7 +122,7 @@ module NotesHelper
end end
   
def new_form_url def new_form_url
return nil unless @snippet.is_a?(PersonalSnippet) return unless @snippet.is_a?(PersonalSnippet)
   
snippet_notes_path(@snippet) snippet_notes_path(@snippet)
end end
Loading
Loading
Loading
@@ -46,7 +46,8 @@ module PreferencesHelper
Loading
@@ -46,7 +46,8 @@ module PreferencesHelper
def first_day_of_week_choices def first_day_of_week_choices
[ [
[_('Sunday'), 0], [_('Sunday'), 0],
[_('Monday'), 1] [_('Monday'), 1],
[_('Saturday'), 6]
] ]
end end
   
Loading
Loading
Loading
@@ -136,18 +136,9 @@ module TreeHelper
Loading
@@ -136,18 +136,9 @@ module TreeHelper
end end
   
# returns the relative path of the first subdir that doesn't have only one directory descendant # returns the relative path of the first subdir that doesn't have only one directory descendant
# rubocop: disable CodeReuse/ActiveRecord
def flatten_tree(root_path, tree) def flatten_tree(root_path, tree)
return tree.flat_path.sub(%r{\A#{Regexp.escape(root_path)}/}, '') if tree.flat_path.present? tree.flat_path.sub(%r{\A#{Regexp.escape(root_path)}/}, '')
subtree = Gitlab::Git::Tree.where(@repository, @commit.id, tree.path)
if subtree.count == 1 && subtree.first.dir?
return tree_join(tree.name, flatten_tree(root_path, subtree.first))
else
return tree.name
end
end end
# rubocop: enable CodeReuse/ActiveRecord
   
def selected_branch def selected_branch
@branch_name || tree_edit_branch @branch_name || tree_edit_branch
Loading
Loading
Loading
@@ -7,7 +7,7 @@ class ApplicationSetting < ActiveRecord::Base
Loading
@@ -7,7 +7,7 @@ class ApplicationSetting < ActiveRecord::Base
include IgnorableColumn include IgnorableColumn
include ChronicDurationAttribute include ChronicDurationAttribute
   
add_authentication_token_field :runners_registration_token, encrypted: true, fallback: true add_authentication_token_field :runners_registration_token, encrypted: -> { Feature.enabled?(:application_settings_tokens_optional_encryption) ? :optional : :required }
add_authentication_token_field :health_check_access_token add_authentication_token_field :health_check_access_token
   
DOMAIN_LIST_SEPARATOR = %r{\s*[,;]\s* # comma or semicolon, optionally surrounded by whitespace DOMAIN_LIST_SEPARATOR = %r{\s*[,;]\s* # comma or semicolon, optionally surrounded by whitespace
Loading
Loading
Loading
@@ -3,14 +3,18 @@
Loading
@@ -3,14 +3,18 @@
module Ci module Ci
class Bridge < CommitStatus class Bridge < CommitStatus
include Ci::Processable include Ci::Processable
include Ci::Contextable
include Importable include Importable
include AfterCommitQueue include AfterCommitQueue
include HasRef
include Gitlab::Utils::StrongMemoize include Gitlab::Utils::StrongMemoize
   
belongs_to :project belongs_to :project
belongs_to :trigger_request belongs_to :trigger_request
validates :ref, presence: true validates :ref, presence: true
   
delegate :merge_request_event?, to: :pipeline
def self.retry(bridge, current_user) def self.retry(bridge, current_user)
raise NotImplementedError raise NotImplementedError
end end
Loading
@@ -37,11 +41,11 @@ module Ci
Loading
@@ -37,11 +41,11 @@ module Ci
false false
end end
   
def expanded_environment_name def runnable?
false
end end
   
def predefined_variables def expanded_environment_name
raise NotImplementedError
end end
   
def execute_hooks def execute_hooks
Loading
Loading
Loading
@@ -5,6 +5,7 @@ module Ci
Loading
@@ -5,6 +5,7 @@ module Ci
prepend ArtifactMigratable prepend ArtifactMigratable
include Ci::Processable include Ci::Processable
include Ci::Metadatable include Ci::Metadatable
include Ci::Contextable
include TokenAuthenticatable include TokenAuthenticatable
include AfterCommitQueue include AfterCommitQueue
include ObjectStorage::BackgroundMove include ObjectStorage::BackgroundMove
Loading
@@ -137,7 +138,7 @@ module Ci
Loading
@@ -137,7 +138,7 @@ module Ci
   
acts_as_taggable acts_as_taggable
   
add_authentication_token_field :token, encrypted: true, fallback: true add_authentication_token_field :token, encrypted: :optional
   
before_save :update_artifacts_size, if: :artifacts_file_changed? before_save :update_artifacts_size, if: :artifacts_file_changed?
before_save :ensure_token before_save :ensure_token
Loading
@@ -289,6 +290,10 @@ module Ci
Loading
@@ -289,6 +290,10 @@ module Ci
self.name == 'pages' self.name == 'pages'
end end
   
def runnable?
true
end
def archived? def archived?
return true if degenerated? return true if degenerated?
   
Loading
@@ -398,46 +403,6 @@ module Ci
Loading
@@ -398,46 +403,6 @@ module Ci
options&.dig(:environment, :on_stop) options&.dig(:environment, :on_stop)
end end
   
# A slugified version of the build ref, suitable for inclusion in URLs and
# domain names. Rules:
#
# * Lowercased
# * Anything not matching [a-z0-9-] is replaced with a -
# * Maximum length is 63 bytes
# * First/Last Character is not a hyphen
def ref_slug
Gitlab::Utils.slugify(ref.to_s)
end
##
# Variables in the environment name scope.
#
def scoped_variables(environment: expanded_environment_name)
Gitlab::Ci::Variables::Collection.new.tap do |variables|
variables.concat(predefined_variables)
variables.concat(project.predefined_variables)
variables.concat(pipeline.predefined_variables)
variables.concat(runner.predefined_variables) if runner
variables.concat(project.deployment_variables(environment: environment)) if environment
variables.concat(yaml_variables)
variables.concat(user_variables)
variables.concat(secret_group_variables)
variables.concat(secret_project_variables(environment: environment))
variables.concat(trigger_request.user_variables) if trigger_request
variables.concat(pipeline.variables)
variables.concat(pipeline.pipeline_schedule.job_variables) if pipeline.pipeline_schedule
end
end
##
# Variables that do not depend on the environment name.
#
def simple_variables
strong_memoize(:simple_variables) do
scoped_variables(environment: nil).to_runner_variables
end
end
## ##
# All variables, including persisted environment variables. # All variables, including persisted environment variables.
# #
Loading
@@ -451,12 +416,46 @@ module Ci
Loading
@@ -451,12 +416,46 @@ module Ci
end end
end end
   
## CI_REGISTRY_USER = 'gitlab-ci-token'.freeze
# Regular Ruby hash of scoped variables, without duplicates that are
# possible to be present in an array of hashes returned from `variables`. def persisted_variables
# Gitlab::Ci::Variables::Collection.new.tap do |variables|
def scoped_variables_hash break variables unless persisted?
scoped_variables.to_hash
variables
.concat(pipeline.persisted_variables)
.append(key: 'CI_JOB_ID', value: id.to_s)
.append(key: 'CI_JOB_URL', value: Gitlab::Routing.url_helpers.project_job_url(project, self))
.append(key: 'CI_JOB_TOKEN', value: token.to_s, public: false, masked: true)
.append(key: 'CI_BUILD_ID', value: id.to_s)
.append(key: 'CI_BUILD_TOKEN', value: token.to_s, public: false, masked: true)
.append(key: 'CI_REGISTRY_USER', value: CI_REGISTRY_USER)
.append(key: 'CI_REGISTRY_PASSWORD', value: token.to_s, public: false, masked: true)
.append(key: 'CI_REPOSITORY_URL', value: repo_url.to_s, public: false)
.concat(deploy_token_variables)
end
end
def persisted_environment_variables
Gitlab::Ci::Variables::Collection.new.tap do |variables|
break variables unless persisted? && persisted_environment.present?
variables.concat(persisted_environment.predefined_variables)
# Here we're passing unexpanded environment_url for runner to expand,
# and we need to make sure that CI_ENVIRONMENT_NAME and
# CI_ENVIRONMENT_SLUG so on are available for the URL be expanded.
variables.append(key: 'CI_ENVIRONMENT_URL', value: environment_url) if environment_url
end
end
def deploy_token_variables
Gitlab::Ci::Variables::Collection.new.tap do |variables|
break variables unless gitlab_deploy_token
variables.append(key: 'CI_DEPLOY_USER', value: gitlab_deploy_token.username)
variables.append(key: 'CI_DEPLOY_PASSWORD', value: gitlab_deploy_token.token, public: false, masked: true)
end
end end
   
def features def features
Loading
@@ -634,27 +633,6 @@ module Ci
Loading
@@ -634,27 +633,6 @@ module Ci
super || project.try(:build_coverage_regex) super || project.try(:build_coverage_regex)
end end
   
def user_variables
Gitlab::Ci::Variables::Collection.new.tap do |variables|
break variables if user.blank?
variables.append(key: 'GITLAB_USER_ID', value: user.id.to_s)
variables.append(key: 'GITLAB_USER_EMAIL', value: user.email)
variables.append(key: 'GITLAB_USER_LOGIN', value: user.username)
variables.append(key: 'GITLAB_USER_NAME', value: user.name)
end
end
def secret_group_variables
return [] unless project.group
project.group.ci_variables_for(git_ref, project)
end
def secret_project_variables(environment: persisted_environment)
project.ci_variables_for(ref: git_ref, environment: environment)
end
def steps def steps
[Gitlab::Ci::Build::Step.from_commands(self), [Gitlab::Ci::Build::Step.from_commands(self),
Gitlab::Ci::Build::Step.from_after_script(self)].compact Gitlab::Ci::Build::Step.from_after_script(self)].compact
Loading
@@ -757,7 +735,7 @@ module Ci
Loading
@@ -757,7 +735,7 @@ module Ci
   
# Virtual deployment status depending on the environment status. # Virtual deployment status depending on the environment status.
def deployment_status def deployment_status
return nil unless starts_environment? return unless starts_environment?
   
if success? if success?
return successful_deployment_status return successful_deployment_status
Loading
@@ -814,89 +792,6 @@ module Ci
Loading
@@ -814,89 +792,6 @@ module Ci
@unscoped_project ||= Project.unscoped.find_by(id: project_id) @unscoped_project ||= Project.unscoped.find_by(id: project_id)
end end
   
CI_REGISTRY_USER = 'gitlab-ci-token'.freeze
def persisted_variables
Gitlab::Ci::Variables::Collection.new.tap do |variables|
break variables unless persisted?
variables
.concat(pipeline.persisted_variables)
.append(key: 'CI_JOB_ID', value: id.to_s)
.append(key: 'CI_JOB_URL', value: Gitlab::Routing.url_helpers.project_job_url(project, self))
.append(key: 'CI_JOB_TOKEN', value: token.to_s, public: false)
.append(key: 'CI_BUILD_ID', value: id.to_s)
.append(key: 'CI_BUILD_TOKEN', value: token.to_s, public: false)
.append(key: 'CI_REGISTRY_USER', value: CI_REGISTRY_USER)
.append(key: 'CI_REGISTRY_PASSWORD', value: token.to_s, public: false)
.append(key: 'CI_REPOSITORY_URL', value: repo_url.to_s, public: false)
.concat(deploy_token_variables)
end
end
def predefined_variables # rubocop:disable Metrics/AbcSize
Gitlab::Ci::Variables::Collection.new.tap do |variables|
variables.append(key: 'CI', value: 'true')
variables.append(key: 'GITLAB_CI', value: 'true')
variables.append(key: 'GITLAB_FEATURES', value: project.licensed_features.join(','))
variables.append(key: 'CI_SERVER_NAME', value: 'GitLab')
variables.append(key: 'CI_SERVER_VERSION', value: Gitlab::VERSION)
variables.append(key: 'CI_SERVER_VERSION_MAJOR', value: Gitlab.version_info.major.to_s)
variables.append(key: 'CI_SERVER_VERSION_MINOR', value: Gitlab.version_info.minor.to_s)
variables.append(key: 'CI_SERVER_VERSION_PATCH', value: Gitlab.version_info.patch.to_s)
variables.append(key: 'CI_SERVER_REVISION', value: Gitlab.revision)
variables.append(key: 'CI_JOB_NAME', value: name)
variables.append(key: 'CI_JOB_STAGE', value: stage)
variables.append(key: 'CI_COMMIT_SHA', value: sha)
variables.append(key: 'CI_COMMIT_SHORT_SHA', value: short_sha)
variables.append(key: 'CI_COMMIT_BEFORE_SHA', value: before_sha)
variables.append(key: 'CI_COMMIT_REF_NAME', value: ref)
variables.append(key: 'CI_COMMIT_REF_SLUG', value: ref_slug)
variables.append(key: "CI_COMMIT_TAG", value: ref) if tag?
variables.append(key: "CI_PIPELINE_TRIGGERED", value: 'true') if trigger_request
variables.append(key: "CI_JOB_MANUAL", value: 'true') if action?
variables.append(key: "CI_NODE_INDEX", value: self.options[:instance].to_s) if self.options&.include?(:instance)
variables.append(key: "CI_NODE_TOTAL", value: (self.options&.dig(:parallel) || 1).to_s)
variables.concat(legacy_variables)
end
end
def legacy_variables
Gitlab::Ci::Variables::Collection.new.tap do |variables|
variables.append(key: 'CI_BUILD_REF', value: sha)
variables.append(key: 'CI_BUILD_BEFORE_SHA', value: before_sha)
variables.append(key: 'CI_BUILD_REF_NAME', value: ref)
variables.append(key: 'CI_BUILD_REF_SLUG', value: ref_slug)
variables.append(key: 'CI_BUILD_NAME', value: name)
variables.append(key: 'CI_BUILD_STAGE', value: stage)
variables.append(key: "CI_BUILD_TAG", value: ref) if tag?
variables.append(key: "CI_BUILD_TRIGGERED", value: 'true') if trigger_request
variables.append(key: "CI_BUILD_MANUAL", value: 'true') if action?
end
end
def persisted_environment_variables
Gitlab::Ci::Variables::Collection.new.tap do |variables|
break variables unless persisted? && persisted_environment.present?
variables.concat(persisted_environment.predefined_variables)
# Here we're passing unexpanded environment_url for runner to expand,
# and we need to make sure that CI_ENVIRONMENT_NAME and
# CI_ENVIRONMENT_SLUG so on are available for the URL be expanded.
variables.append(key: 'CI_ENVIRONMENT_URL', value: environment_url) if environment_url
end
end
def deploy_token_variables
Gitlab::Ci::Variables::Collection.new.tap do |variables|
break variables unless gitlab_deploy_token
variables.append(key: 'CI_DEPLOY_USER', value: gitlab_deploy_token.username)
variables.append(key: 'CI_DEPLOY_PASSWORD', value: gitlab_deploy_token.token, public: false)
end
end
def environment_url def environment_url
options&.dig(:environment, :url) || persisted_environment&.external_url options&.dig(:environment, :url) || persisted_environment&.external_url
end end
Loading
Loading
Loading
@@ -10,7 +10,7 @@ module Ci
Loading
@@ -10,7 +10,7 @@ module Ci
include FromUnion include FromUnion
include TokenAuthenticatable include TokenAuthenticatable
   
add_authentication_token_field :token, encrypted: true, migrating: true add_authentication_token_field :token, encrypted: -> { Feature.enabled?(:ci_runners_tokens_optional_encryption) ? :optional : :required }
   
enum access_level: { enum access_level: {
not_protected: 0, not_protected: 0,
Loading
Loading
Loading
@@ -48,6 +48,7 @@ module Clusters
Loading
@@ -48,6 +48,7 @@ module Clusters
def schedule_status_update def schedule_status_update
return unless installed? return unless installed?
return if external_ip return if external_ip
return if external_hostname
   
ClusterWaitForIngressIpAddressWorker.perform_async(name, id) ClusterWaitForIngressIpAddressWorker.perform_async(name, id)
end end
Loading
Loading
Loading
@@ -3,7 +3,7 @@
Loading
@@ -3,7 +3,7 @@
module Clusters module Clusters
module Applications module Applications
class Jupyter < ActiveRecord::Base class Jupyter < ActiveRecord::Base
VERSION = 'v0.6'.freeze VERSION = '0.9-174bbd5'.freeze
   
self.table_name = 'clusters_applications_jupyter' self.table_name = 'clusters_applications_jupyter'
   
Loading
@@ -18,8 +18,10 @@ module Clusters
Loading
@@ -18,8 +18,10 @@ module Clusters
   
def set_initial_status def set_initial_status
return unless not_installable? return unless not_installable?
return unless cluster&.application_ingress_available?
   
if cluster&.application_ingress_available? && cluster.application_ingress.external_ip ingress = cluster.application_ingress
if ingress.external_ip || ingress.external_hostname
self.status = 'installable' self.status = 'installable'
end end
end end
Loading
@@ -75,17 +77,22 @@ module Clusters
Loading
@@ -75,17 +77,22 @@ module Clusters
"gitlab" => { "gitlab" => {
"clientId" => oauth_application.uid, "clientId" => oauth_application.uid,
"clientSecret" => oauth_application.secret, "clientSecret" => oauth_application.secret,
"callbackUrl" => callback_url "callbackUrl" => callback_url,
"gitlabProjectIdWhitelist" => [project_id]
} }
}, },
"singleuser" => { "singleuser" => {
"extraEnv" => { "extraEnv" => {
"GITLAB_CLUSTER_ID" => cluster.id "GITLAB_CLUSTER_ID" => cluster.id.to_s
} }
} }
} }
end end
   
def project_id
cluster&.project&.id
end
def gitlab_url def gitlab_url
Gitlab.config.gitlab.url Gitlab.config.gitlab.url
end end
Loading
Loading
Loading
@@ -66,6 +66,7 @@ module Clusters
Loading
@@ -66,6 +66,7 @@ module Clusters
def schedule_status_update def schedule_status_update
return unless installed? return unless installed?
return if external_ip return if external_ip
return if external_hostname
   
ClusterWaitForIngressIpAddressWorker.perform_async(name, id) ClusterWaitForIngressIpAddressWorker.perform_async(name, id)
end end
Loading
Loading
Loading
@@ -67,6 +67,7 @@ module Clusters
Loading
@@ -67,6 +67,7 @@ module Clusters
delegate :available?, to: :application_prometheus, prefix: true, allow_nil: true delegate :available?, to: :application_prometheus, prefix: true, allow_nil: true
delegate :available?, to: :application_knative, prefix: true, allow_nil: true delegate :available?, to: :application_knative, prefix: true, allow_nil: true
delegate :external_ip, to: :application_ingress, prefix: true, allow_nil: true delegate :external_ip, to: :application_ingress, prefix: true, allow_nil: true
delegate :external_hostname, to: :application_ingress, prefix: true, allow_nil: true
   
alias_attribute :base_domain, :domain alias_attribute :base_domain, :domain
   
Loading
Loading
Loading
@@ -30,6 +30,12 @@ module Clusters
Loading
@@ -30,6 +30,12 @@ module Clusters
# Override if you need extra data synchronized # Override if you need extra data synchronized
# from K8s after installation # from K8s after installation
end end
def update_command
install_command.tap do |command|
command.version = version
end
end
end end
end end
end end
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment