fieldagent

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2026 License: EPL-2.0 Imports: 52 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DeprovisionScopeAll   = "all"
	DeprovisionScopeLocal = "local"
)
View Source
const (
	ExecTypeStdin      byte = 0
	ExecTypeStdout     byte = 1
	ExecTypeStderr     byte = 2
	ExecTypeControl    byte = 3
	ExecTypeClose      byte = 4
	ExecTypeActivation byte = 5
)

ExecMessageType constants

View Source
const (
	LogTypeLogLine  byte = 6
	LogTypeLogStart byte = 7
	LogTypeLogStop  byte = 8
	LogTypeLogError byte = 9
)

LogMessageType constants

View Source
const ControllerSessionMaxDuration = 24 * time.Hour

ControllerSessionMaxDuration is the hard cap for controller-attached log/exec sessions on the agent.

Variables

This section is empty.

Functions

func ApplyDesiredRuntimeClasses added in v1.1.0

func ApplyDesiredRuntimeClasses(cfg *config.Config, items []*models.ControllerRuntimeClass) error

ApplyDesiredRuntimeClasses applies fleet RuntimeClasses on the edgelet engine using the local persist path (source=managed). Docker and podman keep the desired snapshot and skip apply so the node stays healthy.

func ConfigureRegisterTestClient

func ConfigureRegisterTestClient(baseURL string, httpClient *http.Client)

ConfigureRegisterTestClient wires a test HTTP client for controller/register calls.

func ConfigureRegisterTestRuntime

func ConfigureRegisterTestRuntime(ctx context.Context, connected bool)

ConfigureRegisterTestRuntime wires field agent state for controller register integration tests.

func IsControllerEndpointMissing added in v1.1.0

func IsControllerEndpointMissing(err error) bool

IsControllerEndpointMissing reports a 404 for an unknown controller command path.

func IsControllerNotReady added in v1.0.2

func IsControllerNotReady(err error) bool

IsControllerNotReady reports readiness probe 503 responses.

func IsLegacyControllerAuthError added in v1.0.2

func IsLegacyControllerAuthError(err error) bool

IsLegacyControllerAuthError reports legacy 401 responses without structured codes.

func IsNonRetryableAgentAuthError added in v1.0.2

func IsNonRetryableAgentAuthError(err error) bool

IsNonRetryableAgentAuthError reports structured agent 401 auth failures.

func IsRetryableControllerError added in v1.0.2

func IsRetryableControllerError(err error) bool

IsRetryableControllerError reports whether the error should be retried.

func MarkControllerRegisterSucceededForTest

func MarkControllerRegisterSucceededForTest(uuid string)

MarkControllerRegisterSucceededForTest marks a controller UUID as registered in memory.

func ParseControllerAPIError added in v1.0.2

func ParseControllerAPIError(status int, body string) error

ParseControllerAPIError parses a controller error response body.

func ReadFile

func ReadFile(filename string) (json.RawMessage, int64, error)

ReadFile reads data from a cache file and validates checksum

func ReadFileAsArray

func ReadFileAsArray(filename string) ([]map[string]any, int64, error)

ReadFileAsArray reads a cached file as a JSON array

func ResetControllerRegisterStateForTest

func ResetControllerRegisterStateForTest()

ResetControllerRegisterStateForTest clears in-memory register markers.

func SaveFile

func SaveFile(data any, filename string) error

SaveFile saves data to a cache file with checksum

Types

type APIClient

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

APIClient handles all HTTP communication with the controller

func NewAPIClient

func NewAPIClient() (*APIClient, error)

NewAPIClient creates a new API client for controller communication

func (*APIClient) Delete

func (c *APIClient) Delete(ctx context.Context, command string) error

Delete performs a DELETE request

func (*APIClient) GetJSON

func (c *APIClient) GetJSON(ctx context.Context, command string, result any) error

GetJSON performs a GET request and unmarshals JSON response

func (*APIClient) PatchJSON

func (c *APIClient) PatchJSON(ctx context.Context, command string, body any) error

PatchJSON performs a PATCH request with JSON body

