Skip to content

4.x: Support for OKE Workload identity in OCI integration for Service registry #8862

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Jun 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions all/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -641,6 +641,18 @@
<groupId>io.helidon.integrations.oci</groupId>
<artifactId>helidon-integrations-oci</artifactId>
</dependency>
<dependency>
<groupId>io.helidon.integrations.oci.authentication</groupId>
<artifactId>helidon-integrations-oci-authentication-instance</artifactId>
</dependency>
<dependency>
<groupId>io.helidon.integrations.oci.authentication</groupId>
<artifactId>helidon-integrations-oci-authentication-resource</artifactId>
</dependency>
<dependency>
<groupId>io.helidon.integrations.oci.authentication</groupId>
<artifactId>helidon-integrations-oci-authentication-oke-workload</artifactId>
</dependency>
<dependency>
<groupId>io.helidon.integrations.oci.sdk</groupId>
<artifactId>helidon-integrations-oci-sdk-cdi</artifactId>
Expand Down
15 changes: 15 additions & 0 deletions bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -858,6 +858,21 @@
<artifactId>helidon-integrations-oci</artifactId>
<version>${helidon.version}</version>
</dependency>
<dependency>
<groupId>io.helidon.integrations.oci.authentication</groupId>
<artifactId>helidon-integrations-oci-authentication-instance</artifactId>
<version>${helidon.version}</version>
</dependency>
<dependency>
<groupId>io.helidon.integrations.oci.authentication</groupId>
<artifactId>helidon-integrations-oci-authentication-resource</artifactId>
<version>${helidon.version}</version>
</dependency>
<dependency>
<groupId>io.helidon.integrations.oci.authentication</groupId>
<artifactId>helidon-integrations-oci-authentication-oke-workload</artifactId>
<version>${helidon.version}</version>
</dependency>
<dependency>
<groupId>io.helidon.integrations.oci.sdk</groupId>
<artifactId>helidon-integrations-oci-sdk-cdi</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ private void process(RoundContext roundContext, TypeInfo blueprint) {
// static X create()
addCreateDefaultMethod(blueprintDef, propertyData, classModel, prototype, ifaceName, typeArgumentString, typeArguments);

generateCustomMethods(customMethods, classModel);
generateCustomMethods(classModel, builderTypeName, prototype, customMethods);

// abstract class BuilderBase...
GenerateAbstractBuilder.generate(classModel,
Expand Down Expand Up @@ -366,8 +366,26 @@ private static void generateCustomConstants(CustomMethods customMethods, ClassMo
}
}

private static void generateCustomMethods(CustomMethods customMethods, ClassModel.Builder classModel) {
private static void generateCustomMethods(ClassModel.Builder classModel,
TypeName builderTypeName,
TypeName prototype,
CustomMethods customMethods) {
for (CustomMethods.CustomMethod customMethod : customMethods.factoryMethods()) {
TypeName typeName = customMethod.declaredMethod().returnType();
// there is a chance the typeName does not have a package (if "forward referenced"),
// in that case compare just by classname (leap of faith...)
if (typeName.packageName().isBlank()) {
String className = typeName.className();
if (!(className.equals(prototype.className())
|| className.equals(builderTypeName.className()))) {
// based on class names
continue;
}
} else if (!(typeName.equals(prototype) || typeName.equals(builderTypeName))) {
// we only generate custom factory methods if they return prototype or builder
continue;
}

// prototype definition - custom static factory methods
// static TypeName create(Type type);
CustomMethods.Method generated = customMethod.generatedMethod().method();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

package io.helidon.builder.codegen;

import java.net.URI;
import java.nio.file.Paths;
import java.time.Duration;
import java.util.ArrayList;
import java.util.Iterator;
Expand Down Expand Up @@ -168,6 +170,18 @@ Consumer<ContentBuilder<?>> toDefaultValue(String defaultValue) {
.addContent(defaultValue)
.addContent("\".toCharArray()");
}
if (Types.PATH.equals(typeName)) {
return content -> content.addContent(Paths.class)
.addContent(".get(\"")
.addContent(defaultValue)
.addContent("\")");
}
if (Types.URI.equals(typeName)) {
return content -> content.addContent(URI.class)
.addContent(".create(\"")
.addContent(defaultValue)
.addContent("\")");
}
if (typeName.primitive()) {
if (typeName.fqName().equals("char")) {
return content -> content.addContent("'")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package io.helidon.builder.codegen;

import java.nio.file.Path;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
Expand All @@ -31,6 +32,8 @@ final class Types {
static final TypeName ARRAY_LIST = TypeName.create(ArrayList.class);
static final TypeName LINKED_HASH_SET = TypeName.create(LinkedHashSet.class);
static final TypeName CHAR_ARRAY = TypeName.create(char[].class);
static final TypeName PATH = TypeName.create(Path.class);
static final TypeName URI = TypeName.create(java.net.URI.class);
static final TypeName SERVICE_REGISTRY = TypeName.create("io.helidon.service.registry.ServiceRegistry");
static final TypeName GLOBAL_SERVICE_REGISTRY = TypeName.create("io.helidon.service.registry.GlobalServiceRegistry");
static final TypeName GENERATED_SERVICE = TypeName.create("io.helidon.service.registry.GeneratedService");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.net.URI;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
Expand Down Expand Up @@ -84,6 +86,8 @@ void testTypes() {
checkField(toCheck, checked, fields, "ARRAY_LIST", ArrayList.class);
checkField(toCheck, checked, fields, "LINKED_HASH_SET", LinkedHashSet.class);
checkField(toCheck, checked, fields, "CHAR_ARRAY", char[].class);
checkField(toCheck, checked, fields, "PATH", Path.class);
checkField(toCheck, checked, fields, "URI", URI.class);
checkField(toCheck, checked, fields, "SERVICE_REGISTRY", ServiceRegistry.class);
checkField(toCheck, checked, fields, "GLOBAL_SERVICE_REGISTRY", GlobalServiceRegistry.class);
checkField(toCheck, checked, fields, "GENERATED_SERVICE", GeneratedService.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,9 @@
final class Javadoc {
private static final Pattern JAVADOC_CODE = Pattern.compile("\\{@code (.*?)}");
private static final Pattern JAVADOC_LINK = Pattern.compile("\\{@link (.*?)}");
private static final Pattern JAVADOC_LINKPLAIN = Pattern.compile("\\{@linkplain (.*?)}");
private static final Pattern JAVADOC_VALUE = Pattern.compile("\\{@value (.*?)}");
private static final Pattern JAVADOC_SEE = Pattern.compile("\\{@see (.*?)}");
private static final Pattern JAVADOC_SEE = Pattern.compile("@see (.*?\n)");

private Javadoc() {
}
Expand All @@ -44,6 +45,7 @@ private Javadoc() {
* <li>{@code @param} is stripped from the text</li>
* <li>Any {@code @code} section: the code tag is removed, and surrounded with {@code '}</li>
* <li>Any {@code @link} section: the link tag is removed</li>
* <li>Any {@code @linkplain} section: the linkplain tag is removed</li>
* <li>Any {@code @value} section: the value tag is removed, {code #} is replaced with {@code .}</li>
* <li>Any {@code @see} section: the see tag is removed, prefixed with {@code See},
* {code #} is replaced with {@code .}</li>
Expand All @@ -65,8 +67,10 @@ static String parse(String docComment) {
}
// replace all {@code xxx} with 'xxx'
javadoc = JAVADOC_CODE.matcher(javadoc).replaceAll(it -> javadocCode(it.group(1)));
// replace all {@link ...} with just the name
// replace all {@link ...} with just the link
javadoc = JAVADOC_LINK.matcher(javadoc).replaceAll(it -> javadocLink(it.group(1)));
// replace all {@link ...} with just the name
javadoc = JAVADOC_LINKPLAIN.matcher(javadoc).replaceAll(it -> javadocLink(it.group(1)));
// replace all {@value ...} with just the reference
javadoc = JAVADOC_VALUE.matcher(javadoc).replaceAll(it -> javadocValue(it.group(1)));
// replace all {@see ...} with just the reference
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2023 Oracle and/or its affiliates.
* Copyright (c) 2023, 2024 Oracle and/or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -24,6 +24,8 @@
@Prototype.Configured
@Description("builder")
interface MyTargetBlueprint extends MyAbstractBlueprint {
String CONSTANT = "42";

@Description("message description")
@Option.Configured
@Option.Default("message")
Expand All @@ -39,4 +41,16 @@ interface MyTargetBlueprint extends MyAbstractBlueprint {
@Description("Ignored option")
String ignored();

/**
* Description.
* {@code technical}
* {@link MyTarget#ignored()}
* {@linkplain MyTarget#ignored()}
* {@value #CONSTANT}
*
* @return some value
* @see MyTarget#message()
*/
@Option.Configured
String javadoc();
}
Loading