Skip to content

Commit 68326b8

Browse files
committed
fix: return binary data size instead of content
1 parent b4bf1f1 commit 68326b8

File tree

4 files changed

+16
-6
lines changed

4 files changed

+16
-6
lines changed

modules/api/pkg/resource/configmap/detail.go

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ type ConfigMapDetail struct {
3535

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

4141
// GetConfigMapDetail returns detailed information about a config map
@@ -55,6 +55,16 @@ func getConfigMapDetail(rawConfigMap *v1.ConfigMap) *ConfigMapDetail {
5555
return &ConfigMapDetail{
5656
ConfigMap: toConfigMap(rawConfigMap.ObjectMeta),
5757
Data: rawConfigMap.Data,
58-
BinaryData: rawConfigMap.BinaryData,
58+
BinaryData: getBinaryDataKeySize(rawConfigMap.BinaryData),
5959
}
6060
}
61+
62+
func getBinaryDataKeySize(binaryData map[string][]byte) map[string]int {
63+
converted := make(map[string]int)
64+
65+
for key, value := range binaryData {
66+
converted[key] = len(string(value))
67+
}
68+
69+
return converted
70+
}

modules/api/schema/swagger.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10006,7 +10006,7 @@
1000610006
"binaryData": {
1000710007
"type": "object",
1000810008
"additionalProperties": {
10009-
"type": "string"
10009+
"type": "integer"
1001010010
}
1001110011
},
1001210012
"data": {

modules/web/src/resource/config/configmap/detail/component.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,9 @@ export class ConfigMapDetailComponent implements OnInit, OnDestroy {
7575
return [];
7676
}
7777

78-
return Object.entries(cm.binaryData).map(([name, value]) => ({
78+
return Object.entries(cm.binaryData).map(([name, size]) => ({
7979
name,
80-
size: atob(value).length,
80+
size,
8181
}));
8282
}
8383

modules/web/src/typings/root.api.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -603,7 +603,7 @@ export interface IngressClassDetail extends ResourceDetail {
603603

604604
export interface ConfigMapDetail extends ResourceDetail {
605605
data: StringMap;
606-
binaryData: StringMap;
606+
binaryData: Record<string, number>;
607607
}
608608

609609
export interface CRDDetail extends ResourceDetail {

0 commit comments

Comments
 (0)