Skip to content

Commit c94f2d2

Browse files
authored
Add project group to k8a auth ctx (#1171)
1 parent 1f238ab commit c94f2d2

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

source/Octopus.Tentacle.Contracts/KubernetesAgentAuthContext.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,25 @@ namespace Octopus.Tentacle.Contracts
44
{
55
public class KubernetesAgentAuthContext
66
{
7-
public KubernetesAgentAuthContext(string spaceSlug, string projectSlug, string environmentSlug, string? tenantSlug, string stepSlug)
7+
public KubernetesAgentAuthContext(
8+
string spaceSlug,
9+
string projectSlug,
10+
string? projectGroupSlug,
11+
string environmentSlug,
12+
string? tenantSlug,
13+
string stepSlug)
814
{
915
SpaceSlug = spaceSlug;
1016
ProjectSlug = projectSlug;
17+
ProjectGroupSlug = projectGroupSlug;
1118
EnvironmentSlug = environmentSlug;
1219
TenantSlug = tenantSlug;
1320
StepSlug = stepSlug;
1421
}
1522

1623
public string SpaceSlug { get; }
1724
public string ProjectSlug { get; }
25+
public string? ProjectGroupSlug { get; } // This is only nullable for backwards compatibility
1826
public string EnvironmentSlug { get; }
1927
public string? TenantSlug { get; }
2028
public string StepSlug { get; }

source/Octopus.Tentacle/Kubernetes/KubernetesScriptPodCreator.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
using Newtonsoft.Json;
1313
using Octopus.Tentacle.Configuration;
1414
using Octopus.Tentacle.Configuration.Instances;
15-
using Octopus.Tentacle.Contracts;
1615
using Octopus.Tentacle.Contracts.KubernetesScriptServiceV1;
1716
using Octopus.Tentacle.Core.Diagnostics;
1817
using Octopus.Tentacle.Core.Services.Scripts.Locking;
@@ -434,7 +433,7 @@ V1Affinity ParseScriptPodAffinity(InMemoryTentacleScriptLog tentacleScriptLog)
434433
KubernetesConfig.PodAnnotationsJsonVariableName,
435434
"pod annotations");
436435

437-
Dictionary<string, string>? GetScriptPodAnnotations(InMemoryTentacleScriptLog tentacleScriptLog, StartKubernetesScriptCommandV1 command)
436+
Dictionary<string, string> GetScriptPodAnnotations(InMemoryTentacleScriptLog tentacleScriptLog, StartKubernetesScriptCommandV1 command)
438437
{
439438
var annotations = ParseScriptPodAnnotations(tentacleScriptLog) ?? new Dictionary<string, string>();
440439
annotations.AddRange(GetAuthContext(command));
@@ -478,6 +477,13 @@ static Dictionary<string, string> GetAuthContext(StartKubernetesScriptCommandV1
478477
? HashValue(command.AuthContext.ProjectSlug)
479478
: command.AuthContext.ProjectSlug;
480479

480+
if (command.AuthContext.ProjectGroupSlug is not null)
481+
{
482+
dict[$"{KubernetesConfig.AgentLabelNamespace}/project-group"] = hash
483+
? HashValue(command.AuthContext.ProjectGroupSlug)
484+
: command.AuthContext.ProjectGroupSlug;
485+
}
486+
481487
dict[$"{KubernetesConfig.AgentLabelNamespace}/environment"] = hash
482488
? HashValue(command.AuthContext.EnvironmentSlug)
483489
: command.AuthContext.EnvironmentSlug;

0 commit comments

Comments
 (0)