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,
|
sidecarTemplate corev1.Container,
|
||||||
config sidecarConfiguration,
|
config sidecarConfiguration,
|
||||||
) error {
|
) error {
|
||||||
envs := []corev1.EnvVar{
|
envs := make([]corev1.EnvVar, 0, 5+len(config.env))
|
||||||
{
|
envs = append(envs,
|
||||||
|
corev1.EnvVar{
|
||||||
Name: "NAMESPACE",
|
Name: "NAMESPACE",
|
||||||
Value: cluster.Namespace,
|
Value: cluster.Namespace,
|
||||||
},
|
},
|
||||||
{
|
corev1.EnvVar{
|
||||||
Name: "CLUSTER_NAME",
|
Name: "CLUSTER_NAME",
|
||||||
Value: cluster.Name,
|
Value: cluster.Name,
|
||||||
},
|
},
|
||||||
{
|
corev1.EnvVar{
|
||||||
// TODO: should we really use this one?
|
// TODO: should we really use this one?
|
||||||
// should we mount an emptyDir volume just for that?
|
// should we mount an emptyDir volume just for that?
|
||||||
Name: "SPOOL_DIRECTORY",
|
Name: "SPOOL_DIRECTORY",
|
||||||
Value: "/controller/wal-restore-spool",
|
Value: "/controller/wal-restore-spool",
|
||||||
},
|
},
|
||||||
{
|
corev1.EnvVar{
|
||||||
Name: "CUSTOM_CNPG_GROUP",
|
Name: "CUSTOM_CNPG_GROUP",
|
||||||
Value: cluster.GetObjectKind().GroupVersionKind().Group,
|
Value: cluster.GetObjectKind().GroupVersionKind().Group,
|
||||||
},
|
},
|
||||||
{
|
corev1.EnvVar{
|
||||||
Name: "CUSTOM_CNPG_VERSION",
|
Name: "CUSTOM_CNPG_VERSION",
|
||||||
Value: cluster.GetObjectKind().GroupVersionKind().Version,
|
Value: cluster.GetObjectKind().GroupVersionKind().Version,
|
||||||
},
|
},
|
||||||
}
|
)
|
||||||
|
|
||||||
envs = append(envs, config.env...)
|
envs = append(envs, config.env...)
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user