refactor(api,ssh,gateway,ui): replace edition booleans with SHELLHUB_EDITION enum#6666
refactor(api,ssh,gateway,ui): replace edition booleans with SHELLHUB_EDITION enum#6666luizhf42 wants to merge 2 commits into
Conversation
|
Claude finished @luizhf42's task in 10m 41s —— View job Code Review CompleteReviewed 84 files across code quality, security, testing, language patterns, and architecture. 1 inline issue posted (1 medium). This is a clean, well-executed refactor. The five reviewers independently confirmed the core risk — the
Additional notes
If you've addressed the feedback and want a new review, tag |
35c7cfe to
b4ad36a
Compare
|
/review |
|
Claude finished @otavio's task in 9m 9s —— View job Code Review CompleteReviewed 84 files across code quality, security, testing, language patterns, and architecture. 1 inline issue posted (1 medium), plus 1 cross-repo note below. Second pass on this refactor. The Inline finding
Additional notes
If you've addressed the feedback and want a new review, tag |
Replace `enterprise: boolean` + `cloud: boolean` in `ClientConfig`
with a single `edition: Edition` field. Add `isCommunity()`,
`isEnterprise()`, `isCloud()`, and `isEnterpriseOrCloud()` predicates
to `env.ts`, matching the Go vocabulary.
Delete `utils/features.ts` (`isPremiumFeature`/`hasMfaSupport`);
callers use `isEnterpriseOrCloud()` directly. Fix `Login.tsx` SSO
gate: was `isEnterprise()` (exact), now `isEnterpriseOrCloud()` so
SAML works on cloud too.
Add `src/__mocks__/env.ts` manual mock and a global `vi.mock("@/env")`
in `setup.ts` so test files no longer repeat a 10-line factory.
b4ad36a to
78e0a06
Compare
|
/review |
|
Re: the cross-repo note on |
|
/review |
|
Claude finished @otavio's task in 9m 16s —— View job Code Review CompleteReviewed 84 files across code quality, security, testing, language patterns, and architecture — no new issues found. The code looks good as-is. The two items from the prior rounds — gateway edition normalization (
A couple of non-blocking notes already raised in prior rounds still stand (not re-reported inline): If you push additional changes and want a new review, tag |

What
Replaces the
SHELLHUB_ENTERPRISEandSHELLHUB_CLOUDboolean env vars with a singleSHELLHUB_EDITION=community|enterprise|cloudenum, making the previously illegal fourth state (cloud=true, enterprise=false) unrepresentable by design.Why
Two booleans encoded three editions but permitted a fourth, invalid combination guarded only by a runtime check in
bin/docker-compose.IsEnterprise()meant "at least enterprise" (true on cloud too), and the samecloud || enterpriseexpression appeared under five different local names in the frontend. The build layer already used an enum (ARG EDITION=community|enterprise), so build-time and runtime representations were inconsistent.Closes shellhub-io/team#156
Changes
pkg/envs: addedEditiontype (Community,Enterprise,Cloud) andCurrentEdition()that readsSHELLHUB_EDITION, normalizes (trim + lowercase), defaults to community, and hard-fails on invalid values. Reimplemented predicates:IsCommunity(),IsEnterprise()(now exact),IsCloud()(now exact),IsEnterpriseOrCloud()(new). Addedenvstest.SetEdition()andenvstest.SetRawEdition()helpers that replace all call-order-coupled mock stubs across 35+ test blocks.gateway/config.go: resolvesSHELLHUB_EDITIONonce and derivesEnableEnterprise/EnableCloudbools for the nginx template, which stays unchanged.ssh/session: license+firewall check uses exactIsEnterprise(), asciinema saving usesIsEnterpriseOrCloud().bin/docker-compose: resolvesSHELLHUB_EDITIONwith validation (invalid value = hard exit), selects compose overlays and env files by edition. Deletes thecloud-requires-enterpriseguard..env,.env.enterprise,docker-compose*.yml: two booleans collapsed toSHELLHUB_EDITION.ui/apps/console/src/env.ts:ClientConfig.{enterprise, cloud}replaced withedition: Edition. Same four predicates as Go:isCommunity(),isEnterprise(),isCloud(),isEnterpriseOrCloud().ui/apps/console/src/__mocks__/env.ts+test/setup.ts: manual mock withvi.fn()-backedgetConfig, globalvi.mock("@/env")in setup. Eliminates the 10-linevi.mockfactory repeated in 29 test files.ui/apps/console/src/utils/features.ts: deleted.isPremiumFeature()andhasMfaSupport()were thin wrappers; callers now importisEnterpriseOrCloud()directly.isEnterprise()(exact match, excluded cloud) gated SAML SSO — changed toisEnterpriseOrCloud()so SAML works on cloud too.configuring.mdxandupgrading.mdxto referenceSHELLHUB_EDITION.Testing
pkg/envstests cover normalization (trim, lowercase, invalid → error, empty → community) and all four predicates across all three editions.tests/compose/wrapper.batsandtests/compose/with_cloud.batsupdated and passing.