UNCLASSIFIED
Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Open sidebar
Ironbank Tools
project-template
Commits
1ccd857f
Commit
1ccd857f
authored
Nov 13, 2020
by
Joshua Eason
Browse files
Adding project settings
parent
ccbf8b96
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
79 additions
and
18 deletions
+79
-18
modules/projects.py
modules/projects.py
+79
-18
No files found.
modules/projects.py
View file @
1ccd857f
...
...
@@ -26,7 +26,7 @@ def __getProject(url, token, id):
return
project
def
__set
DefaultBranch
(
url
,
token
,
id
,
branch
):
def
__set
Parameter
(
url
,
token
,
id
,
key
,
value
):
url
=
url
+
"/api/v4/projects/"
+
str
(
id
)
HEADER
=
{
...
...
@@ -34,12 +34,12 @@ def __setDefaultBranch(url, token, id, branch):
}
PARAMS
=
{
'default_branch'
:
branch
,
key
:
value
,
}
response
=
requests
.
put
(
url
,
params
=
PARAMS
,
headers
=
HEADER
)
if
response
.
status_code
!=
200
:
logging
.
critical
(
"Failed to set
default branch
: "
+
str
(
response
.
status_code
)
+
" "
+
response
.
reason
)
logging
.
critical
(
"Failed to set
"
+
key
+
"
: "
+
str
(
response
.
status_code
)
+
" "
+
response
.
reason
)
##### Check methods
...
...
@@ -48,31 +48,92 @@ def check(url, token, tid, pid):
tsettings
=
__getProject
(
url
,
token
,
str
(
tid
))
psettings
=
__getProject
(
url
,
token
,
str
(
pid
))
default_branch
=
checkDefaultBranch
(
tsettings
,
psettings
)
# default_branch = checkParameter(tsettings, psettings, 'default_branch')
# ci_config_path = checkParameter(tsettings, psettings, 'ci_config_path')
# visibility = checkParameter(tsettings, psettings, 'visibility')
parameters
=
{
'allow_merge_on_skipped_pipeline'
:
''
,
'approvals_before_merge'
:
''
,
'auto_cancel_pending_pipelines'
:
''
,
'auto_devops_deploy_strategy'
:
''
,
'auto_devops_enabled'
:
''
,
'autoclose_referenced_issues'
:
''
,
'build_coverage_regex'
:
''
,
'build_git_strategy'
:
''
,
'build_timeout'
:
''
,
'builds_access_level'
:
''
,
'ci_config_path'
:
''
,
'ci_default_git_depth'
:
''
,
'ci_forward_deployment_enabled'
:
''
,
'container_expiration_policy_attributes'
:
''
,
'container_registry_enabled'
:
''
,
'default_branch'
:
''
,
'emails_disabled'
:
''
,
'external_authorization_classification_label'
:
''
,
'forking_access_level'
:
''
,
'issues_access_level'
:
''
,
'lfs_enabled'
:
''
,
'merge_method'
:
''
,
'merge_requests_access_level'
:
''
,
'merge_requests_enabled'
:
''
,
'mirror_overwrites_diverged_branches'
:
''
,
'mirror_trigger_builds'
:
''
,
'mirror'
:
''
,
'only_allow_merge_if_all_discussions_are_resolved'
:
''
,
'only_allow_merge_if_pipeline_succeeds'
:
''
,
'only_mirror_protected_branches'
:
''
,
'packages_enabled'
:
''
,
'pages_access_level'
:
''
,
'requirements_access_level'
:
''
,
'path'
:
''
,
'public_builds'
:
''
,
'remove_source_branch_after_merge'
:
''
,
'repository_access_level'
:
''
,
'repository_storage'
:
''
,
'request_access_enabled'
:
''
,
'resolve_outdated_diff_discussions'
:
''
,
'service_desk_enabled'
:
''
,
'shared_runners_enabled'
:
''
,
'show_default_award_emojis'
:
''
,
'snippets_access_level'
:
''
,
'snippets_enabled'
:
''
,
'suggestion_commit_message'
:
''
,
'tag_list'
:
''
,
'visibility'
:
''
,
'wiki_access_level'
:
''
,
'wiki_enabled'
:
''
}
if
default_branch
!=
''
:
logging
.
warning
(
"Default branch incorrect!"
)
for
i
in
parameters
.
keys
():
parameters
[
i
]
=
checkParameter
(
tsettings
,
psettings
,
i
)
if
parameters
[
i
]
!=
''
:
logging
.
warning
(
i
+
" incorrect!"
)
return
{
'default_branch'
:
default_branch
}
return
parameters
def
check
DefaultBranch
(
tsettings
,
psettings
):
if
tsettings
[
'default_branch'
]
!=
psettings
[
'default_branch'
]:
return
tsettings
[
'default_branch'
]
def
check
Parameter
(
tsettings
,
psettings
,
param
):
if
tsettings
[
param
]
!=
psettings
[
param
]:
return
tsettings
[
param
]
else
:
return
''
##### Fix methods
def
fix
(
url
,
token
,
tid
,
pid
):
fixes
=
check
(
url
,
token
,
tid
,
pid
)
for
i
in
fixes
.
keys
():
if
fixes
[
i
]
!=
''
:
fixParameter
(
url
,
token
,
pid
,
i
,
fixes
[
i
])
# if fixes['default_branch'] != '':
# fixParameter(url, token, pid, 'default_branch', fixes['default_branch'])
if
fixes
[
'
default_branc
h'
]
!=
''
:
fix
DefaultBranch
(
url
,
token
,
pid
,
fixes
[
'default_branc
h'
])
#
if fixes['
ci_config_pat
h'] != '':
#
fix
Parameter
(url, token, pid,
'ci_config_path', fixes['ci_config_pat
h'])
def
fixDefaultBranch
(
url
,
token
,
id
,
branch
):
logging
.
debug
(
"Setting default branch: "
+
branch
)
__setDefaultBranch
(
url
,
token
,
id
,
branch
)
\ No newline at end of file
def
fixParameter
(
url
,
token
,
id
,
key
,
value
):
logging
.
debug
(
"Setting "
+
str
(
key
)
+
": "
+
str
(
value
))
__setParameter
(
url
,
token
,
id
,
key
,
value
)
\ No newline at end of file
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