func (*APIClient) Ping

func (c *APIClient) Ping(ctx context.Context) (bool, error)

Ping pings the controller to check connectivity

func (*APIClient) PostJSON

func (c *APIClient) PostJSON(ctx context.Context, command string, body any, result any) error

PostJSON performs a POST request with JSON body

func (*APIClient) PutJSON

func (c *APIClient) PutJSON(ctx context.Context, command string, body any) error

PutJSON performs a PUT request with JSON body

func (*APIClient) Request

func (c *APIClient) Request(ctx context.Context, command string, requestType RequestType, queryParams map[string]string, body any) (map[string]any, error)

Request performs an HTTP request to the controller with retry logic

type CacheFile

type CacheFile struct {
	Checksum  string          `json:"checksum"`
	Timestamp int64           `json:"timestamp"`
	Data      json.RawMessage `json:"data"`
}

CacheFile represents a cached file with checksum and timestamp

type ConnectionState

type ConnectionState int

ConnectionState represents the WebSocket connection state

const (
	StateDisconnected ConnectionState = iota
	StateConnecting
	StateConnected
	StatePending // Connected but waiting for user
	StateActive  // Connected and paired with user
)

type ControllerAPIError added in v1.0.2

type ControllerAPIError struct {
	StatusCode int
	ErrorKind  string // JSON "error" field (e.g. "Unauthorized")
	Code       string
	Message    string
	Retryable  bool
	Body       string
	Legacy     bool // true when no code/retryable (name+message only)
}

ControllerAPIError represents a structured error response from the controller.

func (*ControllerAPIError) Error added in v1.0.2

func (e *ControllerAPIError) Error() string

type ExecSession

type ExecSession struct {
	SessionID        string `json:"sessionId"`
	MicroserviceUUID string `json:"microserviceUuid"`
	Status           string `json:"status"` // PENDING, ACTIVE
	AgentConnected   bool   `json:"agentConnected"`
}

ExecSession represents a controller exec session row from poll.

type ExecSessionCallback

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

ExecSessionCallback handles Docker exec session I/O and bridges it to WebSocket

func NewExecSessionCallback

func NewExecSessionCallback(microserviceUUID, execID string) *ExecSessionCallback

NewExecSessionCallback creates a new ExecSessionCallback

func (*ExecSessionCallback) Close

func (c *ExecSessionCallback) Close()

Close closes the exec session callback

func (*ExecSessionCallback) GetExecID

func (c *ExecSessionCallback) GetExecID() string

GetExecID returns the exec session ID

func (*ExecSessionCallback) GetStderrWriter

func (c *ExecSessionCallback) GetStderrWriter() io.Writer

GetStderrWriter returns the stderr writer for ProcessManager

func (*ExecSessionCallback) GetStdin

func (c *ExecSessionCallback) GetStdin() io.WriteCloser

GetStdin returns the stdin writer

func (*ExecSessionCallback) GetStdinReader

func (c *ExecSessionCallback) GetStdinReader() io.Reader

GetStdinReader returns the stdin reader for ProcessManager

func (*ExecSessionCallback) GetStdoutWriter

func (c *ExecSessionCallback) GetStdoutWriter() io.Writer

GetStdoutWriter returns the stdout writer for ProcessManager

func (*ExecSessionCallback) IsRunning

func (c *ExecSessionCallback) IsRunning() bool

IsRunning returns whether the callback is running

func (*ExecSessionCallback) OnActivation

func (c *ExecSessionCallback) OnActivation()

OnActivation is called when the exec session is activated

func (*ExecSessionCallback) OnComplete

func (c *ExecSessionCallback) OnComplete()

OnComplete is called when the exec session completes

func (*ExecSessionCallback) OnError

func (c *ExecSessionCallback) OnError(err error)

OnError is called when the exec session encounters an error

func (*ExecSessionCallback) SetExecID

func (c *ExecSessionCallback) SetExecID(execID string)

SetExecID sets the exec session ID

func (*ExecSessionCallback) SetOnCloseHandler

