Documentation
¶
Overview ¶
Package redshift emulates Amazon Redshift over the Query protocol. Clusters run as PostgreSQL containers on localhost (Redshift speaks PostgreSQL's wire protocol and most of its SQL); GetClusterCredentials creates real database logins. Parameter, subnet and security groups, snapshots and logging are metadata. Without Docker the API still answers and Inspect says that nothing runs.
Index ¶
- Constants
- func Alter(user, password string) []string
- func IAMUser(principal string) string
- func Spec(user, password, db string, host int) rds.Spec
- func ValidDB(db string) bool
- func ValidPassword(pw string) bool
- func ValidRole(r string) bool
- func ValidUser(u string) bool
- type Cluster
- type ClusterAssociation
- type ClusterNode
- type CopyGrant
- type CopyStatus
- type DB
- type IamRole
- type Logging
- type Membership
- type ParamGroup
- type Parameter
- type ParameterGroupStatus
- type Schedule
- type SecurityGroup
- type Service
- func (s *Service) Close() error
- func (s *Service) DB(account, region, id string) *DB
- func (s *Service) Info() core.Info
- func (s *Service) Inspect(table, id string) any
- func (s *Service) Load(b []byte) error
- func (s *Service) Reset()
- func (s *Service) Resources() []core.Table
- func (s *Service) Save() ([]byte, error)
- func (s *Service) ServeHTTP(w http.ResponseWriter, r *http.Request)
- type Snapshot
- type SubnetGroup
- type TaggedResource
Constants ¶
const Port = 5439
Port is where Redshift listens, inside the container too.
Variables ¶
This section is empty.
Functions ¶
func Alter ¶
Alter is the command that changes a password inside a container, where local connections are trusted. Check the name and password first.
func IAMUser ¶
IAMUser is the database user of an IAM identity, as GetClusterCredentialsWithIAM and Redshift Serverless name it: IAM:<user> or IAMR:<role>.
func Spec ¶
Spec is the container of a cluster or workgroup: PostgreSQL on Redshift's port, where PUBLIC may create tables in schema public as on Redshift.
func ValidPassword ¶
ValidPassword checks a master or admin password: 8 to 64 printable ASCII characters with an uppercase letter, a lowercase letter and a digit, and none of ' " \ / @ or space.
Types ¶
type Cluster ¶
type Cluster struct {
ClusterIdentifier string
NodeType string
ClusterStatus string `json:",omitempty"` // in views only, from Pogi.State
ClusterAvailabilityStatus string `json:",omitempty"` // in views only, from Pogi.State
MasterUsername string
DBName string
Endpoint *rds.Endpoint `json:",omitempty"`
ClusterCreateTime time.Time
AutomatedSnapshotRetentionPeriod int
ManualSnapshotRetentionPeriod int
ClusterSecurityGroups []Membership `json:",omitempty"`
VpcSecurityGroups []rds.VpcSecurityGroup
ClusterParameterGroups []ParameterGroupStatus
ClusterSubnetGroupName string
VpcId string
AvailabilityZone string
PreferredMaintenanceWindow string
ClusterVersion string
AllowVersionUpgrade bool
NumberOfNodes int
PubliclyAccessible bool
Encrypted bool
KmsKeyId string `json:",omitempty"`
EnhancedVpcRouting bool
IamRoles []IamRole `json:",omitempty"`
DefaultIamRoleArn string `json:",omitempty"`
MaintenanceTrackName string
ClusterNodes []ClusterNode `json:",omitempty"` // in views only
ClusterNamespaceArn string
AvailabilityZoneRelocationStatus string
MultiAZ string
Tags []rds.Tag
ClusterSnapshotCopyStatus *CopyStatus `json:",omitempty"`
Logging *Logging `json:",omitempty" query:"-"`
ScheduleIdentifier string `json:"scheduleIdentifier,omitempty" query:"-"` // snapshot schedule
Pogi rds.Server `json:"pogi" query:"-"`
}
Cluster is a provisioned cluster; it owns its container.
type ClusterAssociation ¶
type ClusterAssociation struct{ ClusterIdentifier, ScheduleAssociationState string }
ClusterAssociation is a cluster a schedule is set on.
type ClusterNode ¶
type ClusterNode struct{ NodeRole, PrivateIPAddress, PublicIPAddress string }
ClusterNode is a node of a cluster; one container serves them all.
type CopyStatus ¶
type CopyStatus struct {
DestinationRegion string
RetentionPeriod int
ManualSnapshotRetentionPeriod int
SnapshotCopyGrantName string `json:",omitempty"`
}
CopyStatus is a cluster's snapshot copy setup.
type DB ¶
type DB struct {
Addr string // 127.0.0.1:port; empty while nothing answers, and Note says why
User string // the master or admin user
Password string
Name string // the default database
Note string
}
DB is where the database of a cluster or workgroup answers.
func (*DB) Connect ¶
Connect logs in to database db (default: the default database) as user with password (default: the master user).
func (*DB) Login ¶
func (d *DB) Login(ctx context.Context, login, user string, groups []string, create bool, password string, expiry time.Time) error
Login lets login sign in with password until expiry, the way temporary credentials do: a role that joins the database user it stands for (and acts as that user once signed in) and the groups that exist. create first makes the user when it is missing. Check the names first.
type IamRole ¶
type IamRole struct{ IamRoleArn, ApplyStatus string }
IamRole is an IAM role of a cluster.
type Logging ¶
type Logging struct {
LoggingEnabled bool
BucketName, S3KeyPrefix, LogDestinationType string
LogExports []string
}
Logging is a cluster's audit logging setup; pogi writes no logs.
type Membership ¶
type Membership struct{ ClusterSecurityGroupName, Status string }
Membership is a cluster security group of a cluster.
type ParamGroup ¶
type ParamGroup struct {
ParameterGroupName string
ParameterGroupFamily string
Description string
Tags []rds.Tag
Params map[string]string `json:",omitempty" query:"-"` // set by users
}
ParamGroup is a cluster parameter group.
type Parameter ¶
type Parameter struct {
ParameterName, ParameterValue, Description, Source, DataType, ApplyType string
IsModifiable bool
}
Parameter is a parameter of a parameter group.
type ParameterGroupStatus ¶
type ParameterGroupStatus struct{ ParameterGroupName, ParameterApplyStatus string }
ParameterGroupStatus is the parameter group of a cluster.
type Schedule ¶
type Schedule struct {
ScheduleDefinitions []string
ScheduleIdentifier string
ScheduleDescription string
Tags []rds.Tag
AssociatedClusterCount int
AssociatedClusters []ClusterAssociation
}
Schedule is a snapshot schedule; ScheduleDefinitions are rate() or cron() expressions.
type SecurityGroup ¶
SecurityGroup is a cluster security group, without ingress rules.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service is the Redshift emulator.
func (*Service) Close ¶
Close removes the containers, except those persisted state resumes next run.
func (*Service) DB ¶
DB is where the database of a cluster answers, for the Data API; nil when there is no such cluster.
func (*Service) Inspect ¶
Inspect returns a cluster with pogi's side: container, master password, state and pogiNote.
func (*Service) Load ¶
Load restores state and reconnects to the containers by name (--persist leaves them behind on shutdown); containers of dropped clusters go.
type Snapshot ¶
type Snapshot struct {
SnapshotIdentifier string
ClusterIdentifier string
SnapshotCreateTime time.Time
Status string
Port int
AvailabilityZone string
ClusterCreateTime time.Time
MasterUsername string
ClusterVersion string
SnapshotType string
NodeType string
NumberOfNodes int
DBName string
VpcId string
Encrypted bool
KmsKeyId string `json:",omitempty"`
EnhancedVpcRouting bool
OwnerAccount string
ManualSnapshotRetentionPeriod int
SnapshotArn string
Tags []rds.Tag
}
Snapshot is a manual snapshot. ponytail: metadata only, like RDS's: restoring needs a dump of the container.
type SubnetGroup ¶
type SubnetGroup struct {
ClusterSubnetGroupName string
Description string
VpcId string
SubnetGroupStatus string
Subnets []rds.Subnet
Tags []rds.Tag
}
SubnetGroup is a cluster subnet group.
type TaggedResource ¶
TaggedResource is a tag of a resource, as DescribeTags lists them.