def setup_js_context(): # setup the appUrl appUrl = urlsplit(request.host_url) g.jsContext = {"appUrl": appUrl.geturl()[:-1]} if tracker.send_anonymous_usage_stats: g.jsContext["isSendAnonymousUsageStats"] = True g.jsContext["projectId"] = tracker.project_id g.jsContext["version"] = meltano.__version__ # setup the airflowUrl try: airflow = ConfigService(project).find_plugin("airflow") settings = PluginSettingsService(project) airflow_port, _ = settings.get_value(db.session, airflow, "webserver.web_server_port") g.jsContext["airflowUrl"] = appUrl._replace( netloc=f"{appUrl.hostname}:{airflow_port}").geturl()[:-1] except (PluginMissingError, PluginSettingMissingError): pass # setup the dbtDocsUrl g.jsContext["dbtDocsUrl"] = appUrl._replace( path="/-/dbt/").geturl()[:-1]
def validate_plugin_config(plugin: PluginRef, name, value, project: Project, settings: PluginSettingsService): setting_def = settings.find_setting(plugin, name) # we want to prevent the edition of protected settings from the UI if setting_def.protected: logging.warning("Cannot set a 'protected' configuration externally.") return False if setting_def.kind == "file" and value and value != "": uploads_directory = project.extract_dir(plugin.full_name) resolved_file_path = project.root_dir(value).resolve() if not str(resolved_file_path).startswith( str(uploads_directory) + "/"): logging.warning( "Cannot set a file configuration to a path outside the project directory" ) return False old_value, source = settings.get_value(db.session, plugin, name) if source in (PluginSettingValueSource.ENV, PluginSettingValueSource.MELTANO_YML): logging.warning( "Cannot override a configuration set in the environment or meltano.yml." ) return False return True