Ensure that the marathon app with the given id is present and is configured
    to match the given config values.

    :param name: The app name/id
    :param config: The configuration to apply (dict)
    :return: A standard Salt changes dictionary

def config(name, config):
    '''
    Ensure that the marathon app with the given id is present and is configured
    to match the given config values.

    :param name: The app name/id
    :param config: The configuration to apply (dict)
    :return: A standard Salt changes dictionary
    '''
    # setup return structure
    ret = {
        'name': name,
        'changes': {},
        'result': False,
        'comment': '',
    }

    # get existing config if app is present
    existing_config = None
    if __salt__['marathon.has_app'](name):
        existing_config = __salt__['marathon.app'](name)['app']

    # compare existing config with defined config
    if existing_config:
        update_config = copy.deepcopy(existing_config)
        salt.utils.configcomparer.compare_and_update_config(
            config,
            update_config,
            ret['changes'],
        )
    else:
        # the app is not configured--we need to create it from scratch
        ret['changes']['app'] = {
            'new': config,
            'old': None,
        }
        update_config = config

    # update the config if we registered any changes
    if ret['changes']:
        # if test, report there will be an update
        if __opts__['test']:
            ret['result'] = None
            ret['comment'] = 'Marathon app {0} is set to be updated'.format(
                name
            )
            return ret

        update_result = __salt__['marathon.update_app'](name, update_config)
        if 'exception' in update_result:
            ret['result'] = False
            ret['comment'] = 'Failed to update app config for {0}: {1}'.format(
                name,
                update_result['exception'],
            )
            return ret
        else:
            ret['result'] = True
            ret['comment'] = 'Updated app config for {0}'.format(name)
            return ret
    ret['result'] = True
    ret['comment'] = 'Marathon app {0} configured correctly'.format(name)
    return ret