What is wrong with this code? I am observing an error “Invalid field access (for value of type ‘Service’): ‘listen’” at the point where I’d expect my function listen() to be called:
function port(s) {
return s.substr(s.len() - s.reverse().find(":"))
}
function listen(s) {
return s.substr(0, s.len() - s.reverse().find(":") - 1)
}
apply Service "https6" for (http in host.vars.https6) {
vars.http_address = listen(http)
vars.http_port = port(http)
# ...
assign where host.vars.https6 && host.zone == "master"
}
UPDATE I am getting one step further when surrounding the expressions with two curly braces, however now a new error appears as “Argument is not a callable object”. My functions listen() and port are by now defined in a global zone.
I’ve tried it, but nops, this apparently does not work. The Language Reference shows examples where use() appears inside a lambda expression or a function definition only, and both seem different from the context at hand.