alibaba-archive / fcli

The cli of function compute.
81 stars 18 forks source link

支持环境变量以及升级 fc-go-sdk 依赖以支持 MNS TriggerConfig #49

Closed ChanDaoH closed 5 years ago

ChanDaoH commented 5 years ago

fcli 支持配置函数的环境变量,为 function update、function create 以及相应的 shell 模式 添加 env flag

Update function attributes

Usage:
  fcli function update [option] [flags]

Aliases:
  update, u

Flags:
  -b, --bucket string                 oss code bucket
      --code-dir string               function code directory. If both code-file and code-dir are provided, code-file will be used.
      --code-file string              zipped code file. If both code-file and code-dir are provided, code-file will be used.
  -d, --description string            function description
      --env stringArray               config environment variables, eg: --env key1=value1 --env key2=value2
      --etag string                   provide etag to do the conditional update. If the specified etag does not match the function's, the update will fail.
  -f, --function-name string          the function name
  -h, --handler string                function handler
      --help                          Print Usage
  -e, --initializationTimeout int32   initializer timeout in seconds
  -i, --initializer string            function initializer
  -m, --memory int32                  memory size in MB
  -o, --object string                 oss code object
  -t, --runtime string                function runtime
  -s, --service-name string           the service name
      --timeout int32                 function timeout in seconds

使用方法

fcli function update -s serviceName -f functionName --code-dir dir.zip --env key1=var1 --env key2=var2
muxiangqiu commented 5 years ago

是不是 shell.go 里面没有同步加支持环境变量功能

vangie commented 5 years ago

--env stringArray , stringArray 这个写法是约定的么?看着并不知道该如何写

ChanDaoH commented 5 years ago

--env stringArray,其中的 stringArray 是约定的,代表可以传递多个 env 标志,用法如下:

fcli function update --env value1 --env value2

我修改下 help 提示,加上点提示信息

vangie commented 5 years ago

--env stringArray,其中的 stringArray 是约定的,代表可以传递多个 env 标志,用法如下:

fcli function update --env value1 --env value2

我修改下 help 提示,加上点提示信息

docker run --help 的提示是

-e, --env list Set environment variables --env-file list Read in a file of environment variables

ChanDaoH commented 5 years ago

stringArray 是 cobra 框架底层为 StringArray Flag 提供的值,暂时没有办法去改变,目前 fcli 的 nas-server-addrnas-mount-dir 等也都是 stringArray. 新增了 --env-file stringArray read in a file of environment variables

muxiangqiu commented 5 years ago

LGTM