Skip to content
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

TMP: Oci integration test poc (pipeline test 2) #8785

Open
wants to merge 20 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
97023aa
Support for inherited annotations in types.
tomas-langer Apr 28, 2024
d0c9765
Support for text resources in CodegenFiler, that supports replacing c…
tomas-langer Apr 28, 2024
2d4e252
Introduction of Helidon Service Registry.
tomas-langer Apr 28, 2024
7bc2921
Replace usage of Helidon Inject with Service Registry
tomas-langer Apr 30, 2024
5397548
Remove usage of Helidon Inject from config, webserver, webclient, tls…
tomas-langer May 2, 2024
48d6e57
OCI module based on service registry
tomas-langer May 8, 2024
19eef18
Suppress checkstyle for service registry tests
tomas-langer May 15, 2024
1266281
Support for config factory methods in custom methods for builder (ins…
tomas-langer May 15, 2024
fb1b405
Support for `Supplier` as a service implementation, with possible `nu…
tomas-langer May 15, 2024
852af23
OCI integration using Service Registry - support for Region and Authe…
tomas-langer May 15, 2024
c359d62
Refactor TLS certificates to use Service Registry instead of Helidon …
tomas-langer May 15, 2024
3f2ad07
Move secrets config sources to correct directories.
tomas-langer May 15, 2024
b5f7082
Required copyright fixes due to changes in this PR.
tomas-langer May 15, 2024
f129981
Use `helidon.oci` to configure metadata to connect to OCI
tomas-langer May 16, 2024
b54f7de
tmp
tomas-langer May 16, 2024
82ee4e9
Introducing support for service registry in blueprints (to load provi…
tomas-langer May 17, 2024
74d8257
Copyright fix.
tomas-langer May 17, 2024
adfee52
Support custom IMDS URI.
tomas-langer May 20, 2024
fa0f958
Introduction of OCI integration test
tomas-langer May 21, 2024
a2462da
build test commit (to be reverted)
tomas-langer May 21, 2024
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
135 changes: 8 additions & 127 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,61 +17,8 @@ concurrency:
cancel-in-progress: true

jobs:
copyright:
timeout-minutes: 10
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up JDK ${{ env.JAVA_VERSION }}
uses: actions/[email protected]
with:
distribution: ${{ env.JAVA_DISTRO }}
java-version: ${{ env.JAVA_VERSION }}
cache: maven
- name: Copyright
run: etc/scripts/copyright.sh
checkstyle:
timeout-minutes: 10
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
- name: Set up JDK ${{ env.JAVA_VERSION }}
uses: actions/[email protected]
with:
distribution: ${{ env.JAVA_DISTRO }}
java-version: ${{ env.JAVA_VERSION }}
cache: maven
- name: Checkstyle
run: etc/scripts/checkstyle.sh
spotbugs:
timeout-minutes: 45
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
- name: Set up JDK ${{ env.JAVA_VERSION }}
uses: actions/[email protected]
with:
distribution: ${{ env.JAVA_DISTRO }}
java-version: ${{ env.JAVA_VERSION }}
cache: maven
- name: Spotbugs
run: etc/scripts/spotbugs.sh
docs:
timeout-minutes: 30
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
- name: Set up JDK ${{ env.JAVA_VERSION }}
uses: actions/[email protected]
with:
distribution: ${{ env.JAVA_DISTRO }}
java-version: ${{ env.JAVA_VERSION }}
cache: maven
- name: Docs
run: etc/scripts/docs.sh
build:
environment: pipeline
timeout-minutes: 60
strategy:
matrix:
Expand All @@ -86,79 +33,13 @@ jobs:
java-version: ${{ env.JAVA_VERSION }}
cache: maven
- name: Maven build
run: etc/scripts/github-build.sh
examples:
timeout-minutes: 30
strategy:
matrix:
os: [ ubuntu-20.04, macos-14 ]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Set up JDK ${{ env.JAVA_VERSION }}
uses: actions/[email protected]
with:
distribution: ${{ env.JAVA_DISTRO }}
java-version: ${{ env.JAVA_VERSION }}
cache: maven
- name: Maven build
env:
HELIDON_OCI_IT_REGION: ${{ secrets.HELIDON_OCI_IT_REGION }}
HELIDON_OCI_IT_TENANCY: ${{ secrets.HELIDON_OCI_IT_TENANCY }}
HELIDON_OCI_IT_USER: ${{ secrets.HELIDON_OCI_IT_USER }}
HELIDON_OCI_IT_FINGERPRINT: ${{ secrets.HELIDON_OCI_IT_FINGERPRINT }}
HELIDON_OCI_IT_KEY: ${{ secrets.HELIDON_OCI_IT_KEY }}
run: |
mvn -B -e "-Dmaven.test.skip=true" $MAVEN_HTTP_ARGS -DskipTests -Ppipeline install
cd examples
cd integrations/oci/oci
mvn -B verify
mp-tck:
timeout-minutes: 60
name: "MicroProfile TCKs"
strategy:
matrix:
os: [ ubuntu-20.04 ]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Set up JDK ${{ env.JAVA_VERSION }}
uses: actions/[email protected]
with:
distribution: ${{ env.JAVA_DISTRO }}
java-version: ${{ env.JAVA_VERSION }}
cache: maven
- name: Maven build
run: etc/scripts/mp-tck.sh
archetypes:
timeout-minutes: 45
strategy:
matrix:
os: [ ubuntu-20.04 ]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Set up JDK ${{ env.JAVA_VERSION }}
uses: actions/[email protected]
with:
distribution: ${{ env.JAVA_DISTRO }}
java-version: ${{ env.JAVA_VERSION }}
cache: maven
- name: Test archetypes
run: etc/scripts/test-archetypes.sh
packaging:
timeout-minutes: 60
strategy:
matrix:
os: [ ubuntu-20.04, macos-14]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: graalvm/setup-graalvm@v1
with:
java-version: 21
distribution: graalvm-community
github-token: ${{ secrets.GITHUB_TOKEN }}
native-image-job-reports: true
cache: maven
- name: Build Helidon
run: etc/scripts/github-compile.sh
- name: JAR packaging
run: etc/scripts/test-packaging-jar.sh
- name: JLink packaging
run: etc/scripts/test-packaging-jlink.sh
- name: Native-Image packaging
run: etc/scripts/test-packaging-native.sh
12 changes: 12 additions & 0 deletions all/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -641,6 +641,10 @@
<groupId>io.helidon.integrations.micrometer</groupId>
<artifactId>helidon-integrations-micrometer-cdi</artifactId>
</dependency>
<dependency>
<groupId>io.helidon.integrations.oci</groupId>
<artifactId>helidon-integrations-oci</artifactId>
</dependency>
<dependency>
<groupId>io.helidon.integrations.oci.sdk</groupId>
<artifactId>helidon-integrations-oci-sdk-cdi</artifactId>
Expand Down Expand Up @@ -1054,6 +1058,14 @@
<groupId>io.helidon.inject.configdriven</groupId>
<artifactId>helidon-inject-configdriven-processor</artifactId>
</dependency>
<dependency>
<groupId>io.helidon.service</groupId>
<artifactId>helidon-service-registry</artifactId>
</dependency>
<dependency>
<groupId>io.helidon.service</groupId>
<artifactId>helidon-service-codegen</artifactId>
</dependency>
<dependency>
<groupId>io.helidon.integrations.oci.sdk</groupId>
<artifactId>helidon-integrations-oci-sdk-processor</artifactId>
Expand Down
17 changes: 17 additions & 0 deletions bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -858,6 +858,11 @@
<artifactId>helidon-integrations-micrometer-cdi</artifactId>
<version>${helidon.version}</version>
</dependency>
<dependency>
<groupId>io.helidon.integrations.oci</groupId>
<artifactId>helidon-integrations-oci</artifactId>
<version>${helidon.version}</version>
</dependency>
<dependency>
<groupId>io.helidon.integrations.oci.sdk</groupId>
<artifactId>helidon-integrations-oci-sdk-cdi</artifactId>
Expand Down Expand Up @@ -1390,6 +1395,18 @@
<version>${helidon.version}</version>
</dependency>

<!-- Service registry -->
<dependency>
<groupId>io.helidon.service</groupId>
<artifactId>helidon-service-registry</artifactId>
<version>${helidon.version}</version>
</dependency>
<dependency>
<groupId>io.helidon.service</groupId>
<artifactId>helidon-service-codegen</artifactId>
<version>${helidon.version}</version>
</dependency>

<!-- Injection Integrations related -->
<dependency>
<groupId>io.helidon.integrations.oci.sdk</groupId>
Expand Down
28 changes: 28 additions & 0 deletions builder/api/src/main/java/io/helidon/builder/api/Prototype.java
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,8 @@ public interface ConfiguredBuilder<BUILDER, PROTOTYPE> extends Builder<BUILDER,
allFromServiceLoader,
existingValue);
}


}

/**
Expand Down Expand Up @@ -442,6 +444,8 @@ public interface OptionDecorator<B, T> {
/**
* Add additional interfaces to implement by the prototype. Provide correct types (fully qualified) for generics.
*/
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.CLASS)
public @interface Implement {
/**
* Interfaces to implement, such as {@code java.lang.Comparable<io.helidon.common.types.TypeName>}.
Expand All @@ -451,5 +455,29 @@ public interface OptionDecorator<B, T> {
String[] value();
}

/**
* Generate support for Service Registry ({@code helidon-service-registry}) for any option that is annotated
* as {@link io.helidon.builder.api.Option.Provider}.
* When enabled (i.e. when this annotation is present), the service registry would be used to discover any service
* implementations including implementations discovered by service loader - appropriate {@code service.loader}
* metadata file will be generated for the service provider interfaces.
* <p>
* Simply add this annotation to your {@link io.helidon.builder.api.Prototype.Blueprint} type to enable service registry.
* Note that if this annotation is NOT present, service registry would not be used, and {@link java.util.ServiceLoader}
* is used instead.
* <p>
* When using this annotation, you cannot use {@code serviceRegistry} as a custom option in your blueprint, as it will
* be added by the annotation processor, to allow customization of the registry instance.
*/
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.CLASS)
public @interface RegistrySupport {
/**
* Whether to enable (default) or disable (set to {@code false}) registry support for this blueprint.
*
* @return whether the registry support should be enabled
*/
boolean value() default true;
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,16 @@
import java.util.List;
import java.util.Optional;
import java.util.Set;
import java.util.TreeSet;
import java.util.stream.Collectors;

import io.helidon.builder.codegen.ValidationTask.ValidateConfiguredType;
import io.helidon.codegen.CodegenContext;
import io.helidon.codegen.CodegenEvent;
import io.helidon.codegen.CodegenException;
import io.helidon.codegen.CodegenFiler;
import io.helidon.codegen.CodegenUtil;
import io.helidon.codegen.FilerTextResource;
import io.helidon.codegen.RoundContext;
import io.helidon.codegen.classmodel.ClassModel;
import io.helidon.codegen.classmodel.Javadoc;
Expand All @@ -51,6 +54,8 @@ class BuilderCodegen implements CodegenExtension {
private final Set<TypeName> runtimeTypes = new HashSet<>();
// all blueprint types (for validation)
private final Set<TypeName> blueprintTypes = new HashSet<>();
// all types from service loader that should be supported by ServiceRegistry
private final Set<String> serviceLoaderContracts = new TreeSet<>(String.CASE_INSENSITIVE_ORDER);

private final CodegenContext ctx;

Expand Down Expand Up @@ -83,6 +88,9 @@ public void process(RoundContext roundContext) {
public void processingOver(RoundContext roundContext) {
process(roundContext);

// now create service.loader
updateServiceLoaderResource();

// we must collect validation information after all types are generated - so
// we also listen on @Generated, so there is another round of annotation processing where we have all
// types nice and ready
Expand Down Expand Up @@ -114,6 +122,23 @@ public void processingOver(RoundContext roundContext) {
}
}

private void updateServiceLoaderResource() {
CodegenFiler filer = ctx.filer();
FilerTextResource serviceLoaderResource = filer.textResource("META-INF/helidon/service.loader");
List<String> lines = new ArrayList<>(serviceLoaderResource.lines());
if (lines.isEmpty()) {
lines.add("# List of service contracts we want to support either from service registry, or from service loader");
}
for (String serviceLoaderContract : this.serviceLoaderContracts) {
if (!lines.contains(serviceLoaderContract)) {
lines.add(serviceLoaderContract);
}
}

serviceLoaderResource.lines(lines);
serviceLoaderResource.write();
}

private void process(RoundContext roundContext, TypeInfo blueprint) {
TypeContext typeContext = TypeContext.create(ctx, blueprint);
AnnotationDataBlueprint blueprintDef = typeContext.blueprintData();
Expand Down Expand Up @@ -227,6 +252,14 @@ private void process(RoundContext roundContext, TypeInfo blueprint) {
classModel,
blueprint.typeName(),
blueprint.originatingElement().orElse(blueprint.typeName()));

if (typeContext.typeInfo().supportsServiceRegistry() && typeContext.propertyData().hasProvider()) {
for (PrototypeProperty property : typeContext.propertyData().properties()) {
if (property.configuredOption().provider()) {
this.serviceLoaderContracts.add(property.configuredOption().providerType().genericTypeName().fqName());
}
}
}
}

private static void addCreateDefaultMethod(AnnotationDataBlueprint blueprintDef,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,12 +151,30 @@ private static Optional<FactoryMethod> createFromConfigMethod(CodegenContext ctx

// first look at declared type and blueprint
String methodName = "create" + capitalize(typeHandler.name());

// check the blueprint itself, and then check the custom methods type
Optional<TypeName> returnType = findFactoryMethodByParamType(blueprint,
COMMON_CONFIG,
methodName);

TypeName typeWithFactoryMethod = blueprint.typeName();

if (returnType.isEmpty()) {
if (blueprint.hasAnnotation(Types.PROTOTYPE_CUSTOM_METHODS)) {
Optional<TypeInfo> typeInfo = blueprint.annotation(Types.PROTOTYPE_CUSTOM_METHODS)
.typeValue()
.flatMap(ctx::typeInfo);
if (typeInfo.isPresent()) {
TypeInfo customMethods = typeInfo.get();
typeWithFactoryMethod = customMethods.typeName();
returnType = findFactoryMethodByParamType(customMethods,
COMMON_CONFIG,
methodName);
}
}
}

if (returnType.isPresent()) {
TypeName typeWithFactoryMethod = blueprint.typeName();
return Optional.of(new FactoryMethod(typeWithFactoryMethod,
returnType.get(),
methodName,
Expand Down
Loading
Loading