github.com/smartcontractkit/chainlink-testing-framework/libs@v0.0.0-20240227141906-ec710b4eb1a3/k8s/examples/simple_toml/env_toml_config.go (about)

     1  package main
     2  
     3  import (
     4  	ctf_config "github.com/smartcontractkit/chainlink-testing-framework/libs/config"
     5  	"github.com/smartcontractkit/chainlink-testing-framework/libs/k8s/environment"
     6  	"github.com/smartcontractkit/chainlink-testing-framework/libs/k8s/pkg/helm/chainlink"
     7  	"github.com/smartcontractkit/chainlink-testing-framework/libs/k8s/pkg/helm/ethereum"
     8  	"github.com/smartcontractkit/chainlink-testing-framework/libs/k8s/pkg/helm/mockserver"
     9  	mockservercfg "github.com/smartcontractkit/chainlink-testing-framework/libs/k8s/pkg/helm/mockserver-cfg"
    10  	"github.com/smartcontractkit/chainlink-testing-framework/libs/utils/ptr"
    11  )
    12  
    13  func main() {
    14  	// in actual implementation here you should read the config from TOML file instead of creating structs manually
    15  	chainlinkConfig := ctf_config.ChainlinkImageConfig{
    16  		Image:   ptr.Ptr("public.ecr.aws/chainlink/chainlink"),
    17  		Version: ptr.Ptr("v2.8.0"),
    18  	}
    19  
    20  	pyroscope := ctf_config.PyroscopeConfig{
    21  		Enabled: ptr.Ptr(false),
    22  	}
    23  
    24  	config := struct {
    25  		Chainlink ctf_config.ChainlinkImageConfig
    26  		Pyroscope ctf_config.PyroscopeConfig
    27  	}{
    28  		Chainlink: chainlinkConfig,
    29  		Pyroscope: pyroscope,
    30  	}
    31  
    32  	var overrideFn = func(_ interface{}, target interface{}) {
    33  		ctf_config.MustConfigOverrideChainlinkVersion(&chainlinkConfig, target)
    34  		ctf_config.MightConfigOverridePyroscopeKey(&pyroscope, target)
    35  	}
    36  
    37  	err := environment.New(&environment.Config{
    38  		NamespacePrefix:   "ztest",
    39  		KeepConnection:    true,
    40  		RemoveOnInterrupt: true,
    41  	}).
    42  		AddHelm(mockservercfg.New(nil)).
    43  		AddHelm(mockserver.New(nil)).
    44  		AddHelm(ethereum.New(nil)).
    45  		AddHelm(chainlink.NewWithOverride(0, map[string]interface{}{
    46  			"replicas": 1,
    47  		}, &config, overrideFn)).
    48  		Run()
    49  	if err != nil {
    50  		panic(err)
    51  	}
    52  }