-
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.
* feat: update go-lambda to support openapi clients * feat: update go-lambda to include env import from nix/default.nix * feat: nix-based bootstrap zip creation
- Loading branch information
Showing
8 changed files
with
116 additions
and
33 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,3 +14,5 @@ parameters: | |
vendorHash: '' | ||
goPackage: go_1_22 | ||
buildGoModule: buildGo122Module | ||
openapi: | ||
enable: true |
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,11 @@ | ||
package config | ||
|
||
type OpenAPIConfig struct { | ||
Enable bool `json:"enable" yaml:"enable"` | ||
} | ||
|
||
func NewOpenAPIConfig() OpenAPIConfig { | ||
return OpenAPIConfig{ | ||
Enable: false, | ||
} | ||
} |
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,26 @@ | ||
{ runCommand, openapi-generator-cli }: | ||
runCommand "client" | ||
{ | ||
src = ../api; | ||
buildInputs = [ openapi-generator-cli ]; | ||
} '' | ||
mkdir -p $out | ||
openapi-generator-cli generate \ | ||
-i $src/openapi.yaml \ | ||
-g go \ | ||
-o $out \ | ||
-p packageName="client" \ | ||
-p packageVersion="0.1.0" | ||
rm -rf \ | ||
$out/.gitignore \ | ||
$out/.openapi-generator \ | ||
$out/.openapi-generator-ignore \ | ||
$out/.travis.yml \ | ||
$out/README.md \ | ||
$out/api \ | ||
$out/docs \ | ||
$out/git_push.sh \ | ||
$out/test | ||
''; |
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,14 @@ | ||
rec { | ||
env = { | ||
CGO_ENABLED = 0; | ||
{{- if .PrivateModules }} | ||
GOPRIVATE = "{{ .PrivateModules }}"; | ||
{{- end }} | ||
}; | ||
|
||
lambda = import ./lambda.nix { inherit env; }; | ||
|
||
{{- if .OpenAPI.Enable }} | ||
client = import ./client.nix; | ||
{{- end }} | ||
} |
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 |
---|---|---|
@@ -1,22 +1,33 @@ | ||
{ env }: | ||
|
||
{ | ||
{{ .Nix.BuildGoModule }}, | ||
name, | ||
runCommand, | ||
}: | ||
|
||
{{ .Nix.BuildGoModule }} { | ||
inherit name; | ||
ldflags = ["-s" "-w"]; | ||
src = ../.; | ||
subPackages = ["cmd/${name}"]; | ||
tags = ["lambda.norpc"]; | ||
vendorHash = ""; | ||
let | ||
pkg = {{ .Nix.BuildGoModule }} { | ||
inherit name; | ||
inherit (env) CGO_ENABLED{{ if .PrivateModules }} GOPRIVATE{{ end }}; | ||
ldflags = ["-s" "-w"]; | ||
src = ../.; | ||
subPackages = ["cmd/${name}"]; | ||
tags = ["lambda.norpc"]; | ||
vendorHash = ""; | ||
|
||
{{ if .PrivateModules -}} | ||
GOPRIVATE = "{{ .PrivateModules }}"; | ||
{{- end }} | ||
preBuild = '' | ||
export HOME=/tmp | ||
ls -alh $HOME/.netrc | ||
''; | ||
}; | ||
|
||
preBuild = '' | ||
export HOME=/tmp | ||
ls -alh $HOME/.netrc | ||
bootstrap = runCommand "${name}-bootstrap" { | ||
buildInputs = [ zip ]; | ||
} '' | ||
(cd ${pkg}/bin && zip $out ${name}) | ||
''; | ||
} | ||
in | ||
pkg.overrideAttrs (final: { | ||
passthru.bootstrap = bootstrap; | ||
}); |