Ejemplo n.º 1
0
def delete(profile):
    config = utils.get_cli_config()
    if profile not in config:
        utils.error("Could not find profile '%s' in CLI config" % profile)
    config.pop(profile, None)
    utils.save_cli_config(config)
    print("Profile deleted.")
Ejemplo n.º 2
0
def select(profile):
    config = utils.get_cli_config()
    if profile not in config:
        utils.error("Could not find profile '%s' in CLI config" % delete)
    for key in config.keys():
        if _SELECTED_KEY_ in config[key] and key != select:
            config[key].pop(_SELECTED_KEY_, None)
    config[profile][_SELECTED_KEY_] = True
    utils.save_cli_config(config)
    print("Selected profile: %s" % profile)
Ejemplo n.º 3
0
def create(profile, url):
    config = utils.get_cli_config()
    if profile in config and 'url' in config[profile]:
        utils.error("This deployment already exist (%s) with url: %s" %
                    (create, config[create]))
    url = validate_nexus_url(url)
    config[profile] = {_URL_KEY_: url}
    if len(config) == 1:
        config[profile][_SELECTED_KEY_] = True
    utils.save_cli_config(config)
    print("Profile created.")
Ejemplo n.º 4
0
def set_token(token):
    """Registers the user token in the current profile."""
    config = utils.get_cli_config()

    selected_profile = None
    for key in config.keys():
        if nexuscli.config._SELECTED_KEY_ in config[key] and config[key][nexuscli.config._SELECTED_KEY_] is True:
            selected_profile = key
            break
    if selected_profile is None:
        utils.error("No profile selected, please use the profiles select to do that.")

    try:
        jwt.decode(token, verify=False)
    except jwt.exceptions.DecodeError:
        utils.error("Provided tokens could not be decoded. Please provide a valid tokens.")

    config[selected_profile][_TOKEN_KEY_] = token
    utils.save_cli_config(config)