debian-mirror-gitlab/lib/gitlab/kas.rb

57 lines
1.3 KiB
Ruby
Raw Normal View History

2020-11-24 15:15:51 +05:30
# frozen_string_literal: true
module Gitlab
module Kas
INTERNAL_API_REQUEST_HEADER = 'Gitlab-Kas-Api-Request'
2021-06-08 01:23:25 +05:30
VERSION_FILE = 'GITLAB_KAS_VERSION'
2020-11-24 15:15:51 +05:30
JWT_ISSUER = 'gitlab-kas'
include JwtAuthenticatable
class << self
def verify_api_request(request_headers)
decode_jwt_for_issuer(JWT_ISSUER, request_headers[INTERNAL_API_REQUEST_HEADER])
rescue JWT::DecodeError
nil
end
def secret_path
Gitlab.config.gitlab_kas.secret_file
end
def ensure_secret!
return if File.exist?(secret_path)
write_secret
end
2021-03-11 19:13:27 +05:30
def included_in_gitlab_com_rollout?(project)
return true unless ::Gitlab.com?
2021-04-29 21:17:54 +05:30
Feature.enabled?(:kubernetes_agent_on_gitlab_com, project, default_enabled: :yaml)
2021-03-11 19:13:27 +05:30
end
2021-06-08 01:23:25 +05:30
# Return GitLab KAS version
#
# @return [String] version
def version
@_version ||= Rails.root.join(VERSION_FILE).read.chomp
end
# Return GitLab KAS external_url
#
# @return [String] external_url
def external_url
Gitlab.config.gitlab_kas.external_url
end
# Return whether GitLab KAS is enabled
#
# @return [Boolean] external_url
def enabled?
!!Gitlab.config['gitlab_kas']&.fetch('enabled', false)
end
2020-11-24 15:15:51 +05:30
end
end
end