Skip to content

feat(client/go): extract Go client into a standalone module#4175

Open
ankitk0305 wants to merge 2 commits intoopenmeterio:mainfrom
ankitk0305:fix/3152-go-client-module
Open

feat(client/go): extract Go client into a standalone module#4175
ankitk0305 wants to merge 2 commits intoopenmeterio:mainfrom
ankitk0305:fix/3152-go-client-module

Conversation

@ankitk0305
Copy link
Copy Markdown

@ankitk0305 ankitk0305 commented Apr 19, 2026

Summary

Fixes #3152

Previously, importing the Go client forced downstream users to pull in the entire openmeter root module with 200+ transitive dependencies, causing version conflicts and unwanted upgrades.

This PR extracts the Go client into its own standalone Go module at github.com/openmeterio/openmeter/api/client/go.

Changes

  • api/client/go/go.mod — new standalone module declaration
  • api/client/go/models/percentage.go — local Percentage type (keeps alpacadecimal, eliminates root module)
  • api/client/go/models/problem.go — local StatusProblem type without the server-side go-chi dependency
  • api/client/go/codegen.yaml — added import-mapping to redirect pkg/models → local models package at generation time, so future go generate runs produce a self-contained output
  • api/client/go/client.gen.go — updated import to local models (reflects what go generate now produces)
  • api/client/go/client_test.go — removed openmeter/meter internal import; uses the generated MeterAggregationSum constant directly

Dependency footprint (before → after)

Before After
entire github.com/openmeterio/openmeter (~200+ deps) 4 direct deps

Standalone client direct dependencies:

  • github.com/alpacahq/alpacadecimalPercentage type
  • github.com/cloudevents/sdk-go/v2 — CloudEvents
  • github.com/getkin/kin-openapi — embedded spec validation
  • github.com/oapi-codegen/runtime — generated client runtime

Notes

  • go mod tidy should be run inside api/client/go/ to generate go.sum before merging.
  • The codegen.yaml import-mapping ensures future regenerations continue to use the local models package.

Test Plan

  • cd api/client/go && go mod tidy completes without errors
  • cd api/client/go && go build ./... succeeds
  • cd api/client/go && go test ./... passes
  • Existing root module tests continue to pass (make test)

Summary by CodeRabbit

  • Chores
    • Updated deployment configuration to explicitly specify container image registry sources for core infrastructure services, enhancing consistency across deployment environments.

Ankit Khandelwal and others added 2 commits April 19, 2026 12:52
Bitnami stopped publishing versioned images to Docker Hub in Nov 2024.
Override image.registry for kafka, postgresql, and redis sub-charts to
pull from registry.bitnami.com where the versioned tags remain available.

Fixes openmeterio#4172

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Fixes openmeterio#3152

Previously, importing the Go client required pulling in the entire
openmeter root module with 200+ transitive dependencies, causing
conflicts and forced upgrades for downstream users.

Changes:
- Add api/client/go/go.mod as a standalone module
  (github.com/openmeterio/openmeter/api/client/go)
- Add api/client/go/models/ with lightweight Percentage and
  StatusProblem types that carry no server-side dependencies
  (removes go-chi and other server deps from the client footprint)
- Update codegen.yaml with import-mapping to redirect
  pkg/models → api/client/go/models at generation time
- Update client.gen.go import accordingly (reflects regenerated output)
- Remove openmeter/meter internal import from client_test.go;
  use the generated MeterAggregationSum constant directly

The standalone module's direct dependencies are:
  github.com/alpacahq/alpacadecimal   (Percentage type)
  github.com/cloudevents/sdk-go/v2    (CloudEvents)
  github.com/getkin/kin-openapi       (embedded spec)
  github.com/oapi-codegen/runtime     (generated client runtime)

Run `go mod tidy` inside api/client/go/ to generate go.sum.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@ankitk0305 ankitk0305 requested a review from a team as a code owner April 19, 2026 20:24
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 19, 2026

📝 Walkthrough

Walkthrough

The pull request adds image registry configuration for three Helm chart services (Kafka, Redis, PostgreSQL) by specifying registry.bitnami.com in the OpenMeter Helm values file.

Changes

Cohort / File(s) Summary
Helm Chart Configuration
deploy/charts/openmeter/values.yaml
Added image.registry: registry.bitnami.com for kafka, redis, and postgresql sections to explicitly define the container image registry source for these services.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

🚥 Pre-merge checks | ✅ 2 | ❌ 4

