def load_config_kubewatch(self, rqueue: queue.Queue, url: str): snapshot = url.split('/')[-1] ss_path = os.path.join(app.snapshot_path, "snapshot-tmp.yaml") self.logger.info("copying configuration: kubewatch, %s to %s" % (url, ss_path)) # Grab the serialization, and save it to disk too. elements: List[str] = [] serialization = load_url_contents(self.logger, "%s/services" % url, stream2=open(ss_path, "w")) if serialization: elements.append(serialization) else: self.logger.debug("no services loaded from snapshot %s" % snapshot) if Config.enable_endpoints: serialization = load_url_contents(self.logger, "%s/endpoints" % url, stream2=open(ss_path, "a")) if serialization: elements.append(serialization) else: self.logger.debug("no endpoints loaded from snapshot %s" % snapshot) serialization = "---\n".join(elements) if not serialization: self.logger.debug("no data loaded from snapshot %s" % snapshot) # We never used to return here. I'm not sure if that's really correct? # self._respond(rqueue, 204, 'ignoring: no data loaded from snapshot %s' % snapshot) # return scc = KubewatchSecretHandler(app.logger, url, app.snapshot_path, snapshot) aconf = Config() fetcher = ResourceFetcher(app.logger, aconf) fetcher.parse_yaml(serialization, k8s=True) if not fetcher.elements: self.logger.debug("no configuration found in snapshot %s" % snapshot) # Don't actually bail here. If they send over a valid config that happens # to have nothing for us, it's still a legit config. # self._respond(rqueue, 204, 'ignoring: no configuration found in snapshot %s' % snapshot) # return self._load_ir(rqueue, aconf, fetcher, scc, snapshot)
def load_config_watt(self, rqueue: queue.Queue, url: str): snapshot = url.split('/')[-1] ss_path = os.path.join(app.snapshot_path, "snapshot-tmp.yaml") self.logger.info("copying configuration: watt, %s to %s" % (url, ss_path)) # Grab the serialization, and save it to disk too. serialization = load_url_contents(self.logger, url, stream2=open(ss_path, "w")) if not serialization: self.logger.debug("no data loaded from snapshot %s" % snapshot) # We never used to return here. I'm not sure if that's really correct? # self._respond(rqueue, 204, 'ignoring: no data loaded from snapshot %s' % snapshot) # return # Weirdly, we don't need a special WattSecretHandler: parse_watt knows how to handle # the secrets that watt sends. scc = SecretHandler(app.logger, url, app.snapshot_path, snapshot) aconf = Config() fetcher = ResourceFetcher(app.logger, aconf) if serialization: fetcher.parse_watt(serialization) if not fetcher.elements: self.logger.debug("no configuration found in snapshot %s" % snapshot) # Don't actually bail here. If they send over a valid config that happens # to have nothing for us, it's still a legit config. # self._respond(rqueue, 204, 'ignoring: no configuration found in snapshot %s' % snapshot) # return self._load_ir(rqueue, aconf, fetcher, scc, snapshot)
def load_config(self, url): snapshot = url.split('/')[-1] ss_path = os.path.join(app.snapshot_path, "snapshot-%s.yaml" % snapshot) self.logger.info("copying configuration from %s to %s" % (url, ss_path)) # Grab the serialization, and save it to disk too. serialization = load_url_contents(self.logger, "%s/services" % url, stream2=open(ss_path, "w")) if not serialization: self.logger.info("no data loaded from snapshot %s?" % snapshot) return scc = SecretSaver(app.logger, url, app.snapshot_path) aconf = Config() fetcher = ResourceFetcher(app.logger, aconf) fetcher.parse_yaml(serialization, k8s=True) if not fetcher.elements: self.logger.info("no configuration found in snapshot %s?" % snapshot) return self._load_ir(aconf, fetcher, scc.url_reader, snapshot)
def load_config(self, rqueue: queue.Queue, url): snapshot = url.split('/')[-1] ss_path = os.path.join(app.snapshot_path, "snapshot-tmp.yaml") self.logger.info("copying configuration from %s to %s" % (url, ss_path)) # Grab the serialization, and save it to disk too. serialization = load_url_contents(self.logger, "%s/services" % url, stream2=open(ss_path, "w")) if os.environ.get('AMBASSADOR_ENABLE_ENDPOINTS'): serialization += '---\n' + \ load_url_contents(self.logger, "%s/endpoints" % url, stream2=open(ss_path, "a")) if not serialization: self.logger.debug("no data loaded from snapshot %s" % snapshot) # We never used to return here. I'm not sure if that's really correct? # self._respond(rqueue, 204, 'ignoring: no data loaded from snapshot %s' % snapshot) # return scc = SecretSaver(app.logger, url, app.snapshot_path) aconf = Config() fetcher = ResourceFetcher(app.logger, aconf) fetcher.parse_yaml(serialization, k8s=True) if not fetcher.elements: self.logger.debug("no configuration found in snapshot %s" % snapshot) # Don't actually bail here. If they send over a valid config that happens # to have nothing for us, it's still a legit config. # self._respond(rqueue, 204, 'ignoring: no configuration found in snapshot %s' % snapshot) # return self._load_ir(rqueue, aconf, fetcher, scc.url_reader, snapshot)