Skip to content

Commit

Permalink
feat!: removed the nonfunctional GatewayService and replaced it with …
Browse files Browse the repository at this point in the history
…the GatewayControl service (#26977)

Release-As: 1.1.0
  • Loading branch information
gcf-owl-bot[bot] authored Aug 22, 2024
1 parent c2ffba1 commit f74171d
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 19 deletions.
6 changes: 3 additions & 3 deletions google-cloud-gke_connect-gateway/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/gke_connect/gateway"

client = Google::Cloud::GkeConnect::Gateway.gateway_service do |config|
client = Google::Cloud::GkeConnect::Gateway.gateway_control do |config|
config.credentials = "path/to/credentialfile.json"
end
```
Expand All @@ -70,7 +70,7 @@ Google::Cloud::GkeConnect::Gateway.configure do |config|
config.credentials = "path/to/credentialfile.json"
end

client = Google::Cloud::GkeConnect::Gateway.gateway_service
client = Google::Cloud::GkeConnect::Gateway.gateway_control
```

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

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

client = Google::Cloud::GkeConnect::Gateway.gateway_service
client = Google::Cloud::GkeConnect::Gateway.gateway_control
```

### Local ADC file
Expand Down
4 changes: 2 additions & 2 deletions google-cloud-gke_connect-gateway/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 GKE_CONNECT_GATEWAY_TEST_PROJECT=test123 GKE_CONNECT_GATEWAY_TEST_KEYFILE=/path/to/keyfile.json rake acceptance"
end
require "google/cloud/gke_connect/gateway/v1beta1/gateway_service/credentials"
::Google::Cloud::GkeConnect::Gateway::V1beta1::GatewayService::Credentials.env_vars.each do |path|
require "google/cloud/gke_connect/gateway/v1beta1/gateway_control/credentials"
::Google::Cloud::GkeConnect::Gateway::V1beta1::GatewayControl::Credentials.env_vars.each do |path|
ENV[path] = nil
end
ENV["GKE_CONNECT_GATEWAY_PROJECT"] = project
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,36 +47,32 @@ module Cloud
module GkeConnect
module Gateway
##
# Create a new client object for GatewayService.
# Create a new client object for GatewayControl.
#
# By default, this returns an instance of
# [Google::Cloud::GkeConnect::Gateway::V1beta1::GatewayService::Client](https://cloud.google.com/ruby/docs/reference/google-cloud-gke_connect-gateway-v1beta1/latest/Google-Cloud-GkeConnect-Gateway-V1beta1-GatewayService-Client)
# [Google::Cloud::GkeConnect::Gateway::V1beta1::GatewayControl::Client](https://cloud.google.com/ruby/docs/reference/google-cloud-gke_connect-gateway-v1beta1/latest/Google-Cloud-GkeConnect-Gateway-V1beta1-GatewayControl-Client)
# for a gRPC client for version V1beta1 of the API.
# However, you can specify a different API version by passing it in the
# `version` parameter. If the GatewayService service is
# `version` parameter. If the GatewayControl service is
# supported by that API version, and the corresponding gem is available, the
# appropriate versioned client will be returned.
#
# ## About GatewayService
# ## About GatewayControl
#
# Gateway service is a public API which works as a Kubernetes resource model
# proxy between end users and registered Kubernetes clusters. Each RPC in this
# service matches with an HTTP verb. End user will initiate kubectl commands
# against the Gateway service, and Gateway service will forward user requests
# to clusters.
# GatewayControl is the control plane API for Connect Gateway.
#
# @param version [::String, ::Symbol] The API version to connect to. Optional.
# Defaults to `:v1beta1`.
# @return [::Object] A client object for the specified version.
#
def self.gateway_service version: :v1beta1, &block
def self.gateway_control version: :v1beta1, &block
require "google/cloud/gke_connect/gateway/#{version.to_s.downcase}"

package_name = Google::Cloud::GkeConnect::Gateway
.constants
.select { |sym| sym.to_s.downcase == version.to_s.downcase.tr("_", "") }
.first
service_module = Google::Cloud::GkeConnect::Gateway.const_get(package_name).const_get(:GatewayService)
service_module = Google::Cloud::GkeConnect::Gateway.const_get(package_name).const_get(:GatewayControl)
service_module.const_get(:Client).new(&block)
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ def universe_domain
end
end

def test_gateway_service_grpc
def test_gateway_control_grpc
Gapic::ServiceStub.stub :new, DummyStub.new do
grpc_channel = GRPC::Core::Channel.new "localhost:8888", nil, :this_channel_is_insecure
client = Google::Cloud::GkeConnect::Gateway.gateway_service do |config|
client = Google::Cloud::GkeConnect::Gateway.gateway_control do |config|
config.credentials = grpc_channel
end
assert_kind_of Google::Cloud::GkeConnect::Gateway::V1beta1::GatewayService::Client, client
assert_kind_of Google::Cloud::GkeConnect::Gateway::V1beta1::GatewayControl::Client, client
end
end
end

0 comments on commit f74171d

Please sign in to comment.