Ejemplo n.º 1
0
    def add_service(self,
                    project,
                    env_spec_name,
                    service_type,
                    variable_name=None):
        """Add a service to anaconda-project.yml.

        The returned ``Status`` should be a ``RequirementStatus`` for
        the service requirement if it evaluates to True (on success),
        but may be another subtype of ``Status`` on failure. A False
        status will have an ``errors`` property with a list of error
        strings.

        Args:
            project (Project): the project
            env_spec_name (str): environment spec name or None for all environment specs
            service_type (str): which kind of service
            variable_name (str): environment variable name (None for default)

        Returns:
            ``Status`` instance
        """
        return project_ops.add_service(project=project,
                                       env_spec_name=env_spec_name,
                                       service_type=service_type,
                                       variable_name=variable_name)
def add_service(project_dir, env_spec_name, service_type, variable_name):
    """Add an item to the services section."""
    project = load_project(project_dir)
    status = project_ops.add_service(project,
                                     env_spec_name=env_spec_name,
                                     service_type=service_type,
                                     variable_name=variable_name)
    if status:
        print(status.status_description)
        print("Added service %s to the project file, its address will be in %s." %
              (status.requirement.service_type, status.requirement.env_var))
        return 0
    else:
        console_utils.print_status_errors(status)
        return 1