Rules must be disabled before being deleted.
If I write tools or scripts to manage my openwhisk projects, using a client library, I end up having to always write an extra call to disable every rule I want to remove.
Would it be possible to modify the API to relax this constraint?
I think it's a good safety measure to be explicit and have the extra step by default.
Maybe have an option -force for those that want to it in one http call
Isn't it what "--disable" flag is already doing?
$ wsk rule delete --help
delete rule
Usage:
wsk rule delete RULE_NAME [flags]
Flags:
--disable automatically disable rule before deleting it
Having a force option would work. 馃憤
The CLI also has to send two API requests to support that flag.
https://github.com/openwhisk/openwhisk/blob/master/tools/cli/go-whisk-cli/commands/rule.go#L389
This protection on the rule isn't much protection at all: one can delete the trigger or the action leaving the rule in a bad state.
What's perhaps necessary is a sealing operation on a package instead, that prevent accidentally deleting, updating, or disabling all assets in the sealed package (note, I'm inventing a new concept, sealing, and allowing rules, triggers, and actions to be nested in a package).
So I've implemented this - the impetus was seeing the horrendous code one has to write to programmatically deal with deleting or updating a rule.
@jthomas npm openwhisk requires an update?
@rabbah npm openwhisk actually didn't manage this behaviour for you, it would return the fail response if you tried to delete an active rule.
Most helpful comment
@rabbah npm openwhisk actually didn't manage this behaviour for you, it would return the fail response if you tried to delete an active rule.