Skip to content
Draft
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
13 changes: 9 additions & 4 deletions internal/service/client/v1/client_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,14 +174,19 @@ func (s *ClientService) CreateLease(ctx context.Context, req *cpb.CreateLeaseReq
return nil, err
}

name, err := uuid.NewV7()
if err != nil {
return nil, err
// Use provided lease_id if specified, otherwise generate a UUIDv7
name := req.LeaseId
if name == "" {
id, err := uuid.NewV7()
if err != nil {
return nil, err
}
name = id.String()
}

jlease, err := jumpstarterdevv1alpha1.LeaseFromProtobuf(req.Lease, types.NamespacedName{
Namespace: namespace,
Name: name.String(),
Name: name,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this would make sense, we just need to make sure that the server provides a reasonable error if the lease name already exists for example.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As well as the jmp client. I.e. explaining that if you provide a lease name, it must be unique.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indeed, i think the generic k8s already exist error is clear, but i'll look

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ack, will mark as approved, if you verify that go ahead and just merge.

}, corev1.LocalObjectReference{
Name: jclient.Name,
})
Expand Down