use of org.ballerinax.docker.generator.models.CopyFileModel in project kubernetes by ballerinax.
the class KnativeUtils method getExternalFileMap.
/**
* Get the set of external files to copy to docker image.
*
* @param keyValue Value of copyFiles field of Job annotation.
* @return A set of external files
* @throws KubernetesPluginException if an error occur while getting the paths
*/
public static Set<CopyFileModel> getExternalFileMap(BLangRecordLiteral.BLangRecordKeyValueField keyValue) throws KubernetesPluginException {
Set<CopyFileModel> externalFiles = new HashSet<>();
List<BLangExpression> configAnnotation = ((BLangListConstructorExpr) keyValue.valueExpr).exprs;
for (BLangExpression bLangExpression : configAnnotation) {
List<BLangRecordLiteral.BLangRecordKeyValueField> annotationValues = convertRecordFields(((BLangRecordLiteral) bLangExpression).getFields());
CopyFileModel externalFileModel = new CopyFileModel();
for (BLangRecordLiteral.BLangRecordKeyValueField annotation : annotationValues) {
switch(annotation.getKey().toString()) {
case "sourceFile":
externalFileModel.setSource(getStringValue(annotation.getValue()));
break;
case "target":
externalFileModel.setTarget(getStringValue(annotation.getValue()));
break;
default:
break;
}
}
if (isBlank(externalFileModel.getSource())) {
throw new KubernetesPluginException("@kubernetes:Deployment copyFiles source cannot be empty.");
}
if (isBlank(externalFileModel.getTarget())) {
throw new KubernetesPluginException("@kubernetes:Deployment copyFiles target cannot be empty.");
}
externalFiles.add(externalFileModel);
}
return externalFiles;
}
use of org.ballerinax.docker.generator.models.CopyFileModel in project kubernetes by ballerinax.
the class KubernetesUtils method getExternalFileMap.
/**
* Get the set of external files to copy to docker image.
*
* @param keyValue Value of copyFiles field of Job annotation.
* @return A set of external files
* @throws KubernetesPluginException if an error occur while getting the paths
*/
public static Set<CopyFileModel> getExternalFileMap(BLangRecordLiteral.BLangRecordKeyValueField keyValue) throws KubernetesPluginException {
Set<CopyFileModel> externalFiles = new HashSet<>();
List<BLangExpression> configAnnotation = ((BLangListConstructorExpr) keyValue.valueExpr).exprs;
for (BLangExpression bLangExpression : configAnnotation) {
List<BLangRecordLiteral.BLangRecordKeyValueField> annotationValues = convertRecordFields(((BLangRecordLiteral) bLangExpression).getFields());
CopyFileModel externalFileModel = new CopyFileModel();
for (BLangRecordLiteral.BLangRecordKeyValueField annotation : annotationValues) {
switch(annotation.getKey().toString()) {
case "sourceFile":
externalFileModel.setSource(getStringValue(annotation.getValue()));
break;
case "target":
externalFileModel.setTarget(getStringValue(annotation.getValue()));
break;
default:
break;
}
}
if (isBlank(externalFileModel.getSource())) {
throw new KubernetesPluginException("@kubernetes:Deployment copyFiles source cannot be empty.");
}
if (isBlank(externalFileModel.getTarget())) {
throw new KubernetesPluginException("@kubernetes:Deployment copyFiles target cannot be empty.");
}
externalFiles.add(externalFileModel);
}
return externalFiles;
}
Aggregations