summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKamil Trzciński <ayufan@ayufan.eu>2018-09-12 13:38:47 +0200
committerKamil Trzciński <ayufan@ayufan.eu>2018-09-12 13:38:47 +0200
commit02adbbe1ab12755f925dea2766c290c4b1352417 (patch)
tree19b4cc186c5fede9867c3e03890196e7bd727023
parent7ce5ca385e75265feb84abbfaefe738b55016c28 (diff)
downloadgitlab-ce-02adbbe1ab12755f925dea2766c290c4b1352417.tar.gz
Add Knative interface (WIP)
-rw-r--r--app/controllers/projects/knative_controller.rb8
-rw-r--r--app/helpers/projects_helper.rb1
-rw-r--r--app/views/layouts/nav/sidebar/_project.html.haml10
-rw-r--r--app/views/projects/knative/_list.html.haml15
-rw-r--r--app/views/projects/knative/_use.html.haml23
-rw-r--r--app/views/projects/knative/index.html.haml12
-rw-r--r--config/routes/project.rb2
-rw-r--r--lib/gitlab/kubernetes/kube_client.rb3
8 files changed, 71 insertions, 3 deletions
diff --git a/app/controllers/projects/knative_controller.rb b/app/controllers/projects/knative_controller.rb
new file mode 100644
index 00000000000..e77e4b0f56c
--- /dev/null
+++ b/app/controllers/projects/knative_controller.rb
@@ -0,0 +1,8 @@
+class Projects::FeatureFlagsController < Projects::ApplicationController
+ respond_to :html
+
+ def index
+ @feature_flags = project.project_feature_flags
+ @unleash_instanceid = project.project_feature_flags_access_tokens.first&.token || project.project_feature_flags_access_tokens.create!.token
+ end
+end
diff --git a/app/helpers/projects_helper.rb b/app/helpers/projects_helper.rb
index 89fee06ee77..ca8361b0276 100644
--- a/app/helpers/projects_helper.rb
+++ b/app/helpers/projects_helper.rb
@@ -300,6 +300,7 @@ module ProjectsHelper
def tab_ability_map
{
environments: :read_environment,
+ knative: :read_cluster,
milestones: :read_milestone,
snippets: :read_project_snippet,
settings: :admin_project,
diff --git a/app/views/layouts/nav/sidebar/_project.html.haml b/app/views/layouts/nav/sidebar/_project.html.haml
index 30e0e9fca27..2671fe4160d 100644
--- a/app/views/layouts/nav/sidebar/_project.html.haml
+++ b/app/views/layouts/nav/sidebar/_project.html.haml
@@ -195,7 +195,7 @@
= _('Charts')
- if project_nav_tab? :operations
- = nav_link(controller: [:environments, :clusters, :user, :gcp]) do
+ = nav_link(controller: [:environments, :clusters, :user, :gcp, :knative]) do
= link_to metrics_project_environments_path(@project), class: 'shortcuts-operations' do
.nav-icon-container
= sprite_icon('cloud-gear')
@@ -203,7 +203,7 @@
= _('Operations')
%ul.sidebar-sub-level-items
- = nav_link(controller: [:environments, :clusters, :user, :gcp], html_options: { class: "fly-out-top-item" } ) do
+ = nav_link(controller: [:environments, :clusters, :user, :gcp, :knative], html_options: { class: "fly-out-top-item" } ) do
= link_to metrics_project_environments_path(@project) do
%strong.fly-out-top-item-name
= _('Operations')
@@ -215,6 +215,12 @@
%span
= _('Metrics')
+ - if project_nav_tab? :knative
+ = nav_link(controller: :knative) do
+ = link_to project_knative_path(@project), title: _('Knative'), class: 'shortcuts-metrics' do
+ %span
+ = _('Knative')
+
= nav_link(controller: :environments, action: [:index, :folder, :show, :new, :edit, :create, :update, :stop, :terminal]) do
= link_to project_environments_path(@project), title: _('Environments'), class: 'shortcuts-environments' do
%span
diff --git a/app/views/projects/knative/_list.html.haml b/app/views/projects/knative/_list.html.haml
new file mode 100644
index 00000000000..a8b727d99ff
--- /dev/null
+++ b/app/views/projects/knative/_list.html.haml
@@ -0,0 +1,15 @@
+.card
+ .card-header
+ - @feature_flags = []
+ Knative Functions (#{@feature_flags.count})
+ %ul.content-list.pages-domain-list
+ - @feature_flags.each do |feature_flag|
+ %li.pages-domain-list-item.unstyled
+ = feature_flag.name
+
+ %div.controls.d-none.d-md-block
+ %p
+ - if feature_flag.active?
+ %span.badge.badge-success Enabled
+ - else
+ %span.badge.badge-danger Disabled
diff --git a/app/views/projects/knative/_use.html.haml b/app/views/projects/knative/_use.html.haml
new file mode 100644
index 00000000000..73d1319511d
--- /dev/null
+++ b/app/views/projects/knative/_use.html.haml
@@ -0,0 +1,23 @@
+.card.bg-info
+ .card-header
+ Configure Knative...
+ .card-body
+ %p
+ Learn how to enable knative functions.
+
+ %ol
+ %li
+ = _("Install a compatible with client library")
+ = (_("(checkout the %{link} for information on how to install it).") % { link: "here" }).html_safe
+ %li
+ = _("Specify the following URL during for the library configuration setup:")
+ %code#coordinator_address= "#{root_url(only_path: false)}api/v4/unleash"
+ %li
+ = _("Use the following application name:")
+ %code#registration_token= @project.id
+ %li
+ = _("Use the following application name:")
+ %code#registration_token= @unleash_instanceid
+ %li
+ = _("You can also see all features online:")
+ %code#registration_token= "#{root_url(only_path: false)}api/v4/unleash/features?appname=#{@project.id}&instanceid=#{@unleash_instanceid}"
diff --git a/app/views/projects/knative/index.html.haml b/app/views/projects/knative/index.html.haml
new file mode 100644
index 00000000000..3a11eb562ea
--- /dev/null
+++ b/app/views/projects/knative/index.html.haml
@@ -0,0 +1,12 @@
+- page_title 'Knative'
+
+%h3.page-title.with-button
+ Knative
+
+%p.light
+ With GitLab Knative
+
+%hr.clearfix
+
+= render 'use'
+= render 'list'
diff --git a/config/routes/project.rb b/config/routes/project.rb
index 4021d62b931..a47c6be5d4f 100644
--- a/config/routes/project.rb
+++ b/config/routes/project.rb
@@ -296,6 +296,8 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
namespace :ci do
resource :lint, only: [:show, :create]
end
+
+ resources :knative
end
draw :legacy_builds
diff --git a/lib/gitlab/kubernetes/kube_client.rb b/lib/gitlab/kubernetes/kube_client.rb
index 8312b901524..c05765850dc 100644
--- a/lib/gitlab/kubernetes/kube_client.rb
+++ b/lib/gitlab/kubernetes/kube_client.rb
@@ -16,7 +16,8 @@ module Gitlab
SUPPORTED_API_GROUPS = [
'api',
'apis/rbac.authorization.k8s.io',
- 'apis/extensions'
+ 'apis/extensions',
+ 'apis/serving.knative.dev'
].freeze
# Core API methods delegates to the core api group client