iww

package
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2022 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SIStateStart      = iota // filled with crn, no network activity
	SIStateExists            // cloud state has been fetched
	SIStateDestroying        // was in the exists state, a cloud call to delete was successful
	SIStateDeleted           // was in the destroying state, a cloud call to find it was successful but not found
)

Service instance state State transition start -Fetch-> exists | deleted exists -Fetch-> exists exists -Fetch-> deleted exists -Destroy-> destroying destroying -Fetch-> exists destroying -Fetch-> destroying destroying -Fetch-> deleted

See further definition of Fetch and Destroy below

Variables

View Source
var VpcSubtypeOperationsIrregularMap = map[string]VpcSubtypeOperations{
	"instance-template": VpcSpecificInstanceTemplateInstance{},
	"vpn":               VpcSpecificVPNGatewayInstance{},
}
View Source
var VpcSubtypeOperationsMap = map[string]VpcSubtypeOperations{
	"vpc":                VpcSpecificVPCInstance{},
	"subnet":             VpcSpecificSubnetInstance{},
	"instance":           VpcSpecificInstanceInstance{},
	"volume":             VpcSpecificVolumeInstance{},
	"key":                VpcSpecificKeyInstance{},
	"load-balancer":      VpcSpecificLoadBalancerInstance{},
	"floating-ip":        VpcSpecificFloatingIPInstance{},
	"image":              VpcSpecificImageInstance{},
	"public-gateway":     VpcSpecificPublicGatewayInstance{},
	"network-acl":        VpcSpecificNetworkACLInstance{},
	"security-group":     VpcSpecificSecurityGroupInstance{},
	"flow-log-collector": VpcSpecificFlowLogCollectorInstance{},
	"instance-group":     VpcSpecificInstanceGroupInstance{},
}

Functions

func ApiEndpoint

func ApiEndpoint(documentedApiEndpoint string, region string) string

func FormatInstance

func FormatInstance(name string, description string, crn Crn) string

func Ls

func Ls(apikey, region string, resourceGroupName string, fast bool) error

ls with apikey from iww command line

func LsCommon

func LsCommon(apikey string, token string, accountID string, region string, resourceGroupName string, resourceGroupID string, fast bool) error

func LsWithToken

func LsWithToken(token string, accountID string, region string, resourceGroupName string, resourceGroupID string, fast bool) error

ls with context manager from ibmcloud cli

func PrintResourceInstances

func PrintResourceInstances(context *Context, fast bool, wrappedResourceInstances []*ResourceInstanceWrapper)

func ResourceInstances

Return the list of resource instances matching the option

func ResourceKeys

Return the list of service keys matching the option

func Rm

func Rm(apikey, region string, resourceGroupName string, fileName string) error

func RmCommon

func RmCommon(apikey string, token string, accountID string, region string, resourceGroupName string, resourceGroupID string) error

func RmServiceInstances

func RmServiceInstances(serviceInstances []*ResourceInstanceWrapper) error

State transition start -fetch-> exists | deleted exists -fetch-> exists exists -fetch-> deleted exists -destroy-> destroying destroying -fetch-> exists destroying -fetch-> destroying destroying -fetch-> deleted

func RmWithToken

func RmWithToken(token string, accountID string, region string, resourceGroupName string, resourceGroupID string) error

func SetGlobalContext

func SetGlobalContext(apikey string, token string, accountID string, region string, resourceGroupName string, resourceGroupID string) error

return the cached context or create it the first time called

func SetGlobalContextResourceGroupID

func SetGlobalContextResourceGroupID() error

func Tag

func Tag(apikey, resourceGroup string) error

func Tst

func Tst(apikey, region string, resourceGroupName string) error

func TstCommon

func TstCommon(apikey string, token string, accountID string, region string, resourceGroupName string, resourceGroupID string) error

func TstServiceInstances

func TstServiceInstances(serviceInstances []*ResourceInstanceWrapper) error

Types

type Context

type Context struct {
	IDToResourceGroupName map[string]string

	KeyProtectClients    map[Key]*kp.Client
	TransitGatewayClient *transitgatewayapisv1.TransitGatewayApisV1
	VpcClients           map[string]*vpcv1.VpcV1
	// contains filtered or unexported fields
}

Global variables all the ones that end in Service are useful for operations

var GlobalContext *Context

func MustGlobalContext

func MustGlobalContext() *Context

