-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix RemoveDeploymentTriggerDecorator order
The decorator RemoveDeploymentTriggerDecorator was not configured to be triggered before ChangeDeploymentTriggerDecorator, so sometimes the image stream tag was wrong. Relates to failures in https://github.com/dekorateio/dekorate/actions/runs/4023231521/jobs/6913879180
- Loading branch information
Showing
10 changed files
with
92 additions
and
119 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
20 changes: 0 additions & 20 deletions
20
...eployment/src/main/java/io/quarkus/kubernetes/deployment/ApplyImageGroupConfigurator.java
This file was deleted.
Oops, something went wrong.
33 changes: 33 additions & 0 deletions
33
...t/src/main/java/io/quarkus/kubernetes/deployment/ApplyImageInfoConfigurationSupplier.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
|
||
package io.quarkus.kubernetes.deployment; | ||
|
||
import io.dekorate.config.ConfigurationSupplier; | ||
import io.dekorate.kubernetes.config.ImageConfiguration; | ||
import io.dekorate.kubernetes.config.ImageConfigurationBuilder; | ||
import io.quarkus.container.spi.ContainerImageInfoBuildItem; | ||
|
||
/** | ||
* Workaround for https://github.com/dekorateio/dekorate/issues/1147: Dekorate only allows providing the image info via | ||
* suppliers, not configurators. | ||
*/ | ||
public class ApplyImageInfoConfigurationSupplier extends ConfigurationSupplier<ImageConfiguration> { | ||
|
||
public ApplyImageInfoConfigurationSupplier(ContainerImageInfoBuildItem image, String defaultRegistry) { | ||
super(create(image, defaultRegistry)); | ||
} | ||
|
||
private static ImageConfigurationBuilder create(ContainerImageInfoBuildItem image, String defaultRegistry) { | ||
ImageConfigurationBuilder builder = new ImageConfigurationBuilder(); | ||
builder.withRegistry(image.getRegistry().orElse(defaultRegistry)); | ||
builder.withEnabled(true); | ||
builder.withGroup(image.getGroup()); | ||
builder.withName(image.getName()); | ||
builder.withVersion(image.getTag()); | ||
return builder; | ||
} | ||
|
||
@Override | ||
public boolean isExplicit() { | ||
return true; | ||
} | ||
} |
19 changes: 0 additions & 19 deletions
19
...oyment/src/main/java/io/quarkus/kubernetes/deployment/ApplyImageRegistryConfigurator.java
This file was deleted.
Oops, something went wrong.
16 changes: 0 additions & 16 deletions
16
...ment/src/main/java/io/quarkus/kubernetes/deployment/ChangeDeploymentTriggerDecorator.java
This file was deleted.
Oops, something went wrong.
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
22 changes: 0 additions & 22 deletions
22
...ment/src/main/java/io/quarkus/kubernetes/deployment/RemoveDeploymentTriggerDecorator.java
This file was deleted.
Oops, something went wrong.
33 changes: 33 additions & 0 deletions
33
.../main/java/io/quarkus/kubernetes/deployment/RemoveDockerImageStreamResourceDecorator.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package io.quarkus.kubernetes.deployment; | ||
|
||
import io.dekorate.kubernetes.decorator.Decorator; | ||
import io.dekorate.kubernetes.decorator.ResourceProvidingDecorator; | ||
import io.dekorate.s2i.decorator.AddDockerImageStreamResourceDecorator; | ||
import io.fabric8.kubernetes.api.model.KubernetesListBuilder; | ||
import io.fabric8.openshift.api.model.ImageStream; | ||
|
||
/** | ||
* Workaround for https://github.com/dekorateio/dekorate/issues/1148: Dekorate is always adding an image stream if we're | ||
* using a docker image, so we need to remove it if we're using a Deployment resource. | ||
*/ | ||
public class RemoveDockerImageStreamResourceDecorator extends ResourceProvidingDecorator<KubernetesListBuilder> { | ||
|
||
private final String name; | ||
|
||
public RemoveDockerImageStreamResourceDecorator(String name) { | ||
this.name = name; | ||
} | ||
|
||
public void visit(KubernetesListBuilder list) { | ||
list.getItems().stream() | ||
.filter(i -> i.getMetadata().getName().equals(name) && i instanceof ImageStream) | ||
.map(ImageStream.class::cast) | ||
.findFirst() | ||
.ifPresent(list::removeFromItems); | ||
} | ||
|
||
@Override | ||
public Class<? extends Decorator>[] after() { | ||
return new Class[] { AddDockerImageStreamResourceDecorator.class }; | ||
} | ||
} |
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