Magefiles

Magefile

To support cross platform development and usage, Sparta uses magefiles rather than Makefiles. Most projects can start with the magefile.go sample below. The Magefiles provide a discoverable CLI, but are entirely optional. go run main.go XXXX style invocation remains available as well.

Default Sparta magefile.go

This magefile.go can be used, unchanged, for most standard Sparta projects.

// +build mage

// File: magefile.go

package main

import (
  spartaMage "github.com/mweagle/Sparta/v3/magefile"
)

// Provision the service
func Provision() error {
  return spartaMage.Provision()
}

// Describe the stack by producing an HTML representation of the CloudFormation
// template
func Describe() error {
  return spartaMage.Describe()
}

// Delete the service, iff it exists
func Delete() error {
  return spartaMage.Delete()
}

// Status report if the stack has been provisioned
func Status() error {
  return spartaMage.Status()
}

// Version information
func Version() error {
  return spartaMage.Version()
}
$ mage -l
Targets:
  delete       the service, iff it exists
  describe     the stack by producing an HTML representation of the CloudFormation template
  provision    the service
  status       report if the stack has been provisioned
  version      information

Sparta Magefile Helpers

There are several magefile helpers available in the Sparta package. These are in addition to and often delegate to, the core mage libraries.