type Crn

type Crn struct {
	Crn string
	// contains filtered or unexported fields
}

Crn is the parsed representation of a crn string. TODO make the vpc stuff more general if needed

func NewCrn

func NewCrn(crn string) *Crn

func (*Crn) AsString

func (crn *Crn) AsString() string

type Key

type Key struct {
	// contains filtered or unexported fields
}

type KeyprotectServiceOpertions

type KeyprotectServiceOpertions struct {
}

--------------------------------------

func (*KeyprotectServiceOpertions) Destroy

func (*KeyprotectServiceOpertions) Fetch

kms removes itsef from the resource controller but continues to return a state of removed

func (*KeyprotectServiceOpertions) FormatInstance

func (s *KeyprotectServiceOpertions) FormatInstance(si *ResourceInstanceWrapper, fast bool) string

type ResourceInstanceOperations

type ResourceInstanceOperations interface {
	/*
	  Fetch function - get the resource from the cloud, if there is an error that indicartes a successful API call
	  with indication that the resource does not exist then resource changes to deleted (other
	  failures do not change the state of the resource)
	*/
	Fetch(si *ResourceInstanceWrapper) // fetch from cloud and upate the state, no need to retry in Fetch
	/*
	  Destroy - request a destroy of the resource.
	*/
	Destroy(si *ResourceInstanceWrapper) // fetch from cloud and upate the state, no need to retry in Fetch
	FormatInstance(si *ResourceInstanceWrapper, fast bool) string
}

func NewVpcOperations

func NewVpcOperations(crn *Crn) (ResourceInstanceOperations, error)

--------------------------------------

type ResourceInstanceWrapper

type ResourceInstanceWrapper struct {

	//context         *Context
	ResourceGroupID *string
	Name            *string
	// contains filtered or unexported fields
}

wrappers are for both resourcecontrollerv2.ResourceInstance and ServiceInstance. Also contain state

func List

func List() ([]*ResourceInstanceWrapper, error)

func NewResourceInstanceWrapper

func NewResourceInstanceWrapper(crn *Crn, resourceGroupID *string, name *string) *ResourceInstanceWrapper

func (*ResourceInstanceWrapper) Destroy

func (ri *ResourceInstanceWrapper) Destroy()

func (*ResourceInstanceWrapper) Fetch

func (ri *ResourceInstanceWrapper) Fetch()

func (*ResourceInstanceWrapper) FormatInstance

func (ri *ResourceInstanceWrapper) FormatInstance(fast bool) string

func (*ResourceInstanceWrapper) ResourceGroup

func (basic *ResourceInstanceWrapper) ResourceGroup() string

ResourceGroup returns a string representation of the resource group. Name if available

type ResourceKeyOperations

type ResourceKeyOperations struct {
	// contains filtered or unexported fields
}

--------------------------------------

func (*ResourceKeyOperations) Destroy

func (*ResourceKeyOperations) Fetch

func (*ResourceKeyOperations) FormatInstance

func (s *ResourceKeyOperations) FormatInstance(si *ResourceInstanceWrapper, fast bool) string

type TransitGatewayServiceOpertions

type TransitGatewayServiceOpertions struct {
}

--------------------------------------

func (*TransitGatewayServiceOpertions) Destroy

func (*TransitGatewayServiceOpertions) Fetch

func (*TransitGatewayServiceOpertions) FormatInstance

type TypicalServiceOperations

type TypicalServiceOperations struct {
	// contains filtered or unexported fields
}

--------------------------------------

func (*TypicalServiceOperations) Destroy

func (*TypicalServiceOperations) Fetch

func (*TypicalServiceOperations) FormatInstance

func (s *TypicalServiceOperations) FormatInstance(si *ResourceInstanceWrapper, fast bool) string

type UnimplementedServiceOperations

type UnimplementedServiceOperations struct {
}

-------------------------------------- If the CRN can not be understood this unimplementedservice is used.

func (UnimplementedServiceOperations) Destroy

func (UnimplementedServiceOperations) Fetch

func (UnimplementedServiceOperations) FormatInstance

type VpcGenericInstanceGroupOperation

type VpcGenericInstanceGroupOperation struct {
	// contains filtered or unexported fields
}

-------------------------------------- instance-groups need the membership count set to zero before deleting.

func (*VpcGenericInstanceGroupOperation) Destroy

