Search in sources :

Example 1 with V1SecurityContextBuilder

use of io.kubernetes.client.openapi.models.V1SecurityContextBuilder in project cdap by caskdata.

the class KubeTwillPreparer method withSecurityContext.

@Override
public SecureTwillPreparer withSecurityContext(String runnableName, SecurityContext securityContext) {
    if (securityContext.getIdentity() != null) {
        setIdentity(runnableName, securityContext.getIdentity());
    }
    if (securityContext.getUserId() != null || securityContext.getGroupId() != null) {
        V1SecurityContextBuilder builder = new V1SecurityContextBuilder();
        if (securityContext.getUserId() != null) {
            builder.withRunAsUser(securityContext.getUserId());
        }
        if (securityContext.getGroupId() != null) {
            builder.withRunAsGroup(securityContext.getGroupId());
        }
        containerSecurityContexts.put(runnableName, builder.build());
    }
    return this;
}
Also used : V1SecurityContextBuilder(io.kubernetes.client.openapi.models.V1SecurityContextBuilder)

Aggregations

V1SecurityContextBuilder (io.kubernetes.client.openapi.models.V1SecurityContextBuilder)1