Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
138eb895
Commit
138eb895
authored
Feb 21, 2022
by
Doug Stull
Committed by
Alper Akgun
Feb 21, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Enable local env variable to set com likeness in dev
- better handling of self managed vs com in local development
parent
290f6ab2
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
66 additions
and
19 deletions
+66
-19
doc/development/ee_features.md
doc/development/ee_features.md
+7
-0
lib/gitlab.rb
lib/gitlab.rb
+8
-2
spec/lib/gitlab_spec.rb
spec/lib/gitlab_spec.rb
+51
-17
No files found.
doc/development/ee_features.md
View file @
138eb895
...
...
@@ -16,6 +16,13 @@ info: To determine the technical writer assigned to the Stage/Group associated w
[
EE features list
](
https://about.gitlab.com/features/
)
.
<!-- markdownlint-enable MD044 -->
## Act as SaaS
When developing locally, there are times when you need your instance to act like the SaaS version of the product.
In those instances, you can simulate SaaS by exporting an environment variable as seen below:
`export GITLAB_SIMULATE_SAAS=1`
## Act as CE when unlicensed
Since the implementation of
...
...
lib/gitlab.rb
View file @
138eb895
...
...
@@ -49,9 +49,15 @@ module Gitlab
INSTALLATION_TYPE
=
File
.
read
(
root
.
join
(
"INSTALLATION_TYPE"
)).
strip
.
freeze
HTTP_PROXY_ENV_VARS
=
%w(http_proxy https_proxy HTTP_PROXY HTTPS_PROXY)
.
freeze
def
self
.
simulate_com?
return
false
unless
Rails
.
env
.
test?
||
Rails
.
env
.
development?
Gitlab
::
Utils
.
to_boolean
(
ENV
[
'GITLAB_SIMULATE_SAAS'
])
end
def
self
.
com?
# Check `gl_subdomain?` as well to keep parity with gitlab.com
Gitlab
.
config
.
gitlab
.
url
==
Gitlab
::
Saas
.
com_url
||
gl_subdomain?
simulate_com?
||
Gitlab
.
config
.
gitlab
.
url
==
Gitlab
::
Saas
.
com_url
||
gl_subdomain?
end
def
self
.
com
...
...
@@ -87,7 +93,7 @@ module Gitlab
end
def
self
.
dev_env_or_com?
Rails
.
env
.
development?
||
com?
com?
end
def
self
.
dev_or_test_env?
...
...
spec/lib/gitlab_spec.rb
View file @
138eb895
...
...
@@ -111,6 +111,12 @@ RSpec.describe Gitlab do
expect
(
described_class
.
com?
).
to
eq
false
end
it
'is true when GITLAB_SIMULATE_SAAS is true'
do
stub_env
(
'GITLAB_SIMULATE_SAAS'
,
'1'
)
expect
(
described_class
.
com?
).
to
eq
true
end
end
describe
'.com'
do
...
...
@@ -210,13 +216,6 @@ RSpec.describe Gitlab do
expect
(
described_class
.
dev_env_org_or_com?
).
to
eq
true
end
it
'is true when dev env'
do
allow
(
described_class
).
to
receive_messages
(
com?:
false
,
org?:
false
)
stub_rails_env
(
'development'
)
expect
(
described_class
.
dev_env_org_or_com?
).
to
eq
true
end
it
'is false when not dev, org or com'
do
allow
(
described_class
).
to
receive_messages
(
com?:
false
,
org?:
false
)
...
...
@@ -225,23 +224,58 @@ RSpec.describe Gitlab do
end
describe
'.dev_env_or_com?'
do
it
'is
true when on .com
'
do
allow
(
described_class
).
to
receive
(
:com?
).
and_return
(
true
)
it
'is
correctly calling com?
'
do
expect
(
described_class
).
to
receive
(
:com?
).
and_call_original
expect
(
described_class
.
dev_env_or_com?
).
to
eq
true
expect
(
described_class
.
dev_env_or_com?
).
to
eq
false
end
end
describe
'.simulate_com?'
do
subject
{
described_class
.
simulate_com?
}
context
'when GITLAB_SIMULATE_SAAS is true'
do
before
do
stub_env
(
'GITLAB_SIMULATE_SAAS'
,
'1'
)
end
it
'is true when test env'
do
expect
(
subject
).
to
eq
true
end
it
'is true when dev env'
do
allow
(
described_class
).
to
receive
(
:com?
).
and_return
(
false
)
allow
(
Rails
).
to
receive
(
:env
).
and_return
(
ActiveSupport
::
StringInquirer
.
new
(
'development'
))
stub_rails_env
(
'development'
)
expect
(
described_class
.
dev_env_or_com?
).
to
eq
true
expect
(
subject
).
to
eq
true
end
it
'is false when not dev or com
'
do
allow
(
described_class
).
to
receive
(
:com?
).
and_return
(
false
)
it
'is false when env is not dev or test
'
do
stub_rails_env
(
'production'
)
expect
(
described_class
.
dev_env_or_com?
).
to
eq
false
expect
(
subject
).
to
eq
false
end
end
context
'when GITLAB_SIMULATE_SAAS is false'
do
before
do
stub_env
(
'GITLAB_SIMULATE_SAAS'
,
'0'
)
end
it
'is false when test env'
do
expect
(
subject
).
to
eq
false
end
it
'is false when dev env'
do
stub_rails_env
(
'development'
)
expect
(
subject
).
to
eq
false
end
it
'is false when env is not dev or test'
do
stub_rails_env
(
'production'
)
expect
(
subject
).
to
eq
false
end
end
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment