Skip to content

refactor: rename *Config types to *Spec and remove CRD renaming map#139

Open
gaarutyunov wants to merge 3 commits into
mainfrom
claude/issue-123-20260417-0728
Open

refactor: rename *Config types to *Spec and remove CRD renaming map#139
gaarutyunov wants to merge 3 commits into
mainfrom
claude/issue-123-20260417-0728

Conversation

@gaarutyunov

@gaarutyunov gaarutyunov commented Apr 17, 2026

Copy link
Copy Markdown
Owner

Closes #123

All config types in pkg/config/config.go have been renamed from the *Config suffix to *Spec (e.g. UpstreamConfigUpstreamSpec). CRD spec types in pkg/crd/v1alpha1 that previously had Proxy/MCPUpstream prefixes are now aligned to the same names as config types, removing the need for a renaming map in CRD generation.

Generated with Claude Code

Summary by CodeRabbit

  • Refactor
    • Standardized configuration type naming throughout codebase by renaming *Config types to *Spec types across all configuration structures (e.g., ProxyConfigProxySpec, ServerConfigServerSpec) for improved consistency and clarity.
    • Simplified internal spec type mapping and generation logic in configuration utilities.

All config types in pkg/config/config.go have been renamed from the
*Config suffix to *Spec (e.g. UpstreamConfig -> UpstreamSpec). The CRD
spec types in pkg/crd/v1alpha1 that previously had Proxy/MCPUpstream
prefixes (ProxyNamingSpec, MCPUpstreamCommandSpec, etc.) are now aligned
to use the same names as the config types (NamingSpec, CommandSpec, etc.).

The SpecMapping in internal/crdutil/typegen.go has been simplified from a
[]struct{ConfigType, CRDType string} to a []string, removing the type-
renaming step from CRD generation since both packages now share the same
names. The generator's nameMap lookup has been replaced with a known-types
set that passes type names through unchanged.

