microcks-cli icon indicating copy to clipboard operation
microcks-cli copied to clipboard

fix: pass context to all http requests in microcks and keycloak clients

Open mugiwaraluffy56 opened this issue 7 months ago • 1 comments

all http requests in MicrocksClient and KeycloakClient were built with http.NewRequest, which doesn't accept a context. this means there's no way to cancel an in-flight request from the caller side — if a call hangs, it just hangs.

switched everything over to http.NewRequestWithContext and added context.Context as the first parameter to all interface methods that make http calls. callers in cmd/ pass context.Background() for now, which keeps behaviour identical while making it possible to wire up proper timeouts later (e.g. in the polling loop in cmd/test.go).

files changed:

  • pkg/connectors/microcks_client.go — updated MicrocksClient interface and all five method implementations
  • pkg/connectors/keycloak_client.go — updated KeycloakClient interface and all three method implementations
  • pkg/watcher/executor.go — updated UploadArtifact call
  • cmd/importDir.go — updated local MicrocksClient interface and ImportDirectory signature
  • cmd/importDir_test.go — updated mock and test calls to match
  • cmd/import.go, cmd/importURL.go, cmd/test.go — pass context.Background() at call sites
  • cmd/login.go — threads cmd.Context() through to all keycloak and microcks calls

note: this is a breaking change to the MicrocksClient and KeycloakClient interface signatures. any code outside this repo that implements or calls these interfaces will need to be updated.

mugiwaraluffy56 avatar May 02 '26 15:05 mugiwaraluffy56

This pull request has been automatically marked as stale because it has not had recent activity :sleeping:

It will be closed in 30 days if no further activity occurs. To unstale this pull request, add a comment with detailed explanation.

There can be many reasons why some specific pull request has no activity. The most probable cause is lack of time, not lack of interest. Microcks is a Cloud Native Computing Foundation project not owned by a single for-profit company. It is a community-driven initiative ruled under open governance model.

Let us figure out together how to push this pull request forward. Connect with us through one of many communication channels we established here.

Thank you for your patience :heart:

github-actions[bot] avatar Jun 02 '26 01:06 github-actions[bot]