Skip to content

Commit a8c5b10

Browse files
authored
Merge pull request #5810 from guettli/better-err-msg-on-undefined-loader-behavior
Better error message on undefined loader behavior.
2 parents bb7a280 + ae7ff36 commit a8c5b10

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

api/internal/plugins/loader/loader.go

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ type Loader struct {
3434
}
3535

3636
func NewLoader(
37-
pc *types.PluginConfig, rf *resmap.Factory, fs filesys.FileSystem) *Loader {
37+
pc *types.PluginConfig, rf *resmap.Factory, fs filesys.FileSystem,
38+
) *Loader {
3839
return &Loader{pc: pc, rf: rf, fs: fs}
3940
}
4041

@@ -58,7 +59,8 @@ func (l *Loader) Config() *types.PluginConfig {
5859

5960
func (l *Loader) LoadGenerators(
6061
ldr ifc.Loader, v ifc.Validator, rm resmap.ResMap) (
61-
result []*resmap.GeneratorWithProperties, err error) {
62+
result []*resmap.GeneratorWithProperties, err error,
63+
) {
6264
for _, res := range rm.Resources() {
6365
g, err := l.LoadGenerator(ldr, v, res)
6466
if err != nil {
@@ -74,7 +76,8 @@ func (l *Loader) LoadGenerators(
7476
}
7577

7678
func (l *Loader) LoadGenerator(
77-
ldr ifc.Loader, v ifc.Validator, res *resource.Resource) (resmap.Generator, error) {
79+
ldr ifc.Loader, v ifc.Validator, res *resource.Resource,
80+
) (resmap.Generator, error) {
7881
c, err := l.loadAndConfigurePlugin(ldr, v, res)
7982
if err != nil {
8083
return nil, err
@@ -87,7 +90,8 @@ func (l *Loader) LoadGenerator(
8790
}
8891

8992
func (l *Loader) LoadTransformers(
90-
ldr ifc.Loader, v ifc.Validator, rm resmap.ResMap) ([]*resmap.TransformerWithProperties, error) {
93+
ldr ifc.Loader, v ifc.Validator, rm resmap.ResMap,
94+
) ([]*resmap.TransformerWithProperties, error) {
9195
var result []*resmap.TransformerWithProperties
9296
for _, res := range rm.Resources() {
9397
t, err := l.LoadTransformer(ldr, v, res)
@@ -104,7 +108,8 @@ func (l *Loader) LoadTransformers(
104108
}
105109

106110
func (l *Loader) LoadTransformer(
107-
ldr ifc.Loader, v ifc.Validator, res *resource.Resource) (*resmap.TransformerWithProperties, error) {
111+
ldr ifc.Loader, v ifc.Validator, res *resource.Resource,
112+
) (*resmap.TransformerWithProperties, error) {
108113
c, err := l.loadAndConfigurePlugin(ldr, v, res)
109114
if err != nil {
110115
return nil, err
@@ -179,7 +184,8 @@ func isBuiltinPlugin(res *resource.Resource) bool {
179184
func (l *Loader) loadAndConfigurePlugin(
180185
ldr ifc.Loader,
181186
v ifc.Validator,
182-
res *resource.Resource) (c resmap.Configurable, err error) {
187+
res *resource.Resource,
188+
) (c resmap.Configurable, err error) {
183189
if isBuiltinPlugin(res) {
184190
switch l.pc.BpLoadingOptions {
185191
case types.BploLoadFromFileSys:
@@ -192,7 +198,7 @@ func (l *Loader) loadAndConfigurePlugin(
192198
c, err = l.makeBuiltinPlugin(res.GetGvk())
193199
default:
194200
err = fmt.Errorf(
195-
"unknown plugin loader behavior specified: %v",
201+
"unknown plugin loader behavior specified: %s %v", res.GetGvk().String(),
196202
l.pc.BpLoadingOptions)
197203
}
198204
} else {
@@ -282,4 +288,3 @@ func (l *Loader) loadExecOrGoPlugin(resId resid.ResId) (resmap.Configurable, err
282288
}
283289
return c, nil
284290
}
285-

0 commit comments

Comments
 (0)