Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(config map): add binary data to config map detail page #9606

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions modules/api/pkg/resource/configmap/detail.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ type ConfigMapDetail struct {
// Data contains the configuration data.
// Each key must be a valid DNS_SUBDOMAIN with an optional leading dot.
Data map[string]string `json:"data,omitempty"`

// BinaryData contains the configuration binary data.
// Each key must be a valid DNS_SUBDOMAIN with an optional leading dot.
BinaryData map[string]int `json:"binaryData,omitempty"`
}

// GetConfigMapDetail returns detailed information about a config map
Expand All @@ -49,7 +53,18 @@ func GetConfigMapDetail(client kubernetes.Interface, namespace, name string) (*C

func getConfigMapDetail(rawConfigMap *v1.ConfigMap) *ConfigMapDetail {
return &ConfigMapDetail{
ConfigMap: toConfigMap(rawConfigMap.ObjectMeta),
Data: rawConfigMap.Data,
ConfigMap: toConfigMap(rawConfigMap.ObjectMeta),
Data: rawConfigMap.Data,
BinaryData: getBinaryDataKeySize(rawConfigMap.BinaryData),
}
}

func getBinaryDataKeySize(binaryData map[string][]byte) map[string]int {
converted := make(map[string]int)

for key, value := range binaryData {
converted[key] = len(string(value))
}

return converted
}
10 changes: 8 additions & 2 deletions modules/api/schema/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -9999,10 +9999,16 @@
},
"configmap.ConfigMapDetail": {
"required": [
"typeMeta",
"objectMeta"
"objectMeta",
"typeMeta"
],
"properties": {
"binaryData": {
"type": "object",
"additionalProperties": {
"type": "integer"
}
},
"data": {
"type": "object",
"additionalProperties": {
Expand Down
12 changes: 12 additions & 0 deletions modules/web/i18n/de/messages.de.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -2680,6 +2680,18 @@
<source>Hides all-namespaces option from the namespaces dropdown list in UI.</source>
<target state="new">Hides all-namespaces option from the namespaces dropdown list in UI.</target>
</trans-unit>
<trans-unit id="881679026777341622" datatype="html">
<source> Binary Data </source>
<target state="new"> Binary Data </target>
</trans-unit>
<trans-unit id="5313896736024470177" datatype="html">
<source> Key </source>
<target state="new"> Key </target>
</trans-unit>
<trans-unit id="2390412373676968256" datatype="html">
<source> Size </source>
<target state="new"> Size </target>
</trans-unit>
</body>
</file>
</xliff>
12 changes: 12 additions & 0 deletions modules/web/i18n/es/messages.es.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -2672,6 +2672,18 @@
<source>Hides all-namespaces option from the namespaces dropdown list in UI.</source>
<target state="new">Hides all-namespaces option from the namespaces dropdown list in UI.</target>
</trans-unit>
<trans-unit id="881679026777341622" datatype="html">
<source> Binary Data </source>
<target state="new"> Binary Data </target>
</trans-unit>
<trans-unit id="5313896736024470177" datatype="html">
<source> Key </source>
<target state="new"> Key </target>
</trans-unit>
<trans-unit id="2390412373676968256" datatype="html">
<source> Size </source>
<target state="new"> Size </target>
</trans-unit>
</body>
</file>
</xliff>
12 changes: 12 additions & 0 deletions modules/web/i18n/fr/messages.fr.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -2668,6 +2668,18 @@
<source>Hides all-namespaces option from the namespaces dropdown list in UI.</source>
<target state="new">Hides all-namespaces option from the namespaces dropdown list in UI.</target>
</trans-unit>
<trans-unit id="881679026777341622" datatype="html">
<source> Binary Data </source>
<target state="new"> Binary Data </target>
</trans-unit>
<trans-unit id="5313896736024470177" datatype="html">
<source> Key </source>
<target state="new"> Key </target>
</trans-unit>
<trans-unit id="2390412373676968256" datatype="html">
<source> Size </source>
<target state="new"> Size </target>
</trans-unit>
</body>
</file>
</xliff>
12 changes: 12 additions & 0 deletions modules/web/i18n/ja/messages.ja.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -2672,6 +2672,18 @@
<source>Hides all-namespaces option from the namespaces dropdown list in UI.</source>
<target state="new">Hides all-namespaces option from the namespaces dropdown list in UI.</target>
</trans-unit>
<trans-unit id="881679026777341622" datatype="html">
<source> Binary Data </source>
<target state="new"> Binary Data </target>
</trans-unit>
<trans-unit id="5313896736024470177" datatype="html">
<source> Key </source>
<target state="new"> Key </target>
</trans-unit>
<trans-unit id="2390412373676968256" datatype="html">
<source> Size </source>
<target state="new"> Size </target>
</trans-unit>
</body>
</file>
</xliff>
12 changes: 12 additions & 0 deletions modules/web/i18n/ko/messages.ko.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -2672,6 +2672,18 @@
<source>Hides all-namespaces option from the namespaces dropdown list in UI.</source>
<target state="new">Hides all-namespaces option from the namespaces dropdown list in UI.</target>
</trans-unit>
<trans-unit id="881679026777341622" datatype="html">
<source> Binary Data </source>
<target state="new"> Binary Data </target>
</trans-unit>
<trans-unit id="5313896736024470177" datatype="html">
<source> Key </source>
<target state="new"> Key </target>
</trans-unit>
<trans-unit id="2390412373676968256" datatype="html">
<source> Size </source>
<target state="new"> Size </target>
</trans-unit>
</body>
</file>
</xliff>
9 changes: 9 additions & 0 deletions modules/web/i18n/messages.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -1979,6 +1979,15 @@
<trans-unit id="8967487471439603323" datatype="html">
<source>Hides all-namespaces option from the namespaces dropdown list in UI.</source>
</trans-unit>
<trans-unit id="2390412373676968256" datatype="html">
<source> Size </source>
</trans-unit>
<trans-unit id="5313896736024470177" datatype="html">
<source> Key </source>
</trans-unit>
<trans-unit id="881679026777341622" datatype="html">
<source> Binary Data </source>
</trans-unit>
</body>
</file>
</xliff>
12 changes: 12 additions & 0 deletions modules/web/i18n/zh-Hans/messages.zh-Hans.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -2672,6 +2672,18 @@
<source>Hides all-namespaces option from the namespaces dropdown list in UI.</source>
<target state="new">Hides all-namespaces option from the namespaces dropdown list in UI.</target>
</trans-unit>
<trans-unit id="881679026777341622" datatype="html">
<source> Binary Data </source>
<target state="new"> Binary Data </target>
</trans-unit>
<trans-unit id="5313896736024470177" datatype="html">
<source> Key </source>
<target state="new"> Key </target>
</trans-unit>
<trans-unit id="2390412373676968256" datatype="html">
<source> Size </source>
<target state="new"> Size </target>
</trans-unit>
</body>
</file>
</xliff>
12 changes: 12 additions & 0 deletions modules/web/i18n/zh-Hant-HK/messages.zh-Hant-HK.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -2672,6 +2672,18 @@
<source>Hides all-namespaces option from the namespaces dropdown list in UI.</source>
<target state="new">Hides all-namespaces option from the namespaces dropdown list in UI.</target>
</trans-unit>
<trans-unit id="881679026777341622" datatype="html">
<source> Binary Data </source>
<target state="new"> Binary Data </target>
</trans-unit>
<trans-unit id="5313896736024470177" datatype="html">
<source> Key </source>
<target state="new"> Key </target>
</trans-unit>
<trans-unit id="2390412373676968256" datatype="html">
<source> Size </source>
<target state="new"> Size </target>
</trans-unit>
</body>
</file>
</xliff>
12 changes: 12 additions & 0 deletions modules/web/i18n/zh-Hant/messages.zh-Hant.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -2672,6 +2672,18 @@
<source>Hides all-namespaces option from the namespaces dropdown list in UI.</source>
<target state="new">Hides all-namespaces option from the namespaces dropdown list in UI.</target>
</trans-unit>
<trans-unit id="881679026777341622" datatype="html">
<source> Binary Data </source>
<target state="new"> Binary Data </target>
</trans-unit>
<trans-unit id="5313896736024470177" datatype="html">
<source> Key </source>
<target state="new"> Key </target>
</trans-unit>
<trans-unit id="2390412373676968256" datatype="html">
<source> Size </source>
<target state="new"> Size </target>
</trans-unit>
</body>
</file>
</xliff>
16 changes: 16 additions & 0 deletions modules/web/src/resource/config/configmap/detail/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,20 @@ export class ConfigMapDetailComponent implements OnInit, OnDestroy {

return JSON.stringify(cm.data);
}

getConfigMapBinaryData(cm: ConfigMapDetail): {
name: string;
size: number;
}[] {
if (!cm) {
return [];
}

return Object.entries(cm.binaryData).map(([name, size]) => ({
name,
size,
}));
}

displayedBinaryDataColumns: string[] = ['name', 'size'];
}
49 changes: 49 additions & 0 deletions modules/web/src/resource/config/configmap/detail/template.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,52 @@
</div>
</div>
</kd-card>

<kd-card
[initialized]="isInitialized"
role="table"
>
<div
title
i18n
>
Binary Data
</div>
<div content>
<mat-table
*ngIf="configMap?.binaryData"
[dataSource]="getConfigMapBinaryData(configMap)"
>
<ng-container matColumnDef="name">
<mat-header-cell
*matHeaderCellDef
i18n
>
Key
</mat-header-cell>
<mat-cell *matCellDef="let cm"> {{ cm.name }} </mat-cell>
</ng-container>

<ng-container matColumnDef="size">
<mat-header-cell
*matHeaderCellDef
i18n
>
Size
</mat-header-cell>
<mat-cell *matCellDef="let cm"> {{ cm.size }} bytes </mat-cell>
</ng-container>

<mat-header-row *matHeaderRowDef="displayedBinaryDataColumns"></mat-header-row>
<mat-row *matRowDef="let row; columns: displayedBinaryDataColumns"></mat-row>
</mat-table>

<div
*ngIf="!configMap?.binaryData"
class="kd-card-padding"
i18n
>
There is no data to display.
</div>
</div>
</kd-card>
1 change: 1 addition & 0 deletions modules/web/src/typings/root.api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -603,6 +603,7 @@ export interface IngressClassDetail extends ResourceDetail {

export interface ConfigMapDetail extends ResourceDetail {
data: StringMap;
binaryData: Record<string, number>;
}

export interface CRDDetail extends ResourceDetail {
Expand Down
Loading