changed initcontainer
This commit is contained in:
@@ -1964,58 +1964,34 @@ spec:
|
|||||||
fsGroup: 1000
|
fsGroup: 1000
|
||||||
initContainers:
|
initContainers:
|
||||||
- name: build-bookmarks-index
|
- name: build-bookmarks-index
|
||||||
image: python:3.12-alpine
|
image: mikefarah/yq:4
|
||||||
securityContext:
|
securityContext:
|
||||||
runAsUser: 0
|
runAsUser: 1000
|
||||||
runAsGroup: 0
|
runAsGroup: 1000
|
||||||
allowPrivilegeEscalation: false
|
allowPrivilegeEscalation: false
|
||||||
command: ["/bin/sh", "-c"]
|
command: ["/bin/sh", "-c"]
|
||||||
args:
|
args:
|
||||||
- |
|
- |
|
||||||
apk add --no-cache py3-yaml >/dev/null
|
set -e
|
||||||
python - <<'PY'
|
mkdir -p /app/assets
|
||||||
import json, os, yaml
|
|
||||||
|
|
||||||
cfg = yaml.safe_load(open('/config/glance.yml', 'r', encoding='utf-8'))
|
yq -o=json '
|
||||||
items = []
|
[ .pages[] as $p
|
||||||
|
| ($p.columns[]?.widgets[]? | select(.type == "bookmarks")) as $w
|
||||||
|
| $w.groups[]? as $g
|
||||||
|
| $g.links[]?
|
||||||
|
| select(.url != null and .url != "")
|
||||||
|
| {
|
||||||
|
title: ((.title // .url) | tostring),
|
||||||
|
url: (.url | tostring),
|
||||||
|
page: ($p.name // "" | tostring),
|
||||||
|
widget: ($w.title // "" | tostring),
|
||||||
|
group: ($g.title // "" | tostring)
|
||||||
|
}
|
||||||
|
] | unique_by(.url)
|
||||||
|
' /config/glance.yml > /app/assets/bookmarks.json
|
||||||
|
|
||||||
for page in cfg.get('pages', []):
|
echo "Bookmarks indexed: $(yq -r 'length' /app/assets/bookmarks.json)"
|
||||||
page_name = page.get('name', '')
|
|
||||||
for col in page.get('columns', []):
|
|
||||||
for w in col.get('widgets', []):
|
|
||||||
if w.get('type') != 'bookmarks':
|
|
||||||
continue
|
|
||||||
widget_title = w.get('title', '')
|
|
||||||
for g in w.get('groups', []):
|
|
||||||
group_title = g.get('title', '')
|
|
||||||
for l in g.get('links', []):
|
|
||||||
title = (l.get('title') or '').strip()
|
|
||||||
url = (l.get('url') or '').strip()
|
|
||||||
if not url:
|
|
||||||
continue
|
|
||||||
items.append({
|
|
||||||
"title": title or url,
|
|
||||||
"url": url,
|
|
||||||
"page": page_name,
|
|
||||||
"widget": widget_title,
|
|
||||||
"group": group_title,
|
|
||||||
})
|
|
||||||
|
|
||||||
# de-dupe by URL
|
|
||||||
seen = set()
|
|
||||||
out = []
|
|
||||||
for it in items:
|
|
||||||
if it["url"] in seen:
|
|
||||||
continue
|
|
||||||
seen.add(it["url"])
|
|
||||||
out.append(it)
|
|
||||||
|
|
||||||
os.makedirs('/app/assets', exist_ok=True)
|
|
||||||
with open('/app/assets/bookmarks.json', 'w', encoding='utf-8') as f:
|
|
||||||
json.dump(out, f, ensure_ascii=False, indent=2)
|
|
||||||
|
|
||||||
print(f"Wrote {len(out)} bookmarks -> /app/assets/bookmarks.json")
|
|
||||||
PY
|
|
||||||
volumeMounts:
|
volumeMounts:
|
||||||
- name: config
|
- name: config
|
||||||
mountPath: /config
|
mountPath: /config
|
||||||
|
|||||||
Reference in New Issue
Block a user