portkey

Portkey: from REPL to Serverless in one call
cgrand 2017-10-11T11:52:30.000022Z

@baptiste-from-paris that’s for you ^^

cgrand 2017-10-11T11:53:56.000452Z

So the problem was that something (someone?) reloaded the portkey.ouroboros namespace

baptiste-from-paris 2017-10-11T11:55:33.000019Z

nice !

baptiste-from-paris 2017-10-11T11:55:49.000350Z

you made it to Baltimore ?

cgrand 2017-10-11T12:12:09.000093Z

still in Heathrow, boarding for Baltimore in 1 2 hour and a half

👏 1
baptiste-from-paris 2017-10-11T12:12:52.000226Z

are you talking there ?

cgrand 2017-10-11T12:13:08.000133Z

No, hosting an unsession on unrepl

baptiste-from-paris 2017-10-11T12:13:15.000087Z

lol

baptiste-from-paris 2017-10-11T12:13:32.000061Z

unsession of unrepl’s

cgrand 2017-10-11T12:13:34.000139Z

(first time at a conf as a regular attendee)

baptiste-from-paris 2017-10-11T12:13:51.000438Z

lol

baptiste-from-paris 2017-10-11T12:14:50.000231Z

that’s nice too ! and talking about portkey? too soon ?

cgrand 2017-10-11T12:21:43.000276Z

yeah too soon, let’s target a proper talk next year 😄

baptiste-from-paris 2017-10-11T12:23:30.000237Z

I’d love to use om-next with portkey for a demo

baptiste-from-paris 2017-10-11T12:26:02.000049Z

what do you think about allowing resource directory instead of files

baptiste-from-paris 2017-10-11T12:26:02.000319Z

?

cgrand 2017-10-11T12:27:28.000357Z

and adding all files in the directory (and subdirs?) as resources?

baptiste-from-paris 2017-10-11T12:27:35.000164Z

yes

baptiste-from-paris 2017-10-11T12:28:03.000030Z

main example would be assets file like css/js/html/img

cgrand 2017-10-11T12:30:02.000270Z

ok except that you formulated your request as “allowing resource directory instead of files” and I’m ok for “allowing resource directory in addition to files”

baptiste-from-paris 2017-10-11T12:30:37.000278Z

yes, my mistake

cgrand 2017-10-11T12:40:22.000227Z

ssl stuff is getting me crazy

cgrand 2017-10-11T12:41:45.000465Z

Let’s train a braindump: • these are JDK classes so we don’t have control on the version

cgrand 2017-10-11T12:44:23.000235Z

• public ifaces are mostly write-only • impl varies a lot

baptiste-from-paris 2017-10-11T12:48:16.000429Z

back to the loader problem or #’wrapper or something else ,

baptiste-from-paris 2017-10-11T12:48:17.000240Z

?

cgrand 2017-10-11T12:52:34.000004Z

back to using clj-http in portkey

baptiste-from-paris 2017-10-11T12:53:27.000177Z

• these are JDK classes so we don't have control on the version => fix a jdk version for now

cgrand 2017-10-11T13:46:02.000315Z

No.

baptiste-from-paris 2017-10-11T13:46:41.000103Z

ok ^^

cgrand 2017-10-11T13:47:06.000141Z

as time pass the problem is going to get bigger

cgrand 2017-10-11T13:47:28.000613Z

(and if the first thing you ask your user is to install a specific JDK....)

cgrand 2017-10-11T13:48:26.000165Z

The root of the problem is clj-http.core/get-conn-mgr.

baptiste-from-paris 2017-10-11T13:48:31.000277Z

yes indeed, and to be honest I am not confortable enough with portkey to realize how big the problem is

cgrand 2017-10-11T13:50:08.000321Z

as an optimization default values are allocated when the clj-http.conn is loaded

cgrand 2017-10-11T13:51:15.000901Z

and these values depends on JDK version, security/crypto settings and moon phase

cgrand 2017-10-11T13:51:45.000232Z

especially moon phase

baptiste-from-paris 2017-10-11T13:52:09.000385Z

that’s what I was going to say, I remember having to turn off SSL with Google client api and portkey

baptiste-from-paris 2017-10-11T13:52:21.000209Z

because of (java.security KeyStore)

cgrand 2017-10-11T13:53:39.000090Z

The Java one?

baptiste-from-paris 2017-10-11T13:53:51.000779Z

yes, let me find you pieces of code

baptiste-from-paris 2017-10-11T13:55:06.000396Z

this code works fine localy =>

(defn gmail-service [app-name account-id file-path account-user]
  (let [transport (.. (NetHttpTransport$Builder.)
                      (trustCertificates (GoogleUtils/getCertificateTrustStore))
                      (build))
        jackson (JacksonFactory/getDefaultInstance)
        credentials (.. (GoogleCredential$Builder.)
                        (setTransport transport)
                        (setJsonFactory jackson)
                        (setServiceAccountId account-id)
                        (setServiceAccountPrivateKeyFromP12File (File. file-path))
                        (setServiceAccountScopes (GmailScopes/all))
                        (setServiceAccountUser account-user)
                        (build))]
    #_(.refreshToken credentials)
    (.. (Gmail$Builder. transport jackson credentials)
        (setApplicationName app-name)
        (build))))

baptiste-from-paris 2017-10-11T13:56:12.000082Z

it let’s you create a gmail-service with a g-suite accounte (pro) and do pretty-much what ever you want with your g-suite account

baptiste-from-paris 2017-10-11T13:56:22.000470Z

but it does not work on portkey

baptiste-from-paris 2017-10-11T13:56:26.000107Z

because of this line

baptiste-from-paris 2017-10-11T13:56:39.000102Z

(trustCertificates (GoogleUtils/getCertificateTrustStore))

cgrand 2017-10-11T13:56:51.000097Z

Clojure is 10yo, don’t use .. anymore

baptiste-from-paris 2017-10-11T13:56:57.000207Z

lol

baptiste-from-paris 2017-10-11T13:57:15.000161Z

i’am addicted to CLJ for a year ^^

baptiste-from-paris 2017-10-11T13:57:42.000126Z

and this getCertificateTrustStore does this =>

baptiste-from-paris 2017-10-11T13:57:52.000118Z

public static synchronized KeyStore getCertificateTrustStore()
      throws IOException, GeneralSecurityException {
    if (certTrustStore == null) {
      certTrustStore = SecurityUtils.getJavaKeyStore();
      InputStream keyStoreStream = GoogleUtils.class.getResourceAsStream("google.jks");
      SecurityUtils.loadKeyStore(certTrustStore, keyStoreStream, "notasecret");
    }
    return certTrustStore;
  }

cgrand 2017-10-11T13:58:05.000035Z

It’s an opinion but -> allows to mix fns and methods, and force you to prefix methods by . making it more locally obvious it’s interop

baptiste-from-paris 2017-10-11T13:58:33.000373Z

ok, thx. will try this way then

baptiste-from-paris 2017-10-11T13:58:59.000748Z

and loadKeyStore fails

baptiste-from-paris 2017-10-11T13:59:11.000061Z

because SecurityUtils.getJavaKeyStore(); returns null

baptiste-from-paris 2017-10-11T14:01:19.000064Z

I have to trie it again but I think that java.security.getInstance was failing

baptiste-from-paris 2017-10-11T14:08:36.000601Z

I’ll check tomorrow morning what this one returns = clj-http.conn-mgr/get-keystore

baptiste-from-paris 2017-10-11T19:50:34.000235Z

I don’t know if It helps or not