appplatform

package
v4.11.0 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2025 License: MPL-2.0 Imports: 34 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

KnownPlaylistItemTypeValues is a list of known playlist item types.

View Source
var PlaylistItemType = types.ObjectType{
	AttrTypes: map[string]attr.Type{
		"type":  types.StringType,
		"value": types.StringType,
	},
}

PlaylistItemType is the type of the playlist item.

Functions

func ErrorToDiagnostics

func ErrorToDiagnostics(action ResourceAction, resourceName, resourceType string, err error) diag.Diagnostics

ErrorToDiagnostics formats an error from the Kubernetes API into Terraform diagnostics.

func GetModelFromMetadata

func GetModelFromMetadata(
	ctx context.Context, src sdkresource.Object, dst *ResourceMetadataModel,
) diag.Diagnostics

GetModelFromMetadata gets the metadata of a resource from the Terraform model.

func NewResource

NewResource creates a new Terraform resource for a Grafana resource.

func ParseFieldPath

func ParseFieldPath(resourceType, fieldPath string) path.Path

ParseFieldPath converts a Kubernetes field path into a Terraform path.

func ParseResourceFromModel

func ParseResourceFromModel[T sdkresource.Object](
	ctx context.Context, src ResourceModel, dst T, specParser SpecParser[T],
) diag.Diagnostics

ParseResourceFromModel parses a resource model into a resource.

func ParseResourceOptionsFromModel

func ParseResourceOptionsFromModel(
	ctx context.Context, src ResourceModel, dst *ResourceOptions,
) diag.Diagnostics

ParseResourceOptionsFromModel parses the options of a resource from the Terraform model.

func SaveResourceToModel

func SaveResourceToModel[T sdkresource.Object](
	ctx context.Context, src T, dst *ResourceModel,
) diag.Diagnostics

SaveResourceToModel saves a resource to a Terraform model.

func SetMetadataFromModel

func SetMetadataFromModel(
	ctx context.Context, src types.Object, dst sdkresource.Object,
) diag.Diagnostics

SetMetadataFromModel sets the metadata of a resource from the Terraform config.

Types

type DashboardSpecModel

type DashboardSpecModel struct {
	JSON  jsontypes.Normalized `tfsdk:"json"`
	Title types.String         `tfsdk:"title"`
	Tags  types.List           `tfsdk:"tags"`
}

DashboardSpecModel is a model for the dashboard spec.

type FieldError

type FieldError struct {
	Field    string
	Path     path.Path
	Messages []string
}

FieldError is a field-level error returned by the Kubernetes API, with the path and messages adapted to Terraform diagnostics.

type FieldErrors

type FieldErrors map[string]FieldError

FieldErrors is a map of field names to FieldError instances.

func FieldErrorsFromCauses

func FieldErrorsFromCauses(resourceType string, causes []metav1.StatusCause) FieldErrors

FieldErrorsFromCauses converts a list of field errors returned by the Kubernetes API into a map of Terraform-acceptable field-level errors.

type NamedResource

type NamedResource struct {
	Resource resource.Resource
	Name     string
	Category common.ResourceCategory
}

NamedResource is a Resource with a name and category.

func AlertEnrichment added in v4.6.0

func AlertEnrichment() NamedResource

AlertEnrichment creates a new Grafana Alert Enrichment resource

func Dashboard

func Dashboard() NamedResource

Dashboard creates a new Grafana Dashboard resource.

func NewNamedResource

func NewNamedResource[T sdkresource.Object, L sdkresource.ListObject](
	category common.ResourceCategory, cfg ResourceConfig[T],
) NamedResource

NewNamedResource creates a new Terraform resource for a Grafana resource. The named resource contains the name of the resource and its category.

func Playlist

func Playlist() NamedResource

Playlist creates a new Grafana Playlist resource.

type PlaylistItemModel

type PlaylistItemModel struct {
	Type  types.String `tfsdk:"type"`
	Value types.String `tfsdk:"value"`
}

PlaylistItemModel is a model for the playlist item.

type PlaylistItemValidator

type PlaylistItemValidator struct{}

PlaylistItemValidator is a validator for the playlist item. It ensures that the playlist item type is one of the known values.

func (PlaylistItemValidator) Description

func (v PlaylistItemValidator) Description(_ context.Context) string

Description returns the description of the validator.

func (PlaylistItemValidator) MarkdownDescription

func (v PlaylistItemValidator) MarkdownDescription(ctx context.Context) string

