mirror of
https://github.com/cloudnative-pg/plugin-barman-cloud.git
synced 2026-01-14 06:33:10 +01:00
fix(lint): preallocate envs slice to avoid reallocations
The golangci-lint v2.8.0 upgrade introduced a prealloc linter finding suggesting to preallocate the envs slice with capacity 5 + len(config.env) to avoid reallocations when appending config.env elements. Signed-off-by: Marco Nenciarini <marco.nenciarini@enterprisedb.com>
This commit is contained in:
parent
ad03222d87
commit
b6c2c2f189
@ -353,30 +353,31 @@ func reconcilePodSpec(
|
||||
sidecarTemplate corev1.Container,
|
||||
config sidecarConfiguration,
|
||||
) error {
|
||||
envs := []corev1.EnvVar{
|
||||
{
|
||||
envs := make([]corev1.EnvVar, 0, 5+len(config.env))
|
||||
envs = append(envs,
|
||||
corev1.EnvVar{
|
||||
Name: "NAMESPACE",
|
||||
Value: cluster.Namespace,
|
||||
},
|
||||
{
|
||||
corev1.EnvVar{
|
||||
Name: "CLUSTER_NAME",
|
||||
Value: cluster.Name,
|
||||
},
|
||||
{
|
||||
corev1.EnvVar{
|
||||
// TODO: should we really use this one?
|
||||
// should we mount an emptyDir volume just for that?
|
||||
Name: "SPOOL_DIRECTORY",
|
||||
Value: "/controller/wal-restore-spool",
|
||||
},
|
||||
{
|
||||
corev1.EnvVar{
|
||||
Name: "CUSTOM_CNPG_GROUP",
|
||||
Value: cluster.GetObjectKind().GroupVersionKind().Group,
|
||||
},
|
||||
{
|
||||
corev1.EnvVar{
|
||||
Name: "CUSTOM_CNPG_VERSION",
|
||||
Value: cluster.GetObjectKind().GroupVersionKind().Version,
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
envs = append(envs, config.env...)
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user