Component usage details in catalog resource view
Summary
A detailed view of a single CI component that shows exactly which projects use which versions, so you can target upgrades and notify the right maintainers when deprecating or fixing issues.
Implementation
Add a GraphQL API (CiCatalogResource.componentUsages) that shows which projects use components from a CI Catalog resource, including version and last used date information. This enables the Component Usage Details page in the catalog resource view.
Scope
- GraphQL
componentUsagesconnection field onCiCatalogResourceType(EE) ProjectUsageTypeandComponentUsageDetailTypeGraphQL types- Resolver with authorization (maintainer+ on catalog resource project), license check, and
ci_component_analyticsfeature flag outdatedfield indicating if a project uses a version older than the latest- Model scope for fetching usages with eager-loaded associations
Authorization
- Only catalog resource project maintainers+ can access this data
- Only projects visible to the current user are returned
- Gated behind
ci_component_analyticsfeature flag and Ultimate license
Merge Requests
- !222665 (merged) — Add semver fields to
CiCatalogResourceVersion(merged) - !224045 (merged) — Add
for_catalog_resource_with_component_versionsscope (merged) - !226460 (merged) — Add
componentUsagesGraphQL types, feature flag, and connection type (in review) - !222663 (merged) — Add
componentUsagesresolver, integration spec, and N+1 test (in progress, depends on !226460 (merged))
Note on version tracking
The last_usages table stores a component_id which points to a component record tied to a specific version via version_id. Each published version creates new component records, so usage.component.version correctly returns the version that was actually used, not the latest version.
Original issue description
Provide a detailed view on the components and components projects usage For each component projects (Catalog item) users can see
- Used version per each component
- Projects URL
- The view will be organized by version, where the older version at the top
- Separation between projects that are using latest versions vs older versions
- Notify project maintainer is the ability to ping project maintainers to make sure they are aware when a new verison is available (could be out of scope for this MVC)
Implementation Details
Version Tracking in LastUsage Table - 5+
Version tracking - 30 are on v1.0.2, 15 on v1.5.1, 5 on v2.0.0
Note: The last_usages table doesn't store which version was used and the gql version field currently resolves from the component's CURRENT version_id, not the version that was actually included. Additional notes:
- Add
version_idcolumn tocatalog_resource_component_last_usages table - Update
Ci::Components::Usages::CreateServicewith this
Query for projects using component - 4 (performance)
Usage tracking - like Component X is used by these 50 projects
Currently we have Project.componentUsages but NOT Component.usedByProjects or CatalogResource.projectUsages <- made these up as a suggestion
- Add new field to
ComponentTypeorCatalogResourceTypeand create new resolver - Permissions: I think we can reuse existing logic from
ProjectUsageResolverhere
Projects with outdated versions - 2
Figure out which projects are using outdated versions - These 30 projects need to upgrade
- We probably need some work to separate "up-to-date" projects from "outdated" projects
🤔 but we already have a boolean
Authorization restrictions
Persons -
- Who can view this project? only components project maintainer+ (in this view, only
components/dockermaintainer+) - This view should not be accessible for developer-
- The maintainer can only see the projects that are visible for their role (e.g. if I am a component project maintainer but a private project is using my components I wont be able to see it in this view
Open question? Can we make sure this view works across all deployment types (Self managed, Dedicated, .com)
