remote

package
v0.2.13 Latest Latest
Warning

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

Go to latest
Published: May 6, 2026 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SortFoldersByDependency

func SortFoldersByDependency(folders []*resources.Resource) ([][]*resources.Resource, error)

SortFoldersByDependency groups folders by their dependency level. Returns a slice where each element is a slice of folders at the same level. All folders at the same level can be pushed concurrently.

Types

type DeleteClient

type DeleteClient interface {
	Delete(ctx context.Context, desc resources.Descriptor, name string, opts metav1.DeleteOptions) error
}

DeleteClient is a client that can delete resources from Grafana.

type DeleteRequest

type DeleteRequest struct {
	// A list of resources to delete.
	Resources *resources.Resources

	// The maximum number of concurrent pushes.
	MaxConcurrency int

	// Whether the operation should stop upon encountering an error.
	StopOnError bool

	// If set to true, the deleter will simulate the delete operations.
	DryRun bool
}

DeleteRequest is a request for deleting resources from Grafana.

type Deleter

type Deleter struct {
	// contains filtered or unexported fields
}

Deleter takes care of deleting resources from Grafana.

func NewDeleter

func NewDeleter(ctx context.Context, cfg config.NamespacedRESTConfig) (*Deleter, error)

NewDeleter creates a new Deleter. It uses a ResourceClientRouter that delegates to provider adapters for provider-backed resource types, and falls back to the default namespaced dynamic client for native resources.

func NewDeleterWithClient

func NewDeleterWithClient(client DeleteClient, registry PushRegistry) *Deleter

NewDeleterWithClient creates a new Deleter with the given client and registry. This is primarily useful for testing.

func (*Deleter) Delete

func (deleter *Deleter) Delete(ctx context.Context, request DeleteRequest) (*OperationSummary, error)

type OperationFailure

type OperationFailure struct {
	// Resource is the resource that failed. May be nil for non-resource failures
	// (e.g., failures fetching all resources of a given type).
	Resource *resources.Resource

	// Error is the error that caused the failure.
	Error error
}

OperationFailure describes a single resource operation failure.

type OperationSummary

type OperationSummary struct {
	// contains filtered or unexported fields
}

OperationSummary tracks the results of a batch resource operation in a thread-safe manner. It uses atomic counters for success/failure counts and a mutex-protected slice for failure details.

func (*OperationSummary) FailedCount

func (s *OperationSummary) FailedCount() int

FailedCount returns the number of failed resource operations.

func (*OperationSummary) Failures

func (s *OperationSummary) Failures() []OperationFailure

Failures returns all recorded operation failures.

func (*OperationSummary) IsTruncated added in v0.2.6

func (s *OperationSummary) IsTruncated() bool

IsTruncated reports whether any list response was truncated.

func (*OperationSummary) RecordFailure

func (s *OperationSummary) RecordFailure(res *resources.Resource, err error)

RecordFailure records a failed operation. res may be nil when the failure is not associated with a specific resource (e.g., a filter-level pull failure).

func (*OperationSummary) RecordSkipped

func (s *OperationSummary) RecordSkipped()

RecordSkipped records a resource type that was skipped because the API does not support the requested operation (e.g. 404 or 405 on LIST).

func (*OperationSummary) RecordSuccess

func (s *OperationSummary) RecordSuccess()

RecordSuccess records a successful operation.

func (*OperationSummary) RecordTruncated added in v0.2.6

func (s *OperationSummary) RecordTruncated()

RecordTruncated records that a list response was truncated (more items available).

func (*OperationSummary) SkippedCount

func (s *OperationSummary) SkippedCount() int

SkippedCount returns the number of resource types skipped because the API does not support the requested operation.

func (*OperationSummary) SuccessCount

func (s *OperationSummary) SuccessCount() int

SuccessCount returns the number of successfully processed resources.

type Processor

type Processor interface {
	Process(res *resources.Resource) error
}

Processor can be used to modify a resource in-place, before it is written or after it is read from local sources.

They can be used to e.g. strip server-side fields from a resource, or add extra metadata after a resource has been read from a file.

type PullClient

