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.



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

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store