apply

package
v0.12.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 11, 2026 License: MPL-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddCommandsTo

func AddCommandsTo(rootCmd *cobra.Command)

AddCommandsTo builds the apply command and adds it to the root command.

func ApplyConfig

func ApplyConfig(cmd *cobra.Command, _ []string, noColor bool, outputFormat string) error

ApplyConfig is the entry point for `megaport-cli apply`.

Types

type ApplyResult

type ApplyResult struct {
	output.Output `json:"-" header:"-"`
	Type          string `json:"type"   header:"Type"`
	Name          string `json:"name"   header:"Name"`
	UID           string `json:"uid"    header:"UID"`
	Status        string `json:"status" header:"Status"`
}

ApplyResult records the outcome of provisioning a single resource.

type InfraConfig

type InfraConfig struct {
	Ports []PortConfig `yaml:"ports" json:"ports"`
	MCRs  []MCRConfig  `yaml:"mcrs"  json:"mcrs"`
	MVEs  []MVEConfig  `yaml:"mves"  json:"mves"`
	VXCs  []VXCConfig  `yaml:"vxcs"  json:"vxcs"`
}

InfraConfig is the top-level structure for a megaport apply config file.

type MCRConfig

type MCRConfig struct {
	Name          string            `yaml:"name" json:"name"`
	LocationID    int               `yaml:"location_id" json:"location_id"`
	Speed         int               `yaml:"speed" json:"speed"`
	Term          int               `yaml:"term" json:"term"`
	ASN           int               `yaml:"asn" json:"asn"`
	DiversityZone string            `yaml:"diversity_zone" json:"diversity_zone"`
	CostCentre    string            `yaml:"cost_centre" json:"cost_centre"`
	ResourceTags  map[string]string `yaml:"resource_tags" json:"resource_tags"`
}

MCRConfig describes an MCR to provision.

type MVEConfig

type MVEConfig struct {
	Name          string                 `yaml:"name" json:"name"`
	LocationID    int                    `yaml:"location_id" json:"location_id"`
	Term          int                    `yaml:"term" json:"term"`
	VendorConfig  map[string]interface{} `yaml:"vendor_config" json:"vendor_config"`
	DiversityZone string                 `yaml:"diversity_zone" json:"diversity_zone"`
	CostCentre    string                 `yaml:"cost_centre" json:"cost_centre"`
	ResourceTags  map[string]string      `yaml:"resource_tags" json:"resource_tags"`
}

MVEConfig describes an MVE to provision. VendorConfig holds vendor-specific fields (e.g. vendor, imageId, productSize).

type MockMCRService

type MockMCRService struct {
	BuyMCRResult         *megaport.BuyMCRResponse
	BuyMCRErr            error
	BuyMCRNilResp        bool
	ValidateMCROrderErr  error
	CapturedMCRRequest   *megaport.BuyMCRRequest
	WaitForMCRReadyDelay time.Duration
	WaitForMCRReadyErr   error
	DeleteMCRErr         error
	DeleteMCRCalledWith  []string
	GetMCRStatus         string // provisioning status returned by GetMCR (default ready)
	GetMCRErr            error  // error returned by GetMCR (simulates a provision-wait failure)
}

MockMCRService implements megaport.MCRService for testing.

func (*MockMCRService) BuyMCR

func (*MockMCRService) DeleteMCR

func (*MockMCRService) DeleteMCRPrefixFilterList

func (m *MockMCRService) DeleteMCRPrefixFilterList(ctx context.Context, mcrID string, id int) (*megaport.DeleteMCRPrefixFilterListResponse, error)

func (*MockMCRService) GetMCR

func (m *MockMCRService) GetMCR(ctx context.Context, mcrId string) (*megaport.MCR, error)

func (*MockMCRService) GetMCRPrefixFilterList

func (m *MockMCRService) GetMCRPrefixFilterList(ctx context.Context, mcrID string, id int) (*megaport.MCRPrefixFilterList, error)

func (*MockMCRService) GetMCRPrefixFilterLists

func (m *MockMCRService) GetMCRPrefixFilterLists(ctx context.Context, mcrId string) ([]*megaport.PrefixFilterList, error)

func (*MockMCRService) ListMCRPrefixFilterLists

func (m *MockMCRService) ListMCRPrefixFilterLists(ctx context.Context, mcrId string) ([]*megaport.PrefixFilterList, error)

func (*MockMCRService) ListMCRResourceTags

func (m *MockMCRService) ListMCRResourceTags(ctx context.Context, mcrID string) (map[string]string, error)

func (*MockMCRService) ListMCRs

