diff --git a/front/config/runtime.exs b/front/config/runtime.exs
index beb2931cb..ccb79e5ee 100644
--- a/front/config/runtime.exs
+++ b/front/config/runtime.exs
@@ -131,14 +131,11 @@ config :front,
config :front, :on_prem?, on_prem?
-if on_prem? do
- config :front,
- feature_provider:
- {FeatureProvider.YamlProvider,
- [yaml_path: System.get_env("FEATURE_YAML_PATH"), agent_name: :feature_provider_agent]}
- config :front, JobPage.Api.Loghub, timeout: :timer.minutes(2)
-else
+edition = System.get_env("EDITION", "") |> String.trim() |> String.downcase()
+is_saas? = !(on_prem? or edition in ["ce", "ee"])
+
+if is_saas? do
config :front,
feature_provider:
{Front.FeatureHubProvider,
@@ -147,6 +144,13 @@ else
{FeatureProvider.CachexCache,
name: :feature_provider_cache, ttl_ms: :timer.minutes(10)}
]}
+else
+ config :front,
+ feature_provider:
+ {FeatureProvider.YamlProvider,
+ [yaml_path: System.get_env("FEATURE_YAML_PATH"), agent_name: :feature_provider_agent]}
+
+ config :front, JobPage.Api.Loghub, timeout: :timer.minutes(2)
end
if System.get_env("AMQP_URL") != nil do
@@ -190,6 +194,4 @@ config :front,
:single_tenant,
System.get_env("SINGLE_TENANT") == "true"
-config :front,
- :edition,
- System.get_env("EDITION", "") |> String.trim() |> String.downcase()
+config :front, :edition, edition
diff --git a/front/helm/templates/job-page.yaml b/front/helm/templates/job-page.yaml
index 0b7e3d2a1..72703e3b3 100644
--- a/front/helm/templates/job-page.yaml
+++ b/front/helm/templates/job-page.yaml
@@ -113,8 +113,6 @@ spec:
{{- end }}
- name: METRICS_SERVICE
value: "front"
- - name: ON_PREM
- value: "true"
- name: FEATURE_YAML_PATH
value: {{ .Values.featureFlags.mountPath | quote }}
- name: GETTING_STARTED_YAML_PATH
diff --git a/front/helm/templates/project-page.yaml b/front/helm/templates/project-page.yaml
index c7419634e..87141e3f2 100644
--- a/front/helm/templates/project-page.yaml
+++ b/front/helm/templates/project-page.yaml
@@ -139,8 +139,6 @@ spec:
{{- end }}
- name: METRICS_SERVICE
value: "front"
- - name: ON_PREM
- value: "true"
- name: START_TELEMETRY
value: {{ .Values.global.telemetry.enabled | quote }}
- name: TELEMETRY_CRON
diff --git a/front/helm/templates/ui-cache-reactor.yaml b/front/helm/templates/ui-cache-reactor.yaml
index e83e040fd..a686b8f92 100644
--- a/front/helm/templates/ui-cache-reactor.yaml
+++ b/front/helm/templates/ui-cache-reactor.yaml
@@ -95,8 +95,6 @@ spec:
- name: METRICS_NAMESPACE
value: {{ .Values.global.statsd.metricsNamespace }}
{{- end }}
- - name: ON_PREM
- value: "true"
- name: FEATURE_YAML_PATH
value: {{ .Values.featureFlags.mountPath | quote }}
- name: GETTING_STARTED_YAML_PATH
diff --git a/front/lib/front.ex b/front/lib/front.ex
index dbc3bb0cf..034024070 100644
--- a/front/lib/front.ex
+++ b/front/lib/front.ex
@@ -35,4 +35,12 @@ defmodule Front do
def os? do
ee?() || ce?()
end
+
+ @doc """
+ Check if we're running on saas or not
+ """
+ @spec saas?() :: boolean()
+ def saas? do
+ !(on_prem?() or os?())
+ end
end
diff --git a/front/lib/front/clients/billing.ex b/front/lib/front/clients/billing.ex
index bc6a003a8..2865c6765 100644
--- a/front/lib/front/clients/billing.ex
+++ b/front/lib/front/clients/billing.ex
@@ -314,26 +314,26 @@ defmodule Front.Clients.Billing do
defp call_grpc(error = {:error, err}, _, _, _, _, _) do
Logger.error("""
- Unexpected error when connecting to Velocity: #{inspect(err)}
+ Unexpected error when connecting to Billing: #{inspect(err)}
""")
error
end
defp call_grpc({:ok, channel}, module, function_name, request, metadata, timeout) do
- if Front.on_prem?() do
- {:error, "Billing service is not running on on-prem instance"}
- else
+ if Front.saas?() do
apply(module, function_name, [channel, request, [metadata: metadata, timeout: timeout]])
+ else
+ {:error, "Billing service is running only on saas instance"}
end
end
defp channel do
- if Front.on_prem?() do
- {:error, "Billing service is not running on on-prem instance"}
- else
+ if Front.saas?() do
Application.fetch_env!(:front, :billing_api_grpc_endpoint)
|> GRPC.Stub.connect()
+ else
+ {:error, "Billing service is running only on saas instance"}
end
end
diff --git a/front/lib/front/layout/cache_invalidator.ex b/front/lib/front/layout/cache_invalidator.ex
index 6362e5e9d..b72dbbf3b 100644
--- a/front/lib/front/layout/cache_invalidator.ex
+++ b/front/lib/front/layout/cache_invalidator.ex
@@ -314,7 +314,7 @@ defmodule Front.Layout.CacheInvalidator do
end
def invalidate_billing(org_id) do
- if not Front.on_prem?() do
+ if Front.saas?() do
Front.Clients.Billing.invalidate_cache(:list_spendings, %{org_id: org_id})
Front.Clients.Billing.invalidate_cache(:current_spending, %{org_id: org_id})
Front.Clients.Billing.invalidate_cache(:credits_usage, %{org_id: org_id})
diff --git a/front/lib/front/models/organization_onboarding.ex b/front/lib/front/models/organization_onboarding.ex
index adf3335cb..1b3dfe1e7 100644
--- a/front/lib/front/models/organization_onboarding.ex
+++ b/front/lib/front/models/organization_onboarding.ex
@@ -125,9 +125,7 @@ defmodule Front.Models.OrganizationOnboarding do
@spec validate_billing(model :: t()) :: :ok | {:error, String.t()}
defp validate_billing(model) do
- if Front.on_prem?() do
- :ok
- else
+ if Front.saas?() do
BillingClient.can_setup_organization(%{
owner_id: model.user_id
})
@@ -136,6 +134,8 @@ defmodule Front.Models.OrganizationOnboarding do
{:ok, %{allowed: false, errors: messages}} -> {:error, Enum.join(messages, ", ")}
{:error, _} -> {:error, "Account check failed"}
end
+ else
+ :ok
end
end
diff --git a/front/lib/front_web/controllers/project_onboarding_controller.ex b/front/lib/front_web/controllers/project_onboarding_controller.ex
index cc9df56b6..f44063ddd 100644
--- a/front/lib/front_web/controllers/project_onboarding_controller.ex
+++ b/front/lib/front_web/controllers/project_onboarding_controller.ex
@@ -630,6 +630,7 @@ defmodule FrontWeb.ProjectOnboardingController do
) do
project_onboarding_path(conn, :onboarding_index, project.name, [""])
else
+ # TODO: check with Amir
if Front.on_prem?() do
if Models.Project.file_exists?(project.id, project.initial_pipeline_file) do
project_onboarding_path(conn, :existing_configuration, project.name)
diff --git a/front/lib/front_web/templates/account/show.html.eex b/front/lib/front_web/templates/account/show.html.eex
index f435cb70c..55def6397 100644
--- a/front/lib/front_web/templates/account/show.html.eex
+++ b/front/lib/front_web/templates/account/show.html.eex
@@ -27,25 +27,25 @@
<%= case {@user.github_scope, @user.github_login} do %>
<% {:NONE, nil} -> %>
Not Connected
- <%= unless Front.on_prem?() do %>
-
- <%= link "Grant public access…", to: account_path(@conn, :update_repo_scope, "github", [access_level: :public]), method: :post %>
- <%= link "Grant private access…", to: account_path(@conn, :update_repo_scope, "github", [access_level: :private]), method: :post %>
-
+ <%= if Front.saas?() do %>
+
+ <%= link "Grant public access…", to: account_path(@conn, :update_repo_scope, "github", [access_level: :public]), method: :post %>
+ <%= link "Grant private access…", to: account_path(@conn, :update_repo_scope, "github", [access_level: :private]), method: :post %>
+
<% else %>
-
- <%= link "Connect…", to: account_path(@conn, :update_repo_scope, "github", [access_level: :email]), method: :post %>
-
+
+ <%= link "Connect…", to: account_path(@conn, :update_repo_scope, "github", [access_level: :email]), method: :post %>
+
<% end %>
<% {:NONE, _} -> %>
Not Connected
·
@<%= @user.github_login %>
- <%= unless Front.on_prem?() do %>
-
- <%= link "Grant public access…", to: account_path(@conn, :update_repo_scope, "github", [access_level: :public]), method: :post %>
- <%= link "Grant private access…", to: account_path(@conn, :update_repo_scope, "github", [access_level: :private]), method: :post %>
-
+ <%= if Front.saas?() do %>
+
+ <%= link "Grant public access…", to: account_path(@conn, :update_repo_scope, "github", [access_level: :public]), method: :post %>
+ <%= link "Grant private access…", to: account_path(@conn, :update_repo_scope, "github", [access_level: :private]), method: :post %>
+
<% end %>
<% {:EMAIL, _} -> %>
Connected
@@ -53,11 +53,11 @@
email only
·
@<%= @user.github_login %>
- <%= unless Front.on_prem?() do %>
-
- <%= link "Grant public access…", to: account_path(@conn, :update_repo_scope, "github", [access_level: :public]), method: :post %>
- <%= link "Grant private access…", to: account_path(@conn, :update_repo_scope, "github", [access_level: :private]), method: :post %>
-
+ <%= if Front.saas?() do %>
+
+ <%= link "Grant public access…", to: account_path(@conn, :update_repo_scope, "github", [access_level: :public]), method: :post %>
+ <%= link "Grant private access…", to: account_path(@conn, :update_repo_scope, "github", [access_level: :private]), method: :post %>
+
<% end %>
<% {:PUBLIC, _} -> %>
Connected
@@ -65,10 +65,10 @@
public repositories
·
@<%= @user.github_login %>
- <%= unless Front.on_prem?() do %>
-
- <%= link "Grant private access…", to: account_path(@conn, :update_repo_scope, "github", [access_level: :private]), method: :post %>
-
+ <%= if Front.saas?() do %>
+
+ <%= link "Grant private access…", to: account_path(@conn, :update_repo_scope, "github", [access_level: :private]), method: :post %>
+
<% end %>
<% {:PRIVATE, _} -> %>
Connected
diff --git a/front/lib/front_web/templates/error/404.html.eex b/front/lib/front_web/templates/error/404.html.eex
index cced88e20..8938a7c69 100644
--- a/front/lib/front_web/templates/error/404.html.eex
+++ b/front/lib/front_web/templates/error/404.html.eex
@@ -44,7 +44,7 @@
- <%= if not Front.on_prem?() do %>
+ <%= if Front.saas?() do %>
Product
@@ -72,7 +72,7 @@
<%= if anonymous?(@conn) do %>
Perhaps you need to log in →
<% else %>
- <%= if not Front.on_prem?() do %>
+ <%= if Front.saas?() do %>
<%= if Enum.all?([:user, :project], fn m -> Enum.member?(Map.keys(@conn.assigns), m) end) do %>
<%= if @conn.assigns.user.gitlab_scope == :NONE &&
@conn.assigns.project.integration_type == :GITLAB do %>
diff --git a/front/lib/front_web/templates/layout/_anonymous_page_header.html.eex b/front/lib/front_web/templates/layout/_anonymous_page_header.html.eex
index 3f81d5dd6..98e77d50a 100644
--- a/front/lib/front_web/templates/layout/_anonymous_page_header.html.eex
+++ b/front/lib/front_web/templates/layout/_anonymous_page_header.html.eex
@@ -8,7 +8,7 @@
Blazing-fast build and deploy!
Log in
- <%= if not Front.on_prem?() do %>
+ <%= if Front.saas?() do %>
Sign up
<% end %>
diff --git a/front/lib/front_web/templates/layout/organization_settings.html.eex b/front/lib/front_web/templates/layout/organization_settings.html.eex
index f62408a8d..cb0432d03 100644
--- a/front/lib/front_web/templates/layout/organization_settings.html.eex
+++ b/front/lib/front_web/templates/layout/organization_settings.html.eex
@@ -50,7 +50,7 @@
<%= link "Okta Integration", to: organization_okta_path(@conn, :show), class: "link db pv1 ph3 br3 dark-gray hover-bg-lightest-gray" %>
<% end %>
<% end %>
- <%= if not Front.on_prem?() do %>
+ <%= if Front.saas?() do %>
<%= if @conn.request_path =~ organization_contacts_path(@conn, :show) do %>
<%= link "Contacts", to: organization_contacts_path(@conn, :show), class: "link db pv1 ph3 br3 bg-green white" %>
<% else %>
diff --git a/front/lib/front_web/templates/people/members/_add_people_button.html.eex b/front/lib/front_web/templates/people/members/_add_people_button.html.eex
index 958895816..2b4ee278a 100644
--- a/front/lib/front_web/templates/people/members/_add_people_button.html.eex
+++ b/front/lib/front_web/templates/people/members/_add_people_button.html.eex
@@ -1,7 +1,9 @@
<%= if show_people_management_buttons?(@conn, @org_scope?, @permissions) do %>
<%= if @org_scope? do %>
-
+ <%= if !Front.on_prem?() do %>
+
+ <% end %>
<% else %>
diff --git a/front/lib/front_web/templates/people/members/members_list.html.eex b/front/lib/front_web/templates/people/members/members_list.html.eex
index c4c0f1f3d..f1db3b8f7 100644
--- a/front/lib/front_web/templates/people/members/members_list.html.eex
+++ b/front/lib/front_web/templates/people/members/members_list.html.eex
@@ -32,9 +32,7 @@
People
- <%= if !@org_scope? || !Front.on_prem?() || Front.ce_roles?() do %>
- <%= render "members/_add_people_button.html", conn: @conn, org_scope?: @org_scope?, permissions: @permissions %>
- <% end %>
+ <%= render "members/_add_people_button.html", conn: @conn, org_scope?: @org_scope?, permissions: @permissions %>
diff --git a/front/lib/front_web/templates/people/organization.html.eex b/front/lib/front_web/templates/people/organization.html.eex
index f9581d8cf..334a1860d 100644
--- a/front/lib/front_web/templates/people/organization.html.eex
+++ b/front/lib/front_web/templates/people/organization.html.eex
@@ -28,7 +28,7 @@
<%= render "members/members_list.html", org_id: @org_id, groups: @groups, members: @members, roles: @roles, org_scope?: @org_scope?, conn: @conn, permissions: @permissions %>
<%= render "_pagination.html", pagination: @pagination%>
- <%= if not Front.on_prem?() do %>
+ <%= if Front.saas?() do %>
<%= @invitations |> Enum.map(fn (invitee) -> %>
<%= render "members/_invitee.html", invitee: invitee, conn: @conn %>
diff --git a/front/lib/front_web/templates/people/show.html.eex b/front/lib/front_web/templates/people/show.html.eex
index 39db1fbdf..bcc64b29c 100644
--- a/front/lib/front_web/templates/people/show.html.eex
+++ b/front/lib/front_web/templates/people/show.html.eex
@@ -41,7 +41,7 @@
Repository access
- <%= if not Front.on_prem?() do %>
+ <%= if Front.saas?() do %>
<% else %>
@@ -51,28 +51,28 @@
<% {:NONE, nil} -> %>
Not Connected
<%= if @owned do %>
- <%= unless Front.on_prem?() do %>
-
- <%= link "Grant public access…", to: people_path(@conn, :update_repo_scope, @user.id, "github", [access_level: :public]), method: :post %>
- <%= link "Grant private access…", to: people_path(@conn, :update_repo_scope, @user.id, "github", [access_level: :private]), method: :post %>
-
- <% else %>
-
- <%= link "Connect…", to: people_path(@conn, :update_repo_scope, @user.id, "github", [access_level: :email]), method: :post %>
-
- <% end %>
+ <%= if Front.saas?() do %>
+
+ <%= link "Grant public access…", to: people_path(@conn, :update_repo_scope, @user.id, "github", [access_level: :public]), method: :post %>
+ <%= link "Grant private access…", to: people_path(@conn, :update_repo_scope, @user.id, "github", [access_level: :private]), method: :post %>
+
+ <% else %>
+
+ <%= link "Connect…", to: people_path(@conn, :update_repo_scope, @user.id, "github", [access_level: :email]), method: :post %>
+
+ <% end %>
<% end %>
<% {:NONE, _} -> %>
Not Connected
·
@<%= @user.github_login %>
<%= if @owned do %>
- <%= unless Front.on_prem?() do %>
-
- <%= link "Grant public access…", to: people_path(@conn, :update_repo_scope, @user.id, "github", [access_level: :public]), method: :post %>
- <%= link "Grant private access…", to: people_path(@conn, :update_repo_scope, @user.id, "github", [access_level: :private]), method: :post %>
-
- <% end %>
+ <%= if Front.saas?() do %>
+
+ <%= link "Grant public access…", to: people_path(@conn, :update_repo_scope, @user.id, "github", [access_level: :public]), method: :post %>
+ <%= link "Grant private access…", to: people_path(@conn, :update_repo_scope, @user.id, "github", [access_level: :private]), method: :post %>
+
+ <% end %>
<% end %>
<% {:EMAIL, _} -> %>
Connected
@@ -81,12 +81,12 @@
·
@<%= @user.github_login %>
<%= if @owned do %>
- <%= unless Front.on_prem?() do %>
-
- <%= link "Grant public access…", to: people_path(@conn, :update_repo_scope, @user.id, "github", [access_level: :public]), method: :post %>
- <%= link "Grant private access…", to: people_path(@conn, :update_repo_scope, @user.id, "github", [access_level: :private]), method: :post %>
-
- <% end %>
+ <%= if Front.saas?() do %>
+
+ <%= link "Grant public access…", to: people_path(@conn, :update_repo_scope, @user.id, "github", [access_level: :public]), method: :post %>
+ <%= link "Grant private access…", to: people_path(@conn, :update_repo_scope, @user.id, "github", [access_level: :private]), method: :post %>
+
+ <% end %>
<% end %>
<% {:PUBLIC, _} -> %>
Connected
@@ -95,11 +95,11 @@
·
@<%= @user.github_login %>
<%= if @owned do %>
- <%= unless Front.on_prem?() do %>
-
- <%= link "Grant private access…", to: people_path(@conn, :update_repo_scope, @user.id, "github", [access_level: :private]), method: :post %>
-
- <% end %>
+ <%= if Front.saas?() do %>
+
+ <%= link "Grant private access…", to: people_path(@conn, :update_repo_scope, @user.id, "github", [access_level: :private]), method: :post %>
+
+ <% end %>
<% end %>
<% {:PRIVATE, _} -> %>
Connected
@@ -135,31 +135,31 @@
<% end %>
<%= if FeatureProvider.feature_enabled?(:gitlab, param: @conn.assigns[:organization_id]) do %>
-
-
GitLab ·
- <%= case {@user.gitlab_scope, @user.gitlab_login} do %>
- <% {:NONE, nil} -> %>
-
Not Connected
- <%= if @owned do %>
-
- <%= link "Grant access…", to: people_path(@conn, :update_repo_scope, @user.id, "gitlab"), method: :post %>
-
- <% end %>
- <% {:NONE, _} -> %>
-
Not Connected
- ·
-
@<%= @user.gitlab_login %>
- <%= if @owned do %>
-
- <%= link "Grant access…", to: people_path(@conn, :update_repo_scope, @user.id, "gitlab"), method: :post %>
-
- <% end %>
- <% {:PRIVATE, _} -> %>
-
Connected
- ·
-
@<%= @user.gitlab_login %>
- <% end %>
-
+
+
GitLab ·
+ <%= case {@user.gitlab_scope, @user.gitlab_login} do %>
+ <% {:NONE, nil} -> %>
+
Not Connected
+ <%= if @owned do %>
+
+ <%= link "Grant access…", to: people_path(@conn, :update_repo_scope, @user.id, "gitlab"), method: :post %>
+
+ <% end %>
+ <% {:NONE, _} -> %>
+
Not Connected
+ ·
+
@<%= @user.gitlab_login %>
+ <%= if @owned do %>
+
+ <%= link "Grant access…", to: people_path(@conn, :update_repo_scope, @user.id, "gitlab"), method: :post %>
+
+ <% end %>
+ <% {:PRIVATE, _} -> %>
+
Connected
+ ·
+
@<%= @user.gitlab_login %>
+ <% end %>
+
<% end %>
diff --git a/front/lib/front_web/templates/project_settings/confirm_delete.html.eex b/front/lib/front_web/templates/project_settings/confirm_delete.html.eex
index 8044b3e51..301b05ae5 100644
--- a/front/lib/front_web/templates/project_settings/confirm_delete.html.eex
+++ b/front/lib/front_web/templates/project_settings/confirm_delete.html.eex
@@ -13,7 +13,7 @@
<%= form_for @conn, project_settings_path(@conn, :submit_delete, @project.id), [method: :post], fn f -> %>
- <%= unless Front.on_prem?() do %>
+ <%= if Front.saas?() do %>
<%= label f, :reason, "Reason for deleting", class: "db b mb1" %>
<%= select f, :reason,