Commit b1e5207e authored by Gabriel Mazetto's avatar Gabriel Mazetto

Merge branch 'alexives/237928/graphql_for_tf_version_sync' into 'master'

Add graphql support for tf version replication

Closes #237928

See merge request gitlab-org/gitlab!42533
parents 8f892adf d1e90512
...@@ -6508,6 +6508,37 @@ type GeoNode { ...@@ -6508,6 +6508,37 @@ type GeoNode {
last: Int last: Int
): TerraformStateRegistryConnection ): 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 The user-facing URL for this Geo node
""" """
...@@ -16923,6 +16954,86 @@ type TerraformStateRegistryEdge { ...@@ -16923,6 +16954,86 @@ type TerraformStateRegistryEdge {
node: TerraformStateRegistry 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 Represents a requirement test report
""" """
......
...@@ -18134,6 +18134,77 @@ ...@@ -18134,6 +18134,77 @@
"isDeprecated": false, "isDeprecated": false,
"deprecationReason": null "deprecationReason": null
}, },
{
"name": "terraformStateVersionRegistries",
"description": "Find terraform state version registries on this Geo node. Available only when feature flag `geo_terraform_state_version_replication` is enabled",
"args": [
{
"name": "ids",
"description": "Filters registries by their ID",
"type": {
"kind": "LIST",
"name": null,
"ofType": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "ID",
"ofType": null
}
}
},
"defaultValue": null
},
{
"name": "after",
"description": "Returns the elements in the list that come after the specified cursor.",
"type": {
"kind": "SCALAR",
"name": "String",
"ofType": null
},
"defaultValue": null
},
{
"name": "before",
"description": "Returns the elements in the list that come before the specified cursor.",
"type": {
"kind": "SCALAR",
"name": "String",
"ofType": null
},
"defaultValue": null
},
{
"name": "first",
"description": "Returns the first _n_ elements from the list.",
"type": {
"kind": "SCALAR",
"name": "Int",
"ofType": null
},
"defaultValue": null
},
{
"name": "last",
"description": "Returns the last _n_ elements from the list.",
"type": {
"kind": "SCALAR",
"name": "Int",
"ofType": null
},
"defaultValue": null
}
],
"type": {
"kind": "OBJECT",
"name": "TerraformStateVersionRegistryConnection",
"ofType": null
},
"isDeprecated": false,
"deprecationReason": null
},
{ {
"name": "url", "name": "url",
"description": "The user-facing URL for this Geo node", "description": "The user-facing URL for this Geo node",
...@@ -49587,6 +49658,251 @@ ...@@ -49587,6 +49658,251 @@
"enumValues": null, "enumValues": null,
"possibleTypes": null "possibleTypes": null
}, },
{
"kind": "OBJECT",
"name": "TerraformStateVersionRegistry",
"description": "Represents the Geo sync and verification state of a terraform state version",
"fields": [
{
"name": "createdAt",
"description": "Timestamp when the TerraformStateVersionRegistry was created",
"args": [
],
"type": {
"kind": "SCALAR",
"name": "Time",
"ofType": null
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "id",
"description": "ID of the TerraformStateVersionRegistry",
"args": [
],
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "ID",
"ofType": null
}
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "lastSyncFailure",
"description": "Error message during sync of the TerraformStateVersionRegistry",
"args": [
],
"type": {
"kind": "SCALAR",
"name": "String",
"ofType": null
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "lastSyncedAt",
"description": "Timestamp of the most recent successful sync of the TerraformStateVersionRegistry",
"args": [
],
"type": {
"kind": "SCALAR",
"name": "Time",
"ofType": null
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "retryAt",
"description": "Timestamp after which the TerraformStateVersionRegistry should be resynced",
"args": [
],
"type": {
"kind": "SCALAR",
"name": "Time",
"ofType": null
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "retryCount",
"description": "Number of consecutive failed sync attempts of the TerraformStateVersionRegistry",
"args": [
],
"type": {
"kind": "SCALAR",
"name": "Int",
"ofType": null
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "state",
"description": "Sync state of the TerraformStateVersionRegistry",
"args": [
],
"type": {
"kind": "ENUM",
"name": "RegistryState",
"ofType": null
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "terraformStateVersionId",
"description": "ID of the terraform state version",
"args": [
],
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "ID",
"ofType": null
}
},
"isDeprecated": false,
"deprecationReason": null
}
],
"inputFields": null,
"interfaces": [
],
"enumValues": null,
"possibleTypes": null
},
{
"kind": "OBJECT",
"name": "TerraformStateVersionRegistryConnection",
"description": "The connection type for TerraformStateVersionRegistry.",
"fields": [
{
"name": "edges",
"description": "A list of edges.",
"args": [
],
"type": {
"kind": "LIST",
"name": null,
"ofType": {
"kind": "OBJECT",
"name": "TerraformStateVersionRegistryEdge",
"ofType": null
}
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "nodes",
"description": "A list of nodes.",
"args": [
],
"type": {
"kind": "LIST",
"name": null,
"ofType": {
"kind": "OBJECT",
"name": "TerraformStateVersionRegistry",
"ofType": null
}
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "pageInfo",
"description": "Information to aid in pagination.",
"args": [
],
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "OBJECT",
"name": "PageInfo",
"ofType": null
}
},
"isDeprecated": false,
"deprecationReason": null
}
],
"inputFields": null,
"interfaces": [
],
"enumValues": null,
"possibleTypes": null
},
{
"kind": "OBJECT",
"name": "TerraformStateVersionRegistryEdge",
"description": "An edge in a connection.",
"fields": [
{
"name": "cursor",
"description": "A cursor for use in pagination.",
"args": [
],
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "String",
"ofType": null
}
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "node",
"description": "The item at the end of the edge.",
"args": [
],
"type": {
"kind": "OBJECT",
"name": "TerraformStateVersionRegistry",
"ofType": null
},
"isDeprecated": false,
"deprecationReason": null
}
],
"inputFields": null,
"interfaces": [
],
"enumValues": null,
"possibleTypes": null
},
{ {
"kind": "OBJECT", "kind": "OBJECT",
"name": "TestReport", "name": "TestReport",
...@@ -2409,6 +2409,21 @@ Represents the sync and verification state of a terraform state. ...@@ -2409,6 +2409,21 @@ Represents the sync and verification state of a terraform state.
| `state` | RegistryState | Sync state of the TerraformStateRegistry | | `state` | RegistryState | Sync state of the TerraformStateRegistry |
| `terraformStateId` | ID! | ID of the TerraformState | | `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 ### TestReport
Represents a requirement test report. 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
...@@ -31,6 +31,11 @@ module Types ...@@ -31,6 +31,11 @@ module Types
resolver: ::Resolvers::Geo::TerraformStateRegistriesResolver, resolver: ::Resolvers::Geo::TerraformStateRegistriesResolver,
description: 'Find terraform state registries on this Geo node', description: 'Find terraform state registries on this Geo node',
feature_flag: :geo_terraform_state_replication 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 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 ...@@ -12,7 +12,7 @@ RSpec.describe GitlabSchema.types['GeoNode'] do
container_repositories_max_capacity sync_object_storage container_repositories_max_capacity sync_object_storage
selective_sync_type selective_sync_shards selective_sync_namespaces selective_sync_type selective_sync_shards selective_sync_namespaces
minimum_reverification_interval package_file_registries 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) 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 ...@@ -16,4 +16,11 @@ RSpec.describe 'Gets registries' do
registry_factory: :geo_terraform_state_registry, registry_factory: :geo_terraform_state_registry,
registry_foreign_key_field_name: 'terraformStateId' 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 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