fixes so we can use an annotation to filter out openshift only or kubernetes only resources for different platforms
@@ -65,6 +65,10 @@ import static io.fabric8.maven.plugin.mojo.build.ApplyMojo.DEFAULT_OPENSHIFT_MAN
*/
@Mojo(name = "resource", defaultPhase = LifecyclePhase.PROCESS_RESOURCES, requiresDependencyResolution = ResolutionScope.COMPILE)
public class ResourceMojo extends AbstractResourceMojo {
+ /**
+ * Used to annotate a resource as being for a specific platform only such as "kubernetes" or "openshift"
+ */
+ public static final String TARGET_PLATFORM_ANNOTATION = "fabric8.io/target-platform";
// THe key how we got the the docker maven plugin
private static final String DOCKER_MAVEN_PLUGIN_KEY = "io.fabric8:docker-maven-plugin";
@@ -318,10 +322,23 @@ public class ResourceMojo extends AbstractResourceMojo {
}
private boolean isOpenshiftItem(HasMetadata item) {
- // Simple package name based heuristic
+ if (!isTargetPlatformOpenShift(item)) {
+ return false;
+ }
return item.getClass().getPackage().getName().contains("openshift");
}
+ private boolean isTargetPlatformOpenShift(HasMetadata item) {
+ // Simple package name based heuristic
+ String targetPlatform = KubernetesHelper.getOrCreateAnnotations(item).get(TARGET_PLATFORM_ANNOTATION);
+ if (targetPlatform != null) {
+ if (!targetPlatform.toLowerCase().equals("openshift")) {
+ return false;
+ }
+ }
+ return true;
+ }
+
private KubernetesList generateResources(List<ImageConfiguration> images)
throws IOException, MojoExecutionException {
@@ -444,6 +461,9 @@ public class ResourceMojo extends AbstractResourceMojo {
List<HasMetadata> objects = new ArrayList<>();
if (items != null) {
for (HasMetadata item : items) {
+ if (!isTargetPlatformOpenShift(item)) {
+ continue;
+ }
if (item instanceof Deployment) {
// if we have a Deployment and a DeploymentConfig of the same name
// since we have a different manifest for OpenShift then lets filter out
