Skip to content

Commit 5040510

Browse files
committed
Renamed a couple of variables for clarity
1 parent 0c924ad commit 5040510

File tree

1 file changed

+34
-34
lines changed
  • internal/arduino/cores/packagemanager

1 file changed

+34
-34
lines changed

internal/arduino/cores/packagemanager/loader.go

+34-34
Original file line numberDiff line numberDiff line change
@@ -227,99 +227,99 @@ func (pm *Builder) loadPlatform(targetPackage *cores.Package, architecture strin
227227
return nil
228228
}
229229

230-
func (pm *Builder) loadPlatformRelease(platform *cores.PlatformRelease, path *paths.Path) error {
230+
func (pm *Builder) loadPlatformRelease(platformRelease *cores.PlatformRelease, platformPath *paths.Path) error {
231231
// If the installed.json file is found load it, this is done to handle the
232232
// case in which the platform's index and its url have been deleted locally,
233233
// if we don't load it some information about the platform is lost
234-
installedJSONPath := path.Join("installed.json")
234+
installedJSONPath := platformPath.Join("installed.json")
235235
if installedJSONPath.Exist() {
236236
if _, err := pm.LoadPackageIndexFromFile(installedJSONPath); err != nil {
237237
return errors.New(i18n.Tr("loading %[1]s: %[2]s", installedJSONPath, err))
238238
}
239239
}
240240

241-
platform.InstallDir = path
242-
platform.Timestamps.AddFile(installedJSONPath)
243-
platform.Properties = platform.Properties.Clone() // TODO: why CLONE?
241+
platformRelease.InstallDir = platformPath
242+
platformRelease.Timestamps.AddFile(installedJSONPath)
243+
platformRelease.Properties = platformRelease.Properties.Clone() // TODO: why CLONE?
244244

245245
// Create platform properties
246-
platformTxtPath := path.Join("platform.txt")
247-
platform.Timestamps.AddFile(platformTxtPath)
246+
platformTxtPath := platformPath.Join("platform.txt")
247+
platformRelease.Timestamps.AddFile(platformTxtPath)
248248
if p, err := properties.SafeLoadFromPath(platformTxtPath); err == nil {
249-
platform.Properties.Merge(p)
249+
platformRelease.Properties.Merge(p)
250250
} else {
251251
return errors.New(i18n.Tr("loading %[1]s: %[2]s", platformTxtPath, err))
252252
}
253253

254-
platformTxtLocalPath := path.Join("platform.local.txt")
255-
platform.Timestamps.AddFile(platformTxtLocalPath)
254+
platformTxtLocalPath := platformPath.Join("platform.local.txt")
255+
platformRelease.Timestamps.AddFile(platformTxtLocalPath)
256256
if p, err := properties.SafeLoadFromPath(platformTxtLocalPath); err == nil {
257-
platform.Properties.Merge(p)
257+
platformRelease.Properties.Merge(p)
258258
} else {
259259
return errors.New(i18n.Tr("loading %[1]s: %[2]s", platformTxtLocalPath, err))
260260
}
261261

262-
if platform.Properties.SubTree("pluggable_discovery").Size() > 0 || platform.Properties.SubTree("pluggable_monitor").Size() > 0 {
263-
platform.PluggableDiscoveryAware = true
262+
if platformRelease.Properties.SubTree("pluggable_discovery").Size() > 0 || platformRelease.Properties.SubTree("pluggable_monitor").Size() > 0 {
263+
platformRelease.PluggableDiscoveryAware = true
264264
} else {
265-
platform.Properties.Set("pluggable_discovery.required.0", "builtin:serial-discovery")
266-
platform.Properties.Set("pluggable_discovery.required.1", "builtin:mdns-discovery")
267-
platform.Properties.Set("pluggable_monitor.required.serial", "builtin:serial-monitor")
265+
platformRelease.Properties.Set("pluggable_discovery.required.0", "builtin:serial-discovery")
266+
platformRelease.Properties.Set("pluggable_discovery.required.1", "builtin:mdns-discovery")
267+
platformRelease.Properties.Set("pluggable_monitor.required.serial", "builtin:serial-monitor")
268268
}
269269

270-
if platform.Name == "" {
271-
if name, ok := platform.Properties.GetOk("name"); ok {
272-
platform.Name = name
270+
if platformRelease.Name == "" {
271+
if name, ok := platformRelease.Properties.GetOk("name"); ok {
272+
platformRelease.Name = name
273273
} else {
274274
// If the platform.txt file doesn't exist for this platform and it's not in any
275275
// package index there is no way of retrieving its name, so we build one using
276276
// the available information, that is the packager name and the architecture.
277-
platform.Name = fmt.Sprintf("%s-%s", platform.Platform.Package.Name, platform.Platform.Architecture)
277+
platformRelease.Name = fmt.Sprintf("%s-%s", platformRelease.Platform.Package.Name, platformRelease.Platform.Architecture)
278278
}
279279
}
280280

281281
// Create programmers properties
282-
programmersTxtPath := path.Join("programmers.txt")
283-
platform.Timestamps.AddFile(programmersTxtPath)
282+
programmersTxtPath := platformPath.Join("programmers.txt")
283+
platformRelease.Timestamps.AddFile(programmersTxtPath)
284284
if programmersProperties, err := properties.SafeLoadFromPath(programmersTxtPath); err == nil {
285285
for programmerID, programmerProps := range programmersProperties.FirstLevelOf() {
286-
if !platform.PluggableDiscoveryAware {
286+
if !platformRelease.PluggableDiscoveryAware {
287287
convertUploadToolsToPluggableDiscovery(programmerProps)
288288
}
289-
platform.Programmers[programmerID] = pm.loadProgrammer(programmerProps)
290-
platform.Programmers[programmerID].PlatformRelease = platform
289+
platformRelease.Programmers[programmerID] = pm.loadProgrammer(programmerProps)
290+
platformRelease.Programmers[programmerID].PlatformRelease = platformRelease
291291
}
292292
} else {
293293
return err
294294
}
295295

296-
if err := pm.loadBoards(platform); err != nil {
296+
if err := pm.loadBoards(platformRelease); err != nil {
297297
return errors.New(i18n.Tr("loading boards: %s", err))
298298
}
299299

300-
if !platform.PluggableDiscoveryAware {
301-
convertLegacyPlatformToPluggableDiscovery(platform)
300+
if !platformRelease.PluggableDiscoveryAware {
301+
convertLegacyPlatformToPluggableDiscovery(platformRelease)
302302
}
303303

304304
// Build pluggable monitor references
305-
platform.Monitors = map[string]*cores.MonitorDependency{}
306-
for protocol, ref := range platform.Properties.SubTree("pluggable_monitor.required").AsMap() {
305+
platformRelease.Monitors = map[string]*cores.MonitorDependency{}
306+
for protocol, ref := range platformRelease.Properties.SubTree("pluggable_monitor.required").AsMap() {
307307
split := strings.Split(ref, ":")
308308
if len(split) != 2 {
309309
return errors.New(i18n.Tr("invalid pluggable monitor reference: %s", ref))
310310
}
311311
pm.log.WithField("protocol", protocol).WithField("tool", ref).Info("Adding monitor tool")
312-
platform.Monitors[protocol] = &cores.MonitorDependency{
312+
platformRelease.Monitors[protocol] = &cores.MonitorDependency{
313313
Packager: split[0],
314314
Name: split[1],
315315
}
316316
}
317317

318318
// Support for pluggable monitors in debugging/development environments
319-
platform.MonitorsDevRecipes = map[string]string{}
320-
for protocol, recipe := range platform.Properties.SubTree("pluggable_monitor.pattern").AsMap() {
319+
platformRelease.MonitorsDevRecipes = map[string]string{}
320+
for protocol, recipe := range platformRelease.Properties.SubTree("pluggable_monitor.pattern").AsMap() {
321321
pm.log.WithField("protocol", protocol).WithField("recipe", recipe).Info("Adding monitor recipe")
322-
platform.MonitorsDevRecipes[protocol] = recipe
322+
platformRelease.MonitorsDevRecipes[protocol] = recipe
323323
}
324324

325325
return nil

0 commit comments

Comments
 (0)