postgres

package
v0.0.0-...-837eb61 Latest Latest
Warning

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

Go to latest
Published: May 2, 2024 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DestructiveReMigrateForTest

func DestructiveReMigrateForTest(cfg *config.Postgres) error

func Transact

func Transact(pg *Postgres, txFunc func(*DBTrans) error) error

Transact wraps your calls in a transaction. If the call should fail with an error it will perform a rollback. Otherwise the transaction will be committed.

Types

type DBTrans

type DBTrans struct {
	*gorp.Transaction
}

func (*DBTrans) StoreTelemetry

func (trans *DBTrans) StoreTelemetry(ctx context.Context, lastTelemetryReportedAt time.Time) error

StoreTelemetry Store last client run telemetry reported timestamp

type NewRollout

type NewRollout struct {
	Id                   int32  `db:"id, primarykey, autoincrement"`
	PolicyName           string `db:"policy_name"`
	PolicyNodeGroup      string `db:"policy_node_group"`
	PolicyRevisionId     string `db:"policy_revision_id"`
	PolicyDomainURL      string `db:"policy_domain_url"`
	PolicyDomainUsername string `db:"policy_domain_username"`
	SCMType              string `db:"scm_type"`
	SCMWebType           string `db:"scm_web_type"`
	PolicySCMURL         string `db:"policy_scm_url"`
	PolicySCMWebURL      string `db:"policy_scm_web_url"`
	PolicySCMCommit      string `db:"policy_scm_commit"`
	SCMAuthorName        string `db:"scm_author_name"`
	SCMAuthorEmail       string `db:"scm_author_email"`
	Description          string `db:"description"`
	CiJobId              string `db:"ci_job_id"`
	CiJobUrl             string `db:"ci_job_url"`
}

type NodeSegment

type NodeSegment struct {
	PolicyName      string
	PolicyNodeGroup string
	PolicyDomainURL string
}

type NodeSegmentWithRollouts

type NodeSegmentWithRollouts struct {
	NodeSegment
	Rollouts []*Rollout
}

type PolicyRev

type PolicyRev struct {
	PolicyName string `db:"policy_name"`
	ID         string `db:"id"`
}

type Postgres

type Postgres struct {
	*config.Postgres
	// contains filtered or unexported fields
}

func New

func New(config *config.Postgres) *Postgres

func Open

func Open(config *config.Postgres) (*Postgres, error)

func (*Postgres) AddPolicyCookbooks

func (p *Postgres) AddPolicyCookbooks(ctx context.Context,
	cookbooks []backend.PolicyCookbookLock, policyRevisionID, policyName string) error

func (*Postgres) Clear

func (p *Postgres) Clear() error

func (*Postgres) Close

func (p *Postgres) Close() error

func (*Postgres) Connect

func (p *Postgres) Connect() error

func (*Postgres) CreateRollout

func (p *Postgres) CreateRollout(ctx context.Context, r *NewRollout) (*Rollout, error)

CreateRollout takes the given rollout attributes and attempts to store the rollout in the database.

func (*Postgres) CreateRolloutFromChefAction

func (p *Postgres) CreateRolloutFromChefAction(ctx context.Context, r *NewRollout) error

func (*Postgres) DestructiveReMigrateForTest

func (db *Postgres) DestructiveReMigrateForTest() error

func (*Postgres) FindRolloutByID

func (p *Postgres) FindRolloutByID(ctx context.Context, id int32) (*Rollout, error)

func (*Postgres) FindRolloutByNodeSegmentAndTime

func (p *Postgres) FindRolloutByNodeSegmentAndTime(nodeSegment *NodeSegment, time *time.Time) (*Rollout, error)

func (*Postgres) GetPolicyCookbooks

func (p *Postgres) GetPolicyCookbooks(revisionID string) (backend.PolicyCookbooks, error)

func (*Postgres) GetRollouts

func (p *Postgres) GetRollouts(ctx context.Context) ([]*Rollout, error)

func (*Postgres) GetTelemetry

func (pg *Postgres) GetTelemetry(ctx context.Context) (Telemetry, error)

GetTelemetry Get last client run telemetry reported timestamp

func (*Postgres) ListNodeSegmentsForRolloutProgress

func (p *Postgres) ListNodeSegmentsForRolloutProgress() ([]*NodeSegmentWithRollouts, error)

func (*Postgres) Migrate

func (p *Postgres) Migrate() error

func (*Postgres) Ping

func (p *Postgres) Ping() error

ping will verify if the database mapped with gorp is available

func (*Postgres) UpdateTelemetryReported

func (pg *Postgres) UpdateTelemetryReported(ctx context.Context, req *request.UpdateTelemetryReportedRequest) error

UpdateLastTelemetryReported Upsert the last client run telemetry reported date in postgres

type Rollout

type Rollout struct {
	NewRollout
	StartTime *time.Time `db:"start_time"`
	EndTime   *time.Time `db:"end_time"`
}

type RolloutWithOrderIndex

type RolloutWithOrderIndex struct {
	Rollout
	OrderIndex     int   `db:"order_index"`     // present in query for last N rollouts per segment
	CurrentRollout *bool `db:"current_rollout"` // db uses this to enforce uniqueness of current rollouts
}

type Telemetry

type Telemetry struct {
	ID                      string    `db:"id" json:"id"`
	LastTelemetryReportedAt time.Time `db:"last_telemetry_reported_at" json:"last_telemetry_reported_at"`
	CreatedAt               time.Time `db:"created_at" json:"created_at"`
}

Jump to

Keyboard shortcuts

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