grpc2rest

package
v0.0.0-...-860b3a7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 8, 2025 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Overview

grpc2rest contains methods for converting Kubernetes-style REST to gRPC.

It contains a Method class that has all request-time information, and a ResourceInfoRepository class responsible for creating Method instances.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Method

type Method interface {
	// GetInputMessage returns the proto message for gRPC input.
	// e.g. GetHelloWorldRequest for K8sHelloWorld.Get.
	GetInputMessage() proto.Message
	// GetOutputMessage returns the proto message for gRPC output.
	// e.g. HelloWorld for K8sHelloWorld.Get.
	GetOutputMessage() proto.Message
	// BuildKubernetesRequest builds a HTTP request for the gRPC input.
	// Must be passed a message generated by GetInputMessage.
	BuildKubernetesRequest(proto.Message) (Request, error)
	// IsWatchCall returns true if the call is a Kubernetes Watch call.
	// Watch calls must be read with Stream() instead of DoRaw() and may
	// return objects that can't be parsed by GetOutputMessage().
	IsWatchCall() bool
}

Method abstracts the semantics of a Kubernetes gRPC method.

type Request

type Request interface {
	// DoRaw returns a body with a single JSON message of the message's
	// GetOutputMessage() type on success. On error, body may contain JSON
	// with an instance of k8s.io/apimachinery/pkg/apis/meta/v1.Status.
	DoRaw(context.Context) ([]byte, error)
	// Stream returns a stream with JSON messages. Each message is a
	// k8s.io/apimachinery/pkg/apis/meta/v1.WatchEvent instance. The object
	// in the WatchEvent may either be a regular object (in which case the
	// GetOutputMessage() can parse the entire JSON), or an meta/v1.Status.
	Stream(context.Context) (io.ReadCloser, error)
}

Request is an interface for the subset of k8s.io/client-go/rest.Request that this code uses. The semantics are the same as rest.Request and repeated below because rest.Request is poorly documented.

type ResourceInfoRepository

type ResourceInfoRepository struct {
	// contains filtered or unexported fields
}

func NewResourceInfoRepository

func NewResourceInfoRepository(config *rest.Config) *ResourceInfoRepository

func (*ResourceInfoRepository) GetMethod

func (r *ResourceInfoRepository) GetMethod(fullMethodName string) (Method, error)

func (*ResourceInfoRepository) Update

func (r *ResourceInfoRepository) Update(done <-chan struct{}, clientset crdclientset.Interface) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL