Skip to content

Commit

Permalink
allow for custom recipe path
Browse files Browse the repository at this point in the history
  • Loading branch information
jardon committed Oct 20, 2024
1 parent 662f113 commit d4440a9
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions vanilla_first_setup/utils/recipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,29 +22,26 @@

logger = logging.getLogger("FirstSetup::RecipeLoader")

recipe_path = "/usr/share/org.vanillaos.FirstSetup/recipe.json"
recipe_path = os.environ["VANILLA_CUSTOM_RECIPE"] if "VANILLA_CUSTOM_RECIPE" in os.environ else "/usr/share/org.vanillaos.FirstSetup/recipe.json"

class RecipeLoader:
def __init__(self):
self.__recipe = {}
self.__load()

def __load(self):
if "VANILLA_CUSTOM_RECIPE" in os.environ:
self.recipe_path = os.environ["VANILLA_CUSTOM_RECIPE"]
logger.info(f"Loading recipe from {recipe_path}")

logger.info(f"Loading recipe from {self.recipe_path}")

if os.path.exists(self.recipe_path):
with open(self.recipe_path, "r") as f:
if os.path.exists(recipe_path):
with open(recipe_path, "r") as f:
self.__recipe = json.load(f)
return

if not self.__validate():
logger.error("Invalid recipe file")
sys.exit(1)

logger.error(f"Recipe not found at {self.recipe_path}")
logger.error(f"Recipe not found at {recipe_path}")
sys.exit(1)

def __validate(self):
Expand Down

0 comments on commit d4440a9

Please sign in to comment.