Documentation
¶
Overview ¶
Package api provides a service provider that wraps go-build's build, release, and SDK subsystems as REST endpoints with WebSocket event streaming.
Index ¶
- Variables
- func Fail(code, message string) any
- func FailWithDetails(code, message string, details any) any
- func New(opts ...Option) core.Result
- func OK(data any) any
- type BuildProvider
- type DescribableGroup
- type Engine
- type Info
- type Option
- type ReleaseWorkflowRequest
- type RouteDescription
- type RouteGroup
- type ToolBridge
- type ToolDescriptor
Examples ¶
- BuildProvider.BasePath
- BuildProvider.Channels
- BuildProvider.Describe
- BuildProvider.Element
- BuildProvider.Name
- BuildProvider.RegisterRoutes
- Engine.Handler
- Engine.Register
- Engine.Serve
- Fail
- FailWithDetails
- Info
- New
- NewProvider
- NewToolBridge
- OK
- ReleaseWorkflowRequest.Decode
- ToolBridge.Add
- ToolBridge.BasePath
- ToolBridge.Name
- ToolBridge.RegisterRoutes
- ToolBridge.Tools
- WithAddr
- WithWSHandler
- WithWSPath
Constants ¶
This section is empty.
Variables ¶
var Assets embed.FS
Assets holds the built UI bundle (core-build.js and related files). The directory is populated by running `npm run build` in the ui/ directory.
Usage example: use api.Assets from package consumers as needed.
Functions ¶
func FailWithDetails ¶
Example ¶
_ = FailWithDetails("bad_request", "invalid request", map[string]any{"field": "name"})
Types ¶
type BuildProvider ¶
type BuildProvider struct {
// contains filtered or unexported fields
}
BuildProvider wraps go-build's build, release, and SDK operations as a service provider. It implements Provider, Streamable, Describable, and Renderable.
p := api.NewProvider(".", hub)
func NewProvider ¶
func NewProvider(projectDir string, hub *events.Hub) *BuildProvider
NewProvider creates a BuildProvider for the given project directory. If projectDir is empty, the current working directory is used. The WS hub is used to emit real-time build events; pass nil if not available.
p := api.NewProvider(".", hub)
Example ¶
--- v0.9.0 generated usage examples ---
_ = NewProvider(core.Path(core.TempDir(), "go-build-compliance"), nil)
core.Println("NewProvider")
Output: NewProvider
func (*BuildProvider) BasePath ¶
func (p *BuildProvider) BasePath() string
BasePath implements api.RouteGroup.
path := p.BasePath() // → "/api/v1/build"
Example ¶
subject := &BuildProvider{}
_ = subject.BasePath()
core.Println("BuildProvider_BasePath")
Output: BuildProvider_BasePath
func (*BuildProvider) Channels ¶
func (p *BuildProvider) Channels() []string
Channels implements provider.Streamable.
channels := p.Channels() // → ["build.started", "build.complete", ...]
Example ¶
subject := &BuildProvider{}
_ = subject.Channels()
core.Println("BuildProvider_Channels")
Output: BuildProvider_Channels
func (*BuildProvider) Describe ¶
func (p *BuildProvider) Describe() []RouteDescription
Describe implements api.DescribableGroup.
routes := p.Describe() // → [{Method: "GET", Path: "/config", ...}, ...]
Example ¶
subject := &BuildProvider{}
_ = subject.Describe()
core.Println("BuildProvider_Describe")
Output: BuildProvider_Describe
func (*BuildProvider) Element ¶
func (p *BuildProvider) Element() provider.ElementSpec
Element implements provider.Renderable.
spec := p.Element() // → {Tag: "core-build-panel", Source: "/assets/core-build.js"}
Example ¶
subject := &BuildProvider{}
_ = subject.Element()
core.Println("BuildProvider_Element")
Output: BuildProvider_Element
func (*BuildProvider) Name ¶
func (p *BuildProvider) Name() string
Name implements api.RouteGroup.
name := p.Name() // → "build"
Example ¶
subject := &BuildProvider{}
_ = subject.Name()
core.Println("BuildProvider_Name")
Output: BuildProvider_Name
func (*BuildProvider) RegisterRoutes ¶
func (p *BuildProvider) RegisterRoutes(rg *gin.RouterGroup)
RegisterRoutes implements api.RouteGroup.
p.RegisterRoutes(rg)
Example ¶
subject := &BuildProvider{}
subject.RegisterRoutes(gin.New().Group("/build"))
core.Println("BuildProvider_RegisterRoutes")
Output: BuildProvider_RegisterRoutes
type DescribableGroup ¶
type DescribableGroup interface {
RouteGroup
Describe() []RouteDescription
}
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
func (*Engine) Register ¶
func (e *Engine) Register(group RouteGroup)
Example ¶
engine := New().Value.(*Engine)
engine.Register(httpTestGroup{name: "test", base: "/test"})
type Info ¶
type Info struct {
Name string "json:\"name\""
Path string "json:\"path\""
Size int64 "json:\"size\""
}
Info holds JSON-friendly metadata about a dist/ file.
Example ¶
subject := Info{Name: "app.tar.gz", Path: "/dist/app.tar.gz", Size: 42}
core.Println(subject.Name, subject.Size)
Output: app.tar.gz 42
type Option ¶
type Option func(*Engine)
func WithWSHandler ¶
func WithWSHandler(handler http.HandlerFunc) Option
Example ¶
handler := func(http.ResponseWriter, *http.Request) {}
_ = New(WithWSHandler(handler))
type ReleaseWorkflowRequest ¶
type ReleaseWorkflowRequest struct {
Path string
WorkflowPath string `json:"workflowPath"`
WorkflowPathSnake string `json:"workflow_path"`
WorkflowPathHyphen string `json:"workflow-path"`
OutputPath string `json:"outputPath"`
OutputPathHyphen string `json:"output-path"`
OutputPathSnake string `json:"output_path"`
LegacyOutputPath string `json:"output"`
WorkflowOutputPath string `json:"workflowOutputPath"`
WorkflowOutputSnake string `json:"workflow_output"`
WorkflowOutputHyphen string `json:"workflow-output"`
WorkflowOutputPathSnake string `json:"workflow_output_path"`
WorkflowOutputPathHyphen string `json:"workflow-output-path"`
}
ReleaseWorkflowRequest captures the workflow-generation inputs exposed by the API.
request := ReleaseWorkflowRequest{Path: "ci/release.yml"} // writes ./ci/release.yml request := ReleaseWorkflowRequest{WorkflowOutputPath: "ops/release.yml"} // writes ./ops/release.yml
func (*ReleaseWorkflowRequest) Decode ¶
func (r *ReleaseWorkflowRequest) Decode(data []byte) core.Result
Example ¶
var subject ReleaseWorkflowRequest
_ = subject.Decode([]byte(`{"` + apiPathField + `":"ci/release.yml"}`))
core.Println(subject.Path)
Output: ci/release.yml
type RouteDescription ¶
type RouteDescription struct {
Method string `json:"method,omitempty"`
Path string `json:"path,omitempty"`
Summary string `json:"summary,omitempty"`
Description string `json:"description,omitempty"`
Tags []string `json:"tags,omitempty"`
RequestBody map[string]any `json:"requestBody,omitempty"`
Responses map[string]any `json:"responses,omitempty"`
}
type RouteGroup ¶
type RouteGroup interface {
Name() string
BasePath() string
RegisterRoutes(*gin.RouterGroup)
}
type ToolBridge ¶
type ToolBridge struct {
// contains filtered or unexported fields
}
func NewToolBridge ¶
func NewToolBridge(basePath string) *ToolBridge
Example ¶
bridge := NewToolBridge("/tools")
_ = bridge.Tools()
func (*ToolBridge) Add ¶
func (b *ToolBridge) Add(descriptor ToolDescriptor, handler gin.HandlerFunc)
Example ¶
bridge := NewToolBridge("/tools")
bridge.Add(ToolDescriptor{Name: "build"}, func(c *gin.Context) {})
func (*ToolBridge) BasePath ¶
func (b *ToolBridge) BasePath() string
Example ¶
bridge := NewToolBridge("/tools")
_ = bridge.BasePath()
func (*ToolBridge) Name ¶
func (b *ToolBridge) Name() string
Example ¶
bridge := NewToolBridge("/tools")
_ = bridge.Name()
func (*ToolBridge) RegisterRoutes ¶
func (b *ToolBridge) RegisterRoutes(group *gin.RouterGroup)
Example ¶
bridge := NewToolBridge("/tools")
router := gin.New()
bridge.RegisterRoutes(router.Group(bridge.BasePath()))
func (*ToolBridge) Tools ¶
func (b *ToolBridge) Tools() []ToolDescriptor
Example ¶
bridge := NewToolBridge("/tools")
bridge.Add(ToolDescriptor{Name: "build"}, func(c *gin.Context) {})
_ = bridge.Tools()