Skip to content

Conversation

@celdrake
Copy link
Collaborator

@celdrake celdrake commented Jan 27, 2026

The OpenAPI schema now has 3 main types: Git, Http, Oci.
Before it was mixing the repository type with the credential settings type.

Related backend changes: flightctl/flightctl#2412

Summary by CodeRabbit

  • Refactor
    • Consolidated and simplified repository spec types (Git/HTTP/OCI) for more consistent validation and configuration.
    • Updated repository-related UI flows (create/import wizards, selectors, device/image build forms) to align with the new type system.
    • Improved repository privacy/credential detection logic for more reliable UI behavior.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Jan 27, 2026

Walkthrough

Refactors repository spec types: removes GenericRepoSpec and SshRepoSpec, introduces GitRepoSpec, renames enum members (e.g., GIT → RepoSpecTypeRepoSpecTypeGit), switches some discriminators to string literals, and updates UI components and utilities to use the new types and enum values.

Changes

Cohort / File(s) Summary
Type Model Consolidation
libs/types/models/RepoSpecType.ts, libs/types/models/GenericRepoSpec.ts, libs/types/models/GitRepoSpec.ts, libs/types/models/SshRepoSpec.ts
Enum members renamed (GITRepoSpecTypeGit, HTTPRepoSpecTypeHttp, OCIRepoSpecTypeOci); GenericRepoSpec and SshRepoSpec removed; new GitRepoSpec added
Repository Spec Type Definitions
libs/types/models/HttpRepoSpec.ts, libs/types/models/OciRepoSpec.ts, libs/types/models/RepositorySpec.ts
Discriminators updated to use literals/explicit types; HttpRepoSpec.httpConfig made optional; RepositorySpec union changed to `(GitRepoSpec
Type Exports
libs/types/index.ts
Removed exports for GenericRepoSpec and SshRepoSpec; added export for GitRepoSpec
Repository Utilities (large)
libs/ui-components/src/components/Repository/CreateRepository/utils.ts
Significant refactor: added isGitRepoSpec and hasCredentialsSettings; removed SSH-specific types; introduced helpers for http/git/oci patches and mapping (e.g., httpConfigToFormValues, get*RepositoryPatches, getInitValues, getRepository); updates to schema/validation and discriminant usage
Repository UI Components
libs/ui-components/src/components/Repository/CreateRepository/CreateRepositoryForm.tsx, libs/ui-components/src/components/Repository/RepositoryDetails/RepositoryDetails.tsx, libs/ui-components/src/components/Repository/RepositoryDetails/RepositoryGeneralDetailsCard.tsx
Updated enum usages to RepoSpecTypeRepoSpecType*; replaced per-type privacy checks with hasCredentialsSettings; adjusted conditional rendering and imports to new types
Wizard & Selector Components
libs/ui-components/src/components/Device/.../ConfigWithRepositoryTemplateForm.tsx, .../ConfigurationTemplates.tsx, libs/ui-components/src/components/Fleet/ImportFleetWizard/..., libs/ui-components/src/components/ImageBuilds/.../SourceImageStep.tsx, OutputImageStep.tsx
Replaced enum references (RepoSpecType.GIT/HTTP/OCIRepoSpecType.RepoSpecTypeGit/Http/Oci) and swapped GenericRepoSpec imports for GitRepoSpec where applicable
Oci Registries Context
libs/ui-components/src/components/ImageBuilds/OciRegistriesContext.tsx
Updated endpoint/type usage to new RepoSpecType variant for OCI
Fleet Import Step
libs/ui-components/src/components/Fleet/ImportFleetWizard/steps/RepositoryStep.tsx
Replaced GenericRepoSpec with GitRepoSpec in imports and casts
Cypress Fixtures
libs/cypress/fixtures/repositories/initialRepositories.ts
Test fixture enum value updated from RepoSpecType.GIT to RepoSpecType.RepoSpecTypeGit
Minor type/index sync
libs/types/index.ts (other edits implied)
Export list updated to reflect removed/added model types

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: updating repository spec types from a mixed type/credential system to three distinct types (Git, Http, Oci).
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 docstrings

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.

@celdrake celdrake changed the title EDM-3068 update repo spec types EDM-3209 EDM-3068 update repo spec types Jan 27, 2026
@celdrake celdrake changed the title EDM-3209 EDM-3068 update repo spec types EDM-3209 EDM-3069 update repo spec types Jan 27, 2026
Copy link

@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.

Actionable comments posted: 2

🤖 Fix all issues with AI agents
In `@libs/ui-components/src/components/Repository/CreateRepository/utils.ts`:
- Around line 420-440: In httpConfigToFormValues, ca.crt is decoded with atob
but tls.crt and tls.key are returned raw; update the mTlsAuth fields inside
httpConfigToFormValues to base64-decode httpConfig['tls.crt'] and
httpConfig['tls.key'] (use atob like caCrt) so tlsCrt and tlsKey contain decoded
strings, while preserving the existing use checks and other fields.
- Around line 566-581: The SSH private key is being assigned raw from
gitRepoSpec.sshConfig.sshPrivateKey but elsewhere (in getRepository()) keys are
base64-encoded with btoa(); update the branch handling
RepoSpecType.RepoSpecTypeGit so that when gitRepoSpec.sshConfig exists you
base64-decode the stored sshPrivateKey before assigning it to
formValues.sshConfig.sshPrivateKey (use the corresponding decode function used
for btoa/encoding in your environment, e.g., atob in the browser), keeping other
fields (privateKeyPassphrase, skipServerVerification) unchanged.
🧹 Nitpick comments (1)
libs/ui-components/src/components/Repository/CreateRepository/utils.ts (1)

805-877: Consider extracting shared httpConfig building logic.

The HTTP config construction logic (lines 814-839 for HTTP repos, lines 843-864 for Git repos) is largely duplicated. Consider extracting a shared helper to reduce duplication and ensure consistency.

♻️ Suggested helper extraction
const buildHttpConfig = (httpConfigValues: RepositoryFormValues['httpConfig']): HttpConfig | undefined => {
  if (!httpConfigValues) return undefined;
  
  const config: HttpConfig = {
    skipServerVerification: httpConfigValues.skipServerVerification,
  };
  
  const caCrt = httpConfigValues.caCrt;
  if (caCrt && !httpConfigValues.skipServerVerification) {
    config['ca.crt'] = btoa(caCrt);
  }
  
  if (httpConfigValues.basicAuth?.use) {
    config.username = httpConfigValues.basicAuth.username;
    config.password = httpConfigValues.basicAuth.password;
  }
  
  if (httpConfigValues.mTlsAuth?.use) {
    const tlsCrt = httpConfigValues.mTlsAuth.tlsCrt;
    if (tlsCrt) config['tls.crt'] = btoa(tlsCrt);
    const tlsKey = httpConfigValues.mTlsAuth.tlsKey;
    if (tlsKey) config['tls.key'] = btoa(tlsKey);
  }
  
  return config;
};

Then use it in both HTTP and Git spec creation paths.

@celdrake celdrake force-pushed the EDM-3068-update-repo-spec-types branch from 120eedf to 15db5ff Compare January 28, 2026 18:53
@celdrake
Copy link
Collaborator Author

Waiting for the backend part to merge first, there are some CI issues.

@celdrake celdrake merged commit 99bfe53 into flightctl:main Jan 29, 2026
6 checks passed
@celdrake celdrake deleted the EDM-3068-update-repo-spec-types branch January 29, 2026 07:16
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.

2 participants