Add latest changes from gitlab-org/gitlab@master
This commit is contained in:
parent
b0a27063a3
commit
a3ed0d253d
|
@ -2,8 +2,9 @@
|
||||||
|
|
||||||
module Ci
|
module Ci
|
||||||
class GenerateKubeconfigService
|
class GenerateKubeconfigService
|
||||||
def initialize(build)
|
def initialize(pipeline, token:)
|
||||||
@build = build
|
@pipeline = pipeline
|
||||||
|
@token = token
|
||||||
@template = Gitlab::Kubernetes::Kubeconfig::Template.new
|
@template = Gitlab::Kubernetes::Kubeconfig::Template.new
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -33,10 +34,10 @@ module Ci
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
attr_reader :build, :template
|
attr_reader :pipeline, :token, :template
|
||||||
|
|
||||||
def agents
|
def agents
|
||||||
build.pipeline.authorized_cluster_agents
|
pipeline.authorized_cluster_agents
|
||||||
end
|
end
|
||||||
|
|
||||||
def cluster_name
|
def cluster_name
|
||||||
|
@ -52,7 +53,7 @@ module Ci
|
||||||
end
|
end
|
||||||
|
|
||||||
def agent_token(agent)
|
def agent_token(agent)
|
||||||
['ci', agent.id, build.token].join(delimiter)
|
['ci', agent.id, token].join(delimiter)
|
||||||
end
|
end
|
||||||
|
|
||||||
def delimiter
|
def delimiter
|
||||||
|
|
|
@ -33,7 +33,7 @@ permission level, who added a new user, or who removed a user.
|
||||||
## Retention policy
|
## Retention policy
|
||||||
|
|
||||||
There is no retention policy in place for audit events.
|
There is no retention policy in place for audit events.
|
||||||
See the [Specify a retention period for audit events](https://gitlab.com/gitlab-org/gitlab/-/issues/8137) for more information.
|
See the [Specify a retention period for audit events](https://gitlab.com/groups/gitlab-org/-/epics/7917) for more information.
|
||||||
|
|
||||||
## List of events
|
## List of events
|
||||||
|
|
||||||
|
|
|
@ -52,7 +52,7 @@ module Gitlab
|
||||||
# https://gitlab.com/groups/gitlab-org/configure/-/epics/8
|
# https://gitlab.com/groups/gitlab-org/configure/-/epics/8
|
||||||
# Until then, we need to make both the old and the new KUBECONFIG contexts available
|
# Until then, we need to make both the old and the new KUBECONFIG contexts available
|
||||||
collection.concat(deployment_variables(environment: environment, job: job))
|
collection.concat(deployment_variables(environment: environment, job: job))
|
||||||
template = ::Ci::GenerateKubeconfigService.new(job).execute
|
template = ::Ci::GenerateKubeconfigService.new(pipeline, token: job.token).execute
|
||||||
kubeconfig_yaml = collection['KUBECONFIG']&.value
|
kubeconfig_yaml = collection['KUBECONFIG']&.value
|
||||||
template.merge_yaml(kubeconfig_yaml) if kubeconfig_yaml.present?
|
template.merge_yaml(kubeconfig_yaml) if kubeconfig_yaml.present?
|
||||||
|
|
||||||
|
|
|
@ -246,7 +246,7 @@ RSpec.describe Gitlab::Ci::Variables::Builder do
|
||||||
subject { builder.kubernetes_variables(environment: nil, job: job) }
|
subject { builder.kubernetes_variables(environment: nil, job: job) }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
allow(Ci::GenerateKubeconfigService).to receive(:new).with(job).and_return(service)
|
allow(Ci::GenerateKubeconfigService).to receive(:new).with(job.pipeline, token: job.token).and_return(service)
|
||||||
end
|
end
|
||||||
|
|
||||||
it { is_expected.to include(key: 'KUBECONFIG', value: 'example-kubeconfig', public: false, file: true) }
|
it { is_expected.to include(key: 'KUBECONFIG', value: 'example-kubeconfig', public: false, file: true) }
|
||||||
|
|
|
@ -6,16 +6,17 @@ RSpec.describe Ci::GenerateKubeconfigService do
|
||||||
describe '#execute' do
|
describe '#execute' do
|
||||||
let(:project) { create(:project) }
|
let(:project) { create(:project) }
|
||||||
let(:build) { create(:ci_build, project: project) }
|
let(:build) { create(:ci_build, project: project) }
|
||||||
|
let(:pipeline) { build.pipeline }
|
||||||
let(:agent1) { create(:cluster_agent, project: project) }
|
let(:agent1) { create(:cluster_agent, project: project) }
|
||||||
let(:agent2) { create(:cluster_agent) }
|
let(:agent2) { create(:cluster_agent) }
|
||||||
|
|
||||||
let(:template) { instance_double(Gitlab::Kubernetes::Kubeconfig::Template) }
|
let(:template) { instance_double(Gitlab::Kubernetes::Kubeconfig::Template) }
|
||||||
|
|
||||||
subject { described_class.new(build).execute }
|
subject { described_class.new(pipeline, token: build.token).execute }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
expect(Gitlab::Kubernetes::Kubeconfig::Template).to receive(:new).and_return(template)
|
expect(Gitlab::Kubernetes::Kubeconfig::Template).to receive(:new).and_return(template)
|
||||||
expect(build.pipeline).to receive(:authorized_cluster_agents).and_return([agent1, agent2])
|
expect(pipeline).to receive(:authorized_cluster_agents).and_return([agent1, agent2])
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'adds a cluster, and a user and context for each available agent' do
|
it 'adds a cluster, and a user and context for each available agent' do
|
||||||
|
|
Loading…
Reference in New Issue