Documentation
¶
Overview ¶
Package frontend builds and packages frontend project archives for upload.
Index ¶
- Constants
- func HasBuildPackage(archiveRoot, appDir string) (bool, error)
- func NormalizeAppRoot(raw string) (string, error)
- func ValidateAppRootExists(archiveRoot, appRoot string) error
- type BuildSource
- type CustomDomainChange
- type CustomDomainEntry
- type DeployedBuild
- type FoundRoute
- type LayoutFrontend
- type Mount
- type MountedBy
- type Package
- type PackageOptions
- type Route
- type RouteInput
- type RouteResult
- type RouteUpdate
- type Routes
- type Service
- func (s Service) AddDomain(ctx context.Context, identifier string, input api.FrontendDomainInput) (*apiclient.Frontend, *apiclient.FrontendCustomDomainResponse, ...)
- func (s Service) CreateCustomDomain(ctx context.Context, identifier string, input api.FrontendCustomDomainInput) (*apiclient.Frontend, *apiclient.FrontendCustomDomainResponse, ...)
- func (s Service) CreateRoute(ctx context.Context, identifier string, input RouteInput) (*apiclient.Frontend, RouteResult, error)
- func (s Service) DeleteByID(ctx context.Context, frontendID uuid.UUID) error
- func (s Service) DeleteCustomDomainByID(ctx context.Context, frontendID uuid.UUID) error
- func (s Service) DeleteDomain(ctx context.Context, frontendID uuid.UUID, domain string) error
- func (s Service) DeleteRoute(ctx context.Context, frontendID uuid.UUID, route FoundRoute) error
- func (s Service) Deploy(ctx context.Context, input api.FrontendDeployInput) (*apiclient.Frontend, error)
- func (s Service) DeployBuild(ctx context.Context, target string, source BuildSource) (*DeployedBuild, error)
- func (s Service) DeploymentLogs(ctx context.Context, frontendID, deploymentID uuid.UUID, limit int, ...) (*apiclient.LogSearchResponse, error)
- func (s Service) Get(ctx context.Context, identifier string) (*apiclient.Frontend, error)
- func (s Service) GetCustomDomain(ctx context.Context, identifier string) (*apiclient.Frontend, *apiclient.FrontendCustomDomainResponse, error)
- func (s Service) GetDomain(ctx context.Context, identifier, domain string) (*apiclient.Frontend, *apiclient.FrontendCustomDomainResponse, error)
- func (s Service) LatestDeployment(ctx context.Context, frontendID uuid.UUID) (*apiclient.FrontendDeployment, error)
- func (s Service) ListCustomDomains(ctx context.Context) ([]CustomDomainEntry, error)
- func (s Service) ListDomains(ctx context.Context, identifier string) (*apiclient.Frontend, []apiclient.FrontendCustomDomainResponse, error)
- func (s Service) ListPage(ctx context.Context, page, limit int) (*apiclient.PaginatedFrontends, error)
- func (s Service) ListRoutes(ctx context.Context, identifier string) (*apiclient.Frontend, Routes, error)
- func (s Service) MountTargets(ctx context.Context, routes []apiclient.FrontendRoute) ([]Mount, error)
- func (s Service) MountedBy(ctx context.Context, frontendID uuid.UUID) ([]MountedBy, error)
- func (s Service) Redeploy(ctx context.Context, identifier string) (*apiclient.Frontend, error)
- func (s Service) Resolve(ctx context.Context, identifier string) (*apiclient.Frontend, error)
- func (s Service) ResolveDeployment(ctx context.Context, frontendID uuid.UUID, deploymentID string) (*apiclient.FrontendDeployment, error)
- func (s Service) ResolveRoute(ctx context.Context, identifier, route string) (*apiclient.Frontend, FoundRoute, error)
- func (s Service) RouteTargets(ctx context.Context, routes []apiclient.FrontendFunctionRoute) ([]Route, error)
- func (s Service) RuntimeLogs(ctx context.Context, frontendID uuid.UUID, limit int, cursor string) (*apiclient.LogSearchResponse, error)
- func (s Service) SetDomainRedirect(ctx context.Context, identifier, domain string, ...) (*apiclient.Frontend, *apiclient.FrontendCustomDomainResponse, error)
- func (s Service) StreamDeploymentLogs(ctx context.Context, frontendID, deploymentID uuid.UUID, limit int) (*api.ProjectLogStream, error)
- func (s Service) StreamRuntimeLogs(ctx context.Context, frontendID uuid.UUID, limit int, lastEventID string) (*api.ProjectLogStream, error)
- func (s Service) UpdateRoute(ctx context.Context, identifier, route string, update RouteUpdate) (*apiclient.Frontend, RouteResult, error)
- type SourceLayout
- type TargetNotPublicError
Constants ¶
const SourceLayoutPath = ".volcano/source-layout.json"
SourceLayoutPath is where a project lists its frontends. Volcano writes it on source export and reads it when it deploys a connected repository, so a project deploys the same frontends from the CLI and from git.
Variables ¶
This section is empty.
Functions ¶
func HasBuildPackage ¶ added in v0.46.0
HasBuildPackage reports whether the app in appDir has a package.json that builds it: its own, or the nearest one above it inside archiveRoot whose build script runs "next build <appDir>". volcano init nextjs creates the second layout, and Volcano's builders accept both.
func NormalizeAppRoot ¶
NormalizeAppRoot validates and normalizes a user-supplied --app-root flag. Empty or "." values become "", meaning the archive root is the app root.
func ValidateAppRootExists ¶
ValidateAppRootExists verifies that --app-root resolves to a directory under the packaged archive root.
Types ¶
type BuildSource ¶ added in v0.51.0
BuildSource is the value of "frontends deploy --from": a frontend and, optionally, one of its deployments.
func ParseBuildSource ¶ added in v0.51.0
func ParseBuildSource(value string) (BuildSource, error)
ParseBuildSource reads <frontend>[@<deployment-id>].
type CustomDomainChange ¶ added in v0.50.0
type CustomDomainChange int
CustomDomainChange is what a custom domain create request did.
const ( // CustomDomainCreated means the frontend did not have the domain and now // has it. CustomDomainCreated CustomDomainChange = iota // CustomDomainSwitched means an active domain of the frontend changed TLS // mode in place. CustomDomainSwitched // CustomDomainUnchanged means the frontend already had the domain in the // requested TLS mode. The server ignores certificate material then. CustomDomainUnchanged )
type CustomDomainEntry ¶
type CustomDomainEntry struct {
Frontend apiclient.Frontend
Domain apiclient.FrontendCustomDomainResponse
}
CustomDomainEntry contains one frontend custom domain attachment.
type DeployedBuild ¶ added in v0.51.0
type DeployedBuild struct {
Frontend *apiclient.Frontend
Source *apiclient.Frontend
SourceDeployment *apiclient.FrontendDeployment
}
DeployedBuild is a deployment started from another frontend's build.
type FoundRoute ¶ added in v0.51.0
type FoundRoute struct {
Function *apiclient.FrontendFunctionRoute
Frontend *apiclient.FrontendRoute
}
FoundRoute is one route of either kind as the server lists it; exactly one field is set.
func (FoundRoute) PathPrefix ¶ added in v0.51.0
func (r FoundRoute) PathPrefix() string
PathPrefix returns the route's path prefix.
type LayoutFrontend ¶ added in v0.46.0
type LayoutFrontend struct {
Name string `json:"name"`
// Workspace is the archived directory. Omitted means frontends/<name>;
// empty means the project root.
Workspace *string `json:"workspace,omitempty"`
AppRoot string `json:"app_root"`
}
LayoutFrontend is one frontend: the directory archived for it and the app inside that directory.
func (LayoutFrontend) Dir ¶ added in v0.46.0
func (f LayoutFrontend) Dir() string
Dir returns the directory archived for the frontend, relative to the project root, in POSIX form. The project root is "".
type Mount ¶ added in v0.51.0
type Mount struct {
apiclient.FrontendRoute
// Target is nil when the mounted frontend is missing from the frontend
// list, such as one deleted after the route was read.
Target *apiclient.Frontend
}
Mount is a Frontend route, which serves a path of one frontend from another frontend of the project, and the frontend it mounts.
type MountedBy ¶ added in v0.51.0
MountedBy is a Frontend route on another frontend that mounts a frontend.
type Package ¶
type Package struct {
Archive []byte
Size int64
PackagingRoot string
AppPath string
// SkippedSymlinks lists POSIX-relative archive paths whose symlinks were
// dropped because the archive cannot represent them safely. Callers
// should surface these so users notice missing files (e.g. monorepo
// assets symlinked across packages).
SkippedSymlinks []string
}
Package contains one frontend source archive ready for API upload.
func PackageDirectory ¶
func PackageDirectory(rootDir string, opts PackageOptions) (*Package, error)
PackageDirectory builds a tar.gz archive of rootDir for upload, applying ignore rules and optionally promoting the working tree to a workspace root. Promotion can be disabled via opts.DisableWorkspacePromotion.
type PackageOptions ¶
type PackageOptions struct {
// DisableWorkspacePromotion packages the selected root as-is even when
// it participates in a JS workspace with `workspace:` deps. The caller
// is responsible for telling the server where the app lives.
DisableWorkspacePromotion bool
// AppRoot, when non-empty, is the POSIX-relative path the caller plans
// to send as the server-side `app_root` field. PackageDirectory rejects
// the request when this path would be excluded by the archive ignore
// rules, so the server is never told to build a directory that is not
// in the upload.
AppRoot string
// ExcludeFiles are paths of files to leave out of the archive. Those
// outside the packaging root are ignored.
ExcludeFiles []string
}
PackageOptions tunes how PackageDirectory builds the archive.
type Route ¶ added in v0.42.0
type Route struct {
apiclient.FrontendFunctionRoute
// Function is nil when the target is missing from the function list, such
// as one deleted after the route was read.
Function *apiclient.Function
}
Route is a frontend function route and the function it forwards to.
type RouteInput ¶ added in v0.42.0
RouteInput is the route a create writes. Exactly one of Function and Frontend, each a name or ID, names the target: a function route forwards to a function, and a Frontend route mounts another frontend.
type RouteResult ¶ added in v0.51.0
RouteResult is one route of either kind; exactly one field is set.
func (RouteResult) PathPrefix ¶ added in v0.51.0
func (r RouteResult) PathPrefix() string
PathPrefix returns the route's path prefix.
type RouteUpdate ¶ added in v0.42.0
RouteUpdate changes the fields that are set and keeps the others. Function and StripPrefix apply to function routes, Frontend to Frontend routes.
type Routes ¶ added in v0.51.0
Routes are a frontend's function and Frontend routes, each in the order the server returns them, most specific first.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service performs authenticated Volcano frontend workflows.
func NewService ¶
func NewService(deps cliruntime.Deps) Service
NewService returns a frontend service.
func (Service) AddDomain ¶ added in v0.51.0
func (s Service) AddDomain( ctx context.Context, identifier string, input api.FrontendDomainInput, ) (*apiclient.Frontend, *apiclient.FrontendCustomDomainResponse, CustomDomainChange, error)
AddDomain adds a custom domain beside a frontend's others, or switches the TLS mode of one it already has. For an existing domain, input without a redirect keeps the domain's, and a redirect without a Status keeps its status: the API refuses a request whose redirect differs from the domain's.
func (Service) CreateCustomDomain ¶
func (s Service) CreateCustomDomain(ctx context.Context, identifier string, input api.FrontendCustomDomainInput) (*apiclient.Frontend, *apiclient.FrontendCustomDomainResponse, CustomDomainChange, error)
CreateCustomDomain attaches a custom domain to a frontend, or switches the TLS mode of its active domain in place when input names the same hostname.
func (Service) CreateRoute ¶ added in v0.42.0
func (s Service) CreateRoute(ctx context.Context, identifier string, input RouteInput) (*apiclient.Frontend, RouteResult, error)
CreateRoute forwards a path prefix on a frontend to a function, or mounts another frontend there when input names a Frontend.
func (Service) DeleteByID ¶
DeleteByID starts deleting one frontend by ID.
func (Service) DeleteCustomDomainByID ¶
DeleteCustomDomainByID detaches the configured custom domain from a frontend ID.
func (Service) DeleteDomain ¶ added in v0.51.0
DeleteDomain removes one custom domain from a frontend.
func (Service) DeleteRoute ¶ added in v0.51.0
DeleteRoute stops serving one route's path prefix, whichever kind it is.
func (Service) Deploy ¶
func (s Service) Deploy(ctx context.Context, input api.FrontendDeployInput) (*apiclient.Frontend, error)
Deploy uploads one frontend source archive and starts a deployment.
func (Service) DeployBuild ¶ added in v0.51.0
func (s Service) DeployBuild(ctx context.Context, target string, source BuildSource) (*DeployedBuild, error)
DeployBuild deploys the build of a source frontend's deployment to target without compiling it again. Without a deployment ID it uses the source's newest active or degraded deployment, which is the one it serves.
func (Service) DeploymentLogs ¶
func (s Service) DeploymentLogs(ctx context.Context, frontendID, deploymentID uuid.UUID, limit int, cursor string) (*apiclient.LogSearchResponse, error)
DeploymentLogs returns one build log search page for a frontend deployment.
func (Service) GetCustomDomain ¶
func (s Service) GetCustomDomain(ctx context.Context, identifier string) (*apiclient.Frontend, *apiclient.FrontendCustomDomainResponse, error)
GetCustomDomain returns the configured custom domain for a frontend.
func (Service) GetDomain ¶ added in v0.51.0
func (s Service) GetDomain(ctx context.Context, identifier, domain string) (*apiclient.Frontend, *apiclient.FrontendCustomDomainResponse, error)
GetDomain returns one custom domain of a frontend.
func (Service) LatestDeployment ¶
func (s Service) LatestDeployment(ctx context.Context, frontendID uuid.UUID) (*apiclient.FrontendDeployment, error)
LatestDeployment returns the first deployment on the default deployment page.
func (Service) ListCustomDomains ¶
func (s Service) ListCustomDomains(ctx context.Context) ([]CustomDomainEntry, error)
ListCustomDomains lists frontend custom domains in the current project.
func (Service) ListDomains ¶ added in v0.51.0
func (s Service) ListDomains(ctx context.Context, identifier string) (*apiclient.Frontend, []apiclient.FrontendCustomDomainResponse, error)
ListDomains returns a frontend's custom domains, oldest first.
func (Service) ListPage ¶
func (s Service) ListPage(ctx context.Context, page, limit int) (*apiclient.PaginatedFrontends, error)
ListPage returns one frontend page in the current project.
func (Service) ListRoutes ¶ added in v0.42.0
func (s Service) ListRoutes(ctx context.Context, identifier string) (*apiclient.Frontend, Routes, error)
ListRoutes returns a frontend's function and Frontend routes.
func (Service) MountTargets ¶ added in v0.51.0
func (s Service) MountTargets(ctx context.Context, routes []apiclient.FrontendRoute) ([]Mount, error)
MountTargets pairs Frontend routes already read with the frontends they mount.
func (Service) MountedBy ¶ added in v0.51.0
MountedBy returns the Frontend routes on other frontends that mount frontendID, which the server requires removed before it deletes the frontend.
func (Service) Redeploy ¶
Redeploy starts a new deployment for the named frontend using the previously uploaded archive.
func (Service) ResolveDeployment ¶
func (s Service) ResolveDeployment(ctx context.Context, frontendID uuid.UUID, deploymentID string) (*apiclient.FrontendDeployment, error)
ResolveDeployment returns a frontend deployment by ID, paging internally.
func (Service) ResolveRoute ¶ added in v0.42.0
func (s Service) ResolveRoute(ctx context.Context, identifier, route string) (*apiclient.Frontend, FoundRoute, error)
ResolveRoute returns one route of either kind, found by its path prefix or ID.
func (Service) RouteTargets ¶ added in v0.42.0
func (s Service) RouteTargets(ctx context.Context, routes []apiclient.FrontendFunctionRoute) ([]Route, error)
RouteTargets pairs routes already read with the functions they forward to.
func (Service) RuntimeLogs ¶
func (s Service) RuntimeLogs(ctx context.Context, frontendID uuid.UUID, limit int, cursor string) (*apiclient.LogSearchResponse, error)
RuntimeLogs returns one runtime log search page for a frontend.
func (Service) SetDomainRedirect ¶ added in v0.51.0
func (s Service) SetDomainRedirect( ctx context.Context, identifier, domain string, redirect *api.FrontendDomainRedirect, ) (*apiclient.Frontend, *apiclient.FrontendCustomDomainResponse, error)
SetDomainRedirect makes a custom domain redirect, or serve the frontend again when redirect is nil. A redirect without a Status keeps the one the domain redirects with; the API would reset it to 308.
func (Service) StreamDeploymentLogs ¶ added in v0.0.4
func (s Service) StreamDeploymentLogs(ctx context.Context, frontendID, deploymentID uuid.UUID, limit int) (*api.ProjectLogStream, error)
StreamDeploymentLogs opens a build log stream for a frontend deployment.
func (Service) StreamRuntimeLogs ¶ added in v0.0.4
func (s Service) StreamRuntimeLogs(ctx context.Context, frontendID uuid.UUID, limit int, lastEventID string) (*api.ProjectLogStream, error)
StreamRuntimeLogs opens a runtime log stream for a frontend, resuming after lastEventID when it is set.
func (Service) UpdateRoute ¶ added in v0.42.0
func (s Service) UpdateRoute(ctx context.Context, identifier, route string, update RouteUpdate) (*apiclient.Frontend, RouteResult, error)
UpdateRoute changes one route of either kind, found by its path prefix or ID. A route keeps its kind.
type SourceLayout ¶ added in v0.46.0
type SourceLayout struct {
Version int `json:"version"`
Frontends []LayoutFrontend `json:"frontends"`
}
SourceLayout lists a project's frontends relative to the project root.
func ParseSourceLayout ¶ added in v0.46.0
func ParseSourceLayout(data []byte) (SourceLayout, error)
ParseSourceLayout decodes and validates a layout file with the rules the server applies to one in a connected repository.
func ReadSourceLayout ¶ added in v0.46.0
func ReadSourceLayout(projectRoot string) (layout SourceLayout, found bool, err error)
ReadSourceLayout reads the layout file under projectRoot. found is false when the project has none.
type TargetNotPublicError ¶ added in v0.42.0
TargetNotPublicError reports a route refused because the function it forwards to is not public, which every route target must be.
func (*TargetNotPublicError) Error ¶ added in v0.42.0
func (e *TargetNotPublicError) Error() string
func (*TargetNotPublicError) Unwrap ¶ added in v0.42.0
func (e *TargetNotPublicError) Unwrap() error