Browse Source

move multi to top level of repo

Rafael Schloming 1 year ago
parent
commit
8551c529e2

+ 4
- 0
.dockerignore View File

@@ -0,0 +1,4 @@
1
+*
2
+!multi/
3
+!ambassador/
4
+!releng/

+ 1
- 1
.gitignore View File

@@ -11,7 +11,7 @@ VERSION.py
11 11
 .mypy_cache
12 12
 cluster.yaml
13 13
 
14
-ambassador.egg-info
14
+*.egg-info
15 15
 build
16 16
 dist
17 17
 

ambassador/Dockerfile → Dockerfile View File

@@ -34,15 +34,18 @@ RUN apk --no-cache add curl python3 socat
34 34
 # full reinstall of all dependencies when dependencies are not changed.
35 35
 ENV AMBASSADOR_ROOT=/ambassador
36 36
 WORKDIR ${AMBASSADOR_ROOT}
37
-COPY requirements.txt .
37
+COPY releng releng
38
+COPY multi/requirements.txt multi/
39
+COPY ambassador/requirements.txt ambassador/
38 40
 
39 41
 # Install application dependencies
40
-RUN pip3 install -r requirements.txt
42
+RUN releng/install-py.sh prd requirements */requirements.txt
41 43
 
42 44
 # Install the application itself
43
-COPY ./ ambassador
44
-RUN cd ambassador && python3 setup.py --quiet install
45
-RUN rm -rf ./ambassador
45
+COPY multi/ multi
46
+COPY ambassador/ ambassador
47
+RUN releng/install-py.sh prd install */requirements.txt
48
+RUN rm -rf ./multi ./ambassador
46 49
 
47 50
 # MKDIR an empty /ambassador/ambassador-config. You can dump a
48 51
 # configmap over this with no trouble, or you can let
@@ -51,7 +54,7 @@ RUN mkdir ambassador-config
51 54
 RUN mkdir envoy
52 55
 
53 56
 # COPY in a default config for use with --demo.
54
-COPY default-config/ ambassador-demo-config
57
+COPY ambassador/default-config/ ambassador-demo-config
55 58
 
56 59
 # Fix permissions to allow running as a non root user
57 60
 RUN chgrp -R 0 ${AMBASSADOR_ROOT} && \
@@ -59,11 +62,11 @@ RUN chgrp -R 0 ${AMBASSADOR_ROOT} && \
59 62
     chmod -R g=u ${AMBASSADOR_ROOT} /etc/passwd
60 63
 
61 64
 # COPY the entrypoint script and make it runnable.
62
-COPY kubewatch.py .
63
-COPY entrypoint.sh .
65
+COPY ambassador/kubewatch.py .
66
+COPY ambassador/entrypoint.sh .
64 67
 # XXX: ambex needs to be replaced with a proper release, or made traceable or something!!!
65
-COPY ambex .
66
-COPY bootstrap-ads.yaml .
68
+COPY ambassador/ambex .
69
+COPY ambassador/bootstrap-ads.yaml .
67 70
 RUN chmod 755 entrypoint.sh
68 71
 
69 72
 ENTRYPOINT [ "./entrypoint.sh" ]

+ 4
- 8
Makefile View File

@@ -190,7 +190,7 @@ export-vars:
190 190
 	@echo "export AMBASSADOR_DOCKER_IMAGE='$(AMBASSADOR_DOCKER_IMAGE)'"
191 191
 
192 192
 ambassador-docker-image: version
193
-	docker build -q $(DOCKER_OPTS) -t $(AMBASSADOR_DOCKER_IMAGE) ./ambassador
193
+	docker build -q $(DOCKER_OPTS) -t $(AMBASSADOR_DOCKER_IMAGE) .
194 194
 
195 195
 docker-login:
196 196
 	@if [ -z $(DOCKER_USERNAME) ]; then echo 'DOCKER_USERNAME not defined'; exit 1; fi
@@ -394,14 +394,10 @@ release:
394 394
 
395 395
 venv: version venv/bin/activate
396 396
 
397
-venv/bin/activate: dev-requirements.txt kat/requirements.txt ambassador/requirements.txt
397
+venv/bin/activate: dev-requirements.txt multi/requirements.txt kat/requirements.txt ambassador/requirements.txt
398 398
 	test -d venv || virtualenv venv --python python3
