Skip to content

Commit

Permalink
Resolve the lint complaint.
Browse files Browse the repository at this point in the history
  • Loading branch information
csfmomo committed May 7, 2024
1 parent 89b910f commit e0d94e9
Showing 1 changed file with 19 additions and 11 deletions.
30 changes: 19 additions & 11 deletions test/internal/kubernetes/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,36 +75,44 @@ func MustGetRestConfig() *rest.Config {
}

func GetRESTClientForMultitenantCRDFromConfig(config *rest.Config) (*rest.RESTClient, error) {
scheme := runtime.NewScheme()
err := v1alpha1.AddToScheme(scheme)
schemeLocal := runtime.NewScheme()
err := v1alpha1.AddToScheme(schemeLocal)
if err != nil {
return nil, err
return nil, errors.Wrap(err, "failed to AddToScheme")
}
config.ContentConfig.GroupVersion = &v1alpha1.GroupVersion
config.APIPath = "/apis"
config.NegotiatedSerializer = serializer.NewCodecFactory(scheme)
config.NegotiatedSerializer = serializer.NewCodecFactory(schemeLocal)
config.UserAgent = rest.DefaultKubernetesUserAgent()
return rest.UnversionedRESTClientFor(config)
client, err := rest.UnversionedRESTClientFor(config)
if err != nil {
return nil, errors.Wrap(err, "failed to UnversionedRESTClientFor config")
}
return client, nil
}

func GetRESTClientForMultitenantCRD(kubeconfig string) (*rest.RESTClient, error) {
scheme := runtime.NewScheme()
err := v1alpha1.AddToScheme(scheme)
schemeLocal := runtime.NewScheme()
err := v1alpha1.AddToScheme(schemeLocal)
if err != nil {
return nil, err
return nil, errors.Wrap(err, "failed to AddToScheme")
}

restConfig, err := clientcmd.RESTConfigFromKubeConfig([]byte(kubeconfig))
if err != nil {
return nil, err
return nil, errors.Wrap(err, "failed to get RESTConfigFromKubeConfig")
}

restConfig.ContentConfig.GroupVersion = &v1alpha1.GroupVersion
restConfig.APIPath = "/apis"
restConfig.NegotiatedSerializer = serializer.NewCodecFactory(scheme)
restConfig.NegotiatedSerializer = serializer.NewCodecFactory(schemeLocal)
restConfig.UserAgent = rest.DefaultKubernetesUserAgent()

return rest.UnversionedRESTClientFor(restConfig)
client, err := rest.UnversionedRESTClientFor(restConfig)
if err != nil {
return nil, errors.Wrap(err, "failed to UnversionedRESTClientFor config")
}
return client, nil
}

func mustParseResource(path string, out interface{}) {
Expand Down

0 comments on commit e0d94e9

Please sign in to comment.