Skip to content
This repository has been archived by the owner on Jun 19, 2024. It is now read-only.

Commit

Permalink
Fix #1793: Labels missing for some objects
Browse files Browse the repository at this point in the history
Reintroduce Enricher Task removed during enrichment process refactoring.
  • Loading branch information
rohanKanojia committed Mar 17, 2020
1 parent 61b0a92 commit 2207ca7
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ Usage:
* Fix #1791: Fix NullPointerException in FileDataSecretEnricher (due to recent change in Kubernetes Client Builder null to LinkedHashMap conversion)
* Fix: ImageChangeTags not being applied in DeploymentConfig generated by plugin in case of resource fragments. (Issue found in [this](https://stackoverflow.com/questions/60375063) StackOverflow post.)
* Fix #1798: Jib logs display correctly, and support ansi
* Fix #1793: Labels missing for some objects

### 4.4.0 (2020-02-13)
* Fix #1572: Support maven --batch-mode option
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package io.fabric8.maven.plugin.mojo.build;

import io.fabric8.kubernetes.api.model.KubernetesListBuilder;
import io.fabric8.maven.core.access.ClusterAccess;
import io.fabric8.maven.core.access.ClusterConfiguration;
import io.fabric8.maven.core.config.BuildRecreateMode;
Expand All @@ -27,11 +28,16 @@
import io.fabric8.maven.core.service.Fabric8ServiceHub;
import io.fabric8.maven.core.util.Configs;
import io.fabric8.maven.core.service.kubernetes.jib.JibAssemblyManager;
import io.fabric8.maven.core.util.MavenUtil;
import io.fabric8.maven.core.util.ProfileUtil;
import io.fabric8.maven.docker.config.ImageConfiguration;
import io.fabric8.maven.docker.service.ServiceHub;
import io.fabric8.maven.docker.util.EnvUtil;
import io.fabric8.maven.docker.util.Task;
import io.fabric8.maven.enricher.api.EnricherContext;
import io.fabric8.maven.enricher.api.MavenEnricherContext;
import io.fabric8.maven.generator.api.GeneratorContext;
import io.fabric8.maven.plugin.enricher.EnricherManager;
import io.fabric8.maven.plugin.generator.GeneratorManager;
import io.fabric8.maven.plugin.mojo.ResourceDirCreator;
import org.apache.maven.plugin.MojoExecutionException;
Expand Down Expand Up @@ -328,6 +334,14 @@ protected BuildService.BuildServiceConfig getBuildServiceConfig() throws MojoExe
projectHelper.attachArtifact(project, "yml", classifier, destFile);
}
})
.enricherTask(new Task<KubernetesListBuilder>() {
@Override
public void execute(KubernetesListBuilder builder) throws Exception {
EnricherManager enricherManager = new EnricherManager(resources, getEnricherContext(), MavenUtil.getCompileClasspathElementsIfRequested(project, useProjectClasspath));
enricherManager.enrich(PlatformMode.kubernetes, builder);
enricherManager.enrich(PlatformMode.openshift, builder);
}
})
.build();
}

Expand Down Expand Up @@ -396,6 +410,27 @@ private GeneratorContext getGeneratorContext() {
.build();
}

// Get enricher context
public EnricherContext getEnricherContext() {
return new MavenEnricherContext.Builder()
.project(project)
.session(session)
.config(extractEnricherConfig())
.images(getResolvedImages())
.resources(resources)
.log(log)
.build();
}

// Get enricher config
private ProcessorConfig extractEnricherConfig() {
try {
return ProfileUtil.blendProfileWithConfiguration(ProfileUtil.ENRICHER_CONFIG, profile, resourceDir, enricher);
} catch (IOException e) {
throw new IllegalArgumentException("Cannot extract enricher config: " + e,e);
}
}

private Fabric8ServiceHub getFabric8ServiceHub() {
return new Fabric8ServiceHub.Builder()
.log(log)
Expand Down

0 comments on commit 2207ca7

Please sign in to comment.