bamaer commented on code in PR #9289:
URL: https://github.com/apache/hop/pull/9289#discussion_r4538146985
##########
plugins/misc/projects/src/main/java/org/apache/hop/projects/environment/ManageEnvironmentsOptionPlugin.java:
##########
@@ -243,24 +243,36 @@ private void createEnvironment(
+ HopConfig.getInstance().getConfigFilename());
enableProject(log, environment, variables, hasHopMetadataProvider, config);
-
- validateConfigFiles(log, variables, environment);
logEnvironmentDetails(log, environment);
}
+ /**
+ * Create the environment's missing configuration files, then enable its
project with them.
+ *
+ * <p>The project variables are applied before the files are created, since
a configuration file
+ * path can refer to them (for example '${PROJECT_HOME}'). Enabling the
project reads the files,
+ * so they have to exist by then.
+ */
private void enableProject(
ILogChannel log,
LifecycleEnvironment environment,
IVariables variables,
IHasHopMetadataProvider hasHopMetadataProvider,
ProjectsConfig config)
- throws HopException {
+ throws Exception {
ProjectConfig projectConfig =
config.findProjectConfig(environment.getProjectName());
if (projectConfig == null) {
log.logBasic(
"Warning: referenced project '" + environment.getProjectName() + "'
doesn't exist");
+ validateConfigFiles(log, variables, environment);
} else {
Project project = projectConfig.loadProject(variables);
+ // Project variables only, so '${PROJECT_HOME}' in the configuration
file paths resolves.
Review Comment:
@hansva I'd keep it in hop conf. The GUI environment dialog asks before it
creates a missing file (`editConfigFile`), and `hop run -e` shouldn't write
files: there a missing file is a real misconfiguration, and the "does not
exist" error is the right message.
##########
plugins/misc/projects/src/main/java/org/apache/hop/projects/environment/ManageEnvironmentsOptionPlugin.java:
##########
@@ -243,24 +243,36 @@ private void createEnvironment(
+ HopConfig.getInstance().getConfigFilename());
enableProject(log, environment, variables, hasHopMetadataProvider, config);
-
- validateConfigFiles(log, variables, environment);
logEnvironmentDetails(log, environment);
}
+ /**
+ * Create the environment's missing configuration files, then enable its
project with them.
+ *
+ * <p>The project variables are applied before the files are created, since
a configuration file
+ * path can refer to them (for example '${PROJECT_HOME}'). Enabling the
project reads the files,
+ * so they have to exist by then.
+ */
private void enableProject(
ILogChannel log,
LifecycleEnvironment environment,
IVariables variables,
IHasHopMetadataProvider hasHopMetadataProvider,
ProjectsConfig config)
- throws HopException {
+ throws Exception {
ProjectConfig projectConfig =
config.findProjectConfig(environment.getProjectName());
if (projectConfig == null) {
log.logBasic(
"Warning: referenced project '" + environment.getProjectName() + "'
doesn't exist");
+ validateConfigFiles(log, variables, environment);
} else {
Project project = projectConfig.loadProject(variables);
+ // Project variables only, so '${PROJECT_HOME}' in the configuration
file paths resolves.
+ // enableProject() below applies them again, together with the
configuration files.
+ //
+ project.modifyVariables(variables, projectConfig, new ArrayList<>(),
environmentName);
Review Comment:
@hansva Same as the nit in the first review: the first pass is needed so
`'${PROJECT_HOME}'`, project variables and parent variables resolve in the file
paths. The cost is a second load of the parent and a duplicate error line when
a parent is broken. I left it, with the comment explaining why.
##########
plugins/misc/lint/src/main/java/org/apache/hop/lint/LinterConfigPlugin.java:
##########
@@ -420,11 +420,8 @@ public LinterConfigPlugin() {
}
/**
- * Called by the configuration perspective when the user applies changes,
and by {@code hop conf}
- * for every registered config plugin whether or not it was given any
options.
- *
- * <p>Because {@code hop conf} calls this unconditionally, doing anything
when nothing was set
- * would rewrite the linter settings on every unrelated {@code hop conf}
command.
+ * Called by {@code hop conf} when at least one of the linter options was
given. The fields hold
Review Comment:
@hansva The configuration perspective saves through `persistContents()`, not
`handleOption()`. Nothing in the GUI calls `handleOption()`, and the linter is
a `config`-category plugin, so only hop conf reaches it. The old note was out
of date.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]