You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@openwhisk.apache.org by GitBox <gi...@apache.org> on 2018/10/11 08:12:09 UTC

[GitHub] ningyougang edited a comment on issue #4058: Add protect feature to avoid update or delete actions by mistake

ningyougang edited a comment on issue #4058: Add protect feature to avoid update or delete actions by mistake
URL: https://github.com/apache/incubator-openwhisk/pull/4058#issuecomment-428034588
 
 
   @cbickel @rabbah ,thanks for your quick reply.
   
   Actually, i opened a pr first here: https://github.com/apache/incubator-openwhisk-cli/pull/372
   Solve the update/delete mistake on CLI side, after think deeply, i found, it is better to solve it in backend layer.(So don't merge that pull/372 temporarily)
   
   I did below changes
   * Add `"annotations":[{"key":"lock","value":true}]` to body instead of `URL request param`
   
   So we can use below method
   ```
   curl  -X PUT -H "Content-type: application/json"  
   --user 23bc46b1-71f6-4ed5-8c54-816aa4f8c502:123zO3xZCLrMN6v2BKK1dXYFpXlPkccOFqm12CdAsMgRU4VrNZ9lyGVCGuMDGIwP 
   -d '{"namespace":"guest","name":"hello","annotations":[{"key":"lock","value":true}],
   "exec":{"kind":"nodejs:default","code":"// Licensed to the Apache Software Foundation (ASF) under one or more contributor\r\n// license agreements; and to You under the Apache License, Version 2.0.\r\n\r\n/**\r\n * Hello, world.\r\n */\r\nfunction main() {\r\n return {\"payload\":\"Hello world\"};\r\n}\r\n"}}' 
   '/api/v1/namespaces/guest/actions/hello?overwrite=true'
   ```
   Or use wsk like this `wsk action create hello hello.js --annotation lock true`
   
   * Or would it make sense to protect it against updates as well?
   
     I agree, already added
   
   * The trick here would be to allow the update to unlock the action again
   
    Use below method(pass -d '{"unlock:"true"}'), for example
   ```
   curl  -X PUT  -H "Content-type: application/json"  
   --user 23bc46b1-71f6-4ed5-8c54-816aa4f8c502:123zO3xZCLrMN6v2BKK1dXYFpXlPkccOFqm12CdAsMgRU4VrNZ9lyGVCGuMDGIwP 
   -d '{"unlock":"true"}'  'http://xxx.xxx.xxx.xxx:port/api/v1/namespaces/guest/actions/hello?overwrite=true'
   ```
   
   * Wsk side(TODO)
   
   If this patch is merged into upstream, the wsk side will do some changes, add `unlock feature` to wsk to enable `update or delete operation`, for example
   ```
   wsk action update hello --unlock
   ``

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services