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

feat(pipeline_template): Add support of semver for template tags #993

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.codec.binary.Hex;
Expand All @@ -62,6 +64,9 @@ public class V2PipelineTemplateController {
private static final List<String> VALID_TEMPLATE_TAGS =
Arrays.asList("latest", "stable", "unstable", "experimental", "test", "canary");

public static final Pattern VALID_TEMPLATE_TAG_PATTERN =
Pattern.compile("^v?[0-9]\\d*\\.\\d+\\.\\d+(?:-[a-zA-Z0-9]+)?$");

@Autowired(required = false)
PipelineTemplateDAO pipelineTemplateDAO = null;

Expand Down Expand Up @@ -257,10 +262,12 @@ private PipelineTemplateDAO getPipelineTemplateDAO() {
}

private void validatePipelineTemplateTag(String tag) {
if (!VALID_TEMPLATE_TAGS.contains(tag)) {
Matcher m = VALID_TEMPLATE_TAG_PATTERN.matcher(tag);
if (!VALID_TEMPLATE_TAGS.contains(tag) && !m.matches()) {
throw new InvalidRequestException(
String.format(
"The provided tag %s is not supported." + " Pipeline template must tag be one of %s",
"The provided tag %s is not supported."
+ " Pipeline template must tag be one of %s or semantic versioning",
tag, VALID_TEMPLATE_TAGS));
}
}
Expand Down