k8s/io/kubernetes/pkg/api.Event 示例代码

2022-03-03

以下示例是关于golang中包含api.Event用法的示例代码,想了解api.Event的具体用法?api.Event怎么用?api.Event使用的例子?那么可以参考以下10个相关示例代码来学习它的具体使用方法。

示例1:
event_test.go开发语言: Go项目名称: kubernetes代码行数: 474
39	OnCreate func(e *api.Event) (*api.Event, error)
40	OnUpdate func(e *api.Event) (*api.Event, error)
41}
43// CreateEvent records the event for testing.
44func (t *testEventRecorder) Create(e *api.Event) (*api.Event, error) {
45	if t.OnCreate != nil {
51// UpdateEvent records the event for testing.
52func (t *testEventRecorder) Update(e *api.Event) (*api.Event, error) {
53	if t.OnUpdate != nil {
312
313func validateEvent(actualEvent *api.Event, expectedEvent *api.Event, t *testing.T) (*api.Event, error) {
314	expectCompression := expectedEvent.Count > 1
430	testEvents := testEventRecorder{
431		OnCreate: func(event *api.Event) (*api.Event, error) {
432			num, err := strconv.Atoi(event.Message)
示例2:
rest.go开发语言: Go项目名称: kubernetes代码行数: 151
44func (rs *REST) Create(ctx api.Context, obj runtime.Object) (runtime.Object, error) {
45	event, ok := obj.(*api.Event)
46	if !ok {
67func (rs *REST) Update(ctx api.Context, obj runtime.Object) (runtime.Object, bool, error) {
68	event, ok := obj.(*api.Event)
69	if !ok {
94	}
95	_, ok := obj.(*api.Event)
96	if !ok {
106	}
107	event, ok := obj.(*api.Event)
108	if !ok {
114func (rs *REST) getAttrs(obj runtime.Object) (objLabels, objFields labels.Set, err error) {
115	event, ok := obj.(*api.Event)
116	if !ok {
示例3:
client.go开发语言: Go项目名称: kubernetes代码行数: 349
77type EventInterface interface {
78	CreateEvent(event *api.Event) (*api.Event, error)
79	ListEvents(selector labels.Selector) (*api.EventList, error)
80	GetEvent(id string) (*api.Event, error)
81	WatchEvents(label, field labels.Selector, resourceVersion string) (watch.Interface, error)
313// CreateEvent makes a new event. Returns the copy of the event the server returns, or an error.
314func (c *Client) CreateEvent(event *api.Event) (*api.Event, error) {
315	result := &api.Event{}
320// ListEvents returns a list of events matching the selectors.
321func (c *Client) ListEvents(label, field labels.Selector) (*api.EventList, error) {
322	result := &api.EventList{}
332// GetEvent returns the given event, or an error.
333func (c *Client) GetEvent(id string) (*api.Event, error) {
334	result := &api.Event{}
示例4:
kubelet_test.go开发语言: Go项目名称: kubernetes代码行数: 866
543	}
544	expectedEvent := api.Event{
545		Event: "test",
556	expectNoError(t, err)
557	var event api.Event
558	err = json.Unmarshal([]byte(response.Node.Value), &event)
571	fakeEtcd.Err = fmt.Errorf("Test error")
572	err := kubelet.LogEvent(&api.Event{
573		Event: "test",
示例5:
kubelet_test.go开发语言: Go项目名称: kubernetes代码行数: 883
560	}
561	expectedEvent := api.Event{
562		Event: "test",
573	expectNoError(t, err)
574	var event api.Event
575	err = json.Unmarshal([]byte(response.Node.Value), &event)
588	fakeEtcd.Err = fmt.Errorf("test error")
589	err := kubelet.LogEvent(&api.Event{
590		Event: "test",
示例6:
kubelet_test.go开发语言: Go项目名称: kubernetes代码行数: 915
560	}
561	expectedEvent := api.Event{
562		Event: "test",
573	expectNoError(t, err)
574	var event api.Event
575	err = json.Unmarshal([]byte(response.Node.Value), &event)
588	fakeEtcd.Err = fmt.Errorf("test error")
589	err := kubelet.LogEvent(&api.Event{
590		Event: "test",
示例7:
rest_test.go开发语言: Go项目名称: kubernetes代码行数: 277
40
41func testEvent(name string) *api.Event {
42	return &api.Event{
56		ctx   api.Context
57		event *api.Event
58		valid bool
162	_, rest := NewTestREST()
163	eventA := &api.Event{
164		InvolvedObject: api.ObjectReference{
173		Reason: "ForTesting",
174		Source: api.EventSource{Component: "test"},
175	}
200	reg, rest := NewTestREST()
201	eventA := &api.Event{
202		InvolvedObject: api.ObjectReference{
示例8:
resource_printer.go开发语言: Go项目名称: kubernetes代码行数: 688
458
459func printEvent(event *api.Event, w io.Writer) error {
460	_, err := fmt.Fprintf(
475// Sorts and prints the EventList in a human-friendly format.
476func printEventList(list *api.EventList, w io.Writer) error {
477	sort.Sort(SortableEvents(list.Items))
示例9:
events.go开发语言: Go项目名称: kubernetes代码行数: 164
36	Create(event *api.Event) (*api.Event, error)
37	Update(event *api.Event) (*api.Event, error)
38	List(label, field labels.Selector) (*api.EventList, error)
39	Get(name string) (*api.Event, error)
40	Watch(label, field labels.Selector, resourceVersion string) (watch.Interface, error)
41	// Search finds events about the specified object
42	Search(objOrRef runtime.Object) (*api.EventList, error)
43}
62// client must have been created with the "" namespace.
63func (e *events) Create(event *api.Event) (*api.Event, error) {
64	if e.namespace != "" && event.Namespace != e.namespace {
81// object.
82func (e *events) Update(event *api.Event) (*api.Event, error) {
83	if len(event.ResourceVersion) == 0 {
示例10:
event.go开发语言: Go项目名称: kubernetes代码行数: 205
42type EventRecorder interface {
43	Create(event *api.Event) (*api.Event, error)
44	Update(event *api.Event) (*api.Event, error)
50// TODO: make me an object with parameterizable queue length and retry interval
51func StartRecording(recorder EventRecorder, source api.EventSource) watch.Interface {
52	// The default math/rand package functions aren't thread safe, so create a
54	randGen := rand.New(rand.NewSource(time.Now().UnixNano()))
55	return GetEvents(func(event *api.Event) {
56		// Make a copy before modification, because there could be multiple listeners.
95// existing event.
96func recordEvent(recorder EventRecorder, event *api.Event, updateExistingEvent bool) bool {
97	var newEvent *api.Event
135func StartLogging(logf func(format string, args ...interface{})) watch.Interface {
136	return GetEvents(func(e *api.Event) {
137		logf("Event(%#v): reason: '%v' %v", e.InvolvedObject, e.Reason, e.Message)

本文地址:https://www.itbaoku.cn/snippets/415650.html