diff --git a/.gitignore b/.gitignore index 4fcbbe9..00295aa 100644 --- a/.gitignore +++ b/.gitignore @@ -20,3 +20,6 @@ # macOS related *.DS_store + +# Go +**/vendor/* diff --git a/CHANGELOG.md b/CHANGELOG.md index fdaf419..bcfa77d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), ### Fixed +- Strip ids.dev_addr from exported devices + ## [v0.12.0] (2024-03-13) ### Added @@ -145,6 +147,3 @@ NOTE: These links should respect backports. See https://github.com/TheThingsNetw --> [unreleased]: https://github.com/TheThingsNetwork/lorawan-stack-migrate/v0.7.0...master -[0.7.0]: https://github.com/TheThingsNetwork/lorawan-stack-migrate/compare/v0.6.0...v0.7.0 -[0.6.0]: https://github.com/TheThingsNetwork/lorawan-stack-migrate/compare/v0.5.0...v0.6.0 -[0.5.0]: https://github.com/TheThingsNetwork/lorawan-stack-migrate/compare/v0.4.0...v0.5.0 diff --git a/pkg/source/tts/source.go b/pkg/source/tts/source.go index 56dd69e..3c784d8 100644 --- a/pkg/source/tts/source.go +++ b/pkg/source/tts/source.go @@ -73,10 +73,15 @@ func (s Source) ExportDevice(devID string) (*ttnpb.EndDevice, error) { if err := validateDeviceIds(dev.Ids, res.Ids); err != nil { return nil, err } - paths := ttnpb.AddFields(nsPaths, ttnpb.AddFields(asPaths, ttnpb.AddFields(jsPaths, "ids.dev_addr")...)...) + paths := ttnpb.AddFields(nsPaths, ttnpb.AddFields(asPaths, jsPaths...)...) if err := dev.SetFields(res, paths...); err != nil { return nil, err } + // Clear ids.dev_addr (denormalized session state) so the export can be + // re-imported via the CLI; session.dev_addr remains the source of truth. + if dev.Ids != nil { + dev.Ids.DevAddr = nil + } // Clear all "{server}_address" fields from exported device if err := dev.SetFields(nil, "application_server_address", "join_server_address", "network_server_address"); err != nil { return nil, err @@ -108,7 +113,10 @@ func (s Source) ExportDevice(devID string) (*ttnpb.EndDevice, error) { } // Iterator implements source.Source. -func (s Source) Iterator(bool) iterator.Iterator { +func (s Source) Iterator(isApplication bool) iterator.Iterator { + if isApplication && s.config.AppID != "" { + return iterator.NewListIterator([]string{s.config.AppID}) + } return iterator.NewReaderIterator(os.Stdin, '\n') }