@@ -110,24 +110,24 @@ func Load(application string, name string) error {
110
110
return errors .New (err )
111
111
}
112
112
113
- ui .Log (ui .AppLogger , "config.active" ,
114
- "name" , name )
113
+ ui .Log (ui .AppLogger , "config.active" , ui. A {
114
+ "name" : name } )
115
115
116
116
// Do we already have that configuration loaded? If so make it current
117
117
// and we're done.
118
118
if c , ok := Configurations [name ]; ok {
119
119
path := filepath .Join (home , ProfileDirectory , name + ".profile" )
120
120
CurrentConfiguration = c
121
121
122
- ui .Log (ui .AppLogger , "config.base.loaded" ,
123
- "path" , path )
122
+ ui .Log (ui .AppLogger , "config.base.loaded" , ui. A {
123
+ "path" : path } )
124
124
125
125
// For any keys that are stored as separate file values, get them now.
126
126
readOutboardConfigFiles (home , name , c )
127
127
128
- ui .Log (ui .AppLogger , "config.is.active" ,
129
- "name" , CurrentConfiguration .Name ,
130
- "id" , CurrentConfiguration .ID )
128
+ ui .Log (ui .AppLogger , "config.is.active" , ui. A {
129
+ "Name" : CurrentConfiguration .Name ,
130
+ "id" : CurrentConfiguration .ID } )
131
131
132
132
return nil
133
133
}
@@ -142,8 +142,8 @@ func Load(application string, name string) error {
142
142
path := filepath .Join (home , ProfileDirectory )
143
143
if _ , err := os .Stat (path ); os .IsNotExist (err ) {
144
144
_ = os .MkdirAll (path , securePermission )
145
- ui .Log (ui .AppLogger , "config.create.dir" ,
146
- "path" , path )
145
+ ui .Log (ui .AppLogger , "config.create.dir" , ui. A {
146
+ "path" : path } )
147
147
}
148
148
149
149
// Read legacy configuration file if it exists.
@@ -157,8 +157,8 @@ func Load(application string, name string) error {
157
157
for _ , file := range files {
158
158
configFile , err := os .Open (file )
159
159
if err == nil {
160
- ui .Log (ui .AppLogger , "config.read.profile" ,
161
- "path" , file )
160
+ ui .Log (ui .AppLogger , "config.read.profile" , ui. A {
161
+ "path" : file } )
162
162
163
163
defer configFile .Close ()
164
164
byteValue , _ := io .ReadAll (configFile )
@@ -171,10 +171,10 @@ func Load(application string, name string) error {
171
171
profile .Name = shortProfileName
172
172
Configurations [shortProfileName ] = & profile
173
173
174
- ui .Log (ui .AppLogger , "config.loaded.config" ,
175
- "name" , profile .Name ,
176
- "id" , profile .ID ,
177
- "count" , len (profile .Items ))
174
+ ui .Log (ui .AppLogger , "config.loaded.config" , ui. A {
175
+ "name" : profile .Name ,
176
+ "id" : profile .ID ,
177
+ "count" : len (profile .Items )} )
178
178
}
179
179
}
180
180
}
@@ -184,8 +184,8 @@ func Load(application string, name string) error {
184
184
// default configuration.
185
185
cp , found := Configurations [name ]
186
186
if ! found {
187
- ui .Log (ui .AppLogger , "config.not.found" ,
188
- "name" , name )
187
+ ui .Log (ui .AppLogger , "config.not.found" , ui. A {
188
+ "name" : name } )
189
189
190
190
cp = & Configuration {
191
191
Description : DefaultConfiguration ,
@@ -196,9 +196,9 @@ func Load(application string, name string) error {
196
196
}
197
197
Configurations [name ] = cp
198
198
} else {
199
- ui .Log (ui .AppLogger , "config.using" ,
200
- "name" , name ,
201
- "id" , cp .ID )
199
+ ui .Log (ui .AppLogger , "config.using" , ui. A {
200
+ "name" : name ,
201
+ "id" : cp .ID } )
202
202
}
203
203
204
204
ProfileName = cp .Name
@@ -246,24 +246,24 @@ func readOutboardConfigFiles(home string, name string, cp *Configuration) {
246
246
if err == nil {
247
247
var value string
248
248
249
- ui .Log (ui .AppLogger , "config.external" ,
250
- "name" , token ,
251
- "path" , fileName )
249
+ ui .Log (ui .AppLogger , "config.external" , ui. A {
250
+ "name" : token ,
251
+ "path" : fileName } )
252
252
253
253
err := json .Unmarshal (bytes , & value )
254
254
if err == nil && len (value ) > 0 {
255
255
// Decrypt the value using the salt as the password if it is marked as an encrypted value.
256
256
if strings .HasPrefix (value , encryptionPrefixTag ) {
257
257
value , err = Decrypt (strings .TrimPrefix (value , encryptionPrefixTag ), cp .Name + cp .Salt + cp .ID )
258
258
if err != nil {
259
- ui .Log (ui .AppLogger , "config.decrypt.error" ,
260
- "name" , token ,
261
- "error" , err )
259
+ ui .Log (ui .AppLogger , "config.decrypt.error" , ui. A {
260
+ "name" : token ,
261
+ "error" : err } )
262
262
263
263
continue
264
264
} else {
265
- ui .Log (ui .AppLogger , "config.decrypted" ,
266
- "name" , token )
265
+ ui .Log (ui .AppLogger , "config.decrypted" , ui. A {
266
+ "name" : token } )
267
267
}
268
268
}
269
269
@@ -283,8 +283,8 @@ func readLegacyConfigFormat(path string, home string, name string) (error, strin
283
283
if err == nil {
284
284
// read the json config as a byte array.
285
285
defer configFile .Close ()
286
- ui .Log (ui .AppLogger , "config.legacy.read" ,
287
- "path" , path )
286
+ ui .Log (ui .AppLogger , "config.legacy.read" , ui. A {
287
+ "path" : path } )
288
288
289
289
byteValue , _ := io .ReadAll (configFile )
290
290
@@ -301,10 +301,10 @@ func readLegacyConfigFormat(path string, home string, name string) (error, strin
301
301
p .Dirty = true
302
302
p .Name = profileName
303
303
Configurations [profileName ] = p
304
- ui .Log (ui .AppLogger , "config.legacy.load" ,
305
- "name" , profileName ,
306
- "id" , p .ID ,
307
- "count" , len (p .Items ))
304
+ ui .Log (ui .AppLogger , "config.legacy.load" , ui. A {
305
+ "name" : profileName ,
306
+ "id" : p .ID ,
307
+ "count" : len (p .Items )} )
308
308
}
309
309
}
310
310
} else {
@@ -364,18 +364,18 @@ func Save() error {
364
364
if err != nil {
365
365
err = errors .New (err )
366
366
367
- ui .Log (ui .AppLogger , "config.save.error" ,
368
- "name" , name ,
369
- "error" , err )
367
+ ui .Log (ui .AppLogger , "config.save.error" , ui. A {
368
+ "name" : name ,
369
+ "error" : err } )
370
370
371
371
break
372
372
} else {
373
373
Configurations [name ] = profile
374
374
375
- ui .Log (ui .AppLogger , "config.save" ,
376
- "name" , name ,
377
- "id" , profile .ID ,
378
- "path" , path )
375
+ ui .Log (ui .AppLogger , "config.save" , ui. A {
376
+ "name" : name ,
377
+ "id" : profile .ID ,
378
+ "path" : path } )
379
379
}
380
380
}
381
381
@@ -396,8 +396,8 @@ func Save() error {
396
396
// Write any keys that are intended to be stored outside the configuration into separate files.
397
397
func saveOutboardConfigItems (profile * Configuration , home string , name string , err error , savedItems map [string ]string ) {
398
398
for token , file := range fileMapping {
399
- ui .Log (ui .AppLogger , "config.external.check" ,
400
- "name" , token )
399
+ ui .Log (ui .AppLogger , "config.external.check" , ui. A {
400
+ "name" : token } )
401
401
402
402
// We only do this for key values that exist and are non-empty.
403
403
if value , ok := profile .Items [token ]; ok && len (value ) > 0 {
@@ -406,14 +406,14 @@ func saveOutboardConfigItems(profile *Configuration, home string, name string, e
406
406
// Encrypt the value using the salt as the password
407
407
value , err = Encrypt (value , profile .Name + profile .Salt + profile .ID )
408
408
if err != nil {
409
- ui .Log (ui .AppLogger , "config.external.encrypt.error" ,
410
- "name" , token ,
411
- "error" , err )
409
+ ui .Log (ui .AppLogger , "config.external.encrypt.error" , ui. A {
410
+ "name" : token ,
411
+ "error" : err } )
412
412
413
413
continue
414
414
} else {
415
- ui .Log (ui .AppLogger , "config.external.encxrypt" ,
416
- "name" , token )
415
+ ui .Log (ui .AppLogger , "config.external.encxrypt" , ui. A {
416
+ "name" : token } )
417
417
418
418
value = encryptionPrefixTag + value
419
419
}
@@ -431,19 +431,19 @@ func saveOutboardConfigItems(profile *Configuration, home string, name string, e
431
431
if err != nil {
432
432
err = errors .New (err )
433
433
434
- ui .Log (ui .AppLogger , "config.external.write.error" ,
435
- "name" , token ,
436
- "path" , fileName ,
437
- "error" , err )
434
+ ui .Log (ui .AppLogger , "config.external.write.error" , ui. A {
435
+ "name" : token ,
436
+ "path" : fileName ,
437
+ "error" : err } )
438
438
439
439
break
440
440
} else {
441
441
savedItems [token ] = profile .Items [token ]
442
442
443
443
delete (profile .Items , token )
444
- ui .Log (ui .AppLogger , "config.extenral.write" ,
445
- "name" , token ,
446
- "path" , fileName )
444
+ ui .Log (ui .AppLogger , "config.extenral.write" , ui. A {
445
+ "name" : token ,
446
+ "path" : fileName } )
447
447
}
448
448
}
449
449
} else {
@@ -453,15 +453,15 @@ func saveOutboardConfigItems(profile *Configuration, home string, name string, e
453
453
454
454
err := os .Remove (fileName )
455
455
if err == nil {
456
- ui .Log (ui .AppLogger , "config.external.deleted" ,
457
- "path" , fileName )
456
+ ui .Log (ui .AppLogger , "config.external.deleted" , ui. A {
457
+ "path" : fileName } )
458
458
} else if ! goerr .Is (err , fs .ErrNotExist ) {
459
- ui .Log (ui .AppLogger , "config.external.delete.error" ,
460
- "path" , fileName ,
461
- "error" , err )
459
+ ui .Log (ui .AppLogger , "config.external.delete.error" , ui. A {
460
+ "path" : fileName ,
461
+ "error" : err } )
462
462
} else {
463
- ui .Log (ui .AppLogger , "config.external.not.found" ,
464
- "path" , fileName )
463
+ ui .Log (ui .AppLogger , "config.external.not.found" , ui. A {
464
+ "path" : fileName } )
465
465
}
466
466
}
467
467
}
@@ -509,9 +509,9 @@ func DeleteProfile(key string) error {
509
509
// profiles need to be refreshed on disk.
510
510
path := filepath .Join (home , ProfileDirectory , key + ".profile" )
511
511
if err = os .Remove (path ); err != nil {
512
- ui .Log (ui .AppLogger , "config.delete.error" ,
513
- "path" , path ,
514
- "error" , err )
512
+ ui .Log (ui .AppLogger , "config.delete.error" , ui. A {
513
+ "path" : path ,
514
+ "error" : err } )
515
515
} else {
516
516
err = Save ()
517
517
}
@@ -523,29 +523,29 @@ func DeleteProfile(key string) error {
523
523
if _ , err := os .Stat (fileName ); err == nil {
524
524
err = os .Remove (fileName )
525
525
if err == nil {
526
- ui .Log (ui .AppLogger , "config.deleted" ,
527
- "name" , key ,
528
- "path" , fileName )
526
+ ui .Log (ui .AppLogger , "config.deleted" , ui. A {
527
+ "name" : key ,
528
+ "path" : fileName } )
529
529
} else {
530
- ui .Log (ui .AppLogger , "config.external.delete.error" ,
531
- "path" , fileName ,
532
- "error" , err )
530
+ ui .Log (ui .AppLogger , "config.external.delete.error" , ui. A {
531
+ "path" : fileName ,
532
+ "error" : err } )
533
533
}
534
534
}
535
535
}
536
536
537
537
// If the deletion was successful, log the deletion.
538
538
if err == nil {
539
- ui .Log (ui .AppLogger , "config.deleted" ,
540
- "name" , key ,
541
- "path" , path )
539
+ ui .Log (ui .AppLogger , "config.deleted" , ui. A {
540
+ "name" : key ,
541
+ "path" : path } )
542
542
}
543
543
544
544
return err
545
545
}
546
546
547
- ui .Log (ui .AppLogger , "config.delete.not.found" ,
548
- "name" , key )
547
+ ui .Log (ui .AppLogger , "config.delete.not.found" , ui. A {
548
+ "name" : key } )
549
549
550
550
return errors .ErrNoSuchProfile .Context (key )
551
551
}
0 commit comments