Configuration #
You can set configurations at the engine level or the SDK level.
Engine configuration #
Pragma Engine uses a list of configuration files at startup to define environment and connection details for each part of your game’s development and release cycle. Your configuration files are passed as a list of files read from disk. Pragma Engine periodically polls your configuration files for changes and reloads them without requiring you to restart the engine.
Configuration overrides and application #
With Pragma Engine you can define a list of common configuration files that are shared between all of your engine deployments. You can also define code-level defaults for development or production environments. To view your configuration files and environments, see the pragma-engine/platform/5-ext/config
folder.
Pragma Engine applies configurations in order, starting with code-level defaults, then each YAML file provided left to right. When applying configurations, Pragma Engine merges ConfigMaps
. You can choose to delete a ConfigMaps
entry by setting the value of a key to NULL
.
As a best practice, organize your YAML files with as little overlap as possible. Minimal overlap makes organizing sets of configurations per environment easier.
Dynamic configuration #
The platform periodically checks your config files for changes and reloads them if changes are found. If you’ve made changes that can’t be dynamically loaded, such as changing a database host, you must restart Pragma Engine.
Secret encryption #
For security, you should encrypt secret values such as API keys, passwords, and credentials before they are stored in your configuration files. You can use the Pragma Homebase API to encrypt and decrypt secret values in your environment before putting them in your configuration files.
All secrets must be encrypted and decrypted per shard. Shards use different encryption keys.
Encrypt #
- Connect to the VPN using the
*.ovpn
file provided to you during onboarding. - Navigate to your Homebase API URL. For example:
https://api.homebase.<studioname>.pragmaengine.com/
. - Choose
/secrets/encryptV1
. - Enter the following values in the request body:
shardId
- The name of the shard you are encrypting a value for.titleId
- The working title of your game that uses the secret.value
- The secret you’re encrypting.
Your encrypted secret will appear below in the Responses section.
Decrypt #
- Connect to the VPN using the
*.ovpn
file provided to you during onboarding. - Navigate to your Homebase API URL. For example:
https://api.homebase.<studioname>.pragmaengine.com/
. - Choose
/secrets/decryptV1
. - Enter the following values in the request body:
shardId
- The name of the shard you are decrypting a value for.titleId
- The working title of your game that uses the secret.value
- The secret you’re decrypting.
Custom service encryption #
To use encrypted values in your custom services, do the following:
- add an encrypted string to your service configuration Kotlin file
- add the
getDecryptedValue
function to your custom service - add the encrypted values to your configuration file.
The following is an example of a service configuration Kotlin file with an encrypted string.
package pragma.account.config
import pragma.config.ConfigBackendModeFactory
import pragma.config.EncryptedString
import pragma.config.PluginConfig
import pragma.settings.BackendType
class TwitchIdProviderConfig private constructor(type: BackendType) : PluginConfig<TwitchIdProviderConfig>(type) {
override val description = "Twitch Id Provider configuration."
var clientSecret by types.encryptedString("your app's secret key (provided by Twitch)")
var clientId by types.string("your app's id (provided by Twitch)")
...
}
To decrypt the private key, use the getDecryptedValue
function in your service.
var formData = parametersOf(
"client_id" to listOf(config.clientId), "client_secret" to listOf(config.clientSecret.getDecryptedValue())
)
The following is an example configuration YAML file for the above encrypted values in the TwitchIdProvider
service.
SDK configuration #
There are several ways to set configuration values for the Pragma SDK using Unreal. The following options are listed in order of priority, with each option overriding the ones below it.
In most cases, these values can be overriden at runtime if the config is changed and reloaded on disk.