Error: error parsing template {{.data.”key-x”}}, template: output:1: bad character U+002D ‘-’

Error return by the Openshift cluster when using the oc tool to retrieve secrets with a key containing a dash(“-”) in it.


Let’s say the secret is defined in follow namespace &

  • namespace: test
  • name of the secret: `config-parameters`


kind: Secret
apiVersion: v1
name: config-parameters
namespace: test
test-id: dGVzdC12YWx1ZQ==
type: Opaque

Let’s try to retrieve the secret “config-parameters” with the key:”test-id”

Execute the following commands (change the “test-id” accordingly)

export NAMESPACE=testexport NAME=config-parametersoc get secrets/$NAME -n $NAMESPACE —-template=’{{index .data "test-id"}}’|base64 -d

Hope this was helpful. Thank you for reading.



Abhishek koserwal

#redhatter #opensource #developer #kubernetes #keycloak #golang #openshift #quarkus #spring