forked from open-policy-agent/opa-envoy-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
plugin.go
27 lines (20 loc) · 873 Bytes
/
plugin.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
// Copyright 2020 The OPA Authors. All rights reserved.
// Use of this source code is governed by an Apache2
// license that can be found in the LICENSE file.
package plugin
import (
"github.com/open-policy-agent/opa/plugins"
"github.com/yerinu2019/opa-envoy-plugin/internal"
)
// Factory defines the interface OPA uses to instantiate a plugin.
type Factory struct{}
// PluginName is the name to register with the OPA plugin manager
const PluginName = internal.PluginName
// New returns the object initialized with a valid plugin configuration.
func (Factory) New(m *plugins.Manager, config interface{}) plugins.Plugin {
return internal.New(m, config.(*internal.Config))
}
// Validate returns a valid configuration to instantiate the plugin.
func (Factory) Validate(m *plugins.Manager, config []byte) (interface{}, error) {
return internal.Validate(m, config)
}