Search in sources :

Example 1 with DoneablePolicyBinding

use of io.fabric8.openshift.api.model.DoneablePolicyBinding in project kie-wb-common by kiegroup.

the class OpenShiftClient method addServiceAccountRole.

private void addServiceAccountRole(String prjName, String name, String role) {
    Resource<PolicyBinding, DoneablePolicyBinding> bindingResource = delegate.policyBindings().inNamespace(prjName).withName(":default");
    DoneablePolicyBinding binding;
    if (bindingResource.get() == null) {
        binding = bindingResource.createNew();
    } else {
        binding = bindingResource.edit();
    }
    binding.editOrNewMetadata().withName(":default").endMetadata().editOrNewPolicyRef().withName("default").endPolicyRef().addNewRoleBinding().withName(role).editOrNewRoleBinding().editOrNewMetadata().withName(role).withNamespace(prjName).endMetadata().addToUserNames("system:serviceaccount:" + prjName + ":" + name).addNewSubject().withName("default").withNamespace(prjName).withKind("ServiceAccount").endSubject().withNewRoleRef().withName(role).endRoleRef().endRoleBinding().endRoleBinding().done();
}
Also used : DoneablePolicyBinding(io.fabric8.openshift.api.model.DoneablePolicyBinding) DoneablePolicyBinding(io.fabric8.openshift.api.model.DoneablePolicyBinding) PolicyBinding(io.fabric8.openshift.api.model.PolicyBinding)

Example 2 with DoneablePolicyBinding

use of io.fabric8.openshift.api.model.DoneablePolicyBinding in project kie-wb-common by kiegroup.

the class OpenShiftClient method addSystemGroupRole.

private void addSystemGroupRole(String prjName, String name, String role) {
    Resource<PolicyBinding, DoneablePolicyBinding> bindingResource = delegate.policyBindings().inNamespace(prjName).withName(":default");
    DoneablePolicyBinding binding;
    if (bindingResource.get() == null) {
        binding = bindingResource.createNew();
    } else {
        binding = bindingResource.edit();
    }
    binding.editOrNewMetadata().withName(":default").endMetadata().editOrNewPolicyRef().withName("default").endPolicyRef().addNewRoleBinding().withName(role).editOrNewRoleBinding().editOrNewMetadata().withName(role).withNamespace(prjName).endMetadata().addToGroupNames("system:serviceaccounts:" + prjName).addNewSubject().withName("default").withNamespace(prjName).withKind("SystemGroup").endSubject().withNewRoleRef().withName(role).endRoleRef().endRoleBinding().endRoleBinding().done();
}
Also used : DoneablePolicyBinding(io.fabric8.openshift.api.model.DoneablePolicyBinding) DoneablePolicyBinding(io.fabric8.openshift.api.model.DoneablePolicyBinding) PolicyBinding(io.fabric8.openshift.api.model.PolicyBinding)

Aggregations

DoneablePolicyBinding (io.fabric8.openshift.api.model.DoneablePolicyBinding)2 PolicyBinding (io.fabric8.openshift.api.model.PolicyBinding)2