template

package
v0.0.0-...-1c296c3 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2021 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Overview

Package template is a reverse proxy.

It translates gRPC into RESTful JSON APIs.

Index

Constants

This section is empty.

Variables

View Source
var File_template_template_proto protoreflect.FileDescriptor

Functions

func RegisterTemplateServiceHandler

func RegisterTemplateServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error

RegisterTemplateServiceHandler registers the http handlers for service TemplateService to "mux". The handlers forward requests to the grpc endpoint over "conn".

func RegisterTemplateServiceHandlerClient

func RegisterTemplateServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client TemplateServiceClient) error

RegisterTemplateServiceHandlerClient registers the http handlers for service TemplateService to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "TemplateServiceClient". Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "TemplateServiceClient" doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in "TemplateServiceClient" to call the correct interceptors.

func RegisterTemplateServiceHandlerFromEndpoint

func RegisterTemplateServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error)

RegisterTemplateServiceHandlerFromEndpoint is same as RegisterTemplateServiceHandler but automatically dials to "endpoint" and closes the connection when "ctx" gets done.

func RegisterTemplateServiceHandlerServer

func RegisterTemplateServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server TemplateServiceServer) error

RegisterTemplateServiceHandlerServer registers the http handlers for service TemplateService to "mux". UnaryRPC :call TemplateServiceServer directly. StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterTemplateServiceHandlerFromEndpoint instead.

func RegisterTemplateServiceServer

func RegisterTemplateServiceServer(s *grpc.Server, srv TemplateServiceServer)

Types

type CreateResponse

type CreateResponse struct {
	Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
	// contains filtered or unexported fields
}

CreateResponse returns the ID of the created template

func (*CreateResponse) Descriptor deprecated

func (*CreateResponse) Descriptor() ([]byte, []int)

Deprecated: Use CreateResponse.ProtoReflect.Descriptor instead.

func (*CreateResponse) GetId

func (x *CreateResponse) GetId() string

func (*CreateResponse) ProtoMessage

func (*CreateResponse) ProtoMessage()

func (*CreateResponse) ProtoReflect

func (x *CreateResponse) ProtoReflect() protoreflect.Message

func (*CreateResponse) Reset

func (x *CreateResponse) Reset()

func (*CreateResponse) String

func (x *CreateResponse) String() string

type Empty

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

Empty represents an empty response

func (*Empty) Descriptor deprecated

func (*Empty) Descriptor() ([]byte, []int)

Deprecated: Use Empty.ProtoReflect.Descriptor instead.

func (*Empty) ProtoMessage

func (*Empty) ProtoMessage()

func (*Empty) ProtoReflect

func (x *Empty) ProtoReflect() protoreflect.Message

func (*Empty) Reset

func (x *Empty) Reset()

func (*Empty) String

func (x *Empty) String() string

type GetRequest

type GetRequest struct {

	// Types that are assignable to GetBy:
	//	*GetRequest_Id
	//	*GetRequest_Name
	GetBy isGetRequest_GetBy `protobuf_oneof:"get_by"`
	// contains filtered or unexported fields
}

GetRequest enables you to filter templates by name or id.

func (*GetRequest) Descriptor deprecated

func (*GetRequest) Descriptor() ([]byte, []int)

Deprecated: Use GetRequest.ProtoReflect.Descriptor instead.

func (*GetRequest) GetGetBy

func (m *GetRequest) GetGetBy() isGetRequest_GetBy

func (*GetRequest) GetId

func (x *GetRequest) GetId() string

func (*GetRequest) GetName

func (x *GetRequest) GetName() string

func (*GetRequest) ProtoMessage

func (*GetRequest) ProtoMessage()

func (*GetRequest) ProtoReflect

func (x *GetRequest) ProtoReflect() protoreflect.Message

func (*GetRequest) Reset

func (x *GetRequest) Reset()

func (*GetRequest) String

func (x *GetRequest) String() string

type GetRequest_Id

type GetRequest_Id struct {
	//
	// Filter by the template id
	Id string `protobuf:"bytes,1,opt,name=id,proto3,oneof"`
}

type GetRequest_Name

type GetRequest_Name struct {
	//
	// Filter by the template name
	Name string `protobuf:"bytes,2,opt,name=name,proto3,oneof"`
}

type ListRequest

