Skip to content

Commit

Permalink
fix(web): Fix dependent pipelines API
Browse files Browse the repository at this point in the history
  • Loading branch information
nandak522 committed Apr 23, 2024
1 parent f413f5c commit 2187037
Showing 1 changed file with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
import com.netflix.spinnaker.front50.model.pipeline.PipelineDAO;
import com.netflix.spinnaker.front50.model.pipeline.PipelineTemplate;
import com.netflix.spinnaker.front50.model.pipeline.PipelineTemplateDAO;
import com.netflix.spinnaker.front50.model.pipeline.TemplateConfiguration;
import com.netflix.spinnaker.front50.model.pipeline.V2TemplateConfiguration;
import com.netflix.spinnaker.kork.web.exceptions.NotFoundException;
import java.nio.charset.StandardCharsets;
import java.security.MessageDigest;
Expand Down Expand Up @@ -186,22 +186,23 @@ List<String> getDependentConfigs(String templateId) {
List<String> dependentConfigIds = new ArrayList<>();

String prefixedId = SPINNAKER_PREFIX + templateId;

pipelineDAO.all().stream()
.filter(pipeline -> pipeline.getType() != null && pipeline.getType().equals(TYPE_TEMPLATED))
.forEach(
templatedPipeline -> {
String source;
try {
TemplateConfiguration config =
objectMapper.convertValue(
templatedPipeline.getConfig(), TemplateConfiguration.class);

source = config.getPipeline().getTemplate().getSource();
V2TemplateConfiguration config =
objectMapper.convertValue(templatedPipeline, V2TemplateConfiguration.class);
source = config.getTemplate().getReference();
} catch (Exception e) {
e.printStackTrace();
return;
}

if (source != null && source.equalsIgnoreCase(prefixedId)) {
if (source != null && source.startsWith(prefixedId)) {
dependentConfigIds.add(templatedPipeline.getId());
}
});
Expand Down

0 comments on commit 2187037

Please sign in to comment.