org.zodic.kubernetes.confcenter.SecretsPropertySourceLocator Maven / Gradle / Ivy
package org.zodic.kubernetes.confcenter;
import io.fabric8.kubernetes.client.KubernetesClient;
import org.springframework.core.annotation.Order;
import org.springframework.core.env.ConfigurableEnvironment;
import org.springframework.core.env.Environment;
import org.springframework.core.env.MapPropertySource;
import org.zodiac.core.bootstrap.config.AppPropertySourceLocator;
import org.zodiac.core.constants.AppOrderConstants;
@Order(value = AppOrderConstants.AppPropertySourceLocatorOrder.KUBERNETES_SECRETS)
public class SecretsPropertySourceLocator implements AppPropertySourceLocator {
private final KubernetesClient client;
private final SecretsConfigInfo secretsConfigInfo;
public SecretsPropertySourceLocator(KubernetesClient client, SecretsConfigInfo secretsConfigInfo) {
this.client = client;
this.secretsConfigInfo = secretsConfigInfo;
}
@Override
public MapPropertySource locatePropertySource(Environment environment) {
return environment instanceof ConfigurableEnvironment
? new SecretsPropertySource(this.client, environment, this.secretsConfigInfo) : null;
}
@Override
public int getPriority() {
return AppOrderConstants.AppPropertySourceLocatorOrder.KUBERNETES_SECRETS;
}
}