NewRuntimeService creates a legacy-style CRI runtime client backed by the upstream Kubernetes CRI client.
(endpoint string, connectionTimeout time.Duration)
| 59 | // NewRuntimeService creates a legacy-style CRI runtime client backed by the |
| 60 | // upstream Kubernetes CRI client. |
| 61 | func NewRuntimeService(endpoint string, connectionTimeout time.Duration) (*RuntimeService, error) { |
| 62 | runtimeService, err := upstreamcri.NewRemoteRuntimeService(context.Background(), endpoint, connectionTimeout, nil, false) |
| 63 | if err != nil { |
| 64 | return nil, err |
| 65 | } |
| 66 | |
| 67 | runtimeConn, err := newRuntimeClientConn(endpoint) |
| 68 | if err != nil { |
| 69 | _ = runtimeService.Close(context.Background()) |
| 70 | return nil, err |
| 71 | } |
| 72 | |
| 73 | return &RuntimeService{ |
| 74 | runtimeService: runtimeService, |
| 75 | runtimeClient: runtimeapi.NewRuntimeServiceClient(runtimeConn), |
| 76 | runtimeConn: runtimeConn, |
| 77 | }, nil |
| 78 | } |
| 79 | |
| 80 | func newRuntimeClientConn(endpoint string) (*grpc.ClientConn, error) { |
| 81 | addr, dialer, err := criutil.GetAddressAndDialer(endpoint) |
searching dependent graphs…