upstream

package
v1.0.756 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2024 License: Apache-2.0 Imports: 27 Imported by: 8

Documentation

Index

Constants

View Source
const (
	StatusAgentError = "agent-error"
	StatusError      = "error"
	StatusOK         = "ok"
	StatusLabel      = "status"
	AgentLabel       = "agent"
)
View Source
const AgentNameQueryParam = "agent_name"

AgentNameQueryParam is the name of the query param that's used to authenticate an agent when using basic auth instead of access tokens.

View Source
const FKErrorIDCount = 10

Variables

This section is empty.

Functions

func AgentAuthMiddleware added in v1.0.356

func AgentAuthMiddleware(agentCache *cache.Cache) func(echo.HandlerFunc) echo.HandlerFunc

func DeleteHandler added in v1.0.283

func DeleteHandler(c echo.Context) error

PushHandler returns an echo handler that deletes the push data from the upstream.

func DeleteOnUpstream added in v1.0.283

func DeleteOnUpstream(ctx context.Context, req *PushData) error

DeleteOnUpstream deletes the given resources by agent on the upstream.

func GetOrCreateAgent added in v1.0.274

func GetOrCreateAgent(ctx context.Context, name string) (*models.Agent, error)

func InsertUpstreamMsg added in v1.0.274

func InsertUpstreamMsg(ctx context.Context, req *PushData) error

func NewPushHandler added in v1.0.608

func NewPushHandler(ringManager StatusRingManager) echo.HandlerFunc

NewPushHandler returns an echo handler that saves the push data from agents.

func PingHandler added in v1.0.337

func PingHandler(c echo.Context) error

func UpdateAgentLastReceived added in v1.0.337

func UpdateAgentLastReceived(ctx context.Context, id uuid.UUID) error

func UpdateAgentLastSeen added in v1.0.337

func UpdateAgentLastSeen(ctx context.Context, id uuid.UUID) error

Types

type ForeignKeyErrorSummary added in v1.0.740

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

func (*ForeignKeyErrorSummary) Add added in v1.0.742

func (fks *ForeignKeyErrorSummary) Add(id string)

func (ForeignKeyErrorSummary) Count added in v1.0.740

func (fks ForeignKeyErrorSummary) Count() int

func (ForeignKeyErrorSummary) MarshalJSON added in v1.0.740

func (fks ForeignKeyErrorSummary) MarshalJSON() ([]byte, error)

type PushData

type PushData struct {
	Canaries                     []models.Canary                      `json:"canaries,omitempty"`
	Checks                       []models.Check                       `json:"checks,omitempty"`
	Components                   []models.Component                   `json:"components,omitempty"`
	ConfigScrapers               []models.ConfigScraper               `json:"config_scrapers,omitempty"`
	ConfigAnalysis               []models.ConfigAnalysis              `json:"config_analysis,omitempty"`
	ConfigChanges                []models.ConfigChange                `json:"config_changes,omitempty"`
	ConfigItems                  []models.ConfigItem                  `json:"config_items,omitempty"`
	CheckStatuses                []models.CheckStatus                 `json:"check_statuses,omitempty"`
	ConfigRelationships          []models.ConfigRelationship          `json:"config_relationships,omitempty"`
	ComponentRelationships       []models.ComponentRelationship       `json:"component_relationships,omitempty"`
	ConfigComponentRelationships []models.ConfigComponentRelationship `json:"config_component_relationships,omitempty"`
	Topologies                   []models.Topology                    `json:"topologies,omitempty"`
	PlaybookActions              []models.PlaybookRunAction           `json:"playbook_actions,omitempty"`
	Artifacts                    []models.Artifact                    `json:"artifacts,omitempty"`
	JobHistory                   []models.JobHistory                  `json:"job_history,omitempty"`
}

PushData consists of data about changes to components, configs, analysis.

func NewPushData added in v1.0.362

func NewPushData[T models.DBTable](records []T) *PushData

func (*PushData) AddMetrics added in v1.0.317

func (p *PushData) AddMetrics(counter context.Counter)

func (*PushData) ApplyLabels

func (t *PushData) ApplyLabels(labels map[string]string)

ApplyLabels injects additional labels to the suitable fields

func (*PushData) Attributes added in v1.0.205

func (p *PushData) Attributes() map[string]any

func (*PushData) Count

func (t *PushData) Count() int

func (*PushData) PopulateAgentID

func (t *PushData) PopulateAgentID(id uuid.UUID)

PopulateAgentID sets agent_id on all the data

func (*PushData) ReplaceTopologyID

