mirror of
https://github.com/vmware-tanzu/pinniped.git
synced 2026-09-20 15:04:34 +00:00
Enable 'makezero' and 'prealloc' linters, and require 'any' instead of 'interface{}'
Enforce importas: - go.pinniped.dev/generated/latest/apis/supervisor/config/v1alpha1 - go.pinniped.dev/generated/latest/apis/supervisor/idp/v1alpha1
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
// Copyright 2023 the Pinniped contributors. All Rights Reserved.
|
||||
// Copyright 2023-2024 the Pinniped contributors. All Rights Reserved.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Package idtransform defines upstream-to-downstream identity transformations which could be
|
||||
@@ -28,7 +28,7 @@ type IdentityTransformation interface {
|
||||
|
||||
// Source returns some representation of the original source code of the transformation, which is
|
||||
// useful for tests to be able to check that a compiled transformation came from the right source.
|
||||
Source() interface{}
|
||||
Source() any
|
||||
}
|
||||
|
||||
// TransformationPipeline is a list of identity transforms, which can be evaluated in order against some given input
|
||||
@@ -89,8 +89,8 @@ func (p *TransformationPipeline) Evaluate(ctx context.Context, username string,
|
||||
return accumulatedResult, nil
|
||||
}
|
||||
|
||||
func (p *TransformationPipeline) Source() []interface{} {
|
||||
result := []interface{}{}
|
||||
func (p *TransformationPipeline) Source() []any {
|
||||
result := []any{}
|
||||
for _, transform := range p.transforms {
|
||||
result = append(result, transform.Source())
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ func (a fakeNoopTransformer) Evaluate(_ctx context.Context, username string, gro
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (a fakeNoopTransformer) Source() interface{} {
|
||||
func (a fakeNoopTransformer) Source() any {
|
||||
return nil // not needed for this test
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ func (a fakeNilGroupTransformer) Evaluate(_ctx context.Context, username string,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (a fakeNilGroupTransformer) Source() interface{} {
|
||||
func (a fakeNilGroupTransformer) Source() any {
|
||||
return nil // not needed for this test
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ func (a fakeAppendStringTransformer) Evaluate(_ctx context.Context, username str
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (a fakeAppendStringTransformer) Source() interface{} {
|
||||
func (a fakeAppendStringTransformer) Source() any {
|
||||
return nil // not needed for this test
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@ func (a fakeDeleteUsernameAndGroupsTransformer) Evaluate(_ctx context.Context, _
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (a fakeDeleteUsernameAndGroupsTransformer) Source() interface{} {
|
||||
func (a fakeDeleteUsernameAndGroupsTransformer) Source() any {
|
||||
return nil // not needed for this test
|
||||
}
|
||||
|
||||
@@ -90,7 +90,7 @@ func (a fakeAuthenticationDisallowedTransformer) Evaluate(_ctx context.Context,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (a fakeAuthenticationDisallowedTransformer) Source() interface{} {
|
||||
func (a fakeAuthenticationDisallowedTransformer) Source() any {
|
||||
return nil // not needed for this test
|
||||
}
|
||||
|
||||
@@ -100,7 +100,7 @@ func (a fakeErrorTransformer) Evaluate(_ctx context.Context, _username string, _
|
||||
return &TransformationResult{}, errors.New("unexpected catastrophic error")
|
||||
}
|
||||
|
||||
func (a fakeErrorTransformer) Source() interface{} {
|
||||
func (a fakeErrorTransformer) Source() any {
|
||||
return nil // not needed for this test
|
||||
}
|
||||
|
||||
@@ -112,7 +112,7 @@ func (a fakeTransformerWithSource) Evaluate(_ctx context.Context, _username stri
|
||||
return nil, nil // not needed for this test
|
||||
}
|
||||
|
||||
func (a fakeTransformerWithSource) Source() interface{} {
|
||||
func (a fakeTransformerWithSource) Source() any {
|
||||
return a.source
|
||||
}
|
||||
|
||||
@@ -334,6 +334,6 @@ func TestTransformationSource(t *testing.T) {
|
||||
pipeline.AppendTransformation(transform)
|
||||
}
|
||||
|
||||
require.Equal(t, []interface{}{"foo", "bar", "baz"}, pipeline.Source())
|
||||
require.NotEqual(t, []interface{}{"foo", "something-else", "baz"}, pipeline.Source())
|
||||
require.Equal(t, []any{"foo", "bar", "baz"}, pipeline.Source())
|
||||
require.NotEqual(t, []any{"foo", "something-else", "baz"}, pipeline.Source())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user