client

package
v0.0.0-...-0369387 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2024 License: Zlib Imports: 30 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildHTTPClient

func BuildHTTPClient(timeout float64, options *agent.Options) *edgeHTTPClient

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

func (client *APIClient) GetEdgeKey(serverAddr string) (string, error)

GetEdgeKey executes a KeyInspect operation against the specified server

func (*APIClient) SetEdgeKey

func (client *APIClient) SetEdgeKey(serverAddr, key string) error

SetEdgeKey executes a KeyCreate operation against the specified server

type AsyncCommand

type AsyncCommand struct {
	ID         int                  `json:"id"`
	Type       string               `json:"type"`
	EndpointID portainer.EndpointID `json:"endpointID"`
	Timestamp  time.Time            `json:"timestamp"`
	Operation  string               `json:"op"`
	Path       string               `json:"path"`
	Value      interface{}          `json:"value"`
}

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"`
}

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 ContainerCommandData

type ContainerCommandData struct {
	ContainerName          string
	ContainerStartOptions  container.StartOptions
	ContainerRemoveOptions container.RemoveOptions
	ContainerOperation     string
}

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 EdgeJobData struct {
	ID                portainer.EdgeJobID
	CollectLogs       bool
	LogsStatus        portainer.EdgeJobLogsStatus
	CronExpression    string
	ScriptFileContent string
	Version           int
}

type EdgeStackLog

type EdgeStackLog struct {
	EdgeStackID portainer.EdgeStackID `json:"edgeStackID,omitempty"`
	Logs        []EndpointLog         `json:"logs,omitempty"`
}

type EndpointLog

type EndpointLog struct {
	DockerContainerID string `json:"dockerContainerID,omitempty"`
	StdOut            string `json:"stdOut,omitempty"`
	StdErr            string `json:"stdErr,omitempty"`
}

type ImageCommandData

type ImageCommandData struct {
	ImageName          string
	ImageRemoveOptions image.RemoveOptions
	ImageOperation     string
}

type LogCommandData

type LogCommandData struct {
	EdgeStackID   portainer.EdgeStackID
	EdgeStackName string
	Tail          int
}

type MetaFields

type MetaFields struct {
	EdgeGroupsIDs      []int `json:"edgeGroupsIds"`
	TagsIDs            []int `json:"tagsIds"`
	EnvironmentGroupID int   `json:"environmentGroupId"`
}

type NonOkResponseError

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

func (*NonOkResponseError) Error

func (e *NonOkResponseError) Error() string

type NormalStackCommandData

type NormalStackCommandData struct {
	Name             string
	StackFileContent string
	StackOperation   string
}

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"`

	// 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, containerPlatform agent.ContainerPlatform, metaFields agent.EdgeMetaFields, httpClient *edgeHTTPClient) *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) error

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) 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 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) SetTimeout

func (client *PortainerAsyncClient) SetTimeout(t time.Duration)

type PortainerClient

type PortainerClient interface {
	GetEnvironmentID() (portainer.EndpointID, error)
	GetEnvironmentStatus(flags ...string) (*PollStatusResponse, error)
	GetEdgeStackConfig(edgeStackID int, version *int) (*edge.StackPayload, error)
	SetEdgeStackStatus(edgeStackID 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) error
}

func NewPortainerClient

func NewPortainerClient(serverAddress string, setEIDFn setEndpointIDFn, getEIDFn getEndpointIDFn, edgeID string, edgeAsyncMode bool, agentPlatform agent.ContainerPlatform, metaFields agent.EdgeMetaFields, httpClient *edgeHTTPClient) 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) *PortainerEdgeClient

NewPortainerEdgeClient returns a pointer to a new PortainerEdgeClient instance

func (*PortainerEdgeClient) EnqueueLogCollectionForStack

func (client *PortainerEdgeClient) EnqueueLogCollectionForStack(logCmd LogCommandData) error

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) 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 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)

type StackStatus

type StackStatus struct {
	ID               int
	Version          int
	Name             string // used in async mode
	CommandOperation string // used in async mode
	ReadyRePullImage bool
}

type VolumeCommandData

type VolumeCommandData struct {
	VolumeName      string
	ForceRemove     bool
	VolumeOperation string
}

Jump to

Keyboard shortcuts

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