Symptom:
Related code:o.pgreplicamaster.Spec.Template.Spec.Volumes = []corev1.Volume{
{Name: "pgreplica-config",
VolumeSource: corev1.VolumeSource{
ConfigMap: corev1.ConfigMapVolumeSource{
LocalObjectReference: corev1.LocalObjectReference{Name: o.UserSpecifiedCM},
},
},
},
}
Compile Error
cannot use "k8s.io/api/core/v1".ConfigMapVolumeSource literal (type "k8s.io/api/core/v1".ConfigMapVolumeSource) as type *"k8s.io/api/core/v1".ConfigMapVolumeSource in field value
Solution:
Refer VolumeSource k8s doc. ConfigMap suppose to have pointer *ConfigMapVolumeSource, not value of ConfigMapVolumeSource , We need to add &.Meanwhile we can't mix field value and value , refer stackflow link
Correct code is:
o.pgreplicamaster.Spec.Template.Spec.Volumes = []corev1.Volume{
{Name: "pgreplica-config",
VolumeSource: corev1.VolumeSource{
ConfigMap: &corev1.ConfigMapVolumeSource{
LocalObjectReference: corev1.LocalObjectReference{Name: o.UserSpecifiedCM},
},
},
},
}
No comments:
Post a Comment