Skip to content

Commit e06d9b8

Browse files
authored
Merge pull request #4 from linuxserver/fix-vars-output
Fix vars output
2 parents 333cbff + 844f190 commit e06d9b8

File tree

3 files changed

+29
-16
lines changed

3 files changed

+29
-16
lines changed

root/app/lsio_github.py

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ def get_repos():
1515

1616
def get_file(repo, branch, path, is_yaml=False):
1717
try:
18-
content = repo.get_contents(path, ref=branch).decoded_content
19-
return yaml.load(content, Loader=yaml.CLoader) if is_yaml else content
18+
return repo.get_contents(path, ref=branch).decoded_content.decode("utf-8")
2019
except:
2120
return None
2221

@@ -27,12 +26,30 @@ def get_last_stable_release(repo):
2726
return release.tag_name, str(release.published_at)
2827
return "latest", str(repo.pushed_at)
2928

30-
def get_readme_vars(repo):
31-
return (get_file(repo, "master", "readme-vars.yml", is_yaml=True) or
29+
def get_readme_vars(repo, project_name):
30+
readme_vars_str = (get_file(repo, "master", "readme-vars.yml", is_yaml=True) or
3231
get_file(repo, "main", "readme-vars.yml", is_yaml=True) or
3332
get_file(repo, "develop", "readme-vars.yml", is_yaml=True) or
3433
get_file(repo, "nightly", "readme-vars.yml", is_yaml=True))
3534

35+
if not readme_vars_str:
36+
return None
37+
38+
replace_map = {
39+
"[{{ project_name|capitalize }}]": project_name,
40+
"{{ project_name|capitalize }}": project_name,
41+
"[{{ project_name }}]": project_name,
42+
"{{ project_name }}": project_name,
43+
"({{ project_url }})": "",
44+
"{{ project_url }}": "",
45+
"{{ arch_x86_64 }}": "x86_64",
46+
"{{ arch_arm64 }}": "arm64",
47+
}
48+
for expression, value in replace_map.items():
49+
readme_vars_str = readme_vars_str.replace(expression, value)
50+
51+
return yaml.load(readme_vars_str, Loader=yaml.CLoader)
52+
3653
def print_rate_limit():
3754
ratelimit = GH.get_rate_limit().core
3855
print(f"Github ratelimit - {ratelimit.remaining}/{ratelimit.limit} resets at {ratelimit.reset}")

root/app/models.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from pydantic import BaseModel
22

3-
# Increment when updating schema
4-
IMAGES_SCHEMA_VERSION = 1
3+
# Increment when updating schema or forcing an update on start
4+
IMAGES_SCHEMA_VERSION = 2
55

66

77
class Tag(BaseModel):

root/app/updater.py

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ def get_tags(readme_vars):
2525

2626
def get_architectures(readme_vars):
2727
if "available_architectures" not in readme_vars:
28-
return [Architecture(arch="arch_x86_64", tag="amd64-latest")]
28+
return [Architecture(arch="x86_64", tag="amd64-latest")]
2929
archs = []
3030
for item in readme_vars["available_architectures"]:
31-
archs.append(Architecture(arch=item["arch"][8:-3], tag=item["tag"]))
31+
archs.append(Architecture(arch=item["arch"], tag=item["tag"]))
3232
return archs
3333

3434
def get_changelogs(readme_vars):
@@ -42,11 +42,6 @@ def get_changelogs(readme_vars):
4242
def get_description(readme_vars):
4343
description = readme_vars.get("project_blurb", "No description")
4444
description = description.replace("\n", " ").strip(" \t\n\r")
45-
if "project_name" in readme_vars:
46-
description = description.replace("[{{ project_name|capitalize }}]", readme_vars["project_name"])
47-
description = description.replace("[{{ project_name }}]", readme_vars["project_name"])
48-
if "project_url" in readme_vars:
49-
description = description.replace("({{ project_url }})", "")
5045
return description
5146

5247
def get_env_vars(readme_vars):
@@ -130,7 +125,7 @@ def get_hostname(readme_vars):
130125
if not include_hostname:
131126
return None
132127
optional = include_hostname == "optional"
133-
hostname = readme_vars.get("param_hostname", False).replace("{{ project_name }}", readme_vars["project_name"])
128+
hostname = readme_vars.get("param_hostname", False)
134129
return Hostname(hostname=hostname, desc=readme_vars.get("param_hostname_desc", ""), optional=optional)
135130

136131
def get_mac_address(readme_vars):
@@ -145,7 +140,8 @@ def get_image(repo):
145140
print(f"Processing {repo.name}")
146141
if not repo.name.startswith("docker-") or repo.name.startswith("docker-baseimage-"):
147142
return None
148-
readme_vars = gh.get_readme_vars(repo)
143+
project_name = repo.name.replace("docker-", "")
144+
readme_vars = gh.get_readme_vars(repo, project_name)
149145
if not readme_vars:
150146
return None
151147
categories = readme_vars.get("project_categories", "")
@@ -174,7 +170,7 @@ def get_image(repo):
174170
caps=get_caps(readme_vars),
175171
)
176172
return Image(
177-
name=repo.name.replace("docker-", ""),
173+
name=project_name,
178174
github_url=repo.html_url,
179175
stars=repo.stargazers_count,
180176
project_url=readme_vars.get("project_url", None),

0 commit comments

Comments
 (0)