Skip to content

Commit

Permalink
fix: update lambda templates to resolve build issues (#15)
Browse files Browse the repository at this point in the history
* fix: update lambda templates to resolve build issues

* fix: resolve nix syntax errors

* fix: resolve openapi issues

* fix: update template to keep tests
  • Loading branch information
hbjydev authored May 7, 2024
1 parent edb8cc4 commit fdf9795
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 12 deletions.
6 changes: 4 additions & 2 deletions internal/config/openapi.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package config

type OpenAPIConfig struct {
Enable bool `json:"enable" yaml:"enable"`
Enable bool `json:"enable" yaml:"enable"`
Filename string `json:"filename" yaml:"filename"`
}

func NewOpenAPIConfig() OpenAPIConfig {
return OpenAPIConfig{
Enable: false,
Enable: false,
Filename: "openapi.json",
}
}
4 changes: 2 additions & 2 deletions internal/templates/templates/go-lambda/justfile
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,11 @@ deploy-all environment:
{{- end }}

{{ if .OpenAPI.Enable -}}
build-client:
build-client{{ if .PrivateModules }} netrc="/tmp/.netrc=/tmp/.netrc"{{ end }}:
#!/usr/bin/env bash
DERIVATION=$(just build client "{{"{{"}} netrc {{"}}"}}")
OUTPUT=$(echo $DERIVATION | jq -r ".[0].outputs.out")
mkdir -p pkg
rm -rf pkg/client
cp -r --no-preserve=mode $OUTPUT pkg/client
git add pkg/client
{{- end }}
10 changes: 4 additions & 6 deletions internal/templates/templates/go-lambda/nix__client.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@ runCommand "client"
mkdir -p $out
openapi-generator-cli generate \
-i $src/openapi.yaml \
-i $src/{{ .OpenAPI.Filename }} \
-g go \
-o $out \
-p packageName="client" \
-p packageVersion="0.1.0"
-p packageName="client"
rm -rf \
$out/.gitignore \
Expand All @@ -21,6 +20,5 @@ runCommand "client"
$out/README.md \
$out/api \
$out/docs \
$out/git_push.sh \
$out/test
'';
$out/git_push.sh
''
5 changes: 3 additions & 2 deletions internal/templates/templates/go-lambda/nix__lambda.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
{{ .Nix.BuildGoModule }},
name,
runCommand,
zip
}:

let
Expand All @@ -14,7 +15,7 @@ let
src = ../.;
subPackages = ["cmd/${name}"];
tags = ["lambda.norpc"];
vendorHash = "";
vendorHash = "{{ .Nix.VendorHash }}";

preBuild = ''
export HOME=/tmp
Expand All @@ -30,4 +31,4 @@ let
in
pkg.overrideAttrs (final: {
passthru.bootstrap = bootstrap;
});
})

0 comments on commit fdf9795

Please sign in to comment.