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

     1  package config
     2  
     3  import (
     4  	"os"
     5  	"sync"
     6  
     7  	"github.com/imdario/mergo"
     8  )
     9  
    10  const (
    11  	EnvVarPrefix = "TEST_"
    12  
    13  	EnvVarNoManifestUpdate            = "NO_MANIFEST_UPDATE"
    14  	EnvVarNoManifestUpdateDescription = "Skip updating manifest when connecting to the namespace"
    15  	EnvVarNoManifestUpdateExample     = "false"
    16  
    17  	EnvVarKeepEnvironments            = "KEEP_ENVIRONMENTS"
    18  	EnvVarKeepEnvironmentsDescription = "Should we keep environments on test completion"
    19  	EnvVarKeepEnvironmentsExample     = "NEVER|ALWAYS|ON_FAILURE"
    20  
    21  	EnvVarNamespace            = "ENV_NAMESPACE"
    22  	EnvVarNamespaceDescription = "Namespace name to connect to"
    23  	EnvVarNamespaceExample     = "chainlink-test-epic"
    24  
    25  	EnvVarJobImage            = "ENV_JOB_IMAGE"
    26  	EnvVarJobImageDescription = "Image to run as a job in k8s"
    27  	EnvVarJobImageExample     = "795953128386.dkr.ecr.us-west-2.amazonaws.com/core-integration-tests:v1.0"
    28  
    29  	EnvVarInsideK8s            = "ENV_INSIDE_K8S"
    30  	EnvVarInsideK8sDescription = "Internal variable to turn forwarding strategy off inside k8s, do not use"
    31  	EnvVarInsideK8sExample     = ""
    32  
    33  	// deprecated (use TOML config instead to pass the image)
    34  	EnvVarCLImage            = "CHAINLINK_IMAGE"
    35  	EnvVarCLImageDescription = "Chainlink image repository"
    36  	EnvVarCLImageExample     = "public.ecr.aws/chainlink/chainlink"
    37  
    38  	// deprecated (use TOML config instead to pass the version)
    39  	EnvVarCLTag            = "CHAINLINK_VERSION"
    40  	EnvVarCLTagDescription = "Chainlink image tag"
    41  	EnvVarCLTagExample     = "1.9.0"
    42  
    43  	EnvVarUser            = "CHAINLINK_ENV_USER"
    44  	EnvVarUserDescription = "Owner of an environment"
    45  	EnvVarUserExample     = "Satoshi"
    46  
    47  	EnvVarCLCommitSha            = "CHAINLINK_COMMIT_SHA"
    48  	EnvVarCLCommitShaDescription = "The sha of the commit that you're running tests on. Mostly used for CI"
    49  	EnvVarCLCommitShaExample     = "${{ github.sha }}"
    50  
    51  	EnvVarTestTrigger            = "TEST_TRIGGERED_BY"
    52  	EnvVarTestTriggerDescription = "How the test was triggered, either manual or CI."
    53  	EnvVarTestTriggerExample     = "CI"
    54  
    55  	EnvVarLogLevel            = "TEST_LOG_LEVEL"
    56  	EnvVarLogLevelDescription = "Environment logging level"
    57  	EnvVarLogLevelExample     = "info | debug | trace"
    58  
    59  	EnvVarDBURL            = "DATABASE_URL"
    60  	EnvVarDBURLDescription = "DATABASE_URL needed for component test. This is only necessary if testhelper methods are imported from core"
    61  	EnvVarDBURLExample     = "postgresql://postgres:node@localhost:5432/chainlink_test?sslmode=disable"
    62  
    63  	EnvVarSlackKey            = "SLACK_API_KEY"
    64  	EnvVarSlackKeyDescription = "The OAuth Slack API key to report tests results with"
    65  	EnvVarSlackKeyExample     = "xoxb-example-key"
    66  
    67  	EnvVarSlackChannel            = "SLACK_CHANNEL"
    68  	EnvVarSlackChannelDescription = "The Slack code for the channel you want to send the notification to"
    69  	EnvVarSlackChannelExample     = "C000000000"
    70  
    71  	EnvVarSlackUser            = "SLACK_USER"
    72  	EnvVarSlackUserDescription = "The Slack code for the user you want to notify"
    73  	EnvVarSlackUserExample     = "U000000000"
    74  
    75  	EnvVarToleration                 = "K8S_TOLERATION"
    76  	EnvVarTolerationsUserDescription = "Node roles to tolerate"
    77  	EnvVarTolerationsExample         = "foundations"
    78  
    79  	EnvVarNodeSelector                = "K8S_NODE_SELECTOR"
    80  	EnvVarNodeSelectorUserDescription = "Node role to deploy to"
    81  	EnvVarNodeSelectorExample         = "foundations"
    82  
    83  	EnvVarDetachRunner                = "DETACH_RUNNER"
    84  	EnvVarDetachRunnerUserDescription = "Should we detach the remote runner after starting a test using it"
    85  	EnvVarDetachRunnerExample         = "true"
    86  
    87  	EnvVarRemoteRunnerCpu                = "RR_CPU"
    88  	EnvVarRemoteRunnerCpuUserDescription = "The cpu limit and req for the remote runner"
    89  	EnvVarRemoteRunnerCpuExample         = "1000m"
    90  
    91  	EnvVarRemoteRunnerMem                = "RR_MEM"
    92  	EnvVarRemoteRunnerMemUserDescription = "The mem limit and req for the remote runner"
    93  	EnvVarRemoteRunnerMemExample         = "1024Mi"
    94  
    95  	EnvVarInternalDockerRepo            = "INTERNAL_DOCKER_REPO"
    96  	EnvVarInternalDockerRepoDescription = "Use internal docker repository for some images"
    97  	EnvVarInternalDockerRepoExample     = "public.ecr.aws"
    98  
    99  	EnvVarLocalCharts                = "LOCAL_CHARTS"
   100  	EnvVarLocalChartsUserDescription = "Use local charts from the CTF repository directly"
   101  	EnvVarLocalChartsExample         = "true"
   102  
   103  	EnvBase64ConfigOverride             = "BASE64_CONFIG_OVERRIDE"
   104  	EnvBase64ConfigOverriderDescription = "Base64-encoded TOML config (should contain at least chainlink image and version)"
   105  	EnvBase64ConfigOverrideExample      = "W0NoYWlubGlua0ltYWdlXQppbWFnZT0icHVibGljLmVjci5hd3MvY2hhaW5saW5rL2NoYWlubGluayIKdmVyc2lvbj0iMi43LjEtYXV0b21hdGlvbi0yMDIzMTEyNyIKCltBdXRvbWF0aW9uXQpbQXV0b21hdGlvbi5HZW5lcmFsXQpkdXJhdGlvbj0yMDAK"
   106  
   107  	EnvBase64NetworkConfig            = "BASE64_NETWORK_CONFIG"
   108  	EnvBase64NetworkConfigDescription = "Base64-encoded TOML network config with default RPC/WS endpoints and private keys"
   109  	EnvBase64NetworkConfigExample     = "Nope :-)"
   110  )
   111  
   112  var (
   113  	JSIIGlobalMu = &sync.Mutex{}
   114  )
   115  
   116  func MustMerge(targetVars interface{}, codeVars interface{}) {
   117  	if err := mergo.Merge(targetVars, codeVars, mergo.WithOverride); err != nil {
   118  		panic(err)
   119  	}
   120  }
   121  
   122  func MustEnvOverrideVersion(target interface{}) {
   123  	image := os.Getenv(EnvVarCLImage)
   124  	tag := os.Getenv(EnvVarCLTag)
   125  	if image != "" && tag != "" {
   126  		if err := mergo.Merge(target, map[string]interface{}{
   127  			"chainlink": map[string]interface{}{
   128  				"image": map[string]interface{}{
   129  					"image":   image,
   130  					"version": tag,
   131  				},
   132  			},
   133  		}, mergo.WithOverride); err != nil {
   134  			panic(err)
   135  		}
   136  	}
   137  }