Fork me on GitHub
#clojure-uk
<
2021-03-26
>
danm10:03:13

How would I use spec to specify an optional positional arg, but define the contents of that arg if it exists? Like, my current spec is:

(s/fdef set-http-probe :args (s/cat :deployment ::kube-deployment/deployment
                                    :kind #{:startup :liveness :readiness :default}
                                    :args (s/keys :opt-un [::kube/probe-kind ::kube/http-port ::kube/path ::kube/probe-args])))
but I actually want to not have to specify the args parameter at all. At the moment if there are no additional optional args to provide I have to call the function with an empty map at that location. I tried wrapping s/keys in s/nilable, but in that case I still had to provide an explicit nil final arg in my call

danm07:03:25

The answer to this was s/alt, which I've not come across before 🎉

Conor08:03:20

I like to use it with ch/ips

danm08:03:01

Why is there no :groan: emoji?

Conor13:03:47

You're a dad now Dan, get in on the joke action

danm10:03:38

Doing 2x s/cat (1 missing :args entirely) that are combined with a basic or doesn't seem to quite work either