<commit_before>#!/usr/bin/env bash

##########################
# Setup
##########################

function setup {

    echo "Preparing the environment"
    # Install requirements
    pip install -r requirements.txt
    run_tests
}

##########################
# Test
##########################

function run_tests {

    echo "Running tests."
    source ./env/test.env && nose2
}

##########################
# Minikube
##########################

function minikube_status {

    echo "Checking Minikube Status"
    minikube status
}

function run_minikube {

    minikube start
}

function check_minikube {

    minikube_status > /dev/null
    if [ $? -eq 0 ]; then
        echo "Minikube is correctly running."
        return 0
    else
        read -p "Minikube is not running. Do you want to start it? [y/N] " -n 1 -r
        echo
        if [[ $REPLY =~ ^[Yy]$ ]]; then
            run_minikube
        fi
    fi
}

##########################
# Docker
##########################

CYCLON_PATH=cyclon_project
EPTO_PATH=epto_project
VERSION=latest

function set_docker_context {

    read -p "Do you want to start working on Minikube context? [y/N] " -n 1 -r
    echo
    if [[ $REPLY =~ ^[Yy]$ ]]; then
        minikube_status > /dev/null
        if [ $? -eq 0 ]; then
            echo "Minikube is not running. I will start it for you!"
            run_minikube
            eval $(minikube docker-env)
        fi
    fi
}

function delete {

    set_docker_context
    echo "Deleting $1"
    docker rmi -f $1
}

function build {

    if run_tests && check_minikube; then
        set_docker_context
        echo "Building $1"
        if [ "$1" = "all" ]; then
            docker build -f ${CYCLON_PATH}/Dockerfile -t cyclon:${VERSION} .
            docker build -f ${EPTO_PATH}/Dockerfile -t epto:${VERSION} .
            tag_image cyclon
            tag_image epto
        elif [ "$1" = "cyclon" ]; then
            docker build -f ${CYCLON_PATH}/Dockerfile -t $1:${VERSION} .
            tag_image $1
        elif [ "$1" = "epto" ]; then
            docker build -f ${EPTO_PATH}/Dockerfile -t $1:${VERSION} .
            tag_image $1
        else
            echo "Sorry I don't known any image named $1"
            exit 1
        fi
    fi
}

function tag_image {

    read -p "Do you want to tag $1? [y/N] " -n 1 -r
    echo
    if [[ $REPLY =~ ^[Yy]$ ]]; then
        tag="884973541725.dkr.ecr.us-west-2.amazonaws.com/thesis:"
        read -p "Is this tag ok for you? [$tag$1] [Y/n] " -r
        echo
        if [[ $REPLY =~ ^[Nn]$ ]]; then
            read -p "Please, enter the tag you want for $1: " -r
            echo
            tag=$REPLY
        else
            tag=$tag$1
        fi
        echo "docker tag $1:$VERSION $tag"
        docker tag $1:${VERSION} $tag
        upload_image $tag
    fi<commit_msg>shell.sh updated with the possibility to build also kubeclient<commit_after>#!/usr/bin/env bash

##########################
# Setup
##########################

function setup {

    echo "Preparing the environment"
    # Install requirements
    pip install -r requirements.txt
    run_tests
}

##########################
# Test
##########################

function run_tests {

    echo "Running tests."
    source ./env/test.env && nose2
}

##########################
# Minikube
##########################

function minikube_status {

    echo "Checking Minikube Status"
    minikube status
}

function run_minikube {

    minikube start
}

function check_minikube {

    minikube_status > /dev/null
    if [ $? -eq 0 ]; then
        echo "Minikube is correctly running."
        return 0
    else
        read -p "Minikube is not running. Do you want to start it? [y/N] " -n 1 -r
        echo
        if [[ $REPLY =~ ^[Yy]$ ]]; then
            run_minikube
        fi
    fi
}

##########################
# Docker
##########################

CYCLON_PATH=cyclon_project
EPTO_PATH=epto_project
KUBERNETES_CLIENT_PATH=kubernetesClient
VERSION=latest

function set_docker_context {

    read -p "Do you want to start working on Minikube context? [y/N] " -n 1 -r
    echo
    if [[ $REPLY =~ ^[Yy]$ ]]; then
        minikube_status > /dev/null
        if [ $? -eq 0 ]; then
            echo "Minikube is not running. I will start it for you!"
            run_minikube
            eval $(minikube docker-env)
        fi
    fi
}

function delete {

    set_docker_context
    echo "Deleting $1"
    docker rmi -f $1
}

function build {

    if run_tests && check_minikube; then
        set_docker_context
        echo "Building $1"
        if [ "$1" = "all" ]; then
            docker build -f ${CYCLON_PATH}/Dockerfile -t cyclon:${VERSION} .
            docker build -f ${EPTO_PATH}/Dockerfile -t epto:${VERSION} .
            tag_image cyclon
            tag_image epto
        elif [ "$1" = "cyclon" ]; then
            docker build -f ${CYCLON_PATH}/Dockerfile -t $1:${VERSION} .
            tag_image $1
        elif [ "$1" = "epto" ]; then
            docker build -f ${EPTO_PATH}/Dockerfile -t $1:${VERSION} .
            tag_image $1
        elif [ "$1" = "kubeclient" ]; then
            docker build -f ${KUBERNETES_CLIENT_PATH}/Dockerfile -f $1:${VERSION} .
            tag_image $1
        else
            echo "Sorry I don't known any image named $1"
            echo "You can build [ cyclon, epto, kubeclient, all ]."
            exit 1
        fi
    fi
}

function tag_image {

    read -p "Do you want to tag $1? [y/N] " -n 1 -r
    echo
    if [[ $REPLY =~ ^[Yy]$ ]]; then
        tag="884973541725.dkr.ecr.us-west-2.amazonaws.com/thesis:"
        read -p "Is this tag ok for you? [$tag$1] [Y/n] " -r
        echo
        if [[ $REPLY =~ ^[Nn]$ ]]; then
            read -p "Please, enter the tag you want for $1: " -r
            echo
            tag=$REPLY
        else
            tag=$tag$1
        fi
        echo "docker tag $1:$VERSION $tag"
        docker tag $1:${VERSION} $tag
        upload_image $tag
    fi
{'fraction_non_alphanumeric': 0.1734026496729834, 'fraction_numerical': 0.013248364916988093, 'mean_word_length': 2.024340770791075, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1900861', 'n_tokens_mistral': 2002, 'n_tokens_neox': 1935, 'n_words': 566}