customresources

package
v0.0.36 Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2026 License: MPL-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package customresources lets hand-written code override the resource implementation produced by the auto-generated `*_resource_gen.go` files without modifying those generated files (which would be lost on the next `make resources` run).

Usage:

  1. Auto-generated code in `internal/byteplus/.../foo_resource_gen.go` registers itself as usual via `registry.AddResourceFactory("foo", fooResource)`.
  2. A hand-written file in the same package, e.g. `foo_resource.go`, calls `customresources.Register("foo", wrapFoo)` from its `init()` function.
  3. The provider's `Resources()` method consults this registry and replaces the auto-generated resource with the wrapped one.

The wrapper receives the inner (auto-generated) resource so it can delegate most of the framework lifecycle while customizing only the parts it needs (typically Create or Read).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Register

func Register(typeName string, f Factory)

Register associates a custom Factory with a Terraform resource type name. Registering the same name twice panics to surface conflicts at startup.

Types

type Factory

type Factory func(ctx context.Context, inner resource.Resource) (resource.Resource, error)

Factory wraps the auto-generated inner resource and returns the resource that should be exposed to the framework in its place.

func Lookup

func Lookup(typeName string) (Factory, bool)

Lookup returns the custom Factory for typeName, if any.

Jump to

Keyboard shortcuts

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