com.netflix.spinnaker.orca.util.ExpressionUtils Maven / Gradle / Ivy
/*
* Copyright 2019 Netflix, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.netflix.spinnaker.orca.util;
import com.google.common.base.Strings;
import com.netflix.spinnaker.kork.exceptions.UserException;
import com.netflix.spinnaker.orca.api.pipeline.models.PipelineExecution;
import com.netflix.spinnaker.orca.api.pipeline.models.StageExecution;
import com.netflix.spinnaker.orca.pipeline.EvaluateVariablesStage;
import com.netflix.spinnaker.orca.pipeline.StageDefinitionBuilderFactory;
import com.netflix.spinnaker.orca.pipeline.expressions.PipelineExpressionEvaluator;
import com.netflix.spinnaker.orca.pipeline.model.StageExecutionImpl;
import com.netflix.spinnaker.orca.pipeline.util.ContextParameterProcessor;
import com.netflix.spinnaker.orca.q.handler.ExpressionAware;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import org.jetbrains.annotations.NotNull;
import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@Component
public class ExpressionUtils implements ExpressionAware {
private ContextParameterProcessor contextParameterProcessor;
private StageDefinitionBuilderFactory stageDefinitionBuilderFactory;
@Autowired
public ExpressionUtils(
ContextParameterProcessor contextParameterProcessor,
StageDefinitionBuilderFactory stageDefinitionBuilderFactory) {
this.contextParameterProcessor = contextParameterProcessor;
this.stageDefinitionBuilderFactory = stageDefinitionBuilderFactory;
}
public Map evaluateVariables(
@Nonnull PipelineExecution execution,
@Nonnull List requisiteStageRefIds,
@Nullable String spelVersionOverride,
@Nonnull List