Skip to content

Commit

Permalink
add comments
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielLiu1123 committed Feb 4, 2023
1 parent 565d545 commit dee3443
Show file tree
Hide file tree
Showing 12 changed files with 49 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@
import io.fabric8.kubernetes.client.KubernetesClient;

/**
* Kubernetes utils.
*
* <p>
* Usually used to get kube config and create {@link KubernetesClient} instance.
*
* @author Freeman
*/
public final class KubernetesUtils {
Expand Down Expand Up @@ -59,7 +64,7 @@ public static String currentNamespace() {
}

/**
* New a KubernetesClient instance.
* Create a KubernetesClient instance.
*
* @return new KubernetesClient instance
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
import org.springframework.context.annotation.Import;

/**
* Spring Cloud Alibaba Kubernetes Config autoconfiguration.
*
* @author Freeman
*/
@Configuration(proxyBeanMethods = false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
import org.springframework.util.StringUtils;

/**
* Spring Cloud Alibaba Kubernetes Config properties.
*
* @author Freeman
*/
@ConfigurationProperties(KubernetesConfigProperties.PREFIX)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@
import org.springframework.core.Ordered;
import org.springframework.core.env.ConfigurableEnvironment;
import org.springframework.core.env.EnumerablePropertySource;
import org.springframework.core.env.Environment;
import org.springframework.core.env.MutablePropertySources;
import org.springframework.core.env.PropertySource;
import org.springframework.core.env.StandardEnvironment;

import static com.alibaba.cloud.kubernetes.config.util.Converters.toPropertySource;
Expand All @@ -54,7 +56,28 @@
import static java.util.stream.Collectors.toList;

/**
* Kubernetes config {@link EnvironmentPostProcessor}.
*
* <p>
* There are two ways to use this post processor:
* <ul>
* <li>when application starts up</li>
* <li>when application triggers a {@link RefreshEvent}</li>
* </ul>
*
* <p>
* When application starts up, this processor will load all the ConfigMaps/Secrets.
* <p>
* When application triggers a {@link RefreshEvent}, Spring will copy a
* {@link Environment} and invoke all {@link EnvironmentPostProcessor}s, then replace the
* {@link PropertySource} if copied {@link Environment} has the same name
* {@link PropertySource}. So this processor only converts the refreshed resource to
* {@link PropertySource} and add it to the {@link Environment} when refresh event is
* triggered.
*
* @author Freeman
* @see org.springframework.cloud.context.refresh.ContextRefresher
* @see org.springframework.cloud.context.refresh.ConfigDataContextRefresher
*/
public class ConfigEnvironmentPostProcessor implements EnvironmentPostProcessor, Ordered {
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
import static com.alibaba.cloud.kubernetes.config.util.ResourceKeyUtils.resourceKey;

/**
* Watcher for config resource changes.
* Watcher for config resources change.
*
* @author Freeman
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@
import org.springframework.core.env.ConfigurableEnvironment;

/**
* {@link HasMetadataResourceEventHandler} process {@link HasMetadata}(ConfigMap/Secret)
* events, trigger {@link RefreshEvent} when necessary.
*
* @author Freeman
*/
class HasMetadataResourceEventHandler<T extends HasMetadata>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
import static java.nio.charset.StandardCharsets.UTF_8;

/**
* {@link Converters} use to convert ConfigMap/Secret to {@link EnumerablePropertySource}.
*
* @author Freeman
*/
public final class Converters {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
package com.alibaba.cloud.kubernetes.config.util;

/**
* Utility class for holding a pair of values.
*
* @author Freeman
*/
public final class Pair<K, V> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
package com.alibaba.cloud.kubernetes.config.util;

/**
* Configuration preference.
*
* @author Freeman
*/
public enum Preference {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
import com.alibaba.cloud.kubernetes.config.processor.YamlFileProcessor;

/**
* {@link Processors} holds all the {@link FileProcessor} instances.
*
* @author Freeman
*/
public final class Processors {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
import java.util.Objects;

/**
* {@link ResourceKey} represents identity of a resource.
*
* @author Freeman
*/
public final class ResourceKey {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
import io.fabric8.kubernetes.api.model.Secret;

/**
* {@link ResourceKeyUtils} used to generate {@link ResourceKey}.
*
* @author Freeman
*/
public final class ResourceKeyUtils {
Expand Down

0 comments on commit dee3443

Please sign in to comment.