github.com/blend/go-sdk@v1.20240719.1/configutil/config_options.go (about) 1 /* 2 3 Copyright (c) 2024 - Present. Blend Labs, Inc. All rights reserved 4 Use of this source code is governed by a MIT license that can be found in the LICENSE file. 5 6 */ 7 8 package configutil 9 10 import ( 11 "context" 12 "io" 13 14 "github.com/blend/go-sdk/env" 15 ) 16 17 // ConfigOptions are options built for reading configs. 18 type ConfigOptions struct { 19 Log Logger 20 Context context.Context 21 Contents []ConfigContents 22 FilePaths []string 23 Env env.Vars 24 } 25 26 // ConfigContents are literal contents to read from. 27 type ConfigContents struct { 28 Ext string 29 Contents io.Reader 30 } 31 32 // Background yields a context for a config options set. 33 func (co ConfigOptions) Background() context.Context { 34 var background context.Context 35 if co.Context != nil { 36 background = co.Context 37 } else { 38 background = context.Background() 39 } 40 41 background = WithConfigPaths(background, co.FilePaths) 42 background = env.WithVars(background, co.Env) 43 return background 44 }