I have a yaml file and in that file I need to replace a specific string that comes after oauth2accesstoken: using a shell script
my current shell script :-
#!/bin/sh
password=$(gcloud auth print-access-token)
password="$password" yq -i '.stringData.creds |= "oauth2accesstoken:" + strenv(password)' /test.yaml
Lets Assume Replace Value is "abcdefg1234"
File :-
kind: Secret
metadata:
name: cred
type: Opaque
stringData:
creds: oauth2accesstoken:ya29.a0AJ8fv7hrWsNVlDaXa-j6IUwBRdxt6GDDXMu1234efrtyhAjPWx0uw0174 # dummy key
Output Should be like this:-
kind: Secret
metadata:
name: cred
type: Opaque
stringData:
creds: oauth2accesstoken:abcdefg1234
Error:-
Error: unknown command ".stringData.creds |= \"oauth2accesstoken:\" + strenv(password)" for "yq"
Run 'yq --help' for usage.
Note:-Above keys are dummy keys.