Make the example command buildable on macOS

Signed-off-by: Kazuyoshi Kato <katokazu@amazon.com>
This commit is contained in:
Kazuyoshi Kato 2021-05-21 17:12:43 -07:00
parent 616d54c531
commit 236899069c
3 changed files with 49 additions and 1 deletions

View File

@ -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()
}

View File

@ -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
}

View File

@ -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 {