Documentation
¶
Index ¶
- Variables
- func ErrorToDiagnostics(action ResourceAction, resourceName, resourceType string, err error) diag.Diagnostics
- func GetModelFromMetadata(ctx context.Context, src sdkresource.Object, dst *ResourceMetadataModel) diag.Diagnostics
- func NewResource[T sdkresource.Object, L sdkresource.ListObject](cfg ResourceConfig[T]) resource.Resource
- func ParseFieldPath(resourceType, fieldPath string) path.Path
- func ParseResourceFromModel[T sdkresource.Object](ctx context.Context, src ResourceModel, dst T, specParser SpecParser[T]) diag.Diagnostics
- func ParseResourceOptionsFromModel(ctx context.Context, src ResourceModel, dst *ResourceOptions) diag.Diagnostics
- func SaveResourceToModel[T sdkresource.Object](ctx context.Context, src T, dst *ResourceModel) diag.Diagnostics
- func SetMetadataFromModel(ctx context.Context, src types.Object, dst sdkresource.Object) diag.Diagnostics
- type DashboardSpecModel
- type FieldError
- type FieldErrors
- type NamedResource
- type PlaylistItemModel
- type PlaylistItemValidator
- type PlaylistSpecModel
- type Resource
- func (r *Resource[T, L]) Configure(ctx context.Context, req resource.ConfigureRequest, ...)
- func (r *Resource[T, L]) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse)
- func (r *Resource[T, L]) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse)
- func (r *Resource[T, L]) ImportState(ctx context.Context, req resource.ImportStateRequest, ...)
- func (r *Resource[T, L]) Metadata(ctx context.Context, req resource.MetadataRequest, ...)
- func (r *Resource[T, L]) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse)
- func (r *Resource[T, L]) Schema(ctx context.Context, req resource.SchemaRequest, res *resource.SchemaResponse)
- func (r *Resource[T, L]) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse)
- type ResourceAction
- type ResourceConfig
- type ResourceMetadataModel
- type ResourceModel
- type ResourceOptions
- type ResourceOptionsModel
- type ResourceSpecSchema
- type SpecParser
- type SpecSaver
Constants ¶
This section is empty.
Variables ¶
var KnownPlaylistItemTypeValues = []string{ string(v0alpha1.PlaylistItemTypeDashboardByTag), string(v0alpha1.PlaylistItemTypeDashboardByUid), string(v0alpha1.PlaylistItemTypeDashboardById), }
KnownPlaylistItemTypeValues is a list of known playlist item types.
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 ¶
func NewResource[T sdkresource.Object, L sdkresource.ListObject](cfg ResourceConfig[T]) resource.Resource
NewResource creates a new Terraform resource for a Grafana resource.
func ParseFieldPath ¶
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 ¶
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 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.
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 ¶
func (v PlaylistItemValidator) ValidateList( ctx context.Context, req validator.ListRequest, resp *validator.ListResponse, )
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 ¶
ResourceOptions is a struct for the options of a Grafana resource.
type ResourceOptionsModel ¶
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.