Skip to content

Commit

Permalink
[backend] clean caldera settings if executor is not enable (#1550)
Browse files Browse the repository at this point in the history
Signed-off-by: Marine LM <marine.lemezo@filigran.io>
  • Loading branch information
MarineLeM authored Sep 30, 2024
1 parent 24bd966 commit b19e019
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import static java.time.Instant.now;
import static java.time.ZoneOffset.UTC;

@ConditionalOnProperty(prefix = "executor.caldera", name = "enable")
@Log
@Service
public class CalderaExecutorService implements Runnable {
Expand Down Expand Up @@ -85,7 +84,8 @@ public CalderaExecutorService(
this.executor = executorService.register(config.getId(), CALDERA_EXECUTOR_TYPE, CALDERA_EXECUTOR_NAME, getClass().getResourceAsStream("/img/icon-caldera.png"), new String[]{Endpoint.PLATFORM_TYPE.Windows.name(), Endpoint.PLATFORM_TYPE.Linux.name(), Endpoint.PLATFORM_TYPE.MacOS.name()});
this.calderaExecutorContextService.registerAbilities();
} else {
executorService.remove(config.getId());
this.platformSettingsService.cleanMessage(BannerMessage.BANNER_KEYS.CALDERA_UNAVAILABLE);
executorService.removeFromType(CALDERA_EXECUTOR_TYPE);
}
} catch (Exception e) {
log.log(Level.SEVERE, "Error creating caldera executor: " + e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,8 @@ public Executor register(String id, String type, String name, InputStream iconDa
public void remove(String id) {
executorRepository.findById(id).ifPresent(executor -> executorRepository.deleteById(id));
}
@Transactional
public void removeFromType(String type) {
executorRepository.findByType(type).ifPresent(executor -> executorRepository.deleteById(executor.getId()));
}
}

0 comments on commit b19e019

Please sign in to comment.