Commit eaa378c7 authored by Guilhem Saurel's avatar Guilhem Saurel
Browse files

style

parent a42b30bd
Pipeline #14240 passed with stage
in 2 minutes and 38 seconds
...@@ -491,12 +491,14 @@ class Repo(TimeStampedModel): ...@@ -491,12 +491,14 @@ class Repo(TimeStampedModel):
def api_req(self, url='', name=None, page=1): def api_req(self, url='', name=None, page=1):
logger.debug(f'requesting api {self.forge} {self.namespace} {self} {url}, page {page}') logger.debug(f'requesting api {self.forge} {self.namespace} {self} {url}, page {page}')
try: try:
return httpx.get(self.api_url() + url, params={'page': page}, return httpx.get(self.api_url() + url,
params={'page': page},
verify=self.forge.verify, verify=self.forge.verify,
headers=self.forge.headers()) headers=self.forge.headers())
except httpx.HTTPError: except httpx.HTTPError:
logger.error(f'requesting api {self.forge} {self.namespace} {self} {url}, page {page} - SECOND TRY') logger.error(f'requesting api {self.forge} {self.namespace} {self} {url}, page {page} - SECOND TRY')
return httpx.get(self.api_url() + url, params={'page': page}, return httpx.get(self.api_url() + url,
params={'page': page},
verify=self.forge.verify, verify=self.forge.verify,
headers=self.forge.headers()) headers=self.forge.headers())
...@@ -956,12 +958,13 @@ class Image(models.Model): ...@@ -956,12 +958,13 @@ class Image(models.Model):
headers = {} headers = {}
if not self.robotpkg.project.public: if not self.robotpkg.project.public:
image_name = self.get_image_name().split('/', maxsplit=1)[1].split(':')[0] image_name = self.get_image_name().split('/', maxsplit=1)[1].split(':')[0]
token = httpx.get(f'{self.robotpkg.project.main_forge.url}/jwt/auth', params={ token = httpx.get(f'{self.robotpkg.project.main_forge.url}/jwt/auth',
'client_id': 'docker', params={
'offline_token': True, 'client_id': 'docker',
'service': 'container_registry', 'offline_token': True,
'scope': f'repository:{image_name}:push,pull' 'service': 'container_registry',
}, 'scope': f'repository:{image_name}:push,pull'
},
auth=('gsaurel', self.robotpkg.project.main_forge.token)).json()['token'] auth=('gsaurel', self.robotpkg.project.main_forge.token)).json()['token']
headers['Authorization'] = f'Bearer {token}' headers['Authorization'] = f'Bearer {token}'
r = httpx.get(self.get_image_url(), headers=headers) r = httpx.get(self.get_image_url(), headers=headers)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment