Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: --ignore .ImageConfig didn't work. #394

Merged
merged 3 commits into from
Apr 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,8 @@ Flags:

lambroll also support to deploy a container image for Lambda.

PackageType=Image and Code.ImageUri are required in function.json.
`PackageType=Image` and `Code.ImageUri` are required in function.json.
`ImageConfig` is optional.

```json
{
Expand All @@ -253,6 +254,15 @@ PackageType=Image and Code.ImageUri are required in function.json.
"PackageType": "Image",
"Code": {
"ImageUri": "012345678912.dkr.ecr.ap-northeast-1.amazonaws.com/lambda/test:latest"
},
"ImageConfig": {
"Command": [
"/path/to/bootstrap"
],
"WorkingDirectory": "/var/task",
"EntryPoint": [
"/path/to/entrypoint"
],
}
}
```
Expand Down
2 changes: 1 addition & 1 deletion create.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func (app *App) prepareFunctionCodeForDeploy(ctx context.Context, opt *DeployOpt
log.Printf("[info] uploading function %d bytes to s3://%s/%s", info.Size(), *bucket, *key)
versionID, err := app.uploadFunctionToS3(ctx, zipfile, *bucket, *key)
if err != nil {
fmt.Errorf("failed to upload function zip to s3://%s/%s: %w", *bucket, *key, err)
return fmt.Errorf("failed to upload function zip to s3://%s/%s: %w", *bucket, *key, err)
}
if versionID != "" {
log.Printf("[info] object created as version %s", versionID)
Expand Down
11 changes: 6 additions & 5 deletions deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func (opt *DeployOption) String() string {
return string(b)
}

// Deploy deployes a new lambda function code
// Deploy deploys a new lambda function code
func (app *App) Deploy(ctx context.Context, opt *DeployOption) error {
if err := opt.Expand(); err != nil {
return err
Expand Down Expand Up @@ -119,6 +119,10 @@ func (app *App) Deploy(ctx context.Context, opt *DeployOption) error {
}
fillDefaultValues(fn)

if err := app.prepareFunctionCodeForDeploy(ctx, opt, fn); err != nil {
return fmt.Errorf("failed to prepare function code for deploy: %w", err)
}

if ignore := opt.Ignore; ignore != "" {
q, err := gojq.Parse(ignore)
if err != nil {
Expand All @@ -135,10 +139,6 @@ func (app *App) Deploy(ctx context.Context, opt *DeployOption) error {
unmarshalJSON(src, &fn, app.functionFilePath)
}

if err := app.prepareFunctionCodeForDeploy(ctx, opt, fn); err != nil {
return fmt.Errorf("failed to prepare function code for deploy: %w", err)
}

log.Println("[info] updating function configuration", opt.label())
confIn := &lambda.UpdateFunctionConfigurationInput{
DeadLetterConfig: fn.DeadLetterConfig,
Expand All @@ -160,6 +160,7 @@ func (app *App) Deploy(ctx context.Context, opt *DeployOption) error {
ImageConfig: fn.ImageConfig,
SnapStart: fn.SnapStart,
}
log.Printf("[debug] %s", jsonStr(confIn))

var newerVersion string
if !opt.DryRun {
Expand Down
8 changes: 8 additions & 0 deletions utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,14 @@ func toGeneralMap(s any, omitEmpty bool) (any, error) {
return x, nil
}

func jsonStr(s any) string {
b, err := json.MarshalIndent(s, "", " ")
if err != nil {
log.Printf("[warn] failed to marshal json: %s", err)
}
return string(b)
}

func marshalJSON(s interface{}) ([]byte, error) {
x, err := toGeneralMap(s, true)
if err != nil {
Expand Down
Loading