2022-05-07 20:08:51 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class Projects::GoogleCloud::GcpRegionsController < Projects::GoogleCloud::BaseController
|
|
|
|
# filtered list of GCP cloud run locations...
|
|
|
|
# ...that have domain mapping available
|
|
|
|
# Source https://cloud.google.com/run/docs/locations 2022-01-30
|
|
|
|
AVAILABLE_REGIONS = %w[asia-east1 asia-northeast1 asia-southeast1 europe-north1 europe-west1 europe-west4 us-central1 us-east1 us-east4 us-west1].freeze
|
|
|
|
|
2022-08-13 15:12:31 +05:30
|
|
|
GCP_REGION_CI_VAR_KEY = 'GCP_REGION'
|
|
|
|
|
2022-05-07 20:08:51 +05:30
|
|
|
def index
|
|
|
|
js_data = {
|
|
|
|
availableRegions: AVAILABLE_REGIONS,
|
|
|
|
refs: refs,
|
2022-08-13 15:12:31 +05:30
|
|
|
cancelPath: project_google_cloud_configuration_path(project)
|
2022-05-07 20:08:51 +05:30
|
|
|
}
|
2023-01-13 00:05:48 +05:30
|
|
|
@js_data = Gitlab::Json.dump(js_data)
|
2022-10-11 01:57:18 +05:30
|
|
|
track_event(:render_form)
|
2022-05-07 20:08:51 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
def create
|
|
|
|
permitted_params = params.permit(:ref, :gcp_region)
|
2022-10-11 01:57:18 +05:30
|
|
|
GoogleCloud::GcpRegionAddOrReplaceService.new(project).execute(permitted_params[:ref], permitted_params[:gcp_region])
|
|
|
|
track_event(:configure_region)
|
2022-08-13 15:12:31 +05:30
|
|
|
redirect_to project_google_cloud_configuration_path(project), notice: _('GCP region configured')
|
2022-05-07 20:08:51 +05:30
|
|
|
end
|
|
|
|
end
|