func (c *ExecSessionCallback) SetOnCloseHandler(handler func())

SetOnCloseHandler sets the handler for close events

func (*ExecSessionCallback) SetOnErrorHandler

func (c *ExecSessionCallback) SetOnErrorHandler(handler func([]byte))

SetOnErrorHandler sets the handler for error data

func (*ExecSessionCallback) SetOnInputHandler

func (c *ExecSessionCallback) SetOnInputHandler(handler func([]byte))

SetOnInputHandler sets the handler for input data

func (*ExecSessionCallback) SetOnOutputHandler

func (c *ExecSessionCallback) SetOnOutputHandler(handler func([]byte))

SetOnOutputHandler sets the handler for output data

func (*ExecSessionCallback) WriteInput

func (c *ExecSessionCallback) WriteInput(data []byte) error

WriteInput writes input data to stdin

type ExecSessionInfo

type ExecSessionInfo struct {
	Session  *ExecSession
	Callback *ExecSessionCallback
}

ExecSessionInfo tracks a local controller exec attachment.

type ExecSessionManager

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

ExecSessionManager manages controller exec session attachments (log-session parity).

func GetExecSessionManager

func GetExecSessionManager() *ExecSessionManager

GetExecSessionManager returns the singleton ExecSessionManager instance.

func (*ExecSessionManager) FetchExecSessions

func (esm *ExecSessionManager) FetchExecSessions(ctx context.Context) ([]*ExecSession, error)

FetchExecSessions fetches exec sessions from the controller.

func (*ExecSessionManager) GetCallback

func (esm *ExecSessionManager) GetCallback(sessionID string) *ExecSessionCallback

GetCallback returns the exec callback for a session id.

func (*ExecSessionManager) HandleExecSessions

func (esm *ExecSessionManager) HandleExecSessions(fetchedSessions []*ExecSession)

HandleExecSessions reconciles local controller exec attachments with polled rows.

func (*ExecSessionManager) ListActiveControllerSessionIDs

func (esm *ExecSessionManager) ListActiveControllerSessionIDs(msUUID string) []string

ListActiveControllerSessionIDs returns sorted controller attachment session ids for one microservice.

func (*ExecSessionManager) SetProcessManager

func (esm *ExecSessionManager) SetProcessManager(pm *processmanager.ProcessManager)

SetProcessManager sets the ProcessManager instance (called by supervisor).

func (*ExecSessionManager) StopAllInteractiveForMicroservice

func (esm *ExecSessionManager) StopAllInteractiveForMicroservice(msUUID string)

StopAllInteractiveForMicroservice stops all exec attachments and runtime sessions for one MS.

func (*ExecSessionManager) StopExecSession

func (esm *ExecSessionManager) StopExecSession(sessionID string)

StopExecSession stops one controller exec attachment (thread-safe).

type ExecSessionWebSocketHandler

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

ExecSessionWebSocketHandler manages the WebSocket connection for exec sessions

func GetExecSessionWebSocketHandler

func GetExecSessionWebSocketHandler(sessionID, microserviceUUID string) *ExecSessionWebSocketHandler

GetExecSessionWebSocketHandler gets or creates an ExecSessionWebSocketHandler for a session.

func (*ExecSessionWebSocketHandler) Connect

func (h *ExecSessionWebSocketHandler) Connect() error

Connect establishes the WebSocket connection to the controller. Call Reset() before Connect() when starting a new exec session. No init pairing frame is sent.

func (*ExecSessionWebSocketHandler) Disconnect

func (h *ExecSessionWebSocketHandler) Disconnect()

Disconnect closes the WebSocket connection and resets handler state for reuse.

func (*ExecSessionWebSocketHandler) GetConnectionState

func (h *ExecSessionWebSocketHandler) GetConnectionState() ConnectionState

GetConnectionState returns the current connection state (for tests and diagnostics).

func (*ExecSessionWebSocketHandler) IsActive

func (h *ExecSessionWebSocketHandler) IsActive() bool

IsActive returns whether the exec session is active

func (*ExecSessionWebSocketHandler) IsConnected

