def environments(): webhook = current_app.ldclient.variation('environments-webhook', current_user.get_ld_user(), False) url = url_parse(request.url) subdomain = url.host.split('.')[0] if subdomain == 'admin' and webhook: try: ld = LaunchDarklyApi(os.environ.get('LD_API_KEY')) project = ld.get_project(PROJECT_NAME) project_pick = pickle.dumps(project) current_app.redis_client.set(PROJECT_NAME, project_pick) return jsonify({'response': 200}) except Exception as e: current_app.logger.error(e) abort(500) else: abort(403)
def __init__(self, debug=False, config_name='default'): self.lock = Lock() self.instances = {} self.ld = LaunchDarklyApi(os.environ.get('LD_API_KEY')) self.config_name = config_name if os.environ.get('TESTING') is None or os.environ.get( 'TESTING') == False: self.rclient = redis.Redis(host=os.environ.get('REDIS_HOST')) else: import fakeredis self.rclient = fakeredis.FakeStrictRedis()
class AdminClient: PROJECT_NAME = os.environ.get("LD_PROJECT_NAME", "support-service") def __init__(self): self.ld = LaunchDarklyApi(os.environ.get('LD_API_KEY')) self.project = self.ld.get_project(AdminClient.PROJECT_NAME) def admin_ldclient(self): for env in self.project.environments: if env.key == 'admin': admin_env = env break ld_config = LdConfig(sdk_key=admin_env.api_key, connect_timeout=30, read_timeout=30) return ldclient.LDClient(config=ld_config)
def __init__(self): self.ld = LaunchDarklyApi(os.environ.get('LD_API_KEY')) self.project = self.ld.get_project(AdminClient.PROJECT_NAME)