Skip to content

Commit

Permalink
cleanup: remove unnecessary switch case in createMVEOrder
Browse files Browse the repository at this point in the history
  • Loading branch information
MegaportPhilipBrowne committed Sep 16, 2024
1 parent e88686a commit 09340af
Showing 1 changed file with 7 additions and 83 deletions.
90 changes: 7 additions & 83 deletions mve.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,93 +158,17 @@ func (svc *MVEServiceOp) ValidateMVEOrder(ctx context.Context, req *BuyMVEReques

func createMVEOrder(req *BuyMVERequest) []*MVEOrderConfig {
order := &MVEOrderConfig{
LocationID: req.LocationID,
Name: req.Name,
Term: req.Term,
PromoCode: req.PromoCode,
CostCentre: req.CostCentre,
ProductType: strings.ToUpper(PRODUCT_MVE),
LocationID: req.LocationID,
Name: req.Name,
Term: req.Term,
PromoCode: req.PromoCode,
CostCentre: req.CostCentre,
VendorConfig: req.VendorConfig,
ProductType: strings.ToUpper(PRODUCT_MVE),
Config: MVEConfig{
DiversityZone: req.DiversityZone,
},
}
switch c := req.VendorConfig.(type) {
case *ArubaConfig:
order.VendorConfig = &ArubaConfig{
Vendor: c.Vendor,
ImageID: c.ImageID,
ProductSize: c.ProductSize,
MVELabel: c.MVELabel,
AccountName: c.AccountName,
AccountKey: c.AccountKey,
}
case *CiscoConfig:
order.VendorConfig = &CiscoConfig{
Vendor: c.Vendor,
ImageID: c.ImageID,
ProductSize: c.ProductSize,
MVELabel: c.MVELabel,
AdminSSHPublicKey: c.AdminSSHPublicKey,
SSHPublicKey: c.SSHPublicKey,
ManageLocally: c.ManageLocally,
CloudInit: c.CloudInit,
FMCIPAddress: c.FMCIPAddress,
FMCRegistrationKey: c.FMCRegistrationKey,
FMCNatID: c.FMCNatID,
}
case *FortinetConfig:
order.VendorConfig = &FortinetConfig{
Vendor: c.Vendor,
ImageID: c.ImageID,
ProductSize: c.ProductSize,
MVELabel: c.MVELabel,
AdminSSHPublicKey: c.AdminSSHPublicKey,
SSHPublicKey: c.SSHPublicKey,
LicenseData: c.LicenseData,
}
case *PaloAltoConfig:
order.VendorConfig = &PaloAltoConfig{
Vendor: c.Vendor,
ImageID: c.ImageID,
ProductSize: c.ProductSize,
MVELabel: c.MVELabel,
AdminSSHPublicKey: c.AdminSSHPublicKey,
SSHPublicKey: c.SSHPublicKey,
AdminPasswordHash: c.AdminPasswordHash,
LicenseData: c.LicenseData,
}
case *VersaConfig:
order.VendorConfig = &VersaConfig{
Vendor: c.Vendor,
ImageID: c.ImageID,
ProductSize: c.ProductSize,
MVELabel: c.MVELabel,
DirectorAddress: c.DirectorAddress,
ControllerAddress: c.ControllerAddress,
LocalAuth: c.LocalAuth,
RemoteAuth: c.RemoteAuth,
SerialNumber: c.SerialNumber,
}
case *VmwareConfig:
order.VendorConfig = &VmwareConfig{
Vendor: c.Vendor,
ImageID: c.ImageID,
ProductSize: c.ProductSize,
MVELabel: c.MVELabel,
AdminSSHPublicKey: c.AdminSSHPublicKey,
SSHPublicKey: c.SSHPublicKey,
VcoAddress: c.VcoAddress,
VcoActivationCode: c.VcoActivationCode,
}
case *MerakiConfig:
order.VendorConfig = &MerakiConfig{
Vendor: c.Vendor,
ImageID: c.ImageID,
ProductSize: c.ProductSize,
MVELabel: c.MVELabel,
Token: c.Token,
}
}

if len(req.Vnics) == 0 {
order.NetworkInterfaces = []MVENetworkInterface{{Description: "Data Plane", VLAN: 0}}
Expand Down

0 comments on commit 09340af

Please sign in to comment.