Search in sources :

Example 1 with ValidatingWebhookConfiguration

use of io.fabric8.kubernetes.api.model.admissionregistration.v1.ValidatingWebhookConfiguration in project strimzi by strimzi.

the class SetupDrainCleaner method applyInstallFiles.

public void applyInstallFiles(ExtensionContext extensionContext) {
    List<File> drainCleanerFiles = Arrays.stream(new File(PATH_TO_DC_CONFIG).listFiles()).sorted().filter(File::isFile).collect(Collectors.toList());
    drainCleanerFiles.forEach(file -> {
        if (!file.getName().contains("README") && !file.getName().contains("Namespace") && !file.getName().contains("Deployment")) {
            final String resourceType = file.getName().split("-")[1].split(".yaml")[0];
            switch(resourceType) {
                case Constants.CLUSTER_ROLE:
                    ClusterRole clusterRole = TestUtils.configFromYaml(file, ClusterRole.class);
                    ResourceManager.getInstance().createResource(extensionContext, clusterRole);
                    break;
                case Constants.SERVICE_ACCOUNT:
                    ServiceAccount serviceAccount = TestUtils.configFromYaml(file, ServiceAccount.class);
                    ResourceManager.getInstance().createResource(extensionContext, new ServiceAccountBuilder(serviceAccount).editMetadata().withNamespace(Constants.DRAIN_CLEANER_NAMESPACE).endMetadata().build());
                    break;
                case Constants.CLUSTER_ROLE_BINDING:
                    ClusterRoleBinding clusterRoleBinding = TestUtils.configFromYaml(file, ClusterRoleBinding.class);
                    ResourceManager.getInstance().createResource(extensionContext, new ClusterRoleBindingBuilder(clusterRoleBinding).build());
                    break;
                case Constants.SECRET:
                    Secret secret = TestUtils.configFromYaml(file, Secret.class);
                    ResourceManager.getInstance().createResource(extensionContext, secret);
                    break;
                case Constants.SERVICE:
                    Service service = TestUtils.configFromYaml(file, Service.class);
                    ResourceManager.getInstance().createResource(extensionContext, service);
                    break;
                case Constants.VALIDATION_WEBHOOK_CONFIG:
                    ValidatingWebhookConfiguration webhookConfiguration = TestUtils.configFromYaml(file, ValidatingWebhookConfiguration.class);
                    ResourceManager.getInstance().createResource(extensionContext, webhookConfiguration);
                    break;
                default:
                    LOGGER.error("Unknown installation resource type: {}", resourceType);
                    throw new RuntimeException("Unknown installation resource type:" + resourceType);
            }
        }
    });
}
Also used : Secret(io.fabric8.kubernetes.api.model.Secret) ServiceAccount(io.fabric8.kubernetes.api.model.ServiceAccount) ValidatingWebhookConfiguration(io.fabric8.kubernetes.api.model.admissionregistration.v1.ValidatingWebhookConfiguration) ClusterRoleBindingBuilder(io.fabric8.kubernetes.api.model.rbac.ClusterRoleBindingBuilder) ClusterRoleBinding(io.fabric8.kubernetes.api.model.rbac.ClusterRoleBinding) ServiceAccountBuilder(io.fabric8.kubernetes.api.model.ServiceAccountBuilder) Service(io.fabric8.kubernetes.api.model.Service) File(java.io.File) ClusterRole(io.fabric8.kubernetes.api.model.rbac.ClusterRole)

Example 2 with ValidatingWebhookConfiguration

use of io.fabric8.kubernetes.api.model.admissionregistration.v1.ValidatingWebhookConfiguration in project strimzi-kafka-operator by strimzi.

the class SetupDrainCleaner method applyInstallFiles.

public void applyInstallFiles(ExtensionContext extensionContext) {
    List<File> drainCleanerFiles = Arrays.stream(new File(PATH_TO_DC_CONFIG).listFiles()).sorted().filter(File::isFile).collect(Collectors.toList());
    drainCleanerFiles.forEach(file -> {
        if (!file.getName().contains("README") && !file.getName().contains("Namespace") && !file.getName().contains("Deployment")) {
            final String resourceType = file.getName().split("-")[1].split(".yaml")[0];
            switch(resourceType) {
                case Constants.CLUSTER_ROLE:
                    ClusterRole clusterRole = TestUtils.configFromYaml(file, ClusterRole.class);
                    ResourceManager.getInstance().createResource(extensionContext, clusterRole);
                    break;
                case Constants.SERVICE_ACCOUNT:
                    ServiceAccount serviceAccount = TestUtils.configFromYaml(file, ServiceAccount.class);
                    ResourceManager.getInstance().createResource(extensionContext, new ServiceAccountBuilder(serviceAccount).editMetadata().withNamespace(Constants.DRAIN_CLEANER_NAMESPACE).endMetadata().build());
                    break;
                case Constants.CLUSTER_ROLE_BINDING:
                    ClusterRoleBinding clusterRoleBinding = TestUtils.configFromYaml(file, ClusterRoleBinding.class);
                    ResourceManager.getInstance().createResource(extensionContext, new ClusterRoleBindingBuilder(clusterRoleBinding).build());
                    break;
                case Constants.SECRET:
                    Secret secret = TestUtils.configFromYaml(file, Secret.class);
                    ResourceManager.getInstance().createResource(extensionContext, secret);
                    break;
                case Constants.SERVICE:
                    Service service = TestUtils.configFromYaml(file, Service.class);
                    ResourceManager.getInstance().createResource(extensionContext, service);
                    break;
                case Constants.VALIDATION_WEBHOOK_CONFIG:
                    ValidatingWebhookConfiguration webhookConfiguration = TestUtils.configFromYaml(file, ValidatingWebhookConfiguration.class);
                    ResourceManager.getInstance().createResource(extensionContext, webhookConfiguration);
                    break;
                default:
                    LOGGER.error("Unknown installation resource type: {}", resourceType);
                    throw new RuntimeException("Unknown installation resource type:" + resourceType);
            }
        }
    });
}
Also used : Secret(io.fabric8.kubernetes.api.model.Secret) ServiceAccount(io.fabric8.kubernetes.api.model.ServiceAccount) ValidatingWebhookConfiguration(io.fabric8.kubernetes.api.model.admissionregistration.v1.ValidatingWebhookConfiguration) ClusterRoleBindingBuilder(io.fabric8.kubernetes.api.model.rbac.ClusterRoleBindingBuilder) ClusterRoleBinding(io.fabric8.kubernetes.api.model.rbac.ClusterRoleBinding) ServiceAccountBuilder(io.fabric8.kubernetes.api.model.ServiceAccountBuilder) Service(io.fabric8.kubernetes.api.model.Service) File(java.io.File) ClusterRole(io.fabric8.kubernetes.api.model.rbac.ClusterRole)

Aggregations

Secret (io.fabric8.kubernetes.api.model.Secret)2 Service (io.fabric8.kubernetes.api.model.Service)2 ServiceAccount (io.fabric8.kubernetes.api.model.ServiceAccount)2 ServiceAccountBuilder (io.fabric8.kubernetes.api.model.ServiceAccountBuilder)2 ValidatingWebhookConfiguration (io.fabric8.kubernetes.api.model.admissionregistration.v1.ValidatingWebhookConfiguration)2 ClusterRole (io.fabric8.kubernetes.api.model.rbac.ClusterRole)2 ClusterRoleBinding (io.fabric8.kubernetes.api.model.rbac.ClusterRoleBinding)2 ClusterRoleBindingBuilder (io.fabric8.kubernetes.api.model.rbac.ClusterRoleBindingBuilder)2 File (java.io.File)2