Repository: kubernetes/dashboard
Pull request #5774 (2021-01-26 11:58:58)

BugFix: raw API calls for ingress should use NetworkingV1beta1 client
This is the bugfix for an issue I caused myself. Ops (but it has never been released :)

When I wrote the PR to move Ingress calls to use extensions/networkingv1beta ( https://github.com/kubernetes/dashboard/pull/5742 ) I forgot to make the raw links to use it.

In other words, on k8s <= 1.18 one could not see the raw yaml of an ingress.

This PR fix that

k8s-ci-robot: [APPROVALNOTIFIER] This PR is **NOT APPROVED**

This pull-request has been approved by: *<a href="https://github.com/kubernetes/dashboard/pull/5774#" title="Author self-approved">marcosdiez</a>*
To complete the [pull request process](https://git.k8s.io/community/contributors/guide/owners.md#the-code-review-process), please assign **floreks** after the PR has been reviewed.
You can assign the PR to them by writing `/assign @floreks` in a comment when ready.

The full list of commands accepted by this bot can be found [here](https://go.k8s.io/bot-commands?repo=kubernetes%2Fdashboard).

<details open>
Needs approval from an approver in each of these files:

- **[OWNERS](https://github.com/kubernetes/dashboard/blob/master/OWNERS)**

Approvers can indicate their approval by writing `/approve` in a comment
Approvers can cancel approval by writing `/approve cancel` in a comment
</details>
<!-- META={"approvers":["floreks"]} -->
codecov[bot]: # [Codecov](https://codecov.io/gh/kubernetes/dashboard/pull/5774?src=pr&el=h1) Report
> Merging [#5774](https://codecov.io/gh/kubernetes/dashboard/pull/5774?src=pr&el=desc) (08a2aaa) into [master](https://codecov.io/gh/kubernetes/dashboard/commit/3c309a1187fd82ab9400d100e5b94936adf5ae19?el=desc) (3c309a1) will **decrease** coverage by `0.02%`.
> The diff coverage is `0.00%`.


```diff
@@            Coverage Diff             @@
##           master    #5774      +/-   ##
==========================================
- Coverage   44.44%   44.41%   -0.03%     
==========================================
  Files         214      214              
  Lines        9124     9127       +3     
  Branches      110      110              
==========================================
- Hits         4055     4054       -1     
- Misses       4795     4798       +3     
- Partials      274      275       +1     
```

floreks: /lgtm
/approve
k8s-ci-robot: [APPROVALNOTIFIER] This PR is **APPROVED**

This pull-request has been approved by: *<a href="https://github.com/kubernetes/dashboard/pull/5774#issuecomment-767507830" title="Approved">floreks</a>*, *<a href="https://github.com/kubernetes/dashboard/pull/5774#" title="Author self-approved">marcosdiez</a>*

The full list of commands accepted by this bot can be found [here](https://go.k8s.io/bot-commands?repo=kubernetes%2Fdashboard).

The pull request process is described [here](https://git.k8s.io/community/contributors/guide/owners.md#the-code-review-process)

<details >
Needs approval from an approver in each of these files:

- ~~[OWNERS](https://github.com/kubernetes/dashboard/blob/master/OWNERS)~~ [floreks]

Approvers can indicate their approval by writing `/approve` in a comment
Approvers can cancel approval by writing `/approve cancel` in a comment
</details>
<!-- META={"approvers":[]} -->

Patch:
diff --git a/src/app/backend/api/types.go b/src/app/backend/api/types.go
index d97907462..6d5272f73 100644
--- a/src/app/backend/api/types.go
+++ b/src/app/backend/api/types.go
@@ -171,17 +171,18 @@ type ClientType string
 
 // List of client types supported by the UI.
 const (
-	ClientTypeDefault             = "restclient"
-	ClientTypeExtensionClient     = "extensionclient"
-	ClientTypeAppsClient          = "appsclient"
-	ClientTypeBatchClient         = "batchclient"
-	ClientTypeBetaBatchClient     = "betabatchclient"
-	ClientTypeAutoscalingClient   = "autoscalingclient"
-	ClientTypeStorageClient       = "storageclient"
-	ClientTypeRbacClient          = "rbacclient"
-	ClientTypeAPIExtensionsClient = "apiextensionsclient"
-	ClientTypeNetworkingClient    = "networkingclient"
-	ClientTypePluginsClient       = "plugin"
+	ClientTypeDefault              = "restclient"
+	ClientTypeExtensionClient      = "extensionclient"
+	ClientTypeAppsClient           = "appsclient"
+	ClientTypeBatchClient          = "batchclient"
+	ClientTypeBetaBatchClient      = "betabatchclient"
+	ClientTypeAutoscalingClient    = "autoscalingclient"
+	ClientTypeStorageClient        = "storageclient"
+	ClientTypeRbacClient           = "rbacclient"
+	ClientTypeAPIExtensionsClient  = "apiextensionsclient"
+	ClientTypeNetworkingClient     = "networkingclient"
+	ClientTypeBetaNetworkingClient = "betanetworkingclient"
+	ClientTypePluginsClient        = "plugin"
 )
 
 // APIMapping is the mapping from resource kind to ClientType and Namespaced.
@@ -204,7 +205,7 @@ var KindToAPIMapping = map[string]APIMapping{
 	ResourceKindDeployment:               {"deployments", ClientTypeAppsClient, true},
 	ResourceKindEvent:                    {"events", ClientTypeDefault, true},
 	ResourceKindHorizontalPodAutoscaler:  {"horizontalpodautoscalers", ClientTypeAutoscalingClient, true},
-	ResourceKindIngress:                  {"ingresses", ClientTypeNetworkingClient, true},
+	ResourceKindIngress:                  {"ingresses", ClientTypeBetaNetworkingClient, true},
 	ResourceKindJob:                      {"jobs", ClientTypeBatchClient, true},
 	ResourceKindCronJob:                  {"cronjobs", ClientTypeBetaBatchClient, true},
 	ResourceKindLimitRange:               {"limitrange", ClientTypeDefault, true},
diff --git a/src/app/backend/client/manager.go b/src/app/backend/client/manager.go
index 00be644bd..b689dcbc7 100644
--- a/src/app/backend/client/manager.go
+++ b/src/app/backend/client/manager.go
@@ -276,6 +276,7 @@ func (self *clientManager) VerberClient(req *restful.Request, config *rest.Confi
 		k8sClient.StorageV1().RESTClient(),
 		k8sClient.RbacV1().RESTClient(),
 		k8sClient.NetworkingV1().RESTClient(),
+		k8sClient.NetworkingV1beta1().RESTClient(),
 		apiextensionsRestClient,
 		pluginsclient.DashboardV1alpha1().RESTClient(),
 		config), nil
diff --git a/src/app/backend/client/verber.go b/src/app/backend/client/verber.go
index f8a206573..120d12611 100644
--- a/src/app/backend/client/verber.go
+++ b/src/app/backend/client/verber.go
@@ -33,18 +33,19 @@ import (
 // resourceVerber is a struct responsible for doing common verb operations on resources, like
 // DELETE, PUT, UPDATE.
 type resourceVerber struct {
-	client              RESTClient
-	extensionsClient    RESTClient
-	appsClient          RESTClient
-	batchClient         RESTClient
-	betaBatchClient     RESTClient
-	autoscalingClient   RESTClient
-	storageClient       RESTClient
-	rbacClient          RESTClient
-	networkingClient    RESTClient
-	apiExtensionsClient RESTClient
-	pluginsClient       RESTClient
-	config              *restclient.Config
+	client               RESTClient
+	extensionsClient     RESTClient
+	appsClient           RESTClient
+	batchClient          RESTClient
+	betaBatchClient      RESTClient
+	autoscalingClient    RESTClient
+	storageClient        RESTClient
+	rbacClient           RESTClient
+	networkingClient     RESTClient
+	betaNetworkingClient RESTClient
+	apiExtensionsClient  RESTClient
+	pluginsClient        RESTClient
+	config               *restclient.Config
 }
 
 type crdInfo struct {
@@ -72,6 +73,8 @@ func (verber *resourceVerber) getRESTClientByType(clientType api.ClientType) RES
 		return verber.rbacClient
 	case api.ClientTypeNetworkingClient:
 		return verber.networkingClient
+	case api.ClientTypeBetaNetworkingClient:
+		return verber.betaNetworkingClient
 	case api.ClientTypeAPIExtensionsClient:
 		return verber.apiExtensionsClient
 	case api.ClientTypePluginsClient:
@@ -167,9 +170,9 @@ type RESTClient interface {
 }
 
 // NewResourceVerber creates a new resource verber that uses the given client for performing operations.
-func NewResourceVerber(client, extensionsClient, appsClient, batchClient, betaBatchClient, autoscalingClient, storageClient, rbacClient, networkingClient, apiExtensionsClient, pluginsClient RESTClient, config *restclient.Config) clientapi.ResourceVerber {
+func NewResourceVerber(client, extensionsClient, appsClient, batchClient, betaBatchClient, autoscalingClient, storageClient, rbacClient, networkingClient, betaNetworkingClient, apiExtensionsClient, pluginsClient RESTClient, config *restclient.Config) clientapi.ResourceVerber {
 	return &resourceVerber{client, extensionsClient, appsClient,
-		batchClient, betaBatchClient, autoscalingClient, storageClient, rbacClient, networkingClient, apiExtensionsClient, pluginsClient, config}
+		batchClient, betaBatchClient, autoscalingClient, storageClient, rbacClient, networkingClient, betaNetworkingClient, apiExtensionsClient, pluginsClient, config}
 }
 
 // Delete deletes the resource of the given kind in the given namespace with the given name.


Test patch:
diff --git a/src/app/backend/auth/manager_test.go b/src/app/backend/auth/manager_test.go
index 0c84f278e..559811779 100644
--- a/src/app/backend/auth/manager_test.go
+++ b/src/app/backend/auth/manager_test.go
@@ -87,7 +87,7 @@ func (self *fakeClientManager) HasAccess(authInfo api.AuthInfo) error {
 }
 
 func (self *fakeClientManager) VerberClient(req *restful.Request, config *rest.Config) (clientapi.ResourceVerber, error) {
-	return client.NewResourceVerber(nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil), nil
+	return client.NewResourceVerber(nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil), nil
 }
 
 func (self *fakeClientManager) CanI(req *restful.Request, ssar *v1.SelfSubjectAccessReview) bool {