#!/usr/bin/env python
import os
from subprocess import check_call


def env(key):
    return os.environ.get(key, "")


BUILD_TAG_COMMUNITY = env("BUILD_TAG_COMMUNITY")
BUILD_TAG_ENTERPRISE = env("BUILD_TAG_ENTERPRISE")
DOCKER_REPO = env("DOCKER_REPO").replace("index.docker.io/", "")
DOCKER_TAG = env("DOCKER_TAG")

if BUILD_TAG_COMMUNITY:
    check_call(["docker", "push", "%s:%s" % (DOCKER_REPO, DOCKER_TAG)])

if BUILD_TAG_ENTERPRISE and DOCKER_TAG not in ["7.0", "8.0"]:
    check_call(["docker", "push", "%s:%s-enterprise" % (DOCKER_REPO, DOCKER_TAG)])
