Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
G
Greenlight
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Arbeitsgruppe Hardwarenahe IT-Systeme
Greenlight
Commits
0630101c
Unverified
Commit
0630101c
authored
2 years ago
by
Khemissi Amir
Committed by
GitHub
2 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Resources migration: Added `migrations:roles` task. (#4001)
parent
3622a25e
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
config/application.rb
+4
-0
4 additions, 0 deletions
config/application.rb
lib/tasks/migrations/migrations.rake
+64
-0
64 additions, 0 deletions
lib/tasks/migrations/migrations.rake
sample.env
+7
-0
7 additions, 0 deletions
sample.env
with
75 additions
and
0 deletions
config/application.rb
+
4
−
0
View file @
0630101c
...
...
@@ -51,6 +51,10 @@ module Greenlight
# The default callback url that bn launcher will redirect to
config
.
gl_callback_url
=
ENV
[
"GL_CALLBACK_URL"
]
# Greenlight V3 variables:
config
.
v3_endpoint
=
ENV
[
"V3_ENDPOINT"
]
config
.
v3_secret_key_base
=
ENV
[
"V3_SECRET_KEY_BASE"
]
# Default credentials (test-install.blindsidenetworks.com/bigbluebutton).
config
.
bigbluebutton_endpoint_default
=
"http://test-install.blindsidenetworks.com/bigbluebutton/api/"
config
.
bigbluebutton_secret_default
=
"8cd8ef52e8e101574e400365b55e11a6"
...
...
This diff is collapsed.
Click to expand it.
lib/tasks/migrations/migrations.rake
0 → 100644
+
64
−
0
View file @
0630101c
# frozen_string_literal: true
namespace
:migrations
do
COMMON
=
{
headers:
{
"Content-Type"
=>
"application/json"
}
}.
freeze
desc
"Migrates v2 resources to v3"
task
:roles
,
[]
=>
:environment
do
|
_task
,
_args
|
has_encountred_issue
=
0
Role
.
select
(
:id
,
:name
).
where
.
not
(
name:
Role
::
RESERVED_ROLE_NAMES
).
each
do
|
r
|
params
=
{
role:
{
name:
r
.
name
}
}
response
=
Net
::
HTTP
.
post
(
uri
(
'roles'
),
payload
(
params
),
COMMON
[
:headers
])
case
response
when
Net
::
HTTPCreated
puts
green
"Succesfully migrated Role:"
puts
cyan
" Name:
#{
r
.
name
}
"
else
puts
red
"Unable to migrate Role:"
puts
red
" Name:
#{
r
.
name
}
"
has_encountred_issue
=
1
# At least one of the migrations failed.
end
end
puts
puts
green
"Roles migration complete."
puts
yellow
"In case of an error please retry the process to resolve."
unless
has_encountred_issue
.
zero?
exit
has_encountred_issue
end
private
def
encrypt_params
(
params
)
unless
Rails
.
configuration
.
v3_secret_key_base
.
present?
raise
red
'Unable to migrate: No "V3_SECRET_KEY_BASE" provided, please check your .env file.'
end
unless
Rails
.
configuration
.
v3_secret_key_base
.
size
>=
32
raise
red
'Unable to migrate: Provided "V3_SECRET_KEY_BASE" must be at least 32 charchters in length.'
end
key
=
Rails
.
configuration
.
v3_secret_key_base
[
0
..
31
]
crypt
=
ActiveSupport
::
MessageEncryptor
.
new
(
key
,
cipher:
'aes-256-gcm'
,
serializer:
Marshal
)
crypt
.
encrypt_and_sign
(
params
,
expires_in:
10
.
seconds
)
end
def
uri
(
path
)
unless
Rails
.
configuration
.
v3_endpoint
.
present?
raise
red
'Unable to migrate: No "V3_ENDPOINT" provided, please check your .env file.'
end
res
=
URI
(
Rails
.
configuration
.
v3_endpoint
)
res
.
path
=
"/api/v1/migrations/
#{
path
}
.json"
res
end
def
payload
(
params
)
encrypted_params
=
{
"encrypted_params"
=>
encrypt_params
(
params
)
}
res
=
{
"v2"
=>
encrypted_params
}
res
.
to_json
end
end
This diff is collapsed.
Click to expand it.
sample.env
+
7
−
0
View file @
0630101c
...
...
@@ -16,6 +16,13 @@ SECRET_KEY_BASE=
BIGBLUEBUTTON_ENDPOINT=
BIGBLUEBUTTON_SECRET=
# The endpoint and "SECRET_KEY_BASE" for your Greenlight v3 instance.
# Set these if you are trying to migrate your resources to v3.
# Example:
#V3_ENDPOINT=https://v3.greenlight.test/
#V3_SECRET_KEY_BASE=
V3_ENDPOINT=
V3_SECRET_KEY_BASE=
# The hostname that the application is accessible from.
#
# Used to protect against various HTTP header attacks
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment