Skip to content

Commit

Permalink
Let text searches access the vidarr id
Browse files Browse the repository at this point in the history
  • Loading branch information
avarsava committed Jun 18, 2024
1 parent 2bfe974 commit 311f38b
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import java.util.List;
import java.util.Optional;
import java.util.OptionalInt;
import java.util.regex.Pattern;
import java.util.stream.Stream;

/**
Expand All @@ -20,6 +21,8 @@
*/
abstract class RunState {

public abstract boolean search(Pattern query);

public static final class PerformResult {
private final ActionState actionState;
private final List<String> errors;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.util.List;
import java.util.Optional;
import java.util.OptionalInt;
import java.util.regex.Pattern;
import java.util.stream.Stream;

/** State when we have no knowledge of what's going on in Vidarr */
Expand All @@ -36,6 +37,11 @@ public RunStateAttemptSubmit(int attempt) {
this.attempt = attempt;
}

@Override
public boolean search(Pattern query) {
return false;
}

@Override
public AvailableCommands commands() {
return AvailableCommands.RESET_ONLY;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import java.util.List;
import java.util.Optional;
import java.util.OptionalInt;
import java.util.regex.Pattern;
import java.util.stream.Stream;

final class RunStateConflicted extends RunState {
Expand All @@ -26,6 +27,11 @@ public RunStateConflicted(List<String> ids) {
+ String.join(", ", ids));
}

@Override
public boolean search(Pattern query) {
return ids.stream().anyMatch(id -> query.matcher(id).matches());
}

@Override
public AvailableCommands commands() {
return AvailableCommands.RESET_ONLY;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,16 @@
import java.util.List;
import java.util.Optional;
import java.util.OptionalInt;
import java.util.regex.Pattern;
import java.util.stream.Stream;

final class RunStateDead extends RunState {

@Override
public boolean search(Pattern query) {
return false;
}

@Override
public AvailableCommands commands() {
return AvailableCommands.RESET_ONLY;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import java.util.List;
import java.util.Optional;
import java.util.OptionalInt;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import java.util.stream.Stream;

Expand All @@ -34,6 +35,11 @@ public RunStateMissing(String id, List<ExternalKey> keys) {
.collect(Collectors.toList());
}

@Override
public boolean search(Pattern query) {
return query.matcher(id).matches();
}

@Override
public AvailableCommands commands() {
return AvailableCommands.RESET_ONLY;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import java.util.List;
import java.util.Optional;
import java.util.OptionalInt;
import java.util.regex.Pattern;
import java.util.stream.Stream;

final class RunStateMonitor extends RunState {
Expand Down Expand Up @@ -93,6 +94,11 @@ public RunStateMonitor(String workflowRunUrl, WorkflowRunStatusResponse status)
this.status = status;
}

@Override
public boolean search(Pattern query) {
return query.matcher(status.getId()).matches();
}

@Override
public AvailableCommands commands() {
// Failed during provision out may be retried
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,8 @@ public boolean search(Pattern query) {
|| query.matcher(v.getValue()).matches()))
|| checkJson(request.getArguments(), query)
|| checkJson(request.getMetadata(), query)
|| checkJson(request.getEngineParameters(), query);
|| checkJson(request.getEngineParameters(), query)
|| state.search(query);
}

@ActionParameter(required = false)
Expand Down

0 comments on commit 311f38b

Please sign in to comment.