private String getTagName(Class<?> clazz) { return clazz.getAnnotation(ConfigTag.class).value(); }
@ConfigTag("depends") public class DependsConfig { @ConfigAttribute(value = "pipeline", optional = false) private String pipeline; @ConfigAttribute(value = "stage", optional = false) private String stage; public DependsConfig() { } public DependsConfig(String pipeline, String stage) { this.pipeline = pipeline; this.stage = stage; } public String getPipeline() { return pipeline; } public String getStage() { return stage; } public boolean depends(String pipelineName, String stageName) { return StringUtils.equals(this.pipeline, pipelineName) && StringUtils.equals(this.stage, stageName); } }
private Element child(Element e, ConfigTag tag) { return e.getChild(tag.value(), Namespace.getNamespace(tag.namespacePrefix(), tag.namespaceURI())); }
private static Namespace namespaceFor(ConfigTag annotation) { return Namespace.getNamespace(annotation.namespacePrefix(), annotation.namespaceURI()); }
public static boolean compare(Element e, Class<?> implementation, ConfigCache configCache) { final AttributeAwareConfigTag attributeAwareConfigTag = annotationFor(implementation, AttributeAwareConfigTag.class); if (attributeAwareConfigTag != null) { return compareAttributeAwareConfigTag(e, attributeAwareConfigTag); } ConfigTag configTag = configTag(implementation, configCache); return configTag.value().equals(e.getName()) && e.getNamespace().getURI().equals(configTag.namespaceURI()); }
@ConfigTag("ant") public class AntTask extends BuildTask { public static final String TYPE = "ant";
private String getTagName() { return profile.getClass().getAnnotation(ConfigTag.class).value(); }
@ConfigTag("rake") public class RakeTask extends BuildTask { public static final String TYPE = "rake";
public String getParentDisplayName() { return getParent().getClass().getAnnotation(ConfigTag.class).value(); }
@ConfigTag("value") public class VariableValueConfig implements Serializable { @ConfigValue
public String getParentDisplayName() { return getParentType().getAnnotation(ConfigTag.class).value(); }
@ConfigTag("encryptedValue") public class EncryptedVariableValueConfig implements Serializable{ @ConfigValue
public static List<String> allTasks(ConfigElementImplementationRegistry registry) { List<String> allTasks = new ArrayList<>(); for (Class<? extends Task> task : registry.implementersOf(Task.class)) { AttributeAwareConfigTag attributeAwareConfigTag = task.getAnnotation(AttributeAwareConfigTag.class); if (attributeAwareConfigTag != null && !allTasks.contains(attributeAwareConfigTag.value())) { allTasks.add(attributeAwareConfigTag.value()); } ConfigTag tag = task.getAnnotation(ConfigTag.class); if (tag != null && !allTasks.contains(tag.value())) { allTasks.add(tag.value()); } } return allTasks; }
@ConfigTag(value = "arg", label = "arg") public class Argument implements Validatable{ @ConfigValue @ValidationErrorKey(value = ExecTask.ARG_LIST_STRING) private String value;
private void update(Username currentUser, PipelineConfigs pipelineConfigs, LocalizedOperationResult result, EntityConfigUpdateCommand command) { try { goConfigService.updateConfig(command, currentUser); } catch (Exception e) { if (e instanceof GoConfigInvalidException) { if (!result.hasMessage()) { result.unprocessableEntity(entityConfigValidationFailed(pipelineConfigs.getClass().getAnnotation(ConfigTag.class).value(), pipelineConfigs.getGroup(), e.getMessage())); } } else if (!(e instanceof ConfigUpdateCheckFailedException)) { LOGGER.error(e.getMessage(), e); result.internalServerError(saveFailedWithReason(e.getMessage())); } } }
@ConfigTag("user") public class RoleUser implements Validatable { private static final String NAME = "name";
private void update(Username currentUser, PipelineConfig pipelineConfig, LocalizedOperationResult result, EntityConfigUpdateCommand command) { try { goConfigService.updateConfig(command, currentUser); } catch (Exception e) { if (e instanceof GoConfigInvalidException) { if (!result.hasMessage()) { result.unprocessableEntity(entityConfigValidationFailed(pipelineConfig.getClass().getAnnotation(ConfigTag.class).value(), str(pipelineConfig.name()), e.getMessage())); } } else if (!(e instanceof ConfigUpdateCheckFailedException)) { LOGGER.error(e.getMessage(), e); result.internalServerError(saveFailedWithReason(e.getMessage())); } } }
@ConfigTag("physical") public class EnvironmentAgentConfig implements Validatable{ @ConfigAttribute(value = "uuid", optional = false) private String uuid;
private void update(Username username, PackageDefinition packageDeinition, HttpLocalizedOperationResult result, EntityConfigUpdateCommand command) { try { goConfigService.updateConfig(command, username); } catch (Exception e) { if (e instanceof GoConfigInvalidException && !result.hasMessage()) { result.unprocessableEntity(entityConfigValidationFailed(packageDeinition.getClass().getAnnotation(ConfigTag.class).value(), packageDeinition.getId(), e.getMessage())); } else { if (!result.hasMessage()) { LOGGER.error(e.getMessage(), e); result.internalServerError(saveFailedWithReason("An error occurred while saving the package config. Please check the logs for more information.")); } } } }