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 Containers
Lockheed Martin
Replicator
Commits
7a7bbea7
Commit
7a7bbea7
authored
Feb 16, 2020
by
Ian Dunbar-Hall
Browse files
finishing hello typing
parent
c75a5774
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
14 additions
and
11 deletions
+14
-11
replicator/dcar/image.py
replicator/dcar/image.py
+5
-4
replicator/dcar/request.py
replicator/dcar/request.py
+4
-3
replicator/dcar/utils.py
replicator/dcar/utils.py
+2
-1
replicator/tests/dcar/request_test.py
replicator/tests/dcar/request_test.py
+1
-1
replicator/tests/dcar/utils_test.py
replicator/tests/dcar/utils_test.py
+1
-1
replicator/totp.py
replicator/totp.py
+1
-1
No files found.
replicator/dcar/image.py
View file @
7a7bbea7
...
@@ -13,6 +13,7 @@ from datetime import timezone
...
@@ -13,6 +13,7 @@ from datetime import timezone
from
datetime
import
timedelta
from
datetime
import
timedelta
from
time
import
sleep
from
time
import
sleep
from
dateutil.parser
import
parse
from
dateutil.parser
import
parse
from
typing
import
Dict
import
bs4
as
bs
# type: ignore
import
bs4
as
bs
# type: ignore
...
@@ -20,14 +21,14 @@ from dcar.request import Session
...
@@ -20,14 +21,14 @@ from dcar.request import Session
from
dcar.utils
import
validate_argument
from
dcar.utils
import
validate_argument
def
website_find_all
(
session
):
def
website_find_all
(
session
)
->
dict
:
"""
"""
This function uses the DCAR website and python beautiful soup to collect
This function uses the DCAR website and python beautiful soup to collect
metadata.
metadata.
"""
"""
validate_argument
(
"session"
,
session
,
Session
)
validate_argument
(
"session"
,
session
,
Session
)
image_details_dict
=
{}
image_details_dict
:
Dict
[
str
,
Dict
]
=
{}
vendor_level_request
=
session
.
get
(
"/"
)
vendor_level_request
=
session
.
get
(
"/"
)
vendor_level_page
=
bs
.
BeautifulSoup
(
vendor_level_request
.
content
,
'html.parser'
)
vendor_level_page
=
bs
.
BeautifulSoup
(
vendor_level_request
.
content
,
'html.parser'
)
...
@@ -104,7 +105,7 @@ def website_find_all(session):
...
@@ -104,7 +105,7 @@ def website_find_all(session):
def
compare_image
(
registry_image_name
:
str
,
registry_user
:
str
,
registry_password
:
str
,
def
compare_image
(
registry_image_name
:
str
,
registry_user
:
str
,
registry_password
:
str
,
image_details
:
dict
,
acceptable_image_delta_min
:
int
=
10
):
image_details
:
dict
,
acceptable_image_delta_min
:
int
=
10
)
->
bool
:
"""
"""
This function compares DCAR image data to a container image on a registry.
This function compares DCAR image data to a container image on a registry.
"""
"""
...
@@ -137,7 +138,7 @@ def compare_image(registry_image_name: str, registry_user: str, registry_passwor
...
@@ -137,7 +138,7 @@ def compare_image(registry_image_name: str, registry_user: str, registry_passwor
def
mirror_image
(
session
,
registry_image_name
:
str
,
registry_user
:
str
,
registry_password
:
str
,
def
mirror_image
(
session
,
registry_image_name
:
str
,
registry_user
:
str
,
registry_password
:
str
,
image_name
:
str
,
image_details
:
dict
,
push_w_docker
:
bool
,
max_retries
:
int
=
3
):
image_name
:
str
,
image_details
:
dict
,
push_w_docker
:
bool
,
max_retries
:
int
=
3
)
->
bool
:
"""
"""
This function takes DCAR image data and will download push an image to a container registry.
This function takes DCAR image data and will download push an image to a container registry.
"""
"""
...
...
replicator/dcar/request.py
View file @
7a7bbea7
...
@@ -4,8 +4,8 @@ detect DCAR SSO.
...
@@ -4,8 +4,8 @@ detect DCAR SSO.
"""
"""
from
time
import
sleep
from
time
import
sleep
from
requests
import
session
,
Response
import
requests
import
bs4
as
bs
# type: ignore
import
bs4
as
bs
# type: ignore
import
pyotp
# type: ignore
import
pyotp
# type: ignore
...
@@ -23,7 +23,7 @@ class Session:
...
@@ -23,7 +23,7 @@ class Session:
validate_argument
(
"password"
,
password
,
str
)
validate_argument
(
"password"
,
password
,
str
)
validate_argument
(
"totp_seed"
,
totp_seed
,
str
)
validate_argument
(
"totp_seed"
,
totp_seed
,
str
)
self
.
session
=
requests
.
session
()
self
.
session
=
session
()
self
.
username
=
username
self
.
username
=
username
self
.
password
=
password
self
.
password
=
password
self
.
totp_seed
=
totp_seed
.
replace
(
" "
,
""
)
self
.
totp_seed
=
totp_seed
.
replace
(
" "
,
""
)
...
@@ -56,7 +56,8 @@ class Session:
...
@@ -56,7 +56,8 @@ class Session:
raise
LoginError
()
raise
LoginError
()
def
get
(
self
,
path
:
str
,
stream
:
bool
=
False
,
verify
:
bool
=
False
,
max_retries
:
int
=
10
,
def
get
(
self
,
path
:
str
,
stream
:
bool
=
False
,
verify
:
bool
=
False
,
max_retries
:
int
=
10
,
retry_sleep
:
int
=
10
,
dcar_url
:
str
=
"https://dcar.dsop.io"
,
sso_url
:
str
=
"https://sso.dsop.io"
):
retry_sleep
:
int
=
10
,
dcar_url
:
str
=
"https://dcar.dsop.io"
,
sso_url
:
str
=
"https://sso.dsop.io"
)
->
Response
:
"""
"""
Wrapper method for the requests.get() method. This method
Wrapper method for the requests.get() method. This method
will check if the request was redirected to DCAR SSO. If
will check if the request was redirected to DCAR SSO. If
...
...
replicator/dcar/utils.py
View file @
7a7bbea7
...
@@ -5,7 +5,8 @@ This module contains random utility functions.
...
@@ -5,7 +5,8 @@ This module contains random utility functions.
import
os
import
os
from
jinja2
import
Template
from
jinja2
import
Template
def
populate_image_name
(
template_string
:
str
,
vendor
:
str
,
product
:
str
,
image
:
str
,
tag
:
str
):
def
populate_image_name
(
template_string
:
str
,
vendor
:
str
,
product
:
str
,
image
:
str
,
tag
:
str
)
->
str
:
"""
"""
Utility function to populate a templated string for a container image
Utility function to populate a templated string for a container image
name.
name.
...
...
replicator/tests/dcar/request_test.py
View file @
7a7bbea7
"""
"""
Module for unit testing the dcar.request module.
Module for unit testing the dcar.request module.
"""
"""
import
pytest
import
pytest
# type: ignore
from
dcar.request
import
Session
,
LoginError
from
dcar.request
import
Session
,
LoginError
class
MockResponse
:
class
MockResponse
:
...
...
replicator/tests/dcar/utils_test.py
View file @
7a7bbea7
"""
"""
Module for unit testing the dcar.utils module.
Module for unit testing the dcar.utils module.
"""
"""
import
pytest
import
pytest
# type: ignore
from
dcar.utils
import
populate_image_name
,
check_envs
from
dcar.utils
import
populate_image_name
,
check_envs
...
...
replicator/totp.py
View file @
7a7bbea7
...
@@ -7,7 +7,7 @@ Example:
...
@@ -7,7 +7,7 @@ Example:
"""
"""
import
os
import
os
import
pyotp
import
pyotp
# type: ignore
from
dcar.utils
import
check_envs
from
dcar.utils
import
check_envs
...
...
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