ksyun

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2023 License: MPL-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ResourceTypeKec       = "instance"
	ResourceTypeEip       = "eip"
	ResourceTypeImage     = "image"
	ResourceTypeBareHost  = "epc-host"
	ResourceTypeBareImage = "epc-image"
)

Variables

View Source
var (
	RequestResourceSuccess = ProcessRequestResult{
		Complete:  true,
		StopRetry: true,
	}

	RequestResourceRetry = ProcessRequestResult{
		Complete:  false,
		StopRetry: false,
	}
)

Functions

func GetCidrHostNum

func GetCidrHostNum(maskLen int) uint

func GetCidrIpMask

func GetCidrIpMask(maskLen int) string

func GetCidrIpRange

func GetCidrIpRange(cidr string) (string, string, string)

func GetIpSeg3Range

func GetIpSeg3Range(ipSegs []string, maskLen int) (int, int)

func GetIpSeg4Range

func GetIpSeg4Range(ipSegs []string, maskLen int) (int, int)

func GetIpSegRange

func GetIpSegRange(userSegIp, offset uint8) (int, int)

func GetSdkValue

func GetSdkValue(stateBag multistep.StateBag, keyPattern string, obj interface{}) interface{}

func Halt

func Halt(stateBag multistep.StateBag, err error, prefix string) multistep.StepAction

func IsUuid added in v0.3.0

func IsUuid(v string) bool

func SSHHost

func SSHHost(c communicator.Config) func(multistep.StateBag) (string, error)

func StringInSlice added in v0.0.10

func StringInSlice(v string, valid []string, ignoreCase bool) bool

Types

type AccessConfig

type AccessConfig struct {
	// Ksyun access key must be provided unless `profile` is set, but it can
	// also be sourced from the `KSYUN_ACCESS_KEY` environment variable.
	KsyunAccessKey string `mapstructure:"access_key" required:"true"`
	// Ksyun secret key must be provided unless `profile` is set, but it can
	// also be sourced from the `KSYUN_SECRET_KEY` environment variable.
	KsyunSecretKey string `mapstructure:"secret_key" required:"true"`
	// Ksyun region must be provided unless `profile` is set, but it can
	// also be sourced from the `KSYUN_REGION` environment variable.
	KsyunRegion string `mapstructure:"region" required:"true"`
}

func (*AccessConfig) Config

func (c *AccessConfig) Config() error

func (*AccessConfig) Prepare

func (c *AccessConfig) Prepare(ctx *interpolate.Context) []error

type AfterStepRun added in v0.0.10

type AfterStepRun func()

type Artifact added in v0.0.10

type Artifact struct {
	// A map of regions to ksyun image id.
	KsyunImageId string
	// BuilderId is the unique ID for the builder that created this ksyun image
	BuilderIdValue string
}

func (*Artifact) BuilderId added in v0.0.10

func (k *Artifact) BuilderId() string

func (*Artifact) Destroy added in v0.0.10

func (k *Artifact) Destroy() error

func (*Artifact) Files added in v0.0.10

func (k *Artifact) Files() []string

func (*Artifact) Id added in v0.0.10

func (k *Artifact) Id() string

func (*Artifact) State added in v0.0.10

func (k *Artifact) State(name string) interface{}

func (*Artifact) String added in v0.0.10

func (k *Artifact) String() string

type ClientConfig

type ClientConfig struct {
	AccessConfig `mapstructure:",squash"`
	// contains filtered or unexported fields
}

func (*ClientConfig) Client

func (c *ClientConfig) Client(stateBag *multistep.BasicStateBag) *ClientWrapper

type ClientWrapper

type ClientWrapper struct {
	SksClient *sks.Sks
	EipClient *eip.Eip
	VpcClient *vpc.Vpc

	TagsClient *tagv2.Tagv2
}

func (*ClientWrapper) WaitResource

func (c *ClientWrapper) WaitResource(param *WaitResourceParam) (*map[string]interface{}, error)

func (*ClientWrapper) WaitSecurityGroupClean

func (c *ClientWrapper) WaitSecurityGroupClean(stateBag multistep.StateBag, securityGroupId string) (*map[string]interface{}, error)

