Skip to content

Commit

Permalink
chore: update naming
Browse files Browse the repository at this point in the history
Removes the use of underscores in Go names.

Ref: #42

Signed-off-by: Ryan Johnson <[email protected]>
  • Loading branch information
tenthirtyam committed Jan 24, 2025
1 parent 0d1d8fd commit 7adf32b
Show file tree
Hide file tree
Showing 24 changed files with 411 additions and 411 deletions.
4 changes: 2 additions & 2 deletions data_source_compute_profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@ func dataSourceComputeProfileRead(ctx context.Context, d *schema.ResourceData, m

network := d.Get("name").(string)

cp, err := hcx.GetComputeProfile(client, res.Data.Items[0].EndpointId, network)
cp, err := hcx.GetComputeProfile(client, res.Data.Items[0].EndpointID, network)

if err != nil {
return diag.FromErr(err)
}

d.SetId(cp.ComputeProfileId)
d.SetId(cp.ComputeProfileID)

return diags
}
6 changes: 3 additions & 3 deletions data_source_network_backing.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ func dataSourceNetworkBackingRead(ctx context.Context, d *schema.ResourceData, m
client := m.(*hcx.Client)

network := d.Get("name").(string)
vcuuid := d.Get("vcuuid").(string)
network_type := d.Get("network_type").(string)
vcUUID := d.Get("vcuuid").(string)
networkType := d.Get("network_type").(string)

res, err := hcx.GetNetworkBacking(client, vcuuid, network, network_type)
res, err := hcx.GetNetworkBacking(client, vcUUID, network, networkType)

if err != nil {
return diag.FromErr(err)
Expand Down
14 changes: 7 additions & 7 deletions hcx/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,17 +102,17 @@ func (c *Client) HcxConnectorAuthenticate() error {
var xmlmessage Entries
xml.Unmarshal(body, &xmlmessage)

certificate_pb := false
certificatePb := false
for _, j := range xmlmessage.Entry {
if j.Strings[0] == "message" {
if j.Strings[1] == "'Trusted root certificates' value should not be empty" {
certificate_pb = true
certificatePb = true
log.Println("Certificate error")
}
}
}

if !certificate_pb {
if !certificatePb {
return fmt.Errorf("body: %s", body)
}

Expand All @@ -128,18 +128,18 @@ func (c *Client) HcxConnectorAuthenticate() error {
}

// NewClient -
func NewClient(hcx, username *string, password *string, adminusername *string, adminpassword *string, vmc_token *string) (*Client, error) {
func NewClient(hcx, username *string, password *string, adminUsername *string, adminPassword *string, vmcToken *string) (*Client, error) {
c := Client{
HTTPClient: &http.Client{
Timeout: 60 * time.Second,
},
HostURL: *hcx,
Username: *username,
Password: *password,
AdminUsername: *adminusername,
AdminPassword: *adminpassword,
AdminUsername: *adminUsername,
AdminPassword: *adminPassword,
IsAuthenticated: false,
Token: *vmc_token,
Token: *vmcToken,
}

return &c, nil
Expand Down
48 changes: 24 additions & 24 deletions hcx/compute_profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,26 +24,26 @@ type InsertComputeProfileBody struct {
}

type Compute struct {
CmpId string `json:"cmpId"`
CmpName string `json:"cmpName"`
CmpType string `json:"cmpType"`
ID string `json:"id"`
Name string `json:"name"`
Type string `json:"type"`
ComputeID string `json:"cmpId"`
ComputeName string `json:"cmpName"`
ComputeType string `json:"cmpType"`
ID string `json:"id"`
Name string `json:"name"`
Type string `json:"type"`
}

type Storage struct {
CmpId string `json:"cmpId"`
CmpName string `json:"cmpName"`
CmpType string `json:"cmpType"`
ID string `json:"id"`
Name string `json:"name"`
Type string `json:"type"`
ComputeID string `json:"cmpId"`
ComputeName string `json:"cmpName"`
ComputeType string `json:"cmpType"`
ID string `json:"id"`
Name string `json:"name"`
Type string `json:"type"`
}

type DeploymentContainer struct {
Computes []Compute `json:"compute"`
CpuReservation int `json:"cpuReservation"`
CPUReservation int `json:"cpuReservation"`
MemoryReservation int `json:"memoryReservation"`
Storage []Storage `json:"storage"`
}
Expand All @@ -65,28 +65,28 @@ type Service struct {
}

type Switch struct {
CmpID string `json:"cmpId"`
ID string `json:"id"`
MaxMTU int `json:"maxMtu,omitempty"`
Name string `json:"name"`
Type string `json:"type"`
ComputeID string `json:"cmpId"`
ID string `json:"id"`
MaxMTU int `json:"maxMtu,omitempty"`
Name string `json:"name"`
Type string `json:"type"`
}

type InsertComputeProfileResult struct {
Data InsertComputeProfileResultData `json:"data"`
}

type InsertComputeProfileResultData struct {
InterconnectTaskId string `json:"interconnectTaskId"`
ComputeProfileId string `json:"computeProfileId"`
InterconnectTaskID string `json:"interconnectTaskId"`
ComputeProfileID string `json:"computeProfileId"`
}

type GetComputeProfileResult struct {
Items []GetComputeProfileResultItem `json:"items"`
}

type GetComputeProfileResultItem struct {
ComputeProfileId string `json:"computeProfileId"`
ComputeProfileID string `json:"computeProfileId"`
Name string `json:"name"`
Compute []Compute `json:"compute"`
Services []Service `json:"services"`
Expand Down Expand Up @@ -156,11 +156,11 @@ func DeleteComputeProfile(c *Client, computeprofileID string) (InsertComputeProf
}

// GetComputeProfile ...
func GetComputeProfile(c *Client, endpointId string, computeprofileName string) (GetComputeProfileResultItem, error) {
func GetComputeProfile(c *Client, endpointID string, computeProfileName string) (GetComputeProfileResultItem, error) {

resp := GetComputeProfileResult{}

req, err := http.NewRequest("GET", fmt.Sprintf("%s/hybridity/api/interconnect/computeProfiles?endpointId=%s", c.HostURL, endpointId), nil)
req, err := http.NewRequest("GET", fmt.Sprintf("%s/hybridity/api/interconnect/computeProfiles?endpointId=%s", c.HostURL, endpointID), nil)
if err != nil {
fmt.Println(err)
return GetComputeProfileResultItem{}, err
Expand All @@ -181,7 +181,7 @@ func GetComputeProfile(c *Client, endpointId string, computeprofileName string)
}

for _, j := range resp.Items {
if j.Name == computeprofileName {
if j.Name == computeProfileName {
return j, nil
}
}
Expand Down
26 changes: 13 additions & 13 deletions hcx/l2_extension.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ import (
)

type InsertL2ExtensionBody struct {
VcGuid string `json:"vcGuid"`
VcGUID string `json:"vcGuid"`
Gateway string `json:"gateway"`
Netmask string `json:"netmask"`
Dns []string `json:"dns"`
DNS []string `json:"dns"`
Destination Destination `json:"destination"`
DestinationNetwork DestinationNetwork `json:"destinationNetwork"`
Features Features `json:"features"`
Expand All @@ -25,14 +25,14 @@ type InsertL2ExtensionBody struct {
}

type DestinationNetwork struct {
GatewayId string `json:"gatewayId"`
GatewayID string `json:"gatewayId"`
}

type Destination struct {
EndpointId string `json:"endpointId"`
EndpointID string `json:"endpointId"`
EndpointName string `json:"endpointName"`
EndpointType string `json:"endpointType"`
ResourceId string `json:"resourceId"`
ResourceID string `json:"resourceId"`
ResourceName string `json:"resourceName"`
ResourceType string `json:"resourceType"`
}
Expand All @@ -43,16 +43,16 @@ type Features struct {
}

type SourceAppliance struct {
ApplianceId string `json:"applianceId"`
ApplianceID string `json:"applianceId"`
}

type SourceNetwork struct {
NetworkId string `json:"networkId"`
NetworkID string `json:"networkId"`
NetworkName string `json:"networkName"`
NetworkType string `json:"networkType"`
}

type InsertL2ExtentionResult struct {
type InsertL2ExtensionResult struct {
ID string `json:"id"`
}

Expand All @@ -61,7 +61,7 @@ type GetL2ExtensionsResult struct {
}

type GetL2ExtensionsResultItem struct {
StretchId string `json:"stretchId"`
StretchID string `json:"stretchId"`
OperationStatus OperationStatus `json:"operationStatus"`
SourceNetwork SourceNetwork `json:"sourceNetwork"`
}
Expand All @@ -75,9 +75,9 @@ type DeleteL2ExtensionResult struct {
}

// InsertL2Extention ...
func InsertL2Extension(c *Client, body InsertL2ExtensionBody) (InsertL2ExtentionResult, error) {
func InsertL2Extension(c *Client, body InsertL2ExtensionBody) (InsertL2ExtensionResult, error) {

resp := InsertL2ExtentionResult{}
resp := InsertL2ExtensionResult{}

var buf bytes.Buffer
json.NewEncoder(&buf).Encode(body)
Expand Down Expand Up @@ -106,7 +106,7 @@ func InsertL2Extension(c *Client, body InsertL2ExtensionBody) (InsertL2Extention
}

// GetL2Extensions ...
func GetL2Extensions(c *Client, network_name string) (GetL2ExtensionsResultItem, error) {
func GetL2Extensions(c *Client, networkName string) (GetL2ExtensionsResultItem, error) {

resp := GetL2ExtensionsResult{}

Expand All @@ -131,7 +131,7 @@ func GetL2Extensions(c *Client, network_name string) (GetL2ExtensionsResultItem,
}

for _, j := range resp.Items {
if j.SourceNetwork.NetworkName == network_name {
if j.SourceNetwork.NetworkName == networkName {
return j, nil
}
}
Expand Down
4 changes: 2 additions & 2 deletions hcx/location.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
type SetLocationBody struct {
City string `json:"city"`
Country string `json:"country"`
CityAscii string `json:"cityAscii"`
CityASCII string `json:"cityAscii"`
Province string `json:"province"`
Latitude float64 `json:"latitude"`
Longitude float64 `json:"longitude"`
Expand All @@ -24,7 +24,7 @@ type GetLocationResult struct {
City string `json:"city"`
Country string `json:"country"`
Province string `json:"province"`
CityAscii string `json:"cityAscii"`
CityASCII string `json:"cityAscii"`
Latitude float64 `json:"latitude"`
Longitude float64 `json:"longitude"`
}
Expand Down
24 changes: 12 additions & 12 deletions hcx/network_profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ type NetworkProfileBody struct {
Name string `json:"name"`
L3TenantManaged bool `json:"l3TenantManaged"`
OwnedBySystem bool `json:"ownedBySystem"`
ObjectId string `json:"objectId,omitempty"`
ObjectID string `json:"objectId,omitempty"`
}

type Filter struct {
Expand All @@ -37,21 +37,21 @@ type Backing struct {
BackingID string `json:"backingId"`
BackingName string `json:"backingName"`
Type string `json:"type"`
VCenterInstanceUuid string `json:"vCenterInstanceUuid"`
VCenterInstanceUUID string `json:"vCenterInstanceUuid"`
VCenterName string `json:"vCenterName,omitempty"`
}

type IPScope struct {
DnsSuffix string `json:"dnsSuffix,omitempty"`
DNSSuffix string `json:"dnsSuffix,omitempty"`
Gateway string `json:"gateway,omitempty"`
PrefixLength int `json:"prefixLength"`
PrimaryDns string `json:"primaryDns,omitempty"`
SecondaryDns string `json:"secondaryDns,omitempty"`
NetworkIpRanges []NetworkIpRange `json:"networkIpRanges,omitempty"`
PrimaryDNS string `json:"primaryDns,omitempty"`
SecondaryDNS string `json:"secondaryDns,omitempty"`
NetworkIPRanges []NetworkIPRange `json:"networkIpRanges,omitempty"`
PoolID string `json:"poolId"`
}

type NetworkIpRange struct {
type NetworkIPRange struct {
EndAddress string `json:"endAddress"`
StartAddress string `json:"startAddress"`
}
Expand All @@ -65,7 +65,7 @@ type NetworkProfileResult struct {

type NetworkProfileData struct {
JobID string `json:"jobId"`
ObjectId string `json:"objectId"`
ObjectID string `json:"objectId"`
}

// InsertNetworkProfile ...
Expand Down Expand Up @@ -142,8 +142,8 @@ func GetNetworkProfile(c *Client, name string) (NetworkProfileBody, error) {
return NetworkProfileBody{}, errors.New("cannot find network profile")
}

// GetNetworkProfileById ...
func GetNetworkProfileById(c *Client, id string) (NetworkProfileBody, error) {
// GetNetworkProfileByID ...
func GetNetworkProfileByID(c *Client, id string) (NetworkProfileBody, error) {

resp := []NetworkProfileBody{}
body := NetworkFilter{
Expand Down Expand Up @@ -177,7 +177,7 @@ func GetNetworkProfileById(c *Client, id string) (NetworkProfileBody, error) {
}

for _, j := range resp {
if j.ObjectId == id {
if j.ObjectID == id {
return j, nil
}
}
Expand Down Expand Up @@ -221,7 +221,7 @@ func UpdateNetworkProfile(c *Client, body NetworkProfileBody) (NetworkProfileRes
var buf bytes.Buffer
json.NewEncoder(&buf).Encode(body)

req, err := http.NewRequest("PUT", fmt.Sprintf("%s/hybridity/api/networks/%s", c.HostURL, body.ObjectId), &buf)
req, err := http.NewRequest("PUT", fmt.Sprintf("%s/hybridity/api/networks/%s", c.HostURL, body.ObjectID), &buf)
if err != nil {
fmt.Println(err)
return resp, err
Expand Down
2 changes: 1 addition & 1 deletion hcx/role_mapping.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ type RoleMapping struct {
type RoleMappingResult struct {
IsSuccess bool `json:"isSuccess"`
Message string `json:"message"`
HttpStatusCode int `json:"httpStatusCode"`
HTTPStatusCode int `json:"httpStatusCode"`
}

// PostActivate ...
Expand Down
Loading

0 comments on commit 7adf32b

Please sign in to comment.