Skip to content
This repository has been archived by the owner on Nov 20, 2020. It is now read-only.

Commit

Permalink
WIP Decompose the Compose files #69
Browse files Browse the repository at this point in the history
  • Loading branch information
francescou committed Dec 12, 2016
1 parent 0fb511a commit 6a0b42b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
2 changes: 1 addition & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def get_project_with_name(name):
get docker compose project given a project name
"""
path = projects[name]
return get_project(path)
return get_project(path, name)

# REST endpoints
@app.route(API_V1 + "projects", methods=['GET'])
Expand Down
8 changes: 5 additions & 3 deletions scripts/bridge.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,16 @@ def get_yml_path(path):
"""
return get_default_config_files(path)[0]

def get_project(path):
def get_project(path, name):
"""
get docker project given file path
"""
logging.debug('get project ' + path)
environment = Environment.from_env_file(path)
config_path = get_config_path_from_options(path, dict(), environment)
project = compose_get_project(path, config_path)
options = dict()
# options['--file'] = path
config_path = get_config_path_from_options(path, options, environment)
project = compose_get_project(path, config_path, project_name=name)
return project

def containers():
Expand Down
11 changes: 8 additions & 3 deletions scripts/find_files.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
"""
find docker-compose.yml files
"""

import fnmatch
import re
import os

def find_yml_files(path):
Expand All @@ -11,9 +11,14 @@ def find_yml_files(path):
"""
matches = {}
for root, _, filenames in os.walk(path):
for _ in fnmatch.filter(filenames, 'docker-compose.yml'):
for file_name in fnmatch.filter(filenames, 'docker-compose*.yml'):
key = root.split('/')[-1]
matches[key] = os.path.join(os.getcwd(), root)
path = os.path.join(os.getcwd(), root)
m = re.search('docker-compose(.+).yml', file_name)
if m == None:
matches[key] = path
else:
matches[key + m.group(1)] = path
return matches


Expand Down

0 comments on commit 6a0b42b

Please sign in to comment.