Documentation ¶
Overview ¶
Package api provides the core business logic for func.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type API ¶
type API interface {
Apply(ctx context.Context, req *ApplyRequest) (*ApplyResponse, error)
}
API is the common interface for the target func api.
type ApplyRequest ¶
type ApplyRequest struct { // Project is the project to apply changes to. Project string // Config is the configuration to apply. Config hcl.Body }
An ApplyRequest is the request to pass to Apply().
type ApplyResponse ¶
type ApplyResponse struct { // SourcesRequired is set if source code uploads are required. SourcesRequired []*SourceRequest }
ApplyResponse is returned from applying resources.
The response may contain an UploadRequest, in which case the apply is rejected due to missing source code. The source code should be uploaded and then Apply should be retried.
type Client ¶
type Client struct { API API Logger *zap.Logger Source SourceProvider }
Client is a func api client.
type Error ¶
type Error struct { Code ErrorCode Message string Diagnostics hcl.Diagnostics }
An Error is a known error returned from the API.
type ErrorCode ¶
type ErrorCode string
An ErrorCode indicates the type of error that occurred.
const ( ValidationError ErrorCode = "validation" )
Valid error codes:
type Reconciler ¶
type Reconciler interface {
Reconcile(ctx context.Context, id, project string, graph reconciler.Graph) error
}
A Reconciler reconciles changes to the graph.
type Server ¶
type Server struct { Logger *zap.Logger Registry Registry Source source.Storage Storage Storage Validator Validator // If set, reconciliation is done synchronously. Reconciler Reconciler }
Server provides the serverside api implementation.
func (*Server) Apply ¶
func (s *Server) Apply(ctx context.Context, req *ApplyRequest) (*ApplyResponse, error)
Apply applies resource changes.
If any resources require source code, the response will contain source requests. Once the sources have been uploaded, Apply should be retried.
The returned error is always of type *Error.
type SourceProvider ¶
SourceProvider provides source code for upload.
type SourceRequest ¶
type SourceRequest struct { // Key is the key of the source code to upload. // The digest maps back to a resource in the ApplyRequest config. Key string // Url is the destination URL to upload to. // The request should be done as a HTTP PUT. URL string // Headers include the additional headers that must be set on the upload. Headers map[string]string }
An SourceRequest describes a single upload request.