Skip to content

Commit

Permalink
Rename #discovery_engine_id to #remote_resource_id
Browse files Browse the repository at this point in the history
This is a more sensible name that doesn't cause confusion around
"engines".
  • Loading branch information
csutter committed Feb 6, 2025
1 parent f9e19e7 commit 5cd43b0
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion app/clients/discovery_engine/control_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class ControlClient
def create(control)
discovery_engine_client.create_control(
control: control.to_discovery_engine_control,
control_id: control.discovery_engine_id,
control_id: control.remote_resource_id,
parent: control.parent.name,
)
rescue Google::Cloud::Error => e
Expand Down
4 changes: 2 additions & 2 deletions app/models/concerns/discovery_engine_nameable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
# projects/{project}/locations/{location}/collections/{collection_id}/engines/
# {engine_id}/controls/{control_id}
#
# Requires the including class to implement `#discovery_engine_id`, and optionally `#parent` if the
# Requires the including class to implement `#remote_resource_id`, and optionally `#parent` if the
# parent resource is not the default collection.
module DiscoveryEngineNameable
# The name (fully qualified path) of this Discovery Engine resource on GCP
def name
[parent_name, resource_path_fragment, discovery_engine_id].join("/")
[parent_name, resource_path_fragment, remote_resource_id].join("/")
end

private
Expand Down
2 changes: 1 addition & 1 deletion app/models/control.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def parent
end

# The ID of the resource on Discovery Engine
def discovery_engine_id
def remote_resource_id
"search-admin-#{id}"
end
end
8 changes: 4 additions & 4 deletions app/models/data_store.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@ class DataStore
# The ID of the default datastore created through Terraform in `govuk_infrastructure`
DEFAULT_DATA_STORE_ID = "govuk_content".freeze

attr_reader :discovery_engine_id
attr_reader :remote_resource_id

def self.default
new(DEFAULT_DATA_STORE_ID)
end

def initialize(discovery_engine_id)
@discovery_engine_id = discovery_engine_id
def initialize(remote_resource_id)
@remote_resource_id = remote_resource_id
end

def ==(other)
discovery_engine_id == other.discovery_engine_id
remote_resource_id == other.remote_resource_id
end
end
8 changes: 4 additions & 4 deletions app/models/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,17 @@ class Engine
# The ID of the default engine created through Terraform in `govuk-infrastructure`
DEFAULT_ENGINE_ID = "govuk".freeze

attr_reader :discovery_engine_id
attr_reader :remote_resource_id

def self.default
new(DEFAULT_ENGINE_ID)
end

def initialize(discovery_engine_id)
@discovery_engine_id = discovery_engine_id
def initialize(remote_resource_id)
@remote_resource_id = remote_resource_id
end

def ==(other)
discovery_engine_id == other.discovery_engine_id
remote_resource_id == other.remote_resource_id
end
end
4 changes: 2 additions & 2 deletions spec/models/control_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@

let(:action) { build(:control_boost_action) }

describe "#discovery_engine_id" do
describe "#remote_resource_id" do
it "builds an ID from the control's database ID" do
expect(control.discovery_engine_id).to eq("search-admin-42")
expect(control.remote_resource_id).to eq("search-admin-42")
end
end

Expand Down

0 comments on commit 5cd43b0

Please sign in to comment.