Skip to content
Merged
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,6 @@

# macOS related
*.DS_store

# Go
**/vendor/*
5 changes: 2 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
12 changes: 10 additions & 2 deletions pkg/source/tts/source.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Comment thread
johanstokking marked this conversation as resolved.
// 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
Expand Down Expand Up @@ -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')
}

Expand Down
Loading