Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: optional services #753

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/abstract-sql-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,13 @@ export const renameResourceField = (
};

export const renameVarResourcesName = (abstractSql: AbstractSqlModel) => {
for (const resource of ['device', 'application']) {
for (const resource of [
'device',
'application',
'device-installs-application-has-service name',
'application-has-service name',
'image-is part of-release',
]) {
renameResourceField(abstractSql, resource, 'config var name', 'name');
renameResourceField(abstractSql, resource, 'env var name', 'name');
}
Expand Down
36 changes: 33 additions & 3 deletions src/balena.sbvr
Original file line number Diff line number Diff line change
Expand Up @@ -346,10 +346,14 @@ Term: application
Term Form: service label
Database Table Name: service label

Fact type: service has name (Auth)
Fact type: service has env var name
Term Form: service environment variable
Database Table Name: service environment variable

Fact type: service has config var name
Term Form: service config variable
Database Table Name: service config variable

Fact type: application has tag key
Term Form: application tag
Database Table Name: application tag
Expand Down Expand Up @@ -380,10 +384,14 @@ Term: device
Term Form: service install
Database Table Name: service install

Fact type: service install has name (Auth)
Fact type: service install has env var name
Term Form: device service environment variable
Database Table Name: device service environment variable

Fact type: service install has config var name
Term Form: device service config variable
Database Table Name: device service config variable

Fact type: device has tag key
Term Form: device tag
Database Table Name: device tag
Expand All @@ -404,10 +412,14 @@ Fact type: image is part of release
Term Form: image label
Database Table Name: image label

Fact type: release image has name (Auth)
Fact type: release image has env var name
Term Form: image environment variable
Database Table Name: image environment variable

Fact type: release image has config var name
Term Form: image config variable
Database Table Name: image config variable

Fact type: user (Auth) is member of organization
Synonymous Form: organization includes user (Auth)
Database Table Name: organization membership
Expand Down Expand Up @@ -711,6 +723,12 @@ Fact type: service environment variable has value
Necessity: each service environment variable has exactly one value.


-- service config variable

Fact type: service config variable has value
Necessity: each service config variable has exactly one value.


-- image

Fact type: image has start timestamp
Expand Down Expand Up @@ -774,12 +792,24 @@ Fact type: image environment variable has value
Necessity: each image environment variable has exactly one value.


-- image config variable

Fact type: image config variable has value
Necessity: each image config variable has exactly one value.


-- device service environment variable

Fact type: device service environment variable has value
Necessity: each device service environment variable has exactly one value.


-- device service config variable

Fact type: device service config variable has value
Necessity: each device service config variable has exactly one value.


-- application tag

Fact type: application tag has value
Expand Down
15 changes: 15 additions & 0 deletions src/features/device-state/routes/state-get-v2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
getStateDelayingEmpty,
getConfig,
getStateEventAdditionalFields,
EnvVarList,
} from '../state-get-utils';
import { sbvrUtils } from '@balena/pinejs';
import { events } from '..';
Expand Down Expand Up @@ -101,6 +102,20 @@ function buildAppFromRelease(
}
const svc = si.service[0];

const findDontRunVar = (vars: EnvVarList) =>
vars.find(
({ name }) => name === 'xBALENA_DONT_RUN_THIS_SERVICE_THING_THINGY',
);
const dontRunVar =
findDontRunVar(si.device_service_environment_variable) ??
findDontRunVar(svc.service_environment_variable) ??
findDontRunVar(ipr.image_environment_variable);
const dontRunThisService = dontRunVar?.value === 'true';

if (dontRunThisService) {
continue;
}

const environment: Dictionary<string> = {};
varListInsert(ipr.image_environment_variable, environment);
varListInsert(application.application_environment_variable, environment);
Expand Down
3 changes: 3 additions & 0 deletions src/features/vars-schema/hooks/config-var-validation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ const configVarHook: hooks.Hooks = {
for (const resource of [
'application_config_variable',
'device_config_variable',
'service_config_variable',
'device_service_config_variable',
'image_config_variable',
]) {
for (const method of ['POST', 'PATCH', 'PUT'] as const) {
hooks.addPureHook(method, 'resin', resource, configVarHook);
Expand Down
Loading