Commit ecbc5cef authored by Alex Ives's avatar Alex Ives

Add graphql Api for Snippet Replication

- Add finder for snippet repostiory registry
- Update documentation for graphql

Relates to https://gitlab.com/gitlab-org/gitlab/issues/263792
parent eccdfbdd
......@@ -8291,6 +8291,37 @@ type GeoNode {
"""
selectiveSyncType: String
"""
Find snippet repository registries on this Geo node. Available only when
feature flag `geo_snippet_repository_replication` is enabled
"""
snippetRepositoryRegistries(
"""
Returns the elements in the list that come after the specified cursor.
"""
after: String
"""
Returns the elements in the list that come before the specified cursor.
"""
before: String
"""
Returns the first _n_ elements from the list.
"""
first: Int
"""
Filters registries by their ID
"""
ids: [ID!]
"""
Returns the last _n_ elements from the list.
"""
last: Int
): SnippetRepositoryRegistryConnection
"""
Indicates if this secondary node will replicate blobs in Object Storage
"""
......@@ -20376,6 +20407,86 @@ type SnippetPermissions {
updateSnippet: Boolean!
}
"""
Represents the Geo sync and verification state of a snippet repository
"""
type SnippetRepositoryRegistry {
"""
Timestamp when the SnippetRepositoryRegistry was created
"""
createdAt: Time
"""
ID of the SnippetRepositoryRegistry
"""
id: ID!
"""
Error message during sync of the SnippetRepositoryRegistry
"""
lastSyncFailure: String
"""
Timestamp of the most recent successful sync of the SnippetRepositoryRegistry
"""
lastSyncedAt: Time
"""
Timestamp after which the SnippetRepositoryRegistry should be resynced
"""
retryAt: Time
"""
Number of consecutive failed sync attempts of the SnippetRepositoryRegistry
"""
retryCount: Int
"""
ID of the Snippet Repository
"""
snippetRepositoryId: ID!
"""
Sync state of the SnippetRepositoryRegistry
"""
state: RegistryState
}
"""
The connection type for SnippetRepositoryRegistry.
"""
type SnippetRepositoryRegistryConnection {
"""
A list of edges.
"""
edges: [SnippetRepositoryRegistryEdge]
"""
A list of nodes.
"""
nodes: [SnippetRepositoryRegistry]
"""
Information to aid in pagination.
"""
pageInfo: PageInfo!
}
"""
An edge in a connection.
"""
type SnippetRepositoryRegistryEdge {
"""
A cursor for use in pagination.
"""
cursor: String!
"""
The item at the end of the edge.
"""
node: SnippetRepositoryRegistry
}
"""
Common sort values
"""
......
......@@ -1362,6 +1362,7 @@ Autogenerated return type of EpicTreeReorder.
| `selectiveSyncNamespaces` | NamespaceConnection | The namespaces that should be synced, if `selective_sync_type` == `namespaces` |
| `selectiveSyncShards` | String! => Array | The repository storages whose projects should be synced, if `selective_sync_type` == `shards` |
| `selectiveSyncType` | String | Indicates if syncing is limited to only specific groups, or shards |
| `snippetRepositoryRegistries` | SnippetRepositoryRegistryConnection | Find snippet repository registries on this Geo node. Available only when feature flag `geo_snippet_repository_replication` is enabled |
| `syncObjectStorage` | Boolean | Indicates if this secondary node will replicate blobs in Object Storage |
| `terraformStateVersionRegistries` | TerraformStateVersionRegistryConnection | Find terraform state version registries on this Geo node |
| `url` | String | The user-facing URL for this Geo node |
......@@ -2969,6 +2970,21 @@ Represents how the blob content should be displayed.
| `reportSnippet` | Boolean! | Indicates the user can perform `report_snippet` on this resource |
| `updateSnippet` | Boolean! | Indicates the user can perform `update_snippet` on this resource |
### SnippetRepositoryRegistry
Represents the Geo sync and verification state of a snippet repository.
| Field | Type | Description |
| ----- | ---- | ----------- |
| `createdAt` | Time | Timestamp when the SnippetRepositoryRegistry was created |
| `id` | ID! | ID of the SnippetRepositoryRegistry |
| `lastSyncFailure` | String | Error message during sync of the SnippetRepositoryRegistry |
| `lastSyncedAt` | Time | Timestamp of the most recent successful sync of the SnippetRepositoryRegistry |
| `retryAt` | Time | Timestamp after which the SnippetRepositoryRegistry should be resynced |
| `retryCount` | Int | Number of consecutive failed sync attempts of the SnippetRepositoryRegistry |
| `snippetRepositoryId` | ID! | ID of the Snippet Repository |
| `state` | RegistryState | Sync state of the SnippetRepositoryRegistry |
### StatusAction
| Field | Type | Description |
......
# frozen_string_literal: true
module Geo
class SnippetRepositoryRegistryFinder
include FrameworkRegistryFinder
end
end
# frozen_string_literal: true
module Resolvers
module Geo
class SnippetRepositoryRegistriesResolver < BaseResolver
type ::Types::Geo::GeoNodeType.connection_type, null: true
include RegistriesResolver
end
end
end
......@@ -30,6 +30,11 @@ module Types
null: true,
resolver: ::Resolvers::Geo::PackageFileRegistriesResolver,
description: 'Package file registries of the GeoNode'
field :snippet_repository_registries, ::Types::Geo::SnippetRepositoryRegistryType.connection_type,
null: true,
resolver: ::Resolvers::Geo::SnippetRepositoryRegistriesResolver,
description: 'Find snippet repository registries on this Geo node',
feature_flag: :geo_snippet_repository_replication
field :terraform_state_version_registries, ::Types::Geo::TerraformStateVersionRegistryType.connection_type,
null: true,
resolver: ::Resolvers::Geo::TerraformStateVersionRegistriesResolver,
......
# frozen_string_literal: true
module Types
module Geo
# rubocop:disable Graphql/AuthorizeTypes because it is included
class SnippetRepositoryRegistryType < BaseObject
include ::Types::Geo::RegistryType
graphql_name 'SnippetRepositoryRegistry'
description 'Represents the Geo sync and verification state of a snippet repository'
field :snippet_repository_id, GraphQL::ID_TYPE, null: false, description: 'ID of the Snippet Repository'
end
end
end
---
title: Add graphql for snippet registries
merge_request: 47448
author:
type: added
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Geo::SnippetRepositoryRegistryFinder do
it_behaves_like 'a framework registry finder', :geo_snippet_repository_registry
end
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Resolvers::Geo::SnippetRepositoryRegistriesResolver do
it_behaves_like 'a Geo registries resolver', :geo_snippet_repository_registry
end
......@@ -12,7 +12,8 @@ RSpec.describe GitlabSchema.types['GeoNode'] do
container_repositories_max_capacity sync_object_storage
selective_sync_type selective_sync_shards selective_sync_namespaces
minimum_reverification_interval merge_request_diff_registries
package_file_registries terraform_state_version_registries
package_file_registries snippet_repository_registries
terraform_state_version_registries
]
expect(described_class).to have_graphql_fields(*expected_fields)
......
......@@ -17,6 +17,13 @@ RSpec.describe 'Gets registries' do
registry_foreign_key_field_name: 'packageFileId'
}
it_behaves_like 'gets registries for', {
field_name: 'snippetRepositoryRegistries',
registry_class_name: 'SnippetRepositoryRegistry',
registry_factory: :geo_snippet_repository_registry,
registry_foreign_key_field_name: 'snippetRepositoryId'
}
it_behaves_like 'gets registries for', {
field_name: 'terraformStateVersionRegistries',
registry_class_name: 'TerraformStateVersionRegistry',
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment