@@ -84,66 +84,76 @@ func NewFramework(r Registry, plugins *config.Plugins, args []config.PluginConfi
84
84
f .plugins [name ] = p
85
85
}
86
86
87
- for _ , r := range plugins .Reserve .Enabled {
88
- if pg , ok := f .plugins [r .Name ]; ok {
89
- p , ok := pg .(ReservePlugin )
90
- if ! ok {
91
- return nil , fmt .Errorf ("plugin %v does not extend reserve plugin" , r .Name )
87
+ if plugins .Reserve != nil {
88
+ for _ , r := range plugins .Reserve .Enabled {
89
+ if pg , ok := f .plugins [r .Name ]; ok {
90
+ p , ok := pg .(ReservePlugin )
91
+ if ! ok {
92
+ return nil , fmt .Errorf ("plugin %v does not extend reserve plugin" , r .Name )
93
+ }
94
+ f .reservePlugins = append (f .reservePlugins , p )
95
+ } else {
96
+ return nil , fmt .Errorf ("reserve plugin %v does not exist" , r .Name )
92
97
}
93
- f .reservePlugins = append (f .reservePlugins , p )
94
- } else {
95
- return nil , fmt .Errorf ("reserve plugin %v does not exist" , r .Name )
96
98
}
97
99
}
98
100
99
- for _ , pb := range plugins .PreBind .Enabled {
100
- if pg , ok := f .plugins [pb .Name ]; ok {
101
- p , ok := pg .(PrebindPlugin )
102
- if ! ok {
103
- return nil , fmt .Errorf ("plugin %v does not extend prebind plugin" , pb .Name )
101
+ if plugins .PreBind != nil {
102
+ for _ , pb := range plugins .PreBind .Enabled {
103
+ if pg , ok := f .plugins [pb .Name ]; ok {
104
+ p , ok := pg .(PrebindPlugin )
105
+ if ! ok {
106
+ return nil , fmt .Errorf ("plugin %v does not extend prebind plugin" , pb .Name )
107
+ }
108
+ f .prebindPlugins = append (f .prebindPlugins , p )
109
+ } else {
110
+ return nil , fmt .Errorf ("prebind plugin %v does not exist" , pb .Name )
104
111
}
105
- f .prebindPlugins = append (f .prebindPlugins , p )
106
- } else {
107
- return nil , fmt .Errorf ("prebind plugin %v does not exist" , pb .Name )
108
112
}
109
113
}
110
114
111
- for _ , ur := range plugins .Unreserve .Enabled {
112
- if pg , ok := f .plugins [ur .Name ]; ok {
113
- p , ok := pg .(UnreservePlugin )
114
- if ! ok {
115
- return nil , fmt .Errorf ("plugin %v does not extend unreserve plugin" , ur .Name )
115
+ if plugins .Unreserve != nil {
116
+ for _ , ur := range plugins .Unreserve .Enabled {
117
+ if pg , ok := f .plugins [ur .Name ]; ok {
118
+ p , ok := pg .(UnreservePlugin )
119
+ if ! ok {
120
+ return nil , fmt .Errorf ("plugin %v does not extend unreserve plugin" , ur .Name )
121
+ }
122
+ f .unreservePlugins = append (f .unreservePlugins , p )
123
+ } else {
124
+ return nil , fmt .Errorf ("unreserve plugin %v does not exist" , ur .Name )
116
125
}
117
- f .unreservePlugins = append (f .unreservePlugins , p )
118
- } else {
119
- return nil , fmt .Errorf ("unreserve plugin %v does not exist" , ur .Name )
120
126
}
121
127
}
122
128
123
- for _ , pr := range plugins .Permit .Enabled {
124
- if pg , ok := f .plugins [pr .Name ]; ok {
125
- p , ok := pg .(PermitPlugin )
126
- if ! ok {
127
- return nil , fmt .Errorf ("plugin %v does not extend permit plugin" , pr .Name )
129
+ if plugins .Permit != nil {
130
+ for _ , pr := range plugins .Permit .Enabled {
131
+ if pg , ok := f .plugins [pr .Name ]; ok {
132
+ p , ok := pg .(PermitPlugin )
133
+ if ! ok {
134
+ return nil , fmt .Errorf ("plugin %v does not extend permit plugin" , pr .Name )
135
+ }
136
+ f .permitPlugins = append (f .permitPlugins , p )
137
+ } else {
138
+ return nil , fmt .Errorf ("permit plugin %v does not exist" , pr .Name )
128
139
}
129
- f .permitPlugins = append (f .permitPlugins , p )
130
- } else {
131
- return nil , fmt .Errorf ("permit plugin %v does not exist" , pr .Name )
132
140
}
133
141
}
134
142
135
- for _ , qs := range plugins .QueueSort .Enabled {
136
- if pg , ok := f .plugins [qs .Name ]; ok {
137
- p , ok := pg .(QueueSortPlugin )
138
- if ! ok {
139
- return nil , fmt .Errorf ("plugin %v does not extend queue sort plugin" , qs .Name )
140
- }
141
- f .queueSortPlugins = append (f .queueSortPlugins , p )
142
- if len (f .queueSortPlugins ) > 1 {
143
- return nil , fmt .Errorf ("only one queue sort plugin can be enabled" )
143
+ if plugins .QueueSort != nil {
144
+ for _ , qs := range plugins .QueueSort .Enabled {
145
+ if pg , ok := f .plugins [qs .Name ]; ok {
146
+ p , ok := pg .(QueueSortPlugin )
147
+ if ! ok {
148
+ return nil , fmt .Errorf ("plugin %v does not extend queue sort plugin" , qs .Name )
149
+ }
150
+ f .queueSortPlugins = append (f .queueSortPlugins , p )
151
+ if len (f .queueSortPlugins ) > 1 {
152
+ return nil , fmt .Errorf ("only one queue sort plugin can be enabled" )
153
+ }
154
+ } else {
155
+ return nil , fmt .Errorf ("queue sort plugin %v does not exist" , qs .Name )
144
156
}
145
- } else {
146
- return nil , fmt .Errorf ("queue sort plugin %v does not exist" , qs .Name )
147
157
}
148
158
}
149
159
0 commit comments