debian-mirror-gitlab/app/controllers/projects/google_cloud/configuration_controller.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

39 lines
1.6 KiB
Ruby
Raw Normal View History

2022-08-13 15:12:31 +05:30
# frozen_string_literal: true
module Projects
module GoogleCloud
class ConfigurationController < Projects::GoogleCloud::BaseController
def index
js_data = {
configurationUrl: project_google_cloud_configuration_path(project),
deploymentsUrl: project_google_cloud_deployments_path(project),
databasesUrl: project_google_cloud_databases_path(project),
serviceAccounts: ::GoogleCloud::ServiceAccountsService.new(project).find_for_project,
createServiceAccountUrl: project_google_cloud_service_accounts_path(project),
2023-07-09 08:55:56 +05:30
emptyIllustrationUrl:
ActionController::Base.helpers.image_path('illustrations/empty-state/empty-pipeline-md.svg'),
2022-08-13 15:12:31 +05:30
configureGcpRegionsUrl: project_google_cloud_gcp_regions_path(project),
gcpRegions: gcp_regions,
revokeOauthUrl: revoke_oauth_url
}
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_page)
2022-08-13 15:12:31 +05:30
end
private
def gcp_regions
params = { key: Projects::GoogleCloud::GcpRegionsController::GCP_REGION_CI_VAR_KEY }
list = ::Ci::VariablesFinder.new(project, params).execute
list.map { |variable| { gcp_region: variable.value, environment: variable.environment_scope } }
end
def revoke_oauth_url
google_token_valid = GoogleApi::CloudPlatform::Client.new(token_in_session, nil)
.validate_token(expires_at_in_session)
google_token_valid ? project_google_cloud_revoke_oauth_index_path(project) : nil
end
end
end
end