-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This adds a `Branch` model and a representation of a data store's default branch, allowing us to remove the more specific environment variable/app configuration. Branches are annoying because they are undocumented and don't formally form part of the Discovery Engine API. Every data store has exactly one branch (the default one), and you don't interact with it in any way _other than_ when you add/update/remove documents on the datastore.
- Loading branch information
Showing
7 changed files
with
39 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Represents a branch on a Discovery Engine data store. | ||
# | ||
# Currently, every data store on Discovery Engine has exactly *one* branch (the default branch), and | ||
# we are not able to make any changes to that resource. However, we still need to model it here | ||
# because documents are children of the branch, not the datastore itself. | ||
# | ||
# see https://cloud.google.com/ruby/docs/reference/google-cloud-discovery_engine-v1/latest/Google-Cloud-DiscoveryEngine-V1-DocumentService-Client | ||
# (there is no documentation specific to branches) | ||
Branch = Data.define(:remote_resource_id) do | ||
include DiscoveryEngineNameable | ||
|
||
# The default branch automatically available on a data store | ||
def self.default | ||
new("default_branch") | ||
end | ||
|
||
def parent | ||
# We only use a single data store in our architecture, so we can hardcode it here. | ||
DataStore.default | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
RSpec.describe Branch do | ||
subject(:branch) { described_class.new("my-branch") } | ||
|
||
describe ".default" do | ||
it "returns the default branch" do | ||
expect(described_class.default).to eq(described_class.new("default_branch")) | ||
end | ||
end | ||
|
||
describe "#name" do | ||
it "returns the fully qualified name of the branch" do | ||
expect(subject.name).to eq("[collection]/dataStores/govuk_content/branches/my-branch") | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters