1
0
Fork 0
mirror of https://github.com/kyverno/kyverno.git synced 2024-12-15 17:51:20 +00:00
kyverno/pkg/clients/kube/interface.generated.go
Charles-Edouard Brétéché 447360c1f3
refactor: improve instrumented clients code and support dynamic/metadata client (#5428)
* refactor: improve instrumented clients creation

Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>

* fix

Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>

* refactor: instrumented clients code part 3

Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>

* fix

Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>

* fix

Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>

* fix

Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>

* fix

Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>

* fix

Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>

* metadata

Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>

* metadata

Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>

Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>
2022-11-22 17:10:07 +08:00

73 lines
1.8 KiB
Go

package clientset
import (
"net/http"
"github.com/kyverno/kyverno/pkg/metrics"
k8s_io_client_go_kubernetes "k8s.io/client-go/kubernetes"
"k8s.io/client-go/rest"
)
type Interface interface {
k8s_io_client_go_kubernetes.Interface
WithMetrics(m metrics.MetricsConfigManager, t metrics.ClientType) Interface
WithTracing() Interface
}
type wrapper struct {
k8s_io_client_go_kubernetes.Interface
}
type NewOption func(Interface) Interface
func NewForConfig(c *rest.Config, opts ...NewOption) (Interface, error) {
inner, err := k8s_io_client_go_kubernetes.NewForConfig(c)
if err != nil {
return nil, err
}
return From(inner, opts...), nil
}
func NewForConfigAndClient(c *rest.Config, httpClient *http.Client, opts ...NewOption) (Interface, error) {
inner, err := k8s_io_client_go_kubernetes.NewForConfigAndClient(c, httpClient)
if err != nil {
return nil, err
}
return From(inner, opts...), nil
}
func NewForConfigOrDie(c *rest.Config, opts ...NewOption) Interface {
return From(k8s_io_client_go_kubernetes.NewForConfigOrDie(c), opts...)
}
func from(inner k8s_io_client_go_kubernetes.Interface, opts ...NewOption) Interface {
return &wrapper{inner}
}
func From(inner k8s_io_client_go_kubernetes.Interface, opts ...NewOption) Interface {
i := from(inner)
for _, opt := range opts {
i = opt(i)
}
return i
}
func (i *wrapper) WithMetrics(m metrics.MetricsConfigManager, t metrics.ClientType) Interface {
return from(WrapWithMetrics(i, m, t))
}
func WithMetrics(m metrics.MetricsConfigManager, t metrics.ClientType) NewOption {
return func(i Interface) Interface {
return i.WithMetrics(m, t)
}
}
func (i *wrapper) WithTracing() Interface {
return from(WrapWithTracing(i))
}
func WithTracing() NewOption {
return func(i Interface) Interface {
return i.WithTracing()
}
}