Skip to content

Commit c93e707

Browse files
authored
Hiding custom recipes (#390)
Easy feature to hide custom recipes from the `recipes` command while making them available from `generate`. This allows us to temporarily hide any custom recipe until the experience stabilizes (currently using for `buildernet/mkosi`).
1 parent b09631f commit c93e707

File tree

4 files changed

+15
-2
lines changed

4 files changed

+15
-2
lines changed

custom-recipes/buildernet/mkosi/playground.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
base: buildernet
2-
description: Deploy the stack with the BuilderNet mkosi image (QEMU)
2+
description: Deploy the stack with the BuilderNet mkosi image (QEMU) - check out the README before running!
3+
hidden: true
34

45
recipe:
56
builder-vm:

main.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -474,8 +474,11 @@ var recipesCmd = &cobra.Command{
474474
}
475475
whiteTitleColor.Println("Custom Recipes:")
476476
for _, cr := range customRecipes {
477-
fmt.Println(" " + customRecipesColor.Sprint(cr))
478477
info, err := playground.GetCustomRecipeInfo(cr, recipes)
478+
if err == nil && info.Hidden {
479+
continue
480+
}
481+
fmt.Println(" " + customRecipesColor.Sprint(cr))
479482
if err == nil {
480483
if info.Description != "" {
481484
descriptionColor.Add(color.Bold).Printf(" %s\n", info.Description)
@@ -575,6 +578,10 @@ func main() {
575578
var customRecipes []playground.Recipe
576579

577580
for _, crName := range customRecipeNames {
581+
info, err := playground.GetCustomRecipeInfo(crName, recipes)
582+
if err == nil && info.Hidden {
583+
continue // Skip hidden custom recipes
584+
}
578585
customRecipe, cleanup, err := playground.LoadCustomRecipe(crName, recipes)
579586
if err != nil {
580587
continue // Skip invalid custom recipes

playground/custom_recipes.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ type CustomRecipeInfo struct {
5656
Name string
5757
Description string
5858
Base string
59+
Hidden bool
5960
ModifiedComponents []string
6061
NewComponents []string
6162
}
@@ -94,6 +95,7 @@ func GetCustomRecipeInfo(customRecipeName string, baseRecipes []Recipe) (*Custom
9495
Name: customRecipeName,
9596
Base: config.Base,
9697
Description: config.Description,
98+
Hidden: config.Hidden,
9799
}
98100

99101
// Find the base recipe to get its components

playground/recipe_yaml.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ type YAMLRecipeConfig struct {
2222
// Description is an optional description of the recipe
2323
Description string `yaml:"description,omitempty"`
2424

25+
// Hidden indicates this recipe should be excluded from listings and automated discovery
26+
Hidden bool `yaml:"hidden,omitempty"`
27+
2528
// Setup is a list of shell commands to run before any services are launched.
2629
// Commands run sequentially in the recipe's directory; each must exit 0.
2730
Setup []string `yaml:"setup,omitempty"`

0 commit comments

Comments
 (0)