recipespy

package
v0.0.0-...-d3da680 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 4, 2024 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Overview

Package recipespy implements utilities for the python recipes framework.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bundle

func Bundle(ctx context.Context, repoPath string, dest string, overrides map[string]string) error

Bundle creates a hermetically runnable recipe bundle.

This is done by packaging the repo and all dependency repos into a folder and then generating an entrypoint script with `-O` override flags to this folder. Optionally provides dep repos with local override paths to pick up the repo from local override instead of repos checked out to .recipe_deps directory during the recipe bootstrap process.

The general principle is that the input to bundle is:

  • a fully bootstrapped recipe repo. All dependency repos specified in recipes.cfg are checked out to .recipe_deps directory under the recipe root dir.
  • files tagged with the `recipes` gitattribute value (see `git help gitattributes`).

and the output is a runnable folder at `dest` for the named repo.

Included files

By default, bundle will include all recipes/ and recipe_modules/ files in your repo, plus the `recipes.cfg` file, and excluding all json expectation files. Recipe bundle also uses the standard `gitattributes` mechanism for tagging files within the repo, and will also include these files when generating the bundle. In particular, it looks for files tagged with the string `recipes`. As an example, you could put this in a `.gitattributes` file in your repo:

*.py       recipes
*_test.py -recipes

That would include all .py files, but exclude all _test.py files. See the page `git help gitattributes` for more information on how gitattributes work.

The recipe repo to bundle may or may not be a git repo. There is a slight difference when bundling a recipe repo that is a git repo that the bundling process leverages the git index, so any untracked file will NOT be in the final bundle.

Types

type Repo

type Repo struct {
	// Path to the repo root on disk. Absolute Path.
	Path string
	// Spec is the config in infra/config/recipes.cfg file
	Spec *recipepb.RepoSpec
}

Repo represents a recipe repo.

It is a folder on disk which contains all of the requirements of a recipe repo:

  • an infra/config/recipes.cfg file
  • a `recipes` and/or `recipe_modules` folder
  • a recipes.py script

func RepoFromPath

func RepoFromPath(path string) (*Repo, error)

RepoFromPath creates a recipe Repo instance from a local path.

func (*Repo) CfgPath

func (r *Repo) CfgPath() string

CfgPath returns the absolute path to recipes.cfg

func (*Repo) CfgPathRel

func (r *Repo) CfgPathRel() string

CfgPathRel returns the relative path from the repo root to recipes.cfg.

func (*Repo) Name

func (r *Repo) Name() string

Name is a shorthand to get the recipe repo name.

func (*Repo) RecipeDepsPath

func (r *Repo) RecipeDepsPath() string

RecipeDepsPath returns the absolute path to the `.recipe_deps` directory.

func (*Repo) RecipesRootPath

func (r *Repo) RecipesRootPath() string

RecipesRootPath returns the path to the base where all recipes are found in the repo.

This is where the "recipes" and "recipe_modules" directories live.

func (*Repo) RecipesRootPathRel

func (r *Repo) RecipesRootPathRel() string

RecipesRootPathRel is like RecipesRootPath but returns relative path to the root. Returns empty path if root path is the repo root.

Directories

Path Synopsis
Package recipespb contains the protobuf definition for recipe.
Package recipespb contains the protobuf definition for recipe.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL