Skip to content

Commit

Permalink
Adding Credentials to allow fetching repo using https instead of ssh
Browse files Browse the repository at this point in the history
  • Loading branch information
llacroix committed Mar 4, 2023
1 parent 2fa9dd0 commit fa878a9
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 5 deletions.
6 changes: 4 additions & 2 deletions odoo_tools/api/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ def checkout(
service,
target_path,
fetch_path=None,
decrypt_key=None
decrypt_key=None,
credentials=None
):
if not fetch_path:
fetch_path = target_path
Expand All @@ -51,7 +52,8 @@ def checkout(
path, info = fetch_addons(
addon,
fetch_path,
decrypt_key=decrypt_key
decrypt_key=decrypt_key,
credentials=credentials,
)

if fetch_path != checkout_path:
Expand Down
25 changes: 23 additions & 2 deletions odoo_tools/cli/click/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,23 +62,44 @@ def show(ctx, service_file, env, url):
@click.option(
'--decrypt-key',
)
@click.option(
'--credentials'
)
@click.argument('service_file')
@click.argument('environment')
@click.argument('target')
@click.pass_context
def checkout(ctx, service_file, environment, target, cache, decrypt_key):
def checkout(
ctx,
service_file,
environment,
target,
cache,
decrypt_key,
credentials,
):
env = ctx.obj['env']

manifests = env.services.get_services(service_file)

service = manifests.services.get(environment)
resolved_service = service.resolved

host, username, password = credentials.split(':')

credentials = {
host: {
"username": username,
"password": password,
}
}

env.services.checkout(
resolved_service,
target,
cache or target,
decrypt_key
decrypt_key,
credentials
)


Expand Down
3 changes: 3 additions & 0 deletions odoo_tools/configuration/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ def fetch_addons(addon, output_directory, decrypt_key=None, credentials=None):
password = credential['password']

url = urlparse(parsed.url2https)

_logger.debug("Fetching with url: %s", url.geturl())

url = url._replace(
netloc="{}:{}@{}".format(
username,
Expand Down
3 changes: 3 additions & 0 deletions odoo_tools/services/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,9 @@ def parse(self, owner, data):
class Dict(List):

def __init__(self, *args, **kwargs):
if 'default' not in kwargs:
kwargs['default'] = {}

super().__init__(*args, **kwargs)
self._key = kwargs['key']

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setuptools.setup(
name="odoo-tools",
version="0.1.6",
version="0.1.7",
author="Loïc Faure-Lacroix <[email protected]>",
author_email="[email protected]",
description="Odoo Tools",
Expand Down

0 comments on commit fa878a9

Please sign in to comment.