db

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2022 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// StatusSchema schema for status updates.
	StatusSchema = "status"
	// LocalStatusSchema schema for local status updates.
	LocalStatusSchema = "local_status"
	// LocalSpecSchema schema for local spec updates.
	LocalSpecSchema = "local_spec"
)

db schemas.

View Source
const (
	// ManagedClustersTable table name of managed clusters.
	ManagedClustersTable = "managed_clusters"
	// ComplianceTable table name of policy compliance status.
	ComplianceTable = "compliance"
	// MinimalComplianceTable table name of minimal policy compliance status.
	MinimalComplianceTable = "aggregated_compliance"
	// LocalPolicySpecTableName table name of local policy spec.
	LocalPolicySpecTableName = "policies"
	// LocalPlacementRulesTableName table name of local placement rules.
	LocalPlacementRulesTableName = "placementrules"
	// LeafHubHeartbeatsTableName table name for LH heartbeats.
	LeafHubHeartbeatsTableName = "leaf_hub_heartbeats"
)

table names.

View Source
const (
	// uuid unique type.
	UUID = "uuid"
	// jsonb unique type.
	Jsonb = "jsonb"
	// compliance type unique type.
	StatusComplianceType = "status.compliance_type"
)

unique db types.

View Source
const (
	// ErrorNone is default value when no error occurs.
	ErrorNone = "none"
)

default values.

Variables

This section is empty.

Functions

This section is empty.

Types

type AggregatedPoliciesStatusDB

type AggregatedPoliciesStatusDB interface {
	GetPolicyIDsByLeafHub(ctx context.Context, schema string, tableName string, leafHubName string) (set.Set, error)
	InsertOrUpdateAggregatedPolicyCompliance(ctx context.Context, schema string, tableName string, leafHubName string,
		policyID string, appliedClusters int, nonCompliantClusters int) error
	DeleteAllComplianceRows(ctx context.Context, schema string, tableName string, leafHubName string,
		policyID string) error
}

AggregatedPoliciesStatusDB is the db interface required by status transport bridge to manage aggregated policy info.

type BatchBuilder

type BatchBuilder interface {
	// Build builds the batch object.
	Build() interface{}
}

BatchBuilder is an interface to build a batch that can be used to be sent to db.

type BatchSenderDB

type BatchSenderDB interface {
	SendBatch(ctx context.Context, batch interface{}) error
}

BatchSenderDB is the db interface required for sending batch updates.

type ComplianceStatus

type ComplianceStatus string

ComplianceStatus represents the possible options for compliance status.

const (
	// NonCompliant non compliant state.
	NonCompliant ComplianceStatus = "non_compliant"
	// Compliant compliant state.
	Compliant ComplianceStatus = "compliant"
	// Unknown unknown compliance state.
	Unknown ComplianceStatus = "unknown"
)

compliance states.

type ControlInfoDB

type ControlInfoDB interface {
	// UpdateHeartbeat inserts or updates heartbeat for a leaf hub.
	UpdateHeartbeat(ctx context.Context, schema string, tableName string, leafHubName string) error
}

ControlInfoDB is the db interface required by status transport bridge to manage control info status.

type GenericLocalBatchBuilder

type GenericLocalBatchBuilder interface {
	BatchBuilder
	// Insert adds the given payload to the batch to be inserted to the db.
	Insert(payload interface{})
	// Update adds the given payload to the batch to be updated in the db.
	Update(payload interface{})
	// Delete adds the given id to the batch to be deleted from db.
	Delete(id string)
}

GenericLocalBatchBuilder is a generic interface for building a batch to update local objects information in db.

type LocalPoliciesStatusDB

type LocalPoliciesStatusDB interface {
	BatchSenderDB
	// GetDistinctIDAndVersion returns a map from resource id to its resourceVersion.
	GetDistinctIDAndVersion(ctx context.Context, schema string, tableName string,
		leafHubName string) (map[string]string, error)
	// NewGenericLocalBatchBuilder returns generic local batch builder.
	NewGenericLocalBatchBuilder(schema string, tableName string, leafHubName string) GenericLocalBatchBuilder
}

LocalPoliciesStatusDB is the db interface required by status bridge to manage local policies.

type ManagedClustersBatchBuilder

