Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed shim publisher dependence on global flag/setting #1343

Merged
merged 1 commit into from
Apr 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions cmd/containerd-shim-runhcs-v1/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,19 @@ type publisher interface {
}

type eventPublisher struct {
namespace string
remotePublisher *shim.RemoteEventsPublisher
}

var _ = (publisher)(&eventPublisher{})
var _ publisher = &eventPublisher{}

func newEventPublisher(address string) (*eventPublisher, error) {
func newEventPublisher(address, namespace string) (*eventPublisher, error) {
p, err := shim.NewPublisher(address)
if err != nil {
return nil, err
}
return &eventPublisher{
namespace: namespace,
remotePublisher: p,
}, nil
}
Expand All @@ -46,5 +48,5 @@ func (e *eventPublisher) publishEvent(ctx context.Context, topic string, event i
return nil
}

return e.remotePublisher.Publish(namespaces.WithNamespace(ctx, namespaceFlag), topic, event)
return e.remotePublisher.Publish(namespaces.WithNamespace(ctx, e.namespace), topic, event)
}
2 changes: 1 addition & 1 deletion cmd/containerd-shim-runhcs-v1/events_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ type fakePublisher struct {
events []interface{}
}

var _ = (publisher)(&fakePublisher{})
var _ publisher = &fakePublisher{}

func newFakePublisher() *fakePublisher {
return &fakePublisher{}
Expand Down
4 changes: 3 additions & 1 deletion cmd/containerd-shim-runhcs-v1/serve.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build windows

package main

import (
Expand Down Expand Up @@ -175,7 +177,7 @@ var serveCommand = cli.Command{
}

ttrpcAddress := os.Getenv(ttrpcAddressEnv)
ttrpcEventPublisher, err := newEventPublisher(ttrpcAddress)
ttrpcEventPublisher, err := newEventPublisher(ttrpcAddress, namespaceFlag)
if err != nil {
return err
}
Expand Down