Commit fff2665b authored by Ash McKenzie's avatar Ash McKenzie

Merge branch '10io-add-cleanup-status-to-container-repository-details-graphql' into 'master'

Add cleanup status field to graphQL ContainerRepositoryType

See merge request gitlab-org/gitlab!47544
parents 4f331405 fe0e17f9
# frozen_string_literal: true
module Types
class ContainerRepositoryCleanupStatusEnum < BaseEnum
graphql_name 'ContainerRepositoryCleanupStatus'
description 'Status of the tags cleanup of a container repository'
value 'UNSCHEDULED', value: 'cleanup_unscheduled', description: 'The tags cleanup is not scheduled. This is the default state.'
value 'SCHEDULED', value: 'cleanup_scheduled', description: 'The tags cleanup is scheduled and is going to be executed shortly.'
value 'UNFINISHED', value: 'cleanup_unfinished', description: 'The tags cleanup has been partially executed. There are still remaining tags to delete.'
value 'ONGOING', value: 'cleanup_ongoing', description: 'The tags cleanup is ongoing.'
end
end
...@@ -15,6 +15,7 @@ module Types ...@@ -15,6 +15,7 @@ module Types
field :created_at, Types::TimeType, null: false, description: 'Timestamp when the container repository was created.' field :created_at, Types::TimeType, null: false, description: 'Timestamp when the container repository was created.'
field :updated_at, Types::TimeType, null: false, description: 'Timestamp when the container repository was updated.' field :updated_at, Types::TimeType, null: false, description: 'Timestamp when the container repository was updated.'
field :expiration_policy_started_at, Types::TimeType, null: true, description: 'Timestamp when the cleanup done by the expiration policy was started on the container repository.' field :expiration_policy_started_at, Types::TimeType, null: true, description: 'Timestamp when the cleanup done by the expiration policy was started on the container repository.'
field :expiration_policy_cleanup_status, Types::ContainerRepositoryCleanupStatusEnum, null: true, description: 'The tags cleanup status for the container repository.'
field :status, Types::ContainerRepositoryStatusEnum, null: true, description: 'Status of the container repository.' field :status, Types::ContainerRepositoryStatusEnum, null: true, description: 'Status of the container repository.'
field :tags_count, GraphQL::INT_TYPE, null: false, description: 'Number of tags associated with this image.' field :tags_count, GraphQL::INT_TYPE, null: false, description: 'Number of tags associated with this image.'
field :can_delete, GraphQL::BOOLEAN_TYPE, null: false, description: 'Can the current user delete the container repository.' field :can_delete, GraphQL::BOOLEAN_TYPE, null: false, description: 'Can the current user delete the container repository.'
......
---
title: Add cleanup status field to graphQL ContainerRepositoryType
merge_request: 47544
author:
type: added
...@@ -3313,6 +3313,11 @@ type ContainerRepository { ...@@ -3313,6 +3313,11 @@ type ContainerRepository {
""" """
createdAt: Time! createdAt: Time!
"""
The tags cleanup status for the container repository.
"""
expirationPolicyCleanupStatus: ContainerRepositoryCleanupStatus
""" """
Timestamp when the cleanup done by the expiration policy was started on the container repository. Timestamp when the cleanup done by the expiration policy was started on the container repository.
""" """
...@@ -3354,6 +3359,31 @@ type ContainerRepository { ...@@ -3354,6 +3359,31 @@ type ContainerRepository {
updatedAt: Time! updatedAt: Time!
} }
"""
Status of the tags cleanup of a container repository
"""
enum ContainerRepositoryCleanupStatus {
"""
The tags cleanup is ongoing.
"""
ONGOING
"""
The tags cleanup is scheduled and is going to be executed shortly.
"""
SCHEDULED
"""
The tags cleanup has been partially executed. There are still remaining tags to delete.
"""
UNFINISHED
"""
The tags cleanup is not scheduled. This is the default state.
"""
UNSCHEDULED
}
""" """
The connection type for ContainerRepository. The connection type for ContainerRepository.
""" """
...@@ -3388,6 +3418,11 @@ type ContainerRepositoryDetails { ...@@ -3388,6 +3418,11 @@ type ContainerRepositoryDetails {
""" """
createdAt: Time! createdAt: Time!
"""
The tags cleanup status for the container repository.
"""
expirationPolicyCleanupStatus: ContainerRepositoryCleanupStatus
""" """
Timestamp when the cleanup done by the expiration policy was started on the container repository. Timestamp when the cleanup done by the expiration policy was started on the container repository.
""" """
......
...@@ -8947,6 +8947,20 @@ ...@@ -8947,6 +8947,20 @@
"isDeprecated": false, "isDeprecated": false,
"deprecationReason": null "deprecationReason": null
}, },
{
"name": "expirationPolicyCleanupStatus",
"description": "The tags cleanup status for the container repository.",
"args": [
],
"type": {
"kind": "ENUM",
"name": "ContainerRepositoryCleanupStatus",
"ofType": null
},
"isDeprecated": false,
"deprecationReason": null
},
{ {
"name": "expirationPolicyStartedAt", "name": "expirationPolicyStartedAt",
"description": "Timestamp when the cleanup done by the expiration policy was started on the container repository.", "description": "Timestamp when the cleanup done by the expiration policy was started on the container repository.",
...@@ -9091,6 +9105,41 @@ ...@@ -9091,6 +9105,41 @@
"enumValues": null, "enumValues": null,
"possibleTypes": null "possibleTypes": null
}, },
{
"kind": "ENUM",
"name": "ContainerRepositoryCleanupStatus",
"description": "Status of the tags cleanup of a container repository",
"fields": null,
"inputFields": null,
"interfaces": null,
"enumValues": [
{
"name": "UNSCHEDULED",
"description": "The tags cleanup is not scheduled. This is the default state.",
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "SCHEDULED",
"description": "The tags cleanup is scheduled and is going to be executed shortly.",
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "UNFINISHED",
"description": "The tags cleanup has been partially executed. There are still remaining tags to delete.",
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "ONGOING",
"description": "The tags cleanup is ongoing.",
"isDeprecated": false,
"deprecationReason": null
}
],
"possibleTypes": null
},
{ {
"kind": "OBJECT", "kind": "OBJECT",
"name": "ContainerRepositoryConnection", "name": "ContainerRepositoryConnection",
...@@ -9199,6 +9248,20 @@ ...@@ -9199,6 +9248,20 @@
"isDeprecated": false, "isDeprecated": false,
"deprecationReason": null "deprecationReason": null
}, },
{
"name": "expirationPolicyCleanupStatus",
"description": "The tags cleanup status for the container repository.",
"args": [
],
"type": {
"kind": "ENUM",
"name": "ContainerRepositoryCleanupStatus",
"ofType": null
},
"isDeprecated": false,
"deprecationReason": null
},
{ {
"name": "expirationPolicyStartedAt", "name": "expirationPolicyStartedAt",
"description": "Timestamp when the cleanup done by the expiration policy was started on the container repository.", "description": "Timestamp when the cleanup done by the expiration policy was started on the container repository.",
...@@ -535,6 +535,7 @@ A container repository. ...@@ -535,6 +535,7 @@ A container repository.
| ----- | ---- | ----------- | | ----- | ---- | ----------- |
| `canDelete` | Boolean! | Can the current user delete the container repository. | | `canDelete` | Boolean! | Can the current user delete the container repository. |
| `createdAt` | Time! | Timestamp when the container repository was created. | | `createdAt` | Time! | Timestamp when the container repository was created. |
| `expirationPolicyCleanupStatus` | ContainerRepositoryCleanupStatus | The tags cleanup status for the container repository. |
| `expirationPolicyStartedAt` | Time | Timestamp when the cleanup done by the expiration policy was started on the container repository. | | `expirationPolicyStartedAt` | Time | Timestamp when the cleanup done by the expiration policy was started on the container repository. |
| `id` | ID! | ID of the container repository. | | `id` | ID! | ID of the container repository. |
| `location` | String! | URL of the container repository. | | `location` | String! | URL of the container repository. |
...@@ -552,6 +553,7 @@ Details of a container repository. ...@@ -552,6 +553,7 @@ Details of a container repository.
| ----- | ---- | ----------- | | ----- | ---- | ----------- |
| `canDelete` | Boolean! | Can the current user delete the container repository. | | `canDelete` | Boolean! | Can the current user delete the container repository. |
| `createdAt` | Time! | Timestamp when the container repository was created. | | `createdAt` | Time! | Timestamp when the container repository was created. |
| `expirationPolicyCleanupStatus` | ContainerRepositoryCleanupStatus | The tags cleanup status for the container repository. |
| `expirationPolicyStartedAt` | Time | Timestamp when the cleanup done by the expiration policy was started on the container repository. | | `expirationPolicyStartedAt` | Time | Timestamp when the cleanup done by the expiration policy was started on the container repository. |
| `id` | ID! | ID of the container repository. | | `id` | ID! | ID of the container repository. |
| `location` | String! | URL of the container repository. | | `location` | String! | URL of the container repository. |
...@@ -3812,6 +3814,17 @@ Mode of a commit action. ...@@ -3812,6 +3814,17 @@ Mode of a commit action.
| `SEVEN_DAYS` | 7 days until tags are automatically removed | | `SEVEN_DAYS` | 7 days until tags are automatically removed |
| `THIRTY_DAYS` | 30 days until tags are automatically removed | | `THIRTY_DAYS` | 30 days until tags are automatically removed |
### ContainerRepositoryCleanupStatus
Status of the tags cleanup of a container repository.
| Value | Description |
| ----- | ----------- |
| `ONGOING` | The tags cleanup is ongoing. |
| `SCHEDULED` | The tags cleanup is scheduled and is going to be executed shortly. |
| `UNFINISHED` | The tags cleanup has been partially executed. There are still remaining tags to delete. |
| `UNSCHEDULED` | The tags cleanup is not scheduled. This is the default state. |
### ContainerRepositoryStatus ### ContainerRepositoryStatus
Status of a container repository. Status of a container repository.
......
{
"type": "array",
"items": {
"type": "object",
"required": ["node"],
"properties": {
"node": {
"$ref": "./container_repository.json"
}
}
}
}
{ {
"type": "object", "type": "object",
"required": ["id", "name", "path", "location", "createdAt", "updatedAt", "tagsCount", "canDelete"], "required": ["id", "name", "path", "location", "createdAt", "updatedAt", "tagsCount", "canDelete", "expirationPolicyCleanupStatus"],
"properties": { "properties": {
"id": { "id": {
"type": "string" "type": "string"
...@@ -31,6 +31,10 @@ ...@@ -31,6 +31,10 @@
}, },
"canDelete": { "canDelete": {
"type": "boolean" "type": "boolean"
},
"expirationPolicyCleanupStatus": {
"type": "string",
"enum": ["UNSCHEDULED", "SCHEDULED", "UNFINISHED", "ONGOING"]
} }
} }
} }
{ {
"type": "object", "type": "object",
"required": ["id", "name", "path", "location", "createdAt", "updatedAt", "tagsCount", "canDelete", "tags"], "required": ["tags"],
"allOf": [{ "$ref": "./container_repository.json" }],
"properties": { "properties": {
"id": {
"type": "string"
},
"name": {
"type": "string"
},
"path": {
"type": "string"
},
"location": {
"type": "string"
},
"createdAt": {
"type": "string"
},
"updatedAt": {
"type": "string"
},
"expirationPolicyStartedAt": {
"type": ["string", "null"]
},
"status": {
"type": ["string", "null"]
},
"tagsCount": {
"type": "integer"
},
"canDelete": {
"type": "boolean"
},
"tags": { "tags": {
"type": "object", "type": "object",
"required": ["nodes"], "required": ["nodes"],
......
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe GitlabSchema.types['ContainerRepositoryCleanupStatus'] do
it 'exposes all statuses' do
expected_keys = ContainerRepository.expiration_policy_cleanup_statuses
.keys
.map { |k| k.gsub('cleanup_', '') }
.map(&:upcase)
expect(described_class.values.keys).to contain_exactly(*expected_keys)
end
end
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
require 'spec_helper' require 'spec_helper'
RSpec.describe GitlabSchema.types['ContainerRepositoryDetails'] do RSpec.describe GitlabSchema.types['ContainerRepositoryDetails'] do
fields = %i[id name path location created_at updated_at expiration_policy_started_at status tags_count can_delete tags] fields = %i[id name path location created_at updated_at expiration_policy_started_at status tags_count can_delete expiration_policy_cleanup_status tags]
it { expect(described_class.graphql_name).to eq('ContainerRepositoryDetails') } it { expect(described_class.graphql_name).to eq('ContainerRepositoryDetails') }
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
require 'spec_helper' require 'spec_helper'
RSpec.describe GitlabSchema.types['ContainerRepository'] do RSpec.describe GitlabSchema.types['ContainerRepository'] do
fields = %i[id name path location created_at updated_at expiration_policy_started_at status tags_count can_delete] fields = %i[id name path location created_at updated_at expiration_policy_started_at status tags_count can_delete expiration_policy_cleanup_status]
it { expect(described_class.graphql_name).to eq('ContainerRepository') } it { expect(described_class.graphql_name).to eq('ContainerRepository') }
...@@ -20,4 +20,12 @@ RSpec.describe GitlabSchema.types['ContainerRepository'] do ...@@ -20,4 +20,12 @@ RSpec.describe GitlabSchema.types['ContainerRepository'] do
is_expected.to have_graphql_type(Types::ContainerRepositoryStatusEnum) is_expected.to have_graphql_type(Types::ContainerRepositoryStatusEnum)
end end
end end
describe 'expiration_policy_cleanup_status field' do
subject { described_class.fields['expirationPolicyCleanupStatus'] }
it 'returns cleanup status enum' do
is_expected.to have_graphql_type(Types::ContainerRepositoryCleanupStatusEnum)
end
end
end end
...@@ -34,7 +34,7 @@ RSpec.describe 'container repository details' do ...@@ -34,7 +34,7 @@ RSpec.describe 'container repository details' do
subject subject
end end
it 'matches the expected schema' do it 'matches the JSON schema' do
expect(container_repository_details_response).to match_schema('graphql/container_repository_details') expect(container_repository_details_response).to match_schema('graphql/container_repository_details')
end end
end end
......
...@@ -47,6 +47,10 @@ RSpec.describe 'getting container repositories in a project' do ...@@ -47,6 +47,10 @@ RSpec.describe 'getting container repositories in a project' do
before do before do
subject subject
end end
it 'matches the JSON schema' do
expect(container_repositories_response).to match_schema('graphql/container_repositories')
end
end end
context 'with different permissions' do context 'with different permissions' do
......
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