Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
A
Am I live
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
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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
shore
Am I live
Commits
19d44862
Commit
19d44862
authored
4 years ago
by
nimrod
Browse files
Options
Downloads
Patches
Plain Diff
Registry checks.
parent
5b6126d1
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
src/gitlab.py
+3
-10
3 additions, 10 deletions
src/gitlab.py
src/registry.py
+15
-0
15 additions, 0 deletions
src/registry.py
src/utils.py
+14
-1
14 additions, 1 deletion
src/utils.py
with
32 additions
and
11 deletions
src/gitlab.py
+
3
−
10
View file @
19d44862
from
utils
import
check_url
,
publish
from
utils
import
check_url
s
def
handler
(
event
,
context
):
# pylint: disable=unused-argument
def
handler
(
event
,
context
):
# pylint: disable=unused-argument
...
@@ -6,16 +6,9 @@ def handler(event, context): # pylint: disable=unused-argument
...
@@ -6,16 +6,9 @@ def handler(event, context): # pylint: disable=unused-argument
checks
=
[
checks
=
[
{
"
url
"
:
"
http://git.shore.co.il/
"
,
"
codes
"
:
[
301
,
302
]},
{
"
url
"
:
"
http://git.shore.co.il/
"
,
"
codes
"
:
[
301
,
302
]},
{
"
url
"
:
"
https://git.shore.co.il/
"
,
"
codes
"
:
[
301
,
302
]},
{
"
url
"
:
"
https://git.shore.co.il/
"
,
"
codes
"
:
[
301
,
302
]},
{
"
url
"
:
"
https://git.shore.co.il/explore/
"
,
"
codes
"
:
[
200
]
},
{
"
url
"
:
"
https://git.shore.co.il/explore/
"
},
]
]
check_urls
(
checks
)
for
check
in
checks
:
if
not
check_url
(
check
[
"
url
"
],
valid_codes
=
check
[
"
codes
"
]):
message
=
f
"
Failed check for
{
check
[
'
url
'
]
}
.
"
print
(
message
)
publish
(
message
)
else
:
print
(
f
"
{
check
[
'
url
'
]
}
is OK.
"
)
if
__name__
==
"
__main__
"
:
if
__name__
==
"
__main__
"
:
...
...
This diff is collapsed.
Click to expand it.
src/registry.py
0 → 100644
+
15
−
0
View file @
19d44862
from
utils
import
check_urls
def
handler
(
event
,
context
):
# pylint: disable=unused-argument
"""
Lambda event handler.
"""
checks
=
[
{
"
url
"
:
"
http://registry.shore.co.il/
"
,
"
codes
"
:
[
301
,
302
]},
{
"
url
"
:
"
https://registry.shore.co.il/
"
},
{
"
url
"
:
"
https://registry.shore.co.il/v2/_catalog
"
},
]
check_urls
(
checks
)
if
__name__
==
"
__main__
"
:
handler
(
"
event
"
,
"
context
"
)
This diff is collapsed.
Click to expand it.
src/utils.py
+
14
−
1
View file @
19d44862
...
@@ -14,7 +14,7 @@ def publish(message):
...
@@ -14,7 +14,7 @@ def publish(message):
def
check_url
(
url
,
method
=
"
GET
"
,
valid_codes
=
(
200
)):
def
check_url
(
url
,
method
=
"
GET
"
,
valid_codes
=
(
200
)):
"""
Checks
URL for
valid
i
ty.
"""
Checks valid
a
ty
of a URL
.
Allows specifying the HTTP method and a list of valid codes.
"""
Allows specifying the HTTP method and a list of valid codes.
"""
try
:
try
:
...
@@ -22,3 +22,16 @@ def check_url(url, method="GET", valid_codes=(200)):
...
@@ -22,3 +22,16 @@ def check_url(url, method="GET", valid_codes=(200)):
return
response
.
status_code
in
valid_codes
return
response
.
status_code
in
valid_codes
except
Exception
:
# pylint: disable=broad-except
except
Exception
:
# pylint: disable=broad-except
return
False
return
False
def
check_urls
(
checks
):
"""
Check a list of URLs.
"""
for
check
in
checks
:
if
check_url
(
check
[
"
url
"
],
check
.
get
(
"
method
"
,
"
GET
"
),
check
.
get
(
"
codes
"
,
[
200
])
):
print
(
f
"
{
check
[
'
url
'
]
}
is OK.
"
)
else
:
message
=
f
"
Failed check for
{
check
[
'
url
'
]
}
.
"
print
(
message
)
publish
(
message
)
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