From aeb96aa807fea81f2e2aa4e3881bfb55b75b8618 Mon Sep 17 00:00:00 2001 From: Rich Bayliss Date: Thu, 28 Feb 2019 11:32:36 +0000 Subject: [PATCH] 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 Connects-to: #847 --- src/compose/types/service.ts | 1 + src/compose/utils.ts | 1 + src/config/functions.ts | 1 + src/config/schema-type.ts | 1 + 4 files changed, 4 insertions(+) diff --git a/src/compose/types/service.ts b/src/compose/types/service.ts index cc46d3b1..81fabe29 100644 --- a/src/compose/types/service.ts +++ b/src/compose/types/service.ts @@ -188,6 +188,7 @@ export interface DeviceMetadata { version: string; deviceType: string; deviceApiKey: string; + apiEndpoint: string; listenPort: number; apiSecret: string; supervisorApiHost: string; diff --git a/src/compose/utils.ts b/src/compose/utils.ts index 7fce3041..33f56c26 100644 --- a/src/compose/utils.ts +++ b/src/compose/utils.ts @@ -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'])) { diff --git a/src/config/functions.ts b/src/config/functions.ts index 9ace79d1..5f444cc9 100644 --- a/src/config/functions.ts +++ b/src/config/functions.ts @@ -76,6 +76,7 @@ export const fnSchema = { 'listenPort', 'name', 'apiSecret', + 'apiEndpoint', 'deviceApiKey', 'version', 'deviceType', diff --git a/src/config/schema-type.ts b/src/config/schema-type.ts index f457b6d1..6b1223f9 100644 --- a/src/config/schema-type.ts +++ b/src/config/schema-type.ts @@ -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]),