Skip to content

Commit

Permalink
chore(cli): address feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
bvtujo committed Jan 16, 2021
1 parent 658ad78 commit b92cf61
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 118 deletions.
1 change: 0 additions & 1 deletion internal/pkg/cli/interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,6 @@ type appResourcesGetter interface {

type taskDeployer interface {
DeployTask(input *deploy.CreateTaskResourcesInput, opts ...cloudformation.StackOption) error
DeleteTask(task deploy.TaskStackInfo) error
}

type taskRunner interface {
Expand Down
67 changes: 0 additions & 67 deletions internal/pkg/cli/mocks/mock_interfaces.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

57 changes: 7 additions & 50 deletions internal/pkg/cli/task_delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,11 @@ type deleteTaskOpts struct {
// Dependencies to interact with other modules
store store
prompt prompter
// spinner progress
sess sessionProvider
sel wsSelector
sess sessionProvider
sel wsSelector

// Generators for env-specific clients
newTaskSel func(session *awssession.Session) cfTaskSelector
// newTaskStopper func(session *awssession.Session) tasksStopper
// newTaskLister func(session *awssession.Session) tasksLister
// newImageRemover func(session *awssession.Session) imageRemover
// newTaskDeleter func(session *awssession.Session) taskDeployer
}

func newDeleteTaskOpts(vars deleteTaskVars) (*deleteTaskOpts, error) {
Expand All @@ -75,27 +70,14 @@ func newDeleteTaskOpts(vars deleteTaskVars) (*deleteTaskOpts, error) {
return &deleteTaskOpts{
deleteTaskVars: vars,

store: store,
// spinner: termprogress.NewSpinner(log.DiagnosticWriter),
store: store,
prompt: prompter,
sess: provider,
sel: selector.NewWorkspaceSelect(prompter, store, ws),
newTaskSel: func(session *awssession.Session) cfTaskSelector {
cfn := cloudformation.New(session)
return selector.NewCFTaskSelect(prompter, store, cfn)
},
// newTaskLister: func(session *awssession.Session) tasksLister {
// return ecs.New(session)
// },
// newTaskStopper: func(session *awssession.Session) tasksStopper {
// return ecs.New(session)
// },
// newTaskDeleter: func(session *awssession.Session) taskDeployer {
// return cloudformation.New(session)
// },
// newImageRemover: func(session *awssession.Session) imageRemover {
// return ecr.New(session)
// },
}, nil
}

Expand All @@ -122,15 +104,13 @@ func (o *deleteTaskOpts) Validate() error {

func (o *deleteTaskOpts) validateFlagsWithEnv() error {
if o.app != "" {
err := o.validateAppName()
if err != nil {
return err
if _, err := o.store.GetApplication(o.app); err != nil {
return fmt.Errorf("get application: %w", err)
}
}

if o.env != "" {
err := o.validateEnvName()
if err != nil {
if o.env != "" && o.app != "" {
if _, err := o.store.GetEnvironment(o.app, o.env); err != nil {
return err
}
}
Expand Down Expand Up @@ -161,29 +141,6 @@ func (o *deleteTaskOpts) validateFlagsWithDefaultCluster() error {
return nil
}

func (o *deleteTaskOpts) validateEnvName() error {
if _, err := o.targetEnv(); err != nil {
return err
}

return nil
}

func (o *deleteTaskOpts) validateAppName() error {
if _, err := o.store.GetApplication(o.app); err != nil {
return fmt.Errorf("get application: %w", err)
}
return nil
}

func (o *deleteTaskOpts) targetEnv() (*config.Environment, error) {
env, err := o.store.GetEnvironment(o.app, o.env)
if err != nil {
return nil, fmt.Errorf("get environment %s config: %w", o.env, err)
}
return env, nil
}

func (o *deleteTaskOpts) askAppName() error {
if o.defaultCluster {
return nil
Expand Down

0 comments on commit b92cf61

Please sign in to comment.