Commit b38b8897 authored by Sri's avatar Sri

Introduce Project :: Infra :: Google Cloud page

- Setup route `Project :: Infrastructure :: Google Cloud`
- Behind feature flag `incubation_5mp_google_cloud`
- For maintainers only: project policy `:manage_project_google_cloud`
- Mockups for:
	- Google Cloud :: Service Accounts
	- Google Cloud :: Deployments
- Specs
    - `Google Cloud` link in `Project` sidebar under `Infrastructure`
    - `projects/-/google_cloud` can only be accessed by maintainers
parent 369af359
# frozen_string_literal: true
class Projects::GoogleCloudController < Projects::ApplicationController
before_action :authorize_can_manage_google_cloud_deployments!
feature_category :release_orchestration
def index
end
private
def authorize_can_manage_google_cloud_deployments!
access_denied! unless can?(current_user, :manage_project_google_cloud, project)
end
end
...@@ -438,6 +438,7 @@ class ProjectPolicy < BasePolicy ...@@ -438,6 +438,7 @@ class ProjectPolicy < BasePolicy
enable :destroy_freeze_period enable :destroy_freeze_period
enable :admin_feature_flags_client enable :admin_feature_flags_client
enable :update_runners_registration_token enable :update_runners_registration_token
enable :manage_project_google_cloud
end end
rule { public_project & metrics_dashboard_allowed }.policy do rule { public_project & metrics_dashboard_allowed }.policy do
......
- breadcrumb_title _('Google Cloud')
- page_title _('Google Cloud')
- @content_class = "limit-container-width" unless fluid_layout
#js-google-cloud
%h1.gl-font-size-h1 Google Cloud
%section#js-section-google-cloud-service-accounts
%h2.gl-font-size-h2 Service Accounts
%p= _('Service Accounts keys are required to authorize GitLab to deploy your Google Cloud project.')
%table.table.b-table.gl-table
%thead
%tr
%th Environment
%th GCP Project ID
%th Service Account Key
%tbody
%tr
%td *
%td serving-salutes-453
%td .....
%tr
%td production
%td crimson-corey-234
%td .....
%tr
%td review/*
%td roving-river-379
%td .....
%a.gl-button.btn.btn-primary= _('Add new service account')
%br
%section#js-section-google-cloud-deployments
.row.row-fluid
.col-lg-4
%h2.gl-font-size-h2 Deployments
%p= _('Google Cloud offers several deployment targets. Select the one most suitable for your project.')
%p
= _('Deployments to Google Kubernetes Engine can be ')
%a{ href: '#' }= _('managed')
= _('in Infrastructure :: Kubernetes clusters')
.col-lg-8
%br
.gl-card.gl-mb-6
.gl-card-body
.gl-display-flex.gl-align-items-baseline
%strong.gl-font-lg App Engine
.gl-ml-auto.gl-text-gray-500 Disabled
%p= _('App Engine description and apps that are suitable for this deployment target')
%button.gl-button.btn.btn-default= _('Configure via Merge Request')
.gl-card.gl-mb-6
.gl-card-body
.gl-display-flex.gl-align-items-baseline
%strong.gl-font-lg Cloud Functions
.gl-ml-auto.gl-text-gray-500 Disabled
%p= _('Cloud Functions description and apps that are suitable for this deployment target')
%button.gl-button.btn.btn-default= _('Configure via Merge Request')
.gl-card.gl-mb-6
.gl-card-body
.gl-display-flex.gl-align-items-baseline
%strong.gl-font-lg Cloud Run
.gl-ml-auto.gl-text-gray-500 Disabled
%p= _('Cloud Run description and apps that are suitable for this deployment target')
%button.gl-button.btn.btn-default= _('Configure via Merge Request')
---
name: incubation_5mp_google_cloud
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/70715
rollout_issue_url:
milestone: '14.3'
type: development
group: group::incubation
default_enabled: false
...@@ -311,6 +311,8 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do ...@@ -311,6 +311,8 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
resources :terraform, only: [:index] resources :terraform, only: [:index]
resources :google_cloud, only: [:index]
resources :environments, except: [:destroy] do resources :environments, except: [:destroy] do
member do member do
post :stop post :stop
......
...@@ -16,6 +16,7 @@ RSpec.describe 'Project navbar' do ...@@ -16,6 +16,7 @@ RSpec.describe 'Project navbar' do
insert_package_nav(_('Infrastructure')) insert_package_nav(_('Infrastructure'))
insert_infrastructure_registry_nav insert_infrastructure_registry_nav
insert_infrastructure_google_cloud_nav
end end
context 'when issue analytics is available' do context 'when issue analytics is available' do
......
...@@ -11,6 +11,7 @@ module Sidebars ...@@ -11,6 +11,7 @@ module Sidebars
add_item(kubernetes_menu_item) add_item(kubernetes_menu_item)
add_item(serverless_menu_item) add_item(serverless_menu_item)
add_item(terraform_menu_item) add_item(terraform_menu_item)
add_item(google_cloud_menu_item)
true true
end end
...@@ -87,6 +88,22 @@ module Sidebars ...@@ -87,6 +88,22 @@ module Sidebars
item_id: :terraform item_id: :terraform
) )
end end
def google_cloud_menu_item
feature_is_enabled = Feature.enabled?(:incubation_5mp_google_cloud)
user_has_permissions = can?(context.current_user, :manage_project_google_cloud, context.project)
unless feature_is_enabled && user_has_permissions
return ::Sidebars::NilMenuItem.new(item_id: :incubation_5mp_google_cloud)
end
::Sidebars::MenuItem.new(
title: _('Google Cloud'),
link: project_google_cloud_index_path(context.project),
active_routes: {},
item_id: :google_cloud
)
end
end end
end end
end end
......
...@@ -2051,6 +2051,9 @@ msgstr "" ...@@ -2051,6 +2051,9 @@ msgstr ""
msgid "Add new directory" msgid "Add new directory"
msgstr "" msgstr ""
msgid "Add new service account"
msgstr ""
msgid "Add or remove previously merged commits" msgid "Add or remove previously merged commits"
msgstr "" msgstr ""
...@@ -3950,6 +3953,9 @@ msgstr "" ...@@ -3950,6 +3953,9 @@ msgstr ""
msgid "Any namespace" msgid "Any namespace"
msgstr "" msgstr ""
msgid "App Engine description and apps that are suitable for this deployment target"
msgstr ""
msgid "App ID" msgid "App ID"
msgstr "" msgstr ""
...@@ -7160,6 +7166,12 @@ msgstr "" ...@@ -7160,6 +7166,12 @@ msgstr ""
msgid "Closes this %{quick_action_target}." msgid "Closes this %{quick_action_target}."
msgstr "" msgstr ""
msgid "Cloud Functions description and apps that are suitable for this deployment target"
msgstr ""
msgid "Cloud Run description and apps that are suitable for this deployment target"
msgstr ""
msgid "Cloud licenses can not be removed." msgid "Cloud licenses can not be removed."
msgstr "" msgstr ""
...@@ -8599,6 +8611,9 @@ msgstr "" ...@@ -8599,6 +8611,9 @@ msgstr ""
msgid "Configure the way a user creates a new account." msgid "Configure the way a user creates a new account."
msgstr "" msgstr ""
msgid "Configure via Merge Request"
msgstr ""
msgid "Configure which lists are shown for anyone who visits this board" msgid "Configure which lists are shown for anyone who visits this board"
msgstr "" msgstr ""
...@@ -11371,6 +11386,9 @@ msgstr "" ...@@ -11371,6 +11386,9 @@ msgstr ""
msgid "Deployments" msgid "Deployments"
msgstr "" msgstr ""
msgid "Deployments to Google Kubernetes Engine can be "
msgstr ""
msgid "Deployments|%{deployments} environment impacted." msgid "Deployments|%{deployments} environment impacted."
msgid_plural "Deployments|%{deployments} environments impacted." msgid_plural "Deployments|%{deployments} environments impacted."
msgstr[0] "" msgstr[0] ""
...@@ -15818,6 +15836,12 @@ msgstr "" ...@@ -15818,6 +15836,12 @@ msgstr ""
msgid "Goal of the changes and what reviewers should be aware of" msgid "Goal of the changes and what reviewers should be aware of"
msgstr "" msgstr ""
msgid "Google Cloud"
msgstr ""
msgid "Google Cloud offers several deployment targets. Select the one most suitable for your project."
msgstr ""
msgid "Google authentication is not %{link_start}properly configured%{link_end}. Ask your GitLab administrator if you want to use this service." msgid "Google authentication is not %{link_start}properly configured%{link_end}. Ask your GitLab administrator if you want to use this service."
msgstr "" msgstr ""
...@@ -30755,6 +30779,9 @@ msgstr "" ...@@ -30755,6 +30779,9 @@ msgstr ""
msgid "Service" msgid "Service"
msgstr "" msgstr ""
msgid "Service Accounts keys are required to authorize GitLab to deploy your Google Cloud project."
msgstr ""
msgid "Service Desk" msgid "Service Desk"
msgstr "" msgstr ""
...@@ -40061,6 +40088,9 @@ msgstr "" ...@@ -40061,6 +40088,9 @@ msgstr ""
msgid "in" msgid "in"
msgstr "" msgstr ""
msgid "in Infrastructure :: Kubernetes clusters"
msgstr ""
msgid "in all GitLab" msgid "in all GitLab"
msgstr "" msgstr ""
...@@ -40216,6 +40246,9 @@ msgstr "" ...@@ -40216,6 +40246,9 @@ msgstr ""
msgid "log in" msgid "log in"
msgstr "" msgstr ""
msgid "managed"
msgstr ""
msgid "manual" msgid "manual"
msgstr "" msgstr ""
......
...@@ -18,6 +18,7 @@ RSpec.describe 'Project navbar' do ...@@ -18,6 +18,7 @@ RSpec.describe 'Project navbar' do
stub_config(registry: { enabled: false }) stub_config(registry: { enabled: false })
insert_package_nav(_('Infrastructure')) insert_package_nav(_('Infrastructure'))
insert_infrastructure_registry_nav insert_infrastructure_registry_nav
insert_infrastructure_google_cloud_nav
end end
it_behaves_like 'verified navigation bar' do it_behaves_like 'verified navigation bar' do
......
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Projects::GoogleCloudController do
let_it_be(:project) { create(:project, :public) }
describe 'GET index' do
let_it_be(:url) { "#{project_google_cloud_index_path(project)}" }
let(:subject) { get url }
context 'when user is authorized' do
let(:user) { project.creator }
before do
sign_in(user)
subject
end
it 'renders content' do
expect(response).to be_successful
end
end
context 'when user is unauthorized' do
let(:user) { create(:user) }
before do
project.add_guest(user)
sign_in(user)
subject
end
it 'shows 404' do
expect(response).to have_gitlab_http_status(:not_found)
end
end
context 'when no user is present' do
before do
subject
end
it 'shows 404' do
expect(response).to have_gitlab_http_status(:not_found)
end
end
end
end
...@@ -52,4 +52,12 @@ module NavbarStructureHelper ...@@ -52,4 +52,12 @@ module NavbarStructureHelper
new_sub_nav_item_name: _('Infrastructure Registry') new_sub_nav_item_name: _('Infrastructure Registry')
) )
end end
def insert_infrastructure_google_cloud_nav
insert_after_sub_nav_item(
_('Terraform'),
within: _('Infrastructure'),
new_sub_nav_item_name: _('Google Cloud')
)
end
end end
...@@ -580,6 +580,23 @@ RSpec.describe 'layouts/nav/sidebar/_project' do ...@@ -580,6 +580,23 @@ RSpec.describe 'layouts/nav/sidebar/_project' do
end end
end end
end end
describe 'Google Cloud' do
it 'has a link to the google cloud page' do
render
expect(rendered).to have_link('Google Cloud', href: project_google_cloud_index_path(project))
end
describe 'when the user does not have access' do
let(:user) { nil }
it 'does not have a link to the google cloud page' do
render
expect(rendered).not_to have_link('Google Cloud')
end
end
end
end end
describe 'Packages and Registries' do describe 'Packages and Registries' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment