8000 docs: add some javadocs · FroMage/java-operator-sdk@9c0ccbd · GitHub
[go: up one dir, main page]

Skip to content

Commit 9c0ccbd

Browse files
committed
docs: add some javadocs
1 parent 538e468 commit 9c0ccbd

File tree

5 files changed

+78
-3
lines changed

5 files changed

+78
-3
lines changed

operator-framework-core/src/main/java/io/javaoperatorsdk/operator/Operator.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ public Operator(KubernetesClient k8sClient, ConfigurationService configurationSe
2828
this.configurationService = configurationService;
2929
}
3030

31+
/**
32+
* Finishes the operator startup process. This is mostly used in injection-aware applications
33+
* where there is no obvious entrypoint to the application which can trigger the injection process
34+
* and start the cluster monitoring processes.
35+
*/
3136
public void start() {
3237
final var version = configurationService.getVersion();
3338
log.info(
@@ -37,11 +42,30 @@ public void start() {
3742
version.getBuiltTime());
3843
}
3944

45+
/**
46+
* Registers the specified controller with this operator.
47+
*
48+
* @param controller the controller to register
49+
* @param <R> the {@code CustomResource} type associated with the controller
50+
* @throws OperatorException if a problem occurred during the registration process
51+
*/
4052
public <R extends CustomResource> void register(ResourceController<R> controller)
4153
throws OperatorException {
4254
register(controller, null);
4355
}
4456

57+
/**
58+
* Registers the specified controller with this operator, overriding its default configuration by
59+
* the specified one (usually created via {@link
60+
* io.javaoperatorsdk.operator.api.config.ControllerConfigurationOverrider#override(ControllerConfiguration)},
61+
* passing it the controller's original configuration.
62+
*
63+
* @param controller the controller to register
64+
* @param configuration the configuration with which we want to register the controller, if {@code
65+
* null}, the controller's orginal configuration is used
66+
* @param <R> the {@code CustomResource} type associated with the controller
67+
* @throws OperatorException if a problem occurred during the registration process
68+
*/
4569
public <R extends CustomResource> void register(
4670
ResourceController<R> controller, ControllerConfiguration<R> configuration)
4771
throws OperatorException {

operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/config/ConfigurationService.java

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,41 @@
55
import io.javaoperatorsdk.operator.api.ResourceController;
66
import java.util.Set;
77

8+
/** An interface from which to retrieve configuration information. */
89
public interface ConfigurationService {
910

11+
/**
12+
* Retrieves the configuration associated with the specified controller
13+
*
14+
* @param controller the controller we want the configuration of
15+
* @param <R> the {@code CustomResource} type associated with the specified controller
16+
* @return the {@link ControllerConfiguration} associated with the specified controller or {@code
17+
* null} if no configuration exists for the controller
18+
*/
1019
<R extends CustomResource> ControllerConfiguration<R> getConfigurationFor(
1120
ResourceController<R> controller);
1221

22+
/**
23+
* Retrieves the Kubernetes client configuration
24+
*
25+
* @return the configuration of the Kubernetes client, defaulting to the provided
26+
* auto-configuration
27+
*/
1328
default Config getClientConfiguration() {
1429
return Config.autoConfigure(null);
1530
}
1631

32+
/**
33+
* Retrieves the set of the names of controllers for which a configuration exists
34+
*
35+
* @return the set of known controller names
36+
*/
1737
Set<String> getKnownControllerNames();
1838

39+
/**
40+
* Retrieves the {@link Version} information associated with this particular instance of the SDK
41+
*
42+
* @return the version information
43+
*/
1944
Version getVersion();
2045
}

operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/config/Utils.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,18 @@ public class Utils {
1313

1414
private static final Logger log = LoggerFactory.getLogger(Utils.class);
1515

16+
/**
17+
* Attempts to load version information from a properties file produced at build time, currently
18+
* via the {@code git-commit-id-plugin} maven plugin.
19+
*
20+
* @return a {@link Version} object encapsulating the version information
21+
*/
1622
public static Version loadFromProperties() {
1723
final var is =
1824
Thread.currentThread().getContextClassLoader().getResourceAsStream("version.properties");
1925

2026
final var properties = new Properties();
21-
if(is != null) {
27+
if (is != null) {
2228
try {
2329
properties.load(is);
2430
} catch (IOException e) {

operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/config/Version.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22

33
import java.util.Date;
44

5+
/** A class encapsulating the version information associated with this SDK instance. */
56
public class Version {
7+
68
private final String project;
79
private final String commit;
810
private final Date builtTime;
@@ -13,14 +15,30 @@ public Version(String project, String commit, Date builtTime) {
1315
this.builtTime = builtTime;
1416
}
1517

18+
/**
19+
* Returns the SDK project version
20+
*
21+
* @return the SDK project version
22+
*/
1623
public String getProject() {
1724
return project;
1825
}
1926

27+
/**
28+
* Returns the git commit id associated with this SDK instance
29+
*
30+
* @return the git commit id
31+
*/
2032
public String getCommit() {
2133
return commit;
2234
}
2335

36+
/**
37+
* Returns the date at which this SDK instance was built
38+
*
39+
* @return the build time at which this SDK instance was built or the date corresponding to {@link
40+
* java.time.Instant#EPOCH} if the built time couldn't be retrieved
41+
*/
2442
public Date getBuiltTime() {
2543
return builtTime;
2644
}

operator-framework/src/main/java/io/javaoperatorsdk/operator/config/runtime/AnnotationConfiguration.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ public String getCRDName() {
3131

3232
@Override
3333
public String getFinalizer() {
34-
return annotation.map(Controller::finalizerName).filter(String::isBlank)
34+
return annotation
35+
.map(Controller::finalizerName)
36+
.filter(String::isBlank)
3537
.orElse(ControllerUtils.getDefaultFinalizerName(getCRDName()));
3638
}
3739

@@ -47,7 +49,7 @@ public Class<R> getCustomResourceClass() {
4749

4850
@Override
4951
public Set<String> getNamespaces() {
50-
return Set.of(annotation.map(Controller::namespaces).orElse(new String[]{}));
52+
return Set.of(annotation.map(Controller::namespaces).orElse(new String[] {}));
5153
}
5254

5355
@Override

0 commit comments

Comments
 (0)
0