❌ Failed checks (4 warnings)

Check name Status Explanation Resolution
Title check ⚠️ Warning The PR title refers to extracting a Go client into a standalone module, but the changeset only modifies Kubernetes Helm chart values (adding image registries for kafka, redis, postgresql). Update the title to accurately reflect the changes, such as 'chore(helm): add image registry configurations for dependencies' or verify the correct files are included in this PR.
Linked Issues check ⚠️ Warning The linked issue #3152 requires creating a standalone Go module for the client with reduced dependencies, but the changeset only modifies Helm chart configuration values. Ensure the Go module changes (go.mod, models, codegen.yaml, client.gen.go) described in PR objectives are actually included in this changeset, or clarify if this is a separate Helm-related PR.
Out of Scope Changes check ⚠️ Warning The changes to deploy/charts/openmeter/values.yaml appear unrelated to the PR's stated objective of extracting a Go client into a standalone module. Either remove the Helm chart changes from this PR or update the PR title and description to include both the Go client extraction and Helm configuration updates as separate, documented objectives.
Description check ⚠️ Warning The PR description discusses extracting a Go client module, but the actual changeset only modifies Helm chart values for image registries. Update the description to match the actual code changes, or verify that all intended Go client module files are included in this PR.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
deploy/charts/openmeter/values.yaml (1)

128-231: ⚠️ Potential issue | 🔴 Critical

registry.bitnami.com isn't a real Bitnami registry — this will break image pulls. 🚨

Same fix needed in three spots: kafka (line ~130), redis (line ~213), postgresql (line ~237). When Kubernetes tries to pull images, it'll hit ImagePullBackOff because that hostname doesn't exist.

Bitnami Helm charts build image references as {{ .Values.image.registry }}/{{ .Values.image.repository }}:{{ .Values.image.tag }}. The public registries that actually work are:

  • docker.io with repository bitnami/kafka, bitnami/redis, etc. (current Bitnami Secure Images)
  • docker.io with repository bitnamilegacy/kafka, bitnamilegacy/redis, etc. (older versions, no longer updated)

Here's the fix:

🔧 Update all three sub-charts
 kafka:
   enabled: true

   image:
-    registry: registry.bitnami.com
+    registry: docker.io
+    repository: bitnami/kafka

Same pattern for redis and postgresql — registry docker.io, repositories bitnami/redis and bitnami/postgresql respectively.

If this was meant to point at an internal mirror or private registry, it should live in user overrides/docs, not the default values.yaml.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@deploy/charts/openmeter/values.yaml` around lines 128 - 231, The values.yaml
currently uses the non-existent registry "registry.bitnami.com" for three
image.registry keys; update each image.registry to "docker.io" and ensure the
corresponding image.repository values point to the official Bitnami images
(e.g., set the Kafka repository to "bitnami/kafka" where the top-level
image.registry and image.repository are used, and set redis.image.repository to
"bitnami/redis" and postgresql.image.repository to "bitnami/postgresql"); adjust
the svix/docker.io override only if you intend to use a private mirror—otherwise
leave defaults pointing at docker.io and document mirror usage in overrides.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@deploy/charts/openmeter/values.yaml`:
- Around line 128-231: The values.yaml currently uses the non-existent registry
"registry.bitnami.com" for three image.registry keys; update each image.registry
to "docker.io" and ensure the corresponding image.repository values point to the
official Bitnami images (e.g., set the Kafka repository to "bitnami/kafka" where
the top-level image.registry and image.repository are used, and set
redis.image.repository to "bitnami/redis" and postgresql.image.repository to
"bitnami/postgresql"); adjust the svix/docker.io override only if you intend to
use a private mirror—otherwise leave defaults pointing at docker.io and document
mirror usage in overrides.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 7c3753e4-1509-46bc-b86f-669ae50484bc

📥 Commits

Reviewing files that changed from the base of the PR and between 13d183b and 6997020.

⛔ Files ignored due to path filters (6)
  • api/client/go/client.gen.go is excluded by !api/client/**
  • api/client/go/client_test.go is excluded by !api/client/**
  • api/client/go/codegen.yaml is excluded by !api/client/**
  • api/client/go/go.mod is excluded by !**/*.mod, !api/client/**
  • api/client/go/models/percentage.go is excluded by !api/client/**
  • api/client/go/models/problem.go is excluded by !api/client/**
📒 Files selected for processing (1)
  • deploy/charts/openmeter/values.yaml

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make a go module for the client

1 participant