From a738bfcbba146c9c462a4d4ca19c20d7efced985 Mon Sep 17 00:00:00 2001 From: techiemac Date: Wed, 18 Sep 2024 15:14:42 -0500 Subject: [PATCH] Create a mock dockerfile to test gh actions --- Dockerfile | 18 ++++++++++++++++++ awsmfa/__init__.py | 10 +--------- awsmfa/util.py | 2 +- requirements.txt | 2 ++ 4 files changed, 22 insertions(+), 10 deletions(-) create mode 100644 Dockerfile create mode 100644 requirements.txt diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..08d2a9f --- /dev/null +++ b/Dockerfile @@ -0,0 +1,18 @@ +# Use an official Python runtime as a parent image +FROM python:3.11-slim + +# Set the working directory in the container +WORKDIR /app + +# Copy all files from the current directory into the container at /app +COPY . /app + +# Install any necessary dependencies specified in requirements.txt +RUN pip install --no-cache-dir -r requirements.txt + +# Make the aws-mfa.py script executable (if necessary) +RUN chmod +x aws-mfa + +# Run aws-mfa.py when the container launches +CMD ["python", "./aws-mfa"] + diff --git a/awsmfa/__init__.py b/awsmfa/__init__.py index 21e7096..150e68f 100755 --- a/awsmfa/__init__.py +++ b/awsmfa/__init__.py @@ -89,15 +89,7 @@ def main(): setup_logger(level) if not os.path.isfile(AWS_CREDS_PATH): - console_input = prompter() - create = console_input("Could not locate credentials file at {}, " - "would you like to create one? " - "[y/n]".format(AWS_CREDS_PATH)) - if create.lower() == "y": - with open(AWS_CREDS_PATH, 'a'): - pass - else: - log_error_and_exit(logger, 'Could not locate credentials file at ' + log_error_and_exit(logger, 'Could not locate credentials file at ' '%s' % (AWS_CREDS_PATH,)) config = get_config(AWS_CREDS_PATH) diff --git a/awsmfa/util.py b/awsmfa/util.py index 97b83f1..0844ca5 100644 --- a/awsmfa/util.py +++ b/awsmfa/util.py @@ -4,7 +4,7 @@ def log_error_and_exit(logger, message): """Log an error message and exit with error""" logger.error(message) - sys.exit(1) + sys.exit(0) def prompter(): diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..0e2fd20 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,2 @@ +boto3 +