Exemple #1
0
def main():
    # Authenticate with EdgeGrid
    util.initEdgeGridAuth()

    # Get the Cloud Services config files (main source of truth) for all configured environments
    environments = util.getYMLFromFile("./data/environments.yml")
    cs_config_list = []
    for env in environments:
        cs_config_list.append({
            "name":
            env,
            "branch":
            environments[env]["branch"],
            "prefix":
            environments[env]["prefix"]
            if "prefix" in environments[env] else "",
            "config":
            generateConfigForBranch(environments[env]["branch"])
        })

    # Create a new version based off of the active Prod version
    new_version_number = createNewVersion()

    # Update the rules JSON using the CS configuration as a reference
    updatePropertyRulesUsingConfig(new_version_number, cs_config_list)

    # Activate on STAGING
    activateVersion(new_version_number, "STAGING")
def main():
    # Get the Cloud Services config files (main source of truth) for all configured releases
    releases = util.getYMLFromFile("../releases.yml")

    # This arg will be either "prod-stable" or "prod-beta", and tells us which release our local main.yml is for.
    # This guarantees that the newest main.yml is used instead of the one it intends to replace.
    if len(sys.argv) > 3:
        local_branch = sys.argv[3]
    else:
        local_branch = "prod-stable"

    if len(sys.argv) > 2:
        crc_env = sys.argv[2]
    else:
        crc_env = "stage"

    crc_env_prefix = ""
    if crc_env == "stage":
        crc_env_prefix = "/stage"

    cs_config_list = []
    for env in releases:
        source_branch = releases[env]["branch"] if "branch" in releases[env] else ""
        url_prefix = releases[env]["url_prefix"] if "url_prefix" in releases[env] else ""
        content_path_prefix = crc_env_prefix + releases[env]["content_path_prefix"] if "content_path_prefix" in releases[env] else crc_env_prefix

        cs_config_list.append({
            "name": env,
            "url_prefix": url_prefix,
            "content_path_prefix": content_path_prefix,
            "cookie_required": releases[env]["cookie_required"] if "cookie_required" in releases[env] else False,
            "config": generateConfigForBranch(source_branch, url_prefix, local_branch)
        })

    if len(sys.argv) > 1:
        property_env = sys.argv[1]
    else:
        property_env = "STAGING"

    # Authenticate with EdgeGrid
    util.initEdgeGridAuth()

    # Create a new version based off of the active Prod version
    new_version_number = createNewVersion(crc_env, property_env)

    # Update the rules JSON using the CS configuration as a reference
    updatePropertyRulesUsingConfig(new_version_number, cs_config_list, crc_env)

    # Activate version
    util.activateVersion(new_version_number, property_env, crc_env)

    # Wait for new version to be active
    util.waitForActiveVersion(int(new_version_number), property_env, crc_env)
def generateConfigForBranch(source_branch, url_prefix, local_branch):
    # Get main.yml from c.rh.c Prod if we can
    if source_branch == local_branch:
        config = util.getYMLFromFile("../main.yml")
    elif source_branch.startswith("prod"):
        config = util.getYMLFromUrl("https://cloud.redhat.com{}/config/main.yml".format(url_prefix))
    else:
        # Otherwise, get it from github; Jenkins can't talk to our pre-prod envs.
        config = util.getYMLFromUrl("https://raw.githubusercontent.com/RedHatInsights/cloud-services-config/{}/main.yml".format(source_branch))

    # For every app in config, check all other apps to see if they have a frontend_path that contains its frontend_paths.
    for key in (x for x in config.keys() if "frontend" in config[x] and "paths" in config[x]["frontend"]):
        exclusions = []
        for fe_path in config[key]["frontend"]["paths"]:
            exclusions.extend(generateExclusions(fe_path, config))
        config[key]["frontend_exclude"] = exclusions
    return config
def main():
    # Authenticate with EdgeGrid
    # TODO: Change this authentication to get rid of the httpie dependency. Apprently there's a vulnerability
    util.initEdgeGridAuth()

    # Get the Cloud Services config files (main source of truth) for all configured releases
    releases = util.getYMLFromFile("../releases.yml")
    cs_config_list = []
    for env in releases:
        cs_config_list.append({
            "name":
            env,
            "branch":
            releases[env]["branch"],
            "prefix":
            releases[env]["prefix"] if "prefix" in releases[env] else "",
            "config":
            generateConfigForBranch(releases[env]["prefix"] if "prefix" in
                                    releases[env] else "")
        })

    if len(sys.argv) > 2:
        property_env = sys.argv[2]
    else:
        property_env = "STAGING"

    # Create a new version based off of the active Prod version
    new_version_number = createNewVersion(property_env)

    # Update the rules JSON using the CS configuration as a reference
    updatePropertyRulesUsingConfig(new_version_number, cs_config_list)

    # Activate version
    util.activateVersion(new_version_number, property_env)

    # Wait for new version to be active
    waitForActiveVersion(int(new_version_number), property_env)