Skip to content

Commit bd650fe

Browse files
authored
Details page for secrets (#1060)
1 parent a262597 commit bd650fe

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+713
-88
lines changed

i18n/messages-en.xtb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -544,4 +544,10 @@
544544
<translation id="4677646778972512564" key="MSG_RC_LIST_NAMESPACE_LABEL" source="/home/denis/Projects/dashboard/.tmp/serve/app-dev.js" desc="Label 'Namespace' which appears as a column label in the table of replication controllers (RC list view).">Namespace</translation>
545545
<translation id="6106340570580081121" key="MSG_DAEMON_SET_DETAIL_SERVICES_TITLE" source="/home/denis/Projects/dashboard/.tmp/serve/app-dev.js" desc="Title 'Services' for the services information section on the daemon set detail page.">Services</translation>
546546
<translation id="4440799155040620024" key="MSG_REPLICA_SET_DETAIL_SERVICES_TITLE" source="/home/denis/Projects/dashboard/.tmp/serve/app-dev.js" desc="Title 'Services' for the services information section on the replica set detail page.">Services</translation>
547+
<translation id="7998045333531060596" key="MSG_SECRET_INFO_DATA_SECTION" source="/usr/local/google/home/bryk/src/github.com/kubernetes/dashboard/.tmp/serve/app-dev.js" desc="Config map info details section name.">Data</translation>
548+
<translation id="4100438030563245765" key="MSG_SECRET_DETAIL_SECRET_LABEL" source="/usr/local/google/home/bryk/src/github.com/kubernetes/dashboard/.tmp/serve/app-dev.js" desc="Label 'Secret' which appears at the top of the delete dialog, opened from a secret details page.">Secret</translation>
549+
<translation id="6735398210716403327" key="MSG_SECRET_INFO_DETAILS_SECTION" source="/usr/local/google/home/bryk/src/github.com/kubernetes/dashboard/.tmp/serve/app-dev.js" desc="Config map info details section name.">Details</translation>
550+
<translation id="2492306272014913632" key="MSG_SECRET_INFO_NAME_ENTRY" source="/usr/local/google/home/bryk/src/github.com/kubernetes/dashboard/.tmp/serve/app-dev.js" desc="Config map info details section name entry.">Name</translation>
551+
<translation id="2646286682599680700" key="MSG_SECRET_INFO_NAMESPACE_ENTRY" source="/usr/local/google/home/bryk/src/github.com/kubernetes/dashboard/.tmp/serve/app-dev.js" desc="Config map info details section namespace entry.">Namespace</translation>
552+
<translation id="849285697167851134" key="MSG_SECRET_INFO_LABELS_ENTRY" source="/usr/local/google/home/bryk/src/github.com/kubernetes/dashboard/.tmp/serve/app-dev.js" desc="Config map info details section labels entry.">Labels</translation>
547553
</translationbundle>

i18n/messages-ja.xtb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -712,8 +712,8 @@
712712
<translation id="7249897739191369792" key="MSG_CONTAINER_DETAILS_NO_ENV_VARS" source="/usr/local/google/home/bryk/src/github.com/kubernetes/dashboard/.tmp/serve/app-dev.js" desc="Label when there is no container environment variables.">-</translation>
713713
<translation id="3684607543489263600" key="MSG_ENV_FROM_CONFIG_MAP" source="/usr/local/google/home/bryk/src/github.com/kubernetes/dashboard/.tmp/serve/app-dev.js" desc="Label for environment variable that comes from a Config Map">value from ConfigMap <ph name="NAME" />/<ph name="KEY" /></translation>
714714
<translation id="6987669710926523285" key="MSG_NODE_LIST_READY_LABEL" source="/usr/local/google/home/bryk/src/github.com/kubernetes/dashboard/.tmp/serve/app-dev.js" desc="Label 'Ready' which appears as a column label in the table of nodes (node list view).">Ready</translation>
715-
<translation id="910153156225182799" key="MSG_CONFIG_MAP_LIST_NAMESPACE_LABEL" source="/home/denis/Projects/dashboard/.tmp/serve/app-dev.js" desc="Config map list header: namespace.">Namespace</translation>
716715
<translation id="7091154364335994224" key="MSG_DAEMON_SET_LIST_NAMESPACE_LABEL" source="/home/denis/Projects/dashboard/.tmp/serve/app-dev.js" desc="Label 'Namespace' which appears as a column label in the table of daemon sets (daemon set list view).">Namespace</translation>
716+
<translation id="910153156225182799" key="MSG_CONFIG_MAP_LIST_NAMESPACE_LABEL" source="/home/denis/Projects/dashboard/.tmp/serve/app-dev.js" desc="Config map list header: namespace.">Namespace</translation>
717717
<translation id="4677646778972512564" key="MSG_RC_LIST_NAMESPACE_LABEL" source="/home/denis/Projects/dashboard/.tmp/serve/app-dev.js" desc="Label 'Namespace' which appears as a column label in the table of replication controllers (RC list view).">Namespace</translation>
718718
<translation id="6537383105836584689" key="MSG_DEPLOYMENT_LIST_NAMESPACE_LABEL" source="/home/denis/Projects/dashboard/.tmp/serve/app-dev.js" desc="Label 'Namespace' which appears as a column label in the table of deployments (deployment list view).">Namespace</translation>
719719
<translation id="2872431258829082433" key="MSG_JOB_LIST_NAME_LABEL" source="/home/denis/Projects/dashboard/.tmp/serve/app-dev.js" desc="Label 'Name' which appears as a column label in the table of jobs (Job list view).">Name</translation>
@@ -733,4 +733,10 @@
733733
<translation id="6106340570580081121" key="MSG_DAEMON_SET_DETAIL_SERVICES_TITLE" source="/home/denis/Projects/dashboard/.tmp/serve/app-dev.js" desc="Title 'Services' for the services information section on the daemon set detail page.">Services</translation>
734734
<translation id="6106340570580081121" key="MSG_DAEMON_SET_DETAIL_SERVICES_TITLE" source="/home/floreks/Projects/dashboard/.tmp/serve/app-dev.js" desc="Title 'Services' for the services information section on the daemon set detail page.">Services</translation>
735735
<translation id="4440799155040620024" key="MSG_REPLICA_SET_DETAIL_SERVICES_TITLE" source="/home/denis/Projects/dashboard/.tmp/serve/app-dev.js" desc="Title 'Services' for the services information section on the replica set detail page.">Services</translation>
736+
<translation id="7998045333531060596" key="MSG_SECRET_INFO_DATA_SECTION" source="/usr/local/google/home/bryk/src/github.com/kubernetes/dashboard/.tmp/serve/app-dev.js" desc="Config map info details section name.">Data</translation>
737+
<translation id="4100438030563245765" key="MSG_SECRET_DETAIL_SECRET_LABEL" source="/usr/local/google/home/bryk/src/github.com/kubernetes/dashboard/.tmp/serve/app-dev.js" desc="Label 'Secret' which appears at the top of the delete dialog, opened from a secret details page.">Secret</translation>
738+
<translation id="6735398210716403327" key="MSG_SECRET_INFO_DETAILS_SECTION" source="/usr/local/google/home/bryk/src/github.com/kubernetes/dashboard/.tmp/serve/app-dev.js" desc="Config map info details section name.">Details</translation>
739+
<translation id="2492306272014913632" key="MSG_SECRET_INFO_NAME_ENTRY" source="/usr/local/google/home/bryk/src/github.com/kubernetes/dashboard/.tmp/serve/app-dev.js" desc="Config map info details section name entry.">Name</translation>
740+
<translation id="2646286682599680700" key="MSG_SECRET_INFO_NAMESPACE_ENTRY" source="/usr/local/google/home/bryk/src/github.com/kubernetes/dashboard/.tmp/serve/app-dev.js" desc="Config map info details section namespace entry.">Namespace</translation>
741+
<translation id="849285697167851134" key="MSG_SECRET_INFO_LABELS_ENTRY" source="/usr/local/google/home/bryk/src/github.com/kubernetes/dashboard/.tmp/serve/app-dev.js" desc="Config map info details section labels entry.">Labels</translation>
736742
</translationbundle>

src/app/backend/handler/apihandler.go

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ import (
3232
"github.com/kubernetes/dashboard/src/app/backend/resource/job"
3333
"github.com/kubernetes/dashboard/src/app/backend/resource/namespace"
3434
"github.com/kubernetes/dashboard/src/app/backend/resource/node"
35+
"github.com/kubernetes/dashboard/src/app/backend/resource/persistentvolume"
3536
"github.com/kubernetes/dashboard/src/app/backend/resource/petset"
3637
"github.com/kubernetes/dashboard/src/app/backend/resource/pod"
37-
"github.com/kubernetes/dashboard/src/app/backend/resource/persistentvolume"
3838
"github.com/kubernetes/dashboard/src/app/backend/resource/replicaset"
3939
"github.com/kubernetes/dashboard/src/app/backend/resource/replicationcontroller"
4040
"github.com/kubernetes/dashboard/src/app/backend/resource/secret"
@@ -289,13 +289,17 @@ func CreateHTTPAPIHandler(client *clientK8s.Client, heapsterClient client.Heapst
289289
Writes(namespace.NamespaceDetail{}))
290290

291291
apiV1Ws.Route(
292-
apiV1Ws.GET("/secret/{namespace}").
292+
apiV1Ws.GET("/secret").
293293
To(apiHandler.handleGetSecretList).
294294
Writes(secret.SecretList{}))
295295
apiV1Ws.Route(
296-
apiV1Ws.GET("/secret").
296+
apiV1Ws.GET("/secret/{namespace}").
297297
To(apiHandler.handleGetSecretList).
298298
Writes(secret.SecretList{}))
299+
apiV1Ws.Route(
300+
apiV1Ws.GET("/secret/{namespace}/{name}").
301+
To(apiHandler.handleGetSecretDetail).
302+
Writes(secret.SecretDetail{}))
299303
apiV1Ws.Route(
300304
apiV1Ws.POST("/secret").
301305
To(apiHandler.handleCreateImagePullSecret).
@@ -922,6 +926,17 @@ func (apiHandler *APIHandler) handleCreateImagePullSecret(request *restful.Reque
922926
response.WriteHeaderAndEntity(http.StatusCreated, secret)
923927
}
924928

929+
func (apiHandler *APIHandler) handleGetSecretDetail(request *restful.Request, response *restful.Response) {
930+
namespace := request.PathParameter("namespace")
931+
name := request.PathParameter("name")
932+
result, err := secret.GetSecretDetail(apiHandler.client, namespace, name)
933+
if err != nil {
934+
handleInternalError(response, err)
935+
return
936+
}
937+
response.WriteHeaderAndEntity(http.StatusCreated, result)
938+
}
939+
925940
// Handles get secrets list API call.
926941
func (apiHandler *APIHandler) handleGetSecretList(request *restful.Request, response *restful.Response) {
927942
namespace := parseNamespacePathParameter(request)
@@ -947,8 +962,8 @@ func (apiHandler *APIHandler) handleGetConfigMapList(request *restful.Request, r
947962

948963
func (apiHandler *APIHandler) handleGetConfigMapDetail(request *restful.Request, response *restful.Response) {
949964
namespace := request.PathParameter("namespace")
950-
service := request.PathParameter("configmap")
951-
result, err := configmap.GetConfigMapDetail(apiHandler.client, namespace, service)
965+
name := request.PathParameter("configmap")
966+
result, err := configmap.GetConfigMapDetail(apiHandler.client, namespace, name)
952967
if err != nil {
953968
handleInternalError(response, err)
954969
return
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
// Copyright 2015 Google Inc. All Rights Reserved.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
package secret
16+
17+
import (
18+
"log"
19+
20+
"github.com/kubernetes/dashboard/src/app/backend/resource/common"
21+
"k8s.io/kubernetes/pkg/api"
22+
client "k8s.io/kubernetes/pkg/client/unversioned"
23+
)
24+
25+
// SecretDetail API resource provides mechanisms to inject containers with configuration data while keeping
26+
// containers agnostic of Kubernetes
27+
type SecretDetail struct {
28+
ObjectMeta common.ObjectMeta `json:"objectMeta"`
29+
TypeMeta common.TypeMeta `json:"typeMeta"`
30+
31+
// Data contains the secret data. Each key must be a valid DNS_SUBDOMAIN
32+
// or leading dot followed by valid DNS_SUBDOMAIN.
33+
// The serialized form of the secret data is a base64 encoded string,
34+
// representing the arbitrary (possibly non-string) data value here.
35+
Data map[string][]byte `json:"data"`
36+
37+
// Used to facilitate programmatic handling of secret data.
38+
Type api.SecretType `json:"type"`
39+
}
40+
41+
// GetSecretDetail returns returns detailed information about a secret
42+
func GetSecretDetail(client *client.Client, namespace, name string) (*SecretDetail, error) {
43+
log.Printf("Getting details of %s secret in %s namespace", name, namespace)
44+
45+
rawSecret, err := client.Secrets(namespace).Get(name)
46+
47+
if err != nil {
48+
return nil, err
49+
}
50+
51+
return getSecretDetail(rawSecret), nil
52+
}
53+
54+
func getSecretDetail(rawSecret *api.Secret) *SecretDetail {
55+
return &SecretDetail{
56+
ObjectMeta: common.NewObjectMeta(rawSecret.ObjectMeta),
57+
TypeMeta: common.NewTypeMeta(common.ResourceKindSecret),
58+
Data: rawSecret.Data,
59+
Type: rawSecret.Type,
60+
}
61+
}

src/app/externs/backendapi.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -676,6 +676,15 @@ backendApi.NamespaceList;
676676
*/
677677
backendApi.NamespaceDetail;
678678

679+
/**
680+
* @typedef {{
681+
* objectMeta: !backendApi.ObjectMeta,
682+
* typeMeta: !backendApi.TypeMeta,
683+
* data: !Object<string, string>,
684+
* }}
685+
*/
686+
backendApi.SecretDetail;
687+
679688
/**
680689
* @typedef {{
681690
* objectMeta: !backendApi.ObjectMeta,

src/app/frontend/chrome/chrome.scss

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,12 @@ a {
9393
display: inline-block;
9494
}
9595

96+
.kd-pre-block {
97+
margin: 0;
98+
white-space: pre-wrap;
99+
word-wrap: break-word;
100+
}
101+
96102
// Disables animation on md-tab switch. Avoids some flickering and is simpler.
97103
[role='tabpanel'] {
98104
transition: none;

src/app/frontend/chrome/chrome_stateconfig.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export default function stateConfig($stateProvider) {
3535
template: `<div ui-view="${toolbarViewName}"></div>`,
3636
},
3737
[actionbarViewName]: {
38-
template: `<div ui-view="${actionbarViewName}"></div>`,
38+
template: `<div ui-view="${actionbarViewName}" layout="row"></div>`,
3939
},
4040
},
4141
});

src/app/frontend/common/components/actionbar/actionbar.scss

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030

3131
.kd-actionbar-breadcrumbs {
3232
flex-grow: 2;
33+
max-width: 100%;
34+
overflow: hidden;
3335
white-space: nowrap;
3436
}
3537

src/app/frontend/common/components/actionbar/actionbardetailbuttons.html

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,13 @@
1414
limitations under the License.
1515
-->
1616

17-
<kd-actionbar-edit-item resource-kind-name="{{$ctrl.resourceKindName}}"
18-
type-meta="$ctrl.typeMeta"
19-
object-meta="$ctrl.objectMeta">
20-
</kd-actionbar-edit-item>
21-
<kd-actionbar-delete-item resource-kind-name="{{$ctrl.resourceKindName}}"
17+
<div layout="row">
18+
<kd-actionbar-edit-item resource-kind-name="{{$ctrl.resourceKindName}}"
2219
type-meta="$ctrl.typeMeta"
2320
object-meta="$ctrl.objectMeta">
24-
</kd-actionbar-delete-item>
21+
</kd-actionbar-edit-item>
22+
<kd-actionbar-delete-item resource-kind-name="{{$ctrl.resourceKindName}}"
23+
type-meta="$ctrl.typeMeta"
24+
object-meta="$ctrl.objectMeta">
25+
</kd-actionbar-delete-item>
26+
</div>

src/app/frontend/common/components/infocard/infocard.scss

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
kd-info-card-section {
2323
display: flex;
2424
flex-grow: 1;
25+
max-width: 100%;
26+
overflow: hidden;
2527
padding-right: 2 * $baseline-grid;
2628
}
2729
}

0 commit comments

Comments
 (0)