Skip to content
This repository has been archived by the owner on Aug 25, 2024. It is now read-only.

Commit

Permalink
Adding force option to update to skip validations
Browse files Browse the repository at this point in the history
  • Loading branch information
cdbartholomew committed Apr 28, 2024
1 parent fc24ae0 commit 1b25c8f
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,11 @@ public static class UpdateApplicationCmd extends AbstractDeployApplicationCmd {
description = "Secrets file path")
private String secretFilePath;

@CommandLine.Option(
names = {"--force"},
description = "Skip validation and force update. Use with caution.")
private boolean force;

@Override
String applicationId() {
return name;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public static class PulsarDLQSourceConfiguration {
The URL of the Pulsar cluster to connect to.
""",
defaultValue = "pulsar://localhost:6650",
required = true)
required = false)
@JsonProperty("pulsar-url")
private String pulsarUrl;

Expand All @@ -69,7 +69,7 @@ public static class PulsarDLQSourceConfiguration {
Namespace to listen for DLQ topics.
""",
defaultValue = "public/default",
required = true)
required = false)
@JsonProperty("namespace")
private String namespace;

Expand All @@ -79,7 +79,7 @@ public static class PulsarDLQSourceConfiguration {
Subscription name to use for the DLQ topics.
""",
defaultValue = "langstream-dlq-subscription",
required = true)
required = false)
@JsonProperty("subscription")
private String subscription;

Expand All @@ -89,7 +89,7 @@ public static class PulsarDLQSourceConfiguration {
Suffix to use for DLQ topics.
""",
defaultValue = "-DLQ",
required = true)
required = false)
@JsonProperty("dlq-suffix")
private String dlqSuffix;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,8 @@ void updateApplication(
@NotBlank @PathVariable("id") String applicationId,
@NotNull @RequestParam("app") Optional<MultipartFile> appFile,
@RequestParam Optional<String> instance,
@RequestParam Optional<String> secrets)
@RequestParam Optional<String> secrets,
@RequestParam(value = "force", required = false) Boolean force)
throws Exception {
performAuthorization(authentication, tenant);
final ParsedApplication parsedApplication =
Expand All @@ -189,7 +190,8 @@ void updateApplication(
tenant,
applicationId,
parsedApplication.getApplication(),
parsedApplication.getCodeArchiveReference());
parsedApplication.getCodeArchiveReference(),
force);
}

@Data
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,17 +172,19 @@ public void updateApplication(
String tenant,
String applicationId,
ModelBuilder.ApplicationWithPackageInfo applicationInstance,
String codeArchiveReference) {
String codeArchiveReference,
Boolean force) {
checkTenant(tenant);
validateDeployMergeAndUpdate(
tenant, applicationId, applicationInstance, codeArchiveReference);
tenant, applicationId, applicationInstance, codeArchiveReference, force);
}

private void validateDeployMergeAndUpdate(
String tenant,
String applicationId,
ModelBuilder.ApplicationWithPackageInfo applicationInstance,
String codeArchiveReference) {
String codeArchiveReference,
Boolean force) {

final StoredApplication existing = applicationStore.get(tenant, applicationId, false);
if (existing == null) {
Expand All @@ -191,7 +193,8 @@ private void validateDeployMergeAndUpdate(
final Application newApplication = applicationInstance.getApplication();
if (!applicationInstance.isHasInstanceDefinition()
&& !applicationInstance.isHasSecretDefinition()
&& !applicationInstance.isHasAppDefinition()) {
&& !applicationInstance.isHasAppDefinition()
&& !force) {
throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "No changes detected");
}
if (!applicationInstance.isHasInstanceDefinition()) {
Expand All @@ -212,7 +215,9 @@ private void validateDeployMergeAndUpdate(
newApplication.setResources(existing.getInstance().getResources());
}
final ExecutionPlan newPlan = validateExecutionPlan(applicationId, newApplication);
validateUpdate(tenant, existing, existingSecrets, newPlan);
if (!force) {
validateUpdate(tenant, existing, existingSecrets, newPlan);
}
if (codeArchiveReference == null) {
codeArchiveReference = existing.getCodeArchiveReference();
}
Expand Down

0 comments on commit 1b25c8f

Please sign in to comment.