summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorKamil Trzciński <ayufan@ayufan.eu>2017-12-04 19:01:12 +0000
committerKamil Trzciński <ayufan@ayufan.eu>2017-12-04 19:01:12 +0000
commitc7940733b410d5f55bbe150dd9b44453fdc9a731 (patch)
tree498c28be5c527a0c41d4fb6dddea2283b9415d1c /lib
parent08125a6bd549a852ff0bb39f274081bb71ca9ae9 (diff)
parent9710015651351725b9cb84bfe658f293e413bf06 (diff)
downloadgitlab-ce-c7940733b410d5f55bbe150dd9b44453fdc9a731.tar.gz
Merge branch 'user-agent-gke-api' into 'master'
Use custom User-Agent header in GCP Client requests Closes #40583 See merge request gitlab-org/gitlab-ce!15705
Diffstat (limited to 'lib')
-rw-r--r--lib/google_api/cloud_platform/client.rb12
1 files changed, 9 insertions, 3 deletions
diff --git a/lib/google_api/cloud_platform/client.rb b/lib/google_api/cloud_platform/client.rb
index 9242cbe840c..b0563fb2d69 100644
--- a/lib/google_api/cloud_platform/client.rb
+++ b/lib/google_api/cloud_platform/client.rb
@@ -44,7 +44,7 @@ module GoogleApi
service = Google::Apis::ContainerV1::ContainerService.new
service.authorization = access_token
- service.get_zone_cluster(project_id, zone, cluster_id)
+ service.get_zone_cluster(project_id, zone, cluster_id, options: user_agent_header)
end
def projects_zones_clusters_create(project_id, zone, cluster_name, cluster_size, machine_type:)
@@ -62,14 +62,14 @@ module GoogleApi
}
} )
- service.create_cluster(project_id, zone, request_body)
+ service.create_cluster(project_id, zone, request_body, options: user_agent_header)
end
def projects_zones_operations(project_id, zone, operation_id)
service = Google::Apis::ContainerV1::ContainerService.new
service.authorization = access_token
- service.get_zone_operation(project_id, zone, operation_id)
+ service.get_zone_operation(project_id, zone, operation_id, options: user_agent_header)
end
def parse_operation_id(self_link)
@@ -82,6 +82,12 @@ module GoogleApi
def token_life_time(expires_at)
DateTime.strptime(expires_at, '%s').to_time.utc - Time.now.utc
end
+
+ def user_agent_header
+ Google::Apis::RequestOptions.new.tap do |options|
+ options.header = { 'User-Agent': "GitLab/#{Gitlab::VERSION.match('(\d+\.\d+)').captures.first} (GPN:GitLab;)" }
+ end
+ end
end
end
end