func (h *ExecSessionWebSocketHandler) IsConnected() bool

IsConnected returns whether the WebSocket is connected

func (*ExecSessionWebSocketHandler) Reset

func (h *ExecSessionWebSocketHandler) Reset()

Reset tears down transport state and prepares the handler for a fresh Connect().

func (*ExecSessionWebSocketHandler) SendMessage

func (h *ExecSessionWebSocketHandler) SendMessage(msgType byte, data []byte) error

SendMessage sends a message to the controller with execId = sessionId. Output is buffered while disconnected or pending activation.

func (*ExecSessionWebSocketHandler) SetExecSessionManager

func (h *ExecSessionWebSocketHandler) SetExecSessionManager(esm *ExecSessionManager)

SetExecSessionManager sets the manager reference for session lifecycle callbacks.

type FieldAgent

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

FieldAgent handles all communication with the fog controller

func GetInstance

func GetInstance() *FieldAgent

GetInstance returns the singleton FieldAgent instance

func (*FieldAgent) Clear

func (fa *FieldAgent) Clear()

Clear clears all microservice data

func (*FieldAgent) Deprovision

func (fa *FieldAgent) Deprovision(clearCredentials bool) error

Deprovision deprovisions the agent clearCredentials=true skip controller request

func (*FieldAgent) DeprovisionWithOptions added in v1.1.0

func (fa *FieldAgent) DeprovisionWithOptions(clearCredentials bool, scope string, purgeVolumes bool) error

DeprovisionWithOptions deprovisions the agent with cleanup scope and optional persistent-volume purge. Automatic callers (delete-node, Edge Guard, status-auth) must pass purgeVolumes=false so volumes/data and volumes/shared remount later.

func (*FieldAgent) DeprovisionWithScope

func (fa *FieldAgent) DeprovisionWithScope(clearCredentials bool, scope string) error

DeprovisionWithScope deprovisions the agent and controls cleanup scope. scope=all removes managed+local workloads; scope=local preserves local workloads. Persistent VOLUME trees are preserved unless purgeVolumes is set via DeprovisionWithOptions.

func (*FieldAgent) FindLatestMicroserviceByUUID

func (fa *FieldAgent) FindLatestMicroserviceByUUID(uuid string) *models.Microservice

FindLatestMicroserviceByUUID finds a microservice by UUID

func (*FieldAgent) FogKnowledgeStatus added in v1.1.0

func (fa *FieldAgent) FogKnowledgeStatus() (knowledgeStatus string, activeKnowledge int, knowledgeLastUpdate int64)

FogKnowledgeStatus returns additive fog and local knowledge status keys. knowledgeStatus is a JSON string; activeKnowledge is the managed count only.

func (*FieldAgent) GetContainerConfig

func (fa *FieldAgent) GetContainerConfig(microserviceUUID string) (string, bool)

GetContainerConfig returns the container config string for a microservice UUID

func (*FieldAgent) GetCurrentMicroservices

func (fa *FieldAgent) GetCurrentMicroservices() []*models.Microservice

GetCurrentMicroservices returns the current microservices (same as latest for now)

func (*FieldAgent) GetLatestMicroservices

func (fa *FieldAgent) GetLatestMicroservices() []*models.Microservice

GetLatestMicroservices returns the latest microservices from the controller

func (*FieldAgent) GetModuleIndex

func (fa *FieldAgent) GetModuleIndex() int

GetModuleIndex returns the module index

func (*FieldAgent) GetName

func (fa *FieldAgent) GetName() string

GetName returns the module name

func (*FieldAgent) GetRegistry

func (fa *FieldAgent) GetRegistry(id int) *models.Registry

GetRegistry returns a registry by ID

func (*FieldAgent) InstanceGPSConfigUpdated

func (fa *FieldAgent) InstanceGPSConfigUpdated() error

InstanceGPSConfigUpdated sends dedicated GPS config updates to the controller.

func (*FieldAgent) IsControllerConnected

func (fa *FieldAgent) IsControllerConnected(fromFile bool) bool

