Documentation
¶
Index ¶
- Constants
- func BuildHTTPClient(timeout float64, options *agent.Options) *edgeHTTPClient
- type APIClient
- type AsyncCommand
- type AsyncRequest
- type AsyncResponse
- type ChartCacher
- type ContainerCommandData
- type DockerSnapshotter
- type EdgeConfig
- type EdgeConfigID
- type EdgeConfigStateType
- type EdgeJobData
- type EdgeStackLog
- type EndpointLog
- type HelmChartStatusPayload
- type ImageCommandData
- type LiveLogCollector
- type LogCommandData
- type MetaFields
- type NonOkResponseError
- type NormalStackCommandData
- type Option
- type PolicyHelmCharts
- type PolicyStatesCommandPayload
- type PollStatusResponse
- type PortainerAsyncClient
- func (client *PortainerAsyncClient) DeleteEdgeStackStatus(edgeStackID int) error
- func (client *PortainerAsyncClient) EnqueueLogCollectionForStack(logCmd LogCommandData)
- func (client *PortainerAsyncClient) GetCharts(chartNames []string) ([]portainer.PolicyChartBundle, portainer.RestoreSettingsBundle, error)
- func (client *PortainerAsyncClient) GetEdgeConfig(id EdgeConfigID) (*EdgeConfig, error)
- func (client *PortainerAsyncClient) GetEdgeStackConfig(edgeStackID int, version *int) (*edge.StackPayload, error)
- func (client *PortainerAsyncClient) GetEnvironmentID() (portainer.EndpointID, error)
- func (client *PortainerAsyncClient) GetEnvironmentStatus(flags ...string) (*PollStatusResponse, error)
- func (client *PortainerAsyncClient) ReportPolicyStatuses(statuses []portainer.PolicyActualState) error
- func (client *PortainerAsyncClient) SetAlertState(_ *pkgmetrics.EdgeAlertState)
- func (client *PortainerAsyncClient) SetChartsResponse(chart *PolicyHelmCharts)
- func (client *PortainerAsyncClient) SetEdgeConfigState(id EdgeConfigID, state EdgeConfigStateType) error
- func (client *PortainerAsyncClient) SetEdgeJobStatus(edgeJobStatus agent.EdgeJobStatus) error
- func (client *PortainerAsyncClient) SetEdgeStackStatus(edgeStackID, version int, edgeStackStatus portainer.EdgeStackStatusType, ...) error
- func (client *PortainerAsyncClient) SetLastCommandTimestamp(timestamp time.Time)
- func (client *PortainerAsyncClient) SetPendingCommand(id portainer.EdgeStackID, version int, timestamp time.Time)
- func (client *PortainerAsyncClient) SetTimeout(t time.Duration)
- func (client *PortainerAsyncClient) UpdatePolicyChartStatuses(statuses []portainer.PolicyChartStatus) error
- type PortainerClient
- type PortainerEdgeClient
- func (client *PortainerEdgeClient) EnqueueLogCollectionForStack(logCmd LogCommandData)
- func (client *PortainerEdgeClient) GetCharts(chartNames []string) ([]portainer.PolicyChartBundle, portainer.RestoreSettingsBundle, error)
- func (client *PortainerEdgeClient) GetEdgeConfig(id EdgeConfigID) (*EdgeConfig, error)
- func (client *PortainerEdgeClient) GetEdgeStackConfig(edgeStackID int, version *int) (*edge.StackPayload, error)
- func (client *PortainerEdgeClient) GetEnvironmentID() (portainer.EndpointID, error)
- func (client *PortainerEdgeClient) GetEnvironmentStatus(flags ...string) (*PollStatusResponse, error)
- func (client *PortainerEdgeClient) ProcessAsyncCommands() error
- func (client *PortainerEdgeClient) ReportPolicyStatuses(statuses []portainer.PolicyActualState) error
- func (client *PortainerEdgeClient) SetAlertState(state *pkgmetrics.EdgeAlertState)
- func (client *PortainerEdgeClient) SetEdgeConfigState(id EdgeConfigID, state EdgeConfigStateType) error
- func (client *PortainerEdgeClient) SetEdgeJobStatus(edgeJobStatus agent.EdgeJobStatus) error
- func (client *PortainerEdgeClient) SetEdgeStackStatus(edgeStackID, version int, edgeStackStatus portainer.EdgeStackStatusType, ...) error
- func (client *PortainerEdgeClient) SetLastCommandTimestamp(timestamp time.Time)
- func (client *PortainerEdgeClient) SetTimeout(t time.Duration)
- func (client *PortainerEdgeClient) UpdatePolicyChartStatuses(statuses []portainer.PolicyChartStatus) error
- type StackStatus
- type VolumeCommandData
Constants ¶
const DefaultHTTPClientTimeoutSeconds = 30
DefaultHTTPClientTimeoutSeconds is the initial timeout used for edge client requests before Portainer can provide a check-in interval.
Variables ¶
This section is empty.
Functions ¶
func BuildHTTPClient ¶
Types ¶
type APIClient ¶
type APIClient struct {
// contains filtered or unexported fields
}
APIClient is used to execute HTTP requests against the agent API
func NewAPIClient ¶
func NewAPIClient() *APIClient
NewAPIClient returns a pointer to a new APIClient instance
func (*APIClient) GetEdgeKey ¶
GetEdgeKey executes a KeyInspect operation against the specified server
func (*APIClient) SetEdgeKey ¶
SetEdgeKey executes a KeyCreate operation against the specified server
type AsyncCommand ¶
type AsyncRequest ¶
type AsyncRequest struct {
CommandTimestamp *time.Time `json:"commandTimestamp,omitempty"`
Snapshot *snapshot `json:"snapshot,omitempty"`
EndpointId portainer.EndpointID `json:"endpointId,omitempty"`
MetaFields *MetaFields `json:"metaFields,omitempty"`
}
type AsyncResponse ¶
type AsyncResponse struct {
PingInterval time.Duration `json:"pingInterval"`
SnapshotInterval time.Duration `json:"snapshotInterval"`
CommandInterval time.Duration `json:"commandInterval"`
EndpointID portainer.EndpointID `json:"endpointID"`
Commands []AsyncCommand `json:"commands"`
NeedFullSnapshot bool `json:"needFullSnapshot"`
}
type ChartCacher ¶
type ChartCacher interface {
SetChartsResponse(chart *PolicyHelmCharts)
}
ChartCacher is an optional interface for clients that support caching chart bundles received via async commands. The async client implements this so processPolicyStates and processPolicyHelmCharts can cache bundles for on-demand GetCharts retrieval without a concrete type assertion.
type ContainerCommandData ¶
type ContainerCommandData struct {
ContainerName string
ContainerStartOptions container.StartOptions
ContainerRemoveOptions container.RemoveOptions
ContainerOperation string
}
type DockerSnapshotter ¶
type DockerSnapshotter func(edgeKey string) (*portainer.DockerSnapshot, error)
type EdgeConfig ¶
type EdgeConfig struct {
ID EdgeConfigID
Name string
BaseDir string
DirEntries []filesystem.DirEntry
Prev *EdgeConfig
Invalid bool
}
type EdgeConfigID ¶
type EdgeConfigID int
type EdgeConfigStateType ¶
type EdgeConfigStateType int
const ( EdgeConfigIdleState EdgeConfigStateType = iota EdgeConfigFailureState EdgeConfigSavingState EdgeConfigDeletingState EdgeConfigUpdatingState )
func (EdgeConfigStateType) String ¶
func (e EdgeConfigStateType) String() string
type EdgeJobData ¶
type EdgeStackLog ¶
type EdgeStackLog struct {
EdgeStackID portainer.EdgeStackID `json:"edgeStackID,omitempty"`
Logs []EndpointLog `json:"logs,omitempty"`
Append bool `json:"append,omitempty"`
}
type EndpointLog ¶
type HelmChartStatusPayload ¶
type HelmChartStatusPayload struct {
Statuses []portainer.PolicyChartStatus `json:"chartStatuses"`
}
type ImageCommandData ¶
type ImageCommandData struct {
ImageName string
ImageRemoveOptions image.RemoveOptions
ImageOperation string
}
type LiveLogCollector ¶
type LiveLogCollector struct {
// contains filtered or unexported fields
}
func StartNewLiveLogCollector ¶
func StartNewLiveLogCollector(containerName, since, until, tail string) (*LiveLogCollector, error)
type LogCommandData ¶
type MetaFields ¶
type NonOkResponseError ¶
type NonOkResponseError struct {
// contains filtered or unexported fields
}
func (*NonOkResponseError) Error ¶
func (e *NonOkResponseError) Error() string
type NormalStackCommandData ¶
type Option ¶
type Option func(*options)
func WithDockerSnapshotter ¶
func WithDockerSnapshotter(snapshotter DockerSnapshotter) Option
func WithGPUOperator ¶
func WithVersion ¶
type PolicyHelmCharts ¶
type PolicyHelmCharts struct {
PolicyChartBundles []portainer.PolicyChartBundle `json:"policyChartBundles"`
RestoreSettingsBundle portainer.RestoreSettingsBundle `json:"restoreSettingsBundle"`
}
type PolicyStatesCommandPayload ¶
type PolicyStatesCommandPayload = portainer.PolicyStatesAsyncPayload
PolicyStatesCommandPayload is the value of an async "policyStates" command. Aliased from portainer.PolicyStatesAsyncPayload for local use.
type PollStatusResponse ¶
type PollStatusResponse struct {
Status string `json:"status"`
Port int `json:"port"`
Schedules []agent.Schedule `json:"schedules"`
CheckinInterval float64 `json:"checkin"`
Credentials string `json:"credentials"`
Stacks []StackStatus `json:"stacks"`
EdgeConfigurations map[EdgeConfigID]EdgeConfigStateType `json:"edge_configurations"`
PolicyChartSummaries []portainer.PolicyChartSummary `json:"policy_chart_summaries"`
// PolicyStates is a pointer so the agent can distinguish "new server sent an
// empty list (all policies deleted → remove all handlers)" from "old server
// omitted the field (use legacy per-chart path)". A nil pointer means the
// field was absent; a non-nil pointer to an empty slice means new server,
// no active policies.
PolicyStates *[]portainer.PolicyDesiredState `json:"policyStates,omitempty"`
AlertRules []pkgmetrics.EdgeAlertRule `json:"alert_rules"`
AlertRulesYAML string `json:"alert_rules_yaml,omitempty"`
// Async mode only
EndpointID int `json:"endpointID"`
PingInterval time.Duration `json:"pingInterval"`
SnapshotInterval time.Duration `json:"snapshotInterval"`
CommandInterval time.Duration `json:"commandInterval"`
AsyncCommands []AsyncCommand `json:"commands"`
}
type PortainerAsyncClient ¶
type PortainerAsyncClient struct {
// contains filtered or unexported fields
}
PortainerAsyncClient is used to execute HTTP requests using only the /api/entrypoint/async api endpoint
func NewPortainerAsyncClient ¶
func NewPortainerAsyncClient( serverAddress string, setEIDFn setEndpointIDFn, getEIDFn getEndpointIDFn, edgeID string, edgeKey string, containerPlatform agent.ContainerPlatform, metaFields agent.EdgeMetaFields, httpClient *edgeHTTPClient, opts ...Option, ) *PortainerAsyncClient
NewPortainerAsyncClient returns a pointer to a new PortainerAsyncClient instance
func (*PortainerAsyncClient) DeleteEdgeStackStatus ¶
func (client *PortainerAsyncClient) DeleteEdgeStackStatus(edgeStackID int) error
func (*PortainerAsyncClient) EnqueueLogCollectionForStack ¶
func (client *PortainerAsyncClient) EnqueueLogCollectionForStack(logCmd LogCommandData)
func (*PortainerAsyncClient) GetCharts ¶
func (client *PortainerAsyncClient) GetCharts(chartNames []string) ([]portainer.PolicyChartBundle, portainer.RestoreSettingsBundle, error)
GetCharts retrieves the chart contents for the specified charts from the Portainer server
func (*PortainerAsyncClient) GetEdgeConfig ¶
func (client *PortainerAsyncClient) GetEdgeConfig(id EdgeConfigID) (*EdgeConfig, error)
func (*PortainerAsyncClient) GetEdgeStackConfig ¶
func (client *PortainerAsyncClient) GetEdgeStackConfig(edgeStackID int, version *int) (*edge.StackPayload, error)
GetEdgeStackConfig retrieves the configuration associated to an Edge stack
func (*PortainerAsyncClient) GetEnvironmentID ¶
func (client *PortainerAsyncClient) GetEnvironmentID() (portainer.EndpointID, error)
func (*PortainerAsyncClient) GetEnvironmentStatus ¶
func (client *PortainerAsyncClient) GetEnvironmentStatus(flags ...string) (*PollStatusResponse, error)
func (*PortainerAsyncClient) ReportPolicyStatuses ¶
func (client *PortainerAsyncClient) ReportPolicyStatuses(statuses []portainer.PolicyActualState) error
ReportPolicyStatuses stores per-policy status in the async snapshot for delivery on the next async poll. Async agents do not make per-request HTTP calls.
func (*PortainerAsyncClient) SetAlertState ¶
func (client *PortainerAsyncClient) SetAlertState(_ *pkgmetrics.EdgeAlertState)
func (*PortainerAsyncClient) SetChartsResponse ¶
func (client *PortainerAsyncClient) SetChartsResponse(chart *PolicyHelmCharts)
func (*PortainerAsyncClient) SetEdgeConfigState ¶
func (client *PortainerAsyncClient) SetEdgeConfigState(id EdgeConfigID, state EdgeConfigStateType) error
func (*PortainerAsyncClient) SetEdgeJobStatus ¶
func (client *PortainerAsyncClient) SetEdgeJobStatus(edgeJobStatus agent.EdgeJobStatus) error
SetEdgeJobStatus sends the jobID log to the Portainer server
func (*PortainerAsyncClient) SetEdgeStackStatus ¶
func (client *PortainerAsyncClient) SetEdgeStackStatus(edgeStackID, version int, edgeStackStatus portainer.EdgeStackStatusType, rollbackTo *int, err string) error
SetEdgeStackStatus updates the status of an Edge stack on the Portainer server
func (*PortainerAsyncClient) SetLastCommandTimestamp ¶
func (client *PortainerAsyncClient) SetLastCommandTimestamp(timestamp time.Time)
func (*PortainerAsyncClient) SetPendingCommand ¶
func (client *PortainerAsyncClient) SetPendingCommand(id portainer.EdgeStackID, version int, timestamp time.Time)
SetPendingCommand stores the latest command timestamp for a given stack ID
func (*PortainerAsyncClient) SetTimeout ¶
func (client *PortainerAsyncClient) SetTimeout(t time.Duration)
func (*PortainerAsyncClient) UpdatePolicyChartStatuses ¶
func (client *PortainerAsyncClient) UpdatePolicyChartStatuses(statuses []portainer.PolicyChartStatus) error
type PortainerClient ¶
type PortainerClient interface {
GetEnvironmentID() (portainer.EndpointID, error)
GetEnvironmentStatus(flags ...string) (*PollStatusResponse, error)
GetEdgeStackConfig(edgeStackID int, version *int) (*edge.StackPayload, error)
SetEdgeStackStatus(edgeStackID, version int, edgeStackStatus portainer.EdgeStackStatusType, rollbackTo *int, errMessage string) error
SetEdgeJobStatus(edgeJobStatus agent.EdgeJobStatus) error
GetEdgeConfig(id EdgeConfigID) (*EdgeConfig, error)
SetEdgeConfigState(id EdgeConfigID, state EdgeConfigStateType) error
SetTimeout(t time.Duration)
SetLastCommandTimestamp(timestamp time.Time)
EnqueueLogCollectionForStack(logCmd LogCommandData)
GetCharts(chartNames []string) ([]portainer.PolicyChartBundle, portainer.RestoreSettingsBundle, error)
UpdatePolicyChartStatuses(statuses []portainer.PolicyChartStatus) error
ReportPolicyStatuses(statuses []portainer.PolicyActualState) error
SetAlertState(state *pkgmetrics.EdgeAlertState)
}
func NewPortainerClient ¶
func NewPortainerClient(serverAddress string, setEIDFn setEndpointIDFn, getEIDFn getEndpointIDFn, edgeID string, edgeKey string, edgeAsyncMode bool, agentPlatform agent.ContainerPlatform, metaFields agent.EdgeMetaFields, httpClient *edgeHTTPClient, gpuOperator bool) PortainerClient
NewPortainerClient returns a pointer to a new PortainerClient instance
type PortainerEdgeClient ¶
type PortainerEdgeClient struct {
// contains filtered or unexported fields
}
PortainerEdgeClient is used to execute HTTP requests against the Portainer API
func NewPortainerEdgeClient ¶
func NewPortainerEdgeClient( serverAddress string, setEIDFn setEndpointIDFn, getEIDFn getEndpointIDFn, edgeID string, agentPlatform agent.ContainerPlatform, metaFields agent.EdgeMetaFields, httpClient *edgeHTTPClient, opts ...Option, ) *PortainerEdgeClient
NewPortainerEdgeClient returns a pointer to a new PortainerEdgeClient instance
func (*PortainerEdgeClient) EnqueueLogCollectionForStack ¶
func (client *PortainerEdgeClient) EnqueueLogCollectionForStack(logCmd LogCommandData)
func (*PortainerEdgeClient) GetCharts ¶
func (client *PortainerEdgeClient) GetCharts(chartNames []string) ([]portainer.PolicyChartBundle, portainer.RestoreSettingsBundle, error)
GetCharts retrieves the chart contents for the specified charts from the Portainer server
func (*PortainerEdgeClient) GetEdgeConfig ¶
func (client *PortainerEdgeClient) GetEdgeConfig(id EdgeConfigID) (*EdgeConfig, error)
func (*PortainerEdgeClient) GetEdgeStackConfig ¶
func (client *PortainerEdgeClient) GetEdgeStackConfig(edgeStackID int, version *int) (*edge.StackPayload, error)
GetEdgeStackConfig retrieves the configuration associated to an Edge stack
func (*PortainerEdgeClient) GetEnvironmentID ¶
func (client *PortainerEdgeClient) GetEnvironmentID() (portainer.EndpointID, error)
func (*PortainerEdgeClient) GetEnvironmentStatus ¶
func (client *PortainerEdgeClient) GetEnvironmentStatus(flags ...string) (*PollStatusResponse, error)
func (*PortainerEdgeClient) ProcessAsyncCommands ¶
func (client *PortainerEdgeClient) ProcessAsyncCommands() error
func (*PortainerEdgeClient) ReportPolicyStatuses ¶
func (client *PortainerEdgeClient) ReportPolicyStatuses(statuses []portainer.PolicyActualState) error
func (*PortainerEdgeClient) SetAlertState ¶
func (client *PortainerEdgeClient) SetAlertState(state *pkgmetrics.EdgeAlertState)
SetAlertState stores the JSON-serialised alert state for inclusion in the next poll request as an HTTP header.
WARNING: the header value is unbounded in size. With many alert rules or verbose reload-error text the payload may exceed the header-size limit of an intermediate reverse proxy (commonly 8 KB per header). This should be migrated to a dedicated request-body field in a future change.
func (*PortainerEdgeClient) SetEdgeConfigState ¶
func (client *PortainerEdgeClient) SetEdgeConfigState(id EdgeConfigID, state EdgeConfigStateType) error
func (*PortainerEdgeClient) SetEdgeJobStatus ¶
func (client *PortainerEdgeClient) SetEdgeJobStatus(edgeJobStatus agent.EdgeJobStatus) error
SetEdgeJobStatus sends the jobID log to the Portainer server
func (*PortainerEdgeClient) SetEdgeStackStatus ¶
func (client *PortainerEdgeClient) SetEdgeStackStatus( edgeStackID, version int, edgeStackStatus portainer.EdgeStackStatusType, rollbackTo *int, error string, ) error
SetEdgeStackStatus updates the status of an Edge stack on the Portainer server
func (*PortainerEdgeClient) SetLastCommandTimestamp ¶
func (client *PortainerEdgeClient) SetLastCommandTimestamp(timestamp time.Time)
func (*PortainerEdgeClient) SetTimeout ¶
func (client *PortainerEdgeClient) SetTimeout(t time.Duration)
func (*PortainerEdgeClient) UpdatePolicyChartStatuses ¶
func (client *PortainerEdgeClient) UpdatePolicyChartStatuses(statuses []portainer.PolicyChartStatus) error
type StackStatus ¶
type StackStatus struct {
ID int
Version int
Name string // used in async mode
CommandOperation string // used in async mode
// ForceRedeploy is used to indicate that the stack should be redeployed
// even if the version is the same this value is set by the server
ForceRedeploy bool
// RepullImage is used to indicate that the image should be re-pulled
// during the next deployment of the stack
RePullImage bool
}