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();
}
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();
}
Aggregations