diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 998cf06..86dbaa3 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -10,7 +10,7 @@ on: env: BASE_IMAGE_USER: driplineorg BASE_IMAGE_REPO: dripline-python - BASE_IMAGE_VER: 'v4.7.1' + BASE_IMAGE_VER: 'develop' REGISTRY: ghcr.io IMAGE_NAME: ${{ github.repository }} @@ -127,5 +127,8 @@ jobs: img_repo=${{ env.BASE_IMAGE_REPO }} img_tag=${{ env.BASE_IMAGE_TAG }} tags: ${{ steps.docker_meta.outputs.tags }} - platforms: linux/amd64 -# platforms: linux/amd64,linux/arm/v7,linux/arm64 + platforms: linux/amd64,linux/arm64,linux/arm/v7 + + - name: Release + uses: softprops/action-gh-release@v2 + if: ${{ github.event_name == 'push' && contains(github.ref, 'refs/tags/') }} diff --git a/Dockerfile b/Dockerfile index ad3dcd5..2287f91 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,12 +1,12 @@ -ARG img_user=driplineorg +ARG img_user=ghcr.io/driplineorg ARG img_repo=dripline-python -ARG img_tag=v4.7.1 +ARG img_tag=develop-dev FROM ${img_user}/${img_repo}:${img_tag} -COPY . /usr/local/src/dragonfly +COPY . /usr/local/src_dragonfly -WORKDIR /usr/local/src/dragonfly +WORKDIR /usr/local/src_dragonfly RUN pip install . WORKDIR / diff --git a/docker-compose.yaml b/docker-compose.yaml new file mode 100644 index 0000000..9ff66ea --- /dev/null +++ b/docker-compose.yaml @@ -0,0 +1,42 @@ +services: + + # The broker for the mesh + rabbit-broker: + image: rabbitmq:3-management + ports: + - "15672:15672" + environment: + - RABBITMQ_DEFAULT_USER=dripline + - RABBITMQ_DEFAULT_PASS=dripline + healthcheck: + test: ["CMD-SHELL", "curl -u dripline:dripline http://rabbit-broker:15672/api/overview &> /dev/null || exit 1"] + + # The classic key-value store, a configuration based on the base Service class + key-value-store: + image: ghcr.io/project8/dragonfly:${DGFLY_IMG_TAG:-latest-dev} + depends_on: + rabbit-broker: + condition: service_healthy + volumes: + - ./examples/key-value-store.yaml:/root/key-value-store.yaml + - ./dripline_mesh.yaml:/root/.dripline_mesh.yaml + environment: + - DRIPLINE_USER=dripline + - DRIPLINE_PASSWORD=dripline + command: > + bash -c "dl-serve -vv -c /root/key-value-store.yaml" + + # The classic key-value-store service with a jitter endpoint + jitter: + image: ghcr.io/project8/dragonfly:${DGFLY_IMG_TAG:-latest-dev} + depends_on: + rabbit-broker: + condition: service_healthy + volumes: + - ./examples/jitter_example.yaml:/root/jitter_example.yaml + - ./dripline_mesh.yaml:/root/.dripline_mesh.yaml + environment: + - DRIPLINE_USER=dripline + - DRIPLINE_PASSWORD=dripline + command: > + bash -c "dl-serve -vv -c /root/jitter_example.yaml" diff --git a/dragonfly/__init__.py b/dragonfly/__init__.py new file mode 100644 index 0000000..ae9daaf --- /dev/null +++ b/dragonfly/__init__.py @@ -0,0 +1,17 @@ +import logging +logger = logging.getLogger(__name__) + +def __get_version(): + import scarab + import dragonfly + import pkg_resources + #TODO: this all needs to be populated from setup.py and gita + version = scarab.VersionSemantic() + logger.info('version should be: {}'.format(pkg_resources.get_distribution('dragonfly').version)) + version.parse(pkg_resources.get_distribution('dragonfly').version) + version.package = 'project8/dragonfly' + version.commit = 'na' + dragonfly.core.add_version('dragonfly', version) + return version +version = __get_version() +__version__ = version.version diff --git a/dripline/extensions/__init__.py b/dripline/extensions/__init__.py index 69e3be5..b62df1e 100644 --- a/dripline/extensions/__init__.py +++ b/dripline/extensions/__init__.py @@ -1 +1,9 @@ +__all__ = [] + __path__ = __import__('pkgutil').extend_path(__path__, __name__) + +# Subdirectories +from . import jitter + +# Modules in this directory +from .add_auth_spec import * diff --git a/dripline/extensions/add_auth_spec.py b/dripline/extensions/add_auth_spec.py new file mode 100644 index 0000000..a36687a --- /dev/null +++ b/dripline/extensions/add_auth_spec.py @@ -0,0 +1,37 @@ +''' +Contains the AddAuthSpec class, for adding authentication specifications +''' + +import dripline.implementations +import scarab + +import logging + +logger = logging.getLogger(__name__) + +__all__ = [] + +__all__.append('AddAuthSpec') +class AddAuthSpec(dripline.implementations.BaseAddAuthSpec): + ''' + + ''' + + def __init__(self, app): + ''' + ''' + dripline.implementations.BaseAddAuthSpec.__init__(self, app) + self.add_slack_auth_spec(app) + + def add_slack_auth_spec(self, app): + ''' + Adds the Slack authenticaiton specification to a scarab::main_app object + ''' + auth_spec = { + 'dripline': { + 'default': 'default-token', + 'env': 'DRIPLINE_SLACK_TOKEN', + }, + } + app.add_default_auth_spec_group( 'slack', scarab.to_param(auth_spec).as_node() ) + logging.debug('Added slack auth spec') diff --git a/dripline/extensions/jitter/__init__.py b/dripline/extensions/jitter/__init__.py index 0def8fb..82eeaf1 100644 --- a/dripline/extensions/jitter/__init__.py +++ b/dripline/extensions/jitter/__init__.py @@ -1,22 +1,3 @@ __all__ = [] -import pkg_resources - -import scarab -a_ver = '0.0.0' #note that this is updated in the following block -try: - a_ver = pkg_resources.get_distribution('dragonfly').version - print('version is: {}'.format(a_ver)) -except: - print('fail!') - pass -version = scarab.VersionSemantic() -version.parse(a_ver) -version.package = 'project8/dragonfly' -version.commit = '---' -__all__.append("version") - -from .dragonfly import * -from .dragonfly import __all__ as __dragonfly_all -__all__ += __dragonfly_all - +from .jitter_endpoint import * diff --git a/dripline_mesh.yaml b/dripline_mesh.yaml new file mode 100644 index 0000000..ce34d78 --- /dev/null +++ b/dripline_mesh.yaml @@ -0,0 +1 @@ +broker: rabbit-broker diff --git a/examples/jitter_example.yaml b/examples/jitter_example.yaml new file mode 100644 index 0000000..378e1a2 --- /dev/null +++ b/examples/jitter_example.yaml @@ -0,0 +1,7 @@ +name: jitter-store +module: Service +endpoints: + - name: jitter-peaches + module: JitterEntity + calibration: '2*{}' + initial_value: 0.75 diff --git a/examples/key-value-store.yaml b/examples/key-value-store.yaml new file mode 100644 index 0000000..8b26530 --- /dev/null +++ b/examples/key-value-store.yaml @@ -0,0 +1,21 @@ +name: my_store +module: Service +endpoints: + - name: peaches + module: KeyValueStore + calibration: '2*{}' + initial_value: 0.75 + log_interval: 10 + get_on_set: True + log_on_set: True + - name: chips + module: KeyValueStore + calibration: 'times3({})' + initial_value: 1.75 + - name: waffles + module: KeyValueStore + #log_interval: 30 + #log_on_set: True + calibration: '1.*{}' + initial_value: 4.00 + diff --git a/jitter_example.yml b/jitter_example.yml deleted file mode 100644 index c9bc933..0000000 --- a/jitter_example.yml +++ /dev/null @@ -1,9 +0,0 @@ -runtime-config: - name: my_store - module: Service - auth_file: /root/auths.json - endpoints: - - name: peaches - module: JitterEntity - calibration: '2*{}' - initial_value: 0.75 diff --git a/setup.py b/setup.py index c4335c5..adbc55d 100644 --- a/setup.py +++ b/setup.py @@ -1,10 +1,10 @@ from setuptools import setup, find_namespace_packages -packages = find_namespace_packages('.', include=['dripline.extensions.*']) +packages = find_namespace_packages('.', include=['dragonfly', 'dripline.extensions', 'dripline.extensions.*']) print('packages are: {}'.format(packages)) setup( name="dragonfly", - version='v2.0.1', + version='v2.0.1', # TODO: should get version from git packages=packages, )