Fixes #37989 - More APIs and remote repository mirroring action #11207
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.
What are the changes introduced in this pull request?
Add API endpoints for remote repositories, manifests and introduce the remote repository mirroring action which mirrors the remote repository into a katello repository.
Considerations taken when implementing this change?
Added a registry_url on remote object cause remote url != registry URL.
What are the testing steps for this pull request?
Run bundle exec rails db:migrate to migrate db
Run following to create 2 remotes, one pointing to redhat flatpak index and another at fedora flatpak index:
Run the below actions to scan the 2 indexes and you should have 2 successful actions in your foreman tasks.
#Sync redhat flatpak:
redhat_remote = Katello::FlatpakRemote.find_by(name: "Redhat flatpak")
ForemanTasks.sync_task(::Actions::Katello::Flatpak::ScanRemote, redhat_remote)
#Sync fedora flatpak:
fedora_remote = Katello::FlatpakRemote.find_by(name: "Fedora flatpak")
ForemanTasks.sync_task(::Actions::Katello::Flatpak::ScanRemote, fedora_remote)
API:
Remotes:
https://centos9-katello-devel.sajha.example.com/katello/api/v2/flatpak_remotes/
Remote repository:
https://centos9-katello-devel.sajha.example.com/katello/api/v2/flatpak_remotes/5/flatpak_remote_repositories/
Remote repository with manifests:
https://centos9-katello-devel.sajha.example.com/katello/api/v2/flatpak_remotes/5/flatpak_remote_repositories/1059?manifests=true
Now you can mirror the repo into Katello by providing remote repo id and a product id:
To mirror a remote repository:
Console:
product = Katello::Product.custom.last
firefox_repository = Katello::FlatpakRemoteRepository.find_by(name: "rhel9/firefox-flatpak")
ForemanTasks.sync_task(::Actions::Katello::Flatpak::MirrorRemoteRepository, firefox_repository, product)
Now sync the new repo and verify that everything looks sane.
Testing permissions:
All of the above steps should work for the admin user and the console admin.
If you create a new user role, they'll need flatpak_remote_permissions : view_flatpak_remotes, create_flatpak_remotes and edit_flatpak_remotes to do actions on remotes.
To mirror remote repos, i.e, create katello repos from remote repo, you need to have the edit_product permission.