Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DEV2-2244 inject enterprise url from updater plugin #480

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
fix for tests
yonip23 committed Mar 6, 2023
commit e564e8430b6817703d9723158dc62577b63b00ef
19 changes: 12 additions & 7 deletions src/main/java/com/tabnine/general/StaticConfig.java
Original file line number Diff line number Diff line change
@@ -32,11 +32,6 @@ public class StaticConfig {
public static final String TABNINE_ENTERPRISE_URL_PROPERTIES_KEY =
TABNINE_PLUGIN_ID_RAW + ".enterpriseUrl";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this an entry in the settings?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


// if the self-hosted updater injected the value, it'll be found here
@Nullable
public static final String TABNINE_ENTERPRISE_URL_DEFAULT_VALUE =
PropertiesComponent.getInstance().getValue(TABNINE_ENTERPRISE_URL_PROPERTIES_KEY);

public static final PluginId TABNINE_PLUGIN_ID = PluginId.getId(TABNINE_PLUGIN_ID_RAW);
public static final int MAX_COMPLETIONS = 5;
public static final String BINARY_PROTOCOL_VERSION = "4.4.223";
@@ -112,14 +107,24 @@ public static Optional<String> getLogLevel() {
return Optional.empty();
}

// if the self-hosted updater injected the value, it'll be found here
@Nullable
public static String getInjectedEnterpriseUrlFromProperties() {
if (ApplicationManager.getApplication().isUnitTestMode()) {
return null;
}
return PropertiesComponent.getInstance().getValue(TABNINE_ENTERPRISE_URL_PROPERTIES_KEY);
}

public static Optional<String> getTabnineEnterpriseHost() {
String path = AppSettingsState.getInstance().getCloud2Url();
if (!path.isEmpty()) {
return Optional.of(path);
}

if (TABNINE_ENTERPRISE_URL_DEFAULT_VALUE != null) {
return Optional.of(TABNINE_ENTERPRISE_URL_DEFAULT_VALUE);
String injectedHost = getInjectedEnterpriseUrlFromProperties();
if (injectedHost != null) {
return Optional.of(injectedHost);
}

return Optional.ofNullable(System.getProperty(TABNINE_ENTERPRISE_HOST));
2 changes: 1 addition & 1 deletion src/main/java/com/tabnine/userSettings/AppSettingsState.kt
Original file line number Diff line number Diff line change
@@ -27,7 +27,7 @@ class AppSettingsState : PersistentStateComponent<AppSettingsState?> {
var debounceTime: Long = 0
var autoImportEnabled: Boolean = true
var binariesFolderOverride: String = ""
var cloud2Url: String = StaticConfig.TABNINE_ENTERPRISE_URL_DEFAULT_VALUE ?: ""
var cloud2Url: String = StaticConfig.getInjectedEnterpriseUrlFromProperties() ?: ""

private var colorState = settingsDefaultColor