Copilot commented on code in PR #306:
URL: 
https://github.com/apache/cloudstack-terraform-provider/pull/306#discussion_r3797580950


##########
cloudstack/resource_cloudstack_vpc_offering.go:
##########
@@ -0,0 +1,406 @@
+//
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+//
+
+package cloudstack
+
+import (
+       "fmt"
+       "log"
+
+       "github.com/apache/cloudstack-go/v2/cloudstack"
+       "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
+)
+
+func resourceCloudStackVPCOffering() *schema.Resource {
+       return &schema.Resource{
+               Create: resourceCloudStackVPCOfferingCreate,
+               Read:   resourceCloudStackVPCOfferingRead,
+               Update: resourceCloudStackVPCOfferingUpdate,
+               Delete: resourceCloudStackVPCOfferingDelete,
+               Importer: &schema.ResourceImporter{
+                       State: importStatePassthrough,
+               },
+               Schema: map[string]*schema.Schema{
+                       "name": {
+                               Type:     schema.TypeString,
+                               Required: true,
+                       },
+                       "display_text": {
+                               Type:     schema.TypeString,
+                               Required: true,
+                       },
+                       "domain_id": {
+                               Type:        schema.TypeList,
+                               Elem:        &schema.Schema{Type: 
schema.TypeString},
+                               Optional:    true,
+                               Description: "the ID of the containing 
domain(s), null for public offerings",
+                               ForceNew:    true,
+                       },
+                       "zone_id": {
+                               Type:        schema.TypeList,
+                               Elem:        &schema.Schema{Type: 
schema.TypeString},
+                               Optional:    true,
+                               Description: "the ID of the containing zone(s), 
null for offerings available in all zones",
+                               ForceNew:    true,
+                       },
+                       "enable": {
+                               Type:        schema.TypeBool,
+                               Optional:    true,
+                               Description: "set to true if the offering is to 
be enabled during creation. Default is false",
+                       },
+                       "for_nsx": {
+                               Type:        schema.TypeBool,
+                               Optional:    true,
+                               Description: "true if the VPC offering is meant 
to be used for NSX, false otherwise",
+                               ForceNew:    true,
+                       },
+                       "nsx_support_lb": {
+                               Type:        schema.TypeBool,
+                               Optional:    true,
+                               Description: "true if the NSX supports Lb 
service, false otherwise",
+                               ForceNew:    true,
+                       },
+                       "internet_protocol": {
+                               Type:        schema.TypeString,
+                               Optional:    true,
+                               Computed:    true,
+                               Description: "The internet protocol of the VPC 
offering. Options are ipv4 and dualstack. Default is ipv4. dualstack will 
create a VPC offering that supports both IPv4 and IPv6",
+                               ForceNew:    true,
+                       },
+                       "network_mode": {
+                               Type:        schema.TypeString,
+                               Optional:    true,
+                               Computed:    true,
+                               Description: "Indicates the mode with which the 
VPC will operate. Valid option: NATTED or ROUTED",
+                               ForceNew:    true,
+                       },
+                       "routing_mode": {
+                               Type:        schema.TypeString,
+                               Optional:    true,
+                               Computed:    true,
+                               Description: "the routing mode for the VPC 
offering. Supported types are: Static or Dynamic.",
+                               ForceNew:    true,
+                       },
+                       "specify_as_number": {
+                               Type:        schema.TypeBool,
+                               Optional:    true,
+                               Description: "true if the VPC offering supports 
choosing AS number",
+                               ForceNew:    true,
+                       },
+                       "network_provider": {
+                               Type:        schema.TypeString,
+                               Optional:    true,
+                               Description: "network provider for the VPC 
offering",
+                               ForceNew:    true,
+                       },
+                       "service_offering_id": {
+                               Type:        schema.TypeString,
+                               Optional:    true,
+                               Description: "the ID of the service offering 
for the VPC router appliance",
+                               ForceNew:    true,
+                       },
+                       "supported_services": {
+                               Type:        schema.TypeSet,
+                               Elem:        &schema.Schema{Type: 
schema.TypeString},
+                               Required:    true,
+                               Description: "the list of supported services",
+                               ForceNew:    true,
+                       },
+                       "service_provider_list": {
+                               Type:        schema.TypeMap,
+                               Optional:    true,
+                               Computed:    true,
+                               Description: "provider to service mapping. If 
not specified, the provider for the service will be mapped to the default 
provider on the physical network",
+                               ForceNew:    true,
+                       },
+                       "service_capability_list": {
+                               Type:        schema.TypeList,
+                               Optional:    true,
+                               Computed:    true,
+                               ForceNew:    true,
+                               Description: "desired service capabilities as 
part of the VPC offering",
+                               Elem: &schema.Resource{
+                                       Schema: map[string]*schema.Schema{
+                                               "service": {
+                                                       Type:        
schema.TypeString,
+                                                       Required:    true,
+                                                       Description: "the 
service the capability applies to, e.g. SourceNat",
+                                               },
+                                               "capability_type": {
+                                                       Type:        
schema.TypeString,
+                                                       Required:    true,
+                                                       Description: "the 
capability type, e.g. RedundantRouter",
+                                               },
+                                               "capability_value": {
+                                                       Type:        
schema.TypeString,
+                                                       Required:    true,
+                                                       Description: "the 
capability value, e.g. true",
+                                               },
+                                       },
+                               },
+                       },
+                       "is_default": {
+                               Type:        schema.TypeBool,
+                               Computed:    true,
+                               Description: "true if this is the default VPC 
offering",
+                       },
+               },
+       }
+}
+
+func resourceCloudStackVPCOfferingCreate(d *schema.ResourceData, meta 
interface{}) error {
+       cs := meta.(*cloudstack.CloudStackClient)
+       name := d.Get("name").(string)
+       displayText := d.Get("display_text").(string)
+
+       // Create a new parameter struct
+       p := cs.VPC.NewCreateVPCOfferingParams(displayText, name)
+
+       if v, ok := d.GetOk("domain_id"); ok {
+               p.SetDomainid(expandStringList(v.([]interface{})))
+       }
+
+       if v, ok := d.GetOk("zone_id"); ok {
+               p.SetZoneid(expandStringList(v.([]interface{})))
+       }
+
+       if v, ok := d.GetOk("enable"); ok {
+               p.SetEnable(v.(bool))
+       }
+
+       if v, ok := d.GetOk("for_nsx"); ok {
+               p.SetFornsx(v.(bool))
+       }
+
+       if v, ok := d.GetOk("nsx_support_lb"); ok {
+               p.SetNsxsupportlb(v.(bool))
+       }
+
+       if v, ok := d.GetOk("internet_protocol"); ok {
+               p.SetInternetprotocol(v.(string))
+       }
+
+       if v, ok := d.GetOk("network_mode"); ok {
+               p.SetNetworkmode(v.(string))
+       }
+
+       if v, ok := d.GetOk("routing_mode"); ok {
+               p.SetRoutingmode(v.(string))
+       }
+
+       if v, ok := d.GetOk("specify_as_number"); ok {
+               p.SetSpecifyasnumber(v.(bool))
+       }
+
+       if v, ok := d.GetOk("network_provider"); ok {
+               p.SetProvider(v.(string))
+       }
+
+       if v, ok := d.GetOk("service_offering_id"); ok {
+               serviceOfferingID, e := retrieveID(cs, "service_offering", 
v.(string))
+               if e != nil {
+                       return e.Error()

Review Comment:
   `resourceCloudStackVPCOfferingCreate` returns `error`, but this line returns 
a `string` (`e.Error()`). This won’t compile. Return the original error value 
(`return e`) (or wrap it with `fmt.Errorf(...: %w, e)` if you want more 
context).



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to