#Make HTTP requests against Service for runtime configuration

1 messages · Page 1 of 1 (latest)

merry bridge
#

Hey, I have a question. I want to create a sonarqube dagger module that allows me to setup a local server from the sonarqube:latest container image. The function to run the server should return a *Service but before that a bunch of http requests against the sonarqube API have to be made to configure the service, e.g. create a default user, retrieve an analysis token, etc.

My initial approach was to use go's net/http after starting the service with svc.Start(), retrieve the endpoint with svc.Endpoint() and then make http.Post(endpoint) requests. This doesn't seem to work because I get hostname lookup errors.

My second attemt was to use a container with curlinstalled, create a servicebinding at the curl container towards to sonarqube container and make requests that way (via WithExec), which works but has caused me some troubles with caching, e.g. the requests are not repeated when running the function again because the layers I created by running WithExec are cached.

Any idea how I can approach this?

TLDR: Start Service -> make HTTP requests to configure service via service's API -> expose Service to use after successful configuration.

Caveat: Configuration can only happen via HTTP API, no configuration option via env-vars, etc.

merry bridge
#

Make HTTP requests against Service for runtime configuration

odd hedge
#

I'd assume you don't want to be re-configuring the service each time, correct?

merry bridge
#

That‘s true, but for me it was inconsistent when requests would be executed and when not. E.g I didn’t use cache volumes to persist the services state during development so I would want to run the requests for configuration again on startup, which did not happen

odd hedge
merry bridge
#

Do you know if my attempt #1 could also work somehow? To make the requests directly with „net/http“ without the need for a curl container?

odd hedge
#

I'll share an example in a bit

merry bridge
odd hedge