use of io.fabric8.kubernetes.api.model.apps.RollingUpdateDeployment in project kubernetes by ballerinax.
the class DeploymentAnnotationProcessor method getStrategy.
/**
* Get Deployment strategy.
*
* @param keyValue Value of strategy field of deployment annotation.
* @return DeploymentStrategy..
*/
private DeploymentStrategy getStrategy(BLangRecordLiteral.BLangRecordKeyValueField keyValue) throws KubernetesPluginException {
DeploymentStrategy strategy = new DeploymentStrategy();
if (keyValue.getValue().type.getKind() == TypeKind.STRING) {
// Rolling Update for Recreate with default values
strategy.setType((getStringValue(keyValue.getValue())));
return strategy;
}
RollingUpdateDeployment rollingParams = new RollingUpdateDeployment();
strategy.setType("RollingUpdate");
for (BLangRecordLiteral.RecordField strategyField : ((BLangRecordLiteral) keyValue.valueExpr).fields) {
BLangRecordLiteral.BLangRecordKeyValueField strategyKeyValueField = ((BLangRecordLiteral.BLangRecordKeyValueField) strategyField);
switch(strategyKeyValueField.getKey().toString()) {
case "maxUnavailable":
if (strategyKeyValueField.getValue().type.getKind() == TypeKind.INT) {
rollingParams.setMaxUnavailable(new IntOrString(getIntValue(strategyKeyValueField.getValue())));
} else {
rollingParams.setMaxUnavailable(new IntOrString(getStringValue(strategyKeyValueField.getValue())));
}
break;
case "maxSurge":
if (strategyKeyValueField.getValue().type.getKind() == TypeKind.INT) {
rollingParams.setMaxSurge(new IntOrString(getIntValue(strategyKeyValueField.getValue())));
} else {
rollingParams.setMaxSurge(new IntOrString(getStringValue(strategyKeyValueField.getValue())));
}
break;
default:
break;
}
}
strategy.setRollingUpdate(rollingParams);
return strategy;
}
Aggregations