I'm trying to replicate this command in the subprocess library.
kubectl patch secret foo --type=json --patch-file=/dev/stdin <<-EOF
[
{
"op": "replace",
"path": "/data/metadata/name",
"value": "bar"
}
]
EOF
How do I go about passing the below value via stdin?
<<-EOF
[
{
"op": "replace",
"path": "/data/metadata/name",
"value": "bar"
}
]
EOF
Ended up getting it working with similar to the following below:
def patch_secret(self, session):
cmd = f'patch secret {self.secret_name} --namespace {self.namespace}' \
f' --type=json --patch-file=/dev/stdin'
data="[{"op": "replace", "path": "/data/foo", "value": "TklFLXhmVnhsRHY4dnZMUEx0WXpJQ0M2bHl4Q1c4cElFdHpxeWFQN1VJTGs="}]"
r = subprocess.run(commands, input=data, env=envs, capture_output=True, universal_newlines=True, **kwargs)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.