Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
Metabase
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
Engineering Digital Service
Metabase
Commits
add41b27
Commit
add41b27
authored
9 years ago
by
Cam Saül
Browse files
Options
Downloads
Patches
Plain Diff
Remove bootstrap.clj
parent
a6703907
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
test/metabase/bootstrap.clj
+0
-59
0 additions, 59 deletions
test/metabase/bootstrap.clj
with
0 additions
and
59 deletions
test/metabase/bootstrap.clj
deleted
100644 → 0
+
0
−
59
View file @
a6703907
(
ns
metabase.bootstrap
"Functions for creating new Orgs/Users from the command-line / REPL."
(
:require
[
metabase.db
:refer
:all
]
(
metabase.models
[
database
:refer
[
Database
]]
[
user
:refer
[
User
]])
[
metabase.test.data
:refer
:all
]))
(
declare
bootstrap-user
prompt-read-line
prompt-read-line-boolean
)
;; # BOOTSTRAPPING
(
defn
bootstrap
"Create a `User` for development purposes.
You may optionally load the test data."
[]
(
setup-db
:auto-migrate
true
)
(
let
[{
:keys
[
email
]}
(
bootstrap-user
)]
(
println
(
format
"Successfully created User \"%s\"."
email
))))
;; # (INTERNAL)
(
defn-
bootstrap-user
"Create a new User."
[]
(
let
[
email
(
prompt-read-line
"User email"
"cam@metabase.com"
)
;; create User if needed
user
(
or
(
sel
:one
User
:email
email
)
(
ins
User
:email
email
:first_name
(
prompt-read-line
"User first name"
"Cam"
)
:last_name
(
prompt-read-line
"User last name"
"Saul"
)
:is_superuser
(
prompt-read-line-boolean
"Make this user a superuser?"
"true"
)
:password
(
prompt-read-line
"User password"
"password"
)))]
user
))
(
defn-
prompt-read-line
"Prompt for input from stdin with PROMPT, returning DEFAULT if user hits return. Optionally, recurse until the returned value is in set VALID-VALUES."
([
prompt
default
]
(
println
prompt
(
str
"[\""
default
"\"]:"
))
(
let
[
line
(
read-line
)]
(
if
(
empty?
line
)
default
line
)))
([
prompt
default
valid-values
]
{
:pre
[(
set?
valid-values
)]}
(
let
[
val
(
prompt-read-line
prompt
default
)]
(
if
(
contains?
valid-values
val
)
val
(
do
(
println
"Must be one of:"
(
map
str
valid-values
))
(
recur
prompt
default
valid-values
))))))
(
defn-
prompt-read-line-boolean
"Prompt user for true/false and return a boolean."
[
prompt
default
]
{
:pre
[(
contains?
#
{
"true"
"false"
}
default
)]}
(
case
(
prompt-read-line
prompt
default
#
{
"true"
"false"
})
"true"
true
"false"
false
))
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