1 /* 2 Copyright 2018 The Kubernetes Authors. 3 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10 Unless required by applicable law or agreed to in writing, software 11 distributed under the License is distributed on an "AS IS" BASIS, 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 See the License for the specific language governing permissions and 14 limitations under the License. 15 */ 16 17 package v1 18 19 import ( 20 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" 21 ) 22 23 // +genclient 24 // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object 25 26 // Lease defines a lease concept. 27 type Lease struct { 28 metav1.TypeMeta `json:",inline"` 29 // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata 30 // +optional 31 metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` 32 33 // spec contains the specification of the Lease. 34 // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status 35 // +optional 36 Spec LeaseSpec `json:"spec,omitempty" protobuf:"bytes,2,opt,name=spec"` 37 } 38 39 // LeaseSpec is a specification of a Lease. 40 type LeaseSpec struct { 41 // holderIdentity contains the identity of the holder of a current lease. 42 // +optional 43 HolderIdentity *string `json:"holderIdentity,omitempty" protobuf:"bytes,1,opt,name=holderIdentity"` 44 // leaseDurationSeconds is a duration that candidates for a lease need 45 // to wait to force acquire it. This is measure against time of last 46 // observed renewTime. 47 // +optional 48 LeaseDurationSeconds *int32 `json:"leaseDurationSeconds,omitempty" protobuf:"varint,2,opt,name=leaseDurationSeconds"` 49 // acquireTime is a time when the current lease was acquired. 50 // +optional 51 AcquireTime *metav1.MicroTime `json:"acquireTime,omitempty" protobuf:"bytes,3,opt,name=acquireTime"` 52 // renewTime is a time when the current holder of a lease has last 53 // updated the lease. 54 // +optional 55 RenewTime *metav1.MicroTime `json:"renewTime,omitempty" protobuf:"bytes,4,opt,name=renewTime"` 56 // leaseTransitions is the number of transitions of a lease between 57 // holders. 58 // +optional 59 LeaseTransitions *int32 `json:"leaseTransitions,omitempty" protobuf:"varint,5,opt,name=leaseTransitions"` 60 } 61 62 // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object 63 64 // LeaseList is a list of Lease objects. 65 type LeaseList struct { 66 metav1.TypeMeta `json:",inline"` 67 // Standard list metadata. 68 // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata 69 // +optional 70 metav1.ListMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` 71 72 // items is a list of schema objects. 73 Items []Lease `json:"items" protobuf:"bytes,2,rep,name=items"` 74 } 75