Skip to content

Commit

Permalink
inital structure
Browse files Browse the repository at this point in the history
  • Loading branch information
shokakucarrier committed Aug 10, 2021
1 parent 1c2c61b commit c5d3be6
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 5 deletions.
6 changes: 4 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
FROM registry.access.redhat.com/ubi8/python-36

RUN mkdir -p /usr/share/indy-sidedcar-init/sidecar-init
USER root

ADD sidecarinit /usr/share/indy-sidedcar-init/sidecar-init
RUN mkdir -p /usr/share/indy-sidedcar-init/sidecarinit

ADD sidecarinit /usr/share/indy-sidedcar-init/sidecarinit
ADD setup.py /usr/share/indy-sidedcar-init
ADD scripts/* /usr/local/bin/

Expand Down
5 changes: 5 additions & 0 deletions scripts/sidecar-init
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash

source /etc/profile

exec /usr/share/indy-sidedcar-init/venv/bin/run-sidecar-init "$@"
7 changes: 4 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
setup(
zip_safe=True,
use_2to3=False,
name='sidecar-init',
name='sidecarinit',
version='0.0.1',
long_description='sidecar-init container for download archive and decompress',
classifiers=[
Expand All @@ -19,11 +19,12 @@
packages=find_packages(exclude=['ez_setup', 'examples', 'tests']),
install_requires=[
"requests",
"zipfile"
"ruamel.yaml",
"click"
],
entry_points={
'console_scripts': [
'run-sidecar-init = sidecar-init:run'
'run-sidecar-init = sidecarinit:run'
],
}
)
3 changes: 3 additions & 0 deletions sidecarinit/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from sidecarinit.commands import (run)

__all__ = ['run']
14 changes: 14 additions & 0 deletions sidecarinit/commands.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import click
import os
import sys
from time import sleep
from traceback import format_exc
import sidecarinit.config as config

@click.command()
@click.argument('env_yml', required=False) #help='Target environment, Same as sidecar application.yml'
@click.option('-B', '--artifact-dir', help='Dir for saving artifacts', default='artifacts')
def run(env_yml, artifact_dir):

#suite = config.read_config(env_yml)
print("hello world")
39 changes: 39 additions & 0 deletions sidecarinit/config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
from ruamel.yaml import YAML
import os

ENV_INDY_URL = 'indy-url'
ENV_PROXY_PORT = 'proxy-port'

DEFAULT_PROXY_PORT = 8081


class Environment:
def __init__(self, env_spec):
self.indy_url = env_spec.get(ENV_INDY_URL)
self.proxy_port = env_spec.get(ENV_PROXY_PORT) or DEFAULT_PROXY_PORT

def read_config(env_yml):
""" Read the suite configuration that this worker should run, from a config.yml file
(specified on the command line and passed in as a parameter here).
Once we have a suite YAML file (from the suite_yml config), that file will be parsed
and passed back with the rest of the config values, in a Config object.
If any required configs are missing and don't have default values, error messages will
be generated. If the list of errors is non-empty at the end of this method, an error
message containing all of the problems will be logged to the console and an
exception will be raised.
"""
errors = []

env_spec = {}
if env_yml is None:
errors.append(f"Missing test environment config file")
elif os.path.exists(env_yml):
with open(env_yml) as f:
yaml = YAML(typ='safe')
env_spec = yaml.load(f)
else:
errors.append( f"Missing test environment config file")

env = Environment(env_spec)

return env

0 comments on commit c5d3be6

Please sign in to comment.