Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Git clone functionality fixes #721

Merged
merged 1 commit into from
Mar 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions docs/applications/dependencies.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ harness:
branch_tag: v1.0.0
path: myrepo
```
> Note that the path parameter is optional and its use should be restricted to necessity (e.g. name clashes)

The directory structure will be as following:
```
Expand All @@ -84,8 +85,11 @@ Hence, inside the Dockerfile we expect to see something like

```dockerfile
COPY dependencies .
COPY dependencies/b.git/src .
COPY dependencies/myrepo .
```
or
```dockerfile
COPY dependencies/b/src .
COPY dependencies/myrepo/b .
```

> Note that Cloud Harness does not add the COPY/ADD statements to the Dockerfile
4 changes: 2 additions & 2 deletions tools/deployment-cli-tools/ch_cli_tools/codefresh.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def clone_step_spec(conf: GitDependencyConfig, context_path: str):
"type": "git-clone",
"repo": conf.url,
"revision": conf.branch_tag,
"working_directory": join(context_path, "dependencies", conf.path or os.path.basename(conf.url)),
"working_directory": join(context_path, "dependencies", conf.path or ""),
"git": get_main_domain(conf.url) # Cannot really tell what's the git config name, usually the name of the repo
}

Expand Down Expand Up @@ -176,7 +176,7 @@ def codefresh_steps_from_base_path(base_path, build_step, fixed_context=None, in

if app_config and app_config.dependencies and app_config.dependencies.git:
for dep in app_config.dependencies.git:
steps[CD_BUILD_STEP_DEPENDENCIES]['steps'].append(clone_step_spec(dep, base_path))
steps[CD_BUILD_STEP_DEPENDENCIES]['steps'].append(clone_step_spec(dep, dockerfile_relative_to_root))

build = None
if build_step in steps:
Expand Down
6 changes: 4 additions & 2 deletions tools/deployment-cli-tools/ch_cli_tools/skaffold.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
from .utils import get_template, dict_merge, find_dockerfiles_paths, app_name_from_path, \
find_file_paths, guess_build_dependencies_from_dockerfile, merge_to_yaml_file, get_json_template, get_image_name

from . import HERE

def relpath_if(p1, p2):
if os.path.isabs(p1):
return p1
Expand Down Expand Up @@ -198,10 +200,10 @@ def git_clone_hook(conf: GitDependencyConfig, context_path: str):
return {
'command': [
'sh',
'tools/clone.sh',
join(os.path.dirname(os.path.dirname(HERE)), 'clone.sh'),
conf.branch_tag,
conf.url,
join(context_path, "dependencies", conf.path or os.path.basename(conf.url))
join(context_path, "dependencies", conf.path or os.path.basename(conf.url).split('.')[0])
]
}

Expand Down
Loading