Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions api/deepcopy/copy.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ type CopierFrom interface {
// Copy takes the fields from src and copies them into the target object.
//
// Calling this method with a nil receiver or a nil src may panic.
CopyFrom(src interface{})
CopyFrom(src any)
}

// Copy copies src into dst. dst and src must have the same type.
Expand All @@ -24,7 +24,7 @@ type CopierFrom interface {
//
// If the copy cannot be performed, this function will panic. Make sure to test
// types that use this function.
func Copy(dst, src interface{}) {
func Copy(dst, src any) {
switch dst := dst.(type) {
case *types.Any:
src := src.(*types.Any)
Expand Down
2 changes: 1 addition & 1 deletion api/genericresource/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"github.com/moby/swarmkit/v2/api"
)

func newParseError(format string, args ...interface{}) error {
func newParseError(format string, args ...any) error {
return fmt.Errorf("could not parse GenericResource: "+format, args...)
}

Expand Down
4 changes: 2 additions & 2 deletions api/storeobject.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func customIndexer(kind string, annotations *Annotations) (bool, [][]byte, error
return len(converted) != 0, converted, nil
}

func fromArgs(args ...interface{}) ([]byte, error) {
func fromArgs(args ...any) ([]byte, error) {
if len(args) != 1 {
return nil, fmt.Errorf("must provide only a single argument")
}
Expand All @@ -86,7 +86,7 @@ func fromArgs(args ...interface{}) ([]byte, error) {
return []byte(arg), nil
}

func prefixFromArgs(args ...interface{}) ([]byte, error) {
func prefixFromArgs(args ...any) ([]byte, error) {
val, err := fromArgs(args...)
if err != nil {
return nil, err
Expand Down
2 changes: 1 addition & 1 deletion ca/external.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ func makeExternalSignRequest(ctx context.Context, client *http.Client, url strin
return nil, errors.New("certificate signing request failed")
}

result, ok := apiResponse.Result.(map[string]interface{})
result, ok := apiResponse.Result.(map[string]any)
if !ok {
return nil, errors.Errorf("invalid result type: %T", apiResponse.Result)
}
Expand Down
2 changes: 1 addition & 1 deletion manager/allocator/allocator_test_suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -2056,7 +2056,7 @@ func isValidSubnet(t assert.TestingT, subnet string) bool {

type mockTester struct{}

func (m mockTester) Errorf(_ string, _ ...interface{}) {
func (m mockTester) Errorf(_ string, _ ...any) {
}

// Returns a timeout given whether we should expect a timeout: In the case where we do expect a timeout,
Expand Down
2 changes: 1 addition & 1 deletion manager/controlapi/ca_rotation.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
var minRootExpiration = 1 * helpers.OneYear

// determines whether an api.RootCA, api.RootRotation, or api.CAConfig has a signing key (local signer)
func hasSigningKey(a interface{}) bool {
func hasSigningKey(a any) bool {
switch b := a.(type) {
case *api.RootCA:
return len(b.CAKey) > 0
Expand Down
4 changes: 2 additions & 2 deletions manager/deallocator/deallocator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ func TestServiceDelete(t *testing.T) {
createDBObjects(t, s, service)

taskIDs := make([]string, taskCount)
tasks := make([]interface{}, taskCount)
tasks := make([]any, taskCount)
for i := 0; i < taskCount; i++ {
taskIDs[i] = "task" + strconv.Itoa(i+1)
tasks[i] = newTask(taskIDs[i], service)
Expand Down Expand Up @@ -329,7 +329,7 @@ func ensureNoDeallocatorEvent(t *testing.T, deallocator *Deallocator) {
}
}

func createDBObjects(t *testing.T, s *store.MemoryStore, objects ...interface{}) {
func createDBObjects(t *testing.T, s *store.MemoryStore, objects ...any) {
err := s.Update(func(tx store.Tx) (e error) {
for _, object := range objects {
switch typedObject := object.(type) {
Expand Down
8 changes: 4 additions & 4 deletions manager/dispatcher/dispatcher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ func TestAssignmentsSecretDriver(t *testing.T) {
}

var mux MockPluginClient
mux.HandleFunc(drivers.SecretsProviderAPI, func(body []byte) (interface{}, error) {
mux.HandleFunc(drivers.SecretsProviderAPI, func(body []byte) (any, error) {
var request drivers.SecretsProviderRequest
assert.NoError(t, json.Unmarshal(body, &request))
response := responses[request.SecretName]
Expand Down Expand Up @@ -1923,7 +1923,7 @@ func makeTasksAndDependenciesWithRedundantReferences(t *testing.T, nodeID string
return secrets, configs, resourceRefs, tasks
}

func taskSpecFromDependencies(dependencies ...interface{}) api.TaskSpec {
func taskSpecFromDependencies(dependencies ...any) api.TaskSpec {
var secretRefs []*api.SecretReference
var configRefs []*api.ConfigReference
var resourceRefs []api.ResourceReference
Expand Down Expand Up @@ -2367,7 +2367,7 @@ func (m *MockPlugin) ScopedPath(_ string) string {
return ""
}

type MockPluginHandlerFn func(argsJSON []byte) (interface{}, error)
type MockPluginHandlerFn func(argsJSON []byte) (any, error)

type MockPluginClient struct {
handlers map[string]MockPluginHandlerFn
Expand All @@ -2383,7 +2383,7 @@ func (mc *MockPluginClient) HandleFunc(method string, fn MockPluginHandlerFn) {
mc.handlers[method] = fn
}

func (mc *MockPluginClient) Call(method string, args, ret interface{}) error {
func (mc *MockPluginClient) Call(method string, args, ret any) error {
fn, ok := mc.handlers[method]
if !ok {
return fmt.Errorf("no handler for %s", method)
Expand Down
2 changes: 1 addition & 1 deletion manager/logbroker/broker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -819,7 +819,7 @@ func printLogMessages(msgs ...api.LogMessage) {
}

// newLogMessage is just a helper to build a new log message.
func newLogMessage(msgctx api.LogContext, format string, vs ...interface{}) api.LogMessage {
func newLogMessage(msgctx api.LogContext, format string, vs ...any) api.LogMessage {
return api.LogMessage{
Context: msgctx,
Timestamp: ptypes.MustTimestampProto(time.Now()),
Expand Down
4 changes: 2 additions & 2 deletions manager/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ func New(config *Config) (*Manager, error) {
// they are not automatically tested. If you modify them later, make _sure_
// that they are correct. If you add substantial side effects, abstract
// these out and test them!
unaryInterceptorWrapper := func(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error) {
unaryInterceptorWrapper := func(ctx context.Context, req any, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (any, error) {
// pass the call down into the grpc_prometheus interceptor
resp, err := grpc_prometheus.UnaryServerInterceptor(ctx, req, info, handler)
if err != nil {
Expand All @@ -272,7 +272,7 @@ func New(config *Config) (*Manager, error) {
return resp, err
}

streamInterceptorWrapper := func(srv interface{}, ss grpc.ServerStream, info *grpc.StreamServerInfo, handler grpc.StreamHandler) error {
streamInterceptorWrapper := func(srv any, ss grpc.ServerStream, info *grpc.StreamServerInfo, handler grpc.StreamHandler) error {
// we can't re-write a stream context, so don't bother creating a
// sub-context like in unary methods
// pass the call down into the grpc_prometheus interceptor
Expand Down
6 changes: 3 additions & 3 deletions manager/orchestrator/jobs/replicated/reconciler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ type uniqueSlotsMatcher struct {
duplicatedSlot uint64
}

func (u uniqueSlotsMatcher) Match(actual interface{}) (bool, error) {
func (u uniqueSlotsMatcher) Match(actual any) (bool, error) {
tasks, ok := actual.([]*api.Task)
if !ok {
return false, fmt.Errorf("actual is not []*api.Tasks{}")
Expand All @@ -45,11 +45,11 @@ func (u uniqueSlotsMatcher) Match(actual interface{}) (bool, error) {
return true, nil
}

func (u uniqueSlotsMatcher) FailureMessage(_ interface{}) string {
func (u uniqueSlotsMatcher) FailureMessage(_ any) string {
return fmt.Sprintf("expected tasks to have unique slots, but %v is duplicated", u.duplicatedSlot)
}

func (u uniqueSlotsMatcher) NegatedFailureMessage(_ interface{}) string {
func (u uniqueSlotsMatcher) NegatedFailureMessage(_ any) string {
return fmt.Sprintf("expected tasks to have duplicate slots")
}

Expand Down
2 changes: 1 addition & 1 deletion manager/orchestrator/testutils/testutils.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ func Expect(t *testing.T, watch chan events.Event, specifiers ...api.Event) {
}

// FatalStack logs the stacks of all goroutines and immediately fails the test.
func FatalStack(t *testing.T, msg string, args ...interface{}) {
func FatalStack(t *testing.T, msg string, args ...any) {
stack := make([]byte, 1024*1024)
stack = stack[:runtime.Stack(stack, true)]
t.Logf("%s\n", stack)
Expand Down
4 changes: 2 additions & 2 deletions manager/scheduler/nodeheap.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ func (h nodeMaxHeap) Less(i, j int) bool {
return h.lessFunc(&h.nodes[j], &h.nodes[i])
}

func (h *nodeMaxHeap) Push(x interface{}) {
func (h *nodeMaxHeap) Push(x any) {
h.nodes = append(h.nodes, x.(NodeInfo))
h.length++
}

func (h *nodeMaxHeap) Pop() interface{} {
func (h *nodeMaxHeap) Pop() any {
h.length--
// return value is never used
return nil
Expand Down
8 changes: 4 additions & 4 deletions manager/state/raft/wait.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (

type waitItem struct {
// channel to wait up the waiter
ch chan interface{}
ch chan any
// callback which is called synchronously when the wait is triggered
cb func()
// callback which is called to cancel a waiter
Expand All @@ -23,19 +23,19 @@ func newWait() *wait {
return &wait{m: make(map[uint64]waitItem)}
}

func (w *wait) register(id uint64, cb func(), cancel func()) <-chan interface{} {
func (w *wait) register(id uint64, cb func(), cancel func()) <-chan any {
w.l.Lock()
defer w.l.Unlock()
_, ok := w.m[id]
if !ok {
ch := make(chan interface{}, 1)
ch := make(chan any, 1)
w.m[id] = waitItem{ch: ch, cb: cb, cancel: cancel}
return ch
}
panic(fmt.Sprintf("duplicate id %x", id))
}

func (w *wait) trigger(id uint64, x interface{}) bool {
func (w *wait) trigger(id uint64, x any) bool {
w.l.Lock()
waitItem, ok := w.m[id]
delete(w.m, id)
Expand Down
18 changes: 9 additions & 9 deletions manager/state/store/extensions.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,36 +153,36 @@ func FindExtensions(tx ReadTx, by By) ([]*api.Extension, error) {

type extensionIndexerByID struct{}

func (indexer extensionIndexerByID) FromArgs(args ...interface{}) ([]byte, error) {
func (indexer extensionIndexerByID) FromArgs(args ...any) ([]byte, error) {
return api.ExtensionIndexerByID{}.FromArgs(args...)
}
func (indexer extensionIndexerByID) PrefixFromArgs(args ...interface{}) ([]byte, error) {
func (indexer extensionIndexerByID) PrefixFromArgs(args ...any) ([]byte, error) {
return api.ExtensionIndexerByID{}.PrefixFromArgs(args...)
}
func (indexer extensionIndexerByID) FromObject(obj interface{}) (bool, []byte, error) {
func (indexer extensionIndexerByID) FromObject(obj any) (bool, []byte, error) {
return api.ExtensionIndexerByID{}.FromObject(obj.(extensionEntry).Extension)
}

type extensionIndexerByName struct{}

func (indexer extensionIndexerByName) FromArgs(args ...interface{}) ([]byte, error) {
func (indexer extensionIndexerByName) FromArgs(args ...any) ([]byte, error) {
return api.ExtensionIndexerByName{}.FromArgs(args...)
}
func (indexer extensionIndexerByName) PrefixFromArgs(args ...interface{}) ([]byte, error) {
func (indexer extensionIndexerByName) PrefixFromArgs(args ...any) ([]byte, error) {
return api.ExtensionIndexerByName{}.PrefixFromArgs(args...)
}
func (indexer extensionIndexerByName) FromObject(obj interface{}) (bool, []byte, error) {
func (indexer extensionIndexerByName) FromObject(obj any) (bool, []byte, error) {
return api.ExtensionIndexerByName{}.FromObject(obj.(extensionEntry).Extension)
}

type extensionCustomIndexer struct{}

func (indexer extensionCustomIndexer) FromArgs(args ...interface{}) ([]byte, error) {
func (indexer extensionCustomIndexer) FromArgs(args ...any) ([]byte, error) {
return api.ExtensionCustomIndexer{}.FromArgs(args...)
}
func (indexer extensionCustomIndexer) PrefixFromArgs(args ...interface{}) ([]byte, error) {
func (indexer extensionCustomIndexer) PrefixFromArgs(args ...any) ([]byte, error) {
return api.ExtensionCustomIndexer{}.PrefixFromArgs(args...)
}
func (indexer extensionCustomIndexer) FromObject(obj interface{}) (bool, [][]byte, error) {
func (indexer extensionCustomIndexer) FromObject(obj any) (bool, [][]byte, error) {
return api.ExtensionCustomIndexer{}.FromObject(obj.(extensionEntry).Extension)
}
4 changes: 2 additions & 2 deletions manager/state/store/memory.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ func (s *MemoryStore) Close() error {
return s.queue.Close()
}

func fromArgs(args ...interface{}) ([]byte, error) {
func fromArgs(args ...any) ([]byte, error) {
if len(args) != 1 {
return nil, fmt.Errorf("must provide only a single argument")
}
Expand All @@ -192,7 +192,7 @@ func fromArgs(args ...interface{}) ([]byte, error) {
return []byte(arg), nil
}

func prefixFromArgs(args ...interface{}) ([]byte, error) {
func prefixFromArgs(args ...any) ([]byte, error) {
val, err := fromArgs(args...)
if err != nil {
return nil, err
Expand Down
14 changes: 7 additions & 7 deletions manager/state/store/nodes.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,11 @@ func FindNodes(tx ReadTx, by By) ([]*api.Node, error) {

type nodeIndexerByHostname struct{}

func (ni nodeIndexerByHostname) FromArgs(args ...interface{}) ([]byte, error) {
func (ni nodeIndexerByHostname) FromArgs(args ...any) ([]byte, error) {
return fromArgs(args...)
}

func (ni nodeIndexerByHostname) FromObject(obj interface{}) (bool, []byte, error) {
func (ni nodeIndexerByHostname) FromObject(obj any) (bool, []byte, error) {
n := obj.(*api.Node)

if n.Description == nil {
Expand All @@ -135,17 +135,17 @@ func (ni nodeIndexerByHostname) FromObject(obj interface{}) (bool, []byte, error
return true, []byte(strings.ToLower(n.Description.Hostname) + "\x00"), nil
}

func (ni nodeIndexerByHostname) PrefixFromArgs(args ...interface{}) ([]byte, error) {
func (ni nodeIndexerByHostname) PrefixFromArgs(args ...any) ([]byte, error) {
return prefixFromArgs(args...)
}

type nodeIndexerByRole struct{}

func (ni nodeIndexerByRole) FromArgs(args ...interface{}) ([]byte, error) {
func (ni nodeIndexerByRole) FromArgs(args ...any) ([]byte, error) {
return fromArgs(args...)
}

func (ni nodeIndexerByRole) FromObject(obj interface{}) (bool, []byte, error) {
func (ni nodeIndexerByRole) FromObject(obj any) (bool, []byte, error) {
n := obj.(*api.Node)

// Add the null character as a terminator
Expand All @@ -154,11 +154,11 @@ func (ni nodeIndexerByRole) FromObject(obj interface{}) (bool, []byte, error) {

type nodeIndexerByMembership struct{}

func (ni nodeIndexerByMembership) FromArgs(args ...interface{}) ([]byte, error) {
func (ni nodeIndexerByMembership) FromArgs(args ...any) ([]byte, error) {
return fromArgs(args...)
}

func (ni nodeIndexerByMembership) FromObject(obj interface{}) (bool, []byte, error) {
func (ni nodeIndexerByMembership) FromObject(obj any) (bool, []byte, error) {
n := obj.(*api.Node)

// Add the null character as a terminator
Expand Down
Loading