399
-	@for REQ_FILE in $^; do \
400
-		venv/bin/pip -v install -q -Ur $$REQ_FILE; \
401
-		if [[ "$$REQ_FILE" == */requirements.txt ]]; then \
402
-			venv/bin/pip -v install -q -e "$$(dirname $$REQ_FILE)/."; \
403
-		fi; \
404
-	done
399
+	@releng/install-py.sh dev requirements $^
400
+	@releng/install-py.sh dev install $^
405 401
 	touch venv/bin/activate
406 402
 	@if [ -d "venv/lib/python3.7/site-packages/kubernetes/client" ]; then \
407 403
 		echo "Fixing Kubernetes Client for Python 3.7"; \

+ 1
- 1
ambassador/tests/kat/abstract_tests.py View File

@@ -152,7 +152,7 @@ class AmbassadorTest(Test):
152 152
 
153 153
         if not AmbassadorTest.IMAGE_BUILT:
154 154
             AmbassadorTest.IMAGE_BUILT = True
155
-            context = os.path.dirname(os.path.dirname(os.path.dirname(__file__)))
155
+            context = os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(__file__))))
156 156
             print("Starting docker build...", end="")
157 157
             sys.stdout.flush()
158 158
             result = run("docker", "build", context, "-t", image)

ambassador/multi/__init__.py → multi/multi/__init__.py View File


ambassador/multi/tests/test_multi.py → multi/multi/tests/test_multi.py View File


+ 0
- 0
multi/requirements.txt View File


+ 35
- 0
multi/setup.py View File

@@ -0,0 +1,35 @@
1
+# Copyright 2018 Datawire. All rights reserved.
2
+#
3
+# Licensed under the Apache License, Version 2.0 (the "License");
4
+# you may not use this file except in compliance with the License.
5
+# You may obtain a copy of the License at
6
+#
7
+#     http://www.apache.org/licenses/LICENSE-2.0
8
+#
9
+# Unless required by applicable law or agreed to in writing, software
10
+# distributed under the License is distributed on an "AS IS" BASIS,
11
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+# See the License for the specific language governing permissions and
13
+# limitations under the License
14
+
15
+import setuptools
16
+from setuptools import setup, find_packages
17
+
18
+import os
19
+
20
+requirements = open("requirements.txt", "r").read().split("\n")
21
+
22
+setup(
23
+    name="multi",
24
+    version="0.1.0",
25
+    packages=find_packages(exclude=["tests"]),
26
+    include_package_data=True,
27
+    install_requires=requirements,
28
+    author="datawire.io",
29
+    author_email="dev@datawire.io",
30
+    keywords=[
31
+        "python",
32
+        "multiple dispatch"
33
+    ],
34
+    classifiers=[],
35
+)

+ 47
- 0
releng/install-py.sh View File

@@ -0,0 +1,47 @@
1
+#!/usr/bin/env sh
2
+
3
+requirements_dev() {
4
+    venv/bin/pip -v install -q -Ur $1
5
+}
6
+
7
+requirements_prd() {
8
+    pip3 install -r $1
9
+}
10
+
11
+install_dev() {
12
+    venv/bin/pip -v install -q -e $1
13
+}
14
+
15
+install_prd() {
16
+    ( cd $1 && python3 setup.py --quiet install )
17
+}
18
+
19
+die() {
20
+    echo $*
21
+    exit 1
22
+}
23
+
24
+# legal values: dev or prd
25
+MODE=$1
26
+shift
27
+OP=$1
28
+shift
29
+
30
+[[ $MODE == "dev" || $MODE == "prd" ]] || die "mode must be dev or prd, got $MODE"
31
+[[ $OP == "requirements" || $OP == "install" ]] || die "op must be install or requirements, got $OP"
32
+
33
+FILES=$*
34
+
35
+do_requirements() {
36
+    requirements_${MODE} $1
37
+}
38
+
39
+do_install() {
40
+    case "$1" in
41
+        */requirements.txt) install_${MODE} "$(dirname $1)/.";;
42
+    esac
43
+}
44
+
45
+for FILE in $FILES; do
46
+    do_${OP} $FILE
47
+done

Loading…
Cancel
Save