Commit d1e90512 authored by Alex Ives's avatar Alex Ives

Add graphql support for tf version replication

Relates to https://gitlab.com/gitlab-org/gitlab/issues/237928
parent 3e88f5ea
......@@ -6508,6 +6508,37 @@ type GeoNode {
last: Int
): TerraformStateRegistryConnection
"""
Find terraform state version registries on this Geo node. Available only when
feature flag `geo_terraform_state_version_replication` is enabled
"""
terraformStateVersionRegistries(
"""
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
): TerraformStateVersionRegistryConnection
"""
The user-facing URL for this Geo node
"""
......@@ -16898,6 +16929,86 @@ type TerraformStateRegistryEdge {
node: TerraformStateRegistry
}
"""
Represents the Geo sync and verification state of a terraform state version
"""
type TerraformStateVersionRegistry {
"""
Timestamp when the TerraformStateVersionRegistry was created
"""
createdAt: Time
"""
ID of the TerraformStateVersionRegistry
"""
id: ID!
"""
Error message during sync of the TerraformStateVersionRegistry
"""
lastSyncFailure: String
"""
Timestamp of the most recent successful sync of the TerraformStateVersionRegistry
"""
lastSyncedAt: Time
"""
Timestamp after which the TerraformStateVersionRegistry should be resynced
"""
retryAt: Time
"""
Number of consecutive failed sync attempts of the TerraformStateVersionRegistry
"""
retryCount: Int
"""
Sync state of the TerraformStateVersionRegistry
"""
state: RegistryState
"""
ID of the terraform state version
"""
terraformStateVersionId: ID!
}
"""
The connection type for TerraformStateVersionRegistry.
"""
type TerraformStateVersionRegistryConnection {
"""
A list of edges.
"""
edges: [TerraformStateVersionRegistryEdge]
"""
A list of nodes.
"""
nodes: [TerraformStateVersionRegistry]
"""
Information to aid in pagination.
"""
pageInfo: PageInfo!
}
"""
An edge in a connection.
"""
type TerraformStateVersionRegistryEdge {
"""
A cursor for use in pagination.
"""
cursor: String!
"""
The item at the end of the edge.
"""
node: TerraformStateVersionRegistry
}
"""
Represents a requirement test report
"""
......
......@@ -2409,6 +2409,21 @@ Represents the sync and verification state of a terraform state.
| `state` | RegistryState | Sync state of the TerraformStateRegistry |
| `terraformStateId` | ID! | ID of the TerraformState |
### TerraformStateVersionRegistry
Represents the Geo sync and verification state of a terraform state version.
| Field | Type | Description |
| ----- | ---- | ----------- |
| `createdAt` | Time | Timestamp when the TerraformStateVersionRegistry was created |
| `id` | ID! | ID of the TerraformStateVersionRegistry |
| `lastSyncFailure` | String | Error message during sync of the TerraformStateVersionRegistry |
| `lastSyncedAt` | Time | Timestamp of the most recent successful sync of the TerraformStateVersionRegistry |
| `retryAt` | Time | Timestamp after which the TerraformStateVersionRegistry should be resynced |
| `retryCount` | Int | Number of consecutive failed sync attempts of the TerraformStateVersionRegistry |
| `state` | RegistryState | Sync state of the TerraformStateVersionRegistry |
| `terraformStateVersionId` | ID! | ID of the terraform state version |
### TestReport
Represents a requirement test report.
......
# frozen_string_literal: true
module Geo
class TerraformStateVersionRegistryFinder
include FrameworkRegistryFinder
end
end
# frozen_string_literal: true
module Resolvers
module Geo
class TerraformStateVersionRegistriesResolver < BaseResolver
include RegistriesResolver
end
end
end
......@@ -32,6 +32,11 @@ module Types
resolver: ::Resolvers::Geo::TerraformStateRegistriesResolver,
description: 'Find terraform state registries on this Geo node',
feature_flag: :geo_terraform_state_replication
field :terraform_state_version_registries, ::Types::Geo::TerraformStateVersionRegistryType.connection_type,
null: true,
resolver: ::Resolvers::Geo::TerraformStateVersionRegistriesResolver,
description: 'Find terraform state version registries on this Geo node',
feature_flag: :geo_terraform_state_version_replication
end
end
end
# frozen_string_literal: true
module Types
module Geo
# rubocop:disable Graphql/AuthorizeTypes because it is included
class TerraformStateVersionRegistryType < BaseObject
include ::Types::Geo::RegistryType
graphql_name 'TerraformStateVersionRegistry'
description 'Represents the Geo sync and verification state of a terraform state version'
field :terraform_state_version_id, GraphQL::ID_TYPE, null: false, description: 'ID of the terraform state version'
end
end
end
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Geo::TerraformStateVersionRegistryFinder do
it_behaves_like 'a framework registry finder', :geo_terraform_state_version_registry
end
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Resolvers::Geo::TerraformStateVersionRegistriesResolver do
it_behaves_like 'a Geo registries resolver', :geo_terraform_state_version_registry
end
......@@ -12,7 +12,7 @@ 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 package_file_registries
terraform_state_registries
terraform_state_registries terraform_state_version_registries
]
expect(described_class).to have_graphql_fields(*expected_fields)
......
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe GitlabSchema.types['TerraformStateVersionRegistry'] do
it_behaves_like 'a Geo registry type'
it 'has the expected fields (other than those included in RegistryType)' do
expected_fields = %i[terraform_state_version_id]
expect(described_class).to have_graphql_fields(*expected_fields).at_least
end
end
......@@ -16,4 +16,11 @@ RSpec.describe 'Gets registries' do
registry_factory: :geo_terraform_state_registry,
registry_foreign_key_field_name: 'terraformStateId'
}
it_behaves_like 'gets registries for', {
field_name: 'terraformStateVersionRegistries',
registry_class_name: 'TerraformStateVersionRegistry',
registry_factory: :geo_terraform_state_version_registry,
registry_foreign_key_field_name: 'terraformStateVersionId'
}
end
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