Skip to content

Commit

Permalink
feat: track deployment events (#1362)
Browse files Browse the repository at this point in the history
Here we add logic for tracking the deployment(s) of a commit's version
to environment(s) and the triggering release train, if any.

Below is a sample.

| ![](https://i.imgur.com/KjGJgRA.png)|
| :---: |
| _Figure 1: sample commit page with deployment events_|
  • Loading branch information
Khaled Ismaeel authored Feb 27, 2024
1 parent eba0f79 commit 17eb96c
Show file tree
Hide file tree
Showing 11 changed files with 931 additions and 129 deletions.
15 changes: 13 additions & 2 deletions pkg/api/v1/api.proto
Original file line number Diff line number Diff line change
Expand Up @@ -57,17 +57,28 @@ message GetCommitInfoResponse {
message Event {
// data that ALL events have:
google.protobuf.Timestamp created_at = 1;

string uuid = 2;
// data that is different per event type:
oneof event_type {
CreateReleaseEvent create_release_event = 2;
CreateReleaseEvent create_release_event = 3;
DeploymentEvent deployment_event = 4;
}
}

message CreateReleaseEvent {
repeated string environment_names = 1;
}

message DeploymentEvent {
message ReleaseTrainSource {
string upstream_environment = 1;
optional string target_environment_group = 2;
}
string application = 1;
string target_environment = 2;
optional ReleaseTrainSource release_train_source = 3;
}

message TagData {
string tag = 1;
string commit_id = 2;
Expand Down
5 changes: 5 additions & 0 deletions pkg/uuid/uuid.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,8 @@ func GetTime(id *UUID) *timestamppb.Timestamp {
result := timestamppb.New(ts)
return result
}

func TimeFromUUID(uuidStr string) *timestamppb.Timestamp {
uuidVar, _ := timeuuid.ParseUUID(uuidStr)
return GetTime(&uuidVar)
}
1 change: 1 addition & 0 deletions services/cd-service/pkg/event/event.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ package event

const (
NewReleaseEventName = "new-release"
DeploymentEventName = "deployment"
)
32 changes: 31 additions & 1 deletion services/cd-service/pkg/repository/testutil/testutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,15 @@ package testutil

import (
"context"
"fmt"
"strings"
"time"

"github.com/freiheit-com/kuberpult/services/cd-service/pkg/config"
"github.com/onokonem/sillyQueueServer/timeuuid"
"time"

"github.com/freiheit-com/kuberpult/pkg/auth"
"github.com/freiheit-com/kuberpult/pkg/uuid"
"google.golang.org/grpc/metadata"
)

Expand Down Expand Up @@ -110,3 +114,29 @@ type TestGenerator struct {
func (t TestGenerator) Generate() string {
return timeuuid.UUIDFromTime(t.Time).String()
}

type IncrementalUUIDBase struct {
count uint64
}

func (gen *IncrementalUUIDBase) Generate() string {
ret := "00000000-0000-0000-0000-" + strings.Repeat("0", (12-len(fmt.Sprint(gen.count)))) + fmt.Sprint(gen.count)
gen.count++
return ret
}

type IncrementalUUID struct {
gen *IncrementalUUIDBase
}

func (gen IncrementalUUID) Generate() string {
return gen.gen.Generate()
}

func NewIncrementalUUIDGenerator() uuid.GenerateUUIDs {
fakeGenBase := IncrementalUUIDBase{}
fakeGen := IncrementalUUID{
gen: &fakeGenBase,
}
return fakeGen
}
Loading

0 comments on commit 17eb96c

Please sign in to comment.