MCPcopy Create free account
hub / github.com/postgres-ai/database-lab-engine / GetSourceInfo

Method GetSourceInfo

engine/internal/rdsrefresh/rds.go:512–550  ·  view source on GitHub ↗

GetSourceInfo returns information about the source database.

(ctx context.Context)

Source from the content-addressed store, hash-verified

510
511// GetSourceInfo returns information about the source database.
512func (r *RDSClient) GetSourceInfo(ctx context.Context) (string, error) {
513 if r.cfg.Source.Type == sourceTypeAuroraCluster {
514 resp, err := r.client.DescribeDBClusters(ctx, &rds.DescribeDBClustersInput{
515 DBClusterIdentifier: aws.String(r.cfg.Source.Identifier),
516 })
517 if err != nil {
518 return "", fmt.Errorf("failed to describe source cluster: %w", err)
519 }
520
521 if len(resp.DBClusters) == 0 {
522 return "", fmt.Errorf("source cluster %q not found", r.cfg.Source.Identifier)
523 }
524
525 cluster := resp.DBClusters[0]
526
527 return fmt.Sprintf("Aurora cluster %s (engine: %s, version: %s)",
528 r.cfg.Source.Identifier,
529 aws.ToString(cluster.Engine),
530 aws.ToString(cluster.EngineVersion)), nil
531 }
532
533 resp, err := r.client.DescribeDBInstances(ctx, &rds.DescribeDBInstancesInput{
534 DBInstanceIdentifier: aws.String(r.cfg.Source.Identifier),
535 })
536 if err != nil {
537 return "", fmt.Errorf("failed to describe source instance: %w", err)
538 }
539
540 if len(resp.DBInstances) == 0 {
541 return "", fmt.Errorf("source instance %q not found", r.cfg.Source.Identifier)
542 }
543
544 instance := resp.DBInstances[0]
545
546 return fmt.Sprintf("RDS instance %s (engine: %s, version: %s)",
547 r.cfg.Source.Identifier,
548 aws.ToString(instance.Engine),
549 aws.ToString(instance.EngineVersion)), nil
550}

Callers 3

TestGetSourceInfoFunction · 0.95
RunMethod · 0.80
DryRunMethod · 0.80

Calls 3

DescribeDBClustersMethod · 0.65
DescribeDBInstancesMethod · 0.65
StringMethod · 0.45

Tested by 1

TestGetSourceInfoFunction · 0.76