type ListRequest struct {

	// Types that are assignable to FilterBy:
	//	*ListRequest_Name
	FilterBy isListRequest_FilterBy `protobuf_oneof:"filter_by"`
	// contains filtered or unexported fields
}

The request to use during a List template request

func (*ListRequest) Descriptor deprecated

func (*ListRequest) Descriptor() ([]byte, []int)

Deprecated: Use ListRequest.ProtoReflect.Descriptor instead.

func (*ListRequest) GetFilterBy

func (m *ListRequest) GetFilterBy() isListRequest_FilterBy

func (*ListRequest) GetName

func (x *ListRequest) GetName() string

func (*ListRequest) ProtoMessage

func (*ListRequest) ProtoMessage()

func (*ListRequest) ProtoReflect

func (x *ListRequest) ProtoReflect() protoreflect.Message

func (*ListRequest) Reset

func (x *ListRequest) Reset()

func (*ListRequest) String

func (x *ListRequest) String() string

type ListRequest_Name

type ListRequest_Name struct {
	//
	// Filter by the template name
	Name string `protobuf:"bytes,1,opt,name=name,proto3,oneof"`
}

type TemplateServiceClient

type TemplateServiceClient interface {
	//
	// CreateTemplate stores a template in the Tinkerbell server.
	CreateTemplate(ctx context.Context, in *WorkflowTemplate, opts ...grpc.CallOption) (*CreateResponse, error)
	//
	// GetTemplate returns a specific template via its identifier.
	GetTemplate(ctx context.Context, in *GetRequest, opts ...grpc.CallOption) (*WorkflowTemplate, error)
	//
	// DeleteTemplate deletes a template via its identifier.
	DeleteTemplate(ctx context.Context, in *GetRequest, opts ...grpc.CallOption) (*Empty, error)
	//
	// ListTemplates returns all the template stored in Tinkerbell server
	ListTemplates(ctx context.Context, in *ListRequest, opts ...grpc.CallOption) (TemplateService_ListTemplatesClient, error)
	//
	// UpdateTemplate updates a template
	// TODO: Read the code and figure out how an update work
	UpdateTemplate(ctx context.Context, in *WorkflowTemplate, opts ...grpc.CallOption) (*Empty, error)
}

TemplateServiceClient is the client API for TemplateService service.

For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.

type TemplateServiceClientMock

type TemplateServiceClientMock struct {
	// CreateTemplateFunc mocks the CreateTemplate method.
	CreateTemplateFunc func(ctx context.Context, in *WorkflowTemplate, opts ...grpc.CallOption) (*CreateResponse, error)

	// DeleteTemplateFunc mocks the DeleteTemplate method.
	DeleteTemplateFunc func(ctx context.Context, in *GetRequest, opts ...grpc.CallOption) (*Empty, error)

	// GetTemplateFunc mocks the GetTemplate method.
	GetTemplateFunc func(ctx context.Context, in *GetRequest, opts ...grpc.CallOption) (*WorkflowTemplate, error)

	// ListTemplatesFunc mocks the ListTemplates method.
	ListTemplatesFunc func(ctx context.Context, in *ListRequest, opts ...grpc.CallOption) (TemplateService_ListTemplatesClient, error)

	// UpdateTemplateFunc mocks the UpdateTemplate method.
	UpdateTemplateFunc func(ctx context.Context, in *WorkflowTemplate, opts ...grpc.CallOption) (*Empty, error)
	// contains filtered or unexported fields
}

TemplateServiceClientMock is a mock implementation of TemplateServiceClient.

    func TestSomethingThatUsesTemplateServiceClient(t *testing.T) {

        // make and configure a mocked TemplateServiceClient
        mockedTemplateServiceClient := &TemplateServiceClientMock{
            CreateTemplateFunc: func(ctx context.Context, in *WorkflowTemplate, opts ...grpc.CallOption) (*CreateResponse, error) {
	               panic("mock out the CreateTemplate method")
            },
            DeleteTemplateFunc: func(ctx context.Context, in *GetRequest, opts ...grpc.CallOption) (*Empty, error) {
	               panic("mock out the DeleteTemplate method")
            },
            GetTemplateFunc: func(ctx context.Context, in *GetRequest, opts ...grpc.CallOption) (*WorkflowTemplate, error) {
	               panic("mock out the GetTemplate method")
            },
            ListTemplatesFunc: func(ctx context.Context, in *ListRequest, opts ...grpc.CallOption) (TemplateService_ListTemplatesClient, error) {
	               panic("mock out the ListTemplates method")
            },
            UpdateTemplateFunc: func(ctx context.Context, in *WorkflowTemplate, opts ...grpc.CallOption) (*Empty, error) {
	               panic("mock out the UpdateTemplate method")
            },
        }

        // use mockedTemplateServiceClient in code that requires TemplateServiceClient
        // and then make assertions.

    }

