Copilot commented on code in PR #212: URL: https://github.com/apache/cloudstack-terraform-provider/pull/212#discussion_r2303678254
########## cloudstack/resource_cloudstack_service_offering.go: ########## @@ -177,6 +248,53 @@ func resourceCloudStackServiceOfferingRead(d *schema.ResourceData, meta interfac "memory": s.Memory, "offer_ha": s.Offerha, "storage_type": s.Storagetype, + "customized": s.Iscustomized, + "min_cpu_number": func() interface{} { + if s.Serviceofferingdetails == nil { + return nil + } + if v, ok := s.Serviceofferingdetails["mincpunumber"]; ok { + if i, err := strconv.Atoi(v); err == nil { + return i + } + } + return nil + }(), + "max_cpu_number": func() interface{} { + if s.Serviceofferingdetails == nil { + return nil + } + if v, ok := s.Serviceofferingdetails["maxcpunumber"]; ok { + if i, err := strconv.Atoi(v); err == nil { + return i + } + } + return nil + }(), + "min_memory": func() interface{} { + if s.Serviceofferingdetails == nil { + return nil + } + if v, ok := s.Serviceofferingdetails["minmemory"]; ok { + if i, err := strconv.Atoi(v); err == nil { + return i + } + } + return nil + }(), + "max_memory": func() interface{} { + if s.Serviceofferingdetails == nil { + return nil + } + if v, ok := s.Serviceofferingdetails["maxmemory"]; ok { + if i, err := strconv.Atoi(v); err == nil { + return i + } + } + return nil + }(), Review Comment: The repeated pattern for extracting integer values from Serviceofferingdetails creates code duplication. Consider extracting this logic into a helper function like `getIntFromDetails(details map[string]string, key string) interface{}`. ```suggestion "min_cpu_number": getIntFromDetails(s.Serviceofferingdetails, "mincpunumber"), "max_cpu_number": getIntFromDetails(s.Serviceofferingdetails, "maxcpunumber"), "min_memory": getIntFromDetails(s.Serviceofferingdetails, "minmemory"), "max_memory": getIntFromDetails(s.Serviceofferingdetails, "maxmemory"), ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: dev-unsubscr...@cloudstack.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org