mirror of
https://github.com/vmware-tanzu/pinniped.git
synced 2026-09-05 15:47:02 +00:00
fix new linter warnings from prealloc linter
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
// Copyright 2020-2025 the Pinniped contributors. All Rights Reserved.
|
||||
// Copyright 2020-2026 the Pinniped contributors. All Rights Reserved.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Package jwtcachefiller implements a controller for filling an authncache.Cache with each
|
||||
@@ -305,7 +305,7 @@ func (c *jwtCacheFillerController) doExpensiveValidations(
|
||||
okSoFar bool,
|
||||
) (*cachedJWTAuthenticator, []*metav1.Condition, []error) {
|
||||
var conditions []*metav1.Condition
|
||||
var errs []error
|
||||
errs := make([]error, 0, 4)
|
||||
|
||||
client := phttp.Default(caBundle.CertPool())
|
||||
client.Timeout = 30 * time.Second // copied from Kube OIDC code
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2020-2024 the Pinniped contributors. All Rights Reserved.
|
||||
// Copyright 2020-2026 the Pinniped contributors. All Rights Reserved.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Package webhookcachefiller implements a controller for filling an authncache.Cache with each added/updated WebhookAuthenticator.
|
||||
@@ -256,7 +256,7 @@ func (c *webhookCacheFillerController) doExpensiveValidations(
|
||||
) (*cachedWebhookAuthenticator, []*metav1.Condition, []error) {
|
||||
var newWebhookAuthenticatorForCache *cachedWebhookAuthenticator
|
||||
var conditions []*metav1.Condition
|
||||
var errs []error
|
||||
errs := make([]error, 0, 2)
|
||||
|
||||
conditions, tlsNegotiateErr := c.validateConnection(ctx, caBundle.CertPool(), endpointHostPort, conditions, okSoFar, usingProxyForHost, logger)
|
||||
errs = append(errs, tlsNegotiateErr)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2020-2024 the Pinniped contributors. All Rights Reserved.
|
||||
// Copyright 2020-2026 the Pinniped contributors. All Rights Reserved.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package supervisorconfig
|
||||
@@ -682,7 +682,7 @@ func appendIdentityProvidersFoundCondition(
|
||||
conditions []*metav1.Condition,
|
||||
) []*metav1.Condition {
|
||||
if len(idpNotFoundIndices) != 0 {
|
||||
messages := []string{}
|
||||
messages := make([]string, 0, len(idpNotFoundIndices))
|
||||
for _, idpNotFoundIndex := range idpNotFoundIndices {
|
||||
messages = append(messages, fmt.Sprintf("cannot find resource specified by .spec.identityProviders[%d].objectRef (with name %q)",
|
||||
idpNotFoundIndex, federationDomainIdentityProviders[idpNotFoundIndex].ObjectRef.Name))
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2020-2025 the Pinniped contributors. All Rights Reserved.
|
||||
// Copyright 2020-2026 the Pinniped contributors. All Rights Reserved.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package supervisorconfig
|
||||
@@ -2182,7 +2182,7 @@ func makeFederationDomainIdentityProviderComparable(fdi *federationdomainprovide
|
||||
}
|
||||
|
||||
func convertToComparableType(fdis []*federationdomainproviders.FederationDomainIssuer) []*comparableFederationDomainIssuer {
|
||||
result := []*comparableFederationDomainIssuer{}
|
||||
result := make([]*comparableFederationDomainIssuer, 0, len(fdis))
|
||||
for _, fdi := range fdis {
|
||||
identityProviders := fdi.IdentityProviders()
|
||||
comparableFDIs := make([]*comparableFederationDomainIdentityProvider, len(identityProviders))
|
||||
@@ -2217,7 +2217,7 @@ func expectedFederationDomainStatusUpdate(
|
||||
}
|
||||
|
||||
func getFederationDomainStatusUpdates(t *testing.T, actions []coretesting.Action) []*supervisorconfigv1alpha1.FederationDomain {
|
||||
federationDomains := []*supervisorconfigv1alpha1.FederationDomain{}
|
||||
federationDomains := make([]*supervisorconfigv1alpha1.FederationDomain, 0, len(actions))
|
||||
|
||||
for _, action := range actions {
|
||||
updateAction, ok := action.(coretesting.UpdateAction)
|
||||
@@ -2320,7 +2320,7 @@ func TestTransformationPipelinesCanBeTestedForEqualityUsingSourceToMakeTestingEa
|
||||
equalPipeline := idtransform.NewTransformationPipeline()
|
||||
differentPipeline1 := idtransform.NewTransformationPipeline()
|
||||
differentPipeline2 := idtransform.NewTransformationPipeline()
|
||||
expectedSourceList := []any{}
|
||||
expectedSourceList := make([]any, 0, len(transforms))
|
||||
|
||||
for i, transform := range transforms {
|
||||
// Compile and append to a pipeline.
|
||||
|
||||
+2
-2
@@ -1,4 +1,4 @@
|
||||
// Copyright 2020-2024 the Pinniped contributors. All Rights Reserved.
|
||||
// Copyright 2020-2026 the Pinniped contributors. All Rights Reserved.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Package githubupstreamwatcher implements a controller which watches GitHubIdentityProviders.
|
||||
@@ -310,7 +310,7 @@ func (c *gitHubWatcherController) validateUpstreamAndUpdateConditions(ctx contex
|
||||
*upstreamgithub.Provider, // If validated, returns the config
|
||||
error, // This error will only refer to programmatic errors such as inability to perform a connection probe or dereference a pointer, not configuration errors
|
||||
) {
|
||||
conditions := make([]*metav1.Condition, 0)
|
||||
conditions := make([]*metav1.Condition, 0, 6)
|
||||
applicationErrors := make([]error, 0)
|
||||
|
||||
clientSecretCondition, clientID, clientSecret, clientSecretErr := c.validateClientSecret(upstream.Spec.Client.SecretName)
|
||||
|
||||
Reference in New Issue
Block a user