Skip to content

Commit

Permalink
Merge pull request #303 from perfectsense/feature/update-scope
Browse files Browse the repository at this point in the history
Fixes to expose pending and current workflow resources to update action.
  • Loading branch information
Jeremy Collins authored Jun 25, 2020
2 parents d258c6c + 4f883b4 commit 2baeb08
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
19 changes: 17 additions & 2 deletions core/src/main/java/gyro/core/resource/DiffableInternals.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import gyro.core.scope.DiffableScope;
import gyro.core.scope.NodeEvaluator;
import gyro.core.scope.RootScope;
import gyro.core.scope.Scope;
import gyro.core.workflow.ModifiedIn;
import gyro.lang.ast.Node;
import gyro.lang.ast.block.BlockNode;
Expand Down Expand Up @@ -111,13 +112,27 @@ public static void reevaluate(Diffable diffable) {
* Create a new scope that is disconnected from the original configuration.
*
* @param diffable The diffable to disconnect
* @param scope parent scope to override
*/
public static void disconnect(Diffable diffable) {
diffable.scope = new DiffableScope(diffable.scope.getParent(), null);
public static void disconnect(Diffable diffable, Scope scope) {
if (scope == null) {
scope = diffable.scope.getParent();
}

diffable.scope = new DiffableScope(scope, null);

disconnectChildren(diffable);
}

/**
* Create a new scope that is disconnected from the original configuration.
*
* @param diffable The diffable to disconnect
*/
public static void disconnect(Diffable diffable) {
disconnect(diffable, null);
}

/**
* Create a new scope that is disconnected from the original configuration.
*
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/java/gyro/core/workflow/UpdateAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public void execute(
Resource pendingResource = visitResource(resource, scope);
DiffableInternals.setModifiedIn(pendingResource, modifiedIn);

DiffableInternals.disconnect(pendingResource);
DiffableInternals.disconnect(pendingResource, scope);
DiffableScope resourceScope = DiffableInternals.getScope(pendingResource);
NodeEvaluator evaluator = pending.getEvaluator();

Expand Down

0 comments on commit 2baeb08

Please sign in to comment.