Skip to content

Commit

Permalink
🦉 Updates from OwlBot post-processor
Browse files Browse the repository at this point in the history
  • Loading branch information
gcf-owl-bot[bot] committed Oct 3, 2024
1 parent 596a1d8 commit 5eaeae1
Show file tree
Hide file tree
Showing 22 changed files with 58 additions and 1,295 deletions.
6 changes: 3 additions & 3 deletions google-cloud-run-client/AUTHENTICATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ To configure a credentials file for an individual client initialization:
```ruby
require "google/cloud/run"

client = Google::Cloud::Run.executions do |config|
client = Google::Cloud::Run.builds do |config|
config.credentials = "path/to/credentialfile.json"
end
```
Expand All @@ -70,7 +70,7 @@ Google::Cloud::Run.configure do |config|
config.credentials = "path/to/credentialfile.json"
end

client = Google::Cloud::Run.executions
client = Google::Cloud::Run.builds
```

### Environment Variables
Expand Down Expand Up @@ -100,7 +100,7 @@ require "google/cloud/run"

ENV["GOOGLE_APPLICATION_CREDENTIALS"] = "path/to/credentialfile.json"

client = Google::Cloud::Run.executions
client = Google::Cloud::Run.builds
```

### Local ADC file
Expand Down
4 changes: 2 additions & 2 deletions google-cloud-run-client/Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ task :acceptance, :project, :keyfile do |t, args|
if project.nil? || keyfile.nil?
fail "You must provide a project and keyfile. e.g. rake acceptance[test123, /path/to/keyfile.json] or GOOGLE_CLOUD_TEST_PROJECT=test123 GOOGLE_CLOUD_TEST_KEYFILE=/path/to/keyfile.json rake acceptance"
end
require "google/cloud/run/v2/executions/credentials"
::Google::Cloud::Run::V2::Executions::Credentials.env_vars.each do |path|
require "google/cloud/run/v2/builds/credentials"
::Google::Cloud::Run::V2::Builds::Credentials.env_vars.each do |path|
ENV[path] = nil
end
ENV["GOOGLE_CLOUD_PROJECT"] = project
Expand Down
34 changes: 34 additions & 0 deletions google-cloud-run-client/lib/google/cloud/run.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,40 @@
module Google
module Cloud
module Run
##
# Create a new client object for Builds.
#
# By default, this returns an instance of
# [Google::Cloud::Run::V2::Builds::Client](https://cloud.google.com/ruby/docs/reference/google-cloud-run-v2/latest/Google-Cloud-Run-V2-Builds-Client)
# for a gRPC client for version V2 of the API.
# However, you can specify a different API version by passing it in the
# `version` parameter. If the Builds service is
# supported by that API version, and the corresponding gem is available, the
# appropriate versioned client will be returned.
# You can also specify a different transport by passing `:rest` or `:grpc` in
# the `transport` parameter.
#
# ## About Builds
#
# Cloud Run Build Control Plane API
#
# @param version [::String, ::Symbol] The API version to connect to. Optional.
# Defaults to `:v2`.
# @param transport [:grpc, :rest] The transport to use. Defaults to `:grpc`.
# @return [::Object] A client object for the specified version.
#
def self.builds version: :v2, transport: :grpc, &block
require "google/cloud/run/#{version.to_s.downcase}"

package_name = Google::Cloud::Run
.constants
.select { |sym| sym.to_s.downcase == version.to_s.downcase.tr("_", "") }
.first
service_module = Google::Cloud::Run.const_get(package_name).const_get(:Builds)
service_module = service_module.const_get(:Rest) if transport == :rest
service_module.const_get(:Client).new(&block)
end

##
# Create a new client object for Executions.
#
Expand Down
19 changes: 19 additions & 0 deletions google-cloud-run-client/test/google/cloud/run/client_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,25 @@ def universe_domain
end
end

def test_builds_grpc
Gapic::ServiceStub.stub :new, DummyStub.new do
grpc_channel = GRPC::Core::Channel.new "localhost:8888", nil, :this_channel_is_insecure
client = Google::Cloud::Run.builds transport: :grpc do |config|
config.credentials = grpc_channel
end
assert_kind_of Google::Cloud::Run::V2::Builds::Client, client
end
end

def test_builds_rest
Gapic::Rest::ClientStub.stub :new, DummyStub.new do
client = Google::Cloud::Run.builds transport: :rest do |config|
config.credentials = :dummy_credentials
end
assert_kind_of Google::Cloud::Run::V2::Builds::Rest::Client, client
end
end

def test_executions_grpc
Gapic::ServiceStub.stub :new, DummyStub.new do
grpc_channel = GRPC::Core::Channel.new "localhost:8888", nil, :this_channel_is_insecure
Expand Down
22 changes: 0 additions & 22 deletions owl-bot-staging/google-cloud-run-client/.gitignore

This file was deleted.

17 changes: 0 additions & 17 deletions owl-bot-staging/google-cloud-run-client/.repo-metadata.json

This file was deleted.

39 changes: 0 additions & 39 deletions owl-bot-staging/google-cloud-run-client/.rubocop.yml

This file was deleted.

28 changes: 0 additions & 28 deletions owl-bot-staging/google-cloud-run-client/.toys.rb

This file was deleted.

11 changes: 0 additions & 11 deletions owl-bot-staging/google-cloud-run-client/.yardopts

This file was deleted.

122 changes: 0 additions & 122 deletions owl-bot-staging/google-cloud-run-client/AUTHENTICATION.md

This file was deleted.

2 changes: 0 additions & 2 deletions owl-bot-staging/google-cloud-run-client/CHANGELOG.md

This file was deleted.

13 changes: 0 additions & 13 deletions owl-bot-staging/google-cloud-run-client/Gemfile

This file was deleted.

Loading

0 comments on commit 5eaeae1

Please sign in to comment.