Documentation
¶
Index ¶
- type Resource
- type ResourceInstance
- func (r *ResourceInstance) Apply(ctx context.Context, v any) error
- func (r *ResourceInstance) Destroy(_ context.Context) error
- func (r *ResourceInstance) Plan(ctx context.Context, v any) (schema.Plan, error)
- func (r *ResourceInstance) Read(ctx context.Context) (schema.State, error)
- func (r *ResourceInstance) RuntimeErr() error
- func (r *ResourceInstance) Spec() *openapi.Server
- func (r *ResourceInstance) Validate(ctx context.Context, state schema.State, resolve schema.Resolver) (any, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Resource ¶
type Resource struct {
Listen string `name:"listen" help:"Listen address (e.g. localhost:8080)"`
Description string `name:"description" help:"Server description for OpenAPI spec"`
Endpoint string `name:"endpoint" readonly:"" help:"Base URL of the running server"`
Router schema.ResourceInstance `name:"router" type:"httprouter" required:"" help:"HTTP router"`
ReadTimeout time.Duration `name:"read_timeout" default:"5m" help:"Read timeout"`
WriteTimeout time.Duration `name:"write_timeout" default:"5m" help:"Write timeout"`
IdleTimeout time.Duration `name:"idle_timeout" default:"5m" help:"Idle timeout for keep-alive connections"`
TLS struct {
Name string `name:"name" help:"TLS server name"`
Verify bool `name:"verify" default:"true" help:"Verify client certificates"`
Cert []byte `name:"cert" sensitive:"" help:"TLS certificate PEM data"`
Key []byte `name:"key" sensitive:"" help:"TLS key PEM data"`
} `embed:"" prefix:"tls."`
}
type ResourceInstance ¶
type ResourceInstance struct {
provider.ResourceInstance[Resource]
// contains filtered or unexported fields
}
func (*ResourceInstance) Apply ¶
func (r *ResourceInstance) Apply(ctx context.Context, v any) error
Apply materialises the resource using the validated configuration.
func (*ResourceInstance) Destroy ¶
func (r *ResourceInstance) Destroy(_ context.Context) error
Destroy tears down the resource and releases its backing infrastructure. It returns an error if the resource cannot be cleanly removed.
func (*ResourceInstance) Plan ¶
Plan computes the diff and performs pre-flight checks on changed fields: probing the listen address for availability and validating TLS certificates (PEM parsing, key-pair match, expiry).
func (*ResourceInstance) Read ¶
Read returns the current state of the server instance. If the background server has exited with an error, it is returned.
func (*ResourceInstance) RuntimeErr ¶
func (r *ResourceInstance) RuntimeErr() error
RuntimeErr returns the error from the background server goroutine, or nil if the server is running normally.
func (*ResourceInstance) Spec ¶
func (r *ResourceInstance) Spec() *openapi.Server
Spec returns the OpenAPI server entry for this instance, or nil if the server has not started yet.