KubernetesResourceUtil { public final static void updateKindFilenameMapper(final Map<String, List<String>> mappings) { final Set<Map.Entry<String, List<String>>> entries = mappings.entrySet(); for (Map.Entry<String, List<String>> entry : entries) { final List<String> filenameTypes = entry.getValue(); final String kind = entry.getKey(); for (String filenameType : filenameTypes) { FILENAME_TO_KIND_MAPPER.put(filenameType, kind); } KIND_TO_FILENAME_MAPPER.put(kind, filenameTypes.get(filenameTypes.size() - 1)); } }  static KubernetesListBuilder readResourceFragmentsFrom(PlatformMode platformMode, ResourceVersioning apiVersions,
                                                                  String defaultName,
                                                                  File[] resourceFiles); static HasMetadata getResource(PlatformMode platformMode, ResourceVersioning apiVersions,
                                          File file, String appName); static File[] listResourceFragments(File localResourceDir, List<String> remotes, Logger log); static File[] listResourceFragments(File resourceDir); static File[] listRemoteResourceFragments(List<String> remotes, Logger log); final static void updateKindFilenameMapper(final Map<String, List<String>> mappings); static void removeItemFromKubernetesBuilder(KubernetesListBuilder builder, HasMetadata item); static String getNameWithSuffix(String name, String kind); static String extractContainerName(GroupArtifactVersion groupArtifactVersion, ImageConfiguration imageConfig); static Map<String, String> removeVersionSelector(Map<String, String> selector); static boolean checkForKind(KubernetesListBuilder builder, String... kinds); static boolean addPort(List<ContainerPort> ports, String portNumberText, String portName, Logger log); static boolean setEnvVar(List<EnvVar> envVarList, String name, String value); static String getEnvVar(List<EnvVar> envVarList, String name, String defaultValue); static boolean removeEnvVar(List<EnvVar> envVarList, String name); static List<EnvVar> convertToEnvVarList(Map<String, String> envVars); static void validateKubernetesMasterUrl(URL masterUrl); static void handleKubernetesClientException(KubernetesClientException e, Logger logger); static String getBuildStatusPhase(Build build); static String getBuildStatusReason(Build build); static Pod getNewestPod(Collection<Pod> pods); static Date getCreationTimestamp(HasMetadata hasMetadata); static Date parseDate(String text); static boolean podHasContainerImage(Pod pod, String imageName); static String getDockerContainerID(Pod pod); static boolean isNewerResource(HasMetadata newer, HasMetadata older); static void mergeSimpleFields(Object targetValues, Object defaultValues); static String mergePodSpec(PodSpecBuilder builder, PodSpec defaultPodSpec, String defaultName); static String mergePodSpec(PodSpecBuilder builder, PodSpec defaultPodSpec, String defaultName, boolean sidecarEnabled); static String getSourceUrlAnnotation(HasMetadata item); static void setSourceUrlAnnotationIfNotSet(HasMetadata item, String sourceUrl); static boolean isAppCatalogResource(HasMetadata templateOrConfigMap); static Set<HasMetadata> loadResources(File manifest); static LabelSelector getPodLabelSelector(Set<HasMetadata> entities); static LabelSelector getPodLabelSelector(HasMetadata entity); static HasMetadata mergeResources(HasMetadata item1, HasMetadata item2, Logger log, boolean switchOnLocalCustomisation); static File getResourceFragmentFromSource(File resourceDirFinal, ResourceConfig resourceConfig, String resourceNameSuffix, Logger log); static Map<String, Quantity> getQuantityFromString(Map<String, String> quantity); static final String API_VERSION; static final String API_EXTENSIONS_VERSION; static final String API_APPS_VERSION; static final String JOB_VERSION; static final String OPENSHIFT_V1_VERSION; static final String CRONJOB_VERSION; static final String RBAC_VERSION; static final ResourceVersioning DEFAULT_RESOURCE_VERSIONING; static final HashSet<Class<?>> SIMPLE_FIELD_TYPES; static final String CONTAINER_NAME_REGEX; }
@Test public void should_update_kind_filename_mapper_in_bimap_fashion() { final Map<String, List<String>> updated = new HashMap<>(); updated.put("Var", Arrays.asList("foo")); KubernetesResourceUtil.updateKindFilenameMapper(updated); final Map<String, String> filenameToKindMapper = KubernetesResourceUtil.FILENAME_TO_KIND_MAPPER; final Map<String, String> kindToFilenameMapper = KubernetesResourceUtil.KIND_TO_FILENAME_MAPPER; assertThat(filenameToKindMapper) .containsEntry("cm", "ConfigMap") .containsEntry("configmap", "ConfigMap") .containsEntry("secret", "Secret") .containsEntry("foo", "Var"); assertThat(kindToFilenameMapper) .containsEntry("ConfigMap", "configmap") .containsEntry("Secret", "secret") .containsEntry("Var", "foo"); }