binbashar / le-docker-leverage-toolbox

Docker image for https://github.com/binbashar/leverage
3 stars 0 forks source link

Enhancement | Automate version bumping #5

Open juanmatias opened 2 years ago

juanmatias commented 2 years ago

Describe the Enhancement

Automate the process in which the container image tag (versioning) is bumped.

Expected Behavior

The image tag is automagically bumped previous the image push. This process should depend on the used Terraform version and the actual Leverage CLI version. See more under Additional Context.

Use Case

This is aimed to both, avoid image overriding in the repo and to avoid errors in the process of bumping the version.

Describe Ideal Solution

Create a process in the build/push pipeline to bump the version and create a tag previous to the image push.

Alternatives Considered

Manual process.

Additional Context

As stated in documentation, the toolbox version has to be bumped if Terraform version in it remains, if the later changes then the toolbox is reset.

As pseudocode:

def get_new_image_tag():
    NEW_TERRAFORM_VERSION = get_new_terraform_version()
    LAST_TERRAFORM_VERSION = get_last_terraform_version()
    LAST_TOOLBOX_VERSION = get_last_terraform_version()
    NEW_TOOLBOX_VERSION = "0.0.1"
    REL_TYPE = get_release_type() # path, minor or mayor

    if NEW_TERRAFORM_VERSION == LAST_TERRAFORM_VERSION:
        NEW_TOOLBOX_VERSION = bump(LAST_TOOLBOX_VERSION, REL_TYPE)

    NEW_IMAGE_TAG = f"{NEW_TERRAFORM_VERSION}-{NEW_TOOLBOX_VERSION}"

    return NEW_IMAGE_TAG