Skip to content

Files

Latest commit

stevsmitSteven Smith
and
Steven Smith
Mar 13, 2025
16ee9b1 · Mar 13, 2025

History

History
90 lines (81 loc) · 4.06 KB

mirror-quay-api.adoc

File metadata and controls

90 lines (81 loc) · 4.06 KB

Using the API to mirror a repository

{productname} administrators can mirror external repositories by using the API.

Prerequisites
  • You have set FEATURE_REPO_MIRROR: true in your config.yaml file.

Procedure
  • Create a new repository mirror configuration by using the POST /api/v1/repository/{repository}/mirror endpoint:

    $ curl -X POST "https://<quay-server.example.com>/api/v1/repository/<namespace>/<repo>/mirror" \
        -H "Authorization: Bearer <access_token>" \
        -H "Content-Type: application/json" \
        -d '{
            "is_enabled": <is_enabled>,
            "external_reference": "<external_reference>",
            "external_registry_username": "<external_registry_username>",
            "external_registry_password": "<external_registry_password>",
            "sync_start_date": "<sync_start_date>",
            "sync_interval": <sync_interval>,
            "robot_username": "<robot_username>",
            "root_rule": {
                "rule": "<rule>",
                "rule_type": "<rule_type>"
            }
        }'
  • You can return information about the mirror configuration by using the GET /api/v1/repository/{repository}/mirror endpoint:

    $ curl -X GET "https://<quay-server.example.com>/api/v1/repository/<namespace>/<repo>/mirror" \
         -H "Authorization: Bearer <access_token>"
    Example output
    {"is_enabled": true, "mirror_type": "PULL", "external_reference": "https://quay.io/repository/argoproj/argocd", "external_registry_username": null, "external_registry_config": {}, "sync_interval": 86400, "sync_start_date": "2025-01-15T12:00:00Z", "sync_expiration_date": null, "sync_retries_remaining": 3, "sync_status": "NEVER_RUN", "root_rule": {"rule_kind": "tag_glob_csv", "rule_value": ["*.latest*"]}, "robot_username": "quayadmin+mirror_robot"}
  • You can use the POST /api/v1/repository/{repository}/mirror/sync-now endpoint to sync the repositories. For example:

    $ curl -X POST "https://<quay-server.example.com>/api/v1/repository/<namespace>/<repo>/mirror/sync-now" \
         -H "Authorization: Bearer <access_token>"

    This command does not return output in the CLI.

  • Alternatively, you can cancel the sync with the POST /api/v1/repository/{repository}/mirror/sync-cancel endpoint.For example:

    $ curl -X POST "https://<quay-server.example.com>/api/v1/repository/<namespace>/<repo>/mirror/sync-cancel" \

    This command does not return output in the CLI.

  • After creating a mirror configuration, you can make changes with the PUT /api/v1/repository/{repository}/mirror command. For example, you might choose to disable automatic synchronizations:

    $ curl -X PUT "https://<quay-server.example.com>/api/v1/repository/<namespace>/<repo>/mirror" \
        -H "Authorization: Bearer <access_token>" \
        -H "Content-Type: application/json" \
        -d '{
            "is_enabled": <false>, (1)
            "external_reference": "<external_reference>",
            "external_registry_username": "<external_registry_username>",
            "external_registry_password": "<external_registry_password>",
            "sync_start_date": "<sync_start_date>",
            "sync_interval": <sync_interval>,
            "robot_username": "<robot_username>",
            "root_rule": {
                "rule": "<rule>",
                "rule_type": "<rule_type>"
            }
        }'
    1. Disables automatic synchronization.