func (*TemplateServiceClientMock) CreateTemplate

func (mock *TemplateServiceClientMock) CreateTemplate(ctx context.Context, in *WorkflowTemplate, opts ...grpc.CallOption) (*CreateResponse, error)

CreateTemplate calls CreateTemplateFunc.

func (*TemplateServiceClientMock) CreateTemplateCalls

func (mock *TemplateServiceClientMock) CreateTemplateCalls() []struct {
	Ctx  context.Context
	In   *WorkflowTemplate
	Opts []grpc.CallOption
}

CreateTemplateCalls gets all the calls that were made to CreateTemplate. Check the length with:

len(mockedTemplateServiceClient.CreateTemplateCalls())

func (*TemplateServiceClientMock) DeleteTemplate

func (mock *TemplateServiceClientMock) DeleteTemplate(ctx context.Context, in *GetRequest, opts ...grpc.CallOption) (*Empty, error)

DeleteTemplate calls DeleteTemplateFunc.

func (*TemplateServiceClientMock) DeleteTemplateCalls

func (mock *TemplateServiceClientMock) DeleteTemplateCalls() []struct {
	Ctx  context.Context
	In   *GetRequest
	Opts []grpc.CallOption
}

DeleteTemplateCalls gets all the calls that were made to DeleteTemplate. Check the length with:

len(mockedTemplateServiceClient.DeleteTemplateCalls())

func (*TemplateServiceClientMock) GetTemplate

func (mock *TemplateServiceClientMock) GetTemplate(ctx context.Context, in *GetRequest, opts ...grpc.CallOption) (*WorkflowTemplate, error)

GetTemplate calls GetTemplateFunc.

func (*TemplateServiceClientMock) GetTemplateCalls

func (mock *TemplateServiceClientMock) GetTemplateCalls() []struct {
	Ctx  context.Context
	In   *GetRequest
	Opts []grpc.CallOption
}

GetTemplateCalls gets all the calls that were made to GetTemplate. Check the length with:

len(mockedTemplateServiceClient.GetTemplateCalls())

func (*TemplateServiceClientMock) ListTemplates

ListTemplates calls ListTemplatesFunc.

func (*TemplateServiceClientMock) ListTemplatesCalls

func (mock *TemplateServiceClientMock) ListTemplatesCalls() []struct {
	Ctx  context.Context
	In   *ListRequest
	Opts []grpc.CallOption
}

ListTemplatesCalls gets all the calls that were made to ListTemplates. Check the length with:

len(mockedTemplateServiceClient.ListTemplatesCalls())

func (*TemplateServiceClientMock) UpdateTemplate

func (mock *TemplateServiceClientMock) UpdateTemplate(ctx context.Context, in *WorkflowTemplate, opts ...grpc.CallOption) (*Empty, error)

UpdateTemplate calls UpdateTemplateFunc.

func (*TemplateServiceClientMock) UpdateTemplateCalls

func (mock *TemplateServiceClientMock) UpdateTemplateCalls() []struct {
	Ctx  context.Context
	In   *WorkflowTemplate
	Opts []grpc.CallOption
}

UpdateTemplateCalls gets all the calls that were made to UpdateTemplate. Check the length with:

len(mockedTemplateServiceClient.UpdateTemplateCalls())

type TemplateServiceServer

type TemplateServiceServer interface {
	//
	// CreateTemplate stores a template in the Tinkerbell server.
	CreateTemplate(context.Context, *WorkflowTemplate) (*CreateResponse, error)
	//
	// GetTemplate returns a specific template via its identifier.
	GetTemplate(context.Context, *GetRequest) (*WorkflowTemplate, error)
	//
	// DeleteTemplate deletes a template via its identifier.
	DeleteTemplate(context.Context, *GetRequest) (*Empty, error)
	//
	// ListTemplates returns all the template stored in Tinkerbell server
	ListTemplates(*ListRequest, TemplateService_ListTemplatesServer) error
	//
	// UpdateTemplate updates a template
	// TODO: Read the code and figure out how an update work
	UpdateTemplate(context.Context, *WorkflowTemplate) (*Empty, error)
}

