-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WIP. Refactor the code to support to generate a resource of type: Pip…
…eline(Run), Task(Run) Signed-off-by: cmoulliard <[email protected]>
- Loading branch information
1 parent
d26edda
commit a21b404
Showing
9 changed files
with
64 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package dev.snowdrop.factory; | ||
|
||
import dev.snowdrop.model.Configurator; | ||
import io.fabric8.kubernetes.api.model.HasMetadata; | ||
|
||
public interface ActionProvider { | ||
HasMetadata buildResource(Configurator cfg); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package dev.snowdrop.factory; | ||
|
||
import dev.snowdrop.model.Configurator; | ||
import io.fabric8.kubernetes.api.model.HasMetadata; | ||
|
||
public class JobBuilder { | ||
private final JobProvider jobProvider; | ||
private String resourceType; | ||
|
||
public JobBuilder(JobProvider jobProvider) { | ||
this.jobProvider = jobProvider; | ||
} | ||
|
||
public JobBuilder withResourceType(String resourceType) { | ||
this.resourceType = resourceType; | ||
return this; | ||
} | ||
|
||
public HasMetadata buildResource(Configurator cfg) { | ||
return jobProvider.buildResource(cfg, resourceType); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,19 @@ | ||
package dev.snowdrop.factory; | ||
|
||
public class JobFactory { | ||
public static JobProvider withType(Type type) { | ||
switch (type) { | ||
case KONFLUX: | ||
public static JobBuilder withProvider(Type providerType) { | ||
JobProvider provider = createProvider(providerType.toString()); // convert string to enum if needed | ||
return new JobBuilder(provider); | ||
} | ||
|
||
private static JobProvider createProvider(String provider) { | ||
switch (provider.toUpperCase()) { | ||
case "KONFLUX": | ||
return new dev.snowdrop.factory.konflux.pipeline.Pipelines(); | ||
case TEKTON: | ||
case "TEKTON": | ||
return new dev.snowdrop.factory.tekton.pipeline.Pipelines(); | ||
default: | ||
throw new IllegalArgumentException("Unknown type: " + type); | ||
throw new IllegalArgumentException("Unknown provider type: " + provider); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...tory/tekton/pipeline/TaskRefResolver.java → ...wdrop/factory/tekton/TaskRefResolver.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package dev.snowdrop.factory.tekton.task; | ||
|
||
import dev.snowdrop.factory.ActionProvider; | ||
import dev.snowdrop.model.Configurator; | ||
import io.fabric8.kubernetes.api.model.HasMetadata; | ||
|
||
public class Tasks implements ActionProvider { | ||
@Override | ||
public HasMetadata buildResource(Configurator cfg) { | ||
return null; | ||
} | ||
} |