本文整理汇总了Golang中k8s/io/kubernetes/pkg/apis/meta/v1.Time类的典型用法代码示例。如果您正苦于以下问题:Golang Time类的具体用法?Golang Time怎么用?Golang Time使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Time类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: Convert_Slice_string_To_unversioned_Time
// Convert_Slice_string_To_unversioned_Time allows converting a URL query parameter value
func Convert_Slice_string_To_unversioned_Time(input *[]string, out *metav1.Time, s conversion.Scope) error {
str := ""
if len(*input) > 0 {
str = (*input)[0]
}
return out.UnmarshalQueryParameter(str)
}
开发者ID:alex-mohr,项目名称:kubernetes,代码行数:8,代码来源:conversion.go
示例2: GetDeletionTimestamp
func (u *Unstructured) GetDeletionTimestamp() *metav1.Time {
var timestamp metav1.Time
timestamp.UnmarshalQueryParameter(getNestedString(u.Object, "metadata", "deletionTimestamp"))
if timestamp.IsZero() {
return nil
}
return ×tamp
}
开发者ID:nak3,项目名称:kubernetes,代码行数:8,代码来源:unstructured.go
示例3: TestScaleDownRCImmediately
func TestScaleDownRCImmediately(t *testing.T) {
time := metav1.Time{Time: time.Now()}
tc := testCase{
minReplicas: 2,
maxReplicas: 5,
initialReplicas: 6,
desiredReplicas: 5,
CPUTarget: 50,
reportedLevels: []uint64{8000, 9500, 1000},
reportedCPURequests: []resource.Quantity{resource.MustParse("0.9"), resource.MustParse("1.0"), resource.MustParse("1.1")},
useMetricsApi: true,
lastScaleTime: &time,
}
tc.runTest(t)
}
开发者ID:alex-mohr,项目名称:kubernetes,代码行数:15,代码来源:horizontal_test.go
示例4: TestScaleUpRCImmediately
func TestScaleUpRCImmediately(t *testing.T) {
time := metav1.Time{Time: time.Now()}
tc := testCase{
minReplicas: 2,
maxReplicas: 6,
initialReplicas: 1,
desiredReplicas: 2,
verifyCPUCurrent: true,
reportedLevels: []uint64{0, 0, 0, 0},
reportedCPURequests: []resource.Quantity{resource.MustParse("1.0"), resource.MustParse("1.0"), resource.MustParse("1.0"), resource.MustParse("1.0")},
useMetricsApi: true,
lastScaleTime: &time,
}
tc.runTest(t)
}
开发者ID:alex-mohr,项目名称:kubernetes,代码行数:15,代码来源:horizontal_test.go
示例5: makeEvent
func (recorder *recorderImpl) makeEvent(ref *v1.ObjectReference, eventtype, reason, message string) *v1.Event {
t := metav1.Time{Time: recorder.clock.Now()}
namespace := ref.Namespace
if namespace == "" {
namespace = v1.NamespaceDefault
}
return &v1.Event{
ObjectMeta: v1.ObjectMeta{
Name: fmt.Sprintf("%v.%x", ref.Name, t.UnixNano()),
Namespace: namespace,
},
InvolvedObject: *ref,
Reason: reason,
Message: message,
FirstTimestamp: t,
LastTimestamp: t,
Count: 1,
Type: eventtype,
}
}
开发者ID:alex-mohr,项目名称:kubernetes,代码行数:20,代码来源:event.go
示例6: afterOrZero
// afterOrZero checks if time t1 is after time t2; if one of them
// is zero, the zero time is seen as after non-zero time.
func afterOrZero(t1, t2 metav1.Time) bool {
if t1.Time.IsZero() || t2.Time.IsZero() {
return t1.Time.IsZero()
}
return t1.After(t2.Time)
}
开发者ID:jonboulle,项目名称:kubernetes,代码行数:8,代码来源:controller_utils.go
示例7:
scheduleTimes := make(map[string]metav1.Time, 0)
runTimes := make(map[string]metav1.Time, 0)
watchTimes := make(map[string]metav1.Time, 0)
var mutex sync.Mutex
checkPod := func(p *v1.Pod) {
mutex.Lock()
defer mutex.Unlock()
defer GinkgoRecover()
if p.Status.Phase == v1.PodRunning {
if _, found := watchTimes[p.Name]; !found {
watchTimes[p.Name] = metav1.Now()
createTimes[p.Name] = p.CreationTimestamp
nodeNames[p.Name] = p.Spec.NodeName
var startTime metav1.Time
for _, cs := range p.Status.ContainerStatuses {
if cs.State.Running != nil {
if startTime.Before(cs.State.Running.StartedAt) {
startTime = cs.State.Running.StartedAt
}
}
}
if startTime != metav1.NewTime(time.Time{}) {
runTimes[p.Name] = startTime
} else {
framework.Failf("Pod %v is reported to be running, but none of its containers is", p.Name)
}
}
}
}
开发者ID:alex-mohr,项目名称:kubernetes,代码行数:31,代码来源:density.go
示例8: SetDeletionTimestamp
func (u *Unstructured) SetDeletionTimestamp(timestamp *metav1.Time) {
ts, _ := timestamp.MarshalQueryParameter()
u.setNestedField(ts, "metadata", "deletionTimestamp")
}
开发者ID:nak3,项目名称:kubernetes,代码行数:4,代码来源:unstructured.go
示例9: GetCreationTimestamp
func (u *Unstructured) GetCreationTimestamp() metav1.Time {
var timestamp metav1.Time
timestamp.UnmarshalQueryParameter(getNestedString(u.Object, "metadata", "creationTimestamp"))
return timestamp
}
开发者ID:nak3,项目名称:kubernetes,代码行数:5,代码来源:unstructured.go
注:本文中的k8s/io/kubernetes/pkg/apis/meta/v1.Time类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论