Conversation
| ) | ||
| switch s.DstTarget.CloudProvider() { | ||
| case types.AWS: | ||
| return s.runAWSInlineGo(ctx, creds, envVars) |
There was a problem hiding this comment.
there's likely a little dry missing here aws vs. azure, but it's probably not so important
|
|
||
| // --- Azure --- | ||
|
|
||
| // azurePostgresParams holds the pre-fetched data needed by the Azure deploy function. |
There was a problem hiding this comment.
unclear on the necessity of this, but it looks like a reasonable choice to me.
There was a problem hiding this comment.
It's meh/whatever to me. Creating an options / value object to limit a giant function signature. A little easier to grok for the humans, inconsequential to the agents. 🤷
| return runPulumi(ctx, stack, s.Options) | ||
| } | ||
|
|
||
| // --- Shared helpers --- |
There was a problem hiding this comment.
this shared helper might belong elsewhere, but it feels pretty unique to this step to me.
There was a problem hiding this comment.
YAGNI. If it's not needed elsewhere yet, fine to leave in here and let the next person refactor when it needs to be used elsewhere.
| componentType = "ptd:AWSControlRoomPostgresConfig" | ||
| } | ||
|
|
||
| // Helper to create alias pointing to old Python component parent URN. |
There was a problem hiding this comment.
we may want to figure out how to refactor this later to be very generic/work for all steps, since it's the real crux of how to convert these steps between languages without producing diffs/deltas
There was a problem hiding this comment.
Same as above IMO: YAGNI, make it generic/reusable once there's another need for it.
| ctx.Export("grafana_db_name", grafanaDb.Name) | ||
| ctx.Export("grant_id", grant.ID()) | ||
|
|
||
| // Extra databases (workload only, e.g. soleng for staging workloads) |
There was a problem hiding this comment.
obviously, we shouldn't use this anymore. but i didn't want to have to clean up/migrate the existing databases prior to conversion.
Lytol
left a comment
There was a problem hiding this comment.
As you mentioned, there's probably some DRYing and refactoring that could make it cleaner for the next human... but definitely don't do any premature refactoring for theoretical future needs. And even the few ones that could be nice now, are probably actually irrelevant in an agentic world.
All that said, looks great to me!
| // the unicode word split algo also doesn't like "postgres_config", so just hack that in manually | ||
| titleCaseStackBaseName := helpers.TitleCase(stackBaseName) | ||
| if stackBaseName == "postgres_config" { | ||
| titleCaseStackBaseName = "PostgresConfig" | ||
| } |
| ) | ||
| switch s.DstTarget.CloudProvider() { | ||
| case types.AWS: | ||
| return s.runAWSInlineGo(ctx, creds, envVars) |
|
|
||
| // --- Azure --- | ||
|
|
||
| // azurePostgresParams holds the pre-fetched data needed by the Azure deploy function. |
There was a problem hiding this comment.
It's meh/whatever to me. Creating an options / value object to limit a giant function signature. A little easier to grok for the humans, inconsequential to the agents. 🤷
| // Fetch DB admin secret from Azure Key Vault | ||
| secretName := fmt.Sprintf("%s-grafana-postgres-admin-secret", s.DstTarget.Name()) | ||
| secretValue, err := s.DstTarget.SecretStore().GetSecretValue(ctx, creds, secretName) | ||
| if err != nil { | ||
| return fmt.Errorf("failed to get postgres admin secret from Key Vault: %w", err) | ||
| } | ||
|
|
||
| var secretData map[string]string | ||
| if err := json.Unmarshal([]byte(secretValue), &secretData); err != nil { | ||
| return fmt.Errorf("failed to parse postgres admin secret JSON: %w", err) | ||
| } | ||
|
|
||
| dbHost := secretData["fqdn"] | ||
| dbUser := secretData["username"] | ||
| dbPassword := secretData["password"] | ||
| if dbHost == "" || dbUser == "" || dbPassword == "" { | ||
| return fmt.Errorf("grafana DB secret must contain 'fqdn', 'username' and 'password' fields") | ||
| } |
There was a problem hiding this comment.
This could probably all benefit from some method extraction and encapsulation. But again, pretty nitpicky and probably inconsequential to the bots.
| return runPulumi(ctx, stack, s.Options) | ||
| } | ||
|
|
||
| // --- Shared helpers --- |
There was a problem hiding this comment.
YAGNI. If it's not needed elsewhere yet, fine to leave in here and let the next person refactor when it needs to be used elsewhere.
| componentType = "ptd:AWSControlRoomPostgresConfig" | ||
| } | ||
|
|
||
| // Helper to create alias pointing to old Python component parent URN. |
There was a problem hiding this comment.
Same as above IMO: YAGNI, make it generic/reusable once there's another need for it.
|
finally got around to running this in an azure env, fix a small bug (that was introduced in a go lib long ago) @Lytol quick re-approval given last commit? |
Description
Refactors the aws control room & workload and azure workload postgres_config steps from python to go. This has been tested with a control room and 2 workloads, producing no diffs.
Category of change
Checklist