-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
76 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package lambda | ||
|
||
import ( | ||
"context" | ||
"os" | ||
"path" | ||
"path/filepath" | ||
|
||
"github.com/elisasre/mageutil/golang" | ||
"github.com/magefile/mage/sh" | ||
) | ||
|
||
// BuildAll builds lambda bootstrap binaries and calculates sha sums for them. | ||
func BuildAll(ctx context.Context, buildTargets []string, goarch string) error { | ||
for _, target := range buildTargets { | ||
err := Build(ctx, target, goarch) | ||
if err != nil { | ||
return err | ||
} | ||
} | ||
return nil | ||
} | ||
|
||
// Build builds lambda bootstrap binary and calculates sha sum for it. | ||
func Build(ctx context.Context, target string, goarch string) error { | ||
info, err := golang.WithSHA(golang.BuildForPlatform(ctx, "linux", goarch, target)) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
src := filepath.Dir(info.BinPath) | ||
dst := path.Join(src, "lambda", filepath.Base(target)) | ||
if err := os.MkdirAll(dst, 0o755); err != nil { | ||
return err | ||
} | ||
|
||
dst = path.Join(dst, "bootstrap") | ||
err = sh.Copy(dst, info.BinPath) | ||
if err != nil { | ||
return err | ||
} | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// Package target exposes Lambda targets that can be imported in magefile using [import syntax]. | ||
// When using this package the user has to set target.BuildTargets. | ||
// | ||
// [import syntax]: https://magefile.org/importing/ | ||
package target | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/elisasre/mageutil/lambda" | ||
"github.com/magefile/mage/mg" | ||
) | ||
|
||
var ( | ||
BuildTargets = []string{} | ||
GOARCH = "amd64" | ||
) | ||
|
||
type Lambda mg.Namespace | ||
|
||
// BuildAll builds lambda bootstrap binaries and calculates sha sums for them. | ||
func (Lambda) BuildAll(ctx context.Context) error { | ||
return lambda.BuildAll(ctx, BuildTargets, GOARCH) | ||
} |