Skip to content

Commit ea55319

Browse files
committed
chore(front): get rid of on_prem util
1 parent 3beae9f commit ea55319

24 files changed

+38
-69
lines changed

front/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ CONTAINER_ENV_VARS = \
4646

4747

4848
CONTAINER_CE_ENV_VARS =\
49-
-e CE_ROLES=true \
49+
-e EDITION=ce \
5050
-e SEED_CLOUD_MACHINES=false \
5151
-e SEED_SELF_HOSTED_AGENTS=true \
5252
-e SEED_CE_FEATURES=true \

front/config/runtime.exs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,6 @@ config :front,
5858
branch_api_grpc_endpoint: System.get_env("BRANCH_GRPC_URL") || "127.0.0.1:50052",
5959
use_rbac_api: if(System.get_env("USE_RBAC_API") == "true", do: true, else: false)
6060

61-
on_prem? = if(System.get_env("ON_PREM") == "true", do: true, else: false)
62-
6361
if config_env() == :prod do
6462
config :logger, level: (System.get_env("LOG_LEVEL") || "info") |> String.to_atom()
6563
config :front, docs_domain: System.get_env("DOCS_DOMAIN", "docs.semaphoreci.com")
@@ -129,11 +127,8 @@ config :front,
129127
zendesk_snippet_id: System.get_env("ZENDESK_SNIPPET_ID"),
130128
google_gtag: System.get_env("GOOGLE_GTAG")
131129

132-
config :front, :on_prem?, on_prem?
133-
134-
135130
edition = System.get_env("EDITION", "") |> String.trim() |> String.downcase()
136-
is_saas? = !(on_prem? or edition in ["ce", "ee"])
131+
is_saas? = !(edition in ["ce", "ee"])
137132

138133
if is_saas? do
139134
config :front,
@@ -168,8 +163,6 @@ end
168163

169164
config :front, :audit_logging, System.get_env("AUDIT_LOGGING") == "true"
170165

171-
config :front, :ce_roles, System.get_env("CE_ROLES") == "true"
172-
173166
config :front,
174167
:hide_promotions,
175168
System.get_env("HIDE_PROMOTIONS") == "true"

front/helm/templates/job-page.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,6 @@ spec:
122122
{{- if eq .Values.global.edition "ce" }}
123123
- name: "SKIP_VELOCITY"
124124
value: "true"
125-
- name: "CE_ROLES"
126-
value: "true"
127125
- name: "HIDE_PROMOTIONS"
128126
value: "true"
129127
{{- end }}

front/helm/templates/project-page.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,6 @@ spec:
152152
{{- if eq .Values.global.edition "ce" }}
153153
- name: "SKIP_VELOCITY"
154154
value: "true"
155-
- name: "CE_ROLES"
156-
value: "true"
157155
- name: "HIDE_PROMOTIONS"
158156
value: "true"
159157
{{- end }}

front/helm/templates/ui-cache-reactor.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,6 @@ spec:
104104
{{- if eq .Values.global.edition "ce" }}
105105
- name: "SKIP_VELOCITY"
106106
value: "true"
107-
- name: "CE_ROLES"
108-
value: "true"
109107
- name: "HIDE_PROMOTIONS"
110108
value: "true"
111109
{{- end }}