func (*VpcGenericInstanceGroupOperation) Fetch

func (*VpcGenericInstanceGroupOperation) FormatInstance

type VpcGenericNoDeleteOperation

type VpcGenericNoDeleteOperation struct {
	// contains filtered or unexported fields
}

-------------------------------------- Some operations, like security group and acl, do not need to be deleted, deleting the vpc will auto delete them And deleting the default will complain.

func (*VpcGenericNoDeleteOperation) Destroy

func (*VpcGenericNoDeleteOperation) Fetch

func (*VpcGenericNoDeleteOperation) FormatInstance

func (noDelete *VpcGenericNoDeleteOperation) FormatInstance(ri *ResourceInstanceWrapper, fast bool) string

type VpcGenericOperation

type VpcGenericOperation struct {
	// contains filtered or unexported fields
}

IS operations

func (*VpcGenericOperation) Destroy

func (vpc *VpcGenericOperation) Destroy(ri *ResourceInstanceWrapper)

func (*VpcGenericOperation) Fetch

func (*VpcGenericOperation) FormatInstance

func (vpc *VpcGenericOperation) FormatInstance(ri *ResourceInstanceWrapper, fast bool) string

type VpcSpecificFloatingIPInstance

type VpcSpecificFloatingIPInstance struct{}

func (VpcSpecificFloatingIPInstance) Destroy

func (vpc VpcSpecificFloatingIPInstance) Destroy(service *vpcv1.VpcV1, id string) (interface{}, error)

func (VpcSpecificFloatingIPInstance) Get

func (spec VpcSpecificFloatingIPInstance) Get(service *vpcv1.VpcV1, id string) (string, bool, interface{}, error)

type VpcSpecificFlowLogCollectorInstance

type VpcSpecificFlowLogCollectorInstance struct{}

func (VpcSpecificFlowLogCollectorInstance) Destroy

func (vpc VpcSpecificFlowLogCollectorInstance) Destroy(service *vpcv1.VpcV1, id string) (interface{}, error)

func (VpcSpecificFlowLogCollectorInstance) Get

func (spec VpcSpecificFlowLogCollectorInstance) Get(service *vpcv1.VpcV1, id string) (string, bool, interface{}, error)

type VpcSpecificImageInstance

type VpcSpecificImageInstance struct{}

func (VpcSpecificImageInstance) Destroy

func (vpc VpcSpecificImageInstance) Destroy(service *vpcv1.VpcV1, id string) (interface{}, error)

func (VpcSpecificImageInstance) Get

func (spec VpcSpecificImageInstance) Get(service *vpcv1.VpcV1, id string) (string, bool, interface{}, error)

type VpcSpecificInstanceGroupInstance

type VpcSpecificInstanceGroupInstance struct{}

func (VpcSpecificInstanceGroupInstance) Destroy

func (vpc VpcSpecificInstanceGroupInstance) Destroy(service *vpcv1.VpcV1, id string) (interface{}, error)

func (VpcSpecificInstanceGroupInstance) Get

func (spec VpcSpecificInstanceGroupInstance) Get(service *vpcv1.VpcV1, id string) (string, bool, interface{}, error)

type VpcSpecificInstanceInstance

type VpcSpecificInstanceInstance struct{}

func (VpcSpecificInstanceInstance) Destroy

func (vpc VpcSpecificInstanceInstance) Destroy(service *vpcv1.VpcV1, id string) (interface{}, error)

func (VpcSpecificInstanceInstance) Get

func (spec VpcSpecificInstanceInstance) Get(service *vpcv1.VpcV1, id string) (string, bool, interface{}, error)

type VpcSpecificInstanceTemplateInstance

type VpcSpecificInstanceTemplateInstance struct{}

func (VpcSpecificInstanceTemplateInstance) Destroy

func (vpc VpcSpecificInstanceTemplateInstance) Destroy(service *vpcv1.VpcV1, id string) (interface{}, error)

func (VpcSpecificInstanceTemplateInstance) Get

func (spec VpcSpecificInstanceTemplateInstance) Get(service *vpcv1.VpcV1, id string) (string, bool, interface{}, error)

type VpcSpecificKeyInstance

type VpcSpecificKeyInstance struct{}

func (VpcSpecificKeyInstance) Destroy

func (vpc VpcSpecificKeyInstance) Destroy(service *vpcv1.VpcV1, id string) (interface{}, error)

