本文整理匯總了Golang中k8s/io/kubernetes/pkg/api/unversioned.Time.UnixNano方法的典型用法代碼示例。如果您正苦於以下問題:Golang Time.UnixNano方法的具體用法?Golang Time.UnixNano怎麽用?Golang Time.UnixNano使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類k8s/io/kubernetes/pkg/api/unversioned.Time
的用法示例。
在下文中一共展示了Time.UnixNano方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: RecordConfigEvent
// RecordConfigEvent records an event for the deployment config referenced by the
// deployment.
func RecordConfigEvent(client kclient.EventNamespacer, deployment *kapi.ReplicationController, decoder runtime.Decoder, eventType, reason, msg string) {
t := unversioned.Time{Time: time.Now()}
var obj runtime.Object = deployment
if config, err := deployutil.DecodeDeploymentConfig(deployment, decoder); err == nil {
obj = config
} else {
glog.Errorf("Unable to decode deployment config from %s/%s: %v", deployment.Namespace, deployment.Name, err)
}
ref, err := kapi.GetReference(obj)
if err != nil {
glog.Errorf("Unable to get reference for %#v: %v", obj, err)
return
}
event := &kapi.Event{
ObjectMeta: kapi.ObjectMeta{
Name: fmt.Sprintf("%v.%x", ref.Name, t.UnixNano()),
Namespace: ref.Namespace,
},
InvolvedObject: *ref,
Reason: reason,
Message: msg,
Source: kapi.EventSource{
Component: deployutil.DeployerPodNameFor(deployment),
},
FirstTimestamp: t,
LastTimestamp: t,
Count: 1,
Type: eventType,
}
if _, err := client.Events(ref.Namespace).Create(event); err != nil {
glog.Errorf("Could not create event '%#v': %v", event, err)
}
}
示例2: emitEvent
func (e *HookExecutor) emitEvent(deployment *kapi.ReplicationController, eventType, reason, msg string) {
t := unversioned.Time{Time: time.Now()}
var ref *kapi.ObjectReference
if config, err := deployutil.DecodeDeploymentConfig(deployment, e.decoder); err != nil {
glog.Errorf("Unable to decode deployment %s/%s to replication contoller: %v", deployment.Namespace, deployment.Name, err)
if ref, err = kapi.GetReference(deployment); err != nil {
glog.Errorf("Unable to get reference for %#v: %v", deployment, err)
return
}
} else {
if ref, err = kapi.GetReference(config); err != nil {
glog.Errorf("Unable to get reference for %#v: %v", config, err)
return
}
}
event := &kapi.Event{
ObjectMeta: kapi.ObjectMeta{
Name: fmt.Sprintf("%v.%x", ref.Name, t.UnixNano()),
Namespace: ref.Namespace,
},
InvolvedObject: *ref,
Reason: reason,
Message: msg,
FirstTimestamp: t,
LastTimestamp: t,
Count: 1,
Type: eventType,
}
if _, err := e.events.Create(event); err != nil {
glog.Errorf("Could not send event '%#v': %v", event, err)
}
}
示例3: makeEvent
func (recorder *recorderImpl) makeEvent(ref *api.ObjectReference, reason, message string) *api.Event {
t := unversioned.Time{recorder.clock.Now()}
namespace := ref.Namespace
if namespace == "" {
namespace = api.NamespaceDefault
}
return &api.Event{
ObjectMeta: api.ObjectMeta{
Name: fmt.Sprintf("%v.%x", ref.Name, t.UnixNano()),
Namespace: namespace,
},
InvolvedObject: *ref,
Reason: reason,
Message: message,
FirstTimestamp: t,
LastTimestamp: t,
Count: 1,
}
}
示例4: makeEvent
func (f *FakeRecorder) makeEvent(ref *v1.ObjectReference, eventtype, reason, message string) *v1.Event {
fmt.Println("make event")
t := unversioned.Time{Time: f.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,
}
}