Skip to content

Commit

Permalink
CCX-3789 Suggestion to change percona to mysql in the ccx terraform p…
Browse files Browse the repository at this point in the history
…rovider. #295 (#18)
  • Loading branch information
bunin authored Jan 3, 2024
1 parent d4715a8 commit a73e1c5
Showing 1 changed file with 23 additions and 3 deletions.
26 changes: 23 additions & 3 deletions terraform/datastore/datastore.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func ToDatastore(d *schema.ResourceData) ccx.Datastore {
ID: d.Id(),
Name: terraform.GetString(d, "name"),
Size: terraform.GetInt(d, "size"),
DBVendor: terraform.GetString(d, "db_vendor"),
DBVendor: vendorToCCX(terraform.GetString(d, "db_vendor")),
DBVersion: terraform.GetString(d, "db_version"),
Type: terraform.GetString(d, "type"),
Tags: terraform.GetStrings(d, "tags"),
Expand Down Expand Up @@ -50,7 +50,7 @@ func ToSchema(d *schema.ResourceData, c ccx.Datastore) error {
if err = d.Set("size", c.Size); err != nil {
return err
}
if err = d.Set("db_vendor", c.DBVendor); err != nil {
if err = d.Set("db_vendor", vendorFromCCX(c.DBVendor)); err != nil {
return err
}
if terraform.GetString(d, "db_version") != "" {
Expand Down Expand Up @@ -273,7 +273,7 @@ func defaultType(vendor, dbType string) string {
return dbType
}
switch vendor {
case "mariadb", "percona":
case "mariadb", "percona", "mysql":
return "replication"
case "psql", "postgres":
return "postgres_streaming"
Expand All @@ -282,3 +282,23 @@ func defaultType(vendor, dbType string) string {
}
return ""
}

var (
tfToCCXVendor = map[string]string{"mysql": "percona"}
ccxToTFVendor = map[string]string{"percona": "mysql"}
)

func vendorToCCX(s string) string {
if v, ok := tfToCCXVendor[s]; ok {
return v
}
return s
}

func vendorFromCCX(s string) string {
if v, ok := ccxToTFVendor[s]; ok {
return v
}
return s

}

0 comments on commit a73e1c5

Please sign in to comment.