serverless/serverless

When invoking locally Go function, '-p' option conflicts with AWS plugin options

Open

#7,871 建立於 2020年6月24日

在 GitHub 查看
 (5 留言) (0 反應) (0 負責人)JavaScript (46,915 star) (5,734 fork)batch import
bugcat/local-devhelp wantedruntime/go

描述

When using

serverless invoke local -f myFunction -p ./tests/ping.json

It leads to an error

Error: Cannot overwrite non-directory './tests/ping.json' with directory '/path/to/myproject/.serverless'.

Using the --path option instead works fine

serverless invoke local -f myFunction --path ./tests/ping.json

As it turns out, the -p parameter is being confused with the one in this line: https://github.com/serverless/serverless/blob/master/lib/plugins/aws/common/lib/artifacts.js#L10 which is likely the --package parameter

service: upload-file-test

frameworkVersion: '>=1.28.0 <2.0.0'

provider:
  name: aws
  runtime: go1.x
  memorySize: 128
  timeout: 30
  stage: ${opt:stage, 'production'}
  region: ${opt:region, 'ap-southeast-1'}
  logRetentionInDays: 30
  deploymentBucket:
    name: somebucket

  environment:

package:
  exclude:
    - ./**
  include:
    - ./bin/**

functions:
  myFunction:
    handler: bin/my-function
    events:
      - http:
          path: ping
          method: get
          cors: true
serverless invoke local -f myFunction -p ./tests/ping.json
Serverless: Load command interactiveCli
Serverless: Load command config
Serverless: Load command config:credentials
Serverless: Load command config:tabcompletion
Serverless: Load command config:tabcompletion:install
Serverless: Load command config:tabcompletion:uninstall
Serverless: Load command create
Serverless: Load command install
Serverless: Load command package
Serverless: Load command deploy
Serverless: Load command deploy:function
Serverless: Load command deploy:list
Serverless: Load command deploy:list:functions
Serverless: Load command invoke
Serverless: Load command invoke:local
Serverless: Load command info
Serverless: Load command logs
Serverless: Load command metrics
Serverless: Load command print
Serverless: Load command remove
Serverless: Load command rollback
Serverless: Load command rollback:function
Serverless: Load command slstats
Serverless: Load command plugin
Serverless: Load command plugin
Serverless: Load command plugin:install
Serverless: Load command plugin
Serverless: Load command plugin:uninstall
Serverless: Load command plugin
Serverless: Load command plugin:list
Serverless: Load command plugin
Serverless: Load command plugin:search
Serverless: Load command config
Serverless: Load command config:credentials
Serverless: Load command rollback
Serverless: Load command rollback:function
Serverless: Load command upgrade
Serverless: Load command uninstall
Serverless: Load command login
Serverless: Load command logout
Serverless: Load command generate-event
Serverless: Load command test
Serverless: Load command dashboard
Serverless: Load command output
Serverless: Load command output:get
Serverless: Load command output:list
Serverless: Load command param
Serverless: Load command param:get
Serverless: Load command param:list
Serverless: Load command studio
Serverless: Load command dev
Serverless: Invoke invoke:local
Serverless: Invoke package
Serverless: Invoke aws:common:validate
Serverless: Invoke aws:common:cleanupTempDir
Serverless: Packaging service...
Serverless: Excluding development dependencies...
Serverless: Invoke aws:package:finalize
Serverless: Invoke aws:common:moveArtifactsToPackage
options package ./tests/ping.json <- my own console.log()
package path undefined <- my own console.log()

  Error --------------------------------------------------

  Error: Cannot overwrite non-directory './tests/ping.json' with directory '/path/to/myproject/.serverless'.
      at onDir (/home/linuxbrew/.linuxbrew/Cellar/serverless/1.73.1/libexec/lib/node_modules/serverless/node_modules/fs-extra/lib/copy-sync/copy-sync.js:101:11)
      at getStats (/home/linuxbrew/.linuxbrew/Cellar/serverless/1.73.1/libexec/lib/node_modules/serverless/node_modules/fs-extra/lib/copy-sync/copy-sync.js:45:37)
      at startCopy (/home/linuxbrew/.linuxbrew/Cellar/serverless/1.73.1/libexec/lib/node_modules/serverless/node_modules/fs-extra/lib/copy-sync/copy-sync.js:38:10)
      at handleFilterAndCopy (/home/linuxbrew/.linuxbrew/Cellar/serverless/1.73.1/libexec/lib/node_modules/serverless/node_modules/fs-extra/lib/copy-sync/copy-sync.js:33:10)
      at Object.copySync (/home/linuxbrew/.linuxbrew/Cellar/serverless/1.73.1/libexec/lib/node_modules/serverless/node_modules/fs-extra/lib/copy-sync/copy-sync.js:26:10)
      at copyDirContentsSync (/home/linuxbrew/.linuxbrew/Cellar/serverless/1.73.1/libexec/lib/node_modules/serverless/lib/utils/fs/copyDirContentsSync.js:12:7)
      at Utils.copyDirContentsSync (/home/linuxbrew/.linuxbrew/Cellar/serverless/1.73.1/libexec/lib/node_modules/serverless/lib/classes/Utils.js:93:12)
      at AwsCommon.moveArtifactsToPackage (/home/linuxbrew/.linuxbrew/Cellar/serverless/1.73.1/libexec/lib/node_modules/serverless/lib/plugins/aws/common/lib/artifacts.js:25:31)
  From previous event:
      at Object.aws:common:moveArtifactsToPackage:move [as hook] (/home/linuxbrew/.linuxbrew/Cellar/serverless/1.73.1/libexec/lib/node_modules/serverless/lib/plugins/aws/common/index.js:54:30)
      at /home/linuxbrew/.linuxbrew/Cellar/serverless/1.73.1/libexec/lib/node_modules/serverless/lib/classes/PluginManager.js:489:55
  From previous event:
      at PluginManager.invoke (/home/linuxbrew/.linuxbrew/Cellar/serverless/1.73.1/libexec/lib/node_modules/serverless/lib/classes/PluginManager.js:489:22)
      at PluginManager.spawn (/home/linuxbrew/.linuxbrew/Cellar/serverless/1.73.1/libexec/lib/node_modules/serverless/lib/classes/PluginManager.js:509:17)
      at AwsPackage.<anonymous> (/home/linuxbrew/.linuxbrew/Cellar/serverless/1.73.1/libexec/lib/node_modules/serverless/lib/plugins/aws/package/index.js:85:53)
  From previous event:
      at Object.aws:package:finalize:saveServiceState [as hook] (/home/linuxbrew/.linuxbrew/Cellar/serverless/1.73.1/libexec/lib/node_modules/serverless/lib/plugins/aws/package/index.js:85:12)
      at /home/linuxbrew/.linuxbrew/Cellar/serverless/1.73.1/libexec/lib/node_modules/serverless/lib/classes/PluginManager.js:489:55
  From previous event:
      at PluginManager.invoke (/home/linuxbrew/.linuxbrew/Cellar/serverless/1.73.1/libexec/lib/node_modules/serverless/lib/classes/PluginManager.js:489:22)
      at PluginManager.spawn (/home/linuxbrew/.linuxbrew/Cellar/serverless/1.73.1/libexec/lib/node_modules/serverless/lib/classes/PluginManager.js:509:17)
      at AwsPackage.<anonymous> (/home/linuxbrew/.linuxbrew/Cellar/serverless/1.73.1/libexec/lib/node_modules/serverless/lib/plugins/aws/package/index.js:70:41)
  From previous event:
      at Object.package:finalize [as hook] (/home/linuxbrew/.linuxbrew/Cellar/serverless/1.73.1/libexec/lib/node_modules/serverless/lib/plugins/aws/package/index.js:69:30)
      at /home/linuxbrew/.linuxbrew/Cellar/serverless/1.73.1/libexec/lib/node_modules/serverless/lib/classes/PluginManager.js:489:55
  From previous event:
      at PluginManager.invoke (/home/linuxbrew/.linuxbrew/Cellar/serverless/1.73.1/libexec/lib/node_modules/serverless/lib/classes/PluginManager.js:489:22)
      at PluginManager.spawn (/home/linuxbrew/.linuxbrew/Cellar/serverless/1.73.1/libexec/lib/node_modules/serverless/lib/classes/PluginManager.js:509:17)
      at AwsInvokeLocal.ensurePackage (/home/linuxbrew/.linuxbrew/Cellar/serverless/1.73.1/libexec/lib/node_modules/serverless/lib/plugins/aws/invokeLocal/index.js:423:42)
      at AwsInvokeLocal.invokeLocalDocker (/home/linuxbrew/.linuxbrew/Cellar/serverless/1.73.1/libexec/lib/node_modules/serverless/lib/plugins/aws/invokeLocal/index.js:430:17)
      at AwsInvokeLocal.invokeLocal (/home/linuxbrew/.linuxbrew/Cellar/serverless/1.73.1/libexec/lib/node_modules/serverless/lib/plugins/aws/invokeLocal/index.js:230:17)
  From previous event:
      at Object.invoke:local:invoke [as hook] (/home/linuxbrew/.linuxbrew/Cellar/serverless/1.73.1/libexec/lib/node_modules/serverless/lib/plugins/aws/invokeLocal/index.js:38:57)
      at /home/linuxbrew/.linuxbrew/Cellar/serverless/1.73.1/libexec/lib/node_modules/serverless/lib/classes/PluginManager.js:489:55
  From previous event:
      at PluginManager.invoke (/home/linuxbrew/.linuxbrew/Cellar/serverless/1.73.1/libexec/lib/node_modules/serverless/lib/classes/PluginManager.js:489:22)
      at /home/linuxbrew/.linuxbrew/Cellar/serverless/1.73.1/libexec/lib/node_modules/serverless/lib/classes/PluginManager.js:524:24
  From previous event:
      at PluginManager.run (/home/linuxbrew/.linuxbrew/Cellar/serverless/1.73.1/libexec/lib/node_modules/serverless/lib/classes/PluginManager.js:524:8)
      at /home/linuxbrew/.linuxbrew/Cellar/serverless/1.73.1/libexec/lib/node_modules/serverless/lib/Serverless.js:131:33
  From previous event:
      at Serverless.run (/home/linuxbrew/.linuxbrew/Cellar/serverless/1.73.1/libexec/lib/node_modules/serverless/lib/Serverless.js:118:74)
      at /home/linuxbrew/.linuxbrew/Cellar/serverless/1.73.1/libexec/lib/node_modules/serverless/bin/serverless.js:80:26
      at processImmediate (internal/timers.js:456:21)
      at process.topLevelDomainCallback (domain.js:137:15)
  From previous event:
      at Object.<anonymous> (/home/linuxbrew/.linuxbrew/Cellar/serverless/1.73.1/libexec/lib/node_modules/serverless/bin/serverless.js:80:4)
      at Module._compile (internal/modules/cjs/loader.js:1200:30)
      at Object.Module._extensions..js (internal/modules/cjs/loader.js:1220:10)
      at Module.load (internal/modules/cjs/loader.js:1049:32)
      at Function.Module._load (internal/modules/cjs/loader.js:937:14)
      at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
      at internal/main/run_main_module.js:17:47

  Get Support --------------------------------------------
     Docs:          docs.serverless.com
     Bugs:          github.com/serverless/serverless/issues
     Issues:        forum.serverless.com

  Your Environment Information ---------------------------
     Operating System:          linux
     Node Version:              14.4.0
     Framework Version:         1.73.1
     Plugin Version:            3.6.13
     SDK Version:               2.3.1
     Components Version:        2.30.16

Framework Core: 1.73.1 Plugin: 3.6.13 SDK: 2.3.1 Components: 2.30.16

貢獻者指南