func (*ClientWrapper) WaitSubnetClean

func (c *ClientWrapper) WaitSubnetClean(stateBag multistep.StateBag, subnetId string) (*map[string]interface{}, error)

type CommonConfig

type CommonConfig struct {
	// VPC ID allocated by the system.
	VpcId string `mapstructure:"vpc_id" required:"false"`
	// the default value is packer_vpc
	VpcName string `mapstructure:"vpc_name" required:"false"`
	// 172.16.0.0/16. When not specified, the default value is 172.16.0.0/16.
	VpcCidrBlock string `mapstructure:"vpc_cidr_block" required:"false"`
	// The ID of the Subnet to be used.
	SubnetId string `mapstructure:"subnet_id" required:"false"`
	// the default value is packer_subnet
	SubnetName string `mapstructure:"subnet_name" required:"false"`
	// 172.16.0.0/24. When not specified, the default value is 172.16.0.0/24.
	DNS1            string `mapstructure:"dns1" required:"false"`
	DNS2            string `mapstructure:"dns2" required:"false"`
	SubnetCidrBlock string `mapstructure:"subnet_cidr_block" required:"false"`
	// availability_zone
	AvailabilityZone string `mapstructure:"availability_zone" required:"false"`
	// ID of the security group to which a newly
	// created instance belongs. Mutual access is allowed between instances in one
	// security group. If not specified, the newly created instance will be added
	// to the default security group. If the default group doesn’t exist, or the
	// number of instances in it has reached the maximum limit, a new security
	// group will be created automatically.
	SecurityGroupId string `mapstructure:"security_group_id" required:"false"`
	// The security group name. The default value
	// is blank. [2, 128] English or Chinese characters, must begin with an
	// uppercase/lowercase letter or Chinese character. Can contain numbers, .,
	// _ or -. It cannot begin with `http://` or `https://`.
	// the default value is packer_security_group
	SecurityGroupName string `mapstructure:"security_group_name" required:"false"`
	// Private IP address, which specifies any valid value within the range of subnet IP address and represents
	// the primary IP address of the instance. Only one can be selected and bound to the primary network card.
	// If this parameter is not specified, the system will automatically select one from the valid address pool at random
	// Valid values: standard IP address format
	PrivateIpAddress string `mapstructure:"private_ip_address" required:"false"`
	// Indicating associate whether public ip for creating kec instance
	// Default `false`
	AssociatePublicIpAddress bool `mapstructure:"associate_public_ip_address" required:"false"`
	// PublicIp charge type, which can be
	// Daily TrafficMonthly DailyPaidByTransfer HourlyInstantSettlement
	// Default is Daily
	PublicIpChargeType string `mapstructure:"public_ip_charge_type" required:"false"`
	// [1-100]
	// Default is 1
	PublicIpBandWidth int `mapstructure:"public_ip_band_width" required:"false"`
	// Default is 0
	ProjectId string `mapstructure:"project_id" required:"false"`

	// Key/value pair tags to apply to the instance that is launched to create the image.
	// These tags are not applied to the resulting image.
	RunTags map[string]string `mapstructure:"run_tags" required:"false"`
	// Same as [`run_tags`](#run_tags) but defined as a singular repeatable
	// block containing a `key` and a `value` field. In HCL2 mode the
	// [`dynamic_block`](/packer/docs/templates/hcl_templates/expressions#dynamic-blocks)
	// will allow you to create those programatically.
	RunTag config.KeyValues `mapstructure:"run_tag" required:"false"`

	// Communicator settings
	Comm communicator.Config `mapstructure:",squash"`
}

type FlatKmiFilterOptions added in v0.2.0

type FlatKmiFilterOptions struct {
	MostRecent  *bool   `mapstructure:"most_recent" cty:"most_recent" hcl:"most_recent"`
	ImageSource *string `mapstructure:"image_source" cty:"image_source" hcl:"image_source"`
	NameRegex   *string `mapstructure:"name_regex" cty:"name_regex" hcl:"name_regex"`
	Platform    *string `mapstructure:"platform" cty:"platform" hcl:"platform"`
}

