Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs:fixed formatting of some documentation #27403

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading