Visit gosparta.io for complete documentation.
Sparta takes a set of golang functions and automatically provisions them in AWS Lambda as a logical unit.
AWS Lambda functions are defined using the standard AWS Lambda signatures:
func()
func() error
func(TIn) error
func() (TOut, error)
func(context.Context) error
func(context.Context, TIn) error
func(context.Context) (TOut, error)
func(context.Context, TIn) (TOut, error)
The TIn and TOut parameters represent encoding/json un/marshallable types.
For instance:
// Standard AWS λ function
func helloWorld(ctx context.Context) (string, error) {
...
}
where
ctx
: The request context that includes both the AWS Context as well as Sparta specific values
Consumers define a set of lambda functions and provide them to Sparta to create a self-documenting, self-deploying AWS Lambda binary:
lambdaFn := sparta.HandleAWSLambda("Hello World",
helloWorld,
sparta.IAMRoleDefinition{})
var lambdaFunctions []*sparta.LambdaAWSInfo
lambdaFunctions = append(lambdaFunctions, lambdaFn)
err := sparta.Main("HelloWorldStack",
"My Hello World stack",
lambdaFunctions,
nil,
nil)
Visit gosparta.io for complete documentation.
Sparta contributions are most welcome. Please consult the latest issues for open issues.
Locally building or testing Sparta itself is typically only needed to make package changes. Sparta is more often used as a required import of another application. Building is done via mage.
To get started building and verifying local changes:
go get -u -d github.com/magefile/mage
- In the .../mweagle/Sparta directory, run
mage -l
to list the current targets:
Targets:
build the application
clean the working directory
describe runs the `TestDescribe` test to generate a describe HTML output file at graph.html
ensureAllPreconditions ensures that the source passes *ALL* static `ensure*` precondition steps
ensureFormatted ensures that the source code is formatted with goimports
ensureLint ensures that the source is `golint`ed
ensureStaticChecks ensures that the source code passes static code checks
ensureTravisBuildEnvironment is the command that sets up the Travis environment to run the build.
ensureVet ensures that the source has been `go vet`ted
generateBuildInfo creates the automatic buildinfo.go file so that we can stamp the SHA into the binaries we build...
generateConstants runs the set of commands that update the embedded CONSTANTS for both local and AWS Lambda execution
installBuildRequirements installs or updates the dependent packages that aren't referenced by the source, but are needed to build the Sparta source
publish the latest source
test runs the Sparta tests
testCover runs the test and opens up the resulting report
travisBuild is the task to build in the context of a Travis CI pipeline
Confirm tests are passing on HEAD
by first running mage -v test
.
As you periodically make local changes, run mage -v test
to confirm backward compatibility.
When possible, please include a test case that verifies the local change and ensures compatibility.
Thanks to all Sparta contributors (alphabetical):
- Kyle Anderson
- James Brook
- Ryan Brown
- sdbeard
- Scott Raine
- Paul Seiffert
- Thom Shutt