FlatKmiFilterOptions is an auto-generated flat version of KmiFilterOptions. Where the contents of a field with a `mapstructure:,squash` tag are bubbled up.

func (*FlatKmiFilterOptions) HCL2Spec added in v0.2.0

func (*FlatKmiFilterOptions) HCL2Spec() map[string]hcldec.Spec

HCL2Spec returns the hcl spec of a KmiFilterOptions. This spec is used by HCL to read the fields of KmiFilterOptions. The decoded values from this spec will then be applied to a FlatKmiFilterOptions.

type KmiFilterOptions added in v0.2.0

type KmiFilterOptions struct {
	// Selects the newest created image when true.
	// This is most useful for selecting a daily distro build.
	MostRecent bool `mapstructure:"most_recent"`

	// ImageSource Valid values are import, copy, share, extend, system.
	ImageSource string `mapstructure:"image_source"`

	// NameRegex A regex string to filter resulting images by name.
	// (Such as: `^CentOS 7.[1-2] 64` means CentOS 7.1 of 64-bit operating system or CentOS 7.2 of 64-bit operating system,
	// \"^Ubuntu 16.04 64\" means Ubuntu 16.04 of 64-bit operating system).
	NameRegex string `mapstructure:"name_regex"`

	// Platform type of the image system.
	Platform string `mapstructure:"platform"`
}

func (*KmiFilterOptions) FlatMapstructure added in v0.2.0

func (*KmiFilterOptions) FlatMapstructure() interface{ HCL2Spec() map[string]hcldec.Spec }

FlatMapstructure returns a new FlatKmiFilterOptions. FlatKmiFilterOptions is an auto-generated flat version of KmiFilterOptions. Where the contents a fields with a `mapstructure:,squash` tag are bubbled up.

func (*KmiFilterOptions) GetFilteredImage added in v0.2.0

func (d *KmiFilterOptions) GetFilteredImage(params *map[string]interface{}, kecConn *kec.Kec) (image *Ks3Image, err error)

GetFilteredImage to get source image with filers

func (*KmiFilterOptions) IsEmpty added in v0.2.0

func (d *KmiFilterOptions) IsEmpty() bool

func (*KmiFilterOptions) String added in v0.2.0

func (d *KmiFilterOptions) String() string

type Ks3Image added in v0.2.0

type Ks3Image struct {
	ImageId       string `mapstructure:"ImageId"`
	ImageType     string `mapstructure:"Type"`
	Name          string `mapstructure:"Name"`
	CreationDate  string `mapstructure:"CreationDate"`
	Platform      string `mapstructure:"Platform"`
	ImageSource   string `mapstructure:"ImageSource"`
	RealImageId   string `mapstructure:"RealImageId"`
	IsCloudMarket bool   `mapstructure:"IsCloudMarket"`
	SysDisk       int    `mapstructure:"SysDisk"`
	IsPublic      bool   `mapstructure:"IsPublic"`
}

func (*Ks3Image) Filler added in v0.2.0

func (ki *Ks3Image) Filler(rawMap interface{}) error

type Ks3Images added in v0.2.0

type Ks3Images struct {
	ImagesSet []*Ks3Image `mapstructure:"ImagesSet"`
}

func (*Ks3Images) Filler added in v0.2.0

func (k *Ks3Images) Filler(rawMap interface{}) error

Filler convert map structure to struct.

type ProcessRequestResult

type ProcessRequestResult struct {
	Complete  bool
	StopRetry bool
}

type StepCleanupKsyunTempKeys

type StepCleanupKsyunTempKeys struct {
	Comm                  *communicator.Config
	SSHTemporaryPublicKey *string
}

func (*StepCleanupKsyunTempKeys) Cleanup

func (s *StepCleanupKsyunTempKeys) Cleanup(state multistep.StateBag)

func (*StepCleanupKsyunTempKeys) Run

type StepConfigKsyunCommon

type StepConfigKsyunCommon struct {
	CommonConfig *CommonConfig
}

func (*StepConfigKsyunCommon) Cleanup

