Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update process should check version and not allow reversion through update #765

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import java.util.stream.Collectors;

import org.apache.commons.io.FileUtils;
import org.eclipse.aether.artifact.Artifact;
import org.jboss.galleon.ProvisioningException;
import org.jboss.galleon.diff.FsDiff;
import org.jboss.galleon.diff.FsEntry;
Expand Down Expand Up @@ -117,7 +118,6 @@ public Integer call() throws Exception {
log.tracef("Perform full update");

console.println(CliMessages.MESSAGES.updateHeader(installationDir));

try (UpdateAction updateAction = actionFactory.update(installationDir, mavenOptions, console, repositories)) {
performUpdate(updateAction, yes, console, installationDir);
}
Expand All @@ -133,6 +133,12 @@ private boolean performUpdate(UpdateAction updateAction, boolean yes, CliConsole
Path targetDir = null;
try {
targetDir = Files.createTempDirectory("update-candidate");
final List<Artifact> manifestUpdates = updateAction.findCurrentChannelSessionManifests();
if(!manifestUpdates.isEmpty()){
for(Artifact version: manifestUpdates){
console.println("Manifest version update detected: Version ["+ version + "]is now available.");
}
}
if (buildUpdate(updateAction, targetDir, yes, console, () -> console.confirmUpdates())) {
console.println("");
console.buildUpdatesComplete();
Expand Down Expand Up @@ -422,17 +428,17 @@ private FeaturePackLocation getFpl(InstallationProfile knownFeaturePack, String
public UpdateCommand(CliConsole console, ActionFactory actionFactory) {
super(console, actionFactory, CliConstants.Commands.UPDATE,
List.of(
new UpdateCommand.PrepareCommand(console, actionFactory),
new UpdateCommand.ApplyCommand(console, actionFactory),
new UpdateCommand.PerformCommand(console, actionFactory),
new UpdateCommand.ListCommand(console, actionFactory),
new PrepareCommand(console, actionFactory),
new ApplyCommand(console, actionFactory),
new PerformCommand(console, actionFactory),
new ListCommand(console, actionFactory),
new SubscribeCommand(console, actionFactory))
);

}

private static boolean buildUpdate(UpdateAction updateAction, Path updateDirectory, boolean yes, CliConsole console, Supplier<Boolean> confirmation) throws OperationException, ProvisioningException {
final UpdateSet updateSet = updateAction.findUpdates();

console.updatesFound(updateSet.getArtifactUpdates());
if (updateSet.isEmpty()) {
return false;
Expand Down Expand Up @@ -470,5 +476,4 @@ public static Path detectProsperoInstallationPath() throws ArgumentParsingExcept
}
return Paths.get(modulePath).toAbsolutePath().getParent();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,13 @@
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

import org.apache.commons.io.FileUtils;
import org.eclipse.aether.artifact.Artifact;
import org.eclipse.aether.artifact.DefaultArtifact;
import org.jboss.galleon.util.PathsUtils;
import org.wildfly.channel.Channel;
import org.wildfly.channel.Repository;
Expand All @@ -35,6 +38,7 @@
import org.wildfly.prospero.api.InstallationMetadata;
import org.wildfly.prospero.api.exceptions.OperationException;
import org.wildfly.prospero.galleon.GalleonEnvironment;
import org.wildfly.prospero.metadata.ManifestVersionRecord;
import org.wildfly.prospero.model.ProsperoConfig;
import org.wildfly.prospero.updates.UpdateFinder;
import org.wildfly.prospero.updates.UpdateSet;
Expand Down Expand Up @@ -171,4 +175,14 @@ private ProsperoConfig addTemporaryRepositories(List<Repository> repositories) {

return new ProsperoConfig(channels, prosperoConfig.getMavenOptions());
}

public List<Artifact> findCurrentChannelSessionManifests() {
List<Artifact> manifestArtifacts = new ArrayList<>();
List<ManifestVersionRecord.MavenManifest> mavenManifests = metadata.getManifestVersions().get().getMavenManifests();
for (ManifestVersionRecord.MavenManifest mavenManifest : mavenManifests) {
manifestArtifacts.add(new DefaultArtifact(mavenManifest.getGroupId(), mavenManifest.getArtifactId(), "yaml", mavenManifest.getVersion()));
}
return manifestArtifacts;
}

}
Loading