resource

package
v1.6.9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 13, 2026 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

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."`
}

func (Resource) Name

func (Resource) Name() string

func (Resource) New

func (r Resource) New(name string) (schema.ResourceInstance, error)

func (Resource) Schema

func (Resource) Schema() []schema.Attribute

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

func (r *ResourceInstance) Plan(ctx context.Context, v any) (schema.Plan, error)

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.

func (*ResourceInstance) Validate

func (r *ResourceInstance) Validate(ctx context.Context, state schema.State, resolve schema.Resolver) (any, error)

Validate decodes the incoming state, resolves references, and returns the validated *Resource configuration for use by Plan and Apply.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL