github.com/drone/runner-go@v1.12.0/environ/provider/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 provider 6 7 import "context" 8 9 // Combine returns a new combined environment provider, 10 // capable of sourcing environment variables from multiple 11 // providers. 12 func Combine(sources ...Provider) Provider { 13 return &combined{sources} 14 } 15 16 type combined struct { 17 sources []Provider 18 } 19 20 func (p *combined) List(ctx context.Context, in *Request) ([]*Variable, error) { 21 var out []*Variable 22 for _, source := range p.sources { 23 got, err := source.List(ctx, in) 24 if err != nil { 25 return nil, err 26 } 27 out = append(out, got...) 28 } 29 return out, nil 30 }