notes(feishu): 完整带 ~/.local/share/lark-cli/ 加密 token 进 sidecar
deploy notes / build-and-deploy (push) Successful in 2m4s
deploy notes / build-and-deploy (push) Successful in 2m4s
之前只 cp config.json (365B 索引),user OAuth token 实际加密存在
~/.local/share/lark-cli/{master.key, appsecret_*.enc, cli_*_*.enc}。
secret 改成捎带全部 4 个文件;initContainer cp 到 PVC 两个子目录;
sidecar mount /root/.lark-cli + /root/.local/share/lark-cli 两路。
server.py 撤回 --as user(带上 token 后能调 docs:document:create scope)。
This commit is contained in:
@@ -198,6 +198,7 @@ def convert(req: ConvertReq):
|
|||||||
if not md.exists():
|
if not md.exists():
|
||||||
raise HTTPException(400, f'md not found: {md}')
|
raise HTTPException(400, f'md not found: {md}')
|
||||||
|
|
||||||
|
# user identity = fam 自己拥有 doc(host 上手动跑过 OAuth 授权一次)
|
||||||
cmd = ['/usr/local/bin/markdown-to-feishu', str(md), '--as', 'user']
|
cmd = ['/usr/local/bin/markdown-to-feishu', str(md), '--as', 'user']
|
||||||
if req.existing_doc_id:
|
if req.existing_doc_id:
|
||||||
cmd += ['--update', req.existing_doc_id]
|
cmd += ['--update', req.existing_doc_id]
|
||||||
@@ -241,6 +242,7 @@ def convert(req: ConvertReq):
|
|||||||
raise HTTPException(502, f'md2feishu missing doc_id/url: {data}')
|
raise HTTPException(502, f'md2feishu missing doc_id/url: {data}')
|
||||||
log.info("ok: doc_id=%s url=%s embeds=%s",
|
log.info("ok: doc_id=%s url=%s embeds=%s",
|
||||||
doc_id, url, data.get('embeds_inserted'))
|
doc_id, url, data.get('embeds_inserted'))
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'doc_id': doc_id,
|
'doc_id': doc_id,
|
||||||
'url': url,
|
'url': url,
|
||||||
|
|||||||
+18
-11
@@ -37,23 +37,29 @@ spec:
|
|||||||
imagePullSecrets:
|
imagePullSecrets:
|
||||||
- name: registry-creds
|
- name: registry-creds
|
||||||
initContainers:
|
initContainers:
|
||||||
# secret volume 是只读的,但 lark-cli 跑时要写 cache / refresh token。
|
# lark-cli auth 分两处:
|
||||||
# 启动时把 secret 里的 config.json 复制到 PVC 子目录 lark-cli/,主容器再挂这个子目录到 ~/.lark-cli。
|
# ~/.lark-cli/config.json — app id / open id 索引
|
||||||
# 已存在不覆盖(保留运行时刷新过的 token)。
|
# ~/.local/share/lark-cli/*.enc + master.key — 加密的 OAuth user token
|
||||||
|
# secret volume 只读但 lark-cli 跑时要刷 token 写回。先 cp 到 PVC 让它可写。
|
||||||
|
# 已存在不覆盖:保留运行时 refresh 过的 token,免每次重启回滚到老 token。
|
||||||
- name: lark-config-init
|
- name: lark-config-init
|
||||||
image: busybox:1.36
|
image: busybox:1.36
|
||||||
command:
|
command:
|
||||||
- sh
|
- sh
|
||||||
- -c
|
- -c
|
||||||
- |
|
- |
|
||||||
mkdir -p /data/lark-cli
|
mkdir -p /data/lark-cli /data/lark-share
|
||||||
if [ ! -f /data/lark-cli/config.json ]; then
|
if [ ! -f /data/lark-cli/config.json ]; then
|
||||||
cp /secrets/lark-cli/config.json /data/lark-cli/config.json
|
cp /secrets/lark-cli/config.json /data/lark-cli/config.json
|
||||||
chmod 600 /data/lark-cli/config.json
|
echo "seeded ~/.lark-cli/config.json"
|
||||||
echo "seeded lark-cli config from secret"
|
|
||||||
else
|
|
||||||
echo "lark-cli config already present in PVC, leaving alone"
|
|
||||||
fi
|
fi
|
||||||
|
for f in master.key appsecret_cli_a3f21503fbb8900e.enc cli_a3f21503fbb8900e_ou_1d4fb299843b6a341c1942b056181ca8.enc; do
|
||||||
|
if [ ! -f "/data/lark-share/$f" ]; then
|
||||||
|
cp "/secrets/lark-cli/$f" "/data/lark-share/$f"
|
||||||
|
echo "seeded ~/.local/share/lark-cli/$f"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
chmod -R 600 /data/lark-cli /data/lark-share 2>/dev/null || true
|
||||||
volumeMounts:
|
volumeMounts:
|
||||||
- name: lark-cli-secret
|
- name: lark-cli-secret
|
||||||
mountPath: /secrets/lark-cli
|
mountPath: /secrets/lark-cli
|
||||||
@@ -142,6 +148,9 @@ spec:
|
|||||||
- name: data
|
- name: data
|
||||||
mountPath: /root/.lark-cli
|
mountPath: /root/.lark-cli
|
||||||
subPath: lark-cli
|
subPath: lark-cli
|
||||||
|
- name: data
|
||||||
|
mountPath: /root/.local/share/lark-cli
|
||||||
|
subPath: lark-share
|
||||||
volumes:
|
volumes:
|
||||||
- name: data
|
- name: data
|
||||||
persistentVolumeClaim:
|
persistentVolumeClaim:
|
||||||
@@ -149,9 +158,7 @@ spec:
|
|||||||
- name: lark-cli-secret
|
- name: lark-cli-secret
|
||||||
secret:
|
secret:
|
||||||
secretName: lark-cli-creds
|
secretName: lark-cli-creds
|
||||||
items:
|
# 默认挂全部 keys(config.json + master.key + 两个 .enc)
|
||||||
- key: config.json
|
|
||||||
path: config.json
|
|
||||||
---
|
---
|
||||||
apiVersion: v1
|
apiVersion: v1
|
||||||
kind: Service
|
kind: Service
|
||||||
|
|||||||
Reference in New Issue
Block a user