Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
164e9136
Commit
164e9136
authored
Nov 11, 2020
by
Tiger
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add CI job to Terraform state version GraphQL type
https://gitlab.com/gitlab-org/gitlab/-/merge_requests/47339
parent
023b7230
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
39 additions
and
1 deletion
+39
-1
app/graphql/types/terraform/state_version_type.rb
app/graphql/types/terraform/state_version_type.rb
+6
-0
changelogs/unreleased/267168-add-ci-build-to-terraform-state-version-graphql-type.yml
...-add-ci-build-to-terraform-state-version-graphql-type.yml
+5
-0
doc/api/graphql/reference/gitlab_schema.graphql
doc/api/graphql/reference/gitlab_schema.graphql
+5
-0
doc/api/graphql/reference/gitlab_schema.json
doc/api/graphql/reference/gitlab_schema.json
+14
-0
doc/api/graphql/reference/index.md
doc/api/graphql/reference/index.md
+1
-0
spec/factories/terraform/state_version.rb
spec/factories/terraform/state_version.rb
+1
-0
spec/graphql/types/terraform/state_version_type_spec.rb
spec/graphql/types/terraform/state_version_type_spec.rb
+2
-1
spec/requests/api/graphql/project/terraform/states_spec.rb
spec/requests/api/graphql/project/terraform/states_spec.rb
+5
-0
No files found.
app/graphql/types/terraform/state_version_type.rb
View file @
164e9136
...
...
@@ -17,6 +17,12 @@ module Types
description:
'The user that created this version'
,
resolve:
->
(
version
,
_
,
_
)
{
Gitlab
::
Graphql
::
Loaders
::
BatchModelLoader
.
new
(
User
,
version
.
created_by_user_id
).
find
}
field
:job
,
Types
::
Ci
::
JobType
,
null:
true
,
authorize: :read_build
,
description:
'The job that created this version'
,
resolve:
->
(
version
,
_
,
_
)
{
Gitlab
::
Graphql
::
Loaders
::
BatchModelLoader
.
new
(
::
Ci
::
Build
,
version
.
ci_build_id
).
find
}
field
:created_at
,
Types
::
TimeType
,
null:
false
,
description:
'Timestamp the version was created'
...
...
changelogs/unreleased/267168-add-ci-build-to-terraform-state-version-graphql-type.yml
0 → 100644
View file @
164e9136
---
title
:
Add CI job to Terraform state version GraphQL type
merge_request
:
47339
author
:
type
:
added
doc/api/graphql/reference/gitlab_schema.graphql
View file @
164e9136
...
...
@@ -20541,6 +20541,11 @@ type TerraformStateVersion {
"""
id
:
ID
!
"""
The
job
that
created
this
version
"""
job
:
CiJob
"""
Timestamp
the
version
was
updated
"""
...
...
doc/api/graphql/reference/gitlab_schema.json
View file @
164e9136
...
...
@@ -59663,6 +59663,20 @@
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "job",
"description": "The job that created this version",
"args": [
],
"type": {
"kind": "OBJECT",
"name": "CiJob",
"ofType": null
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "updatedAt",
"description": "Timestamp the version was updated",
doc/api/graphql/reference/index.md
View file @
164e9136
...
...
@@ -3019,6 +3019,7 @@ Autogenerated return type of TerraformStateUnlock.
|
`createdAt`
| Time! | Timestamp the version was created |
|
`createdByUser`
| User | The user that created this version |
|
`id`
| ID! | ID of the Terraform state version |
|
`job`
| CiJob | The job that created this version |
|
`updatedAt`
| Time! | Timestamp the version was updated |
### TerraformStateVersionRegistry
...
...
spec/factories/terraform/state_version.rb
View file @
164e9136
...
...
@@ -4,6 +4,7 @@ FactoryBot.define do
factory
:terraform_state_version
,
class:
'Terraform::StateVersion'
do
terraform_state
factory: :terraform_state
created_by_user
factory: :user
build
{
association
(
:ci_build
,
project:
terraform_state
.
project
)
}
sequence
(
:version
)
file
{
fixture_file_upload
(
'spec/fixtures/terraform/terraform.tfstate'
,
'application/json'
)
}
...
...
spec/graphql/types/terraform/state_version_type_spec.rb
View file @
164e9136
...
...
@@ -7,12 +7,13 @@ RSpec.describe GitlabSchema.types['TerraformStateVersion'] do
it
{
expect
(
described_class
).
to
require_graphql_authorizations
(
:read_terraform_state
)
}
describe
'fields'
do
let
(
:fields
)
{
%i[id created_by_user created_at updated_at]
}
let
(
:fields
)
{
%i[id created_by_user
job
created_at updated_at]
}
it
{
expect
(
described_class
).
to
have_graphql_fields
(
fields
)
}
it
{
expect
(
described_class
.
fields
[
'id'
].
type
).
to
be_non_null
}
it
{
expect
(
described_class
.
fields
[
'createdByUser'
].
type
).
not_to
be_non_null
}
it
{
expect
(
described_class
.
fields
[
'job'
].
type
).
not_to
be_non_null
}
it
{
expect
(
described_class
.
fields
[
'createdAt'
].
type
).
to
be_non_null
}
it
{
expect
(
described_class
.
fields
[
'updatedAt'
].
type
).
to
be_non_null
}
end
...
...
spec/requests/api/graphql/project/terraform/states_spec.rb
View file @
164e9136
...
...
@@ -29,6 +29,10 @@ RSpec.describe 'query terraform states' do
createdByUser {
id
}
job {
name
}
}
lockedByUser {
...
...
@@ -61,6 +65,7 @@ RSpec.describe 'query terraform states' do
expect
(
version
[
'createdAt'
]).
to
eq
(
latest_version
.
created_at
.
iso8601
)
expect
(
version
[
'updatedAt'
]).
to
eq
(
latest_version
.
updated_at
.
iso8601
)
expect
(
version
.
dig
(
'createdByUser'
,
'id'
)).
to
eq
(
latest_version
.
created_by_user
.
to_global_id
.
to_s
)
expect
(
version
.
dig
(
'job'
,
'name'
)).
to
eq
(
latest_version
.
build
.
name
)
end
it
'returns count of terraform states'
do
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment