【问题标题】:How can I fix this Taskfile command?如何修复此 Taskfile 命令?
【发布时间】:2023-01-24 01:54:53
【问题描述】:

我正在尝试使用 public.ecr.aws/lambda/python:3.8 图像测试本地 Lambda 函数。我在使用 task 将 curl POST 正确转义/编码到此 API 端点时遇到问题。

如果 json 负载被编码,API 会抱怨:

[test] {"errorMessage": "Unable to unmarshal input: Expecting property name enclosed in double quotes: line 1 column 2 (char 1)", "errorType": "Runtime.UnmarshalError", "stackTrace": []}

如果不是,task 命令会抱怨:

yaml: line 7: did not find expected key

这是taskfile.yml

version: "3"

tasks:
    default:
        desc: Test the API
        cmds:
        - curl -XPOST http://localhost:9000/2015-03-31/functions/function/invocations -d '{'name': 'Todd'}'

【问题讨论】:

    标签: api curl lambda taskfile


    【解决方案1】:

    任务文件在某些​​地方(例如 desc 或 cmds 元素)在“:”上呕吐。您可以使用管道尝试以下操作:

    version: "3"
    
    tasks:
        default:
            desc: Test the API
            cmds:
            - |
              curl -XPOST http://localhost:9000/2015-03-31/functions/function/invocations -d '{'name': 'Todd'}'
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-11-16
      • 2019-09-21
      • 2016-11-21
      • 2020-09-12
      • 1970-01-01
      • 2022-11-12
      • 2015-08-16
      • 1970-01-01
      相关资源
      最近更新 更多