Documentation
¶
Overview ¶
Package instancegroup is a generated GoMock package.
Index ¶
- type BaseHandler
- type CleanupHandler
- type Config
- type CreateHandler
- type Instance
- type InstanceGroup
- type MockInstanceGroup
- func (m *MockInstanceGroup) Decrease(ctx context.Context, iids []string) ([]string, error)
- func (m *MockInstanceGroup) EXPECT() *MockInstanceGroupMockRecorder
- func (m *MockInstanceGroup) Get(ctx context.Context, iid string) (*Instance, error)
- func (m *MockInstanceGroup) Increase(ctx context.Context, delta int) ([]string, error)
- func (m *MockInstanceGroup) Init(ctx context.Context) error
- func (m *MockInstanceGroup) List(ctx context.Context) ([]*Instance, error)
- func (m *MockInstanceGroup) Sanity(ctx context.Context) error
- type MockInstanceGroupMockRecorder
- func (mr *MockInstanceGroupMockRecorder) Decrease(ctx, iids any) *gomock.Call
- func (mr *MockInstanceGroupMockRecorder) Get(ctx, iid any) *gomock.Call
- func (mr *MockInstanceGroupMockRecorder) Increase(ctx, delta any) *gomock.Call
- func (mr *MockInstanceGroupMockRecorder) Init(ctx any) *gomock.Call
- func (mr *MockInstanceGroupMockRecorder) List(ctx any) *gomock.Call
- func (mr *MockInstanceGroupMockRecorder) Sanity(ctx any) *gomock.Call
- type PreDecreaseHandler
- type PreIncreaseHandler
- type SanityHandler
- type ServerHandler
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BaseHandler ¶
type BaseHandler struct{}
BaseHandler configure the instance server create options with the instance group configuration.
type CleanupHandler ¶
type Config ¶
type Config struct {
// Location is the Scaleway "Zone" name to create the server in.
// Refer to https://www.scaleway.com/en/docs/account/reference-content/products-availability/ to list available zones.
Zone string
// ServerNamePrefix is the prefix of the server name. The server name will be
// generated by appending a random suffix to this prefix.
ServerNamePrefix string
// ServerTypes is a list of Scaleway "Server Type" names or ids to create the server with.
// Run `scw instance server-type list` to list available server types.
// The system will check availability of each type and filter out types with shortage.
// Then it will attempt to create a server with each available type in order until one succeeds.
// Both "available" and "scarce" availability states are accepted; only "shortage" is filtered out.
ServerTypes []string
// PublicIPv4Disabled indicates whether the server should be created without a public IPv4 address.
// If set to true, the server will not have a public IPv4 address.
PublicIPv4Disabled bool
// PublicIPv6Disabled indicates whether the server should be created without a public IPv6 address.
// If set to true, the server will not have a public IPv6 address.
PublicIPv6Disabled bool
// PrivateNetworkIDs is a list of private networks IDs to attach the server to.
// Run `scw vpc private-network list` to list available private networks.
PrivateNetworkIDs []string
// Image is the Scaleway "Image" (name or id) to create the server with. Run
// `scw image list` to list available images.
Image string
// CloudInit is the data available to initialization framework that may run after the
// server boot.
CloudInit string
// VolumeType is the type of volume to attach to the server. It must be either empty, 'l_ssd', 'b_ssd' or 'sbs_volume'.
VolumeType string
// VolumeSize is the size in GB of the volume that will be attached to the server.
VolumeSize uint16
// VolumeIops is the number of IOPS to allocate for the volume.
VolumeIops uint16
// Tags is a list of tags to apply to the server.
Tags []string
}
type CreateHandler ¶
type Instance ¶
type Instance struct {
// Name of the instance, used for the underlying server and other attached resources.
Name string
// ID of the instance's underlying server.
ID string
// ServerType is the commercial type of the server (e.g., "GP1-XS", "DEV1-L").
// This field is populated after server creation and is included in the IID for visibility.
ServerType string
// Server is the instance's underlying server, and must never be partially populated.
Server *scwInstance.Server
// contains filtered or unexported fields
}
func InstanceFromIID ¶
func InstanceFromServer ¶
func InstanceFromServer(server *scwInstance.Server) *Instance
func NewInstance ¶
func (*Instance) IID ¶
IID holds the data to identify the instance outside of the instance group.
Formats:
- Legacy: "name:id" (no server type)
- With server type: "name:id:server-type"
Example: "scaleway-dev1-l-80gb:abc123-server-id:gp1-xs"
The server type is included so users can see which SKU was actually provisioned, especially useful when fallback to alternative types occurs.
type InstanceGroup ¶
type InstanceGroup interface {
Init(ctx context.Context) error
Increase(ctx context.Context, delta int) ([]string, error)
Decrease(ctx context.Context, iids []string) ([]string, error)
List(ctx context.Context) ([]*Instance, error)
Get(ctx context.Context, iid string) (*Instance, error)
Sanity(ctx context.Context) error
}
type MockInstanceGroup ¶
type MockInstanceGroup struct {
// contains filtered or unexported fields
}
MockInstanceGroup is a mock of InstanceGroup interface.
func NewMockInstanceGroup ¶
func NewMockInstanceGroup(ctrl *gomock.Controller) *MockInstanceGroup
NewMockInstanceGroup creates a new mock instance.
func (*MockInstanceGroup) EXPECT ¶
func (m *MockInstanceGroup) EXPECT() *MockInstanceGroupMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockInstanceGroup) Init ¶
func (m *MockInstanceGroup) Init(ctx context.Context) error
Init mocks base method.
type MockInstanceGroupMockRecorder ¶
type MockInstanceGroupMockRecorder struct {
// contains filtered or unexported fields
}
MockInstanceGroupMockRecorder is the mock recorder for MockInstanceGroup.
func (*MockInstanceGroupMockRecorder) Decrease ¶
func (mr *MockInstanceGroupMockRecorder) Decrease(ctx, iids any) *gomock.Call
Decrease indicates an expected call of Decrease.
func (*MockInstanceGroupMockRecorder) Get ¶
func (mr *MockInstanceGroupMockRecorder) Get(ctx, iid any) *gomock.Call
Get indicates an expected call of Get.
func (*MockInstanceGroupMockRecorder) Increase ¶
func (mr *MockInstanceGroupMockRecorder) Increase(ctx, delta any) *gomock.Call
Increase indicates an expected call of Increase.
func (*MockInstanceGroupMockRecorder) Init ¶
func (mr *MockInstanceGroupMockRecorder) Init(ctx any) *gomock.Call
Init indicates an expected call of Init.
type PreDecreaseHandler ¶
type PreIncreaseHandler ¶
type SanityHandler ¶
type ServerHandler ¶
type ServerHandler struct{}
ServerHandler implements transactional instance creation with automatic rollback. If Create() fails at any step, all partially created resources are immediately cleaned up via a deferred Cleanup call. This ensures no orphaned resources remain.
func (*ServerHandler) Cleanup ¶
func (h *ServerHandler) Cleanup(ctx context.Context, group *instanceGroup, instance *Instance) error
Cleanup is idempotent and safe to call multiple times on the same instance. It handles missing resources (404) gracefully and retries transient API errors. Resources are discovered both by direct server lookup and by tag-based search, ensuring orphaned resources from partial failures are also cleaned up.