Skip to content
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

Fixes #37989 - More APIs and remote repository mirroring action #11207

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

sjha4
Copy link
Member

@sjha4 sjha4 commented Nov 7, 2024

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:

remote1 = Katello::FlatpakRemote.new(name: "Redhat flatpak", 
url: "https://flatpaks.redhat.io/rhel",
organization_id: 1,
seeded: true,
username: get from [token.redhat.com ](https://access.redhat.com/terms-based-registry/token/)
token: get from [token.redhat.com ](https://access.redhat.com/terms-based-registry/token/)
)
remote1.save!

remote2 = Katello::FlatpakRemote.new(name: "Fedora flatpak", url: "https://registry.fedoraproject.org/",organization_id: 1,seeded: true)
remote2.save!

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.

@sjha4 sjha4 force-pushed the import_remote_repositories branch 4 times, most recently from 3f2cdfa to 03254ae Compare November 12, 2024 20:22
@sjha4 sjha4 changed the title [WIP] Fixes #37989 - More APIs and remote repository mirroring action Fixes #37989 - More APIs and remote repository mirroring action Nov 12, 2024
Copy link
Member

@ianballou ianballou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only remaining things I see not working are the manifests=false param and mirroring via the API.

@sjha4
Copy link
Member Author

sjha4 commented Nov 14, 2024

The 2 issues should now be resolved. Ended up removing model perms for remote_repositories and relying completely on remote permissions to avoid having multiple permissions for the related objects. Mirror will need edit_product and view_remote perms.

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