TemplateServiceServer is the server API for TemplateService service.

type TemplateService_ListTemplatesClient

type TemplateService_ListTemplatesClient interface {
	Recv() (*WorkflowTemplate, error)
	grpc.ClientStream
}

type TemplateService_ListTemplatesClientMock

type TemplateService_ListTemplatesClientMock struct {
	// CloseSendFunc mocks the CloseSend method.
	CloseSendFunc func() error

	// ContextFunc mocks the Context method.
	ContextFunc func() context.Context

	// HeaderFunc mocks the Header method.
	HeaderFunc func() (metadata.MD, error)

	// RecvFunc mocks the Recv method.
	RecvFunc func() (*WorkflowTemplate, error)

	// RecvMsgFunc mocks the RecvMsg method.
	RecvMsgFunc func(m interface{}) error

	// SendMsgFunc mocks the SendMsg method.
	SendMsgFunc func(m interface{}) error

	// TrailerFunc mocks the Trailer method.
	TrailerFunc func() metadata.MD
	// contains filtered or unexported fields
}

TemplateService_ListTemplatesClientMock is a mock implementation of TemplateService_ListTemplatesClient.

    func TestSomethingThatUsesTemplateService_ListTemplatesClient(t *testing.T) {

        // make and configure a mocked TemplateService_ListTemplatesClient
        mockedTemplateService_ListTemplatesClient := &TemplateService_ListTemplatesClientMock{
            CloseSendFunc: func() error {
	               panic("mock out the CloseSend method")
            },
            ContextFunc: func() context.Context {
	               panic("mock out the Context method")
            },
            HeaderFunc: func() (metadata.MD, error) {
	               panic("mock out the Header method")
            },
            RecvFunc: func() (*WorkflowTemplate, error) {
	               panic("mock out the Recv method")
            },
            RecvMsgFunc: func(m interface{}) error {
	               panic("mock out the RecvMsg method")
            },
            SendMsgFunc: func(m interface{}) error {
	               panic("mock out the SendMsg method")
            },
            TrailerFunc: func() metadata.MD {
	               panic("mock out the Trailer method")
            },
        }

        // use mockedTemplateService_ListTemplatesClient in code that requires TemplateService_ListTemplatesClient
        // and then make assertions.

    }

func (*TemplateService_ListTemplatesClientMock) CloseSend

CloseSend calls CloseSendFunc.

func (*TemplateService_ListTemplatesClientMock) CloseSendCalls

func (mock *TemplateService_ListTemplatesClientMock) CloseSendCalls() []struct {
}

CloseSendCalls gets all the calls that were made to CloseSend. Check the length with:

len(mockedTemplateService_ListTemplatesClient.CloseSendCalls())

func (*TemplateService_ListTemplatesClientMock) Context

Context calls ContextFunc.

func (*TemplateService_ListTemplatesClientMock) ContextCalls

func (mock *TemplateService_ListTemplatesClientMock) ContextCalls() []struct {
}

ContextCalls gets all the calls that were made to Context. Check the length with:

len(mockedTemplateService_ListTemplatesClient.ContextCalls())

func (*TemplateService_ListTemplatesClientMock) Header

Header calls HeaderFunc.

func (*TemplateService_ListTemplatesClientMock) HeaderCalls

func (mock *TemplateService_ListTemplatesClientMock) HeaderCalls() []struct {
}

HeaderCalls gets all the calls that were made to Header. Check the length with:

len(mockedTemplateService_ListTemplatesClient.HeaderCalls())

func (*TemplateService_ListTemplatesClientMock) Recv

Recv calls RecvFunc.

func (*TemplateService_ListTemplatesClientMock) RecvCalls

func (mock *TemplateService_ListTemplatesClientMock) RecvCalls() []struct {
}

RecvCalls gets all the calls that were made to Recv. Check the length with:

len(mockedTemplateService_ListTemplatesClient.RecvCalls())

func (*TemplateService_ListTemplatesClientMock) RecvMsg

func (mock *TemplateService_ListTemplatesClientMock) RecvMsg(m interface{}) error

RecvMsg calls RecvMsgFunc.

func (*TemplateService_ListTemplatesClientMock) RecvMsgCalls

func (mock *TemplateService_ListTemplatesClientMock) RecvMsgCalls() []struct {
	M interface{}
}