func (t *PushData) ReplaceTopologyID(id *uuid.UUID)

ReplaceTopologyID replaces the topology_id for all the components with the provided id.

func (PushData) Size added in v1.0.467

func (t PushData) Size() (int, error)

Size returns the size of JSON encoded pushdata in bytes

func (*PushData) String

func (p *PushData) String() string

type PushFKError added in v1.0.428

type PushFKError struct {
	IDs []string `json:"ids"`
}

func (*PushFKError) Empty added in v1.0.724

func (t *PushFKError) Empty() bool

type PushGroup added in v1.0.529

type PushGroup struct {
	Name   string
	Tables []pushableTable

	// DependsOn is a list of tables that need to be reconciled
	// for this group to be reconciled.
	DependsOn []string
}

PushGroup are a set of tables that need to be reconciled in order. If one fails, the rest are skipped.

type ReconcileSummary added in v1.0.529

type ReconcileSummary map[string]ReconcileTableSummary

func ReconcileAll added in v1.0.362

func ReconcileAll(ctx context.Context, config UpstreamConfig, batchSize int) ReconcileSummary

func ReconcileSome added in v1.0.362

func ReconcileSome(ctx context.Context, config UpstreamConfig, batchSize int, runOnly ...string) ReconcileSummary

func (*ReconcileSummary) AddSkipped added in v1.0.529

func (t *ReconcileSummary) AddSkipped(tables ...pushableTable)

func (*ReconcileSummary) AddStat added in v1.0.529

func (t *ReconcileSummary) AddStat(table string, success int, foreignKeyFailures ForeignKeyErrorSummary, err error)

func (ReconcileSummary) DidReconcile added in v1.0.529

func (t ReconcileSummary) DidReconcile(tables []string) bool

DidReconcile returns true if all of the given tables reconciled successfully.

func (ReconcileSummary) Error added in v1.0.529

func (t ReconcileSummary) Error() error

func (ReconcileSummary) GetSuccessFailure added in v1.0.529

func (t ReconcileSummary) GetSuccessFailure() (int, int)

type ReconcileTableSummary added in v1.0.529

type ReconcileTableSummary struct {
	Success   int                    `json:"success,omitempty"`
	FKeyError ForeignKeyErrorSummary `json:"foreign_error,omitempty"`
	Skipped   bool                   `json:"skipped,omitempty"`
	Error     *oops.OopsError        `json:"error,omitempty"`
}

type StatusRingManager added in v1.0.608

type StatusRingManager interface {
	// Add adds the given history to the corresponding status ring of the agent.
	// if the status ring doesn't exist then it creates a new one.
	Add(ctx context.Context, agentID string, history models.JobHistory)
}

StatusRingManager manages status rings for agent jobs.

func NewStatusRingStore added in v1.0.608

func NewStatusRingStore(evicted chan uuid.UUID) StatusRingManager

type UpstreamClient added in v1.0.192

type UpstreamClient struct {
	AgentName string
	*http.Client
}

func NewUpstreamClient added in v1.0.192

func NewUpstreamClient(config UpstreamConfig) *UpstreamClient

func (*UpstreamClient) Delete added in v1.0.283

func (t *UpstreamClient) Delete(ctx context.Context, msg *PushData) error

Delete performs hard delete on the given items from the upstream server.

func (*UpstreamClient) Ping added in v1.0.337

func (t *UpstreamClient) Ping(ctx context.Context) error

Ping sends a ping message to the upstream

func (*UpstreamClient) Push added in v1.0.192

func (t *UpstreamClient) Push(ctx context.Context, msg *PushData) error

Push uploads the given push message to the upstream server.

func (*UpstreamClient) PushArtifacts added in v1.0.316

func (t *UpstreamClient) PushArtifacts(ctx context.Context, artifactID uuid.UUID, reader io.ReadCloser) error

PushArtifacts uploads the given artifact to the upstream server.

type UpstreamConfig

type UpstreamConfig struct {
	AgentName          string
	Host               string
	InsecureSkipVerify bool
	Username           string
	Password           string
	Labels             []string
	Debug              bool
	Options            []func(c *http.Client)
}

func (*UpstreamConfig) IsPartiallyFilled

func (t *UpstreamConfig) IsPartiallyFilled() (bool, error)

func (*UpstreamConfig) LabelsMap

func (t *UpstreamConfig) LabelsMap() map[string]string

func (UpstreamConfig) String added in v1.0.259

func (t UpstreamConfig) String() string

func (*UpstreamConfig) Valid

func (t *UpstreamConfig) Valid() bool

Jump to

Keyboard shortcuts

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