Documentation ¶
Overview ¶
Package gomote contains all of the necessary components to implement and use the gomote functionality. Gomotes are instances which are dedicated to an individual user or service.
Index ¶
- type BuildersClient
- type Server
- func (s *Server) AddBootstrap(ctx context.Context, req *protos.AddBootstrapRequest) (*protos.AddBootstrapResponse, error)
- func (s *Server) Authenticate(ctx context.Context, req *protos.AuthenticateRequest) (*protos.AuthenticateResponse, error)
- func (s *Server) CreateInstance(req *protos.CreateInstanceRequest, ...) error
- func (s *Server) DestroyInstance(ctx context.Context, req *protos.DestroyInstanceRequest) (*protos.DestroyInstanceResponse, error)
- func (s *Server) ExecuteCommand(req *protos.ExecuteCommandRequest, ...) error
- func (s *Server) InstanceAlive(ctx context.Context, req *protos.InstanceAliveRequest) (*protos.InstanceAliveResponse, error)
- func (s *Server) ListDirectory(ctx context.Context, req *protos.ListDirectoryRequest) (*protos.ListDirectoryResponse, error)
- func (s *Server) ListDirectoryStreaming(req *protos.ListDirectoryRequest, ...) error
- func (s *Server) ListInstances(ctx context.Context, req *protos.ListInstancesRequest) (*protos.ListInstancesResponse, error)
- func (s *Server) ReadTGZToURL(ctx context.Context, req *protos.ReadTGZToURLRequest) (*protos.ReadTGZToURLResponse, error)
- func (s *Server) RemoveFiles(ctx context.Context, req *protos.RemoveFilesRequest) (*protos.RemoveFilesResponse, error)
- func (s *Server) SignSSHKey(ctx context.Context, req *protos.SignSSHKeyRequest) (*protos.SignSSHKeyResponse, error)
- func (s *Server) UploadFile(ctx context.Context, req *protos.UploadFileRequest) (*protos.UploadFileResponse, error)
- func (s *Server) WriteFileFromURL(ctx context.Context, req *protos.WriteFileFromURLRequest) (*protos.WriteFileFromURLResponse, error)
- func (s *Server) WriteTGZFromURL(ctx context.Context, req *protos.WriteTGZFromURLRequest) (*protos.WriteTGZFromURLResponse, error)
- type SwarmOpts
- type SwarmingServer
- func (ss *SwarmingServer) AddBootstrap(ctx context.Context, req *protos.AddBootstrapRequest) (*protos.AddBootstrapResponse, error)
- func (ss *SwarmingServer) Authenticate(ctx context.Context, req *protos.AuthenticateRequest) (*protos.AuthenticateResponse, error)
- func (ss *SwarmingServer) CreateInstance(req *protos.CreateInstanceRequest, ...) error
- func (ss *SwarmingServer) DestroyInstance(ctx context.Context, req *protos.DestroyInstanceRequest) (*protos.DestroyInstanceResponse, error)
- func (ss *SwarmingServer) ExecuteCommand(req *protos.ExecuteCommandRequest, ...) error
- func (ss *SwarmingServer) InstanceAlive(ctx context.Context, req *protos.InstanceAliveRequest) (*protos.InstanceAliveResponse, error)
- func (ss *SwarmingServer) ListDirectory(ctx context.Context, req *protos.ListDirectoryRequest) (*protos.ListDirectoryResponse, error)
- func (ss *SwarmingServer) ListDirectoryStreaming(req *protos.ListDirectoryRequest, ...) error
- func (ss *SwarmingServer) ListInstances(ctx context.Context, req *protos.ListInstancesRequest) (*protos.ListInstancesResponse, error)
- func (ss *SwarmingServer) ListSwarmingBuilders(ctx context.Context, req *protos.ListSwarmingBuildersRequest) (*protos.ListSwarmingBuildersResponse, error)
- func (ss *SwarmingServer) ReadTGZToURL(ctx context.Context, req *protos.ReadTGZToURLRequest) (*protos.ReadTGZToURLResponse, error)
- func (ss *SwarmingServer) RemoveFiles(ctx context.Context, req *protos.RemoveFilesRequest) (*protos.RemoveFilesResponse, error)
- func (ss *SwarmingServer) SignSSHKey(ctx context.Context, req *protos.SignSSHKeyRequest) (*protos.SignSSHKeyResponse, error)
- func (ss *SwarmingServer) UploadFile(ctx context.Context, req *protos.UploadFileRequest) (*protos.UploadFileResponse, error)
- func (ss *SwarmingServer) WriteFileFromURL(ctx context.Context, req *protos.WriteFileFromURLRequest) (*protos.WriteFileFromURLResponse, error)
- func (ss *SwarmingServer) WriteTGZFromURL(ctx context.Context, req *protos.WriteTGZFromURLRequest) (*protos.WriteTGZFromURLResponse, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BuildersClient ¶
type BuildersClient interface { GetBuilder(ctx context.Context, in *buildbucketpb.GetBuilderRequest, opts ...grpc.CallOption) (*buildbucketpb.BuilderItem, error) ListBuilders(ctx context.Context, in *buildbucketpb.ListBuildersRequest, opts ...grpc.CallOption) (*buildbucketpb.ListBuildersResponse, error) }
BuildersClient is a partial interface of the buildbuicketpb.BuildersClient interface.
type Server ¶
type Server struct { // embed the unimplemented server. protos.UnimplementedGomoteServiceServer // contains filtered or unexported fields }
Server is a gomote server implementation.
func New ¶
func New(rsp *remote.SessionPool, sched *schedule.Scheduler, rawCAPriKey []byte, gomoteGCSBucket string, storageClient *storage.Client) *Server
New creates a gomote server. If the rawCAPriKey is invalid, the program will exit.
func (*Server) AddBootstrap ¶
func (s *Server) AddBootstrap(ctx context.Context, req *protos.AddBootstrapRequest) (*protos.AddBootstrapResponse, error)
AddBootstrap adds the bootstrap version of Go to an instance and returns the URL for the bootstrap version. If no bootstrap version is defined then the returned version URL will be empty.
func (*Server) Authenticate ¶
func (s *Server) Authenticate(ctx context.Context, req *protos.AuthenticateRequest) (*protos.AuthenticateResponse, error)
Authenticate will allow the caller to verify that they are properly authenticated and authorized to interact with the Service.
func (*Server) CreateInstance ¶
func (s *Server) CreateInstance(req *protos.CreateInstanceRequest, stream protos.GomoteService_CreateInstanceServer) error
CreateInstance will create a gomote instance for the authenticated user.
func (*Server) DestroyInstance ¶
func (s *Server) DestroyInstance(ctx context.Context, req *protos.DestroyInstanceRequest) (*protos.DestroyInstanceResponse, error)
DestroyInstance will destroy a gomote instance. It will ensure that the caller is authenticated and is the owner of the instance before it destroys the instance.
func (*Server) ExecuteCommand ¶
func (s *Server) ExecuteCommand(req *protos.ExecuteCommandRequest, stream protos.GomoteService_ExecuteCommandServer) error
ExecuteCommand will execute a command on a gomote instance. The output from the command will be streamed back to the caller if the output is set.
func (*Server) InstanceAlive ¶
func (s *Server) InstanceAlive(ctx context.Context, req *protos.InstanceAliveRequest) (*protos.InstanceAliveResponse, error)
InstanceAlive will ensure that the gomote instance is still alive and will extend the timeout. The requester must be authenticated.
func (*Server) ListDirectory ¶
func (s *Server) ListDirectory(ctx context.Context, req *protos.ListDirectoryRequest) (*protos.ListDirectoryResponse, error)
ListDirectory lists the contents of the directory on a gomote instance.
func (*Server) ListDirectoryStreaming ¶
func (s *Server) ListDirectoryStreaming(req *protos.ListDirectoryRequest, stream grpc.ServerStreamingServer[protos.ListDirectoryResponse]) error
ListDirectoryStreaming lists the contents of the directory on a gomote instance.
func (*Server) ListInstances ¶
func (s *Server) ListInstances(ctx context.Context, req *protos.ListInstancesRequest) (*protos.ListInstancesResponse, error)
ListInstances will list the gomote instances owned by the requester. The requester must be authenticated.
func (*Server) ReadTGZToURL ¶
func (s *Server) ReadTGZToURL(ctx context.Context, req *protos.ReadTGZToURLRequest) (*protos.ReadTGZToURLResponse, error)
ReadTGZToURL retrieves a directory from the gomote instance and writes the file to GCS. It returns a signed URL which the caller uses to read the file from GCS.
func (*Server) RemoveFiles ¶
func (s *Server) RemoveFiles(ctx context.Context, req *protos.RemoveFilesRequest) (*protos.RemoveFilesResponse, error)
RemoveFiles removes files or directories from the gomote instance.
func (*Server) SignSSHKey ¶
func (s *Server) SignSSHKey(ctx context.Context, req *protos.SignSSHKeyRequest) (*protos.SignSSHKeyResponse, error)
SignSSHKey signs the public SSH key with a certificate. The signed public SSH key is intended for use with the gomote service SSH server. It will be signed by the certificate authority of the server and will restrict access to the gomote instance that it was signed for.
func (*Server) UploadFile ¶
func (s *Server) UploadFile(ctx context.Context, req *protos.UploadFileRequest) (*protos.UploadFileResponse, error)
UploadFile creates a URL and a set of HTTP post fields which are used to upload a file to a staging GCS bucket. Uploaded files are made available to the gomote instances via a subsequent call to one of the WriteFromURL endpoints.
func (*Server) WriteFileFromURL ¶
func (s *Server) WriteFileFromURL(ctx context.Context, req *protos.WriteFileFromURLRequest) (*protos.WriteFileFromURLResponse, error)
WriteFileFromURL initiates an HTTP request to the passed in URL and streams the contents of the request to the gomote instance.
func (*Server) WriteTGZFromURL ¶
func (s *Server) WriteTGZFromURL(ctx context.Context, req *protos.WriteTGZFromURLRequest) (*protos.WriteTGZFromURLResponse, error)
WriteTGZFromURL will instruct the gomote instance to download the tar.gz from the provided URL. The tar.gz file will be unpacked in the work directory relative to the directory provided.
type SwarmOpts ¶
type SwarmOpts struct { // OnInstanceRequested optionally specifies a hook to run synchronously // after the computeService.Instances.Insert call, but before // waiting for its operation to proceed. OnInstanceRequested func() // OnInstanceCreated optionally specifies a hook to run synchronously // after the instance operation succeeds. OnInstanceCreated func() // OnInstanceRegistration optionally specifies a hook to run synchronously // after the instance has been registered in rendezvous. OnInstanceRegistration func() }
SwarmOpts provides additional options for swarming task creation.
type SwarmingServer ¶
type SwarmingServer struct { // embed the unimplemented server. protos.UnimplementedGomoteServiceServer // contains filtered or unexported fields }
SwarmingServer is a gomote server implementation which supports LUCI swarming bots.
func NewSwarming ¶
func NewSwarming(rsp *remote.SessionPool, rawCAPriKey []byte, gomoteGCSBucket string, storageClient *storage.Client, rdv *rendezvous.Rendezvous, swarmClient swarming.Client, buildersClient buildbucketpb.BuildersClient) (*SwarmingServer, error)
NewSwarming creates a gomote server. If the rawCAPriKey is invalid, the program will exit.
func (*SwarmingServer) AddBootstrap ¶
func (ss *SwarmingServer) AddBootstrap(ctx context.Context, req *protos.AddBootstrapRequest) (*protos.AddBootstrapResponse, error)
AddBootstrap adds the bootstrap version of Go to an instance and returns the URL for the bootstrap version. If no bootstrap version is defined then the returned version URL will be empty.
func (*SwarmingServer) Authenticate ¶
func (ss *SwarmingServer) Authenticate(ctx context.Context, req *protos.AuthenticateRequest) (*protos.AuthenticateResponse, error)
Authenticate will allow the caller to verify that they are properly authenticated and authorized to interact with the Service.
func (*SwarmingServer) CreateInstance ¶
func (ss *SwarmingServer) CreateInstance(req *protos.CreateInstanceRequest, stream protos.GomoteService_CreateInstanceServer) error
CreateInstance will create a gomote instance within a swarming task for the authenticated user.
func (*SwarmingServer) DestroyInstance ¶
func (ss *SwarmingServer) DestroyInstance(ctx context.Context, req *protos.DestroyInstanceRequest) (*protos.DestroyInstanceResponse, error)
DestroyInstance will destroy a gomote instance. It will ensure that the caller is authenticated and is the owner of the instance before it destroys the instance.
func (*SwarmingServer) ExecuteCommand ¶
func (ss *SwarmingServer) ExecuteCommand(req *protos.ExecuteCommandRequest, stream protos.GomoteService_ExecuteCommandServer) error
ExecuteCommand will execute a command on a gomote instance. The output from the command will be streamed back to the caller if the output is set.
func (*SwarmingServer) InstanceAlive ¶
func (ss *SwarmingServer) InstanceAlive(ctx context.Context, req *protos.InstanceAliveRequest) (*protos.InstanceAliveResponse, error)
InstanceAlive will ensure that the gomote instance is still alive and will extend the timeout. The requester must be authenticated.
func (*SwarmingServer) ListDirectory ¶
func (ss *SwarmingServer) ListDirectory(ctx context.Context, req *protos.ListDirectoryRequest) (*protos.ListDirectoryResponse, error)
ListDirectory lists the contents of the directory on a gomote instance.
func (*SwarmingServer) ListDirectoryStreaming ¶
func (ss *SwarmingServer) ListDirectoryStreaming(req *protos.ListDirectoryRequest, stream grpc.ServerStreamingServer[protos.ListDirectoryResponse]) error
ListDirectoryStreaming lists the contents of the directory on a gomote instance.
func (*SwarmingServer) ListInstances ¶
func (ss *SwarmingServer) ListInstances(ctx context.Context, req *protos.ListInstancesRequest) (*protos.ListInstancesResponse, error)
ListInstances will list the gomote instances owned by the requester. The requester must be authenticated.
func (*SwarmingServer) ListSwarmingBuilders ¶
func (ss *SwarmingServer) ListSwarmingBuilders(ctx context.Context, req *protos.ListSwarmingBuildersRequest) (*protos.ListSwarmingBuildersResponse, error)
ListSwarmingBuilders lists all of the swarming builders which run for the Go master or release branches. The requester must be authenticated.
func (*SwarmingServer) ReadTGZToURL ¶
func (ss *SwarmingServer) ReadTGZToURL(ctx context.Context, req *protos.ReadTGZToURLRequest) (*protos.ReadTGZToURLResponse, error)
ReadTGZToURL retrieves a directory from the gomote instance and writes the file to GCS. It returns a signed URL which the caller uses to read the file from GCS.
func (*SwarmingServer) RemoveFiles ¶
func (ss *SwarmingServer) RemoveFiles(ctx context.Context, req *protos.RemoveFilesRequest) (*protos.RemoveFilesResponse, error)
RemoveFiles removes files or directories from the gomote instance.
func (*SwarmingServer) SignSSHKey ¶
func (ss *SwarmingServer) SignSSHKey(ctx context.Context, req *protos.SignSSHKeyRequest) (*protos.SignSSHKeyResponse, error)
SignSSHKey signs the public SSH key with a certificate. The signed public SSH key is intended for use with the gomote service SSH server. It will be signed by the certificate authority of the server and will restrict access to the gomote instance that it was signed for.
func (*SwarmingServer) UploadFile ¶
func (ss *SwarmingServer) UploadFile(ctx context.Context, req *protos.UploadFileRequest) (*protos.UploadFileResponse, error)
UploadFile creates a URL and a set of HTTP post fields which are used to upload a file to a staging GCS bucket. Uploaded files are made available to the gomote instances via a subsequent call to one of the WriteFromURL endpoints.
func (*SwarmingServer) WriteFileFromURL ¶
func (ss *SwarmingServer) WriteFileFromURL(ctx context.Context, req *protos.WriteFileFromURLRequest) (*protos.WriteFileFromURLResponse, error)
WriteFileFromURL initiates an HTTP request to the passed in URL and streams the contents of the request to the gomote instance.
func (*SwarmingServer) WriteTGZFromURL ¶
func (ss *SwarmingServer) WriteTGZFromURL(ctx context.Context, req *protos.WriteTGZFromURLRequest) (*protos.WriteTGZFromURLResponse, error)
WriteTGZFromURL will instruct the gomote instance to download the tar.gz from the provided URL. The tar.gz file will be unpacked in the work directory relative to the directory provided.