Commit fd003cc4 authored by Rithu John's avatar Rithu John
Browse files

address feedback

No related merge requests found
Showing with 556 additions and 529 deletions
+556 -529
......@@ -730,9 +730,9 @@ message ConfigMap {
map<string, string> annotations = 4;
map<string, string> labels = 5;
// represents a configmaps data field which is simple
// represents a configmaps data field which is a
// key:value map
google.protobuf.Struct data = 6;
map<string, google.protobuf.Value> data = 6;
}
message ListConfigMapsRequest {
......
This diff is collapsed.
......@@ -4065,14 +4065,21 @@ func (m *ConfigMap) Validate() error {
// no validation rules for Labels
if v, ok := interface{}(m.GetData()).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return ConfigMapValidationError{
field: "Data",
reason: "embedded message failed validation",
cause: err,
for key, val := range m.GetData() {
_ = val
// no validation rules for Data[key]
if v, ok := interface{}(val).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return ConfigMapValidationError{
field: fmt.Sprintf("Data[%v]", key),
reason: "embedded message failed validation",
cause: err,
}
}
}
}
return nil
......
......@@ -83,11 +83,11 @@ func protoForConfigMap(cluster string, k8sconfigMap *v1.ConfigMap) *k8sapiv1.Con
}
// optional fields
if k8sconfigMap.Data != nil {
dataMap := make(map[string]interface{}, len(k8sconfigMap.Data))
dataMap := make(map[string]*structpb.Value, len(k8sconfigMap.Data))
for k, v := range k8sconfigMap.Data {
dataMap[k] = v
dataMap[k], _ = structpb.NewValue(v)
}
ret.Data, _ = structpb.NewStruct(dataMap)
ret.Data = dataMap
}
return ret
}
......@@ -210,10 +210,9 @@ func TestProtoForConfigMap(t *testing.T) {
if len(tt.configMap.Data) > 0 {
mapData := tt.configMap.Data
mapResult := configMap.Data.AsMap()
for key, val := range mapResult {
assert.Equal(t, mapData[key], val)
for key, val := range configMap.Data {
assert.Equal(t, mapData[key], val.GetStringValue())
}
}
})
......
......@@ -12882,7 +12882,7 @@ export namespace clutch {
labels?: ({ [k: string]: string }|null);
 
/** ConfigMap data */
data?: (google.protobuf.IStruct|null);
data?: ({ [k: string]: google.protobuf.IValue }|null);
}
 
/** Represents a ConfigMap. */
......@@ -12910,7 +12910,7 @@ export namespace clutch {
public labels: { [k: string]: string };
 
/** ConfigMap data. */
public data?: (google.protobuf.IStruct|null);
public data: { [k: string]: google.protobuf.IValue };
 
/**
* Verifies a ConfigMap message.
......
......@@ -30461,7 +30461,7 @@ export const clutch = $root.clutch = (() => {
* @property {string|null} [name] ConfigMap name
* @property {Object.<string,string>|null} [annotations] ConfigMap annotations
* @property {Object.<string,string>|null} [labels] ConfigMap labels
* @property {google.protobuf.IStruct|null} [data] ConfigMap data
* @property {Object.<string,google.protobuf.IValue>|null} [data] ConfigMap data
*/
 
/**
......@@ -30475,6 +30475,7 @@ export const clutch = $root.clutch = (() => {
function ConfigMap(properties) {
this.annotations = {};
this.labels = {};
this.data = {};
if (properties)
for (let keys = Object.keys(properties), i = 0; i < keys.length; ++i)
if (properties[keys[i]] != null)
......@@ -30523,11 +30524,11 @@ export const clutch = $root.clutch = (() => {
 
/**
* ConfigMap data.
* @member {google.protobuf.IStruct|null|undefined} data
* @member {Object.<string,google.protobuf.IValue>} data
* @memberof clutch.k8s.v1.ConfigMap
* @instance
*/
ConfigMap.prototype.data = null;
ConfigMap.prototype.data = $util.emptyObject;
 
/**
* Verifies a ConfigMap message.
......@@ -30566,9 +30567,14 @@ export const clutch = $root.clutch = (() => {
return "labels: string{k:string} expected";
}
if (message.data != null && message.hasOwnProperty("data")) {
let error = $root.google.protobuf.Struct.verify(message.data);
if (error)
return "data." + error;
if (!$util.isObject(message.data))
return "data: object expected";
let key = Object.keys(message.data);
for (let i = 0; i < key.length; ++i) {
let error = $root.google.protobuf.Value.verify(message.data[key[i]]);
if (error)
return "data." + error;
}
}
return null;
};
......@@ -30605,10 +30611,15 @@ export const clutch = $root.clutch = (() => {
for (let keys = Object.keys(object.labels), i = 0; i < keys.length; ++i)
message.labels[keys[i]] = String(object.labels[keys[i]]);
}
if (object.data != null) {
if (object.data) {
if (typeof object.data !== "object")
throw TypeError(".clutch.k8s.v1.ConfigMap.data: object expected");
message.data = $root.google.protobuf.Struct.fromObject(object.data);
message.data = {};
for (let keys = Object.keys(object.data), i = 0; i < keys.length; ++i) {
if (typeof object.data[keys[i]] !== "object")
throw TypeError(".clutch.k8s.v1.ConfigMap.data: object expected");
message.data[keys[i]] = $root.google.protobuf.Value.fromObject(object.data[keys[i]]);
}
}
return message;
};
......@@ -30629,12 +30640,12 @@ export const clutch = $root.clutch = (() => {
if (options.objects || options.defaults) {
object.annotations = {};
object.labels = {};
object.data = {};
}
if (options.defaults) {
object.cluster = "";
object.namespace = "";
object.name = "";
object.data = null;
}
if (message.cluster != null && message.hasOwnProperty("cluster"))
object.cluster = message.cluster;
......@@ -30653,8 +30664,11 @@ export const clutch = $root.clutch = (() => {
for (let j = 0; j < keys2.length; ++j)
object.labels[keys2[j]] = message.labels[keys2[j]];
}
if (message.data != null && message.hasOwnProperty("data"))
object.data = $root.google.protobuf.Struct.toObject(message.data, options);
if (message.data && (keys2 = Object.keys(message.data)).length) {
object.data = {};
for (let j = 0; j < keys2.length; ++j)
object.data[keys2[j]] = $root.google.protobuf.Value.toObject(message.data[keys2[j]], options);
}
return object;
};
 
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment