github.com/containerd/Containerd@v1.4.13/services/version/service.go (about) 1 /* 2 Copyright The containerd Authors. 3 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10 Unless required by applicable law or agreed to in writing, software 11 distributed under the License is distributed on an "AS IS" BASIS, 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 See the License for the specific language governing permissions and 14 limitations under the License. 15 */ 16 17 package version 18 19 import ( 20 "context" 21 22 api "github.com/containerd/containerd/api/services/version/v1" 23 "github.com/containerd/containerd/plugin" 24 ctrdversion "github.com/containerd/containerd/version" 25 ptypes "github.com/gogo/protobuf/types" 26 "google.golang.org/grpc" 27 ) 28 29 var _ api.VersionServer = &service{} 30 31 func init() { 32 plugin.Register(&plugin.Registration{ 33 Type: plugin.GRPCPlugin, 34 ID: "version", 35 InitFn: initFunc, 36 }) 37 } 38 39 func initFunc(ic *plugin.InitContext) (interface{}, error) { 40 return &service{}, nil 41 } 42 43 type service struct { 44 } 45 46 func (s *service) Register(server *grpc.Server) error { 47 api.RegisterVersionServer(server, s) 48 return nil 49 } 50 51 func (s *service) Version(ctx context.Context, _ *ptypes.Empty) (*api.VersionResponse, error) { 52 return &api.VersionResponse{ 53 Version: ctrdversion.Version, 54 Revision: ctrdversion.Revision, 55 }, nil 56 }