Defining an environment configuration in code view
Learn how to define an environment configuration in the code view.
Use the kind: environment configuration in a separate YAML file to define
environment-specific settings required during test runs. These settings include dynamic values such
as API keys, resource IDs, and other variables that often differ across environments like
development, staging, and production. Referencing these values externally helps you keep test files
clean and reduces duplication, especially when running the same test cases across multiple
stages.
This configuration supports defining multiple environment variables as key-value pairs. You can either specify the values directly in the file or reference them from your actual runtime environment. Although the configuration supports tagging variables as secrets, only non-secret values are currently supported during test runs. Structuring environment data this way allows you to reuse variable sets across test files, maintain consistency, and adapt quickly to changes in deployment conditions.
The following template and field descriptions guide you in setting up an environment configuration.
kind: environment
metadata:
name: Environment_Name # Unique name for the environment configuration
version: Version # Version of the environment configuration
tags:
- Tag1 # Add relevant tags for categorization
- Tag2
namespace: Namespace # Logical grouping for managing test resources
spec:
variables:
- key: Variable_Key # Specify the key for the variable
value: "${Variable_Name}" # Reference the environment variable
isSecret: true/false # Indicates if the variable is sensitive
In the template:
Replace Environment_Name, Version, Tag1,
Tag2, Namespace, Variable_Key, and
Variable_Name with the appropriate values for your specific configuration.
| Category | Field | Description |
|---|---|---|
kind |
Defines the type of configuration. In this case, it specifies that this configuration is for
an environment. |
|
metadata. Contains essential identifiers and organizational tags for the environment. |
name |
Specifies a name for the environment configuration. Use a meaningful name that clearly identifies its purpose. |
version |
Indicates the version of the environment configuration. Update this field whenever you change the environment setup. | |
tags |
Lists relevant tags for categorization. | |
namespace |
Defines the logical grouping for managing test resources. This field helps organize environments within a specific scope. | |
spec. Contains environment-specific settings, such as variables needed during API tests. Each variable can be set as a non-secret or secret, depending on security needs. |
variables |
Contains a list of key-value pairs that define the environment variables that are used in
your tests.
|
A sample configuration for environment kind is as follows:
kind: environment
metadata:
name: testEnvironment
version: 1.0.0
tags:
- payEnv
namespace: default
spec:
variables:
- key: "petid"
value: "13"
isSecret: false
- key: "apiKey"
value: '453-0002837546'
isSecret: false
In this example:
Metadataprovides an identifier for this environment configuration astestEnvironment, with version1.0.0.Variablessection defines two variables:petidwith a value of13andapiKeywith a value of453-0002837546. Both variables haveisSecretmarked asfalse, meaning that their values are not encoded and are accessible in plain text.