Fork me on GitHub
#clojure
<
2019-09-25
>
khellang08:09:12

has anyone written a github action for setting up the clj tooling?

vlaaad09:09:44

I discussed it in #tools-deps awhile ago https://clojurians-log.clojureverse.org/tools-deps/2019-09-13 I guess @gerred could know more

ghadi11:09:48

Something like that will work. You’re going to have to configure an ssh agent and a secret if you have private deps

jumar17:09:45

I'm wondering how people deal with clj-http exceptions and potentially sensitive data. We have a high-level component that spawns processes and catch and logs all errors at the top level. However clj-http might throw an exception on non-ok status (such as 404) and since it uses slingshot the exception contains the whole environment -> the problem is that it can contain basic auth credentials for example:

clojure.lang.ExceptionInfo: clj-http: status 404
    environment: {req
                  {:basic-auth ["xxx" "yyy"],

hiredman17:09:05

Catch the exception, strip the info, or turn off the exception throwing behavior

jumar18:09:53

Yeah, that's what I've ended up doing right now (meaning removing the sensitive information from logs)

noisesmith18:09:12

what I've done is :throw-exceptions false combined with explicitly calling the clj-http.client function that tests for exceptional results with our own throw

👍 4
noisesmith18:09:17

clj-http.client/success? is the function

noisesmith18:09:28

where client is an AOP style wrapper:

(fn [opts]
    (let [{:keys [error] :as response} (client opts)]
      (when (not (clj-http/success? response))
        (error-reporter opts response (failure-reporters error)))
      response))

noisesmith18:09:21

this is inside a middleware and returns a new client

ghadi18:09:16

the exception stuff is bizarre, but one thing that's not in the exception info is the request uri

lukasz18:09:34

You can also use ring-style middlewares with clj-http - makes it easier to share the code for cleaning up request data, plugging in authentication etc

noisesmith20:09:35

is there a public repo for the clj / clojure command line tools?

ghadi21:09:31

that where it lives, surprisingly enough

dpsutton21:09:03

the name made me doubt myself

noisesmith21:09:58

I found it just before checking for the answer here, by looking in the clojure-tools jar file referenced in the script

noisesmith21:09:04

the pom.xml links that repo

noisesmith21:09:18

that reminds me, someone was mentioning quoting / whitespace issues somewhere in the script logic, and recently I learned about %q in shell format, which shell-quotes its argument

noisesmith21:09:41

$ printf %q '""'
\"\"
sometimes that can save you a lot of quoting headaches

noisesmith21:09:28

may or may not be applicable to the issue in clj (something about caching dep maps?)

noisesmith21:09:07

oh never mind, that only works for gnu printf and bsd printf is what osx uses ootb

lukasz21:09:13

😢 I got excited for a sec (I'm writing a lot of shell scripts which need to work in macos and linux)

noisesmith21:09:02

yeah - I wonder if there's something similar that reliably works on bsd

lilactown21:09:40

curse you bsd tools!

lukasz21:09:44

Well, I usually end up switching to Ruby or Python once the scripts get out of hand. That said, I do enjoy typing esac to end the case statement 😉

dpsutton21:09:53

i had to fix one gnu/bsd sed issue today and that was annoying enough

dpsutton21:09:08

i'm glad i don't have your pain

lilactown21:09:28

hehe, I was just working with a script that had to do some branching on uname -s because sed -i acts differently in gnu vs bsd

dpsutton21:09:14

Yup. It was sed -i. So annoying