diff --git a/README.md b/README.md index abbeda9..6d1ad08 100644 --- a/README.md +++ b/README.md @@ -294,18 +294,16 @@ $ ttn-lw-migrate firefly device --invalidate-keys < device_ids.txt > devices.jso The Firefly LNS does not strictly enforce device to application relationships. -Setting the `--all` flag will export **all devices that are accessible by the API key** are exported. - -The `application` command without the `--all` flag does nothing. +Setting the `--all` flag will export **all devices that are accessible by the API key**. The `application` command without the `--all` flag does nothing. > Note: Please be cautious while using this command as this might invalidate all the keys of all the devices. -Similarly, to export all devices accessible by the API Key, +To export all devices accessible by the API Key, ```bash # dry run first, verify that no errors occur $ ttn-lw-migrate firefly application --all --verbose > devices.json -# export devices +# export all devices $ ttn-lw-migrate firefly application --all --invalidate-keys > devices.json ``` diff --git a/pkg/export/export.go b/pkg/export/export.go index 669d141..7a08cee 100644 --- a/pkg/export/export.go +++ b/pkg/export/export.go @@ -62,7 +62,7 @@ func (cfg Config) ExportDev(s source.Source, devID string) error { return errDevIDExceedsMaxLength.WithAttributes("id", id) } - if dev.Ids.DeviceId != oldID { + if dev.Ids.DeviceId != oldID && oldID != "" { if dev.Attributes == nil { dev.Attributes = make(map[string]string) } diff --git a/pkg/source/firefly/config.go b/pkg/source/firefly/config.go index 8f7e801..32edfd2 100644 --- a/pkg/source/firefly/config.go +++ b/pkg/source/firefly/config.go @@ -48,19 +48,7 @@ type Config struct { // NewConfig returns a new Firefly configuration. func NewConfig() *Config { config := &Config{ - flags: &pflag.FlagSet{}, - joinEUI: os.Getenv("JOIN_EUI"), - appID: os.Getenv("APP_ID"), - frequencyPlanID: os.Getenv("FREQUENCY_PLAN_ID"), - macVersion: os.Getenv("MAC_VERSION"), - invalidateKeys: (os.Getenv("INVALIDATE_KEYS") == "true"), - all: (os.Getenv("ALL") == "true"), - Config: client.Config{ - Host: os.Getenv("FIREFLY_HOST"), - CACertPath: os.Getenv("FIREFLY_CA_CERT_PATH"), - APIKey: os.Getenv("FIREFLY_API_KEY"), - UseHTTP: (os.Getenv("FIREFLY_USE_HTTP") == "true"), - }, + flags: &pflag.FlagSet{}, } config.flags.StringVar(&config.Host, diff --git a/pkg/source/source.go b/pkg/source/source.go index 2de5849..428416b 100644 --- a/pkg/source/source.go +++ b/pkg/source/source.go @@ -56,7 +56,7 @@ type Source interface { RangeDevices(appID string, f func(s Source, devID string) error) error // Close cleans up and terminates any open connections. Close() error - // Iterator returns an iterator for devices. + // Iterator returns an iterator for the source. Iterator(isApplication bool) iterator.Iterator }