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

Fixed registry platforms config merging #25006

Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,6 @@ public RegistryClient buildRegistryClient(RegistryConfig config) throws Registry
} else {
platformsResolver = new MavenPlatformsResolver(platformsConfig, defaultResolver, log);
}

return new RegistryClientDispatcher(config, platformsResolver,
Boolean.TRUE.equals(platformsConfig == null ? Boolean.FALSE : platformsConfig.getExtensionCatalogsIncluded())
? new MavenPlatformExtensionsResolver(defaultResolver, log)
Expand All @@ -179,7 +178,7 @@ private static MavenRegistryArtifactResolver defaultResolver(MavenArtifactResolv
return new MavenRegistryArtifactResolverWithCleanup(resolver, cleanupTimestampedArtifacts);
}

private static RegistryConfig.Mutable completeRegistryConfig(RegistryConfig original, RegistryConfig descriptor) {
static RegistryConfig.Mutable completeRegistryConfig(RegistryConfig original, RegistryConfig descriptor) {
RegistryConfig.Mutable complete = RegistryConfig.builder();

complete.setId(original.getId() == null ? descriptor.getId() : original.getId());
Expand Down Expand Up @@ -226,7 +225,7 @@ private static RegistryPlatformsConfig completeRegistryPlatformConfig(RegistryPl
if (client == null) {
return descriptor;
}
if (isComplete(client)) {
if (isComplete(client, descriptor)) {
return client;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package io.quarkus.registry.client.maven;

import static org.assertj.core.api.Assertions.assertThat;

import io.quarkus.maven.ArtifactCoords;
import io.quarkus.registry.config.RegistryConfig;
import io.quarkus.registry.config.RegistryDescriptorConfig;
import io.quarkus.registry.config.RegistryPlatformsConfig;
import org.junit.jupiter.api.Test;

public class MavenRegistryClientCompleteConfigTest {

@Test
public void testCompletePlatformsConfig() throws Exception {

final RegistryDescriptorConfig descriptorConfig = RegistryDescriptorConfig.builder()
.setArtifact(ArtifactCoords.fromString("org.acme.registry:acme-registry-descriptor::json:1.0-SNAPSHOT"))
.build();

final RegistryConfig.Mutable originalRegistryConfig = RegistryConfig.builder();
originalRegistryConfig.setId("acme-registry")
.setDescriptor(descriptorConfig)
.setPlatforms(RegistryPlatformsConfig.builder()
.setArtifact(ArtifactCoords.fromString("org.acme.registry:acme-platforms::json:1.0-SNAPSHOT"))
.build());

final RegistryConfig.Mutable registryDescriptor = RegistryConfig.builder();
registryDescriptor.setId("acme-registry")
.setDescriptor(descriptorConfig)
.setPlatforms(RegistryPlatformsConfig.builder()
.setArtifact(ArtifactCoords.fromString("org.acme.registry:acme-platforms::json:1.0-SNAPSHOT"))
.setExtensionCatalogsIncluded(true)
.build());

final RegistryConfig.Mutable completeConfig = MavenRegistryClientFactory.completeRegistryConfig(originalRegistryConfig,
registryDescriptor);
assertThat(completeConfig.getId()).isEqualTo("acme-registry");
assertThat(completeConfig.getDescriptor().getArtifact())
.isEqualTo(ArtifactCoords.fromString("org.acme.registry:acme-registry-descriptor::json:1.0-SNAPSHOT"));
final RegistryPlatformsConfig completePlatforms = completeConfig.getPlatforms();
assertThat(completePlatforms).isNotNull();
assertThat(completePlatforms.getArtifact())
.isEqualTo(ArtifactCoords.fromString("org.acme.registry:acme-platforms::json:1.0-SNAPSHOT"));
assertThat(completePlatforms.getExtensionCatalogsIncluded()).isTrue();
}
}