db

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 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 (
	// ManagedClustersTableName table name of managed clusters.
	ManagedClustersTableName = "managed_clusters"

	// ComplianceTableName table name of policy compliance status.
	ComplianceTableName = "compliance"
	// MinimalComplianceTable table name of minimal policy compliance status.
	MinimalComplianceTable = "aggregated_compliance"
	// LocalPolicySpecTableName table name of local policy spec.
	LocalPolicySpecTableName = "policies"

	// SubscriptionStatusesTableName table name of subscription-statuses.
	SubscriptionStatusesTableName = "subscription_statuses"
	// SubscriptionReportsTableName table name of subscription-reports.
	SubscriptionReportsTableName = "subscription_reports"

	// PlacementRulesTableName table name of placement-rules.
	PlacementRulesTableName = "placementrules"
	// PlacementsTableName table name of placements.
	PlacementsTableName = "placements"
	// PlacementDecisionsTableName table name of placement-decisions.
	PlacementDecisionsTableName = "placementdecisions"

	// 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"
	// ComplianceType unique type.
	ComplianceType = "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 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 sends a batch operation to the db and returns list of errors if there were any.
	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 to manage control info status.

type GenericBatchBuilder

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

GenericBatchBuilder is a generic interface for building a batch to update global objects information in db.

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 GenericStatusResourceDB

type GenericStatusResourceDB interface {
	BatchSenderDB
	// GetResourceIDToVersionByLeafHub returns a map from resource id to its resourceVersion.
	GetResourceIDToVersionByLeafHub(ctx context.Context, schema string, tableName string,
		leafHubName string) (map[string]string, error)
	NewGenericBatchBuilder(schema string, tableName string, leafHubName string) GenericBatchBuilder
}

GenericStatusResourceDB is the db interface required to manage generic status resources.

type LocalPoliciesStatusDB

type LocalPoliciesStatusDB interface {
	BatchSenderDB
	// GetLocalResourceIDToVersionByLeafHub returns a map from local resource id to its resourceVersion.
	GetLocalResourceIDToVersionByLeafHub(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 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 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 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

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