CRDs regenerated via make generate-crds (spec_gen.go, zz_generated.deepcopy.go,
charts/mcp-anything/crds/*.yaml updated).

All unit tests pass; lint, vet, integration/e2e/treeshake build tags compile.

Co-authored-by: German Arutyunov <gaarutyunov@users.noreply.github.com>
@coderabbitai

coderabbitai Bot commented Apr 17, 2026

Copy link
Copy Markdown
Contributor

Warning

Rate limit exceeded

@claude[bot] has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 52 minutes and 36 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 52 minutes and 36 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: cd8b56cf-d322-4a63-aded-dd3328634fea

📥 Commits

Reviewing files that changed from the base of the PR and between 5cdfcca and b95f423.

📒 Files selected for processing (4)
  • internal/crdutil/typegen.go
  • pkg/crd/v1alpha1/spec_gen.go
  • pkg/crd/v1alpha1/types.go
  • pkg/operator/configgen/generator.go
📝 Walkthrough

Walkthrough

This PR systematically renames all exported configuration struct types ending in "Config" to "Spec" throughout the codebase, including the top-level ProxyConfig→ProxySpec and cascading updates to all dependent packages, CRD types, builders, middleware registrations, and tests, with no functional logic changes.

Changes

Cohort / File(s) Summary
CRD YAML Schema Annotations
charts/mcp-anything/crds/mcpproxy.yaml, charts/mcp-anything/crds/mcpupstream.yaml
Updated "Generated from" description references in CRD schemas from *Config types to corresponding *Spec types (e.g., JWTAuthConfigJWTAuthSpec, CommandConfigCommandSpec).
Type Generator Refactoring
internal/crdutil/typegen.go
Refactored SpecMapping from slice of {ConfigType, CRDType} pairs to slice of identical type names ([]string), removing the rename-mapping logic and updating related helper functions and error messages accordingly.
Top-Level Config Types
pkg/config/config.go
Renamed top-level ProxyConfigProxySpec and systematically renamed ~40+ nested exported config struct types ending in *Config to *Spec (e.g., ServerConfigServerSpec, TelemetryConfigTelemetrySpec, CacheConfigCacheSpec).
Config Loader
pkg/config/loader.go
Updated Loader type to store atomic.Pointer[ProxySpec], Load() function return type, and NewLoader callback signature to use ProxySpec instead of ProxyConfig.
Inbound Auth Providers
pkg/auth/inbound/jwt/jwt.go, pkg/auth/inbound/apikey/apikey.go, pkg/auth/inbound/introspection/introspection.go, pkg/auth/inbound/wellknown.go
Updated NewValidator constructors and middleware registrations to accept JWTAuthSpec, APIKeyAuthSpec, IntrospectionSpec, and use ProxySpec in WellKnownHandler signature.
Outbound Auth Providers
pkg/auth/outbound/bearer/bearer.go, pkg/auth/outbound/apikey/apikey.go, pkg/auth/outbound/oauth2/oauth2.go, pkg/auth/outbound/none/none.go, pkg/auth/outbound/oauth2usersession/oauth2usersession.go
Updated NewProvider constructors and middleware registrations to accept BearerOutboundSpec, APIKeyOutboundSpec, OAuth2CCSpec, OAuth2UserSessionSpec, and use OutboundAuthSpec for config assertions.
Cache Package
pkg/cache/cache.go, pkg/cache/memory/memory.go, pkg/cache/redis/redis.go
Updated StoreFactory type and New function signatures to accept CacheStoreSpec instead of CacheStoreConfig.
Runtime Package
pkg/runtime/registry.go, pkg/runtime/js/js.go, pkg/runtime/lua/lua.go, pkg/runtime/lua/provider_test.go, pkg/runtime/lua/validator_test.go
Updated Factory function type and runtime pool registration callbacks to accept RuntimeSpec, and auth/script constructors to use JSAuthSpec/JSOutboundSpec/LuaAuthSpec/LuaOutboundSpec.
Session Store Providers
pkg/session/session.go, pkg/session/memory/memory.go, pkg/session/postgres/postgres.go, pkg/session/redis/redis.go
Updated StoreFactory type and New function signatures to accept SessionStoreSpec instead of SessionStoreConfig.
Rate Limiting
pkg/ratelimit/ratelimit.go, pkg/ratelimit/memory/memory.go, pkg/ratelimit/redis/redis.go, pkg/ratelimit/ratelimit_test.go
Updated StoreFactory type, Enforcer.configs field, and New function to use RateLimitSpec and ProxySpec.
Server & Transport
pkg/server/server.go, pkg/transport/tls.go, pkg/transport/transport.go, pkg/transport/transport_test.go
Updated Server.cfg field and constructor, TLS builder functions, and transport builder methods to accept ProxySpec/ServerTLSSpec/TLSSpec/TransportSpec.
OpenAPI & UI
pkg/openapi/generator.go, pkg/openapi/loader.go, pkg/openapi/overlay.go, pkg/openapi/validator.go, pkg/openapi/naming.go, pkg/openapi/naming_test.go, pkg/ui/ui.go
Updated function signatures for loading/generating/validating OpenAPI specs to accept OpenAPISourceSpec, OverlaySpec, UpstreamSpec, NamingSpec, SlugRulesSpec, and ToolUISpec.
Embedding Providers
pkg/embedding/embedding.go, pkg/embedding/hugot/hugot.go
Updated ProviderFactory type and New function to accept EmbeddingSpec instead of EmbeddingConfig, and constructor to use HugotEmbedSpec.
Upstream Builders & Registry
pkg/upstream/upstream.go, pkg/upstream/registry.go, pkg/upstream/http/builder.go, pkg/upstream/http/client.go, pkg/upstream/http/refresh.go, pkg/upstream/http/ui_factory.go, pkg/upstream/http/withui/withui.go, pkg/upstream/command/builder.go, pkg/upstream/command/command.go, pkg/upstream/script/builder.go, pkg/upstream/script/script.go, pkg/upstream/script/script_test.go, pkg/upstream/circuitbreaker/breaker.go, pkg/upstream/refresher.go
Systematically updated Builder.Build method, RefresherFactory, and public function signatures to accept UpstreamSpec, NamingSpec, CommandSpec, ScriptSpec, and related spec types.
MCP Manager & Caddy
pkg/mcp/manager.go, pkg/mcpanything/proxy.go, pkg/caddy/caddy.go
Updated internal fields and function signatures in Manager and Proxy to use ProxySpec and spec-typed configurations (RateLimitSpec, GroupSpec, NamingSpec, CacheSpec).
CRD Generated Types
pkg/crd/v1alpha1/spec_gen.go, pkg/crd/v1alpha1/types.go, pkg/crd/v1alpha1/zz_generated.deepcopy.go
Renamed CRD Go types by removing prefixes and using canonical names (e.g., MCPUpstreamCommandSpecCommandSpec, ProxyNamingSpecNamingSpec, MCPUpstreamValidationSpecValidationSpec), updated field types in MCPProxySpec/MCPUpstreamSpec, and regenerated deep-copy methods.
Operator & Config Generator
pkg/operator/configgen/generator.go
Updated internal helper buildGeneratedInputSchema parameter type from *v1alpha1.MCPUpstreamCommandInputSchema to *v1alpha1.CommandInputSchema and updated documentation comments.
Telemetry
pkg/telemetry/provider.go
Updated documentation comment to reference config.TelemetrySpec instead of config.TelemetryConfig.
End-to-End & Integration Tests
tests/e2e/kraken_e2e_test.go, tests/e2e/remote_dev_e2e_test.go, tests/integration/operator_test.go
Updated test fixture types to use v1alpha1.NamingSpec, v1alpha1.CommandSpec, and related renamed CRD types instead of old names with prefixes.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~75 minutes

Possibly related PRs

Poem

🐰 Once configs wore the "Config" name so bright,
But now they don the "Spec" mantle in the light!
From ProxyConfig to ProxySpec we've climbed,
A thousand types renamed—at last, aligned! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.98% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed Title accurately describes the main change: systematic renaming of *Config types to *Spec and CRD renaming map removal.
Linked Issues check ✅ Passed PR fulfills all requirements from issue #123: renamed all *Config to *Spec types, aligned CRD spec type names, simplified SpecMapping, updated all usages, and fixed tests/build tags.
Out of Scope Changes check ✅ Passed All changes are in-scope: type renames, function signature updates, and deep-copy method regeneration directly support the renaming and CRD alignment objectives.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/issue-123-20260417-0728

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.

@gaarutyunov

Copy link
Copy Markdown
Owner Author

@claude you misunderstood me. I meant keep Config for configs, but make the renaming algorithmic. Parse the type name, replace Config by Spec and that’s it.

@claude

claude Bot commented Apr 17, 2026

Copy link
Copy Markdown

Claude finished @gaarutyunov's task in 11m 30s —— View job


Fixing CRD type renaming to be algorithmic

  • Read relevant files to understand current state
  • Revert *Spec*Config rename in pkg/config/config.go and all consumers
  • Update internal/crdutil/typegen.go to algorithmically replace ConfigSpec in type names
  • Update/regenerate CRD types in pkg/crd/v1alpha1/
  • Run make check — all lint/vet/test/build pass
  • Commit and push

What changed

internal/crdutil/typegen.go:

  • SpecMapping now lists config type names (JWTAuthConfig, NamingConfig, etc.)
  • New specName() function replaces Config suffix with Spec algorithmically
  • GenerateSpecContent builds a nameMap (config → spec) and passes it through convertField/convertTypeExpr
  • Types without a Config suffix (CommandInputSchema, CommandSchemaProperty) are passed through unchanged

All config types stay as *Config throughout pkg/config and the rest of the codebase. The CRD spec types (NamingSpec, TelemetrySpec, ValidationSpec, etc.) are the same as before — just derived algorithmically now instead of via a manual mapping.
|

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
internal/crdutil/typegen.go (1)

38-57: Minor doc nit: SpecMapping contains non-*Spec entries.

The updated doc says the list contains "spec type names," but CommandInputSchema and CommandSchemaProperty don't follow the *Spec convention. Consider softening the wording (e.g., "shared type names mirrored into v1alpha1") to avoid implying a naming invariant the list doesn't enforce. Purely cosmetic — no functional concern.

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

In `@internal/crdutil/typegen.go` around lines 38 - 57, The top-of-file comment
for SpecMapping misleadingly says it lists "spec type names" but the slice
SpecMapping contains non-*Spec entries like CommandInputSchema and
CommandSchemaProperty; update the doc comment near SpecMapping to use a softer,
accurate description (e.g., "shared type names mirrored into v1alpha1" or "types
mirrored as CRD spec/shared types") so it doesn't imply a naming invariant, and
mention the ordering/rules unchanged; edit the comment block above the
SpecMapping variable to reflect this wording change.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@pkg/operator/configgen/generator.go`:
- Line 261: Doc comment for buildGeneratedInputSchema has a grammatical error:
change "converts an CommandInputSchema" to "converts a CommandInputSchema" in
the comment above the buildGeneratedInputSchema function to use the correct
article for CommandInputSchema.

---

Nitpick comments:
In `@internal/crdutil/typegen.go`:
- Around line 38-57: The top-of-file comment for SpecMapping misleadingly says
it lists "spec type names" but the slice SpecMapping contains non-*Spec entries
like CommandInputSchema and CommandSchemaProperty; update the doc comment near
SpecMapping to use a softer, accurate description (e.g., "shared type names
mirrored into v1alpha1" or "types mirrored as CRD spec/shared types") so it
doesn't imply a naming invariant, and mention the ordering/rules unchanged; edit
the comment block above the SpecMapping variable to reflect this wording change.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 09c098cc-1cee-43d2-a055-c4885bc44365

📥 Commits

Reviewing files that changed from the base of the PR and between 5658758 and 5cdfcca.

📒 Files selected for processing (68)
  • charts/mcp-anything/crds/mcpproxy.yaml
  • charts/mcp-anything/crds/mcpupstream.yaml
  • internal/crdutil/typegen.go
  • pkg/auth/inbound/apikey/apikey.go
  • pkg/auth/inbound/introspection/introspection.go
  • pkg/auth/inbound/jwt/jwt.go
  • pkg/auth/inbound/wellknown.go
  • pkg/auth/outbound/apikey/apikey.go
  • pkg/auth/outbound/bearer/bearer.go
  • pkg/auth/outbound/none/none.go
  • pkg/auth/outbound/oauth2/oauth2.go
  • pkg/auth/outbound/oauth2usersession/oauth2usersession.go
  • pkg/cache/cache.go
  • pkg/cache/memory/memory.go
  • pkg/cache/redis/redis.go
  • pkg/caddy/caddy.go
  • pkg/config/config.go
  • pkg/config/loader.go
  • pkg/crd/v1alpha1/spec_gen.go
  • pkg/crd/v1alpha1/types.go
  • pkg/crd/v1alpha1/zz_generated.deepcopy.go
  • pkg/embedding/embedding.go
  • pkg/embedding/hugot/hugot.go
  • pkg/mcp/manager.go
  • pkg/mcpanything/proxy.go
  • pkg/openapi/generator.go
  • pkg/openapi/loader.go
  • pkg/openapi/naming.go
  • pkg/openapi/naming_test.go
  • pkg/openapi/overlay.go
  • pkg/openapi/validator.go
  • pkg/operator/configgen/generator.go
  • pkg/ratelimit/memory/memory.go
  • pkg/ratelimit/ratelimit.go
  • pkg/ratelimit/ratelimit_test.go
  • pkg/ratelimit/redis/redis.go
  • pkg/runtime/js/js.go
  • pkg/runtime/lua/lua.go
  • pkg/runtime/lua/provider_test.go
  • pkg/runtime/lua/validator_test.go
  • pkg/runtime/registry.go
  • pkg/server/server.go
  • pkg/session/memory/memory.go
  • pkg/session/postgres/postgres.go
  • pkg/session/redis/redis.go
  • pkg/session/session.go
  • pkg/telemetry/provider.go
  • pkg/transport/tls.go
  • pkg/transport/transport.go
  • pkg/transport/transport_test.go
  • pkg/ui/ui.go
  • pkg/upstream/circuitbreaker/breaker.go
  • pkg/upstream/command/builder.go
  • pkg/upstream/command/command.go
  • pkg/upstream/http/builder.go
  • pkg/upstream/http/client.go
  • pkg/upstream/http/refresh.go
  • pkg/upstream/http/ui_factory.go
  • pkg/upstream/http/withui/withui.go
  • pkg/upstream/refresher.go
  • pkg/upstream/registry.go
  • pkg/upstream/script/builder.go
  • pkg/upstream/script/script.go
  • pkg/upstream/script/script_test.go
  • pkg/upstream/upstream.go
  • tests/e2e/kraken_e2e_test.go
  • tests/e2e/remote_dev_e2e_test.go
  • tests/integration/operator_test.go

Comment thread pkg/operator/configgen/generator.go Outdated
…mically

Instead of renaming all config types from *Config to *Spec, the CRD generator
in internal/crdutil/typegen.go now derives CRD spec type names algorithmically
by replacing the "Config" suffix with "Spec" (e.g. NamingConfig -> NamingSpec).
Types without a "Config" suffix (CommandInputSchema, CommandSchemaProperty) are
used unchanged. All config type names stay as *Config throughout the codebase.

Co-authored-by: German Arutyunov <gaarutyunov@users.noreply.github.com>
@gaarutyunov

Copy link
Copy Markdown
Owner Author

@claude all integration and e2e tests are failing now

@claude

claude Bot commented Apr 17, 2026

Copy link
Copy Markdown

Claude finished @gaarutyunov's task in 10m 46s —— View job


Fixed failing integration and e2e tests

Root cause: The PR renamed CRD types in pkg/crd/v1alpha1 (removed prefixes: ProxyNamingSpecNamingSpec, MCPUpstreamCommandSpecCommandSpec, etc.) but the test files were not updated to match.

Fixed in commit b95f423:

Old name New name Files
ProxyNamingSpec NamingSpec operator_test.go, kraken_e2e_test.go, remote_dev_e2e_test.go
MCPUpstreamCommandSpec CommandSpec remote_dev_e2e_test.go
MCPUpstreamCommandInputSchema CommandInputSchema remote_dev_e2e_test.go
MCPUpstreamCommandSchemaProperty CommandSchemaProperty remote_dev_e2e_test.go

make check passes (lint + vet + unit tests + build).

Replace old prefixed type names with their renamed equivalents:
- ProxyNamingSpec → NamingSpec
- MCPUpstreamCommandSpec → CommandSpec
- MCPUpstreamCommandInputSchema → CommandInputSchema
- MCPUpstreamCommandSchemaProperty → CommandSchemaProperty

Co-authored-by: German Arutyunov <gaarutyunov@users.noreply.github.com>
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.

Remove renaming of CRDs

1 participant