NodeSelectorProvisioner implements ConfigurationProvisioner { @Override public void provision(KubernetesEnvironment k8sEnv, RuntimeIdentity identity) throws InfrastructureException { if (!nodeSelectorAttributes.isEmpty()) { k8sEnv .getPodsData() .values() .forEach(d -> d.getSpec().setNodeSelector(nodeSelectorAttributes)); } } @Inject  NodeSelectorProvisioner(
      @Nullable @Named("che.workspace.pod.node_selector") String nodeSelectorProperty); @Override void provision(KubernetesEnvironment k8sEnv, RuntimeIdentity identity);  }
@Test public void shouldAddNodeSelectorIntoAllPods() throws Exception { k8sEnv.addPod(createPod("pod")); k8sEnv.addPod(createPod("pod2")); provisioner = new NodeSelectorProvisioner("a=b,foo=bar"); provisioner.provision(k8sEnv, runtimeId); for (Pod pod : k8sEnv.getPodsCopy().values()) { assertEquals(pod.getSpec().getNodeSelector().size(), 2); assertEquals(pod.getSpec().getNodeSelector().get("a"), "b"); assertEquals(pod.getSpec().getNodeSelector().get("foo"), "bar"); } }
@Test public void shouldOmitEmptySelector() throws Exception { k8sEnv.addPod(createPod("pod")); k8sEnv.addPod(createPod("pod2")); provisioner = new NodeSelectorProvisioner(null); provisioner.provision(k8sEnv, runtimeId); for (Pod pod : k8sEnv.getPodsCopy().values()) { assertTrue(pod.getSpec().getNodeSelector().isEmpty()); } }