@@ -437,7 +437,7 @@ func parseAttribute(e *yang.Entry, attr *YamlConfigAttribute) {
437
437
}
438
438
}
439
439
440
- func augmentConfig (config * YamlConfig , modelPaths [] string ) {
440
+ func augmentConfig (config * YamlConfig , yangModules * yang. Modules ) {
441
441
path := ""
442
442
if config .AugmentPath != "" {
443
443
path = config .AugmentPath
@@ -446,7 +446,7 @@ func augmentConfig(config *YamlConfig, modelPaths []string) {
446
446
}
447
447
448
448
module := strings .Split (path , ":" )[0 ]
449
- e , errors := yang .GetModule (module , modelPaths ... )
449
+ e , errors := yangModules .GetModule (module )
450
450
if len (errors ) > 0 {
451
451
fmt .Printf ("YANG parser error(s): %+v\n \n " , errors )
452
452
return
@@ -548,19 +548,25 @@ func main() {
548
548
}
549
549
550
550
items , _ = os .ReadDir (modelsPath )
551
- modelPaths := make ([]string , 0 )
551
+
552
+ yangModules := yang .NewModules ()
552
553
553
554
// Iterate over yang models
554
555
for _ , item := range items {
555
- if filepath .Ext (item .Name ()) == ".yang" {
556
- modelPaths = append (modelPaths , filepath .Join (modelsPath , item .Name ()))
556
+ if filepath .Ext (item .Name ()) != ".yang" {
557
+ continue
558
+ }
559
+
560
+ fn := filepath .Join (modelsPath , item .Name ())
561
+ if err := yangModules .Read (fn ); err != nil {
562
+ log .Fatalf ("yang parser: %v" , err )
557
563
}
558
564
}
559
565
560
566
for i := range configs {
561
567
// Augment config by yang models
562
568
if ! configs [i ].NoAugmentConfig {
563
- augmentConfig (& configs [i ], modelPaths )
569
+ augmentConfig (& configs [i ], yangModules )
564
570
}
565
571
566
572
fmt .Printf ("Augumented %d/%d: %v\n " , i + 1 , len (configs ), configs [i ].Name )
0 commit comments