IsControllerConnected reports whether live controller I/O should proceed. Cache reads pass fromFile=true; live paths use cached reachability from ping workers.

func (*FieldAgent) NotProvisioned

func (fa *FieldAgent) NotProvisioned() bool

NotProvisioned checks if the agent is not provisioned

func (*FieldAgent) OnProcessManagerReady

func (fa *FieldAgent) OnProcessManagerReady()

OnProcessManagerReady notifies the process manager after cache bootstrap when PM is wired later in supervisor startup.

func (*FieldAgent) PostStatusHelper

func (fa *FieldAgent) PostStatusHelper()

PostStatusHelper posts the fog status to the controller Exported for use by Edge Guard to immediately notify controller of hardware changes

func (*FieldAgent) Provision

func (fa *FieldAgent) Provision(key string) error

Provision provisions the agent with the controller

func (*FieldAgent) SetControllerStatus

func (fa *FieldAgent) SetControllerStatus(status models.ControllerStatus)

SetControllerStatus updates the agent controller connection status.

func (*FieldAgent) SetCurrentMicroservices

func (fa *FieldAgent) SetCurrentMicroservices(microservices []*models.Microservice)

SetCurrentMicroservices sets the current microservices

func (*FieldAgent) SetKnowledgeManager added in v1.1.0

func (fa *FieldAgent) SetKnowledgeManager(m *knowledgemanager.Manager)

SetKnowledgeManager sets the Knowledge manager used for fleet-desired Knowledge ingest.

func (*FieldAgent) SetModelManager added in v1.1.0

func (fa *FieldAgent) SetModelManager(m *modelmanager.Manager)

SetModelManager sets the Model manager used for fleet-desired Model ingest.

func (*FieldAgent) SetOnConfigsUpdate

func (fa *FieldAgent) SetOnConfigsUpdate(callback func(changedUUIDs []string) error)

SetOnConfigsUpdate sets the callback when microservice config content changes.

func (*FieldAgent) SetOnMicroservicesUpdate

func (fa *FieldAgent) SetOnMicroservicesUpdate(callback func([]*models.Microservice) error)

SetOnMicroservicesUpdate sets the callback for microservices updates

func (*FieldAgent) SetOnRegistriesUpdate

func (fa *FieldAgent) SetOnRegistriesUpdate(callback func([]*models.Registry) error)

SetOnRegistriesUpdate sets the callback for registries updates

func (*FieldAgent) SetProcessManager

func (fa *FieldAgent) SetProcessManager(pm *processmanager.ProcessManager)

SetProcessManager sets the ProcessManager reference

func (*FieldAgent) Start

func (fa *FieldAgent) Start() error

Start starts the FieldAgent and all background workers

func (*FieldAgent) Stop

func (fa *FieldAgent) Stop() error

Stop stops the FieldAgent and all background workers

func (*FieldAgent) SyncControllerRegister

func (fa *FieldAgent) SyncControllerRegister(force bool) bool

SyncControllerRegister upserts the controller microservice. When force is false, skips if register already succeeded for this UUID. When force is true, always attempts upsert when preconditions are met (e.g. after CP patch apply).

func (*FieldAgent) Update

func (fa *FieldAgent) Update() error

Update updates the FieldAgent when configuration changes. Most workers re-read config on every tick; upgradeScanWorker is notified explicitly when upgradeScanFrequency changes so its timer is reset immediately. NewAPIClient() is moved into the background goroutine so the SIGHUP handler goroutine is never blocked by DNS resolution for the new controller URL.

type LogConnectionState

type LogConnectionState int

LogConnectionState represents the WebSocket connection state

const (
	LogStateDisconnected LogConnectionState = iota
	LogStateConnecting
	LogStateConnected
	LogStatePending // Connected but waiting for LOG_START
	LogStateActive  // Connected and streaming logs
)

type LogSession

type LogSession struct {
	SessionID        string `json:"sessionId"`
	MicroserviceUUID string `json:"microserviceUuid,omitempty"`
	IofogUUID        string `json:"iofogUuid,omitempty"`
	Status           string `json:"status"` // ACTIVE, PENDING, etc.
}

