diff --git a/README.md b/README.md index f201bfa..0ce8754 100644 --- a/README.md +++ b/README.md @@ -16,15 +16,15 @@ pip install determine-docker-tags Here is a list of the options available. You can find more detailed usage instructions below. -| ENV Var | Default | Description | -| ------------------ | ------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| VERSION_TYPE | "" | How the program should find the version number. Can be "docker_env", "docker_from", "date" or "". | -| APP_NAME | "" | The name of the application whose version number you want to use to generate tags. | -| DOCKERFILE_PATH | "Dockerfile" | The path to the Dockerfile you want to run the program on | -| APP_ENV | "" | A static string to add to the end of every tag with a "-" added inbetween the tag and the string. The string will not be added to any tags defined in CUSTOM_TAGS. | -| CUSTOM_TAGS | "" | Any extra static tags you want to add to the image, for example "latest". You can provide a list in the form of a comma separated string to specify multiple tags. For example "latest,prod,example" | -| INCLUDE_MAJOR | "yes" | If the major version number should be a tag. This setting will be ignored if the major version number is 0. Can be "yes" or "no". | -| INCLUDE_EXTRA_INFO | "yes" | If the extra information that you find after the version number in many docker image tags should be kept and added to every tag. Can be "yes" or "no" | +| ENV Var | Default | Description | +| --------------- | ------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| VERSION_TYPE | "" | How the program should find the version number. Can be "docker_env", "docker_from", "date" or "". | +| APP_NAME | "" | The name of the application whose version number you want to use to generate tags. | +| DOCKERFILE_PATH | "Dockerfile" | The path to the Dockerfile you want to run the program on | +| APP_ENV | "" | A static string to add to the end of every tag with a "-" added inbetween the tag and the string. The string will not be added to any tags defined in CUSTOM_TAGS. | +| CUSTOM_TAGS | "" | Any extra static tags you want to add to the image, for example "latest". You can provide a list in the form of a comma separated string to specify multiple tags. For example "latest,prod,example" | +| INCLUDE_MAJOR | "yes" | If the major version number should be a tag. This setting will be ignored if the major version number is 0. Can be "yes" or "no". | +| INCLUDE_SUFFIX | "yes" | If the suffix that you find after the version number in many docker image tags should be kept and added to every tag. Can be "yes" or "no" | ## Usage @@ -88,9 +88,9 @@ We then set `APP_NAME` to `nginx` and the generated tags would be: 1.18,1.18.0 ``` -### INCLUDE_EXTRA_INFO +### INCLUDE_SUFFIX -`INCLUDE_EXTRA_INFO` is mainly intended to be used with the `docker_from` version type. It determines whether or not the suffix should be included in the generated tags. The default for this option is `yes`. Let's say we had the following `FROM` instruction in our Dockerfile: +`INCLUDE_SUFFIX` is mainly intended to be used with the `docker_from` version type. It determines whether or not the suffix should be included in the generated tags. The default for this option is `yes`. Let's say we had the following `FROM` instruction in our Dockerfile: ``` FROM nginx:1.18.0-alpine diff --git a/determine_docker_tags/__init__.py b/determine_docker_tags/__init__.py index 1237beb..16e55ed 100644 --- a/determine_docker_tags/__init__.py +++ b/determine_docker_tags/__init__.py @@ -5,7 +5,7 @@ import re from datetime import date -def determine_tags(version_string, app_env, include_major, include_extra_info): +def determine_tags(version_string, app_env, include_major, include_suffix): tags = "" if "-" in version_string: @@ -14,7 +14,7 @@ def determine_tags(version_string, app_env, include_major, include_extra_info): else: extra_info = "" - if include_extra_info == "no": + if include_suffix == "no": extra_info = "" if app_env: @@ -55,17 +55,24 @@ def main(): app_env = os.getenv("APP_ENV", "") custom_tags = os.getenv("CUSTOM_TAGS", "") include_major = os.getenv("INCLUDE_MAJOR", "yes") # yes or no - include_extra_info = os.getenv("INCLUDE_EXTRA_INFO", "yes") # yes or no + include_suffix = os.getenv("INCLUDE_SUFFIX", "yes") # yes or no + include_extra_info = os.getenv("INCLUDE_EXTRA_INFO", "") # DEPRECATED + + if include_extra_info and not include_extra_info.isspace(): + print( + "DEPRECATION NOTICE: INCLUDE_EXTRA_INFO is deprecated. Please use INCLUDE_SUFFIX instead." + ) + include_suffix = include_extra_info if include_major == "positive": include_major = "yes" elif include_major == "negative": include_major = "no" - if include_extra_info == "positive": - include_extra_info = "yes" - elif include_extra_info == "negative": - include_extra_info = "no" + if include_suffix == "positive": + include_suffix = "yes" + elif include_suffix == "negative": + include_suffix = "no" if version_type == "docker_env": is_app_name_empty(app_name) @@ -79,9 +86,7 @@ def main(): if version_string[0] == "v": version_string = version_string[1:] - tags = determine_tags( - version_string, app_env, include_major, include_extra_info - ) + tags = determine_tags(version_string, app_env, include_major, include_suffix) elif version_type == "docker_from": is_app_name_empty(app_name) @@ -95,9 +100,7 @@ def main(): if "@" in version_string: version_string = version_string[: version_string.find("@")] - tags = determine_tags( - version_string, app_env, include_major, include_extra_info - ) + tags = determine_tags(version_string, app_env, include_major, include_suffix) elif version_type == "date": version_string = date.today().strftime("%Y%m%d")