@Before public void createTestResource() { configMap1 = new ConfigMapBuilder() .withNewMetadata() .withName("configmap1") .withNamespace("ns1") .withAnnotations(Collections.singletonMap("foo", "bar")) .withLabels(Collections.singletonMap("foo-label", "bar-label")) .endMetadata() .addToData("one", "1") .build(); }
@Override protected ConfigMap resource() { return new ConfigMapBuilder() .withNewMetadata() .withName(RESOURCE_NAME) .withNamespace(NAMESPACE) .withLabels(singletonMap("foo", "bar")) .endMetadata() .withData(singletonMap("FOO", Integer.toString(new Random().nextInt()))) .build(); } }
private void generate(ConfigMapModel configMapModel) throws KubernetesPluginException { ConfigMap configMap = new ConfigMapBuilder() .withNewMetadata() .withName(configMapModel.getName()) .withNamespace(dataHolder.getNamespace()) .endMetadata() .withData(configMapModel.getData()) .build(); try { String configMapContent = SerializationUtils.dumpWithoutRuntimeStateAsYaml(configMap); KubernetesUtils.writeToFile(configMapContent, CONFIG_MAP_FILE_POSTFIX + YAML); } catch (IOException e) { String errorMessage = "Error while parsing yaml file for config map: " + configMapModel.getName(); throw new KubernetesPluginException(errorMessage, e); } }
protected ConfigMap createConfigMap(String name, Map<String, String> data) { return new ConfigMapBuilder() .withNewMetadata() .withName(name) .withNamespace(namespace) .withLabels(labels.toMap()) .withOwnerReferences(createOwnerReference()) .endMetadata() .withData(data) .build(); }