type ManagedClustersBatchBuilder interface {
	BatchBuilder
	// Insert adds the given (cluster payload, error string) to the batch to be inserted to the db.
	Insert(payload interface{}, errorString string)
	// Update adds the given arguments to the batch to update clusterName with the given payload in db.
	Update(clusterName string, payload interface{})
	// Delete adds delete statement to the batch to delete the given cluster from db.
	Delete(clusterName string)
}

ManagedClustersBatchBuilder is an interface for building a batch to update managed clusters information in db.

type ManagedClustersStatusDB

type ManagedClustersStatusDB interface {
	BatchSenderDB
	// GetManagedClustersByLeafHub returns a map from clusterName to its resourceVersion.
	GetManagedClustersByLeafHub(ctx context.Context, schema string, tableName string,
		leafHubName string) (map[string]string, error)
	// NewManagedClustersBatchBuilder returns managed clusters batch builder.
	NewManagedClustersBatchBuilder(schema string, tableName string, leafHubName string) ManagedClustersBatchBuilder
}

ManagedClustersStatusDB is the db interface required by status transport bridge to manage managed clusters status.

type PoliciesBatchBuilder

type PoliciesBatchBuilder interface {
	BatchBuilder
	// Insert adds the given (policyID, clusterName, errorString, compliance) to the batch to be inserted to the db.
	Insert(policyID string, clusterName string, errorString string, compliance ComplianceStatus)
	// Update adds the given (policyID, compliance) to the batch to be updated in the db.
	UpdatePolicyCompliance(policyID string, compliance ComplianceStatus)
	// Update adds the given (policyID, clusterName, compliance) to the batch to be updated in the db.
	UpdateClusterCompliance(policyID string, clusterName string, compliance ComplianceStatus)
	// DeletePolicy adds delete statement to the batch to delete the given policyID from db.
	DeletePolicy(policyID string)
	// DeleteClusterStatus adds delete statement to the batch to delete the given (policyID,clusterName) from db.
	DeleteClusterStatus(policyID string, clusterName string)
}

PoliciesBatchBuilder is an interface for building a batch to update policies status information in db.

type PoliciesStatusDB

type PoliciesStatusDB interface {
	BatchSenderDB
	// GetComplianceStatusByLeafHub returns a map of policies, each maps to a set of clusters.
	GetComplianceStatusByLeafHub(ctx context.Context, schema string, tableName string,
		leafHubName string) (map[string]*PolicyClustersSets, error)
	// GetNonCompliantClustersByLeafHub returns a map of policies, each maps to sets of (NonCompliant,Unknown) clusters.
	GetNonCompliantClustersByLeafHub(ctx context.Context, schema string, tableName string,
		leafHubName string) (map[string]*PolicyClustersSets, error)
	// NewPoliciesBatchBuilder returns policies status batch builder.
	NewPoliciesBatchBuilder(schema string, tableName string, leafHubName string) PoliciesBatchBuilder
}

PoliciesStatusDB is the db interface required by status transport bridge to manage policies status.

type PolicyClustersSets

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

PolicyClustersSets is a data structure to hold both non compliant clusters set and unknown clusters set.

func NewPolicyClusterSets

func NewPolicyClusterSets() *PolicyClustersSets

NewPolicyClusterSets creates a new instance of PolicyClustersSets.

func (*PolicyClustersSets) AddCluster

func (sets *PolicyClustersSets) AddCluster(clusterName string, complianceStatus ComplianceStatus)

AddCluster adds the given cluster name to the given compliance status clusters set.

func (*PolicyClustersSets) GetAllClusters

func (sets *PolicyClustersSets) GetAllClusters() set.Set

GetAllClusters returns the clusters set of a policy (union of compliant/nonCompliant/unknown clusters).

func (*PolicyClustersSets) GetClusters

func (sets *PolicyClustersSets) GetClusters(complianceStatus ComplianceStatus) set.Set

GetClusters returns the clusters set by compliance status.

type StatusTransportBridgeDB

type StatusTransportBridgeDB interface {
	GetPoolSize() int32
	Stop()

	ManagedClustersStatusDB
	PoliciesStatusDB
	AggregatedPoliciesStatusDB
	LocalPoliciesStatusDB
	ControlInfoDB
}

StatusTransportBridgeDB is the db interface required by status transport bridge.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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