Replies: 6 comments
-
Hi! Currently Verb does not offer an option to load variables from external files. I thought of adding it in the past but I never had the need myself. My main question I guess is whether it is better to allow users to load variables from an |
Beta Was this translation helpful? Give feedback.
-
How about something like:
Then, the file would be evaluated either 1) the first time a request is sent or 2) each time a request is sent. |
Beta Was this translation helpful? Give feedback.
-
It would be perfect, no matter for me if the external file is in elisp or
org format.
And thanks a lot for your package !
Le jeu. 25 avr. 2024, 20:25, Federico Tedin ***@***.***> a
écrit :
… How about something like:
#+VERB-PRELUDE: "~/foo.el"
...
Then, the file would be evaluated either 1) the first time a request is
sent or 2) each time a request is sent.
—
Reply to this email directly, view it on GitHub
<#68 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAHR7XW5GE2MW5FYMEFFFUDY7FDBRAVCNFSM6AAAAABGZJLESGVHI2DSMVQWIX3LMV43SRDJONRXK43TNFXW4Q3PNVWWK3TUHM4TEMRYGQYDS>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
I was just working on something like this for myself and stumbled across this discussion. My use case is store configuration variables and "security" items like api keys together in a gpg file, away from the verb org files. Then I can share and send to git repo without worrying about exposed api keys, etc. Emacs will open and decrypt gpg files automatically with auth-sources configured. I went with Json seems more accessible to some folks using org and verb. Here's my function to load up verb variables from a json file: (defun my/verb-set-var-from-secure-config (filename)
"Load a json configuration file named: FILENAME into verb variables."
(interactive)
(save-excursion
(let* ((json (with-temp-buffer
(insert-file-contents filename)
(buffer-string)))
(data (json-parse-string json :object-type 'plist)))
(cl-loop for (k v) on data by #'cddr
if (and (listp v) (cl-evenp (length v)))
do (cl-loop for (subk subv) on v by #'cddr
do (verb-set-var (substring (symbol-name subk) 1) subv))
else do (verb-set-var (substring (symbol-name k) 1) v)))))
;; Call example:
;; (my/verb-set-var-from-secure-config "/path/to/my/file.json.gpg") My example of json file for some cloudflare api data that I put tinto {
"email": "[email protected]",
"global_api_key": "0xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"account_id": "42000000000000000000000000000000",
"bearer": "Xxxxxxxxxx-xxxxxxxxxx_xxxxxxxxxxxxxxxxxx",
"zone-ids":
{"myexample.com": "1xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"myotherdomain.com": "2xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"}
} With all that said... I would love BTW, I just found and started using verb yesterday. And it is wonderful. Thanks! Edit: fix call to function to be just filename. |
Beta Was this translation helpful? Give feedback.
-
Thanks for the comment @jeff-phil - that looks like the type of thing that would be perfect to run automatically before a request is sent. The tip about Emacs decrypting GPG files automatically is useful as well - although Verb does not have anything to do with it directly, I might mention in in the documentation in the future since it's useful nonetheless. |
Beta Was this translation helpful? Give feedback.
-
I had a little bit of time and energy tonight, so I went ahead and created PR #69 for this. I ended up adding ability to specify either json and/or .el file for the configuration files, determined based on the content. |
Beta Was this translation helpful? Give feedback.
-
Hi,
I would like to store authentication keys in an external file, like :
~/.emacs.env.org :
myfile.org:
With no success. "authparam" is only read if local variables are defined in myfile.org.
The only alternative I found is to define my var in a block and evaluate it manually.
Any idea or alternative ?
Beta Was this translation helpful? Give feedback.
All reactions