Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding an environment variable to docker file, fixing -td flag and catching exceptions and adding tag to docker image #45

Merged
merged 1 commit into from
Oct 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,5 @@ RUN set -ex \
&& > /var/log/faillog \
&& > /var/log/lastlog

# Default to /tmp/kubiscan/kubeconfig
ENV CONF_PATH=/kubiscan/kubeconfig.yaml
# Environment variable to know if running in a container
ENV RUNNING_IN_A_CONTAINER=true
14 changes: 7 additions & 7 deletions api/api_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@
CoreV1Api = None
RbacAuthorizationV1Api = None


def running_in_container():
with open('/proc/1/comm') as file:
line = file.readline().strip()
while line:
if 'systemd' in line:
return False
line = file.readline().strip()
return True
running_in_a_container = os.getenv('RUNNING_IN_A_CONTAINER')
if running_in_a_container is not None and running_in_a_container == 'true':
return True
return False


def replace(file_path, pattern, subst):
#Create temp file
fh, abs_path = mkstemp()
Expand Down
2 changes: 1 addition & 1 deletion docker_run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ if ! test -f "$kube_config"; then
fi

# Running the container.
docker run -t -d --rm --name kubiscan_container -e CONF_PATH=/config --network host natan2nik/kubiscan:kubiscan
docker run -t -d --rm --name kubiscan_container -e CONF_PATH=/config --network host natan2nik/kubiscan:latest
# docker run -t -d --rm --name kubiscan_container -e CONF_PATH=/config --network host --detach kubiscan bash -c "sleep infinity"

# The new container id.
Expand Down
Loading