github.com/smartcontractkit/chainlink-testing-framework/libs@v0.0.0-20240227141906-ec710b4eb1a3/config/overrides.go (about) 1 package config 2 3 import ( 4 "dario.cat/mergo" 5 ) 6 7 // MustConfigOverrideChainlinkVersion will override the chainlink image and version 8 // in property maps from the passed config. It will panic if the config is nil. 9 func MustConfigOverrideChainlinkVersion(config *ChainlinkImageConfig, target interface{}) { 10 if config == nil { 11 panic("[ChainlinkImageConfig] must be present") 12 } 13 if config.Image != nil && *config.Image != "" && config.Version != nil && *config.Version != "" { 14 if err := mergo.Merge(target, map[string]interface{}{ 15 "chainlink": map[string]interface{}{ 16 "image": map[string]interface{}{ 17 "image": *config.Image, 18 "version": *config.Version, 19 }, 20 }, 21 }, mergo.WithOverride); err != nil { 22 panic(err) 23 } 24 } 25 } 26 27 // MightConfigOverridePyroscope will override the pyroscope config in property maps 28 // from the passed config. If the config is nil, or the enabled flag is not set, or 29 // the key is not set, then this function will do nothing. 30 func MightConfigOverridePyroscopeKey(config *PyroscopeConfig, target interface{}) { 31 if config == nil || (config.Enabled == nil || !*config.Enabled) || (config.Key == nil || *config.Key == "") { 32 return 33 } 34 35 env := make(map[string]string) 36 env["CL_PYROSCOPE_AUTH_TOKEN"] = *config.Key 37 38 if err := mergo.Merge(target, map[string]interface{}{ 39 "env": env, 40 }, mergo.WithOverride); err != nil { 41 panic(err) 42 } 43 }