def _validate_config(self): if not self.config.get('keyfile'): msg = ('The path to a Service Account JSON keyfile is required to ' 'authenticate to Google Compute Engine and Cloud ' 'Resource Manager.') logging.error(msg) raise exceptions.GCPConfigError(msg) if not self.config.get('dns_zone'): msg = ('The absolute DNS zone, i.e. "example.com.", is required to ' 'identify to which zone generated records should belong.') logging.error(msg) raise exceptions.GCPConfigError(msg)
def _validate_config(self): # req keys: keyfile, project, topic # TODO (lynn): keyfile won't be required once we support other # auth methods if not self.config.get('keyfile'): msg = ('The path to a Service Account JSON keyfile is required to ' 'authenticate for Google Cloud Pub/Sub.') logging.error(msg) raise exceptions.GCPConfigError(msg) if not self.config.get('project'): msg = 'The GCP project where Cloud DNS is located is required.' logging.error(msg) raise exceptions.GCPConfigError(msg)
def _validate_config(self): # req keys: project, topic if not self.config.get('project'): msg = 'The GCP project where Cloud Pub/Sub is located is required.' logging.error(msg) raise exceptions.GCPConfigError(msg) if not self.config.get('topic'): msg = ('A topic for the client to publish to in Cloud Pub/Sub is ' 'required.') logging.error(msg) raise exceptions.GCPConfigError(msg) topic_prefix = f'projects/{self.config["project"]}/topics/' if not self.config.get('topic').startswith(topic_prefix): self.config['topic'] = f'{topic_prefix}{self.config["topic"]}'
def _validate_config(self): if not self.config.get('dns_zone'): msg = ( 'The absolute DNS zone, i.e. "example.com.", is required to ' 'identify to which zone generated records should belong.') logging.error(msg) raise exceptions.GCPConfigError(msg)
def _validate_config(self): errors = [] errors = self._call_validators() if errors: error_msgs = '\n'.join(errors) exp_msg = f'Invalid configuration:\n{error_msgs}' logging.error(error_msgs) raise exceptions.GCPConfigError(exp_msg)
def _validate_config(self): errors = [] for validate_func in self.validate_config_funcs: validate_func(errors) if errors: exc_msg = 'Invalid configuration:\n' for error in errors: logging.error(error) exc_msg += error + '\n' raise exceptions.GCPConfigError(exc_msg)
def _validate_config(self): # req keys: keyfile, project, topic # TODO (lynn): keyfile won't be required once we support other # auth methods if not self.config.get('keyfile'): msg = ('The path to a Service Account JSON keyfile is required to ' 'authenticate for Google Cloud Pub/Sub.') logging.error(msg) raise exceptions.GCPConfigError(msg) if not self.config.get('project'): msg = 'The GCP project where Cloud Pub/Sub is located is required.' logging.error(msg) raise exceptions.GCPConfigError(msg) if not self.config.get('topic'): msg = ('A topic for the client to publish to in Cloud Pub/Sub is ' 'required.') logging.error(msg) raise exceptions.GCPConfigError(msg) topic_prefix = f'projects/{self.config["project"]}/topics/' if not self.config.get('topic').startswith(topic_prefix): self.config['topic'] = f'{topic_prefix}{self.config["topic"]}'
def _validate_config(self): errors = [] # req keys: keyfile, project, topic, subscription # TODO (lynn): keyfile won't be required once we support other # auth methods if not self.config.get('keyfile'): msg = ('The path to a Service Account JSON keyfile is required to ' 'authenticate for Google Cloud Pub/Sub.') errors.append(msg) if not self.config.get('project'): msg = ('The GCP project where Cloud Pub/Sub is located is ' 'required.') errors.append(msg) if not self.config.get('topic'): msg = ( 'A topic for the client to subscribe to in Cloud Pub/Sub is ' 'required.') errors.append(msg) if not self.config.get('subscription'): msg = ('A subscription for the client to pull messages from in ' 'Cloud Pub/Sub is required.') errors.append(msg) if ('max_msg_age' in self.config and (not isinstance(self.config['max_msg_age'], int) or self.config['max_msg_age'] < 1)): msg = ( 'Invalid value for max_msg_age (discard messages older than ' 'this many seconds).') errors.append(msg) if errors: exp_msg = 'Invalid configuration:\n' for error in errors: logging.error(error) exp_msg += error + '\n' raise exceptions.GCPConfigError(exp_msg) topic_prefix = f'projects/{self.config["project"]}/topics/' if not self.config.get('topic').startswith(topic_prefix): self.config['topic'] = f'{topic_prefix}{self.config["topic"]}' sub_prefix = f'projects/{self.config["project"]}/subscriptions/' if not self.config.get('subscription').startswith(sub_prefix): sub = f'{sub_prefix}{self.config["subscription"]}' self.config['subscription'] = sub
def _validate_config(self): # req keys: project if not self.config.get('project'): msg = 'The GCP project where Cloud DNS is located is required.' logging.error(msg) raise exceptions.GCPConfigError(msg)