def __save_env(self, tenant, service, envs): if envs: # 删除原有env env_var_service.delete_service_env(tenant, service) # 删除原有的build类型环境变量 env_var_service.delete_service_build_env(tenant, service) SENSITIVE_ENV_NAMES = ('TENANT_ID', 'SERVICE_ID', 'TENANT_NAME', 'SERVICE_NAME', 'SERVICE_VERSION', 'MEMORY_SIZE', 'SERVICE_EXTEND_METHOD', 'SLUG_URL', 'DEPEND_SERVICE', 'REVERSE_DEPEND_SERVICE', 'POD_ORDER', 'PATH', 'POD_NET_IP') for env in envs: if env["name"] in SENSITIVE_ENV_NAMES: continue # BUILD_开头的env保存为build类型的环境变量 elif env["name"].startswith("BUILD_"): code, msg, data = env_var_service.add_service_build_env_var( tenant, service, 0, env["name"], env["name"], env["value"], True) if code != 200: logger.error( "save service check info env error {0}".format( msg)) else: code, msg, env_data = env_var_service.add_service_env_var( tenant, service, 0, env["name"], env["name"], env["value"], True, "inner") if code != 200: logger.error( "save service check info env error {0}".format( msg))
def __save_env(self, tenant, service, envs): if envs: # 删除原有env env_var_service.delete_service_env(tenant, service) SENSITIVE_ENV_NAMES = ( 'TENANT_ID', 'SERVICE_ID', 'TENANT_NAME', 'SERVICE_NAME', 'SERVICE_VERSION', 'MEMORY_SIZE', 'SERVICE_EXTEND_METHOD', 'SLUG_URL', 'DEPEND_SERVICE', 'REVERSE_DEPEND_SERVICE', 'POD_ORDER', 'PATH', 'PORT', 'POD_NET_IP', 'LOG_MATCH' ) for env in envs: if env["name"] in SENSITIVE_ENV_NAMES: continue code, msg, env_data = env_var_service.add_service_env_var(tenant, service, 0, env["name"], env["name"], env["value"], True, "inner") if code != 200: logger.error("service.check", "save service check info env error {0}".format(msg)) # return code, msg return 200, "success"