Skip to content

Commit

Permalink
fix (jkube-kit): generify watch support for all build strategies
Browse files Browse the repository at this point in the history
Signed-off-by: Marc Nuri <[email protected]>
  • Loading branch information
manusa committed Mar 25, 2024
1 parent f0ae12a commit cfa80fc
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,34 +13,37 @@
*/
package org.eclipse.jkube.kit.config.image.build;

import lombok.Getter;

/**
* OpenShift build mode. Only used when mode is "openshift"
*
* @author roland
* @since 01/08/16
*/
@Getter
public enum JKubeBuildStrategy {

// Constants used to extract extra information from a `fromExt` build configuration
/**
* S2i build with a binary source
*/
s2i("S2I"),
s2i("S2I", true),

/**
* JIB build
*/
jib("Jib"),
jib("Jib", true),

/**
* Docker build with a binary source
*/
docker("Docker"),
docker("Docker", true),

/**
* BuildPacks
*/
buildpacks("Buildpacks");
buildpacks("Buildpacks", false);

// Source strategy elements
public enum SourceStrategy {
Expand All @@ -56,9 +59,11 @@ public String key() {


private final String label;
private final boolean supportsWatch;

JKubeBuildStrategy(String label) {
JKubeBuildStrategy(String label, boolean supportsWatch) {
this.label = label;
this.supportsWatch = supportsWatch;
}

/**
Expand All @@ -74,8 +79,5 @@ public boolean isSame(String type) {
);
}

public String getLabel() {
return label;
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ private WatcherManager() {
public static void watch(List<ImageConfiguration> ret, String namespace, Collection<HasMetadata> resources, WatcherContext watcherCtx)
throws Exception {

if (watcherCtx.getJKubeBuildStrategy() != null && watcherCtx.getJKubeBuildStrategy().equals(JKubeBuildStrategy.buildpacks)) {
throw new JKubeException("Watch is not supported in BuildPacks build strategy");
if (watcherCtx.getJKubeBuildStrategy() != null && !watcherCtx.getJKubeBuildStrategy().isSupportsWatch()) {
throw new JKubeException("Watch is not supported in " + watcherCtx.getJKubeBuildStrategy().getLabel() + " build strategy");
}
final PluginServiceFactory<WatcherContext> pluginFactory = new PluginServiceFactory<>(watcherCtx);
if (watcherCtx.isUseProjectClasspath()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ void watch_whenBuildPacksBuildStrategy_thenThrowException() {
// When
assertThatExceptionOfType(JKubeException.class)
.isThrownBy(() -> WatcherManager.watch(null, null, null, watcherContext))
.withMessage("Watch is not supported in BuildPacks build strategy");
.withMessage("Watch is not supported in Buildpacks build strategy");
}

// Loaded from META-INF/jkube/watcher-default
Expand Down

0 comments on commit cfa80fc

Please sign in to comment.