fleet

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: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ReadErrorBody

func ReadErrorBody(resp *http.Response) string

ReadErrorBody reads and returns the response body as a string for error messages.

Types

type Client

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

Client is a base HTTP client for the Grafana Fleet Management API. All operations use POST (gRPC/Connect style JSON-over-HTTP).

func LoadClient

func LoadClient(ctx context.Context, loader ConfigLoader) (*Client, string, error)

LoadClient loads cloud configuration and constructs a Fleet Management client using Basic auth ({instanceID}:{apiToken}). Returns the client, the resolved namespace, and any error. Fails with a descriptive error if AgentManagementInstanceURL or AgentManagementInstanceID is not available for the stack.

func NewClient

func NewClient(ctx context.Context, baseURL, instanceID, apiToken string, useBasicAuth bool, httpClient *http.Client) *Client

NewClient creates a new Fleet Management base client. When useBasicAuth is true, requests use Basic auth with instanceID:apiToken. Otherwise, requests use Bearer token auth. If httpClient is nil, httputils.NewDefaultClient is used.

func (*Client) DoRequest

func (c *Client) DoRequest(ctx context.Context, path string, body any) (*http.Response, error)

DoRequest builds and executes a POST request against the Fleet Management API. It is exported so that packages composing this client can call the base transport.

func (*Client) DoRequestWithHeaders

func (c *Client) DoRequestWithHeaders(ctx context.Context, path string, body any, headers map[string]string) (*http.Response, error)

DoRequestWithHeaders is like DoRequest but adds extra headers to the request.

type ClientResult

type ClientResult struct {
	Client    *Client
	Namespace string
	Stack     cloud.StackInfo
}

ClientResult holds the results of LoadClient including the fleet base client, resolved namespace, and the full stack info for deriving backend URLs and prom headers.

func LoadClientWithStack

func LoadClientWithStack(ctx context.Context, loader ConfigLoader) (*ClientResult, error)

LoadClientWithStack is like LoadClient but also returns the full stack info, needed by instrumentation commands to derive backend URLs and prom headers.

type ConfigLoader

type ConfigLoader interface {
	LoadCloudConfig(ctx context.Context) (providers.CloudRESTConfig, error)
}

ConfigLoader can load Grafana Cloud configuration from the active context. This mirrors the interface in internal/providers/fleet/ to avoid a circular import.

Jump to

Keyboard shortcuts

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