feature: Add BALENA_API_URL environment variable when using the balena-api feature label

When using the label `io.balena.features.balena-api` the supervisor will inject 2 environment
variables into the container:
- BALENA_API_KEY
- BALENA_API_URL

This allows the container to access the currently associated API using the KEY.

Change-type: patch
Signed-off-by: Rich Bayliss <rich@balena.io>
Connects-to: #847
This commit is contained in:
Rich Bayliss 2019-02-28 11:32:36 +00:00
parent 50d2df73a1
commit aeb96aa807
No known key found for this signature in database
GPG Key ID: E53C4B4D18499E1A
4 changed files with 4 additions and 0 deletions

View File

@ -188,6 +188,7 @@ export interface DeviceMetadata {
version: string;
deviceType: string;
deviceApiKey: string;
apiEndpoint: string;
listenPort: number;
apiSecret: string;
supervisorApiHost: string;

View File

@ -357,6 +357,7 @@ export function addFeaturesFromLabels(
if (checkTruthy(service.config.labels['io.balena.features.balena-api'])) {
setEnvVariables('API_KEY', options.deviceApiKey);
setEnvVariables('API_URL', options.apiEndpoint);
}
if (checkTruthy(service.config.labels['io.balena.features.supervisor-api'])) {

View File

@ -76,6 +76,7 @@ export const fnSchema = {
'listenPort',
'name',
'apiSecret',
'apiEndpoint',
'deviceApiKey',
'version',
'deviceType',

View File

@ -218,6 +218,7 @@ export const schemaTypes = {
name: t.string,
apiSecret: t.union([t.string, NullOrUndefined]),
deviceApiKey: t.string,
apiEndpoint: t.string,
version: t.string,
deviceType: t.string,
osVersion: t.union([t.string, NullOrUndefined]),