Commit 25bbaf2d authored by Mark Chao's avatar Mark Chao

Merge branch '323708-use-correct-agent-in-kubeconfig' into 'master'

Use the correct project path in generated `KUBECONFIG` file

See merge request gitlab-org/gitlab!70452
parents 5b45872f 57d828bf
......@@ -4,7 +4,6 @@ module Ci
class GenerateKubeconfigService
def initialize(build)
@build = build
@project = build.project
@template = Gitlab::Kubernetes::Kubeconfig::Template.new
end
......@@ -34,7 +33,7 @@ module Ci
private
attr_reader :build, :project, :template
attr_reader :build, :template
def agents
build.pipeline.authorized_cluster_agents
......@@ -49,7 +48,7 @@ module Ci
end
def context_name(agent)
[project.full_path, agent.name].join(delimiter)
[agent.project.full_path, agent.name].join(delimiter)
end
def agent_token(agent)
......
......@@ -7,7 +7,7 @@ RSpec.describe Ci::GenerateKubeconfigService do
let(:project) { create(:project) }
let(:build) { create(:ci_build, project: project) }
let(:agent1) { create(:cluster_agent, project: project) }
let(:agent2) { create(:cluster_agent, project: project) }
let(:agent2) { create(:cluster_agent) }
let(:template) { instance_double(Gitlab::Kubernetes::Kubeconfig::Template) }
......@@ -39,7 +39,7 @@ RSpec.describe Ci::GenerateKubeconfigService do
user: "agent:#{agent1.id}"
)
expect(template).to receive(:add_context).with(
name: "#{project.full_path}:#{agent2.name}",
name: "#{agent2.project.full_path}:#{agent2.name}",
cluster: 'gitlab',
user: "agent:#{agent2.id}"
)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment