Skip to content

Commit

Permalink
Merge pull request #25 from mtakaki/mtakaki_expose_configuration
Browse files Browse the repository at this point in the history
Exposing the configuration to avoid the current parsing problems. #20
  • Loading branch information
mtakaki authored Jan 20, 2017
2 parents 9ccdc7e + c59126f commit a147add
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions cachet_url_monitor/configuration.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
#!/usr/bin/env python
import abc
import copy
import logging
import time

import status as st
import os
import re
import time

import requests
import status as st
from yaml import dump
from yaml import load

# This is the mandatory fields that must be in the configuration file in this
Expand Down Expand Up @@ -61,6 +63,9 @@ def __init__(self, config_file):
self.config_file = config_file
self.data = load(file(self.config_file, 'r'))

# Exposing the configuration to confirm it's parsed as expected.
self.print_out()

# We need to validate the configuration is correct and then validate the component actually exists.
self.validate()

Expand Down Expand Up @@ -149,6 +154,16 @@ def evaluate(self):
if status > self.status:
self.status = status
self.message = expectation.get_message(self.request)
self.logger.info(self.message)

def print_out(self):
self.logger.info('Current configuration:\n%s' % (self.__repr__()))

def __repr__(self):
temporary_data = copy.deepcopy(self.data)
# Removing the token so we don't leak it in the logs.
del temporary_data['cachet']['token']
return dump(temporary_data, default_flow_style=False)

def push_status(self):
"""Pushes the status of the component to the cachet server. It will update the component
Expand Down

0 comments on commit a147add

Please sign in to comment.