use of org.ballerinax.kubernetes.models.knative.SecretModel in project kubernetes by ballerinax.
the class KnativeSecretHandler method createArtifacts.
@Override
public void createArtifacts() throws KubernetesPluginException {
// secret
int count = 0;
Collection<SecretModel> secretModels = knativeDataHolder.getSecretModelSet();
if (secretModels.size() > 0) {
OUT.println();
}
for (SecretModel secretModel : secretModels) {
count++;
generate(secretModel);
OUT.print("\t@kubernetes:Secret \t\t\t - complete " + count + "/" + secretModels.size() + "\r");
}
}
use of org.ballerinax.kubernetes.models.knative.SecretModel in project kubernetes by ballerinax.
the class KnativeServiceHandler method populateVolumeMounts.
private List<VolumeMount> populateVolumeMounts(ServiceModel serviceModel) {
List<VolumeMount> volumeMounts = new ArrayList<>();
for (SecretModel secretModel : serviceModel.getSecretModels()) {
VolumeMount volumeMount = new VolumeMountBuilder().withMountPath(secretModel.getMountPath()).withName(secretModel.getName() + VOLUME_DEFINE).withReadOnly(secretModel.isReadOnly()).build();
volumeMounts.add(volumeMount);
}
for (ConfigMapModel configMapModel : serviceModel.getConfigMapModels()) {
VolumeMount volumeMount = new VolumeMountBuilder().withMountPath(configMapModel.getMountPath()).withName(configMapModel.getName() + VOLUME_DEFINE).withReadOnly(configMapModel.isReadOnly()).build();
volumeMounts.add(volumeMount);
}
return volumeMounts;
}
use of org.ballerinax.kubernetes.models.knative.SecretModel in project kubernetes by ballerinax.
the class KnativeSecretAnnotationProcesser method processSecret.
private void processSecret(IdentifierNode nodeID, AnnotationAttachmentNode attachmentNode) throws KubernetesPluginException {
Set<SecretModel> secrets = new HashSet<>();
List<BLangRecordLiteral.BLangRecordKeyValueField> keyValues = convertRecordFields(((BLangRecordLiteral) ((BLangAnnotationAttachment) attachmentNode).expr).getFields());
for (BLangRecordLiteral.BLangRecordKeyValueField keyValue : keyValues) {
List<BLangExpression> secretAnnotation = ((BLangListConstructorExpr) keyValue.valueExpr).exprs;
for (BLangExpression bLangExpression : secretAnnotation) {
SecretModel secretModel = new SecretModel();
List<BLangRecordLiteral.BLangRecordKeyValueField> annotationValues = convertRecordFields(((BLangRecordLiteral) bLangExpression).getFields());
for (BLangRecordLiteral.BLangRecordKeyValueField annotation : annotationValues) {
SecretMountConfig secretMountConfig = SecretMountConfig.valueOf(annotation.getKey().toString());
switch(secretMountConfig) {
case name:
secretModel.setName(getValidName(getStringValue(annotation.getValue())));
break;
case labels:
secretModel.setLabels(getMap(keyValue.getValue()));
break;
case annotations:
secretModel.setAnnotations(getMap(keyValue.getValue()));
break;
case mountPath:
secretModel.setMountPath(getStringValue(annotation.getValue()));
break;
case data:
List<BLangExpression> data = ((BLangListConstructorExpr) annotation.valueExpr).exprs;
secretModel.setData(getDataForSecret(data));
break;
case readOnly:
secretModel.setReadOnly(getBooleanValue(annotation.getValue()));
break;
default:
break;
}
}
if (isBlank(secretModel.getName())) {
secretModel.setName(getValidName(nodeID.getValue()) + SECRET_POSTFIX);
}
secrets.add(secretModel);
}
}
KnativeContext.getInstance().getDataHolder().addSecrets(secrets);
}
use of org.ballerinax.kubernetes.models.knative.SecretModel in project kubernetes by ballerinax.
the class KnativeServiceHandler method populateVolume.
private List<Volume> populateVolume(ServiceModel serviceModel) {
List<Volume> volumes = new ArrayList<>();
for (SecretModel secretModel : serviceModel.getSecretModels()) {
Volume volume = new VolumeBuilder().withName(secretModel.getName() + VOLUME_DEFINE).withNewSecret().withSecretName(secretModel.getName()).endSecret().build();
volumes.add(volume);
}
for (ConfigMapModel configMapModel : serviceModel.getConfigMapModels()) {
Volume volume = new VolumeBuilder().withName(configMapModel.getName() + VOLUME_DEFINE).withNewConfigMap().withName(configMapModel.getName()).endConfigMap().build();
volumes.add(volume);
}
return volumes;
}
Aggregations