Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
DojoCLI
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package 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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Dojo Project (HES-SO)
Projects
UI
DojoCLI
Commits
f582a479
Commit
f582a479
authored
1 year ago
by
michael.minelli
Browse files
Options
Downloads
Plain Diff
Merge branch 'store_token_for_different_env' into v2.2.0
parents
b98af2b8
902475e1
No related branches found
No related tags found
No related merge requests found
Pipeline
#26545
passed
1 year ago
Stage: test
Changes
3
Pipelines
2
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
CHANGELOG.md
+3
-0
3 additions, 0 deletions
CHANGELOG.md
NodeApp/src/config/LocalConfig.ts
+35
-15
35 additions, 15 deletions
NodeApp/src/config/LocalConfig.ts
NodeApp/src/types/LocalConfigKeys.ts
+1
-0
1 addition, 0 deletions
NodeApp/src/types/LocalConfigKeys.ts
with
39 additions
and
15 deletions
CHANGELOG.md
+
3
−
0
View file @
f582a479
...
@@ -31,6 +31,9 @@
...
@@ -31,6 +31,9 @@
### 🎨 Interface
### 🎨 Interface
-
The gitlab token can be passed as secret user input in addition to the command line.
-
The gitlab token can be passed as secret user input in addition to the command line.
### 🔨 Internal / Developers
-
Environment support added to CLI config file
### 📚 Documentation
### 📚 Documentation
-
Wiki update for this new version
-
Wiki update for this new version
...
...
This diff is collapsed.
Click to expand it.
NodeApp/src/config/LocalConfig.ts
+
35
−
15
View file @
f582a479
import
*
as
fs
from
'
fs
'
;
import
*
as
fs
from
'
fs
'
;
import
logger
from
'
../shared/logging/WinstonLogger
'
;
import
SessionManager
from
'
../managers/SessionManager
'
;
import
SessionManager
from
'
../managers/SessionManager
'
;
import
Config
from
'
./Config
'
;
import
Config
from
'
./Config
'
;
import
LocalConfigKeys
from
'
../types/LocalConfigKeys
'
;
import
LocalConfigKeys
from
'
../types/LocalConfigKeys
'
;
import
GitlabManager
from
'
../managers/GitlabManager
'
;
import
GitlabManager
from
'
../managers/GitlabManager
'
;
import
JSON5
from
'
json5
'
;
import
JSON5
from
'
json5
'
;
import
ClientsSharedConfig
from
'
../sharedByClients/config/ClientsSharedConfig
'
;
class
LocalConfig
{
class
LocalConfig
{
...
@@ -24,23 +24,43 @@ class LocalConfig {
...
@@ -24,23 +24,43 @@ class LocalConfig {
try
{
try
{
this
.
_config
=
JSON5
.
parse
(
fs
.
readFileSync
(
this
.
configPath
).
toString
());
this
.
_config
=
JSON5
.
parse
(
fs
.
readFileSync
(
this
.
configPath
).
toString
());
SessionManager
.
token
=
this
.
_config
.
apiToken
;
if
(
LocalConfigKeys
.
API_TOKEN_ENV
in
this
.
_config
&&
ClientsSharedConfig
.
apiURL
in
this
.
_config
[
LocalConfigKeys
.
API_TOKEN_ENV
]
)
{
GitlabManager
.
token
=
this
.
_config
.
gitlabPersonalToken
;
SessionManager
.
token
=
this
.
_config
[
LocalConfigKeys
.
API_TOKEN_ENV
][
ClientsSharedConfig
.
apiURL
];
}
catch
(
error
)
{
}
}
else
{
SessionManager
.
token
=
this
.
_config
[
LocalConfigKeys
.
API_TOKEN
];
}
GitlabManager
.
token
=
this
.
_config
[
LocalConfigKeys
.
GITLAB_PERSONAL_TOKEN
];
}
catch
(
error
)
{
console
.
log
(
error
);
}
}
}
updateConfig
(
key
:
LocalConfigKeys
,
value
:
any
)
{
updateConfig
(
key
:
LocalConfigKeys
,
value
:
any
)
{
if
(
(
this
.
_config
as
any
)[
key
]
===
value
)
{
let
previousValue
=
(
this
.
_config
as
any
)[
key
];
if
(
key
===
LocalConfigKeys
.
API_TOKEN
&&
(
!
(
LocalConfigKeys
.
API_TOKEN_ENV
in
this
.
_config
)
||
!
(
ClientsSharedConfig
.
apiURL
in
this
.
_config
[
LocalConfigKeys
.
API_TOKEN_ENV
]))
)
{
previousValue
=
null
;
}
if
(
previousValue
===
value
)
{
return
;
return
;
}
}
if
(
key
===
LocalConfigKeys
.
API_TOKEN
)
{
delete
(
this
.
_config
as
any
)[
LocalConfigKeys
.
API_TOKEN
];
if
(
!
(
LocalConfigKeys
.
API_TOKEN_ENV
in
this
.
_config
)
)
{
(
this
.
_config
as
any
)[
LocalConfigKeys
.
API_TOKEN_ENV
]
=
{};
}
(
this
.
_config
as
any
)[
LocalConfigKeys
.
API_TOKEN_ENV
][
ClientsSharedConfig
.
apiURL
]
=
value
;
}
else
{
(
this
.
_config
as
any
)[
key
]
=
value
;
(
this
.
_config
as
any
)[
key
]
=
value
;
}
try
{
try
{
fs
.
writeFileSync
(
this
.
configPath
,
JSON5
.
stringify
(
this
.
_config
,
null
,
4
));
fs
.
writeFileSync
(
this
.
configPath
,
JSON5
.
stringify
(
this
.
_config
,
null
,
4
));
}
catch
(
error
)
{
}
catch
(
error
)
{
}
logger
.
error
(
error
);
}
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
NodeApp/src/types/LocalConfigKeys.ts
+
1
−
0
View file @
f582a479
enum
LocalConfigKeys
{
enum
LocalConfigKeys
{
API_TOKEN
=
'
apiToken
'
,
API_TOKEN
=
'
apiToken
'
,
API_TOKEN_ENV
=
'
apiTokenEnv
'
,
GITLAB_PERSONAL_TOKEN
=
'
gitlabPersonalToken
'
,
GITLAB_PERSONAL_TOKEN
=
'
gitlabPersonalToken
'
,
}
}
...
...
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