Permalink
Fetching contributors…
Cannot retrieve contributors at this time
46 lines (34 sloc) 1.68 KB
FROM python:2
ARG SPEC=https://developers.linode.com/openapi.yaml
ARG API_OVERRIDE=api.linode.com
ARG TOKEN
RUN apt-get update && apt-get install -y python3 python3-pip bats
RUN pip install requests terminaltables colorclass PyYAML enum34
RUN pip3 install requests terminaltables colorclass PyYAML enum34
ENV PYTHONPATH=.
ENV PATH="/usr/local/bin:/usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/root/.local/bin"
ENV DEFAULT_API="url: https://api.linode.com/v4"
ENV API_ENV="url: https://${API_OVERRIDE}/v4"
WORKDIR /src/linode-cli
COPY . .
# Preserve the original cli.py file
RUN mv linodecli/cli.py linodecli/original-cli.py
# Modify the cli.py to no longer verify certs and suppress warnings (allows running tests on custom environments)
RUN sed 's/data=body/data=body,verify=False/' linodecli/original-cli.py > linodecli/cli.py \
&& echo "from requests.packages.urllib3.exceptions import InsecureRequestWarning\nrequests.packages.urllib3.disable_warnings(InsecureRequestWarning)" >> /src/linode-cli/linodecli/cli.py
# Build and Install the Linode CLI
RUN curl -o /src/linode-cli/openapi.yaml ${SPEC} \
&& sed -n "s|${DEFAULT_API}|${API_ENV}|g;w cli-tests.yaml" /src/linode-cli/openapi.yaml \
&& git submodule init \
&& git submodule update \
&& make build SPEC=cli-tests.yaml \
&& make install SPEC=cli-tests.yaml \
&& cd dist \
&& pip install --user $(ls) \
&& echo -n "[DEFAULT]\ntoken = ${TOKEN}" > /root/.linode-cli
WORKDIR /src
# Install BATS testing framework
RUN git clone https://github.com/bats-core/bats-core.git \
&& cd bats-core \
&& ./install.sh /usr/local
CMD bats /src/linode-cli/test/linodes /src/linode-cli/test/domains