Skip to content

Commit 71a1b1c

Browse files
yeoldegroveNotTheEvilOne
authored andcommitted
optionally fetch flavors.yaml from GitHub
1 parent 45e6e2a commit 71a1b1c

File tree

2 files changed

+45
-19
lines changed

2 files changed

+45
-19
lines changed

src/gardenlinux/flavors/__main__.py

Lines changed: 44 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import sys
1212

1313
from ..git import Git
14+
from ..github import GitHub
1415

1516
from .parser import Parser
1617

@@ -48,6 +49,11 @@ def parse_args():
4849

4950
parser = ArgumentParser(description="Parse flavors.yaml and generate combinations.")
5051

52+
parser.add_argument(
53+
"--commit",
54+
default=None,
55+
help="Commit hash to fetch flavors.yaml from GitHub (if not specified, uses local file).",
56+
)
5157
parser.add_argument(
5258
"--no-arch",
5359
action="store_true",
@@ -120,25 +126,44 @@ def main():
120126

121127
args = parse_args()
122128

123-
flavors_file = os.path.join(Git().root, "flavors.yaml")
124-
125-
if not os.path.isfile(flavors_file):
126-
sys.exit(f"Error: {flavors_file} does not exist.")
127-
128-
# Load and validate the flavors.yaml
129-
with open(flavors_file, "r") as file:
130-
flavors_data = file.read()
131-
132-
combinations = Parser(flavors_data).filter(
133-
include_only_patterns=args.include_only,
134-
wildcard_excludes=args.exclude,
135-
only_build=args.build,
136-
only_test=args.test,
137-
only_test_platform=args.test_platform,
138-
only_publish=args.publish,
139-
filter_categories=args.category,
140-
exclude_categories=args.exclude_category,
141-
)
129+
if args.commit:
130+
# Use GitHub API to fetch flavors.yaml
131+
github = GitHub()
132+
flavors_content = github.get_flavors_yaml(commit=args.commit)
133+
134+
parser = Parser(data=flavors_content)
135+
136+
combinations = parser.filter(
137+
include_only_patterns=args.include_only,
138+
wildcard_excludes=args.exclude,
139+
only_build=args.build,
140+
only_test=args.test,
141+
only_test_platform=args.test_platform,
142+
only_publish=args.publish,
143+
filter_categories=args.category,
144+
exclude_categories=args.exclude_category,
145+
)
146+
else:
147+
# Use local file
148+
flavors_file = os.path.join(Git().root, "flavors.yaml")
149+
150+
if not os.path.isfile(flavors_file):
151+
sys.exit(f"Error: {flavors_file} does not exist.")
152+
153+
# Load and validate the flavors.yaml
154+
with open(flavors_file, "r") as file:
155+
flavors_data = file.read()
156+
157+
combinations = Parser(flavors_data).filter(
158+
include_only_patterns=args.include_only,
159+
wildcard_excludes=args.exclude,
160+
only_build=args.build,
161+
only_test=args.test,
162+
only_test_platform=args.test_platform,
163+
only_publish=args.publish,
164+
filter_categories=args.category,
165+
exclude_categories=args.exclude_category,
166+
)
142167

143168
if args.json_by_arch:
144169
grouped_combinations = Parser.group_by_arch(combinations)

src/gardenlinux/flavors/parser.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
from ..constants import GL_FLAVORS_SCHEMA
1212
from ..logger import LoggerSetup
13+
from ..github import GitHub
1314

1415

1516
class Parser(object):

0 commit comments

Comments
 (0)