use of org.wso2.siddhi.query.api.annotation.Annotation in project siddhi by wso2.
the class SiddhiQLBaseVisitorImpl method visitSiddhi_app.
/**
* {@inheritDoc}
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*
* @param ctx
*/
@Override
public SiddhiApp visitSiddhi_app(@NotNull SiddhiQLParser.Siddhi_appContext ctx) {
SiddhiApp siddhiApp = SiddhiApp.siddhiApp();
for (SiddhiQLParser.App_annotationContext annotationContext : ctx.app_annotation()) {
siddhiApp.annotation((Annotation) visit(annotationContext));
}
for (SiddhiQLParser.Definition_streamContext streamContext : ctx.definition_stream()) {
siddhiApp.defineStream((StreamDefinition) visit(streamContext));
}
for (SiddhiQLParser.Definition_tableContext tableContext : ctx.definition_table()) {
siddhiApp.defineTable((TableDefinition) visit(tableContext));
}
for (SiddhiQLParser.Definition_functionContext functionContext : ctx.definition_function()) {
siddhiApp.defineFunction((FunctionDefinition) visit(functionContext));
}
for (SiddhiQLParser.Definition_windowContext windowContext : ctx.definition_window()) {
siddhiApp.defineWindow((WindowDefinition) visit(windowContext));
}
for (SiddhiQLParser.Definition_aggregationContext aggregationContext : ctx.definition_aggregation()) {
siddhiApp.defineAggregation((AggregationDefinition) visit(aggregationContext));
}
for (SiddhiQLParser.Execution_elementContext executionElementContext : ctx.execution_element()) {
ExecutionElement executionElement = (ExecutionElement) visit(executionElementContext);
if (executionElement instanceof Partition) {
siddhiApp.addPartition((Partition) executionElement);
} else if (executionElement instanceof Query) {
siddhiApp.addQuery((Query) executionElement);
} else {
throw newSiddhiParserException(ctx);
}
}
for (SiddhiQLParser.Definition_triggerContext triggerContext : ctx.definition_trigger()) {
siddhiApp.defineTrigger((TriggerDefinition) visit(triggerContext));
}
populateQueryContext(siddhiApp, ctx);
return siddhiApp;
}
use of org.wso2.siddhi.query.api.annotation.Annotation in project kubernetes by ballerinax.
the class KubernetesAnnotationProcessor method processDeployment.
/**
* Process annotations and create deployment model object.
*
* @param attachmentNode annotation attachment node.
* @return Deployment model object
*/
DeploymentModel processDeployment(AnnotationAttachmentNode attachmentNode) throws KubernetesPluginException {
DeploymentModel deploymentModel = new DeploymentModel();
List<BLangRecordLiteral.BLangRecordKeyValue> keyValues = ((BLangRecordLiteral) ((BLangAnnotationAttachment) attachmentNode).expr).getKeyValuePairs();
for (BLangRecordLiteral.BLangRecordKeyValue keyValue : keyValues) {
DeploymentConfiguration deploymentConfiguration = DeploymentConfiguration.valueOf(keyValue.getKey().toString());
String annotationValue = resolveValue(keyValue.getValue().toString());
switch(deploymentConfiguration) {
case name:
deploymentModel.setName(getValidName(annotationValue));
break;
case labels:
deploymentModel.setLabels(getMap(((BLangRecordLiteral) keyValue.valueExpr).keyValuePairs));
break;
case enableLiveness:
deploymentModel.setEnableLiveness(annotationValue);
break;
case livenessPort:
deploymentModel.setLivenessPort(Integer.parseInt(annotationValue));
break;
case initialDelaySeconds:
deploymentModel.setInitialDelaySeconds(Integer.parseInt(annotationValue));
break;
case periodSeconds:
deploymentModel.setPeriodSeconds(Integer.parseInt(annotationValue));
break;
case username:
deploymentModel.setUsername(annotationValue);
break;
case env:
deploymentModel.setEnv(getMap(((BLangRecordLiteral) keyValue.valueExpr).keyValuePairs));
break;
case password:
deploymentModel.setPassword(annotationValue);
break;
case baseImage:
deploymentModel.setBaseImage(annotationValue);
break;
case push:
deploymentModel.setPush(Boolean.valueOf(annotationValue));
break;
case buildImage:
deploymentModel.setBuildImage(Boolean.valueOf(annotationValue));
break;
case image:
deploymentModel.setImage(annotationValue);
break;
case dockerHost:
deploymentModel.setDockerHost(annotationValue);
break;
case dockerCertPath:
deploymentModel.setDockerCertPath(annotationValue);
break;
case imagePullPolicy:
deploymentModel.setImagePullPolicy(annotationValue);
break;
case replicas:
deploymentModel.setReplicas(Integer.parseInt(annotationValue));
break;
default:
break;
}
}
return deploymentModel;
}
use of org.wso2.siddhi.query.api.annotation.Annotation in project kubernetes by ballerinax.
the class KubernetesAnnotationProcessor method processIngressAnnotation.
/**
* Process annotations and create Ingress model object.
*
* @param serviceName Ballerina service name
* @param attachmentNode annotation attachment node.
* @return Ingress model object
*/
IngressModel processIngressAnnotation(String serviceName, AnnotationAttachmentNode attachmentNode) throws KubernetesPluginException {
IngressModel ingressModel = new IngressModel();
List<BLangRecordLiteral.BLangRecordKeyValue> keyValues = ((BLangRecordLiteral) ((BLangAnnotationAttachment) attachmentNode).expr).getKeyValuePairs();
for (BLangRecordLiteral.BLangRecordKeyValue keyValue : keyValues) {
IngressConfiguration ingressConfiguration = IngressConfiguration.valueOf(keyValue.getKey().toString());
String annotationValue = resolveValue(keyValue.getValue().toString());
switch(ingressConfiguration) {
case name:
ingressModel.setName(getValidName(annotationValue));
break;
case labels:
ingressModel.setLabels(getMap(((BLangRecordLiteral) keyValue.valueExpr).keyValuePairs));
break;
case path:
ingressModel.setPath(annotationValue);
break;
case targetPath:
ingressModel.setTargetPath(annotationValue);
break;
case hostname:
ingressModel.setHostname(annotationValue);
break;
case ingressClass:
ingressModel.setIngressClass(annotationValue);
break;
case enableTLS:
ingressModel.setEnableTLS(Boolean.parseBoolean(annotationValue));
break;
default:
break;
}
}
if (ingressModel.getName() == null || ingressModel.getName().length() == 0) {
ingressModel.setName(getValidName(serviceName) + INGRESS_POSTFIX);
}
if (ingressModel.getHostname() == null || ingressModel.getHostname().length() == 0) {
ingressModel.setHostname(getValidName(serviceName) + INGRESS_HOSTNAME_POSTFIX);
}
return ingressModel;
}
use of org.wso2.siddhi.query.api.annotation.Annotation in project kubernetes by ballerinax.
the class KubernetesAnnotationProcessor method processSecrets.
/**
* Process Secrets annotations.
*
* @param attachmentNode Attachment Node
* @return List of @{@link SecretModel} objects
*/
Set<SecretModel> processSecrets(AnnotationAttachmentNode attachmentNode) throws KubernetesPluginException {
Set<SecretModel> secrets = new HashSet<>();
List<BLangRecordLiteral.BLangRecordKeyValue> keyValues = ((BLangRecordLiteral) ((BLangAnnotationAttachment) attachmentNode).expr).getKeyValuePairs();
for (BLangRecordLiteral.BLangRecordKeyValue keyValue : keyValues) {
List<BLangExpression> secretAnnotation = ((BLangArrayLiteral) keyValue.valueExpr).exprs;
for (BLangExpression bLangExpression : secretAnnotation) {
SecretModel secretModel = new SecretModel();
List<BLangRecordLiteral.BLangRecordKeyValue> annotationValues = ((BLangRecordLiteral) bLangExpression).getKeyValuePairs();
for (BLangRecordLiteral.BLangRecordKeyValue annotation : annotationValues) {
VolumeMountConfig volumeMountConfig = VolumeMountConfig.valueOf(annotation.getKey().toString());
String annotationValue = resolveValue(annotation.getValue().toString());
switch(volumeMountConfig) {
case name:
secretModel.setName(getValidName(annotationValue));
break;
case mountPath:
secretModel.setMountPath(annotationValue);
break;
case data:
List<BLangExpression> data = ((BLangArrayLiteral) annotation.valueExpr).exprs;
secretModel.setData(getDataForSecret(data));
break;
case readOnly:
secretModel.setReadOnly(Boolean.parseBoolean(annotationValue));
break;
default:
break;
}
}
secrets.add(secretModel);
}
}
return secrets;
}
use of org.wso2.siddhi.query.api.annotation.Annotation in project kubernetes by ballerinax.
the class KubernetesAnnotationProcessor method processServiceAnnotation.
/**
* Process annotations and create service model object.
*
* @param endpointName ballerina service name
* @param attachmentNode annotation attachment node.
* @return Service model object
*/
ServiceModel processServiceAnnotation(String endpointName, AnnotationAttachmentNode attachmentNode) throws KubernetesPluginException {
ServiceModel serviceModel = new ServiceModel();
List<BLangRecordLiteral.BLangRecordKeyValue> keyValues = ((BLangRecordLiteral) ((BLangAnnotationAttachment) attachmentNode).expr).getKeyValuePairs();
for (BLangRecordLiteral.BLangRecordKeyValue keyValue : keyValues) {
ServiceConfiguration serviceConfiguration = ServiceConfiguration.valueOf(keyValue.getKey().toString());
String annotationValue = resolveValue(keyValue.getValue().toString());
switch(serviceConfiguration) {
case name:
serviceModel.setName(getValidName(annotationValue));
break;
case labels:
serviceModel.setLabels(getMap(((BLangRecordLiteral) keyValue.valueExpr).keyValuePairs));
break;
case serviceType:
serviceModel.setServiceType(annotationValue);
break;
case port:
serviceModel.setPort(Integer.parseInt(annotationValue));
break;
default:
break;
}
}
if (serviceModel.getName() == null) {
serviceModel.setName(getValidName(endpointName) + SVC_POSTFIX);
}
return serviceModel;
}
Aggregations