Skip to content

Commit f229142

Browse files
committed
Pluggable discovery upload user fields are now limited to 50 chars
1 parent f7dedb2 commit f229142

File tree

3 files changed

+29
-0
lines changed

3 files changed

+29
-0
lines changed

commands/upload/upload.go

+3
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,9 @@ func getUserFields(toolID string, platformRelease *cores.PlatformRelease) ([]*rp
102102

103103
for _, key := range keys {
104104
value := fields.Get(key)
105+
if len(value) > 50 {
106+
value = fmt.Sprintf("%s…", value[:49])
107+
}
105108
secretProp := fmt.Sprintf("%s.secret", key)
106109
secret, ok := fields.GetOk(secretProp)
107110
if !ok {

commands/upload/upload_test.go

+13
Original file line numberDiff line numberDiff line change
@@ -303,4 +303,17 @@ tools.arduino_ota.upload.field.password.secret=THIS_IS_NOT_A_BOOLEAN`))
303303
userFields, err = getUserFields("arduino_ota", platformRelease)
304304
require.Nil(t, userFields)
305305
require.EqualError(t, err, `parsing "tools.arduino_ota.upload.field.password.secret", property is not a boolean`)
306+
307+
props, err = properties.LoadFromBytes([]byte(`
308+
tools.arduino_ota.upload.field.some_field=This is a really long label that ideally must never be set by any platform
309+
`))
310+
require.NoError(t, err)
311+
platformRelease.Properties = props
312+
userFields, err = getUserFields("arduino_ota", platformRelease)
313+
require.NoError(t, err)
314+
require.Len(t, userFields, 1)
315+
require.Equal(t, userFields[0].ToolId, "arduino_ota")
316+
require.Equal(t, userFields[0].Name, "some_field")
317+
require.Equal(t, userFields[0].Label, "This is a really long label that ideally must nev…")
318+
require.False(t, userFields[0].Secret)
306319
}

docs/platform-specification.md

+13
Original file line numberDiff line numberDiff line change
@@ -972,6 +972,19 @@ tools.arduino_ota.upload.field.password.secret=true
972972
tools.arduino_ota.upload.pattern="{runtime.tools.arduinoOTA.path}/bin/arduinoOTA" -address {upload.port.address} -port 65280 -username "{upload.field.username} -password "{upload.field.password}" -sketch "{build.path}/{build.project_name}.bin"
973973
```
974974

975+
If a **FIELD_LABEL** is longer than 50 characters it will be truncated to 49 characters and an ellipsis (``) appended
976+
to it. For example this field:
977+
978+
```
979+
tools.arduino_ota.upload.field.some_field=This is a really long label that ideally must never be set by any platform
980+
```
981+
982+
will be shown to the user as:
983+
984+
```
985+
This is a really long label that ideally must nev…
986+
```
987+
975988
#### Upload verification
976989

977990
Upload verification can be enabled via the Arduino IDE's **File > Preferences > Verify code after upload** or

0 commit comments

Comments
 (0)