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
3df33d69
Commit
3df33d69
authored
Jan 04, 2021
by
Tiger
Committed by
Tiger Watson
Jan 19, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move Terraform::StateVersion.with_files_stored_locally to Core
https://gitlab.com/gitlab-org/gitlab/-/merge_requests/50740
parent
f1a4ee68
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
19 additions
and
17 deletions
+19
-17
app/models/terraform/state_version.rb
app/models/terraform/state_version.rb
+1
-0
ee/app/models/ee/terraform/state_version.rb
ee/app/models/ee/terraform/state_version.rb
+0
-1
ee/spec/models/ee/terraform/state_version_spec.rb
ee/spec/models/ee/terraform/state_version_spec.rb
+0
-16
spec/models/terraform/state_version_spec.rb
spec/models/terraform/state_version_spec.rb
+18
-0
No files found.
app/models/terraform/state_version.rb
View file @
3df33d69
...
@@ -9,6 +9,7 @@ module Terraform
...
@@ -9,6 +9,7 @@ module Terraform
belongs_to
:build
,
class_name:
'Ci::Build'
,
optional:
true
,
foreign_key: :ci_build_id
belongs_to
:build
,
class_name:
'Ci::Build'
,
optional:
true
,
foreign_key: :ci_build_id
scope
:ordered_by_version_desc
,
->
{
order
(
version: :desc
)
}
scope
:ordered_by_version_desc
,
->
{
order
(
version: :desc
)
}
scope
:with_files_stored_locally
,
->
{
where
(
file_store:
Terraform
::
StateUploader
::
Store
::
LOCAL
)
}
default_value_for
(
:file_store
)
{
StateUploader
.
default_store
}
default_value_for
(
:file_store
)
{
StateUploader
.
default_store
}
...
...
ee/app/models/ee/terraform/state_version.rb
View file @
3df33d69
...
@@ -9,7 +9,6 @@ module EE
...
@@ -9,7 +9,6 @@ module EE
include
::
Gitlab
::
Geo
::
ReplicableModel
include
::
Gitlab
::
Geo
::
ReplicableModel
with_replicator
Geo
::
TerraformStateVersionReplicator
with_replicator
Geo
::
TerraformStateVersionReplicator
scope
:with_files_stored_locally
,
->
{
where
(
file_store:
::
ObjectStorage
::
Store
::
LOCAL
)
}
scope
:project_id_in
,
->
(
ids
)
{
joins
(
:terraform_state
).
where
(
'terraform_states.project_id'
:
ids
)
}
scope
:project_id_in
,
->
(
ids
)
{
joins
(
:terraform_state
).
where
(
'terraform_states.project_id'
:
ids
)
}
end
end
...
...
ee/spec/models/ee/terraform/state_version_spec.rb
View file @
3df33d69
...
@@ -9,22 +9,6 @@ RSpec.describe Terraform::StateVersion do
...
@@ -9,22 +9,6 @@ RSpec.describe Terraform::StateVersion do
let_it_be
(
:group
)
{
create
(
:group
)
}
let_it_be
(
:group
)
{
create
(
:group
)
}
let_it_be
(
:project
)
{
create
(
:project
,
group:
group
)
}
let_it_be
(
:project
)
{
create
(
:project
,
group:
group
)
}
describe
'.with_files_stored_locally'
do
it
'includes states with local storage'
do
create_list
(
:terraform_state_version
,
5
)
expect
(
described_class
.
with_files_stored_locally
).
to
have_attributes
(
count:
5
)
end
it
'excludes states without local storage'
do
stub_terraform_state_object_storage
create_list
(
:terraform_state_version
,
5
)
expect
(
described_class
.
with_files_stored_locally
).
to
have_attributes
(
count:
0
)
end
end
describe
'.replicables_for_current_secondary'
do
describe
'.replicables_for_current_secondary'
do
where
(
:selective_sync_enabled
,
:object_storage_sync_enabled
,
:terraform_object_storage_enabled
,
:synced_states
)
do
where
(
:selective_sync_enabled
,
:object_storage_sync_enabled
,
:terraform_object_storage_enabled
,
:synced_states
)
do
true
|
true
|
true
|
5
true
|
true
|
true
|
5
...
...
spec/models/terraform/state_version_spec.rb
View file @
3df33d69
...
@@ -24,6 +24,24 @@ RSpec.describe Terraform::StateVersion do
...
@@ -24,6 +24,24 @@ RSpec.describe Terraform::StateVersion do
it
{
expect
(
subject
.
map
(
&
:version
)).
to
eq
(
versions
.
sort
.
reverse
)
}
it
{
expect
(
subject
.
map
(
&
:version
)).
to
eq
(
versions
.
sort
.
reverse
)
}
end
end
describe
'.with_files_stored_locally'
do
subject
{
described_class
.
with_files_stored_locally
}
it
'includes states with local storage'
do
create_list
(
:terraform_state_version
,
5
)
expect
(
subject
).
to
have_attributes
(
count:
5
)
end
it
'excludes states without local storage'
do
stub_terraform_state_object_storage
create_list
(
:terraform_state_version
,
5
)
expect
(
subject
).
to
have_attributes
(
count:
0
)
end
end
end
end
context
'file storage'
do
context
'file storage'
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