【发布时间】:2022-01-20 14:36:18
【问题描述】:
我想用 go 解析如下结构:
---
prjA:
user1:
metadata:
namespace: prj-ns
spec:
containers:
- image: some-contaner:latest
name: containerssh-client-image
resources:
limits:
ephemeral-storage: 4Gi
requests:
ephemeral-storage: 2Gi
securityContext:
runAsGroup: 1000
runAsNonRoot: true
runAsUser: 1000
imagePullSecrets:
- docker-registry-secret
我正在使用 sigs.k8s.io/yaml 来解组 YAML:
var userConfig map[string]map[string]kubernetes.PodConfig
err = yaml.UnmarshalStrict(yamlFile, &userConfig)
kubernetes 是从github.com/containerssh/kubernetes 导入的。一切正常 - 除了immagePullSecrets 会出现以下错误:
ERROR unmarshal user config file; error [error unmarshaling JSON: while decoding JSON: json: cannot unmarshal string into Go struct field PodSpec.spec.imagePullSecrets of type v1.LocalObjectReference]
在go中指定/解析imagePullSecrets的正确方法是什么?
【问题讨论】:
标签: go kubernetes yaml container-ssh