Permalink
Browse files

Setup api base url override

  • Loading branch information...
patthiel committed Sep 17, 2018
1 parent 7afed95 commit bff2d66ecb8266b02639584816cc6e8a1dc00af9
Showing with 16 additions and 4 deletions.
  1. +16 −4 Dockerfile-bats
View
@@ -1,6 +1,7 @@
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
@@ -9,16 +10,27 @@ 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 . .
# Build and Install Linode CLI
RUN git submodule init \
# 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=${SPEC} \
&& make install SPEC=${SPEC} \
&& 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

0 comments on commit bff2d66

Please sign in to comment.