diff --git a/pkg/instance/pool.go b/pkg/instance/pool.go deleted file mode 100644 index 31540465..00000000 --- a/pkg/instance/pool.go +++ /dev/null @@ -1,77 +0,0 @@ -package instance - -import ( - "context" - "fmt" -) - -// InstancePool is a struct that represents a pool of instances -type InstancePool struct { - instances []*Instance - amount int -} - -// NewPool creates a pool of instances -// This function can only be called in the state 'Committed' -func (i *Instance) NewPool(amount int) (*InstancePool, error) { - if !i.IsInState(StateCommitted) { - return nil, ErrCreatingPoolNotAllowed.WithParams(i.state.String()) - } - instances := make([]*Instance, amount) - for j := 0; j < amount; j++ { - instances[j] = i.CloneWithSuffix(fmt.Sprintf("-%d", j)) - } - - i.state = StateDestroyed - i.Logger.Debugf("Set state of instance '%s' to '%s'", i.name, i.state.String()) - - return &InstancePool{ - instances: instances, - amount: amount, - }, nil -} - -// Instances returns the instances in the instance pool -func (i *InstancePool) Instances() []*Instance { - return i.instances -} - -// StartWithoutWait starts all instances in the instance pool without waiting for them to be running -func (i *InstancePool) StartWithoutWait(ctx context.Context) error { - for _, instance := range i.instances { - if err := instance.StartAsync(ctx); err != nil { - return err - } - } - return nil -} - -// Start starts all instances in the instance pool -func (i *InstancePool) Start(ctx context.Context) error { - for _, instance := range i.instances { - if err := instance.Start(ctx); err != nil { - return err - } - } - return nil -} - -// Destroy destroys all instances in the instance pool -func (i *InstancePool) Destroy(ctx context.Context) error { - for _, instance := range i.instances { - if err := instance.Destroy(ctx); err != nil { - return err - } - } - return nil -} - -// WaitInstancePoolIsRunning waits until all instances in the instance pool are running -func (i *InstancePool) WaitInstancePoolIsRunning(ctx context.Context) error { - for _, instance := range i.instances { - if err := instance.WaitInstanceIsRunning(ctx); err != nil { - return err - } - } - return nil -} diff --git a/pkg/knuu/instance_old.go b/pkg/knuu/instance_old.go index 4381970d..e7bf5bc1 100644 --- a/pkg/knuu/instance_old.go +++ b/pkg/knuu/instance_old.go @@ -29,10 +29,6 @@ type Executor struct { *Instance } -type InstancePool struct { - instance.InstancePool -} - type InstanceState instance.InstanceState const ( @@ -321,45 +317,6 @@ func BatchDestroy(instances ...*Instance) error { return instance.BatchDestroy(context.Background(), ins...) } -// Deprecated: Use the new package knuu instead. -func (i *Instance) CreatePool(amount int) (*InstancePool, error) { - pool, err := i.Instance.NewPool(amount) - if err != nil { - return nil, err - } - return &InstancePool{*pool}, nil -} - -// Deprecated: Use the new package knuu instead. -func (i *InstancePool) StartWithoutWait() error { - return i.InstancePool.StartWithoutWait(context.Background()) -} - -// Deprecated: Use the new package knuu instead. -func (i *InstancePool) Start() error { - return i.InstancePool.Start(context.Background()) -} - -// Deprecated: Use the new package knuu instead. -func (i *InstancePool) Destroy() error { - return i.InstancePool.Destroy(context.Background()) -} - -// Deprecated: Use the new package knuu instead. -func (i *InstancePool) WaitInstancePoolIsRunning() error { - return i.InstancePool.WaitInstancePoolIsRunning(context.Background()) -} - -// Deprecated: Use the new package knuu instead. -func (i *InstancePool) Instances() []*Instance { - instances := i.InstancePool.Instances() - newInstances := make([]*Instance, len(instances)) - for i, instance := range instances { - newInstances[i] = &Instance{*instance} - } - return newInstances -} - // Deprecated: Use the new package knuu instead. func (i *Instance) Labels() map[string]string { return i.Instance.Labels()