Remove unnecessary config.json keys

Change-type: patch
This commit is contained in:
Pagan Gazzard 2020-04-17 14:01:44 +01:00
parent fff87127ce
commit 913418bb37
11 changed files with 3 additions and 41 deletions

View File

@ -105,12 +105,9 @@ The `config.json` file should look something like this:
{
"applicationId": "2167", /* Id of the app this supervisor will run */
"apiKey": "supersecretapikey", /* The API key to provision the device on the balena API */
"userId": "141", /* User ID for the user who owns the app */
"username": "gh_pcarranzav", /* User name for the user who owns the app */
"deviceType": "intel-nuc", /* The device type corresponding to the test application */
"apiEndpoint": "https://api.balena-cloud.com", /* Endpoint for the balena API */
"deltaEndpoint": "https://delta.balena-cloud.com", /* Endpoint for the delta server to download Docker binary diffs */
"vpnEndpoint": "vpn.balena-cloud.com", /* Endpoint for the balena VPN server */
"listenPort": 48484, /* Listen port for the supervisor API */
"mixpanelToken": "aaaaaaaaaaaaaaaaaaaaaaaaaa", /* Mixpanel token to report events */
}

View File

@ -289,7 +289,6 @@ export class APIBinder {
'unmanaged',
'provisioned',
'apiTimeout',
'userId',
'deviceId',
]);
@ -307,9 +306,7 @@ export class APIBinder {
);
}
// TODO: When API supports it as per https://github.com/resin-io/hq/pull/949 remove userId
_.defaults(device, {
belongs_to__user: conf.userId,
is_managed_by__device: conf.deviceId,
uuid: deviceRegister.generateUniqueKey(),
registered_at: Math.floor(Date.now() / 1000),

View File

@ -54,7 +54,6 @@ export const fnSchema = {
return config
.getMany([
'uuid',
'userId',
'applicationId',
'apiKey',
'deviceApiKey',
@ -69,7 +68,6 @@ export const fnSchema = {
return {
uuid: conf.uuid,
applicationId: conf.applicationId,
userId: conf.userId,
deviceArch: conf.deviceArch,
deviceType: conf.deviceType,
provisioningApiKey: conf.apiKey,

View File

@ -46,14 +46,6 @@ export const schemaTypes = {
type: t.string,
default: 'unknown',
},
username: {
type: t.string,
default: NullOrUndefined,
},
userId: {
type: PermissiveNumber,
default: NullOrUndefined,
},
deviceId: {
type: PermissiveNumber,
default: NullOrUndefined,
@ -204,7 +196,6 @@ export const schemaTypes = {
// from the definitions above and still have the types work
uuid: t.union([t.string, NullOrUndefined]),
applicationId: t.union([PermissiveNumber, NullOrUndefined]),
userId: t.union([PermissiveNumber, NullOrUndefined]),
deviceType: t.string,
provisioningApiKey: t.union([t.string, NullOrUndefined]),
deviceApiKey: t.string,

View File

@ -39,16 +39,6 @@ export const schema = {
mutable: false,
removeIfNull: false,
},
username: {
source: 'config.json',
mutable: false,
removeIfNull: false,
},
userId: {
source: 'config.json',
mutable: false,
removeIfNull: false,
},
deviceId: {
source: 'config.json',
mutable: true,

View File

@ -63,7 +63,7 @@ describe('Config', () => {
});
it('does not allow setting an immutable field', async () => {
const promise = conf.set({ username: 'somebody else' });
const promise = conf.set({ deviceType: 'a different device type' });
// We catch it to avoid the unhandled error log
promise.catch(_.noop);
return expect(promise).to.be.rejected;

View File

@ -110,7 +110,6 @@ describe('ApiBinder', () => {
expect(balenaAPI.balenaBackend!.devices).to.deep.equal({
'1': {
id: 1,
user: conf.userId,
application: conf.applicationId,
uuid: conf.uuid,
device_type: conf.deviceType,

View File

@ -1,13 +1,9 @@
{
"applicationName": "supertestrpi3",
"applicationId": 78373,
"deviceType": "raspberrypi3",
"userId": 1001,
"username": "someone",
"appUpdatePollInterval": 3000,
"listenPort": 2345,
"vpnPort": 443,
"vpnEndpoint": "vpn.resin.io",
"registryEndpoint": "registry2.resin.io",
"deltaEndpoint": "https://delta.resin.io",
"mixpanelToken": "baz",

View File

@ -1 +1 @@
{"applicationName":"supertestrpi3","applicationId":78373,"deviceType":"raspberrypi3","userId":1001,"username":"someone","appUpdatePollInterval":3000,"listenPort":2345,"vpnPort":443,"apiEndpoint":"http://0.0.0.0:3000","vpnEndpoint":"vpn.resin.io","registryEndpoint":"registry2.resin.io","deltaEndpoint":"https://delta.resin.io","mixpanelToken":"baz","apiKey":"boo","version":"2.0.6+rev3.prod"}
{"applicationId":78373,"deviceType":"raspberrypi3","appUpdatePollInterval":3000,"listenPort":2345,"vpnPort":443,"apiEndpoint":"http://0.0.0.0:3000","registryEndpoint":"registry2.resin.io","deltaEndpoint":"https://delta.resin.io","mixpanelToken":"baz","apiKey":"boo","version":"2.0.6+rev3.prod"}

View File

@ -1 +1 @@
{"applicationName":"supertestrpi3","applicationId":78373,"deviceType":"raspberrypi3","userId":1001,"username":"someone","appUpdatePollInterval":3000,"listenPort":2345,"vpnPort":443,"apiEndpoint":"https://api.resin.io","vpnEndpoint":"vpn.resin.io","registryEndpoint":"registry2.resin.io","deltaEndpoint":"https://delta.resin.io","mixpanelToken":"baz","apiKey":"boo","version":"2.0.6+rev3.prod"}
{"applicationId":78373,"deviceType":"raspberrypi3","appUpdatePollInterval":3000,"listenPort":2345,"vpnPort":443,"apiEndpoint":"https://api.resin.io","registryEndpoint":"registry2.resin.io","deltaEndpoint":"https://delta.resin.io","mixpanelToken":"baz","apiKey":"boo","version":"2.0.6+rev3.prod"}

View File

@ -63,10 +63,7 @@ configIsUnchanged() {
if hasValueChanged "BOOT_MOUNTPOINT" "$BOOT_MOUNTPOINT" "$SUPERVISOR_CONTAINER_ENV_JSON" || \
hasValueChanged "REGISTRY_ENDPOINT" "$REGISTRY_ENDPOINT" "$SUPERVISOR_CONTAINER_ENV_JSON" || \
hasValueChanged "PUBNUB_SUBSCRIBE_KEY" "$PUBNUB_SUBSCRIBE_KEY" "$SUPERVISOR_CONTAINER_ENV_JSON" || \
hasValueChanged "PUBNUB_PUBLISH_KEY" "$PUBNUB_PUBLISH_KEY" "$SUPERVISOR_CONTAINER_ENV_JSON" || \
hasValueChanged "MIXPANEL_TOKEN" "$MIXPANEL_TOKEN" "$SUPERVISOR_CONTAINER_ENV_JSON" || \
hasValueChanged "DELTA_ENDPOINT" "$DELTA_ENDPOINT" "$SUPERVISOR_CONTAINER_ENV_JSON" || \
hasValueChanged "LED_FILE" "${LED_FILE}" "$SUPERVISOR_CONTAINER_ENV_JSON" || \
hasValueChanged "LISTEN_PORT" "$LISTEN_PORT" "$SUPERVISOR_CONTAINER_ENV_JSON" || \
hasValueChanged "SUPERVISOR_IMAGE" "${SUPERVISOR_IMAGE}:${SUPERVISOR_TAG}" "$SUPERVISOR_CONTAINER_ENV_JSON" || \
@ -97,10 +94,7 @@ runSupervisor() {
-e DOCKER_SOCKET=/var/run/balena-engine.sock \
-e "BOOT_MOUNTPOINT=$BOOT_MOUNTPOINT" \
-e "REGISTRY_ENDPOINT=$REGISTRY_ENDPOINT" \
-e "PUBNUB_SUBSCRIBE_KEY=$PUBNUB_SUBSCRIBE_KEY" \
-e "PUBNUB_PUBLISH_KEY=$PUBNUB_PUBLISH_KEY" \
-e "MIXPANEL_TOKEN=$MIXPANEL_TOKEN" \
-e "DELTA_ENDPOINT=$DELTA_ENDPOINT" \
-e "LED_FILE=${LED_FILE}" \
-e "LISTEN_PORT=$LISTEN_PORT" \
-e "SUPERVISOR_IMAGE=${SUPERVISOR_IMAGE}:${SUPERVISOR_TAG}" \