def get_latest_version(environment_name, dictionary_with_versions, major_version_to_check_for): """Get the latest version of a template for a given an environment""" latest_version_dict = {} for component_name, environment_version in dictionary_with_versions.items( ): for environment in environment_version: # put all blueprint versions in a dictionary if then environment name is found in the blueprint name # it is expected that blueprint version will be formatted tec-prd_2.0.2 (env_version.number) if environment_name == str(environment.split("_")[0]): # The major version should always come after the underscore and be the first 2 digits which # are separated by a decimal point major_version_in_list = environment.split('_')[1].split(".")[0] + '.' + \ environment.split('_')[1].split(".")[1] # The reason to deconstruct and then reconstruct the environmnet name is that it is posible to # have multiple minor revisions such as 1.1.4.22.3 in which case you cannot cheat and just remove # the trailing decimal point major_version_with_comp_in_list = component_name + "_" + major_version_in_list if major_version_with_comp_in_list in major_version_to_check_for: # associate a component with a specific blueprint common.append_to_single_dimension_dict( latest_version_dict, component_name, environment) # Go through the dictionary and redefine each component with the latest blueprint version for key in latest_version_dict.keys(): latest_version = max(latest_version_dict[key]) latest_version_dict[key] = latest_version return (latest_version_dict)
def return_all_objects_underneath_folder_with_specific_metadata(cls, property_to_search_for): search_results = cls.search_artifactory_api(property_to_search_for) component_version_dict = {} for uri in search_results['results']: component_name_from_uri = uri['uri'].split("/")[-1] log.debug("Processing %s with the uri: %s" % (component_name_from_uri, uri['uri'])) for versions in requests.get(uri['uri']).json()['children']: common.append_to_single_dimension_dict(component_version_dict, component_name_from_uri, versions['uri'].strip("/")) return(component_version_dict)
def return_all_objects_underneath_folder_with_specific_metadata( cls, property_to_search_for): search_results = cls.search_artifactory_api(property_to_search_for) component_version_dict = {} for uri in search_results['results']: component_name_from_uri = uri['uri'].split("/")[-1] log.debug("Processing %s with the uri: %s" % (component_name_from_uri, uri['uri'])) for versions in requests.get(uri['uri']).json()['children']: common.append_to_single_dimension_dict( component_version_dict, component_name_from_uri, versions['uri'].strip("/")) return (component_version_dict)
def get_latest_version(environment_name, dictionary_with_versions, major_version_to_check_for): """Get the latest version of a template for a given an environment""" latest_version_dict = {} for component_name, environment_version in dictionary_with_versions.items(): for environment in environment_version: # put all blueprint versions in a dictionary if then environment name is found in the blueprint name # it is expected that blueprint version will be formatted tec-prd_2.0.2 (env_version.number) if environment_name == str(environment.split("_")[0]): # The major version should always come after the underscore and be the first 2 digits which # are separated by a decimal point major_version_in_list = environment.split('_')[1].split(".")[0] + '.' + \ environment.split('_')[1].split(".")[1] # The reason to deconstruct and then reconstruct the environmnet name is that it is posible to # have multiple minor revisions such as 1.1.4.22.3 in which case you cannot cheat and just remove # the trailing decimal point major_version_with_comp_in_list = component_name + "_" + major_version_in_list if major_version_with_comp_in_list in major_version_to_check_for: # associate a component with a specific blueprint common.append_to_single_dimension_dict(latest_version_dict, component_name, environment) # Go through the dictionary and redefine each component with the latest blueprint version for key in latest_version_dict.keys(): latest_version = max(latest_version_dict[key]) latest_version_dict[key] = latest_version return(latest_version_dict)