mirror of
https://github.com/open-policy-agent/opa.git
synced 2026-08-14 20:32:27 -06:00
e43ef0a979
Earlier this evening I tried to run the Go [modernize](https://pkg.go.dev/golang.org/x/tools/gopls/internal/analysis/modernize) analyzer on OPA. That didn't go as planned: - https://github.com/golang/go/issues/73661 - https://github.com/golang/go/issues/73663 While we wait for that to be fixed, I figured an old-fashioned search-and-replace across the repo may work for at least the `interface{}` to `any` conversion. That should help make it easier to see the other fixes as applied by the modernize tool once it has had those issues resolved. Signed-off-by: Anders Eknert <anders@styra.com>
53 lines
1.5 KiB
Go
53 lines
1.5 KiB
Go
// Copyright 2018 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 discovery implements configuration discovery.
|
|
package discovery
|
|
|
|
import (
|
|
"github.com/open-policy-agent/opa/plugins"
|
|
"github.com/open-policy-agent/opa/v1/hooks"
|
|
"github.com/open-policy-agent/opa/v1/metrics"
|
|
v1 "github.com/open-policy-agent/opa/v1/plugins/discovery"
|
|
)
|
|
|
|
const (
|
|
// Name is the discovery plugin name that will be registered with the plugin manager.
|
|
Name = v1.Name
|
|
)
|
|
|
|
// Discovery implements configuration discovery for OPA. When discovery is
|
|
// started it will periodically download a configuration bundle and try to
|
|
// reconfigure the OPA.
|
|
type Discovery = v1.Discovery
|
|
|
|
// Factories provides a set of factory functions to use for
|
|
// instantiating custom plugins.
|
|
func Factories(fs map[string]plugins.Factory) func(*Discovery) {
|
|
return v1.Factories(fs)
|
|
}
|
|
|
|
// Metrics provides a metrics provider to pass to plugins.
|
|
func Metrics(m metrics.Metrics) func(*Discovery) {
|
|
return v1.Metrics(m)
|
|
}
|
|
|
|
func Hooks(hs hooks.Hooks) func(*Discovery) {
|
|
return v1.Hooks(hs)
|
|
}
|
|
|
|
func BootConfig(bootConfig map[string]any) func(*Discovery) {
|
|
return v1.BootConfig(bootConfig)
|
|
}
|
|
|
|
// New returns a new discovery plugin.
|
|
func New(manager *plugins.Manager, opts ...func(*Discovery)) (*Discovery, error) {
|
|
return v1.New(manager, opts...)
|
|
}
|
|
|
|
// Lookup returns the discovery plugin registered with the manager.
|
|
func Lookup(manager *plugins.Manager) *Discovery {
|
|
return v1.Lookup(manager)
|
|
}
|