Skip to content

Commit aa3ab17

Browse files
authored
4.x: Support for OKE Workload identity in OCI integration for Service registry (#8862)
* Mark service registry as a preview feature * Make sure suppliers return a new instance each time they are called * Support for builders of authentication detail providers. * Documentation update. * Test some javadoc tags are correctly handled * Builder: Factory methods should only be generated if returning prototype or builder * Use Authentication instead of Atn * Remove usages of "Strategy" and replace with "Method"
1 parent dc01487 commit aa3ab17

File tree

82 files changed

+2563
-476
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

82 files changed

+2563
-476
lines changed

all/pom.xml

+12
Original file line numberDiff line numberDiff line change
@@ -641,6 +641,18 @@
641641
<groupId>io.helidon.integrations.oci</groupId>
642642
<artifactId>helidon-integrations-oci</artifactId>
643643
</dependency>
644+
<dependency>
645+
<groupId>io.helidon.integrations.oci.authentication</groupId>
646+
<artifactId>helidon-integrations-oci-authentication-instance</artifactId>
647+
</dependency>
648+
<dependency>
649+
<groupId>io.helidon.integrations.oci.authentication</groupId>
650+
<artifactId>helidon-integrations-oci-authentication-resource</artifactId>
651+
</dependency>
652+
<dependency>
653+
<groupId>io.helidon.integrations.oci.authentication</groupId>
654+
<artifactId>helidon-integrations-oci-authentication-oke-workload</artifactId>
655+
</dependency>
644656
<dependency>
645657
<groupId>io.helidon.integrations.oci.sdk</groupId>
646658
<artifactId>helidon-integrations-oci-sdk-cdi</artifactId>

bom/pom.xml

+15
Original file line numberDiff line numberDiff line change
@@ -858,6 +858,21 @@
858858
<artifactId>helidon-integrations-oci</artifactId>
859859
<version>${helidon.version}</version>
860860
</dependency>
861+
<dependency>
862+
<groupId>io.helidon.integrations.oci.authentication</groupId>
863+
<artifactId>helidon-integrations-oci-authentication-instance</artifactId>
864+
<version>${helidon.version}</version>
865+
</dependency>
866+
<dependency>
867+
<groupId>io.helidon.integrations.oci.authentication</groupId>
868+
<artifactId>helidon-integrations-oci-authentication-resource</artifactId>
869+
<version>${helidon.version}</version>
870+
</dependency>
871+
<dependency>
872+
<groupId>io.helidon.integrations.oci.authentication</groupId>
873+
<artifactId>helidon-integrations-oci-authentication-oke-workload</artifactId>
874+
<version>${helidon.version}</version>
875+
</dependency>
861876
<dependency>
862877
<groupId>io.helidon.integrations.oci.sdk</groupId>
863878
<artifactId>helidon-integrations-oci-sdk-cdi</artifactId>

builder/codegen/src/main/java/io/helidon/builder/codegen/BuilderCodegen.java

+20-2
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ private void process(RoundContext roundContext, TypeInfo blueprint) {
232232
// static X create()
233233
addCreateDefaultMethod(blueprintDef, propertyData, classModel, prototype, ifaceName, typeArgumentString, typeArguments);
234234

235-
generateCustomMethods(customMethods, classModel);
235+
generateCustomMethods(classModel, builderTypeName, prototype, customMethods);
236236

237237
// abstract class BuilderBase...
238238
GenerateAbstractBuilder.generate(classModel,
@@ -366,8 +366,26 @@ private static void generateCustomConstants(CustomMethods customMethods, ClassMo
366366
}
367367
}
368368

369-
private static void generateCustomMethods(CustomMethods customMethods, ClassModel.Builder classModel) {
369+
private static void generateCustomMethods(ClassModel.Builder classModel,
370+
TypeName builderTypeName,
371+
TypeName prototype,
372+
CustomMethods customMethods) {
370373
for (CustomMethods.CustomMethod customMethod : customMethods.factoryMethods()) {
374+
TypeName typeName = customMethod.declaredMethod().returnType();
375+
// there is a chance the typeName does not have a package (if "forward referenced"),
376+
// in that case compare just by classname (leap of faith...)
377+
if (typeName.packageName().isBlank()) {
378+
String className = typeName.className();
379+
if (!(className.equals(prototype.className())
380+
|| className.equals(builderTypeName.className()))) {
381+
// based on class names
382+
continue;
383+
}
384+
} else if (!(typeName.equals(prototype) || typeName.equals(builderTypeName))) {
385+
// we only generate custom factory methods if they return prototype or builder
386+
continue;
387+
}
388+
371389
// prototype definition - custom static factory methods
372390
// static TypeName create(Type type);
373391
CustomMethods.Method generated = customMethod.generatedMethod().method();

builder/codegen/src/main/java/io/helidon/builder/codegen/TypeHandler.java

+14
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
package io.helidon.builder.codegen;
1818

19+
import java.net.URI;
20+
import java.nio.file.Paths;
1921
import java.time.Duration;
2022
import java.util.ArrayList;
2123
import java.util.Iterator;
@@ -168,6 +170,18 @@ Consumer<ContentBuilder<?>> toDefaultValue(String defaultValue) {
168170
.addContent(defaultValue)
169171
.addContent("\".toCharArray()");
170172
}
173+
if (Types.PATH.equals(typeName)) {
174+
return content -> content.addContent(Paths.class)
175+
.addContent(".get(\"")
176+
.addContent(defaultValue)
177+
.addContent("\")");
178+
}
179+
if (Types.URI.equals(typeName)) {
180+
return content -> content.addContent(URI.class)
181+
.addContent(".create(\"")
182+
.addContent(defaultValue)
183+
.addContent("\")");
184+
}
171185
if (typeName.primitive()) {
172186
if (typeName.fqName().equals("char")) {
173187
return content -> content.addContent("'")

builder/codegen/src/main/java/io/helidon/builder/codegen/Types.java

+3
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
package io.helidon.builder.codegen;
1818

19+
import java.nio.file.Path;
1920
import java.util.ArrayList;
2021
import java.util.LinkedHashMap;
2122
import java.util.LinkedHashSet;
@@ -31,6 +32,8 @@ final class Types {
3132
static final TypeName ARRAY_LIST = TypeName.create(ArrayList.class);
3233
static final TypeName LINKED_HASH_SET = TypeName.create(LinkedHashSet.class);
3334
static final TypeName CHAR_ARRAY = TypeName.create(char[].class);
35+
static final TypeName PATH = TypeName.create(Path.class);
36+
static final TypeName URI = TypeName.create(java.net.URI.class);
3437
static final TypeName SERVICE_REGISTRY = TypeName.create("io.helidon.service.registry.ServiceRegistry");
3538
static final TypeName GLOBAL_SERVICE_REGISTRY = TypeName.create("io.helidon.service.registry.GlobalServiceRegistry");
3639
static final TypeName GENERATED_SERVICE = TypeName.create("io.helidon.service.registry.GeneratedService");

builder/tests/codegen/src/test/java/io/helidon/builder/codegen/TypesTest.java

+4
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818

1919
import java.lang.reflect.Field;
2020
import java.lang.reflect.Modifier;
21+
import java.net.URI;
22+
import java.nio.file.Path;
2123
import java.util.ArrayList;
2224
import java.util.HashMap;
2325
import java.util.HashSet;
@@ -84,6 +86,8 @@ void testTypes() {
8486
checkField(toCheck, checked, fields, "ARRAY_LIST", ArrayList.class);
8587
checkField(toCheck, checked, fields, "LINKED_HASH_SET", LinkedHashSet.class);
8688
checkField(toCheck, checked, fields, "CHAR_ARRAY", char[].class);
89+
checkField(toCheck, checked, fields, "PATH", Path.class);
90+
checkField(toCheck, checked, fields, "URI", URI.class);
8791
checkField(toCheck, checked, fields, "SERVICE_REGISTRY", ServiceRegistry.class);
8892
checkField(toCheck, checked, fields, "GLOBAL_SERVICE_REGISTRY", GlobalServiceRegistry.class);
8993
checkField(toCheck, checked, fields, "GENERATED_SERVICE", GeneratedService.class);

config/metadata-processor/src/main/java/io/helidon/config/metadata/processor/Javadoc.java

+6-2
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,9 @@
3030
final class Javadoc {
3131
private static final Pattern JAVADOC_CODE = Pattern.compile("\\{@code (.*?)}");
3232
private static final Pattern JAVADOC_LINK = Pattern.compile("\\{@link (.*?)}");
33+
private static final Pattern JAVADOC_LINKPLAIN = Pattern.compile("\\{@linkplain (.*?)}");
3334
private static final Pattern JAVADOC_VALUE = Pattern.compile("\\{@value (.*?)}");
34-
private static final Pattern JAVADOC_SEE = Pattern.compile("\\{@see (.*?)}");
35+
private static final Pattern JAVADOC_SEE = Pattern.compile("@see (.*?\n)");
3536

3637
private Javadoc() {
3738
}
@@ -44,6 +45,7 @@ private Javadoc() {
4445
* <li>{@code @param} is stripped from the text</li>
4546
* <li>Any {@code @code} section: the code tag is removed, and surrounded with {@code '}</li>
4647
* <li>Any {@code @link} section: the link tag is removed</li>
48+
* <li>Any {@code @linkplain} section: the linkplain tag is removed</li>
4749
* <li>Any {@code @value} section: the value tag is removed, {code #} is replaced with {@code .}</li>
4850
* <li>Any {@code @see} section: the see tag is removed, prefixed with {@code See},
4951
* {code #} is replaced with {@code .}</li>
@@ -65,8 +67,10 @@ static String parse(String docComment) {
6567
}
6668
// replace all {@code xxx} with 'xxx'
6769
javadoc = JAVADOC_CODE.matcher(javadoc).replaceAll(it -> javadocCode(it.group(1)));
68-
// replace all {@link ...} with just the name
70+
// replace all {@link ...} with just the link
6971
javadoc = JAVADOC_LINK.matcher(javadoc).replaceAll(it -> javadocLink(it.group(1)));
72+
// replace all {@link ...} with just the name
73+
javadoc = JAVADOC_LINKPLAIN.matcher(javadoc).replaceAll(it -> javadocLink(it.group(1)));
7074
// replace all {@value ...} with just the reference
7175
javadoc = JAVADOC_VALUE.matcher(javadoc).replaceAll(it -> javadocValue(it.group(1)));
7276
// replace all {@see ...} with just the reference

config/tests/config-metadata-builder-api/src/main/java/io/helidon/config/tests/config/metadata/builder/api/MyTargetBlueprint.java

+15-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2023 Oracle and/or its affiliates.
2+
* Copyright (c) 2023, 2024 Oracle and/or its affiliates.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -24,6 +24,8 @@
2424
@Prototype.Configured
2525
@Description("builder")
2626
interface MyTargetBlueprint extends MyAbstractBlueprint {
27+
String CONSTANT = "42";
28+
2729
@Description("message description")
2830
@Option.Configured
2931
@Option.Default("message")
@@ -39,4 +41,16 @@ interface MyTargetBlueprint extends MyAbstractBlueprint {
3941
@Description("Ignored option")
4042
String ignored();
4143

44+
/**
45+
* Description.
46+
* {@code technical}
47+
* {@link MyTarget#ignored()}
48+
* {@linkplain MyTarget#ignored()}
49+
* {@value #CONSTANT}
50+
*
51+
* @return some value
52+
* @see MyTarget#message()
53+
*/
54+
@Option.Configured
55+
String javadoc();
4256
}

0 commit comments

Comments
 (0)