Skip to content

Commit

Permalink
feat(core): Support deserializing Execution.initialConfig (#3019)
Browse files Browse the repository at this point in the history
Also adds support for using `initialConfig.enabled` as a short circuit
of the `EnabledPipelineValidator` check.

This seems reasonable as a user can already submit pipeline json against
an arbitrary pipeline config id (that may or may not exist).

Providing an ability to explicitly override the enabled check seems
harmless.
  • Loading branch information
ajordens committed Jul 3, 2019
1 parent 9e6f470 commit bce489e
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ private Execution parsePipeline(String configJson) throws IOException {
.withLimitConcurrent(getBoolean(config, "limitConcurrent"))
.withKeepWaitingPipelines(getBoolean(config, "keepWaitingPipelines"))
.withNotifications((List<Map<String, Object>>) config.get("notifications"))
.withInitialConfig((Map<String, Object>) config.get("initialConfig"))
.withOrigin(getString(config, "origin"))
.withStartTimeExpiry(getString(config, "startTimeExpiry"))
.withSource(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -292,9 +292,9 @@ public void setSource(@Nullable PipelineSource source) {
return notifications;
}

private final Map<String, Serializable> initialConfig = new HashMap<>();
private final Map<String, Object> initialConfig = new HashMap<>();

public @Nonnull Map<String, Serializable> getInitialConfig() {
public @Nonnull Map<String, Object> getInitialConfig() {
return initialConfig;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,15 @@ public PipelineBuilder withNotifications(List<Map<String, Object>> notifications
return this;
}

public PipelineBuilder withInitialConfig(Map<String, Object> initialConfig) {
pipeline.getInitialConfig().clear();
if (initialConfig != null) {
pipeline.getInitialConfig().putAll(initialConfig);
}

return this;
}

public PipelineBuilder withPipelineConfigId(String id) {
pipeline.setPipelineConfigId(id);
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ public void checkRunnable(Execution pipeline) {
"Front50 not enabled, no way to validate pipeline. Fix this by setting front50.enabled: true");
}

Boolean isExplicitlyEnabled =
(Boolean) pipeline.getInitialConfig().getOrDefault("enabled", false);
if (isExplicitlyEnabled) {
return;
}

if (!isStrategy(pipeline)) {
try {
// attempt an optimized lookup via pipeline history vs fetching all pipelines for the
Expand Down

0 comments on commit bce489e

Please sign in to comment.