Commit Graph

62 Commits

Author SHA1 Message Date
Mateusz Filipowicz
f396b2f712 chore: improve logging and add trace logging with --trace flag 2025-02-07 17:42:05 +01:00
Mateusz Filipowicz
399c5cde86 ci: apply permissions and linting 2025-02-07 17:42:05 +01:00
Mateusz Filipowicz
2cfed99cf5 fix: arbitrary file access during archive extraction
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
2025-02-07 17:42:05 +01:00
Mateusz Filipowicz
d8f38a84e8 chore: applying linter fixes 2025-02-07 15:41:34 +01:00
Mateusz Filipowicz
f794153790 feat: write used latest Unifi version to .unifi-version file to be used as marker 2025-02-07 15:41:34 +01:00
Mateusz Filipowicz
c393dcbe71 fix: WAN network support was broken 2025-02-07 15:40:42 +01:00
Mateusz Filipowicz
3fda37369e feat: removed -latest flag and instead support latest version marker, refactor (#233)
* feat: remove -latest flag and instead support latest version marker

* refactor: move determining unifi version, download URL and downloading resources and field definitions to dedicated files

* refactor: move writing version file to version.go file

* refactor: move code generation code to dedicated generator.go file

* chore: fix linting issues

* chore: add version tests
2025-01-07 12:10:23 +11:00
Mateusz Filipowicz
bee7bea744 feat: improve logging of code generator, including debug log option (#232) 2025-01-02 11:30:34 +11:00
Joshua Spence
7ebc6da3f8 Enable more golangci-lint rules (#227)
* WIP

* Enable `paralleltest` linter

* Enable `perfsprint` linter
2024-11-22 17:37:44 +11:00
dependabot[bot]
7af621d15f Bump github.com/golangci/golangci-lint from 1.55.2 to 1.62.0 (#224)
* Bump github.com/golangci/golangci-lint from 1.55.2 to 1.62.0

Bumps [github.com/golangci/golangci-lint](https://github.com/golangci/golangci-lint) from 1.55.2 to 1.62.0.
- [Release notes](https://github.com/golangci/golangci-lint/releases)
- [Changelog](https://github.com/golangci/golangci-lint/blob/master/CHANGELOG.md)
- [Commits](https://github.com/golangci/golangci-lint/compare/v1.55.2...v1.62.0)

---
updated-dependencies:
- dependency-name: github.com/golangci/golangci-lint
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

* Linter fixes

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Josh Spence <jspence@anduril.com>
2024-11-22 10:43:58 +11:00
Joshua Spence
206f4be940 Make golangci-lint more strict (#150)
* Reformat some YAML files

* Make `golangci-lint` more strict
2023-06-23 09:00:12 +10:00
Joshua Spence
97b562a6d2 Improvements to field generation (#137)
* Remove `no-embedded-types` flag

We don't use this.

* Use `fw-download.ubnt.com`

* Return firmware download URL from `latestUnifiVersion`

* Don't use version metadata
2023-05-26 15:29:07 +10:00
Joshua Spence
dd2fd56a6f Add more device fields (#111)
These fields will be used to improve acceptance tests.
2023-02-28 20:20:02 +11:00
Michon van Dooren
3add31c46b Don't omitempty Device.PortOverrides (#104) 2023-02-28 09:35:41 +11:00
Joshua Spence
6ada9e4e8e Fix lint 2023-02-23 14:16:28 +11:00
Paul Tyng
49ed8b85a7 fix compile error 2022-10-31 15:53:30 -04:00
Paul Tyng
6de33139b5 change stp_priority to numberOrString 2022-10-31 15:48:42 -04:00
Paul Tyng
e7f16ff6c4 lint issues 2022-10-22 21:02:27 -04:00
Paul Tyng
0552712b3b Always send schedule 2022-10-22 21:00:33 -04:00
Paul Tyng
887fae8168 handle omitted is true bools 2022-10-19 20:35:58 -04:00
jeanluc
1ac863de1f Fix type of lte_ext_ant/lte_poe fields (#89) 2022-08-10 11:34:05 +10:00
Joshua Spence
621d0e78f7 Don't set omitempty on mdns_enabled (#74) 2022-05-16 14:43:17 +10:00
Joshua Spence
09e0556344 Add back mdns_enabled (#73) 2022-05-16 13:56:45 +10:00
Joshua Spence
d2a3d064ac Fix SettingGlobalAp (#71)
Variable names (or struct fields) cannot start with a number.
2022-05-12 13:48:20 +10:00
Oskar
3e7bd072ea Omit empty NetworkID in account resource (#59)
* Omit empty NetworkID in account

* Run `go generate`

* Fix tests

Co-authored-by: Joshua Spence <josh@joshuaspence.com>
2022-01-31 15:58:42 +11:00
Joshua Spence
124f349da4 Format generated golang with go/format (#48) 2021-09-24 13:17:25 +10:00
Joshua Spence
8d4ca5f389 Revert "Add controller version to generated files" (#47)
This reverts commit 13d5677bf3.
2021-09-24 07:21:34 +10:00
Joshua Spence
0cb7d3e514 Add AdoptDevice and ForgetDevice methods (#45)
* Add `AdoptDevice` and `ForgetDevice` methods

* Address comments
2021-09-17 11:16:56 +10:00
Paul Tyng
13d5677bf3 Add controller version to generated files 2021-08-31 09:02:23 -04:00
Johannes Heck
4e9d935af2 fix Ht fieldType for device import 2021-08-18 16:10:47 -04:00
Joshua Spence
e27afc6e32 Add --latest flag
Allow using the latest version of the Unifi controller with `--latest`.
2021-08-11 11:40:15 +10:00
Joshua Spence
8f8e19eb2a Don't commit intermediate files
Don't commit the extracted JSON files as well only need the generated `*.generated.go` files.
2021-08-11 11:40:15 +10:00
Kurt McAlpine
7081791f4f Export fields on SettingMgmtXSshKeys (#41) 2021-07-05 14:51:44 +10:00
Joshua Spence
693795b5f0 Fix failing test 2021-06-29 17:43:00 -04:00
Joshua Spence
64a73cdd4b Fix linter issues 2021-06-29 17:43:00 -04:00
Joshua Spence
2f7eee3a6a Add dev_id_override to user 2021-06-18 15:39:41 -04:00
Joshua Spence
dd685c0447 Fix type of x_ssh_keys
The `unifi_settings_mgmt` resource fails for me with the following error:

```
Error: unable to decode body: GET s/default/get/setting/mgmt unable to unmarshal alias: json: cannot unmarshal object into Go struct field .x_ssh_keys of type string
```

My `x_ssh_keys` looks like this:

```
[
  {
    "name": "Laptop",
    "type": "ssh-rsa",
    "key": "REDACTED",
    "comment": "REDACTED",
    "date": "2021-02-25T08:26:04Z",
    "fingerprint": "REDACTED"
  }
]
```
2021-06-16 09:28:49 -04:00
James Stephenson
fbed685c37 Fixing unmarshalling of numberOrString
New unmarshalling rules for fields which could be numeric or string
values were not properly typecasted upon being deserialized.

Cleaned up the api template file and moved custom unmarshalling type
logic into go code out of the template.
2021-04-16 13:41:01 -04:00
Paul Tyng
4ab4036985 Bump to 6.0.43, use go generate
Also moved fetching of JSON information to Go for cross-OS usage.
2021-04-09 09:51:50 -04:00
Paul Tyng
5219e06753 Remove old field JSON 2021-04-09 09:51:50 -04:00
Kurt McAlpine
bd8898db77 Set d.Key for all settings updates 2021-04-09 09:51:50 -04:00
Paul Tyng
4702e34c81 Fix unmarshalling of tx_power 2021-03-21 21:34:29 -04:00
Paul Tyng
82a3baaf00 Handle marshaling of numbers and strings for channels 2021-03-21 21:13:58 -04:00
Paul Tyng
9c60a9de6f Change to string for auto support 2021-03-20 11:30:10 -04:00
Hendrik "T4cC0re" Meyer
4aed7d703d Generate UnmarshalJSON to handle emptyStringInt types
This commit changes the code generator to generate a `UnmarshalJSON` for each
struct, so that if unmarshalled it properly handles UniFis varying integer values
via the `emptyStringInt` type.

Structs not including a field of `int` type will still have the function generated,
but it will effectively do nothing.

Fixes #18
2021-01-03 13:21:53 -05:00
Paul Tyng
abc676f62b Add support for 6.0.23 2020-10-20 10:10:32 -04:00
Ben Davies
df937016b0 Moved handling of string response to int using the existing emptyStringInt method as part of UnmarshalJSON as per Pauls suggestion 2020-10-09 13:42:28 -04:00
Ben Davies
e7f9c5eb97 Added WAN egress qos fix 2020-10-09 13:42:28 -04:00
James Stephenson
6203ee9620 Renaming PortConf to PortProfile; cleanup Device API func names 2020-10-09 08:56:24 -04:00
James Stephenson
e93f92a066 Expose Device API 2020-10-09 08:56:24 -04:00