mage

package
v0.0.0-...-3bfe646 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2023 License: Apache-2.0 Imports: 17 Imported by: 0

README

Mage

This is a highly experimental build framework that writes the complicated build logic in Go. This allows to write the build system in the same language as the project itself, take advantage of any libraries and share code between projects, and more aggressively take advantage of caching and parallelization to get out of devs way.

Due to the complexity of the current Makefile I'm not confident I've fully replicated them in go, however, the outcome of the build can be installed.

Getting Started

go run mage.go cluster:gravity

This is roughly equivalent to make production telekube within the repository directory.

Configuration

Mage doesn't support build arguments, so all customization of the build process is done via environment variables. For a complete listing of environment variables, run the help:envs target. This will give a listing of all environment variables and any current settings.

go run mage.go help:envs

Notes and Tips

  1. There isn't really a good way to rebuild specific packages bypassing caching, besides changing the version that would be assigned. So for example to force rebuild RBAC would require changing the version by environment variable.

For Example: RBAC_APP_TAG=7.0.0-rbac.1 go run mage.go cluster:gravity

  1. The automatic version assignment this uses is a bit different than the version.sh script currently being used. I'm not really sure what's better, but version.sh will generate something like 7.1.0-alpha.1.149 and this will use 7.1.0-alpha.1-149-g86435b2c-dirty. The downside is this can generate more packages to rebuild when getting marked as dirty.

  2. To better interact with gopls, dependent apps are no longer extracted to the build/ directory, and instead generate temporary directory for extraction and build.

  3. For now I've set caching to default to the build directory. So build/cache will be used for Go's caches, and build/apps get's used for internal applications. The cache directory can be overridden by XDG_CACHE_HOME.

  4. To get a full list of targets run go run mage.go -l. In general the targets are organized as:

    1. build - Building Go assets
    2. cluster - Building cluster images
    3. help - Help
    4. package - System packages that will be shipped with the installer
    5. test - Tests such as running go tests, linting, etc.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Clean

func Clean() (err error)

Clean cleans up the build directory.

func IsUpToDate

func IsUpToDate(dst string, source string, sources ...string) (uptodate bool)

IsUpToDate returns true iff all of the (source, sources...) are older or the same age as dst.

func Shutdown

func Shutdown()

Shutdown runs any shutdown hooks. TODO(dima): currently implemented (and visible) as a build target but ideally should be hidden from the build pipeline

Types

type Build

type Build mg.Namespace

func (Build) All

func (Build) All()

func (Build) BuildContainer

func (Build) BuildContainer(ctx context.Context) (err error)

BuildContainer creates a docker container as a consistent Go environment to use for software builds.

func (Build) Darwin

func (Build) Darwin(ctx context.Context) (err error)

Darwin builds Go binaries on the Darwin platform (doesn't support cross compile).

func (Build) Go

func (r Build) Go(ctx context.Context) (err error)

Go builds platform-native binaries

func (Build) Linux

func (Build) Linux(ctx context.Context) (err error)

Linux builds Go Linux binaries using consistent build environment.

func (Build) Selinux

func (Build) Selinux(ctx context.Context) (err error)

Selinux builds internal selinux code

func (Build) SelinuxPolicy

func (Build) SelinuxPolicy(ctx context.Context) (err error)

type Cluster

type Cluster mg.Namespace

func (Cluster) Gravity

func (Cluster) Gravity(ctx context.Context) (err error)

Gravity builds the reference gravity cluster image.

func (Cluster) Hub

func (Cluster) Hub(ctx context.Context) (err error)

Hub builds the reference hub cluster image.

func (Cluster) Wormhole

func (Cluster) Wormhole(ctx context.Context) (err error)

Wormhole builds the reference gravity cluster image based on wormhole networking.

type Mkdirer

type Mkdirer string

Mkdirer is a mage target to ensure a directory exists

func Mkdir

func Mkdir(dir string) Mkdirer

MkDir returns a mage target that ensures the given directory exists

func (Mkdirer) ID

func (r Mkdirer) ID() string

ID uniquely identifies the target to mage

func (Mkdirer) Name

func (r Mkdirer) Name() string

Name returns the name of the target

func (Mkdirer) Run

func (r Mkdirer) Run(context.Context) error

Run ensures the underlying directory exists

type Package

type Package mg.Namespace

func (Package) Bandwagon

func (Package) Bandwagon(ctx context.Context) (err error)

func (Package) DNS

func (Package) DNS(ctx context.Context) (err error)

func (Package) Fio

func (Package) Fio(ctx context.Context) (err error)

func (Package) Gravity

func (Package) Gravity(ctx context.Context) (err error)

func (Package) Ingress

func (Package) Ingress(ctx context.Context) (err error)

func (Package) K8s

func (Package) K8s(ctx context.Context) (err error)

func (Package) Logging

func (Package) Logging(ctx context.Context) (err error)

func (Package) Monitoring

func (Package) Monitoring(ctx context.Context) (err error)

func (Package) Planet

func (Package) Planet(ctx context.Context) (err error)

func (Package) Rbac

func (Package) Rbac(ctx context.Context) (err error)

func (Package) Site

func (Package) Site(ctx context.Context) (err error)

func (Package) Storage

func (Package) Storage(ctx context.Context) (err error)

func (Package) Telekube

func (Package) Telekube(ctx context.Context) (err error)

func (Package) Teleport

func (Package) Teleport(ctx context.Context) (err error)

func (Package) Tiller

func (Package) Tiller(ctx context.Context) (err error)

func (Package) Web

func (Package) Web(ctx context.Context) (err error)

type Test

type Test mg.Namespace

func (Test) All

func (Test) All(ctx context.Context)

func (Test) Cover

func (Test) Cover(ctx context.Context) (err error)

Cover converts the coverage profile to HTML.

func (Test) Lint

func (Test) Lint(ctx context.Context) (err error)

Lint runs golangci linter against the repo.

func (Test) Unit

func (Test) Unit(ctx context.Context, pkg string) (err error)

Unit runs unit tests with the race detector enabled.

Jump to

Keyboard shortcuts

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