Skip to content

Commit 07ace54

Browse files
Sebastian FlorekSebastian Florek
authored andcommitted
Add frontend and backend for pet set list view (#791)
1 parent 1cde4d2 commit 07ace54

39 files changed

+1223
-53
lines changed

i18n/messages-en.xtb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@
111111
<translation id="5605659611398511623" key="MSG_WORKLOADS_DEPLOYMENTS_LABEL" source="/home/mirchev/go_workspace/src/github.com/kubernetes/dashboard/.tmp/serve/app-dev.js" desc="Label &quot;Deployments&quot;, which appears above the deployments list on the workloads page.">Deployments</translation>
112112
<translation id="3282083729093413912" key="MSG_WORKLOADS_REPLICA_SETS_LABEL" source="/home/mirchev/go_workspace/src/github.com/kubernetes/dashboard/.tmp/serve/app-dev.js" desc="Label &quot;Replica sets&quot;, which appears above the replica sets list on the workloads page.">Replica sets</translation>
113113
<translation id="4853525775301386469" key="MSG_WORKLOADS_REPLICATION_CONTROLLERS_LABEL" source="/home/mirchev/go_workspace/src/github.com/kubernetes/dashboard/.tmp/serve/app-dev.js" desc="Label &quot;Replication controllers&quot;, which appears above the replication controllers list on the workloads page.">Replication controllers</translation>
114+
<translation id="8569806629013746854" key="MSG_WORKLOADS_PET_SETS_LABEL" source="/home/floreks/Projects/dashboard/.tmp/serve/app-dev.js" desc="Label &quot;Pet Sets&quot;, which appears above the replica set list on the workloads page.">Pet Sets</translation>
114115
<translation id="494424795601874379" key="MSG_WORKLOADS_PODS_LABEL" source="/home/mirchev/go_workspace/src/github.com/kubernetes/dashboard/.tmp/serve/app-dev.js" desc="Label &quot;Pods&quot;, which appears above the pods list on the workloads page.">Pods</translation>
115116
<translation id="8249554138996646295" key="MSG_WORKLOADS_ACTION_BAR_DEPLOY_TOOLTIP" source="/home/mirchev/go_workspace/src/github.com/kubernetes/dashboard/.tmp/serve/app-dev.js" desc="This tooltip appears when the user hovers over the &quot;+&quot; (Deploy) button on the workloads page.">Deploy a containerized app</translation>
116117
<translation id="4581297925702163661" key="MSG_SERVICE_LIST_NAME_LABEL" source="/home/mirchev/go_workspace/src/github.com/kubernetes/dashboard/.tmp/serve/app-dev.js" desc="Label 'Name' which appears as a column label in the table of services (service list view).">Name</translation>
@@ -130,4 +131,11 @@
130131
<translation id="6864041232530892176" key="MSG_SERVICE_DETAIL_CLUSTER_IP_LABEL" source="/home/mirchev/go_workspace/src/github.com/kubernetes/dashboard/.tmp/serve/app-dev.js" desc="Label 'Cluster IP' for the service IP in the cluster, appears in the connectivity part (right) of the service details view.">Cluster IP</translation>
131132
<translation id="807395060665311082" key="MSG_SERVICE_DETAIL_INTERNAL_ENDPOINTS_LABEL" source="/home/mirchev/go_workspace/src/github.com/kubernetes/dashboard/.tmp/serve/app-dev.js" desc="Label 'Internal endpoints' for the internal endpoints of the service, appears in the connectivity part (right) of the service details view.">Internal endpoints</translation>
132133
<translation id="6468266868985457861" key="MSG_SERVICE_DETAIL_EXTERNAL_ENDPOINTS_LABEL" source="/home/mirchev/go_workspace/src/github.com/kubernetes/dashboard/.tmp/serve/app-dev.js" desc="Label 'External endpoints' for the external endpoints of the service, appears in the connectivity part (right) of the service details view.">External endpoints</translation>
134+
<translation id="1157514904008403171" key="MSG_PET_SET_CARD_TOOLTIP_ERROR" source="/home/floreks/Projects/dashboard/.tmp/serve/app-dev.js" desc="Tooltip text which appears on error icon hover.">One or more pods have errors</translation>
135+
<translation id="5677265435825016706" key="MSG_PET_SET_CARD_TOOLTIP_PENDING" source="/home/floreks/Projects/dashboard/.tmp/serve/app-dev.js" desc="Tooltip text which appears on pending icon hover.">One or more pods are in pending state</translation>
136+
<translation id="3899323843932532450" key="MSG_PET_SET_LIST_HEADER_NAME" source="/home/floreks/Projects/dashboard/.tmp/serve/app-dev.js" desc="Pet set list header: name.">Name</translation>
137+
<translation id="8003529818786986419" key="MSG_PET_SET_LIST_HEADER_LABELS" source="/home/floreks/Projects/dashboard/.tmp/serve/app-dev.js" desc="Pet set list header: labels.">Labels</translation>
138+
<translation id="2586490478144382446" key="MSG_PET_SET_LIST_HEADER_PODS" source="/home/floreks/Projects/dashboard/.tmp/serve/app-dev.js" desc="Pet set list header: pods.">Pods</translation>
139+
<translation id="1017086337822469058" key="MSG_PET_SET_LIST_HEADER_AGE" source="/home/floreks/Projects/dashboard/.tmp/serve/app-dev.js" desc="Pet set list header: age.">Age</translation>
140+
<translation id="5744665687208066898" key="MSG_PET_SET_LIST_HEADER_IMAGES" source="/home/floreks/Projects/dashboard/.tmp/serve/app-dev.js" desc="Pet set list header: images.">Images</translation>
133141
</translationbundle>

i18n/messages-ja.xtb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@
111111
<translation id="5605659611398511623" key="MSG_WORKLOADS_DEPLOYMENTS_LABEL" source="/home/mirchev/go_workspace/src/github.com/kubernetes/dashboard/.tmp/serve/app-dev.js" desc="Label &quot;Deployments&quot;, which appears above the deployments list on the workloads page.">Deployments</translation>
112112
<translation id="3282083729093413912" key="MSG_WORKLOADS_REPLICA_SETS_LABEL" source="/home/mirchev/go_workspace/src/github.com/kubernetes/dashboard/.tmp/serve/app-dev.js" desc="Label &quot;Replica sets&quot;, which appears above the replica sets list on the workloads page.">Replica sets</translation>
113113
<translation id="4853525775301386469" key="MSG_WORKLOADS_REPLICATION_CONTROLLERS_LABEL" source="/home/mirchev/go_workspace/src/github.com/kubernetes/dashboard/.tmp/serve/app-dev.js" desc="Label &quot;Replication controllers&quot;, which appears above the replication controllers list on the workloads page.">Replication controllers</translation>
114+
<translation id="8569806629013746854" key="MSG_WORKLOADS_PET_SETS_LABEL" source="/home/floreks/Projects/dashboard/.tmp/serve/app-dev.js" desc="Label &quot;Pet Sets&quot;, which appears above the replica set list on the workloads page.">Pet Sets</translation>
114115
<translation id="494424795601874379" key="MSG_WORKLOADS_PODS_LABEL" source="/home/mirchev/go_workspace/src/github.com/kubernetes/dashboard/.tmp/serve/app-dev.js" desc="Label &quot;Pods&quot;, which appears above the pods list on the workloads page.">Pods</translation>
115116
<translation id="8249554138996646295" key="MSG_WORKLOADS_ACTION_BAR_DEPLOY_TOOLTIP" source="/home/mirchev/go_workspace/src/github.com/kubernetes/dashboard/.tmp/serve/app-dev.js" desc="This tooltip appears when the user hovers over the &quot;+&quot; (Deploy) button on the workloads page.">Deploy a containerized app</translation>
116117
<translation id="4581297925702163661" key="MSG_SERVICE_LIST_NAME_LABEL" source="/home/mirchev/go_workspace/src/github.com/kubernetes/dashboard/.tmp/serve/app-dev.js" desc="Label 'Name' which appears as a column label in the table of services (service list view).">Name</translation>
@@ -130,4 +131,11 @@
130131
<translation id="6864041232530892176" key="MSG_SERVICE_DETAIL_CLUSTER_IP_LABEL" source="/home/mirchev/go_workspace/src/github.com/kubernetes/dashboard/.tmp/serve/app-dev.js" desc="Label 'Cluster IP' for the service IP in the cluster, appears in the connectivity part (right) of the service details view.">Cluster IP</translation>
131132
<translation id="807395060665311082" key="MSG_SERVICE_DETAIL_INTERNAL_ENDPOINTS_LABEL" source="/home/mirchev/go_workspace/src/github.com/kubernetes/dashboard/.tmp/serve/app-dev.js" desc="Label 'Internal endpoints' for the internal endpoints of the service, appears in the connectivity part (right) of the service details view.">Internal endpoints</translation>
132133
<translation id="6468266868985457861" key="MSG_SERVICE_DETAIL_EXTERNAL_ENDPOINTS_LABEL" source="/home/mirchev/go_workspace/src/github.com/kubernetes/dashboard/.tmp/serve/app-dev.js" desc="Label 'External endpoints' for the external endpoints of the service, appears in the connectivity part (right) of the service details view.">External endpoints</translation>
134+
<translation id="1157514904008403171" key="MSG_PET_SET_CARD_TOOLTIP_ERROR" source="/home/floreks/Projects/dashboard/.tmp/serve/app-dev.js" desc="Tooltip text which appears on error icon hover.">One or more pods have errors</translation>
135+
<translation id="5677265435825016706" key="MSG_PET_SET_CARD_TOOLTIP_PENDING" source="/home/floreks/Projects/dashboard/.tmp/serve/app-dev.js" desc="Tooltip text which appears on pending icon hover.">One or more pods are in pending state</translation>
136+
<translation id="3899323843932532450" key="MSG_PET_SET_LIST_HEADER_NAME" source="/home/floreks/Projects/dashboard/.tmp/serve/app-dev.js" desc="Pet set list header: name.">Name</translation>
137+
<translation id="8003529818786986419" key="MSG_PET_SET_LIST_HEADER_LABELS" source="/home/floreks/Projects/dashboard/.tmp/serve/app-dev.js" desc="Pet set list header: labels.">Labels</translation>
138+
<translation id="2586490478144382446" key="MSG_PET_SET_LIST_HEADER_PODS" source="/home/floreks/Projects/dashboard/.tmp/serve/app-dev.js" desc="Pet set list header: pods.">Pods</translation>
139+
<translation id="1017086337822469058" key="MSG_PET_SET_LIST_HEADER_AGE" source="/home/floreks/Projects/dashboard/.tmp/serve/app-dev.js" desc="Pet set list header: age.">Age</translation>
140+
<translation id="5744665687208066898" key="MSG_PET_SET_LIST_HEADER_IMAGES" source="/home/floreks/Projects/dashboard/.tmp/serve/app-dev.js" desc="Pet set list header: images.">Images</translation>
133141
</translationbundle>

src/app/backend/handler/apihandler.go

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import (
2929
"github.com/kubernetes/dashboard/resource/daemonset"
3030
"github.com/kubernetes/dashboard/resource/deployment"
3131
. "github.com/kubernetes/dashboard/resource/namespace"
32+
"github.com/kubernetes/dashboard/resource/petset"
3233
"github.com/kubernetes/dashboard/resource/pod"
3334
"github.com/kubernetes/dashboard/resource/replicaset"
3435
. "github.com/kubernetes/dashboard/resource/replicationcontroller"
@@ -86,7 +87,8 @@ func FormatResponseLog(resp *restful.Response, req *restful.Request) string {
8687
func CreateHttpApiHandler(client *client.Client, heapsterClient HeapsterClient,
8788
clientConfig clientcmd.ClientConfig) http.Handler {
8889

89-
verber := common.NewResourceVerber(client.RESTClient, client.ExtensionsClient.RESTClient)
90+
verber := common.NewResourceVerber(client.RESTClient, client.ExtensionsClient.RESTClient,
91+
client.AppsClient.RESTClient)
9092
apiHandler := ApiHandler{client, heapsterClient, clientConfig, verber}
9193
wsContainer := restful.NewContainer()
9294

@@ -263,13 +265,35 @@ func CreateHttpApiHandler(client *client.Client, heapsterClient HeapsterClient,
263265
To(apiHandler.handleGetServiceDetail).
264266
Writes(resourceService.ServiceDetail{}))
265267

268+
apiV1Ws.Route(
269+
apiV1Ws.GET("/petset").
270+
To(apiHandler.handleGetPetSetList).
271+
Writes(resourceService.ServiceList{}))
272+
apiV1Ws.Route(
273+
apiV1Ws.GET("/petset/{namespace}").
274+
To(apiHandler.handleGetPetSetList).
275+
Writes(resourceService.ServiceList{}))
276+
266277
apiV1Ws.Route(
267278
apiV1Ws.DELETE("/{kind}/namespace/{namespace}/name/{name}").
268279
To(apiHandler.handleDeleteResource))
269280

270281
return wsContainer
271282
}
272283

284+
// Handles get pet set list API call.
285+
func (apiHandler *ApiHandler) handleGetPetSetList(request *restful.Request,
286+
response *restful.Response) {
287+
namespace := parseNamespacePathParameter(request)
288+
result, err := petset.GetPetSetList(apiHandler.client, namespace)
289+
if err != nil {
290+
handleInternalError(response, err)
291+
return
292+
}
293+
294+
response.WriteHeaderAndEntity(http.StatusCreated, result)
295+
}
296+
273297
// Handles get service list API call.
274298
func (apiHandler *ApiHandler) handleGetServiceList(request *restful.Request, response *restful.Response) {
275299
namespace := parseNamespacePathParameter(request)

src/app/backend/resource/common/resourcechannels.go

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ type ResourceChannels struct {
5858

5959
// List and error channels to Nodes.
6060
NodeList NodeListChannel
61+
62+
// List and error channels to PetSets.
63+
PetSetList PetSetListChannel
6164
}
6265

6366
// ServiceListChannel is a list and error channels to Services.
@@ -297,6 +300,7 @@ func GetReplicaSetListChannel(client client.ReplicaSetsNamespacer,
297300
filteredItems = append(filteredItems, item)
298301
}
299302
}
303+
list.Items = filteredItems
300304
for i := 0; i < numReads; i++ {
301305
channel.List <- list
302306
channel.Error <- err
@@ -329,6 +333,7 @@ func GetDaemonSetListChannel(client client.DaemonSetsNamespacer,
329333
filteredItems = append(filteredItems, item)
330334
}
331335
}
336+
list.Items = filteredItems;
332337
for i := 0; i < numReads; i++ {
333338
channel.List <- list
334339
channel.Error <- err
@@ -346,14 +351,23 @@ type PetSetListChannel struct {
346351

347352
// GetPetSetListChannel returns a pair of channels to a PetSet list and errors that
348353
// both must be read numReads times.
349-
func GetPetSetListChannel(client client.PetSetNamespacer, numReads int) PetSetListChannel {
354+
func GetPetSetListChannel(client client.PetSetNamespacer,
355+
nsQuery *NamespaceQuery, numReads int) PetSetListChannel {
350356
channel := PetSetListChannel{
351357
List: make(chan *apps.PetSetList, numReads),
352358
Error: make(chan error, numReads),
353359
}
354360

355361
go func() {
356-
petSets, err := client.PetSets(api.NamespaceAll).List(listEverything)
362+
petSets, err := client.PetSets(nsQuery.ToRequestParam()).List(listEverything)
363+
var filteredItems []apps.PetSet
364+
for _, item := range petSets.Items {
365+
if nsQuery.Matches(item.ObjectMeta.Namespace) {
366+
filteredItems = append(filteredItems, item)
367+
}
368+
}
369+
370+
petSets.Items = filteredItems;
357371
for i := 0; i < numReads; i++ {
358372
channel.List <- petSets
359373
channel.Error <- err

src/app/backend/resource/common/types.go

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,19 @@ const (
9595
ResourceKindEvent = "event"
9696
ResourceKindReplicationController = "replicationcontroller"
9797
ResourceKindDaemonSet = "daemonset"
98+
ResourceKindPetSet = "petset"
99+
)
100+
101+
// ClientType represents type of client that is used to perform generic operations on resources.
102+
// Different resources belong to different client, i.e. Deployments belongs to extension client
103+
// and PetSets to apps client.
104+
type ClientType string
105+
106+
// List of client types supported by the UI.
107+
const (
108+
ClientTypeDefault = "restclient"
109+
ClientTypeExtensionClient = "extensionclient"
110+
ClientTypeAppsClient = "appsclient"
98111
)
99112

100113
// Mapping from resource kind to K8s apiserver API path. This is mostly pluralization, because
@@ -103,16 +116,18 @@ const (
103116
var kindToAPIMapping = map[string]struct {
104117
// K8s resource name
105118
Resource string
106-
// Whether extensions client should be used. True for extensions client, false for normal.
107-
Extension bool
119+
// Client type used by given resource, i.e. deployments are using extension client and pet
120+
// sets apps client.
121+
ClientType ClientType
108122
}{
109-
ResourceKindService: {"services", false},
110-
ResourceKindPod: {"pods", false},
111-
ResourceKindEvent: {"events", false},
112-
ResourceKindReplicationController: {"replicationcontrollers", false},
113-
ResourceKindDeployment: {"deployments", true},
114-
ResourceKindReplicaSet: {"replicasets", true},
115-
ResourceKindDaemonSet: {"daemonsets", false},
123+
ResourceKindService: {"services", ClientTypeDefault},
124+
ResourceKindPod: {"pods", ClientTypeDefault},
125+
ResourceKindEvent: {"events", ClientTypeDefault},
126+
ResourceKindReplicationController: {"replicationcontrollers", ClientTypeDefault},
127+
ResourceKindDeployment: {"deployments", ClientTypeExtensionClient},
128+
ResourceKindReplicaSet: {"replicasets", ClientTypeExtensionClient},
129+
ResourceKindDaemonSet: {"daemonsets", ClientTypeDefault},
130+
ResourceKindPetSet: {"petsets", ClientTypeAppsClient},
116131
}
117132

118133
// IsSelectorMatching returns true when an object with the given

src/app/backend/resource/common/verber.go

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import (
2525
type ResourceVerber struct {
2626
client RESTClient
2727
extensionsClient RESTClient
28+
appsClient RESTClient
2829
}
2930

3031
// RESTClient is an interface for REST operations used in this file.
@@ -34,8 +35,8 @@ type RESTClient interface {
3435

3536
// NewResourceVerber creates a new resource verber that uses the given client for performing
3637
// operations.
37-
func NewResourceVerber(client RESTClient, extensionsClient RESTClient) ResourceVerber {
38-
return ResourceVerber{client, extensionsClient}
38+
func NewResourceVerber(client, extensionsClient, appsClient RESTClient) ResourceVerber {
39+
return ResourceVerber{client, extensionsClient, appsClient}
3940
}
4041

4142
// Delete deletes the resource of the given kind in the given namespace with the given name.
@@ -45,12 +46,7 @@ func (verber *ResourceVerber) Delete(kind string, namespace string, name string)
4546
return fmt.Errorf("Unknown resource kind: %s", kind)
4647
}
4748

48-
var client RESTClient
49-
if resourceSpec.Extension {
50-
client = verber.extensionsClient
51-
} else {
52-
client = verber.client
53-
}
49+
client := verber.getRESTClientByType(resourceSpec.ClientType)
5450

5551
return client.Delete().
5652
Namespace(namespace).
@@ -59,3 +55,14 @@ func (verber *ResourceVerber) Delete(kind string, namespace string, name string)
5955
Do().
6056
Error()
6157
}
58+
59+
func (verber *ResourceVerber) getRESTClientByType(clientType ClientType) RESTClient {
60+
switch clientType {
61+
case ClientTypeExtensionClient:
62+
return verber.extensionsClient
63+
case ClientTypeAppsClient:
64+
return verber.appsClient
65+
default:
66+
return verber.client
67+
}
68+
}

src/app/backend/resource/deployment/deploymentlist.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import (
1818
"log"
1919

2020
"github.com/kubernetes/dashboard/resource/common"
21+
"github.com/kubernetes/dashboard/resource/event"
2122

2223
"k8s.io/kubernetes/pkg/api"
2324
k8serrors "k8s.io/kubernetes/pkg/api/errors"
@@ -116,6 +117,7 @@ func getDeploymentList(deployments []extensions.Deployment,
116117
matchingPods := common.FilterNamespacedPodsBySelector(pods, deployment.ObjectMeta.Namespace,
117118
deployment.Spec.Selector.MatchLabels)
118119
podInfo := getPodInfo(&deployment, matchingPods)
120+
podInfo.Warnings = event.GetPodsEventWarnings(events, matchingPods)
119121

120122
deploymentList.Deployments = append(deploymentList.Deployments,
121123
Deployment{

0 commit comments

Comments
 (0)