github.com/drone/runner-go@v1.12.0/registry/combine.go (about) 1 // Copyright 2019 Drone.IO Inc. All rights reserved. 2 // Use of this source code is governed by the Polyform License 3 // that can be found in the LICENSE file. 4 5 package registry 6 7 import ( 8 "context" 9 10 "github.com/drone/drone-go/drone" 11 ) 12 13 // Combine returns a new combined registry provider, capable of 14 // sourcing registry credentials from multiple providers. 15 func Combine(sources ...Provider) Provider { 16 return &combined{sources} 17 } 18 19 type combined struct { 20 sources []Provider 21 } 22 23 func (p *combined) List(ctx context.Context, in *Request) ([]*drone.Registry, error) { 24 var out []*drone.Registry 25 for _, source := range p.sources { 26 list, err := source.List(ctx, in) 27 if err != nil { 28 return nil, err 29 } 30 out = append(out, list...) 31 } 32 return out, nil 33 }