I'd expect to be able to create a hook via sensuctl create -f just like other resources.
[root@sensu_backend /]# sensuctl create -f hook.json
Error: PUT "/hooks/test": {"code":2,"message":"not found"}
[root@sensu_backend /]# cat hook.json
{
"type": "Hook",
"spec": {
"metadata": {
"name": "test",
"namespace": "default",
"labels": {
"foo": "baz"
}
},
"command": "ps aux",
"timeout": 60
}
}
[root@sensu_backend /]# sensuctl create -f hook.json
Error: PUT "/hooks/test": {"code":2,"message":"not found"}
I rely very heavily on sensuctl create -f in the sensu Puppet module. This was not an issue I recall facing during beta. CC @ghoneycutt
This is somewhat confusing for people, unfortunately.
A Hook is a runtime Hook object - not designed to be created by users.
The actual type that should be created is HookConfig, and that is the type we do QA on.
We had an alias for Hook that people could use, to support sensuctl create, which didn't get updated when we refactored our API. Turns out it wasn't covered by our testing.
You can use "type": "HookConfig" to work around this for now.
The long term fix is to update the Hook's URIPath method to respect namespaces properly.
I can confirm using HookConfig works.
@echlebek I don't think we need an alias for "Hook" here. Hooks weren't a first class object in Sensu (classic), they were only an attribute of checks. Hook objects have only existed during Sensu Go alpha and beta releases, so deprecating then in favor of HookConfig should be fine.