本文整理汇总了Golang中k8s/io/kubernetes/pkg/client/unversioned.EventNamespacer类的典型用法代码示例。如果您正苦于以下问题:Golang EventNamespacer类的具体用法?Golang EventNamespacer怎么用?Golang EventNamespacer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了EventNamespacer类的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: NewHorizontalController
func NewHorizontalController(evtNamespacer client.EventNamespacer, scaleNamespacer client.ScaleNamespacer, hpaNamespacer client.HorizontalPodAutoscalersNamespacer, metricsClient metrics.MetricsClient) *HorizontalController {
broadcaster := record.NewBroadcaster()
broadcaster.StartRecordingToSink(evtNamespacer.Events(""))
recorder := broadcaster.NewRecorder(api.EventSource{Component: "horizontal-pod-autoscaler"})
return &HorizontalController{
metricsClient: metricsClient,
eventRecorder: recorder,
scaleNamespacer: scaleNamespacer,
hpaNamespacer: hpaNamespacer,
}
}
示例3: RecordConfigWarnings
// RecordConfigWarnings records all warning events from the replication controller to the
// associated deployment config.
func RecordConfigWarnings(client kclient.EventNamespacer, rc *kapi.ReplicationController, decoder runtime.Decoder, out io.Writer) {
if rc == nil {
return
}
events, err := client.Events(rc.Namespace).Search(rc)
if err != nil {
fmt.Fprintf(out, "--> Error listing events for replication controller %s: %v\n", rc.Name, err)
return
}
// TODO: Do we need to sort the events?
for _, e := range events.Items {
if e.Type == kapi.EventTypeWarning {
fmt.Fprintf(out, "--> %s: %s %s\n", e.Reason, rc.Name, e.Message)
RecordConfigEvent(client, rc, decoder, e.Type, e.Reason, e.Message)
}
}
}
示例4: GetEventListChannelWithOptions
// GetEventListChannelWithOptions is GetEventListChannel plus list options.
func GetEventListChannelWithOptions(client client.EventNamespacer,
nsQuery *NamespaceQuery, options api.ListOptions, numReads int) EventListChannel {
channel := EventListChannel{
List: make(chan *api.EventList, numReads),
Error: make(chan error, numReads),
}
go func() {
list, err := client.Events(nsQuery.ToRequestParam()).List(options)
var filteredItems []api.Event
for _, item := range list.Items {
if nsQuery.Matches(item.ObjectMeta.Namespace) {
filteredItems = append(filteredItems, item)
}
}
list.Items = filteredItems
for i := 0; i < numReads; i++ {
channel.List <- list
channel.Error <- err
}
}()
return channel
}