Skip to content

Commit

Permalink
Make application name optional in the schema, and stop adding it to n…
Browse files Browse the repository at this point in the history
…ew config

Change-type: minor
  • Loading branch information
Page- committed Apr 13, 2020
1 parent 15d4d43 commit 2ce6676
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 27 deletions.
3 changes: 0 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ Documentation
```js
config = deviceConfig.generate
application:
app_name: 'HelloWorldApp'
id: 18
device_type: 'raspberry-pi'
user:
Expand All @@ -75,7 +74,6 @@ console.log(config)
```js
config = deviceConfig.generate
application:
app_name: 'HelloWorldApp'
id: 18
device_type: 'raspberry-pi2'
deviceType: 'raspberrypi3'
Expand Down Expand Up @@ -115,7 +113,6 @@ console.log(config)
```js
config = deviceConfig.generate
application:
app_name: 'HelloWorldApp'
id: 18
device_type: 'raspberry-pi'
user:
Expand Down
4 changes: 0 additions & 4 deletions lib/config.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ schema = require('./schema')
# @example
# config = deviceConfig.generate
# application:
# app_name: 'HelloWorldApp'
# id: 18
# device_type: 'raspberry-pi'
# user:
Expand All @@ -59,7 +58,6 @@ schema = require('./schema')
# @example
# config = deviceConfig.generate
# application:
# app_name: 'HelloWorldApp'
# id: 18
# device_type: 'raspberry-pi2'
# deviceType: 'raspberrypi3'
Expand All @@ -86,7 +84,6 @@ exports.generate = (options, params = {}) ->
vpnPort: 443

config =
applicationName: options.application.app_name
applicationId: options.application.id
deviceType: options.deviceType or options.application.device_type

Expand Down Expand Up @@ -131,7 +128,6 @@ exports.generate = (options, params = {}) ->
# @example
# config = deviceConfig.generate
# application:
# app_name: 'HelloWorldApp'
# id: 18
# device_type: 'raspberry-pi'
# user:
Expand Down
3 changes: 2 additions & 1 deletion lib/schema.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,11 @@ _ = require('lodash')
###
module.exports =
properties:
# Included for backwards compatibility - it does not exist in modern config files
applicationName:
description: 'application name'
type: 'string'
required: true
required: false
allowEmpty: false
applicationId:
description: 'application id'
Expand Down
20 changes: 1 addition & 19 deletions tests/config.spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ describe 'Device Config:', ->
it 'should pass validation', ->
config = deviceConfig.generate
application:
app_name: 'HelloWorldApp'
id: 18
device_type: 'raspberry-pi'
user:
Expand All @@ -35,7 +34,6 @@ describe 'Device Config:', ->
it 'should default appUpdatePollInterval to 1 second', ->
config = deviceConfig.generate
application:
app_name: 'HelloWorldApp'
id: 18
device_type: 'raspberry-pi'
user:
Expand All @@ -58,7 +56,6 @@ describe 'Device Config:', ->
it 'should default to the application device type when an explicit one is not provided', ->
config = deviceConfig.generate
application:
app_name: 'HelloWorldApp'
id: 18
device_type: 'raspberry-pi2'
user:
Expand All @@ -83,7 +80,6 @@ describe 'Device Config:', ->
it 'should use the provided device type instead of the application one', ->
config = deviceConfig.generate
application:
app_name: 'HelloWorldApp'
id: 18
device_type: 'raspberry-pi2'
deviceType: 'raspberrypi3'
Expand All @@ -109,7 +105,6 @@ describe 'Device Config:', ->
it 'should include files section if no version is given', ->
config = deviceConfig.generate
application:
app_name: 'HelloWorldApp'
id: 18
device_type: 'raspberry-pi'
user:
Expand All @@ -132,7 +127,6 @@ describe 'Device Config:', ->
it 'should include files and connectivity sections if the given version is < 2.0.0', ->
config = deviceConfig.generate
application:
app_name: 'HelloWorldApp'
id: 18
device_type: 'raspberry-pi'
user:
Expand All @@ -158,7 +152,6 @@ describe 'Device Config:', ->
it 'should not include files or connectivity sections if the given version is >= 2.0.0', ->
config = deviceConfig.generate
application:
app_name: 'HelloWorldApp'
id: 18
device_type: 'raspberry-pi'
user:
Expand All @@ -184,7 +177,6 @@ describe 'Device Config:', ->
it 'should default appUpdatePollInterval to 1 second if NaN', ->
config = deviceConfig.generate
application:
app_name: 'HelloWorldApp'
id: 18
device_type: 'raspberry-pi'
user:
Expand All @@ -208,7 +200,6 @@ describe 'Device Config:', ->
it 'should default vpnPort to 443', ->
config = deviceConfig.generate
application:
app_name: 'HelloWorldApp'
id: 18
device_type: 'raspberry-pi'
user:
Expand All @@ -230,7 +221,6 @@ describe 'Device Config:', ->
it 'should handle wifi configuration', ->
config = deviceConfig.generate
application:
app_name: 'HelloWorldApp'
id: 18
device_type: 'raspberry-pi'
user:
Expand All @@ -255,7 +245,6 @@ describe 'Device Config:', ->
it 'should handle multiple network configurations', ->
config = deviceConfig.generate
application:
app_name: 'HelloWorldApp'
id: 18
device_type: 'raspberry-pi'
user:
Expand Down Expand Up @@ -289,7 +278,6 @@ describe 'Device Config:', ->
it 'should parse vpnPort as an integer automatically', ->
config = deviceConfig.generate
application:
app_name: 'HelloWorldApp'
id: 18
device_type: 'raspberry-pi'
user:
Expand All @@ -315,7 +303,6 @@ describe 'Device Config:', ->
m.chai.expect ->
deviceConfig.generate
application:
app_name: 'HelloWorldApp'
id: 18
device_type: 'raspberry-pi'
user:
Expand All @@ -340,7 +327,6 @@ describe 'Device Config:', ->
m.chai.expect ->
deviceConfig.generate
application:
app_name: 'HelloWorldApp'
id: 18
device_type: 'raspberry-pi'
user:
Expand All @@ -366,7 +352,6 @@ describe 'Device Config:', ->
m.chai.expect ->
config = deviceConfig.generate
application:
app_name: 'HelloWorldApp'
id: 18
device_type: 'raspberry-pi'
user:
Expand All @@ -393,7 +378,6 @@ describe 'Device Config:', ->
m.chai.expect ->
deviceConfig.generate
application:
id: 18
device_type: 'raspberry-pi'
user:
id: 7
Expand All @@ -408,12 +392,11 @@ describe 'Device Config:', ->
delta: 'https://delta.resin.io'
,
network: 'ethernet'
.to.throw('Validation: applicationName is required')
.to.throw('Validation: applicationId is required')

it 'should throw an error if the config json contains extra properties', ->
config = deviceConfig.generate
application:
app_name: 'HelloWorldApp'
id: 18
device_type: 'raspberry-pi'
user:
Expand All @@ -440,7 +423,6 @@ describe 'Device Config:', ->
it 'should allow balenaRootCA to be undefined', ->
config = deviceConfig.generate
application:
app_name: 'HelloWorldApp'
id: 18
device_type: 'raspberry-pi'
user:
Expand Down

0 comments on commit 2ce6676

Please sign in to comment.