@Test public void testRetrieveSecretsWithoutConfigEnable() { KubernetesConfigSourceConfig config = defaultConfig(); KubernetesConfigBuildTimeConfig buildTimeConfig = new KubernetesConfigBuildTimeConfig(); buildTimeConfig.secretsEnabled = true; Secret secret = secretMapBuilder("testOnlySingleMatchingPropertiesData") .addToData("application.properties", encodeValue("key1=value1\nsome.key=someValue")).build(); List<String> secrets = Lists.list("cm1"); config.secrets = Optional.of(secrets); KubernetesClient kubernetesClient = Mockito.mock(KubernetesClient.class); stubSecrets(kubernetesClient, secret, "cm1"); KubernetesConfigSourceProvider kcsp = new KubernetesConfigSourceProvider(config, buildTimeConfig, kubernetesClient); Iterable<ConfigSource> configSources = kcsp.getConfigSources(null); assertThat(configSources).isNotEmpty(); ConfigSource next = configSources.iterator().next(); assertThat(next.getProperties()).containsKeys("key1", "some.key"); }
@Override public Iterable<ConfigSource> getConfigSources(ClassLoader forClassLoader) { if (!config.configMaps.isPresent() && !config.secrets.isPresent()) { log.debug("No ConfigMaps or Secrets were configured for config source lookup"); return Collections.emptyList(); } List<ConfigSource> result = new ArrayList<>(); if (config.enabled && config.configMaps.isPresent()) { result.addAll(getConfigMapConfigSources(config.configMaps.get())); } if (buildTimeConfig.secretsEnabled && config.secrets.isPresent()) { result.addAll(getSecretConfigSources(config.secrets.get())); } return result; }
KubernetesConfigSourceProvider implements ConfigSourceProvider { @Override public Iterable<ConfigSource> getConfigSources(ClassLoader forClassLoader) { if (!config.configMaps.isPresent() && !config.secrets.isPresent()) { log.debug("No ConfigMaps or Secrets were configured for config source lookup"); return Collections.emptyList(); } List<ConfigSource> result = new ArrayList<>(); if (config.enabled && config.configMaps.isPresent()) { result.addAll(getConfigMapConfigSources(config.configMaps.get())); } if (buildTimeConfig.secretsEnabled && config.secrets.isPresent()) { result.addAll(getSecretConfigSources(config.secrets.get())); } return result; } }
KubernetesConfigSourceProvider implements ConfigSourceProvider { @Override public Iterable<ConfigSource> getConfigSources(ClassLoader forClassLoader) { if (!config.configMaps.isPresent() && !config.secrets.isPresent()) { log.debug("No ConfigMaps or Secrets were configured for config source lookup"); return Collections.emptyList(); } List<ConfigSource> result = new ArrayList<>(); if (config.enabled && config.configMaps.isPresent()) { result.addAll(getConfigMapConfigSources(config.configMaps.get())); } if (buildTimeConfig.secretsEnabled && config.secrets.isPresent()) { result.addAll(getSecretConfigSources(config.secrets.get())); } return result; } KubernetesConfigSourceProvider(KubernetesConfigSourceConfig config, KubernetesConfigBuildTimeConfig buildTimeConfig,
            KubernetesClient client); }
KubernetesConfigSourceProvider implements ConfigSourceProvider { @Override public Iterable<ConfigSource> getConfigSources(ClassLoader forClassLoader) { if (!config.configMaps.isPresent() && !config.secrets.isPresent()) { log.debug("No ConfigMaps or Secrets were configured for config source lookup"); return Collections.emptyList(); } List<ConfigSource> result = new ArrayList<>(); if (config.enabled && config.configMaps.isPresent()) { result.addAll(getConfigMapConfigSources(config.configMaps.get())); } if (buildTimeConfig.secretsEnabled && config.secrets.isPresent()) { result.addAll(getSecretConfigSources(config.secrets.get())); } return result; } KubernetesConfigSourceProvider(KubernetesConfigSourceConfig config, KubernetesConfigBuildTimeConfig buildTimeConfig,
            KubernetesClient client); @Override Iterable<ConfigSource> getConfigSources(ClassLoader forClassLoader); }
KubernetesConfigSourceProvider implements ConfigSourceProvider { @Override public Iterable<ConfigSource> getConfigSources(ClassLoader forClassLoader) { if (!config.configMaps.isPresent() && !config.secrets.isPresent()) { log.debug("No ConfigMaps or Secrets were configured for config source lookup"); return Collections.emptyList(); } List<ConfigSource> result = new ArrayList<>(); if (config.enabled && config.configMaps.isPresent()) { result.addAll(getConfigMapConfigSources(config.configMaps.get())); } if (buildTimeConfig.secretsEnabled && config.secrets.isPresent()) { result.addAll(getSecretConfigSources(config.secrets.get())); } return result; } KubernetesConfigSourceProvider(KubernetesConfigSourceConfig config, KubernetesConfigBuildTimeConfig buildTimeConfig,
            KubernetesClient client); @Override Iterable<ConfigSource> getConfigSources(ClassLoader forClassLoader);  }