func (m *MockMCRService) ListMCRs(ctx context.Context, req *megaport.ListMCRsRequest) ([]*megaport.MCR, error)

func (*MockMCRService) ModifyMCR

func (*MockMCRService) ModifyMCRPrefixFilterList

func (m *MockMCRService) ModifyMCRPrefixFilterList(ctx context.Context, mcrID string, id int, list *megaport.MCRPrefixFilterList) (*megaport.ModifyMCRPrefixFilterListResponse, error)

func (*MockMCRService) RestoreMCR

func (m *MockMCRService) RestoreMCR(ctx context.Context, mcrId string) (*megaport.RestoreMCRResponse, error)

func (*MockMCRService) UpdateMCRIPsecAddOn added in v0.7.1

func (m *MockMCRService) UpdateMCRIPsecAddOn(ctx context.Context, mcrID string, addOnUID string, tunnelCount int) error

func (*MockMCRService) UpdateMCRResourceTags

func (m *MockMCRService) UpdateMCRResourceTags(ctx context.Context, mcrID string, tags map[string]string) error

func (*MockMCRService) UpdateMCRWithAddOn added in v0.7.1

func (m *MockMCRService) UpdateMCRWithAddOn(ctx context.Context, mcrID string, req megaport.MCRAddOnRequest) error

func (*MockMCRService) ValidateMCROrder

func (m *MockMCRService) ValidateMCROrder(ctx context.Context, req *megaport.BuyMCRRequest) error

func (*MockMCRService) WaitForMCRReady added in v0.9.2

func (m *MockMCRService) WaitForMCRReady(ctx context.Context, mcrID string, timeout time.Duration) error

type MockMVEService

type MockMVEService struct {
	BuyMVEResult        *megaport.BuyMVEResponse
	BuyMVEErr           error
	BuyMVENilResp       bool
	ValidateMVEOrderErr error
	DeleteMVEErr        error
	DeleteMVECalledWith []string
	GetMVEStatus        string // provisioning status returned by GetMVE (default ready)
	GetMVEErr           error  // error returned by GetMVE (simulates a provision-wait failure)
}

MockMVEService implements megaport.MVEService for testing.

func (*MockMVEService) BuyMVE

func (*MockMVEService) DeleteMVE

func (*MockMVEService) GetMVE

func (m *MockMVEService) GetMVE(ctx context.Context, mveId string) (*megaport.MVE, error)

func (*MockMVEService) ListAvailableMVESizes

func (m *MockMVEService) ListAvailableMVESizes(ctx context.Context) ([]*megaport.MVESize, error)

func (*MockMVEService) ListMVEImages

func (m *MockMVEService) ListMVEImages(ctx context.Context) ([]*megaport.MVEImage, error)

func (*MockMVEService) ListMVEResourceTags

func (m *MockMVEService) ListMVEResourceTags(ctx context.Context, mveID string) (map[string]string, error)

func (*MockMVEService) ListMVEs

func (m *MockMVEService) ListMVEs(ctx context.Context, req *megaport.ListMVEsRequest) ([]*megaport.MVE, error)

func (*MockMVEService) ModifyMVE

func (*MockMVEService) UpdateMVEResourceTags

func (m *MockMVEService) UpdateMVEResourceTags(ctx context.Context, mveID string, tags map[string]string) error

func (*MockMVEService) ValidateMVEOrder

func (m *MockMVEService) ValidateMVEOrder(ctx context.Context, req *megaport.BuyMVERequest) error

type MockPortService

type MockPortService struct {
	BuyPortResult        *megaport.BuyPortResponse
	BuyPortErr           error
	BuyPortNilResp       bool
	ValidatePortOrderErr error
	CapturedPortRequest  *megaport.BuyPortRequest
	DeletePortErr        error
	DeletePortCalledWith []string
	GetPortStatus        string // provisioning status returned by GetPort (default ready)
	GetPortErr           error  // error returned by GetPort (simulates a provision-wait failure)
}

MockPortService implements megaport.PortService for testing.

func (*MockPortService) BuyPort

func (*MockPortService) CheckPortVLANAvailability

func (m *MockPortService) CheckPortVLANAvailability(ctx context.Context, portId string, vlan int) (bool, error)

func (*MockPortService) DeletePort

func (*MockPortService) GetPort

func (m *MockPortService) GetPort(ctx context.Context, portId string) (*megaport.Port, error)

func (*MockPortService) ListPortResourceTags

func (m *MockPortService) ListPortResourceTags(ctx context.Context, portID string) (map[string]string, error)

func (*MockPortService) ListPorts

func (m *MockPortService) ListPorts(ctx context.Context) ([]*megaport.Port, error)

