-
Notifications
You must be signed in to change notification settings - Fork 22
Add deb repository and remote pages #347
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
ggainey
merged 10 commits into
pulp:main
from
warisshaikh1:deb-repositories-and-remotes
Sep 18, 2026
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
f5b8470
Add deb repository and remote pages
warisshaikh1 9ca092a
Page through the distributions of a deb repository being deleted
warisshaikh1 76c8e1f
Default a deb sync to mirror: false, as pulp_deb does
warisshaikh1 41259d7
Turn an empty deb detail lookup into a not-found rejection
warisshaikh1 b024482
Collapse the deb repository breadcrumb branches
warisshaikh1 c8ca1da
Resolve the remote API through plugin2api
warisshaikh1 fbe42c1
Stop stubbing hasObjectPermission on deb distributions
warisshaikh1 0e65e51
Describe the deb remote and repository as interfaces
warisshaikh1 f62ee78
Add smoke tests for the deb pages
warisshaikh1 159ea94
Take the shared SyncModal for the deb sync action
warisshaikh1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| import { msg } from '@lingui/core/macro'; | ||
| import { Paths, formatPath } from 'src/paths'; | ||
| import { Action } from './action'; | ||
|
|
||
| export const debRemoteCreateAction = Action({ | ||
| title: msg`Add remote`, | ||
| onClick: (item, { navigate }) => | ||
| navigate(formatPath(Paths.deb.remote.edit, { name: '_' })), | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| import { msg, t } from '@lingui/core/macro'; | ||
| import { DebRemoteAPI } from 'src/api'; | ||
| import { DeleteRemoteModal } from 'src/components'; | ||
| import { | ||
| handleHttpError, | ||
| parsePulpIDFromURL, | ||
| taskAlert, | ||
| waitForTaskUrl, | ||
| } from 'src/utilities'; | ||
| import { Action } from './action'; | ||
|
|
||
| export const debRemoteDeleteAction = Action({ | ||
| title: msg`Delete`, | ||
| modal: ({ addAlert, listQuery, setState, state }) => | ||
| state.deleteModalOpen ? ( | ||
| <DeleteRemoteModal | ||
| closeAction={() => setState({ deleteModalOpen: null })} | ||
| deleteAction={() => | ||
| deleteRemote(state.deleteModalOpen, { addAlert, setState, listQuery }) | ||
| } | ||
| name={state.deleteModalOpen.name} | ||
| /> | ||
| ) : null, | ||
| onClick: ( | ||
| { name, id, pulp_href }: { name: string; id?: string; pulp_href?: string }, | ||
| { setState }, | ||
| ) => | ||
| setState({ | ||
| deleteModalOpen: { pulpId: id || parsePulpIDFromURL(pulp_href), name }, | ||
| }), | ||
| }); | ||
|
|
||
| function deleteRemote({ name, pulpId }, { addAlert, setState, listQuery }) { | ||
| return DebRemoteAPI.delete(pulpId) | ||
| .then(({ data }) => { | ||
| addAlert(taskAlert(data.task, t`Removal started for remote ${name}`)); | ||
| setState({ deleteModalOpen: null }); | ||
| return waitForTaskUrl(data.task); | ||
| }) | ||
| .then(() => listQuery()) | ||
| .catch( | ||
| handleHttpError(t`Failed to remove remote ${name}`, () => null, addAlert), | ||
| ); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| import { msg } from '@lingui/core/macro'; | ||
| import { Paths, formatPath } from 'src/paths'; | ||
| import { Action } from './action'; | ||
|
|
||
| export const debRemoteEditAction = Action({ | ||
| title: msg`Edit`, | ||
| onClick: ({ name }, { navigate }) => | ||
| navigate(formatPath(Paths.deb.remote.edit, { name })), | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| import { msg } from '@lingui/core/macro'; | ||
| import { Paths, formatPath } from 'src/paths'; | ||
| import { Action } from './action'; | ||
|
|
||
| export const debRepositoryCreateAction = Action({ | ||
| title: msg`Add repository`, | ||
| onClick: (item, { navigate }) => | ||
| navigate(formatPath(Paths.deb.repository.edit, { name: '_' })), | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,123 @@ | ||
| import { msg, t } from '@lingui/core/macro'; | ||
| import { DebDistributionAPI, DebRepositoryAPI } from 'src/api'; | ||
| import { DeleteRepositoryModal } from 'src/components'; | ||
| import { | ||
| handleHttpError, | ||
| parsePulpIDFromURL, | ||
| taskAlert, | ||
| waitForTaskUrl, | ||
| } from 'src/utilities'; | ||
| import { Action } from './action'; | ||
|
|
||
| export const debRepositoryDeleteAction = Action({ | ||
| title: msg`Delete`, | ||
| modal: ({ addAlert, listQuery, setState, state }) => | ||
| state.deleteModalOpen ? ( | ||
| <DeleteRepositoryModal | ||
| closeAction={() => setState({ deleteModalOpen: null })} | ||
| deleteAction={() => | ||
| deleteRepository(state.deleteModalOpen, { | ||
| addAlert, | ||
| listQuery, | ||
| setState, | ||
| }) | ||
| } | ||
| name={state.deleteModalOpen.name} | ||
| /> | ||
| ) : null, | ||
| onClick: ( | ||
| { name, id, pulp_href }: { name: string; id?: string; pulp_href?: string }, | ||
| { setState }, | ||
| ) => | ||
| setState({ | ||
| deleteModalOpen: { | ||
| pulpId: id || parsePulpIDFromURL(pulp_href), | ||
| name, | ||
| pulp_href, | ||
| }, | ||
| }), | ||
| }); | ||
|
|
||
| const DISTRIBUTION_PAGE_SIZE = 100; | ||
|
|
||
| // A repository can be serving more distributions than a single page holds, and | ||
| // any the lookup misses are left pointing at a repository that no longer exists. | ||
| async function listDistributions(repository) { | ||
| const distributions = []; | ||
| let page = 1; | ||
| let count = Infinity; | ||
|
|
||
| while (distributions.length < count) { | ||
| const { data } = await DebDistributionAPI.list({ | ||
| repository, | ||
| page, | ||
| page_size: DISTRIBUTION_PAGE_SIZE, | ||
| }); | ||
|
|
||
| // Also stops the loop should count ever disagree with what the pages return. | ||
| if (!data.results?.length) { | ||
| break; | ||
| } | ||
|
|
||
| distributions.push(...data.results); | ||
| count = data.count; | ||
| page++; | ||
| } | ||
|
|
||
| return distributions; | ||
| } | ||
|
|
||
| async function deleteRepository( | ||
| { name, pulp_href, pulpId }, | ||
| { addAlert, setState, listQuery }, | ||
| ) { | ||
| const distributionsToDelete = await listDistributions(pulp_href).catch( | ||
| (e) => { | ||
| handleHttpError( | ||
| t`Failed to list distributions, removing only the repository.`, | ||
| () => null, | ||
| addAlert, | ||
| )(e); | ||
| return []; | ||
| }, | ||
| ); | ||
|
|
||
| const deleteRepo = DebRepositoryAPI.delete(pulpId) | ||
| .then(({ data }) => { | ||
| addAlert(taskAlert(data.task, t`Removal started for repository ${name}`)); | ||
| return waitForTaskUrl(data.task); | ||
| }) | ||
| .catch( | ||
| handleHttpError( | ||
| t`Failed to remove repository ${name}`, | ||
| () => setState({ deleteModalOpen: null }), | ||
| addAlert, | ||
| ), | ||
| ); | ||
|
|
||
| const deleteDistribution = ({ name, pulp_href }) => { | ||
| const distribution_id = parsePulpIDFromURL(pulp_href); | ||
| return DebDistributionAPI.delete(distribution_id) | ||
| .then(({ data }) => { | ||
| addAlert( | ||
| taskAlert(data.task, t`Removal started for distribution ${name}`), | ||
| ); | ||
| return waitForTaskUrl(data.task); | ||
| }) | ||
| .catch( | ||
| handleHttpError( | ||
| t`Failed to remove distribution ${name}`, | ||
| () => null, | ||
| addAlert, | ||
| ), | ||
| ); | ||
| }; | ||
|
|
||
| return Promise.all([ | ||
| deleteRepo, | ||
| ...distributionsToDelete.map(deleteDistribution), | ||
| ]).then(() => { | ||
| setState({ deleteModalOpen: null }); | ||
| listQuery(); | ||
| }); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| import { msg } from '@lingui/core/macro'; | ||
| import { Paths, formatPath } from 'src/paths'; | ||
| import { Action } from './action'; | ||
|
|
||
| export const debRepositoryEditAction = Action({ | ||
| title: msg`Edit`, | ||
| onClick: ({ name }, { navigate }) => | ||
| navigate(formatPath(Paths.deb.repository.edit, { name })), | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| import { msg, t } from '@lingui/core/macro'; | ||
| import { DebRepositoryAPI } from 'src/api'; | ||
| import { SyncModal } from 'src/components'; | ||
| import { handleHttpError, parsePulpIDFromURL, taskAlert } from 'src/utilities'; | ||
| import { Action } from './action'; | ||
|
|
||
| // pulp_deb's own API default for a sync. ansible and file offer to mirror | ||
| // instead, and this deliberately does not follow them: mirroring deletes local | ||
| // content the remote no longer has, so it is the direction to opt into rather | ||
| // than out of. | ||
| const MIRROR_BY_DEFAULT = false; | ||
|
|
||
| export const debRepositorySyncAction = Action({ | ||
| title: msg`Sync`, | ||
| modal: ({ addAlert, query, setState, state }) => | ||
| state.syncModalOpen ? ( | ||
| <SyncModal | ||
| closeAction={() => setState({ syncModalOpen: null })} | ||
| defaultMirror={MIRROR_BY_DEFAULT} | ||
| syncAction={(syncParams) => | ||
| syncRepository(state.syncModalOpen, { addAlert, query }, syncParams) | ||
| } | ||
| name={state.syncModalOpen.name} | ||
| /> | ||
| ) : null, | ||
| onClick: ({ name, pulp_href }, { setState }) => | ||
| setState({ | ||
| syncModalOpen: { name, pulp_href }, | ||
| }), | ||
| visible: (_item, { hasPermission }) => | ||
| hasPermission('deb.change_aptrepository'), | ||
| disabled: ({ remote, last_sync_task }) => { | ||
| if (!remote) { | ||
| return t`There are no remotes associated with this repository.`; | ||
| } | ||
|
|
||
| if ( | ||
| last_sync_task && | ||
| ['running', 'waiting'].includes(last_sync_task.state) | ||
| ) { | ||
| return t`Sync task is already queued.`; | ||
| } | ||
| }, | ||
| }); | ||
|
|
||
| function syncRepository({ name, pulp_href }, { addAlert, query }, syncParams) { | ||
| const pulpId = parsePulpIDFromURL(pulp_href); | ||
| return DebRepositoryAPI.sync( | ||
| pulpId, | ||
| syncParams || { mirror: MIRROR_BY_DEFAULT }, | ||
| ) | ||
| .then(({ data }) => { | ||
| addAlert(taskAlert(data.task, t`Sync started for repository "${name}".`)); | ||
|
|
||
| query(); | ||
| }) | ||
| .catch( | ||
| handleHttpError( | ||
| t`Failed to sync repository "${name}"`, | ||
| () => null, | ||
| addAlert, | ||
| ), | ||
| ); | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| import { PulpAPI } from './pulp'; | ||
|
|
||
| const base = new PulpAPI(); | ||
|
|
||
| export const DebDistributionAPI = { | ||
| create: (data) => base.http.post(`distributions/deb/apt/`, data), | ||
|
|
||
| delete: (id) => base.http.delete(`distributions/deb/apt/${id}/`), | ||
|
|
||
| list: (params?) => base.list(`distributions/deb/apt/`, params), | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| import { PulpAPI } from './pulp'; | ||
|
|
||
| export interface DebRemoteType { | ||
| architectures: string; | ||
| ca_cert: string; | ||
| client_cert: string; | ||
| components: string; | ||
| distributions: string; | ||
| download_concurrency: number; | ||
| gpgkey: string; | ||
| ignore_missing_package_indices?: boolean; | ||
| name: string; | ||
| proxy_url: string; | ||
| pulp_href?: string; | ||
| rate_limit: number; | ||
| sync_installer?: boolean; | ||
| sync_sources?: boolean; | ||
| sync_udebs?: boolean; | ||
| tls_validation: boolean; | ||
| url: string; | ||
|
|
||
| // connect_timeout | ||
| // headers | ||
| // max_retries | ||
| // policy | ||
| // prn | ||
| // pulp_created | ||
| // pulp_labels | ||
| // pulp_last_updated | ||
| // sock_connect_timeout | ||
| // sock_read_timeout | ||
| // total_timeout | ||
|
|
||
| hidden_fields: { | ||
| is_set: boolean; | ||
| name: string; | ||
| }[]; | ||
|
|
||
| my_permissions?: string[]; | ||
| } | ||
|
|
||
| // as in file-remote | ||
| function smartUpdate(remote: DebRemoteType, unmodifiedRemote: DebRemoteType) { | ||
| for (const field of Object.keys(remote)) { | ||
| if (remote[field] === '') { | ||
| remote[field] = null; | ||
| } | ||
|
|
||
| // API returns headers:null but doesn't accept it .. and we don't edit headers | ||
| if (remote[field] === null && unmodifiedRemote[field] === null) { | ||
| delete remote[field]; | ||
| } | ||
| } | ||
|
|
||
| return remote; | ||
| } | ||
|
|
||
| const base = new PulpAPI(); | ||
|
|
||
| export const DebRemoteAPI = { | ||
| create: (data) => base.http.post(`remotes/deb/apt/`, data), | ||
|
|
||
| delete: (id) => base.http.delete(`remotes/deb/apt/${id}/`), | ||
|
|
||
| get: (id) => base.http.get(`remotes/deb/apt/${id}/`), | ||
|
|
||
| list: (params?) => base.list(`remotes/deb/apt/`, params), | ||
|
|
||
| smartUpdate: (id, newValue: DebRemoteType, oldValue: DebRemoteType) => | ||
| base.http.put(`remotes/deb/apt/${id}/`, smartUpdate(newValue, oldValue)), | ||
| }; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.