Skip to content
Open
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
3 changes: 3 additions & 0 deletions controller/api/v1alpha1/lease_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,9 @@ func (l *Lease) ToProtobuf() *cpb.Lease {
Name: l.Status.ExporterRef.Name,
}))
}
if alias, ok := l.Labels[string(LeaseLabelName)]; ok {
lease.Alias = ptr.To(alias)
}

return &lease
}
Expand Down
40 changes: 40 additions & 0 deletions controller/api/v1alpha1/lease_helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -574,4 +574,44 @@ var _ = Describe("Lease.ToProtobuf", func() {

Expect(pb.Tags).To(BeEmpty())
})

It("should populate alias from lease-name label", func() {
lease := &Lease{
ObjectMeta: metav1.ObjectMeta{
Name: "demo-x7k2q",
Namespace: "default",
Labels: map[string]string{
string(LeaseLabelName): "demo",
},
},
Spec: LeaseSpec{
ClientRef: corev1.LocalObjectReference{Name: "test-client"},
Duration: &metav1.Duration{Duration: time.Hour},
Selector: metav1.LabelSelector{MatchLabels: map[string]string{"board": "rpi4"}},
},
}

pb := lease.ToProtobuf()

Expect(pb.Alias).NotTo(BeNil())
Expect(*pb.Alias).To(Equal("demo"))
})

It("should not set alias when lease-name label is absent", func() {
lease := &Lease{
ObjectMeta: metav1.ObjectMeta{
Name: "lease-m9p3r",
Namespace: "default",
},
Spec: LeaseSpec{
ClientRef: corev1.LocalObjectReference{Name: "test-client"},
Duration: &metav1.Duration{Duration: time.Hour},
Selector: metav1.LabelSelector{MatchLabels: map[string]string{"board": "rpi4"}},
},
}

pb := lease.ToProtobuf()

Expect(pb.Alias).To(BeNil())
})
})
1 change: 1 addition & 0 deletions controller/api/v1alpha1/lease_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ type LeaseLabel string
const (
LeaseLabelEnded LeaseLabel = "jumpstarter.dev/lease-ended"
LeaseLabelEndedValue string = "true"
LeaseLabelName LeaseLabel = "jumpstarter.dev/lease-name"
LeaseTagMetadataPrefix string = "metadata.jumpstarter.dev/"
)

Expand Down
184 changes: 126 additions & 58 deletions controller/internal/protocol/jumpstarter/client/v1/client.pb.go

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 15 additions & 15 deletions controller/internal/protocol/jumpstarter/v1/common.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading