From 236899069c6f7d7bd857b9deac1197143ec99862 Mon Sep 17 00:00:00 2001 From: Kazuyoshi Kato Date: Fri, 21 May 2021 17:12:43 -0700 Subject: [PATCH] Make the example command buildable on macOS Signed-off-by: Kazuyoshi Kato --- example/cmd/handshaker_linux.go | 23 +++++++++++++++++++++++ example/cmd/handshaker_other.go | 25 +++++++++++++++++++++++++ example/cmd/main.go | 2 +- 3 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 example/cmd/handshaker_linux.go create mode 100644 example/cmd/handshaker_other.go diff --git a/example/cmd/handshaker_linux.go b/example/cmd/handshaker_linux.go new file mode 100644 index 000000000..67b415f4a --- /dev/null +++ b/example/cmd/handshaker_linux.go @@ -0,0 +1,23 @@ +/* + Copyright The containerd Authors. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package main + +import ttrpc "github.com/containerd/ttrpc" + +func defaultHandshaker() ttrpc.Handshaker { + return ttrpc.UnixSocketRequireSameUser() +} diff --git a/example/cmd/handshaker_other.go b/example/cmd/handshaker_other.go new file mode 100644 index 000000000..5ea1a90ea --- /dev/null +++ b/example/cmd/handshaker_other.go @@ -0,0 +1,25 @@ +// +build !linux + +/* + Copyright The containerd Authors. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package main + +import ttrpc "github.com/containerd/ttrpc" + +func defaultHandshaker() ttrpc.Handshaker { + return nil +} diff --git a/example/cmd/main.go b/example/cmd/main.go index f1f43ab70..da924ebd3 100644 --- a/example/cmd/main.go +++ b/example/cmd/main.go @@ -73,7 +73,7 @@ func dumpMetadata(ctx context.Context) { func server() error { s, err := ttrpc.NewServer( - ttrpc.WithServerHandshaker(ttrpc.UnixSocketRequireSameUser()), + ttrpc.WithServerHandshaker(defaultHandshaker()), ttrpc.WithUnaryServerInterceptor(serverIntercept), ) if err != nil {