func (*MockPortService) LockPort

func (m *MockPortService) LockPort(ctx context.Context, portId string) (*megaport.LockPortResponse, error)

func (*MockPortService) ModifyPort

func (*MockPortService) RestorePort

func (m *MockPortService) RestorePort(ctx context.Context, portId string) (*megaport.RestorePortResponse, error)

func (*MockPortService) UnlockPort

func (m *MockPortService) UnlockPort(ctx context.Context, portId string) (*megaport.UnlockPortResponse, error)

func (*MockPortService) UpdatePortResourceTags

func (m *MockPortService) UpdatePortResourceTags(ctx context.Context, portID string, tags map[string]string) error

func (*MockPortService) ValidatePortOrder

func (m *MockPortService) ValidatePortOrder(ctx context.Context, req *megaport.BuyPortRequest) error

type MockVXCService

type MockVXCService struct {
	BuyVXCResult    *megaport.BuyVXCResponse
	BuyVXCErr       error
	BuyVXCErrOnCall int // if > 0, return BuyVXCErr only on this call number (1-based)

	BuyVXCNilResp       bool
	ValidateVXCOrderErr error
	CapturedVXCRequest  *megaport.BuyVXCRequest
	DeleteVXCErr        error
	DeleteVXCCalledWith []string
	GetVXCStatus        string // provisioning status returned by GetVXC (default ready)
	GetVXCErr           error  // error returned by GetVXC (simulates a provision-wait failure)
	// contains filtered or unexported fields
}

MockVXCService implements megaport.VXCService for testing.

func (*MockVXCService) BuyVXC

func (*MockVXCService) DeleteVXC

func (m *MockVXCService) DeleteVXC(ctx context.Context, id string, req *megaport.DeleteVXCRequest) error

func (*MockVXCService) GetVXC

func (m *MockVXCService) GetVXC(ctx context.Context, id string) (*megaport.VXC, error)

func (*MockVXCService) ListPartnerPorts

func (*MockVXCService) ListVXCResourceTags

func (m *MockVXCService) ListVXCResourceTags(ctx context.Context, vxcID string) (map[string]string, error)

func (*MockVXCService) ListVXCs

func (m *MockVXCService) ListVXCs(ctx context.Context, req *megaport.ListVXCsRequest) ([]*megaport.VXC, error)

func (*MockVXCService) UpdateVXC

func (*MockVXCService) UpdateVXCResourceTags

func (m *MockVXCService) UpdateVXCResourceTags(ctx context.Context, vxcID string, tags map[string]string) error

func (*MockVXCService) ValidateVXCOrder

func (m *MockVXCService) ValidateVXCOrder(ctx context.Context, req *megaport.BuyVXCRequest) error

type Module

type Module struct{}

Module implements registry.Module for the apply command.

func NewModule

func NewModule() *Module

func (*Module) Name

func (m *Module) Name() string

func (*Module) RegisterCommands

func (m *Module) RegisterCommands(rootCmd *cobra.Command)

type PortConfig

type PortConfig struct {
	Name                  string            `yaml:"name" json:"name"`
	LocationID            int               `yaml:"location_id" json:"location_id"`
	Speed                 int               `yaml:"speed" json:"speed"`
	Term                  int               `yaml:"term" json:"term"`
	MarketplaceVisibility bool              `yaml:"marketplace_visibility" json:"marketplace_visibility"`
	DiversityZone         string            `yaml:"diversity_zone" json:"diversity_zone"`
	CostCentre            string            `yaml:"cost_centre" json:"cost_centre"`
	ResourceTags          map[string]string `yaml:"resource_tags" json:"resource_tags"`
}

PortConfig describes a port to provision.

type VXCConfig

type VXCConfig struct {
	Name         string            `yaml:"name" json:"name"`
	RateLimit    int               `yaml:"rate_limit" json:"rate_limit"`
	Term         int               `yaml:"term" json:"term"`
	AEnd         VXCEndpointConfig `yaml:"a_end" json:"a_end"`
	BEnd         VXCEndpointConfig `yaml:"b_end" json:"b_end"`
	CostCentre   string            `yaml:"cost_centre" json:"cost_centre"`
	ResourceTags map[string]string `yaml:"resource_tags" json:"resource_tags"`
}

VXCConfig describes a VXC to provision.

type VXCEndpointConfig

type VXCEndpointConfig struct {
	ProductUID string `yaml:"product_uid" json:"product_uid"`
	VLAN       int    `yaml:"vlan" json:"vlan"`
}

VXCEndpointConfig describes one end of a VXC connection.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL