@@ -129,7 +129,6 @@ func InjectVaultSecret(ctx context.Context, client splcommon.ControllerClient, s
129
129
return fmt .Errorf ("vault secretPath is required when vault is enabled" )
130
130
}
131
131
132
- secretPath := vaultSpec .SecretPath
133
132
vaultRole := vaultSpec .Role
134
133
secretKeyToEnv := []string {
135
134
"hec_token" ,
@@ -183,7 +182,7 @@ func InjectVaultSecret(ctx context.Context, client splcommon.ControllerClient, s
183
182
},
184
183
},
185
184
}
186
- }
185
+ }
187
186
188
187
splunkConfigYAML , err := yaml .Marshal (splunkConfig )
189
188
if err != nil {
@@ -198,12 +197,15 @@ func InjectVaultSecret(ctx context.Context, client splcommon.ControllerClient, s
198
197
annotations ["vault.hashicorp.com/secret-volume-path-defaults" ] = "/mnt/splunk-secrets"
199
198
annotations ["vault.hashicorp.com/agent-inject-template-defaults" ] = splunkConfigString
200
199
for _ , key := range secretKeyToEnv {
201
- annotationKey := fmt .Sprintf ("vault.hashicorp.com/agent-inject-secret-%s" , key )
202
- annotations [annotationKey ] = fmt .Sprintf ("%s/%s" , secretPath , key )
200
+ annotationKey := fmt .Sprintf ("vault.hashicorp.com/agent-inject-template-%s" , key )
201
+ annotations [annotationKey ] = fmt .Sprintf ("{{- with secret \" secret/data/splunk/%s\" -}}{{ .Data.value }}{{- end }}" , key )
202
+ if kvVersion == "2" {
203
+ annotations [annotationKey ] = fmt .Sprintf ("{{- with secret \" secret/data/splunk/%s\" -}}{{ .Data.data.value }}{{- end }}" , key )
204
+ }
203
205
annotationFile := fmt .Sprintf ("vault.hashicorp.com/agent-inject-file-%s" , key )
204
206
annotations [annotationFile ] = key
205
207
annotationVolumeKey := fmt .Sprintf ("vault.hashicorp.com/secret-volume-path-%s" , key )
206
- annotations [annotationVolumeKey ] = fmt . Sprintf ( "/mnt/splunk-secrets/%s" , key )
208
+ annotations [annotationVolumeKey ] = "/mnt/splunk-secrets"
207
209
}
208
210
209
211
// Apply these annotations to the StatefulSet PodTemplateSpec without overwriting existing ones
@@ -404,7 +406,7 @@ func GetSpecificSecretTokenFromVault(ctx context.Context, c splcommon.Controller
404
406
password = metadataResponse .Data .Value
405
407
} else if kvVersion == "2" {
406
408
password = metadataResponse .Data .Data .Value
407
- }
409
+ }
408
410
409
411
return password , nil
410
412
}
0 commit comments