Skip to content

Commit

Permalink
remove closing states (#176)
Browse files Browse the repository at this point in the history
fixes #174
  • Loading branch information
aastein authored Apr 3, 2018
1 parent baa56c6 commit f1ce7d1
Show file tree
Hide file tree
Showing 18 changed files with 135 additions and 734 deletions.
8 changes: 1 addition & 7 deletions _docs/dot/tenant-cancel.dot
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ digraph marketplace {
"5" [shape=box label="Deployment: Closed\lDeploymentGroup: Closed\l"];
"6" [shape=box label="Deployment: Closed\lDeploymentGroup: Closed\lOrder: Closed\l"];
"7" [shape=box label="Deployment: Closed\lDeploymentGroup: Closed\lOrder: Closed\lFulfillment: Closed\l"];
"8" [shape=box label="Deployment: Closing\lDeploymentGroup: Closing\lOrder: Closed\lFulfillment: Closed\lLease: Closing\l"];

"9" [shape=box label="Deployment: Closed\lDeploymentGroup: Closed\lOrder: Closed\lFulfillment: Closed\lLease: Closed\l"];
"8" [shape=box label="Deployment: Closed\lDeploymentGroup: Closed\lOrder: Closed\lFulfillment: Closed\lLease: Closed\l"];

"0" -> "1" [label="TxCreateDeployment"];
"1" -> "2" [label="TxCreateOrder"];
Expand All @@ -26,10 +24,6 @@ digraph marketplace {
"3" -> "7" [label="TxCloseDeployment"];
"4" -> "8" [label="TxCloseDeployment"];

"8" -> "9" [label="TxCloseLease"];


{ rank=same "1", "2", "3", "4" }
{ rank=same "5", "6", "7", "8" }
{ rank=same "9" }
}
71 changes: 27 additions & 44 deletions _docs/dot/tenant-cancel.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion _integration/cmp/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func deployCreate(key vars.Ref, daddr vars.Ref) gestalt.Component {
}

func deployClose(key vars.Ref, daddr vars.Ref) gestalt.Component {
check := deployQueryState(daddr, types.Deployment_CLOSING)
check := deployQueryState(daddr, types.Deployment_CLOSED)

return g.Group("deploy-close").
Run(
Expand Down
33 changes: 12 additions & 21 deletions app/deployment/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -343,14 +343,23 @@ func (a *app) doDeliverCloseTx(ctx apptypes.Context, tx *types.TxCloseDeployment
}
}

deployment.State = types.Deployment_CLOSED
err = a.State().Deployment().Save(deployment)
if err != nil {
return tmtypes.ResponseDeliverTx{
Code: code.INVALID_TRANSACTION,
Log: err.Error(),
}
}

groups, err := a.State().DeploymentGroup().ForDeployment(deployment.Address)
if err != nil {
return tmtypes.ResponseDeliverTx{
Code: code.INVALID_TRANSACTION,
Log: err.Error(),
}
}
if deployment == nil {
if groups == nil {
return tmtypes.ResponseDeliverTx{
Code: code.INVALID_TRANSACTION,
Log: "Deployment groups",
Expand All @@ -365,18 +374,8 @@ func (a *app) doDeliverCloseTx(ctx apptypes.Context, tx *types.TxCloseDeployment
}
}

deployment.State = types.Deployment_CLOSED
groupState := types.DeploymentGroup_CLOSED

if leases != nil {
deployment.State = types.Deployment_CLOSING
groupState = types.DeploymentGroup_CLOSING
}

for _, group := range groups {
if group.State != types.DeploymentGroup_CLOSING {
group.State = groupState
}
group.State = types.DeploymentGroup_CLOSED
err = a.State().DeploymentGroup().Save(group)
if err != nil {
return tmtypes.ResponseDeliverTx{
Expand Down Expand Up @@ -426,7 +425,7 @@ func (a *app) doDeliverCloseTx(ctx apptypes.Context, tx *types.TxCloseDeployment

if leases != nil {
for _, lease := range leases {
lease.State = types.Lease_CLOSING
lease.State = types.Lease_CLOSED
err = a.State().Lease().Save(lease)
if err != nil {
return tmtypes.ResponseDeliverTx{
Expand All @@ -437,14 +436,6 @@ func (a *app) doDeliverCloseTx(ctx apptypes.Context, tx *types.TxCloseDeployment
}
}

err = a.State().Deployment().Save(deployment)
if err != nil {
return tmtypes.ResponseDeliverTx{
Code: code.INVALID_TRANSACTION,
Log: err.Error(),
}
}

return tmtypes.ResponseDeliverTx{
Tags: apptypes.NewTags(a.Name(), apptypes.TxTypeCloseDeployment),
}
Expand Down
2 changes: 1 addition & 1 deletion app/deployment/app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ func TestCloseTx_4(t *testing.T) {

testutil.CloseDeployment(t, app, &depl.Address, &key)

check(types.Deployment_CLOSING, types.DeploymentGroup_CLOSING, types.Order_CLOSED, types.Fulfillment_CLOSED, types.Lease_CLOSING)
check(types.Deployment_CLOSED, types.DeploymentGroup_CLOSED, types.Order_CLOSED, types.Fulfillment_CLOSED, types.Lease_CLOSED)
}

// check deployment and group query & status
Expand Down
Loading

0 comments on commit f1ce7d1

Please sign in to comment.