MarkdownDescription returns the markdown description of the validator.

func (PlaylistItemValidator) ValidateList

ValidateList validates the playlist item. It ensures that the playlist item type is one of the known values.

type PlaylistSpecModel

type PlaylistSpecModel struct {
	Title    types.String `tfsdk:"title"`
	Interval types.String `tfsdk:"interval"`
	Items    types.List   `tfsdk:"items"`
}

PlaylistSpecModel is a model for the playlist spec.

type Resource

type Resource[T sdkresource.Object, L sdkresource.ListObject] struct {
	// contains filtered or unexported fields
}

Resource is a generic Terraform resource for a Grafana resource.

func (*Resource[T, L]) Configure

func (r *Resource[T, L]) Configure(ctx context.Context, req resource.ConfigureRequest, resp *resource.ConfigureResponse)

Configure initializes the Resource.

func (*Resource[T, L]) Create

func (r *Resource[T, L]) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse)

Create creates a new Grafana resource.

func (*Resource[T, L]) Delete

func (r *Resource[T, L]) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse)

Delete deletes the Grafana resource.

func (*Resource[T, L]) ImportState

func (r *Resource[T, L]) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse)

ImportState imports the state of the Grafana resource.

func (*Resource[T, L]) Metadata

func (r *Resource[T, L]) Metadata(ctx context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse)

Metadata returns the metadata for the Resource.

func (*Resource[T, L]) Read

func (r *Resource[T, L]) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse)

Read reads the Grafana resource.

func (*Resource[T, L]) Schema

func (r *Resource[T, L]) Schema(ctx context.Context, req resource.SchemaRequest, res *resource.SchemaResponse)

Schema returns the schema for the Resource.

func (*Resource[T, L]) Update

func (r *Resource[T, L]) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse)

Update updates the Grafana resource.

type ResourceAction

type ResourceAction string

ResourceAction is the action that is being performed on the resource.

const (
	ResourceActionCreate ResourceAction = "create"
	ResourceActionUpdate ResourceAction = "update"
	ResourceActionDelete ResourceAction = "delete"
	ResourceActionRead   ResourceAction = "read"
)

type ResourceConfig

type ResourceConfig[T sdkresource.Object] struct {
	Schema     ResourceSpecSchema
	Kind       sdkresource.Kind
	SpecParser SpecParser[T]
	SpecSaver  SpecSaver[T]
}

ResourceConfig is a configuration for a Grafana resource.

type ResourceMetadataModel

type ResourceMetadataModel struct {
	UUID        types.String `tfsdk:"uuid"`
	UID         types.String `tfsdk:"uid"`
	FolderUID   types.String `tfsdk:"folder_uid"`
	Version     types.String `tfsdk:"version"`
	URL         types.String `tfsdk:"url"`
	Annotations types.Map    `tfsdk:"annotations"`
}

ResourceMetadataModel is a Terraform model for the metadata of a Grafana resource.

type ResourceModel

type ResourceModel struct {
	ID       types.String `tfsdk:"id"`
	Metadata types.Object `tfsdk:"metadata"`
	Spec     types.Object `tfsdk:"spec"`
	Options  types.Object `tfsdk:"options"`
}

ResourceModel is a Terraform model for a Grafana resource.

type ResourceOptions

type ResourceOptions struct {
	Overwrite bool
	Validate  bool
	LintRules []string
}

ResourceOptions is a struct for the options of a Grafana resource.

type ResourceOptionsModel

type ResourceOptionsModel struct {
	Overwrite types.Bool `tfsdk:"overwrite"`
}

ResourceOptionsModel is a Terraform model for the options of a Grafana resource.

type ResourceSpecSchema

type ResourceSpecSchema struct {
	Description         string
	MarkdownDescription string
	DeprecationMessage  string
	SpecAttributes      map[string]schema.Attribute
	SpecBlocks          map[string]schema.Block
}

ResourceSpecSchema is the Terraform schema for a Grafana resource spec.

type SpecParser

type SpecParser[T sdkresource.Object] func(ctx context.Context, src types.Object, dst T) diag.Diagnostics

SpecParser is a function that parses a resource spec from a Terraform model.

type SpecSaver

type SpecSaver[T sdkresource.Object] func(ctx context.Context, src T, dst *ResourceModel) diag.Diagnostics

SpecSaver is a function that saves a resource spec to a Terraform model.

Jump to

Keyboard shortcuts

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