Skip to content

Commit

Permalink
Reinstate github repository into deployment database as it was intended
Browse files Browse the repository at this point in the history
  • Loading branch information
kimtore committed Jun 12, 2024
1 parent d505349 commit 46cb08a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
9 changes: 5 additions & 4 deletions pkg/grpc/deployserver/deployserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,11 @@ func (ds *deployServer) addToDatabase(ctx context.Context, request *pb.Deploymen

cluster := request.GetCluster()
deployment := database.Deployment{
ID: request.GetID(),
Team: request.GetTeam(),
Cluster: &cluster,
Created: pb.TimestampAsTime(request.GetTime()),
ID: request.GetID(),
Team: request.GetTeam(),
Cluster: &cluster,
Created: pb.TimestampAsTime(request.GetTime()),
GitHubRepository: request.GetRepository().FullNamePtr(),
}

// Write deployment request to database
Expand Down
10 changes: 10 additions & 0 deletions pkg/pb/repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,16 @@ func (m *GithubRepository) FullName() string {
return fmt.Sprintf("%s/%s", m.GetOwner(), m.GetName())
}

// FullNamePtr returns a pointer to the full name "navikt/foobar" of the repository.
// If GithubRepository is null, returns a null pointer.
func (m *GithubRepository) FullNamePtr() *string {
if m == nil || len(m.GetName()) == 0 || len(m.GetOwner()) == 0 {
return nil
}
fullName := fmt.Sprintf("%s/%s", m.GetOwner(), m.GetName())
return &fullName
}

func (m *GithubRepository) Valid() bool {
return len(m.GetOwner()) > 0 && len(m.GetName()) > 0
}

0 comments on commit 46cb08a

Please sign in to comment.