コード例 #1
0
ファイル: __init__.py プロジェクト: Amin12002/fandogh-cli
def deploy_managed_service(service_name, version, configs):
    configution = parse_key_values(configs)
    response = get_session().post(base_managed_services_url,
                                  json={'name': service_name,
                                        'version': version,
                                        'config': configution}
                                  )
    if response.status_code != 200:
        raise get_exception(response)
    else:
        return response.json()
コード例 #2
0
def deploy_managed_service(service_name, version, configs):
    token = get_stored_token()
    configution = parse_key_values(configs)
    response = requests.post(base_managed_services_url,
                             json={'name': service_name,
                                   'version': version,
                                   'config': configution},
                             headers={'Authorization': 'JWT ' + token}
                             )
    if response.status_code != 200:
        raise get_exception(response)
    else:
        return response.json()
コード例 #3
0
ファイル: __init__.py プロジェクト: iamvee/fandogh-cli
def _generate_manifest(image, version, name, port, envs, hosts, internal,
                       registry_secret, image_pull_policy, internal_ports):
    manifest = dict()

    if internal:
        manifest['kind'] = 'InternalService'
    else:
        manifest['kind'] = 'ExternalService'

    if name:
        manifest['name'] = name

    spec = dict()

    if image:
        spec['image'] = '{}:{}'.format(image, version)

    env_list = []

    if envs:
        env_variables = parse_key_values(envs)
        for key in env_variables:
            env_list.append({'name': key, 'value': env_variables[key]})

    spec['env'] = env_list

    if registry_secret:
        spec['image_pull_secret'] = registry_secret

    if image_pull_policy:
        spec['image_pull_policy'] = image_pull_policy

    if hosts:
        spec['domains'] = [{'name': host} for host in hosts]

    if port:
        spec['port'] = port
    if internal_ports:
        internal_ports = list(internal_ports)
        spec['internal_port_mapping'] = [
            parse_port_mapping(port_mapping) for port_mapping in internal_ports
        ]

    manifest['spec'] = spec
    return manifest