func (s *StepConfigKsyunCommon) Cleanup(stateBag multistep.StateBag)

func (*StepConfigKsyunCommon) Run

type StepConfigKsyunKeyPair

type StepConfigKsyunKeyPair struct {
	CommonConfig *CommonConfig

	SSHTemporaryPublicKey *string
	// contains filtered or unexported fields
}

func (*StepConfigKsyunKeyPair) Cleanup

func (s *StepConfigKsyunKeyPair) Cleanup(stateBag multistep.StateBag)

func (*StepConfigKsyunKeyPair) Run

type StepConfigKsyunPublicIp

type StepConfigKsyunPublicIp struct {
	CommonConfig *CommonConfig
	// contains filtered or unexported fields
}

func (*StepConfigKsyunPublicIp) Cleanup

func (s *StepConfigKsyunPublicIp) Cleanup(stateBag multistep.StateBag)

func (*StepConfigKsyunPublicIp) Run

type StepConfigKsyunSecurityGroup

type StepConfigKsyunSecurityGroup struct {
	CommonConfig *CommonConfig

	Index int
	After AfterStepRun
	// contains filtered or unexported fields
}

func (*StepConfigKsyunSecurityGroup) Cleanup

func (s *StepConfigKsyunSecurityGroup) Cleanup(stateBag multistep.StateBag)

func (*StepConfigKsyunSecurityGroup) Run

type StepConfigKsyunSubnet

type StepConfigKsyunSubnet struct {
	CommonConfig *CommonConfig

	SubnetType string
	Index      int
	After      AfterStepRun
	// contains filtered or unexported fields
}

func (*StepConfigKsyunSubnet) Cleanup

func (s *StepConfigKsyunSubnet) Cleanup(stateBag multistep.StateBag)

func (*StepConfigKsyunSubnet) Run

type StepConfigKsyunVpc

type StepConfigKsyunVpc struct {
	CommonConfig *CommonConfig

	After AfterStepRun
	// contains filtered or unexported fields
}

func (*StepConfigKsyunVpc) Cleanup

func (s *StepConfigKsyunVpc) Cleanup(stateBag multistep.StateBag)

func (*StepConfigKsyunVpc) Run

type StepCreateKsyunTags added in v0.3.0

type StepCreateKsyunTags struct {
	Tags map[string]string

	// tag resource type Values: instance, epc-host, epc-image, image, eip
	ResourceType string
}

func (*StepCreateKsyunTags) Cleanup added in v0.3.0

func (s *StepCreateKsyunTags) Cleanup(stateBag multistep.StateBag)

func (*StepCreateKsyunTags) Run added in v0.3.0

type Tag added in v0.3.0

type Tag struct {
	Id         int    `mapstructure:"Id"`
	Key        string `mapstructure:"Key"`
	Value      string `mapstructure:"Value"`
	CreateTime string `mapstructure:"CreateTime"`
	CanDelete  int    `mapstructure:"CanDelete"`
	IsBillTag  int    `mapstructure:"IsBillTag"`
}

type TagMap added in v0.3.0

type TagMap map[string]string

func (TagMap) KsyunTags added in v0.3.0

func (t TagMap) KsyunTags() Tags

type Tags added in v0.3.0

type Tags []*Tag

func (Tags) GetTagsParams added in v0.3.0

func (t Tags) GetTagsParams(rsType, rsUuid string) (map[string]interface{}, error)

func (Tags) Pinning added in v0.3.0

func (t Tags) Pinning(rsType, rsUuid string, client *tagv2.Tagv2) error

func (Tags) Report added in v0.3.0

func (t Tags) Report(ui packersdk.Ui)

type WaitResourceParam

type WaitResourceParam struct {
	RequestResource func() (*map[string]interface{}, error)
	ProcessRequest  func(*map[string]interface{}, error) ProcessRequestResult
	RetryInterval   time.Duration
	RetryTimes      int
}

Directories

Path Synopsis
The ksyun contains a packersdk.Builder implementation that builds ecs images for ksyun.
The ksyun contains a packersdk.Builder implementation that builds ecs images for ksyun.

Jump to

Keyboard shortcuts

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