Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions pkg/app/api/grpcapi/piped_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -1030,7 +1030,6 @@ func (a *PipedAPI) CreateDeploymentChain(ctx context.Context, req *pipedservice.
chainBlocks := make([]*model.ChainBlock, 0, len(req.Matchers)+1)
// Add the first deployment which created by piped as the first block of the chain.
chainBlocks = append(chainBlocks, &model.ChainBlock{
Index: 0,
Nodes: []*model.ChainNode{
{
ApplicationRef: &model.ChainApplicationRef{
Expand All @@ -1042,6 +1041,7 @@ func (a *PipedAPI) CreateDeploymentChain(ctx context.Context, req *pipedservice.
},
},
},
StartedAt: time.Now().Unix(),
})

blockAppsMap := make(map[int][]*model.Application, len(req.Matchers))
Expand All @@ -1053,8 +1053,8 @@ func (a *PipedAPI) CreateDeploymentChain(ctx context.Context, req *pipedservice.

blockAppsMap[i+1] = blockApps
chainBlocks = append(chainBlocks, &model.ChainBlock{
Index: int32(i + 1),
Nodes: nodes,
Nodes: nodes,
StartedAt: time.Now().Unix(),
})
}

Expand Down Expand Up @@ -1089,7 +1089,7 @@ func (a *PipedAPI) CreateDeploymentChain(ctx context.Context, req *pipedservice.
Type: model.Command_CHAIN_SYNC_APPLICATION,
ChainSyncApplication: &model.Command_ChainSyncApplication{
DeploymentChainId: dc.Id,
BlockIndex: int32(blockIndex),
BlockIndex: uint32(blockIndex),
ApplicationId: app.Id,
SyncStrategy: model.SyncStrategy_AUTO,
},
Expand Down Expand Up @@ -1131,7 +1131,7 @@ func (a *PipedAPI) InChainDeploymentPlannable(ctx context.Context, req *pipedser
}, nil
}

if req.Deployment.DeploymentChainBlockIndex >= int32(len(dc.Blocks)) {
if req.Deployment.DeploymentChainBlockIndex >= uint32(len(dc.Blocks)) {
return nil, status.Error(codes.InvalidArgument, "invalid deployment with chain block index provided")
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/app/piped/trigger/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func buildDeployment(
now time.Time,
noti *config.DeploymentNotification,
deploymentChainID string,
deploymentChainBlockIndex int32,
deploymentChainBlockIndex uint32,
) (*model.Deployment, error) {

var commitURL string
Expand Down
2 changes: 1 addition & 1 deletion pkg/app/piped/trigger/trigger.go
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ func (t *Trigger) checkRepoCandidates(ctx context.Context, repoID string, cs []c
strategy model.SyncStrategy
strategySummary string
deploymentChainID string
deploymentChainBlockIndex int32
deploymentChainBlockIndex uint32
)

switch c.kind {
Expand Down
2 changes: 1 addition & 1 deletion pkg/datastore/deploymentchainstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ var deploymentChainFactory = func() interface{} {
var (
DeploymentChainAddDeploymentToBlock = func(deployment *model.Deployment) func(*model.DeploymentChain) error {
return func(dc *model.DeploymentChain) error {
if deployment.DeploymentChainBlockIndex == 0 || deployment.DeploymentChainBlockIndex >= int32(len(dc.Blocks)) {
if deployment.DeploymentChainBlockIndex == 0 || deployment.DeploymentChainBlockIndex >= uint32(len(dc.Blocks)) {
return fmt.Errorf("invalid block index provided")
}
block := dc.Blocks[deployment.DeploymentChainBlockIndex]
Expand Down
2 changes: 1 addition & 1 deletion pkg/model/command.proto
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ message Command {

message ChainSyncApplication {
string deployment_chain_id = 1;
int32 block_index = 2;
uint32 block_index = 2;
string application_id = 3 [(validate.rules).string.min_len = 1];
SyncStrategy sync_strategy = 4;
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/model/deployment.proto
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ message Deployment {
string deployment_chain_id = 40;
// Index represents the offset of the node which this deployment
// belongs to.
int32 deployment_chain_block_index = 41;
uint32 deployment_chain_block_index = 41;

int64 completed_at = 100 [(validate.rules).int64.gte = 0];
int64 created_at = 101 [(validate.rules).int64.gte = 0];
Expand Down
4 changes: 1 addition & 3 deletions pkg/model/deployment_chain.proto
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,8 @@ message ChainNode {
}

message ChainBlock {
// Index represent the offset of the node in chain.
int32 index = 1;
// List of applications which should be deployed at the same time in chain.
repeated ChainNode nodes = 2;
repeated ChainNode nodes = 1;

// Unix time when the deployment chain node is started.
int64 started_at = 100 [(validate.rules).int64.gte = 0];
Expand Down