LogSession represents a log session from the controller

type LogSessionInfo

type LogSessionInfo struct {
	Session     *LogSession
	ContainerID string
	IsStreaming bool
	// contains filtered or unexported fields
}

LogSessionInfo tracks information about an active log session

type LogSessionManager

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

LogSessionManager manages active log sessions

func GetLogSessionManager

func GetLogSessionManager() *LogSessionManager

GetLogSessionManager returns the singleton LogSessionManager instance.

func (*LogSessionManager) FetchLogSessions

func (lsm *LogSessionManager) FetchLogSessions(ctx context.Context) ([]*LogSession, error)

FetchLogSessions fetches log sessions from the controller

func (*LogSessionManager) HandleLogSessions

func (lsm *LogSessionManager) HandleLogSessions(fetchedSessions []*LogSession)

HandleLogSessions handles fetched log sessions from controller

func (*LogSessionManager) HandleWebSocketTransportClose

func (lsm *LogSessionManager) HandleWebSocketTransportClose(sessionID string)

HandleWebSocketTransportClose stops log tailing when the controller WebSocket drops. The session row is retained so HandleLogSessions can reconnect on the next poll.

func (*LogSessionManager) SetEngine

func (lsm *LogSessionManager) SetEngine(e engine.ContainerEngine)

SetEngine sets the ContainerEngine used to look up containers and tail their logs. Must be called before log session streaming starts (from supervisor after engine init).

func (*LogSessionManager) SetProcessManager

func (lsm *LogSessionManager) SetProcessManager(pm *processmanager.ProcessManager)

SetProcessManager sets the ProcessManager instance (called by supervisor).

func (*LogSessionManager) StartLogStreamingOnActivation

func (lsm *LogSessionManager) StartLogStreamingOnActivation(sessionID string, tailConfigMap map[string]any)

StartLogStreamingOnActivation starts log streaming when WebSocket becomes active This method is called from LogSessionWebSocketHandler when it receives LOG_START

func (*LogSessionManager) StartWorker

func (lsm *LogSessionManager) StartWorker(ctx context.Context)

StartWorker starts the background worker that periodically fetches and handles log sessions

func (*LogSessionManager) StopLogSession

func (lsm *LogSessionManager) StopLogSession(sessionID string)

StopLogSession stops a log session (thread-safe)

type LogSessionWebSocketHandler

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

LogSessionWebSocketHandler manages the WebSocket connection for log sessions

func GetLogSessionWebSocketHandler

func GetLogSessionWebSocketHandler(sessionID, microserviceUUID, iofogUUID string, isMicroserviceLog bool) *LogSessionWebSocketHandler

GetLogSessionWebSocketHandler gets or creates a LogSessionWebSocketHandler for a session

func (*LogSessionWebSocketHandler) Connect

func (h *LogSessionWebSocketHandler) Connect() error

Connect establishes the WebSocket connection to the controller. Call Reset() before Connect() when reusing a handler for a new session.

func (*LogSessionWebSocketHandler) Disconnect

func (h *LogSessionWebSocketHandler) Disconnect()

Disconnect closes the WebSocket connection and resets handler state for reuse.

func (*LogSessionWebSocketHandler) DisconnectWithReason

func (h *LogSessionWebSocketHandler) DisconnectWithReason(reason string)

DisconnectWithReason closes the WebSocket with a specific close reason before reset.

func (*LogSessionWebSocketHandler) GetConnectionState

func (h *LogSessionWebSocketHandler) GetConnectionState() LogConnectionState

GetConnectionState returns the current connection state (for tests and diagnostics).

func (*LogSessionWebSocketHandler) IsActive

func (h *LogSessionWebSocketHandler) IsActive() bool

IsActive returns whether the log session is active

func (*LogSessionWebSocketHandler) IsConnected

func (h *LogSessionWebSocketHandler) IsConnected() bool

IsConnected returns whether the WebSocket is connected

func (*LogSessionWebSocketHandler) Reset