type PullClient interface {
	Get(
		ctx context.Context, desc resources.Descriptor, name string, opts metav1.GetOptions,
	) (*unstructured.Unstructured, error)

	GetMultiple(
		ctx context.Context, desc resources.Descriptor, names []string, opts metav1.GetOptions,
	) ([]unstructured.Unstructured, error)

	List(
		ctx context.Context, desc resources.Descriptor, opts metav1.ListOptions,
	) (*unstructured.UnstructuredList, error)
}

PullClient is a client that can pull resources from Grafana.

type PullRegistry

type PullRegistry interface {
	PreferredResources() resources.Descriptors
}

PullRegistry is a registry of resources that can be pulled from Grafana.

type PullRequest

type PullRequest struct {
	// Which resources to pull.
	Filters resources.Filters

	// Processors to apply to resources after they are pulled.
	Processors []Processor

	// Destination list for the pulled resources.
	Resources *resources.Resources

	// Whether to include resources managed by other tools.
	ExcludeManaged bool

	// Whether the operation should stop upon encountering an error.
	StopOnError bool

	// Limit caps the number of items returned per resource type. Zero means no limit.
	// Use Limit=1 for introspection operations (e.g. --json ? field discovery) to
	// avoid triggering a full list operation.
	Limit int64
}

PullRequest is a request for pulling resources from Grafana.

type Puller

type Puller struct {
	// contains filtered or unexported fields
}

Puller is a command that pulls resources from Grafana.

func NewDefaultPuller

func NewDefaultPuller(ctx context.Context, restConfig config.NamespacedRESTConfig) (*Puller, error)

NewDefaultPuller creates a new Puller. It uses a ResourceClientRouter that delegates to provider adapters for provider-backed resource types, and falls back to the default versioned dynamic client for native resources.

func NewPuller

func NewPuller(client PullClient, registry PullRegistry) *Puller

NewPuller creates a new Puller.

func (*Puller) Pull

func (p *Puller) Pull(ctx context.Context, req PullRequest) (*OperationSummary, error)

Pull pulls resources from Grafana.

type PushClient

PushClient is a client that can push resources to Grafana.

type PushLister added in v0.2.3

type PushLister interface {
	List(ctx context.Context, desc resources.Descriptor, opts metav1.ListOptions) (*unstructured.UnstructuredList, error)
}

PushLister is an optional interface that PushClient implementations may satisfy to enable listing resources on the target. Used for natural-key matching during cross-stack push operations.

type PushRegistry

type PushRegistry interface {
	SupportedResources() resources.Descriptors
}

PushRegistry is a registry of resources that can be pushed to Grafana.

type PushRequest

type PushRequest struct {
	// A list of resources to push.
	Resources *resources.Resources

	// Processors to apply to resources before pushing them.
	Processors []Processor

	// The maximum number of concurrent pushes.
	MaxConcurrency int

	// Whether the operation should stop upon encountering an error.
	StopOnError bool

	// If set to true, the pusher will use the server-side dry-run feature to simulate the push operations.
	// This will not actually create or update any resources,
	// but will ensure the requests are valid and perform server-side validations.
	DryRun bool

	// Disable log emission for push failures. Callers will have to rely on the OperationSummary
	// returned by the Push() function to explore and report failures.
	NoPushFailureLog bool

	// Whether to include resources managed by other tools.
	IncludeManaged bool
}

PushRequest is a request for pushing resources to Grafana.

type Pusher

type Pusher struct {
	// contains filtered or unexported fields
}

Pusher takes care of pushing resources to Grafana API.

func NewDefaultPusher

func NewDefaultPusher(ctx context.Context, cfg config.NamespacedRESTConfig) (*Pusher, error)

NewDefaultPusher creates a new Pusher. It uses a ResourceClientRouter that delegates to provider adapters for provider-backed resource types, and falls back to the default namespaced dynamic client for native resources.

func NewPusher

func NewPusher(client PushClient, registry PushRegistry) *Pusher

NewPusher creates a new Pusher.

func (*Pusher) Push

func (p *Pusher) Push(ctx context.Context, request PushRequest) (*OperationSummary, error)

Push pushes resources to Grafana. It pushes folders first (respecting parent-child hierarchy), then other resources. This ensures that parent folders are created before their children, and all folders are created before other resources that depend on them.

Jump to

Keyboard shortcuts

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