Skip to content

Commit

Permalink
extract agent upgrade secret volume creation
Browse files Browse the repository at this point in the history
  • Loading branch information
rain-on committed Nov 26, 2024
1 parent 25925d2 commit 118ba20
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,23 +81,7 @@ protected override IList<V1Volume> CreateVolumes(StartKubernetesScriptCommandV1
ClaimName = KubernetesConfig.PodVolumeClaimName
}
},
new()
{
Name = "agent-upgrade",
Secret = new V1SecretVolumeSource
{
SecretName = "agent-upgrade-secret",
Items = new List<V1KeyToPath>()
{
new()
{
Key = ".dockerconfigjson",
Path = "config.json"
}
},
Optional = true,
},
},
CreateAgentUpgradeSecretVolume(),
};
}

Expand Down
32 changes: 20 additions & 12 deletions source/Octopus.Tentacle/Kubernetes/KubernetesScriptPodCreator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,9 @@ async Task CreatePod(StartKubernetesScriptCommandV1 command, IScriptWorkspace wo
.Select(secretName => new V1LocalObjectReference(secretName))
.ToList();

var volumes = CreateVolumes(command);
volumes.Append(CreateAgentUpgradeSecretVolume());

var pod = new V1Pod
{
Metadata = new V1ObjectMeta
Expand Down Expand Up @@ -241,22 +244,27 @@ protected virtual IList<V1Volume> CreateVolumes(StartKubernetesScriptCommandV1 c
ClaimName = KubernetesConfig.PodVolumeClaimName
}
},
new()
CreateAgentUpgradeSecretVolume(),
};
}

protected V1Volume CreateAgentUpgradeSecretVolume()
{
return new()
{
Name = "agent-upgrade",
Secret = new V1SecretVolumeSource
{
Name = "agent-upgrade",
Secret = new V1SecretVolumeSource
SecretName = "agent-upgrade-secret",
Items = new List<V1KeyToPath>()
{
SecretName = "agent-upgrade-secret",
Items = new List<V1KeyToPath>()
new()
{
new()
{
Key = ".dockerconfigjson",
Path = "config.json"
}
},
Optional = true,
Key = ".dockerconfigjson",
Path = "config.json"
}
},
Optional = true,
},
};
}
Expand Down

0 comments on commit 118ba20

Please sign in to comment.