bobfile

package
v0.0.0-...-631b0da Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2025 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Project configuration file for Turbo Bob

Index

Constants

View Source
const (
	Name                       = ".config/turbobob.json"
	FileDescriptionBoilerplate = "https://github.com/function61/turbobob"
)
View Source
const (
	CurrentVersionMajor = 1
)

Variables

View Source
var (
	ErrBuilderNotFound             = errors.New("builder not found")
	ErrBobfileNotFound             = errors.New("turbobob.json does not exist. Run $ bob tools init")
	ErrInitBobfileExists           = errors.New("cannot init; Bobfile already exists")
	ErrUnsupportedBobfileVersion   = errors.New("Unsupported Bobfile version")
	ErrInvalidDockerCredsEnvFormat = errors.New("Invalid format for DOCKER_CREDS")
	ErrUnableToParseDockerTag      = errors.New("Unable to parse Docker tag")
	ErrIncorrectFileDescriptionBp  = errors.New("you are not supposed to change FileDescriptionBoilerplate")
)

Functions

This section is empty.

Types

type Bobfile

type Bobfile struct {
	FileDescriptionBoilerplate string            `json:"for_description_of_this_file_see"`
	VersionMajor               int               `json:"version_major"`
	ProjectName                string            `json:"project_name"`
	Meta                       ProjectMetadata   `json:"meta,omitempty"`
	Builders                   []BuilderSpec     `json:"builders"`
	DockerImages               []DockerImageSpec `json:"docker_images,omitempty"`
	Subrepos                   []SubrepoSpec     `json:"subrepos,omitempty"`
	OsArches                   *OsArchesSpec     `json:"os_arches,omitempty"`
	Experiments                experiments       `json:"experiments_i_consent_to_breakage,omitempty"`
	Deprecated1                string            `json:"project_emoji_icon,omitempty"` // moved to `ProjectMetadata`
}

func Read

func Read() (*Bobfile, error)

FIXME: Bobfile should actually be read only after correct revision has been checked out from VCs

func (Bobfile) ProjectEmojiIcon

func (b Bobfile) ProjectEmojiIcon() string

type BuilderCommands

type BuilderCommands struct {
	Prepare []string `json:"prepare,omitempty"`
	Build   []string `json:"build"`
	Publish []string `json:"publish,omitempty"`
	Dev     []string `json:"dev"`
}
	Suppose you have three builders: 1) backend, 2) frontend and 3) documentation.
	Here's the order in which the commands are executed:

    Start ────────────────┐     ┌───────────────┐     ┌───────────────┐
                          │     ▲               │     ▲               │
               ┌──────────▼┐    │    ┌──────────▼┐    │    ┌──────────▼┐
       Backend │  Prepare ││    │    │  Build   ││    │    │  Publish ││
               └──────────┼┘    │    └──────────┼┘    │    └──────────┼┘
                          │     │               │     │               │
                          │     │               │     │               │
               ┌──────────▼┐    │    ┌──────────▼┐    │    ┌──────────▼┐
      Frontend │  Prepare ││    │    │  Build   ││    │    │  Publish ││
               └──────────┼┘    │    └──────────┼┘    │    └──────────┼┘
                          │     │               │     │               │
                          │     │               │     │               │
               ┌──────────▼┐    │    ┌──────────▼┐    │    ┌──────────▼┐
 Documentation │  Prepare ││    │    │  Build   ││    │    │  Publish ││
               └──────────┼┘    │    └──────────┼┘    │    └──────────┼┘
                          │     │               │     │               │
                          │     │               │     │               │
                          └─────┘               └─────┘               ▼

	Rationale:

	- backend needs some codegenerated stuff from documentation, like URLs so backend can link to documentation,
	  so backend build can use stuff from documentation.prepare step.
	- you'll want to publish artefacts only if all builders succeeded (*.build before *.publish),
	  so there's no unnecessary uploads.

type BuilderSpec

type BuilderSpec struct {
	Name             string            `json:"name"`
	Uses             string            `json:"uses"` // "docker://alpine:latest" | "dockerfile://build-default.Dockerfile"
	MountSource      string            `json:"mount_source,omitempty"`
	MountDestination string            `json:"mount_destination"`
	Workdir          string            `json:"workdir,omitempty"`
	Commands         BuilderCommands   `json:"commands"`
	DevPorts         []string          `json:"dev_ports,omitempty"`
	DevHttpIngress   string            `json:"dev_http_ingress,omitempty"`
	DevProTips       []string          `json:"dev_pro_tips,omitempty"`
	DevShellCommands []DevShellCommand `json:"dev_shell_commands,omitempty"` // injected as history for quick recall (ctrl + r)
	Envs             map[string]string `json:"env,omitempty"`
	PassEnvs         []string          `json:"pass_envs,omitempty"`
	ContextlessBuild bool              `json:"contextless_build,omitempty"`
}

type DevShellCommand

type DevShellCommand struct {
	Command   string `json:"command"`
	Important bool   `json:"important"` // important commands are shown as pro-tips on "$ bob dev"
}

type DockerImageSpec

type DockerImageSpec struct {
	Image          string   `json:"image"`
	DockerfilePath string   `json:"dockerfile_path"`
	AuthType       *string  `json:"auth_type"`           // creds_from_env
	Platforms      []string `json:"platforms,omitempty"` // if set, uses buildx
	TagLatest      bool     `json:"tag_latest"`
}

type OsArchesSpec

type OsArchesSpec struct {
	Neutral        bool `json:"neutral"`       // works across all OSes and arches, example: native JavaScript project or a website
	LinuxNeutral   bool `json:"linux-neutral"` // works on Linux, arch doesn't matter
	LinuxAmd64     bool `json:"linux-amd64"`
	LinuxArm       bool `json:"linux-arm"`
	LinuxArm64     bool `json:"linux-arm64"`
	LinuxRiscv64   bool `json:"linux-riscv64"`
	WindowsNeutral bool `json:"windows-neutral"` // works on Windows, arch doesn't matter
	WindowsAmd64   bool `json:"windows-amd64"`
	DarwinAmd64    bool `json:"darwin-amd64"`
}

documents os/arch combos which this project's build artefacts support. follow constants from Go's GOOS/GOARCH

func (*OsArchesSpec) AsBuildEnvVariables

func (o *OsArchesSpec) AsBuildEnvVariables() []string

type ProjectMetadata

type ProjectMetadata struct {
	Description      string `json:"description,omitempty"`        // what this project is used for
	Website          string `json:"website,omitempty"`            // URL of homepage or such
	Documentation    string `json:"documentation,omitempty"`      // URL of documentation website
	ProjectEmojiIcon string `json:"project_emoji_icon,omitempty"` // to quickly differentiate projects in e.g. workspace switcher
}

type SubrepoSpec

type SubrepoSpec struct {
	Source      string              `json:"source"`
	Kind        versioncontrol.Kind `json:"kind"`
	Destination string              `json:"destination"`
	Revision    string              `json:"revision"`
}

Jump to

Keyboard shortcuts

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