Skip to content

Commit c18237b

Browse files
refactor: disable automount with admin flag override (#434)
1 parent 2507eee commit c18237b

File tree

4 files changed

+6
-3
lines changed

4 files changed

+6
-3
lines changed

internal/generator/buildvalues.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,8 @@ type BuildValues struct {
8989
ConfigSSHHost string `json:"configSSHHost"`
9090
ConfigSSHPort string `json:"configSSHPort"`
9191
LagoonEnvVariables map[string]string `json:"lagoonEnvVariables" description:"map of variables that will be saved into the lagoon-env secret"`
92-
LagoonPlatformEnvVariables map[string]string `json:"agoonPlatformEnvVariables" description:"map of variables that will be saved into the lagoon-platform-env secret"`
92+
LagoonPlatformEnvVariables map[string]string `json:"lagoonPlatformEnvVariables" description:"map of variables that will be saved into the lagoon-platform-env secret"`
93+
AutoMountServiceAccountToken bool `json:"autoMountServiceAccountToken" description:"flag to enable automounting the service account token"`
9394
}
9495

9596
type Resources struct {

internal/generator/generator.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,8 @@ func NewGenerator(
352352
buildValues.Resources.Limits.Memory = CheckAdminFeatureFlag("CONTAINER_MEMORY_LIMIT", false)
353353
buildValues.Resources.Limits.EphemeralStorage = CheckAdminFeatureFlag("EPHEMERAL_STORAGE_LIMIT", false)
354354
buildValues.Resources.Requests.EphemeralStorage = CheckAdminFeatureFlag("EPHEMERAL_STORAGE_REQUESTS", false)
355+
automount, _ := strconv.ParseBool(CheckAdminFeatureFlag("AUTOMOUNT_SERVICE_ACCOUNT_TOKEN", false))
356+
buildValues.AutoMountServiceAccountToken = automount
355357
// validate that what is provided
356358
if buildValues.Resources.Limits.Memory != "" {
357359
err := ValidateResourceQuantity(buildValues.Resources.Limits.Memory)

internal/templating/templates_cronjob.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ func GenerateCronjobTemplate(
101101
}
102102

103103
// disable automounted service account
104-
cronjob.Spec.JobTemplate.Spec.Template.Spec.AutomountServiceAccountToken = helpers.BoolPtr(false)
104+
cronjob.Spec.JobTemplate.Spec.Template.Spec.AutomountServiceAccountToken = &buildValues.AutoMountServiceAccountToken
105105

106106
cronjob.Spec.Schedule = nCronjob.Schedule
107107
cronjob.Spec.ConcurrencyPolicy = batchv1.ForbidConcurrent

internal/templating/templates_deployment.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ func GenerateDeploymentTemplate(
102102
deployment.ObjectMeta.Annotations = annotations
103103

104104
// disable automounted service account
105-
deployment.Spec.Template.Spec.AutomountServiceAccountToken = helpers.BoolPtr(false)
105+
deployment.Spec.Template.Spec.AutomountServiceAccountToken = &buildValues.AutoMountServiceAccountToken
106106

107107
if serviceValues.UseSpotInstances {
108108
// handle spot instance label and affinity/tolerations/selectors

0 commit comments

Comments
 (0)