func (h *LogSessionWebSocketHandler) Reset()

Reset tears down transport state and prepares the handler for a fresh Connect().

func (*LogSessionWebSocketHandler) SendMessage

func (h *LogSessionWebSocketHandler) SendMessage(msgType byte, data []byte) error

SendMessage sends a log message to the controller. Output is buffered while disconnected or pending activation (exec-session parity).

func (*LogSessionWebSocketHandler) SetLogSessionManager

func (h *LogSessionWebSocketHandler) SetLogSessionManager(lsm *LogSessionManager)

SetLogSessionManager sets the LogSessionManager reference

type Orchestrator

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

Orchestrator wraps APIClient with additional methods

func NewOrchestrator

func NewOrchestrator(apiClient *APIClient) *Orchestrator

NewOrchestrator creates a new Orchestrator instance

func (*Orchestrator) GetControllerCert

func (o *Orchestrator) GetControllerCert(ctx context.Context) (string, error)

GetControllerCert gets the controller certificate from the controller Note: This uses an insecure connection to get the certificate when current cert is invalid

func (*Orchestrator) GetJSON

func (o *Orchestrator) GetJSON(ctx context.Context, command string, result any) error

GetJSON performs a GET request and returns JSON

func (*Orchestrator) Ping

func (o *Orchestrator) Ping(ctx context.Context) (bool, error)

Ping pings the IOFog controller

func (*Orchestrator) Provision

func (o *Orchestrator) Provision(ctx context.Context, key string) (map[string]any, error)

Provision does provisioning with the given key

func (*Orchestrator) Request

func (o *Orchestrator) Request(ctx context.Context, command string, requestType RequestType, queryParams map[string]string, body any) (map[string]any, error)

Request performs an HTTP request (wrapper around APIClient.Request)

func (*Orchestrator) Update

func (o *Orchestrator) Update() error

Update updates the orchestrator configuration

type RequestType

type RequestType string

RequestType represents HTTP request types

const (
	GET    RequestType = "GET"
	POST   RequestType = "POST"
	PUT    RequestType = "PUT"
	PATCH  RequestType = "PATCH"
	DELETE RequestType = "DELETE"
)

type State

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

State represents the current state of the FieldAgent

func NewState

func NewState() *State

NewState creates a new State instance

func (*State) GetControllerStatus

func (s *State) GetControllerStatus() models.ControllerStatus

GetControllerStatus returns the controller status

func (*State) GetLastCommandTime

func (s *State) GetLastCommandTime() int64

GetLastCommandTime returns the last command time

func (*State) GetLastGetChangesList

func (s *State) GetLastGetChangesList() int64

GetLastGetChangesList returns the last time changes were retrieved

func (*State) IsConnected

func (s *State) IsConnected() bool

IsConnected returns whether we're connected to the controller

func (*State) IsControllerVerified

func (s *State) IsControllerVerified() bool

IsControllerVerified returns whether the controller is verified

func (*State) IsInitialization

func (s *State) IsInitialization() bool

IsInitialization returns whether we're in initialization phase

func (*State) SetConnected

func (s *State) SetConnected(connected bool)

SetConnected sets the connected status

func (*State) SetControllerStatus

func (s *State) SetControllerStatus(status models.ControllerStatus)

SetControllerStatus sets the controller status

func (*State) SetControllerVerified

func (s *State) SetControllerVerified(verified bool)

SetControllerVerified sets the controller verified flag

func (*State) SetInitialization

func (s *State) SetInitialization(init bool)

SetInitialization sets the initialization flag

func (*State) SetLastCommandTime

func (s *State) SetLastCommandTime(timestamp int64)

SetLastCommandTime sets the last command time

func (*State) SetLastGetChangesList

func (s *State) SetLastGetChangesList(timestamp int64)

SetLastGetChangesList sets the last time changes were retrieved

func (*State) UpdateLastCommandTime

func (s *State) UpdateLastCommandTime()

UpdateLastCommandTime updates the last command time to current time

Jump to

Keyboard shortcuts

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