RecvMsgCalls gets all the calls that were made to RecvMsg. Check the length with:

len(mockedTemplateService_ListTemplatesClient.RecvMsgCalls())

func (*TemplateService_ListTemplatesClientMock) SendMsg

func (mock *TemplateService_ListTemplatesClientMock) SendMsg(m interface{}) error

SendMsg calls SendMsgFunc.

func (*TemplateService_ListTemplatesClientMock) SendMsgCalls

func (mock *TemplateService_ListTemplatesClientMock) SendMsgCalls() []struct {
	M interface{}
}

SendMsgCalls gets all the calls that were made to SendMsg. Check the length with:

len(mockedTemplateService_ListTemplatesClient.SendMsgCalls())

func (*TemplateService_ListTemplatesClientMock) Trailer

Trailer calls TrailerFunc.

func (*TemplateService_ListTemplatesClientMock) TrailerCalls

func (mock *TemplateService_ListTemplatesClientMock) TrailerCalls() []struct {
}

TrailerCalls gets all the calls that were made to Trailer. Check the length with:

len(mockedTemplateService_ListTemplatesClient.TrailerCalls())

type TemplateService_ListTemplatesServer

type TemplateService_ListTemplatesServer interface {
	Send(*WorkflowTemplate) error
	grpc.ServerStream
}

type UnimplementedTemplateServiceServer

type UnimplementedTemplateServiceServer struct {
}

UnimplementedTemplateServiceServer can be embedded to have forward compatible implementations.

func (*UnimplementedTemplateServiceServer) CreateTemplate

func (*UnimplementedTemplateServiceServer) DeleteTemplate

func (*UnimplementedTemplateServiceServer) GetTemplate

func (*UnimplementedTemplateServiceServer) ListTemplates

func (*UnimplementedTemplateServiceServer) UpdateTemplate

type WorkflowTemplate

type WorkflowTemplate struct {

	//
	// The template identifier
	Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
	//
	// The name of the template. You can see it as a friendly way to remember a
	// template
	Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"`
	//
	// When a template got created
	CreatedAt *timestamppb.Timestamp `protobuf:"bytes,4,opt,name=created_at,json=createdAt,proto3" json:"created_at,omitempty"`
	//
	// The last time a template was modified
	UpdatedAt *timestamppb.Timestamp `protobuf:"bytes,5,opt,name=updated_at,json=updatedAt,proto3" json:"updated_at,omitempty"`
	//
	// When a template got deleted. This is the value used to identify a deleted
	// template as well. If empty the template can be used to generate workflows.
	DeletedAt *timestamppb.Timestamp `protobuf:"bytes,6,opt,name=deleted_at,json=deletedAt,proto3" json:"deleted_at,omitempty"`
	//
	// The content of the template in its YAML representation
	Data string `protobuf:"bytes,7,opt,name=data,proto3" json:"data,omitempty"`
	// contains filtered or unexported fields
}

WorkflowTemplate describes the template itself.

func (*WorkflowTemplate) Descriptor deprecated

func (*WorkflowTemplate) Descriptor() ([]byte, []int)

Deprecated: Use WorkflowTemplate.ProtoReflect.Descriptor instead.

func (*WorkflowTemplate) GetCreatedAt

func (x *WorkflowTemplate) GetCreatedAt() *timestamppb.Timestamp

func (*WorkflowTemplate) GetData

func (x *WorkflowTemplate) GetData() string

func (*WorkflowTemplate) GetDeletedAt

func (x *WorkflowTemplate) GetDeletedAt() *timestamppb.Timestamp

func (*WorkflowTemplate) GetId

func (x *WorkflowTemplate) GetId() string

func (*WorkflowTemplate) GetName

func (x *WorkflowTemplate) GetName() string

func (*WorkflowTemplate) GetUpdatedAt

func (x *WorkflowTemplate) GetUpdatedAt() *timestamppb.Timestamp

func (*WorkflowTemplate) ProtoMessage

func (*WorkflowTemplate) ProtoMessage()

func (*WorkflowTemplate) ProtoReflect

func (x *WorkflowTemplate) ProtoReflect() protoreflect.Message

func (*WorkflowTemplate) Reset

func (x *WorkflowTemplate) Reset()

func (*WorkflowTemplate) String

func (x *WorkflowTemplate) String() string

Jump to

Keyboard shortcuts

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