use of io.fabric8.kubernetes.api.model.Binding in project intellij-tekton by redhat-developer.
the class AddTriggerAction method getTriggerBindings.
private Map<String, String> getTriggerBindings(String namespace, Tkn tkncli) {
Map<String, String> triggerBindingsOnCluster = new HashMap<>();
GenericKubernetesResourceList allTriggerBindings = tkncli.getCustomResources(namespace, CRDHelper.getCRDContext("triggers.tekton.dev/v1beta1", "triggerbindings"));
if (allTriggerBindings == null) {
return triggerBindingsOnCluster;
}
allTriggerBindings.getItems().forEach(binding -> {
try {
String bindingAsYAML = YAMLBuilder.writeValueAsString(binding);
triggerBindingsOnCluster.put(binding.getMetadata().getName(), bindingAsYAML);
} catch (IOException e) {
logger.warn(e.getLocalizedMessage(), e);
}
});
return triggerBindingsOnCluster;
}
use of io.fabric8.kubernetes.api.model.Binding in project quarkus-operator-sdk by quarkiverse.
the class CsvManifestsBuilder method handlePermissions.
private void handlePermissions(List<ClusterRole> clusterRoles, List<RoleBinding> roleBindings, List<Role> roles, String defaultServiceAccountName, NamedInstallStrategyFluent.SpecNested<ClusterServiceVersionSpecFluent.InstallNested<ClusterServiceVersionFluent.SpecNested<ClusterServiceVersionBuilder>>> installSpec) {
Map<String, List<PolicyRule>> customPermissionRules = new HashMap<>();
if (metadata.permissionRules != null) {
for (CSVMetadataHolder.PermissionRule permissionRule : metadata.permissionRules) {
String serviceAccountName = StringUtils.defaultIfEmpty(permissionRule.serviceAccountName, defaultServiceAccountName);
List<PolicyRule> customRulesByServiceAccount = customPermissionRules.get(serviceAccountName);
if (customRulesByServiceAccount == null) {
customRulesByServiceAccount = new LinkedList<>();
customPermissionRules.put(serviceAccountName, customRulesByServiceAccount);
}
customRulesByServiceAccount.add(new PolicyRuleBuilder().addAllToApiGroups(Arrays.asList(permissionRule.apiGroups)).addAllToResources(Arrays.asList(permissionRule.resources)).addAllToVerbs(Arrays.asList(permissionRule.verbs)).build());
}
}
for (RoleBinding binding : roleBindings) {
String serviceAccountName = findServiceAccountFromSubjects(binding.getSubjects(), defaultServiceAccountName);
if (NO_SERVICE_ACCOUNT.equals(serviceAccountName)) {
LOGGER.warnf("Role '%s' was not added because the service account is missing", binding.getRoleRef().getName());
continue;
}
List<PolicyRule> rules = new LinkedList<>();
rules.addAll(findRules(binding.getRoleRef(), clusterRoles, roles));
Optional.ofNullable(customPermissionRules.remove(serviceAccountName)).ifPresent(rules::addAll);
handlerPermission(rules, serviceAccountName, installSpec);
}
}
use of io.fabric8.kubernetes.api.model.Binding 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.kubernetes.api.model.Binding 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();
}
use of io.fabric8.kubernetes.api.model.Binding in project docker-maven-plugin by fabric8io.
the class VolumeBindingUtilTest method testResolveRelativeVolumePathWithAccessSpecifications.
/**
* Insures that a host volume binding string that contains a path relative to the current working directory <em>and
* </em> specifies access controls resolves to the supplied base directory <em>and</em> that the access controls are
* preserved through the operation.
*/
@Test
public void testResolveRelativeVolumePathWithAccessSpecifications() {
String volumeString = format(BIND_STRING_WITH_ACCESS_FMT, RELATIVE_PATH, CONTAINER_PATH, RO_ACCESS);
// './rel:/path/to/container/dir:ro' to '/absolute/basedir/rel:/path/to/container/dir:ro'
String relativizedVolumeString = resolveRelativeVolumeBinding(ABS_BASEDIR, volumeString);
String expectedBindingString = format(BIND_STRING_WITH_ACCESS_FMT, new File(ABS_BASEDIR, stripLeadingPeriod(RELATIVE_PATH)), CONTAINER_PATH, RO_ACCESS);
assertEquals(expectedBindingString, relativizedVolumeString);
}
Aggregations