Skip to content

Commit d6a64b3

Browse files
committed
add param group info for rds
1 parent 7ae4034 commit d6a64b3

File tree

2 files changed

+51
-3
lines changed

2 files changed

+51
-3
lines changed

cmd/ctrlc/root/sync/aws/rds/rds.go

Lines changed: 49 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ func processInstances(ctx context.Context, rdsClient *rds.Client, region string)
164164
}
165165

166166
for _, instance := range resp.DBInstances {
167-
resource, err := processInstance(ctx, &instance, region)
167+
resource, err := processInstance(ctx, &instance, region, rdsClient)
168168
if err != nil {
169169
log.Error("Failed to process RDS instance", "identifier", *instance.DBInstanceIdentifier, "error", err)
170170
continue
@@ -182,7 +182,7 @@ func processInstances(ctx context.Context, rdsClient *rds.Client, region string)
182182
return resources, nil
183183
}
184184

185-
func processInstance(_ context.Context, instance *types.DBInstance, region string) (api.AgentResource, error) {
185+
func processInstance(ctx context.Context, instance *types.DBInstance, region string, rdsClient *rds.Client) (api.AgentResource, error) {
186186
// Get default port based on engine
187187
port := int32(5432) // Default to PostgreSQL port
188188
if instance.Endpoint != nil && instance.Endpoint.Port != nil && *instance.Endpoint.Port != 0 {
@@ -209,6 +209,15 @@ func processInstance(_ context.Context, instance *types.DBInstance, region strin
209209

210210
metadata := buildInstanceMetadata(instance, region, host, int(port), consoleUrl)
211211

212+
// Add parameter group details if available
213+
if len(instance.DBParameterGroups) > 0 {
214+
for _, pg := range instance.DBParameterGroups {
215+
if pg.DBParameterGroupName != nil {
216+
fetchParameterGroupDetails(ctx, rdsClient, *pg.DBParameterGroupName, metadata)
217+
}
218+
}
219+
}
220+
212221
return api.AgentResource{
213222
Version: "ctrlplane.dev/database/v1",
214223
Kind: "AWSRelationalDatabaseService",
@@ -462,6 +471,44 @@ var relationshipRules = []api.CreateResourceRelationshipRule{
462471
},
463472
}
464473

474+
// fetchParameterGroupDetails retrieves parameters from a parameter group and adds them to metadata
475+
func fetchParameterGroupDetails(ctx context.Context, rdsClient *rds.Client, parameterGroupName string, metadata map[string]string) {
476+
metadata["database/parameter-group"] = parameterGroupName
477+
478+
// Get the parameters for this parameter group
479+
var marker *string
480+
paramCount := 0
481+
482+
for {
483+
resp, err := rdsClient.DescribeDBParameters(ctx, &rds.DescribeDBParametersInput{
484+
DBParameterGroupName: &parameterGroupName,
485+
Marker: marker,
486+
})
487+
if err != nil {
488+
log.Error("Failed to get parameter group details", "parameter_group", parameterGroupName, "error", err)
489+
return
490+
}
491+
492+
for _, param := range resp.Parameters {
493+
if param.ParameterName != nil && param.ParameterValue != nil {
494+
paramKey := fmt.Sprintf("database/parameter/%s", *param.ParameterName)
495+
metadata[paramKey] = *param.ParameterValue
496+
paramCount++
497+
}
498+
}
499+
500+
if resp.Marker == nil {
501+
break
502+
}
503+
marker = resp.Marker
504+
}
505+
506+
// Add a count of how many parameters were added
507+
if paramCount > 0 {
508+
metadata["database/parameter-count"] = strconv.Itoa(paramCount)
509+
}
510+
}
511+
465512
// upsertToCtrlplane handles upserting resources to Ctrlplane
466513
func upsertToCtrlplane(ctx context.Context, resources []api.AgentResource, region, name *string) error {
467514
if *name == "" {

cmd/ctrlc/root/sync/github/pullrequests.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -542,14 +542,15 @@ func initPullRequestMetadata(pr *github.PullRequest, owner, repo string) map[str
542542
"git/state": pr.GetState(),
543543
"git/status": normalizedStatus,
544544
"git/author": pr.GetUser().GetLogin(),
545+
"git/branch": pr.GetHead().GetRef(),
546+
545547
"git/source-branch": pr.GetHead().GetRef(),
546548
"git/target-branch": pr.GetBase().GetRef(),
547549
}
548550

549551
// Add draft status
550552
if pr.GetDraft() {
551553
metadata["git/draft"] = "true"
552-
log.Debug("PR is draft", "number", prNumber)
553554
} else {
554555
metadata["git/draft"] = "false"
555556
}

0 commit comments

Comments
 (0)