@@ -50,14 +50,14 @@ type secret struct {
50
50
Label_ string `yaml:"label"`
51
51
RotatePolicy_ string `yaml:"rotate-policy,omitempty"`
52
52
Owner_ string `yaml:"owner"`
53
- AutoPrune_ bool `yaml:"auto-prune"`
53
+ AutoPrune_ bool `yaml:"auto-prune,omitempty "`
54
54
Created_ time.Time `yaml:"create-time"`
55
55
Updated_ time.Time `yaml:"update-time"`
56
56
Revisions_ []* secretRevision `yaml:"revisions"`
57
57
58
- ACL_ map [string ]* secretAccess `yaml:"acl"`
59
- Consumers_ []* secretConsumer `yaml:"consumers"`
60
- RemoteConsumers_ []* secretRemoteConsumer `yaml:"remote-consumers"`
58
+ ACL_ map [string ]* secretAccess `yaml:"acl,omitempty "`
59
+ Consumers_ []* secretConsumer `yaml:"consumers,omitempty "`
60
+ RemoteConsumers_ []* secretRemoteConsumer `yaml:"remote-consumers,omitempty "`
61
61
62
62
NextRotateTime_ * time.Time `yaml:"next-rotate-time,omitempty"`
63
63
@@ -352,6 +352,7 @@ func secretV1Fields() (schema.Fields, schema.Defaults) {
352
352
"rotate-policy" : schema .Omit ,
353
353
"auto-prune" : schema .Omit ,
354
354
"next-rotate-time" : schema .Omit ,
355
+ "acl" : schema .Omit ,
355
356
"consumers" : schema .Omit ,
356
357
"remote-consumers" : schema .Omit ,
357
358
}
@@ -372,14 +373,21 @@ func importSecret(source map[string]interface{}, importVersion int, fieldFunc fu
372
373
Version_ : int (valid ["secret-version" ].(int64 )),
373
374
Description_ : valid ["description" ].(string ),
374
375
Label_ : valid ["label" ].(string ),
375
- RotatePolicy_ : valid ["rotate-policy" ].(string ),
376
- AutoPrune_ : valid ["auto-prune" ].(bool ),
377
376
Owner_ : valid ["owner" ].(string ),
378
377
Created_ : valid ["create-time" ].(time.Time ).UTC (),
379
378
Updated_ : valid ["update-time" ].(time.Time ).UTC (),
380
379
NextRotateTime_ : fieldToTimePtr (valid , "next-rotate-time" ),
381
380
}
382
381
382
+ if policy , ok := valid ["rotate-policy" ].(string ); ok {
383
+ secret .RotatePolicy_ = policy
384
+ }
385
+
386
+ // This should be in a v2 schema but it's already also in v1.
387
+ if autoPrune , ok := valid ["auto-prune" ].(bool ); ok {
388
+ secret .AutoPrune_ = autoPrune
389
+ }
390
+
383
391
secretACL , err := importSecretAccess (valid , importVersion )
384
392
if err != nil {
385
393
return nil , errors .Trace (err )
@@ -456,7 +464,10 @@ func importSecretAccess(source map[string]interface{}, version int) (map[string]
456
464
if ! ok {
457
465
return nil , errors .NotValidf ("version %d" , version )
458
466
}
459
- sourceList := source ["acl" ].(map [interface {}]interface {})
467
+ sourceList , ok := source ["acl" ].(map [interface {}]interface {})
468
+ if ! ok {
469
+ return nil , nil
470
+ }
460
471
return importSecretAccessMap (sourceList , importFunc )
461
472
}
462
473
@@ -571,7 +582,10 @@ func importSecretConsumers(source map[string]interface{}, version int) ([]*secre
571
582
if ! ok {
572
583
return nil , errors .NotValidf ("version %d" , version )
573
584
}
574
- sourceList := source ["consumers" ].([]interface {})
585
+ sourceList , ok := source ["consumers" ].([]interface {})
586
+ if ! ok {
587
+ return nil , nil
588
+ }
575
589
return importSecretConsumersList (sourceList , importFunc )
576
590
}
577
591
@@ -759,7 +773,10 @@ func importSecretRevisions(source map[string]interface{}, version int) ([]*secre
759
773
if ! ok {
760
774
return nil , errors .NotValidf ("version %d" , version )
761
775
}
762
- sourceList := source ["revisions" ].([]interface {})
776
+ sourceList , ok := source ["revisions" ].([]interface {})
777
+ if ! ok {
778
+ return nil , nil
779
+ }
763
780
return importSecretRevisionList (sourceList , importFunc )
764
781
}
765
782
0 commit comments