Skip to content
Snippets Groups Projects

Add Google Cloud Compute services

Merged Pedro Pombeiro requested to merge pedropombeiro/438315/add-services into master
7 files
+ 64
51
Compare changes
  • Side-by-side
  • Inline
Files
7
@@ -2,10 +2,13 @@
@@ -2,10 +2,13 @@
module GoogleCloudPlatform
module GoogleCloudPlatform
module Compute
module Compute
class BaseService
class BaseService < ::BaseProjectService
include BaseServiceUtility
include BaseServiceUtility
include Gitlab::Utils::StrongMemoize
include Gitlab::Utils::StrongMemoize
 
VALID_ORDER_BY_COLUMNS = %w[creationTimestamp name].freeze
 
VALID_ORDER_BY_DIRECTIONS = %w[asc desc].freeze
 
SAAS_ONLY = "This is a SaaS-only feature that can't run here"
SAAS_ONLY = "This is a SaaS-only feature that can't run here"
FEATURE_FLAG_NOT_ENABLED = 'Feature flag not enabled'
FEATURE_FLAG_NOT_ENABLED = 'Feature flag not enabled'
ACCESS_DENIED = 'Access denied'
ACCESS_DENIED = 'Access denied'
@@ -17,7 +20,7 @@ class BaseService
@@ -17,7 +20,7 @@ class BaseService
attr_accessor :project, :current_user
attr_accessor :project, :current_user
def initialize(project:, current_user: nil)
def initialize(project:, current_user:)
@project = project
@project = project
@current_user = current_user
@current_user = current_user
end
end
@@ -46,6 +49,17 @@ def allowed?
@@ -46,6 +49,17 @@ def allowed?
can?(current_user, :read_runner_cloud_provisioning_options, project)
can?(current_user, :read_runner_cloud_provisioning_options, project)
end
end
 
def valid_order_by?(value)
 
return true if value.blank?
 
 
column, direction = value.split(' ')
 
 
return false unless column.in?(VALID_ORDER_BY_COLUMNS)
 
return false unless direction.in?(VALID_ORDER_BY_DIRECTIONS)
 
 
true
 
end
 
def client
def client
::GoogleCloudPlatform::Compute::Client.new(
::GoogleCloudPlatform::Compute::Client.new(
project: project,
project: project,
@@ -56,11 +70,11 @@ def client
@@ -56,11 +70,11 @@ def client
end
end
def gcp_project_id
def gcp_project_id
project_integration&.artifact_registry_project_id
project_integration.artifact_registry_project_id
end
end
def gcp_wlif
def gcp_wlif
project_integration&.wlif
project_integration.wlif
end
end
def project_integration
def project_integration
Loading