front/lib/front.ex

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,4 @@
11
defmodule Front do
2-
@doc """
3-
Checks if application is running on-prem environment
4-
"""
5-
@spec on_prem?() :: boolean()
6-
def on_prem? do
7-
Application.get_env(:front, :on_prem?)
8-
end
9-
10-
@spec ce_roles?() :: boolean()
11-
def ce_roles? do
12-
Application.get_env(:front, :ce_roles)
13-
end
14-
152
@doc """
163
Check if it's CE edition
174
"""
@@ -41,6 +28,6 @@ defmodule Front do
4128
"""
4229
@spec saas?() :: boolean()
4330
def saas? do
44-
!(on_prem?() or os?())
31+
!os?()
4532
end
4633
end

front/lib/front_web/controllers/organization_okta_controller.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ defmodule FrontWeb.OrganizationOktaController do
8484
with {:ok, model} <- create_integration(org_id, user_id, integration),
8585
{:ok, token} <- gen_token(model) do
8686
Watchman.increment(watchman_name(:create, :success))
87-
if Front.on_prem?(), do: log_create(conn, user_id, model)
87+
if Front.os?(), do: log_create(conn, user_id, model)
8888

8989
conn
9090
|> put_flash(:notice, "Success: Your organization is connected with Okta")

front/lib/front_web/controllers/page_controller.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ defmodule FrontWeb.PageController do
1818
def status404(conn, _params) do
1919
# On onprem, if user isn't logged in, we want to redirect user to okta login
2020
# right away, without showing the 404 page
21-
if anonymous?(conn) == true and Front.on_prem?() do
21+
if anonymous?(conn) == true and Front.os?() do
2222
conn
2323
|> put_resp_header("location", login_url(conn))
2424
|> send_resp(302, "")

front/lib/front_web/controllers/people_controller.ex

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ defmodule FrontWeb.PeopleController do
276276
user_type = params["type"] || ""
277277

278278
member_role_id =
279-
if Front.ce_roles?() do
279+
if Front.ce?() do
280280
{:ok, roles} = RoleManagement.list_possible_roles(org_id, "org_scope")
281281

282282
member_role = Enum.find(roles, fn role -> role.name == "Member" end)
@@ -493,7 +493,7 @@ defmodule FrontWeb.PeopleController do
493493

494494
defp create_email_member(conn, params) do
495495
Watchman.benchmark("people.create_member", fn ->
496-
if email_members_supported?(conn.assigns.organization_id) || Front.ce_roles?() do
496+
if email_members_supported?(conn.assigns.organization_id) || Front.ce?() do
497497
user_id = conn.assigns.user_id
498498
org_id = conn.assigns.organization_id
499499

@@ -787,7 +787,7 @@ defmodule FrontWeb.PeopleController do
787787

788788
defp change_user_email(conn, user_id, email) do
789789
Watchman.benchmark("people.change_email", fn ->
790-
if email_members_supported?(conn.assigns.organization_id) || Front.ce_roles?() do
790+
if email_members_supported?(conn.assigns.organization_id) || Front.ce?() do
791791
conn
792792
|> Audit.new(:User, :Modified)
793793
|> Audit.add(description: "Change Email")
@@ -854,7 +854,7 @@ defmodule FrontWeb.PeopleController do
854854

855855
defp reset_user_password(conn, user_id) do
856856
Watchman.benchmark("people.reset_password", fn ->
857-
if email_members_supported?(conn.assigns.organization_id) || Front.ce_roles?() do
857+
if email_members_supported?(conn.assigns.organization_id) || Front.ce?() do
858858
conn
859859
|> Audit.new(:User, :Modified)
860860
|> Audit.add(description: "Reset Password")

front/lib/front_web/controllers/project_onboarding_controller.ex

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -630,15 +630,14 @@ defmodule FrontWeb.ProjectOnboardingController do
630630
) do
631631
project_onboarding_path(conn, :onboarding_index, project.name, [""])
632632
else
633-
# TODO: check with Amir
634-
if Front.on_prem?() do
633+
if Front.saas?() do
634+
project_onboarding_path(conn, :invite_collaborators, project.name)
635+
else
635636
if Models.Project.file_exists?(project.id, project.initial_pipeline_file) do
636637
project_onboarding_path(conn, :existing_configuration, project.name)
637638
else
638639
project_onboarding_path(conn, :template, project.name)
639640
end
640-
else
641-
project_onboarding_path(conn, :invite_collaborators, project.name)
642641
end
643642
end
644643

0 commit comments

Comments
 (0)