mirror of
https://github.com/k8sgpt-ai/k8sgpt.git
synced 2025-09-03 00:08:08 +00:00
refactor: replace rest client with controller-runtime clientset for Trivy analyzers (#776)
* refactor: replace rest client with controller-runtime clientset for Trivy analyzers Signed-off-by: ptyin <peteryin1604@gmail.com> * refactor: remove rest client Signed-off-by: ptyin <peteryin1604@gmail.com> --------- Signed-off-by: ptyin <peteryin1604@gmail.com>
This commit is contained in:
@@ -14,12 +14,10 @@ limitations under the License.
|
||||
package kubernetes
|
||||
|
||||
import (
|
||||
"k8s.io/apimachinery/pkg/runtime/serializer"
|
||||
"k8s.io/client-go/kubernetes"
|
||||
_ "k8s.io/client-go/plugin/pkg/client/auth/oidc"
|
||||
"k8s.io/client-go/rest"
|
||||
"k8s.io/client-go/tools/clientcmd"
|
||||
"k8s.io/kubectl/pkg/scheme"
|
||||
ctrl "sigs.k8s.io/controller-runtime/pkg/client"
|
||||
)
|
||||
|
||||
@@ -31,10 +29,6 @@ func (c *Client) GetClient() kubernetes.Interface {
|
||||
return c.Client
|
||||
}
|
||||
|
||||
func (c *Client) GetRestClient() rest.Interface {
|
||||
return c.RestClient
|
||||
}
|
||||
|
||||
func (c *Client) GetCtrlClient() ctrl.Client {
|
||||
return c.CtrlClient
|
||||
}
|
||||
@@ -64,14 +58,6 @@ func NewClient(kubecontext string, kubeconfig string) (*Client, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
config.APIPath = "/api"
|
||||
config.GroupVersion = &scheme.Scheme.PrioritizedVersionsForGroup("")[0]
|
||||
config.NegotiatedSerializer = serializer.WithoutConversionCodecFactory{CodecFactory: scheme.Codecs}
|
||||
|
||||
restClient, err := rest.RESTClientFor(config)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
ctrlClient, err := ctrl.New(config, ctrl.Options{})
|
||||
if err != nil {
|
||||
@@ -85,7 +71,6 @@ func NewClient(kubecontext string, kubeconfig string) (*Client, error) {
|
||||
|
||||
return &Client{
|
||||
Client: clientSet,
|
||||
RestClient: restClient,
|
||||
CtrlClient: ctrlClient,
|
||||
Config: config,
|
||||
ServerVersion: serverVersion,
|
||||
|
Reference in New Issue
Block a user