This is an automated email from the ASF dual-hosted git repository. jbonofre pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/incubator-liminal.git
commit f4bdfac225f3c7656966b0fffafd8d3e871fb7f5 Author: aviemzur <[email protected]> AuthorDate: Thu Mar 12 12:05:11 2020 +0200 Add cli --- rainbow/cli/__init__.py => rainbow-cli | 24 +++++++++++++++++++++- rainbow/build/__init__.py | 3 --- .../build/{build_rainbow.py => build_rainbows.py} | 4 ++-- rainbow/core/util/files_util.py | 2 +- requirements.txt | 1 + tests/runners/airflow/build/test_build_rainbow.py | 4 ++-- 6 files changed, 29 insertions(+), 9 deletions(-) diff --git a/rainbow/cli/__init__.py b/rainbow-cli old mode 100644 new mode 100755 similarity index 68% rename from rainbow/cli/__init__.py rename to rainbow-cli index c24b2fa..4f16b4e --- a/rainbow/cli/__init__.py +++ b/rainbow-cli @@ -1,3 +1,5 @@ +#!/usr/bin/env python3 + # # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file @@ -15,4 +17,24 @@ # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. -# TODO: cli +import os + +import click + +from rainbow.build import build_rainbows + + [email protected]() +def cli(): + pass + + [email protected]() [email protected]('--path', default=os.getcwd(), help='Build within this path.') +def build(path): + click.echo(f'Building rainbows in {path}') + build_rainbows.build_rainbows(path) + + +if __name__ == '__main__': + cli() diff --git a/rainbow/build/__init__.py b/rainbow/build/__init__.py index 9e84106..217e5db 100644 --- a/rainbow/build/__init__.py +++ b/rainbow/build/__init__.py @@ -15,6 +15,3 @@ # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. -""" -TODO: rainbow build. -""" diff --git a/rainbow/build/build_rainbow.py b/rainbow/build/build_rainbows.py similarity index 95% rename from rainbow/build/build_rainbow.py rename to rainbow/build/build_rainbows.py index 7c03104..d10a9bc 100644 --- a/rainbow/build/build_rainbow.py +++ b/rainbow/build/build_rainbows.py @@ -24,7 +24,7 @@ from rainbow.core.util import files_util from rainbow.docker.python.python_image import PythonImage -def build_rainbow(path): +def build_rainbows(path): """ TODO: doc for build_rainbow """ @@ -32,7 +32,7 @@ def build_rainbow(path): config_files = files_util.find_config_files(path) for config_file in config_files: - print(f'Building artifacts file: f{config_file}') + print(f'Building artifacts for file: {config_file}') with open(config_file) as stream: # TODO: validate config diff --git a/rainbow/core/util/files_util.py b/rainbow/core/util/files_util.py index e5a8e09..403fec9 100644 --- a/rainbow/core/util/files_util.py +++ b/rainbow/core/util/files_util.py @@ -23,6 +23,6 @@ def find_config_files(path): files = [] for r, d, f in os.walk(path): for file in f: - if file[file.rfind('.') + 1:] in ['yml', 'yaml']: + if os.path.basename(file) in ['rainbow.yml', 'rainbow.yaml']: files.append(os.path.join(r, file)) return files diff --git a/requirements.txt b/requirements.txt index 6e05d98..599ab8b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,3 +3,4 @@ PyYAML docker==4.2.0 apache-airflow==1.10.9 docker-pycreds==0.4.0 +click==7.1.1 diff --git a/tests/runners/airflow/build/test_build_rainbow.py b/tests/runners/airflow/build/test_build_rainbow.py index d1b28aa..533848f 100644 --- a/tests/runners/airflow/build/test_build_rainbow.py +++ b/tests/runners/airflow/build/test_build_rainbow.py @@ -2,7 +2,7 @@ import unittest from unittest import TestCase import docker -from rainbow.build import build_rainbow +from rainbow.build import build_rainbows class TestBuildRainbow(TestCase): @@ -15,7 +15,7 @@ class TestBuildRainbow(TestCase): if len(docker_client.images.list(image_name)) > 0: docker_client.images.remove(image=image_name) - build_rainbow.build_rainbow('tests/runners/airflow/rainbow') + build_rainbows.build_rainbows('tests/runners/airflow/rainbow') for image_name in image_names: docker_client.images.get(name=image_name)
