github.com/mweagle/Sparta@v1.15.0/README.md (about) 1 <div align="center"><img src="https://raw.githubusercontent.com/mweagle/Sparta/master/docs_source/static/site/SpartaLogoLarge.png" /> 2 </div> 3 4 # Sparta <p align="center"> 5 6  7 8 [](https://godoc.org/github.com/mweagle/Sparta) 9 10 [](https://goreportcard.com/report/github.com/mweagle/Sparta) 11 12 Visit [gosparta.io](https://gosparta.io) for complete documentation. 13 14 ## Overview 15 16 Sparta takes a set of _golang_ functions and automatically provisions them in 17 [AWS Lambda](https://aws.amazon.com/lambda/) as a logical unit. 18 19 AWS Lambda functions are defined using the standard [AWS Lambda signatures](https://aws.amazon.com/blogs/compute/announcing-go-support-for-aws-lambda/): 20 21 - `func()` 22 - `func() error` 23 - `func(TIn) error` 24 - `func() (TOut, error)` 25 - `func(context.Context) error` 26 - `func(context.Context, TIn) error` 27 - `func(context.Context) (TOut, error)` 28 - `func(context.Context, TIn) (TOut, error)` 29 30 The TIn and TOut parameters represent encoding/json un/marshallable types. 31 32 For instance: 33 34 ```go 35 // Standard AWS λ function 36 func helloWorld(ctx context.Context) (string, error) { 37 ... 38 } 39 ``` 40 41 where 42 43 - `ctx` : The request context that includes both the [AWS Context](https://github.com/aws/aws-lambda-go/blob/master/lambdacontext/context.go) as well as Sparta specific [values](https://godoc.org/github.com/mweagle/Sparta#pkg-constants.) 44 45 Consumers define a set of lambda functions and provide them to Sparta to create a self-documenting, self-deploying AWS Lambda binary: 46 47 ```go 48 lambdaFn, _ := sparta.NewAWSLambda("Hello World", 49 helloWorld, 50 sparta.IAMRoleDefinition{}) 51 52 var lambdaFunctions []*sparta.LambdaAWSInfo 53 lambdaFunctions = append(lambdaFunctions, lambdaFn) 54 55 err := sparta.Main("HelloWorldStack", 56 "My Hello World stack", 57 lambdaFunctions, 58 nil, 59 nil) 60 ``` 61 62 Visit [gosparta.io](https://gosparta.io) for complete documentation. 63 64 ## Contributing 65 66 Sparta contributions are most welcome. Please consult the latest [issues](https://github.com/mweagle/Sparta/issues) for open issues. 67 68 ### Building 69 70 Locally building or testing Sparta itself is typically only needed to make package 71 changes. Sparta is more often used as a required import of another application. 72 Building is done via [mage](https://magefile.org/). 73 74 To get started building and verifying local changes: 75 76 1. `go get -u -d github.com/magefile/mage` 77 1. In the .../mweagle/Sparta directory, run `mage -l` to list the current targets: 78 79 \$ mage -l 80 Targets: 81 build the application 82 clean the working directory 83 compareAgainstMasterBranch is a convenience function to show the comparisons of the current pushed branch against the master branch 84 describe runs the `TestDescribe` test to generate a describe HTML output file at graph.html 85 docsBuild builds the public documentation site in the /docs folder 86 docsCommit builds and commits the current documentation with an autogenerated comment 87 docsEdit starts a Hugo server and hot reloads the documentation at http://localhost:1313 88 docsInstallRequirements installs the required Hugo version 89 ensureAllPreconditions ensures that the source passes _ALL_ static `ensure*` precondition steps 90 ensureCleanTree ensures that the git tree is clean 91 ensureFormatted ensures that the source code is formatted with goimports 92 ensureGoFmt ensures that the source is `gofmt -s` is empty 93 ensureLint ensures that the source is `golint`ed 94 ensureMarkdownSpelling ensures that all \*.MD files are checked for common spelling mistakes 95 ensurePrealloc ensures that slices that could be preallocated are enforced 96 ensureSpelling ensures that there are no misspellings in the source 97 ensureStaticChecks ensures that the source code passes static code checks 98 ensureTravisBuildEnvironment is the command that sets up the Travis environment to run the build. 99 ensureVet ensures that the source has been `go vet`ted 100 generateBuildInfo creates the automatic buildinfo.go file so that we can stamp the SHA into the binaries we build... 101 generateConstants runs the set of commands that update the embedded CONSTANTS for both local and AWS Lambda execution 102 installBuildRequirements installs or updates the dependent packages that aren't referenced by the source, but are needed to build the Sparta source 103 logCodeMetrics ensures that the source code is formatted with goimports 104 publish the latest source 105 test runs the Sparta tests 106 testCover runs the test and opens up the resulting report 107 travisBuild is the task to build in the context of a Travis CI pipeline 108 109 Confirm tests are passing on `HEAD` by first running `mage -v test`. 110 111 As you periodically make local changes, run `mage -v test` to confirm backward compatibility. 112 113 ### Tests 114 115 When possible, please include a [test case](https://golang.org/pkg/testing/) that verifies the local change and ensures compatibility. 116 117 ## Contributors 118 119 Thanks to all Sparta contributors (alphabetical): 120 121 - **Kyle Anderson** 122 - [James Brook](https://github.com/jbrook) 123 - [Ryan Brown](https://github.com/ryansb) 124 - [sdbeard](https://github.com/sdbeard) 125 - [Scott Raine](https://github.com/nylar) 126 - [Paul Seiffert](https://github.com/seiffert) 127 - [Thom Shutt](https://github.com/thomshutt)