Ejemplo n.º 1
0
REQUIRED_CONFIG = ["USER", "TOKEN", "SERVER"]


class TrackerFactory:
    @staticmethod
    def getCollector(username, token, tracker_api, projects, tracker_provider):
        if tracker_provider == "jira":
            return JiraFailureCollector(username, token, tracker_api, projects)
        if tracker_provider == "servicenow":
            return ServiceNowFailureCollector(username, token, tracker_api)


if __name__ == "__main__":
    logging.info("===== Starting Failure Collector =====")
    if pelorus.missing_configs(REQUIRED_CONFIG):
        print("This program will exit.")
        sys.exit(1)
    projects = None
    if os.environ.get("PROJECTS") is not None:
        logging.info(
            "Querying issues from '%s' projects.",
            os.environ.get("PROJECTS"),
        )
        projects = os.environ.get("PROJECTS")
    username = os.environ.get("USER")
    token = os.environ.get("TOKEN")
    tracker_api = os.environ.get("SERVER")
    tracker_provider = os.environ.get("PROVIDER", pelorus.DEFAULT_TRACKER)
    logging.info("Server: " + tracker_api)
    logging.info("User: " + username)
Ejemplo n.º 2
0
def test_missing_configs():
    configs = ["VAR1", "VAR2"]
    assert pelorus.missing_configs(configs)
    os.environ["VAR1"] = "value"
    os.environ["VAR2"] = "value"
    assert not pelorus.missing_configs(configs)