func (VpcSpecificKeyInstance) Get

func (spec VpcSpecificKeyInstance) Get(service *vpcv1.VpcV1, id string) (string, bool, interface{}, error)

type VpcSpecificLoadBalancerInstance

type VpcSpecificLoadBalancerInstance struct{}

func (VpcSpecificLoadBalancerInstance) Destroy

func (vpc VpcSpecificLoadBalancerInstance) Destroy(service *vpcv1.VpcV1, id string) (interface{}, error)

func (VpcSpecificLoadBalancerInstance) Get

func (spec VpcSpecificLoadBalancerInstance) Get(service *vpcv1.VpcV1, id string) (string, bool, interface{}, error)

type VpcSpecificNetworkACLInstance

type VpcSpecificNetworkACLInstance struct{}

func (VpcSpecificNetworkACLInstance) Destroy

func (vpc VpcSpecificNetworkACLInstance) Destroy(service *vpcv1.VpcV1, id string) (interface{}, error)

func (VpcSpecificNetworkACLInstance) Get

func (spec VpcSpecificNetworkACLInstance) Get(service *vpcv1.VpcV1, id string) (string, bool, interface{}, error)

type VpcSpecificPublicGatewayInstance

type VpcSpecificPublicGatewayInstance struct{}

func (VpcSpecificPublicGatewayInstance) Destroy

func (vpc VpcSpecificPublicGatewayInstance) Destroy(service *vpcv1.VpcV1, id string) (interface{}, error)

func (VpcSpecificPublicGatewayInstance) Get

func (spec VpcSpecificPublicGatewayInstance) Get(service *vpcv1.VpcV1, id string) (string, bool, interface{}, error)

type VpcSpecificSecurityGroupInstance

type VpcSpecificSecurityGroupInstance struct{}

func (VpcSpecificSecurityGroupInstance) Destroy

func (vpc VpcSpecificSecurityGroupInstance) Destroy(service *vpcv1.VpcV1, id string) (interface{}, error)

func (VpcSpecificSecurityGroupInstance) Get

func (spec VpcSpecificSecurityGroupInstance) Get(service *vpcv1.VpcV1, id string) (string, bool, interface{}, error)

type VpcSpecificSubnetInstance

type VpcSpecificSubnetInstance struct{}

func (VpcSpecificSubnetInstance) Destroy

func (vpc VpcSpecificSubnetInstance) Destroy(service *vpcv1.VpcV1, id string) (interface{}, error)

func (VpcSpecificSubnetInstance) Get

func (spec VpcSpecificSubnetInstance) Get(service *vpcv1.VpcV1, id string) (string, bool, interface{}, error)

type VpcSpecificVPCInstance

type VpcSpecificVPCInstance struct{}

func (VpcSpecificVPCInstance) Destroy

func (vpc VpcSpecificVPCInstance) Destroy(service *vpcv1.VpcV1, id string) (interface{}, error)

func (VpcSpecificVPCInstance) Get

func (spec VpcSpecificVPCInstance) Get(service *vpcv1.VpcV1, id string) (string, bool, interface{}, error)

type VpcSpecificVPNGatewayInstance

type VpcSpecificVPNGatewayInstance struct{}

These are irregular operations, notice the switch statements

func (VpcSpecificVPNGatewayInstance) Destroy

func (vpc VpcSpecificVPNGatewayInstance) Destroy(service *vpcv1.VpcV1, id string) (interface{}, error)

func (VpcSpecificVPNGatewayInstance) Get

func (spec VpcSpecificVPNGatewayInstance) Get(service *vpcv1.VpcV1, id string) (string, bool, interface{}, error)

type VpcSpecificVolumeInstance

type VpcSpecificVolumeInstance struct{}

func (VpcSpecificVolumeInstance) Destroy

func (vpc VpcSpecificVolumeInstance) Destroy(service *vpcv1.VpcV1, id string) (interface{}, error)

func (VpcSpecificVolumeInstance) Get

func (spec VpcSpecificVolumeInstance) Get(service *vpcv1.VpcV1, id string) (string, bool, interface{}, error)

type VpcSubtypeOperations

type VpcSubtypeOperations interface {
	Get(service *vpcv1.VpcV1, id string) (string, bool, interface{}, error)
	Destroy(service *vpcv1.VpcV1, id string) (interface{}, error)
}

Jump to

Keyboard shortcuts

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