将列表内容从yaml添加到configmap | openshift |期待char'“'但得到char'['

问题描述

我正在尝试使用YAML文件在OpenShift中创建ConfigMap。

我的YAML的值列表如下。

kind: ConfigMap
apiVersion: v1
metadata:
  name: sample-map-json-fields
  namespace: default
data:
  fields:
    - hello
    - world
    - my.test.field

我像下面这样执行-

 oc create -f filename.yaml

获取如下异常-

来自服务器的错误(BadRequest):创建“ filename.yaml”时出错: 版本“ v1”中的ConfigMap不能作为ConfigMap处理:[pos 42]: json:期望为char'“',但得到char'['

如果我在数据中没有列表内容的情况下也这样做,那么它将起作用。

请帮助您处理ConfigMap的YAML列表。

解决方法

这不起作用,因为您提供的是array,而Kubernetes希望收到string

got "array",expected "string"

请在Kubernetes API文档中阅读有关configMap的更多信息:

data  - _object_   

Data contains the configuration data. Each key must
consist of alphanumeric characters,'-','_' or '.'. Values with
non-UTF-8 byte sequences must use the BinaryData field. The keys
stored in Data must not overlap with the keys in the BinaryData field,this is enforced during validation process.

或者随时随地docs

// Data contains the configuration data.
// Each key must consist of alphanumeric characters,'_' or '.'.
// Values with non-UTF-8 byte sequences must use the BinaryData field.
// The keys stored in Data must not overlap with the keys in
// the BinaryData field,this is enforced during validation process.
// +optional


Data map[string]string `json:"data,omitempty" protobuf:"bytes,2,rep,name=data"`

相关问答

依赖报错 idea导入项目后依赖报错,解决方案:https://blog....
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下...
错误1:gradle项目控制台输出为乱码 # 解决方案:https://bl...
错误还原:在查询的过程中,传入的workType为0时,该条件不起...
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct...