refactor: add general tasks to the existing tasks

This commit is contained in:
oscarzhou 2023-01-08 21:39:25 +13:00
parent 2839a68c6a
commit 96cb2cc8a4
6 changed files with 57 additions and 6 deletions

View File

@ -1,10 +1,12 @@
package tasks
import (
"ocl/portainer-devtool/tasks/common"
"ocl/portainer-devtool/utils"
)
type CodeSecurityScanTask struct {
ParentTasks []common.Tasker
}
func NewCodeSecurityScanTask() *CodeSecurityScanTask {
@ -30,6 +32,10 @@ func (task *CodeSecurityScanTask) Execute() error {
return nil
}
func (task *CodeSecurityScanTask) SetParentTaskers(tasks []common.Tasker) {
task.ParentTasks = tasks
}
func (task *CodeSecurityScanTask) String() string {
return "Code Security Scan"
}

View File

@ -2,10 +2,12 @@ package tasks
import (
"fmt"
"ocl/portainer-devtool/tasks/common"
"ocl/portainer-devtool/utils"
)
type CurlLookupTask struct {
ParentTasks []common.Tasker
}
func NewCurlLookupTask() *CurlLookupTask {
@ -43,6 +45,10 @@ func (task *CurlLookupTask) Execute() error {
return nil
}
func (task *CurlLookupTask) SetParentTaskers(tasks []common.Tasker) {
task.ParentTasks = tasks
}
func (task *CurlLookupTask) String() string {
return "Lookup Curl Commands"
}

View File

@ -7,10 +7,11 @@ import (
"io/ioutil"
"net/http"
"ocl/portainer-devtool/configs"
"ocl/portainer-devtool/tasks/common"
)
type GenerateJwtTokenTask struct {
Config *configs.Config
common.GeneralTask
}
type GenerateJwtTokenResponse struct {
@ -19,7 +20,7 @@ type GenerateJwtTokenResponse struct {
func NewGenerateJwtTokenTask(cfg *configs.Config) *GenerateJwtTokenTask {
return &GenerateJwtTokenTask{
Config: cfg,
GeneralTask: *common.NewGeneralTask(cfg),
}
}

View File

@ -0,0 +1,36 @@
package tasks
import (
"ocl/portainer-devtool/configs"
"ocl/portainer-devtool/repositories/unpacker"
"ocl/portainer-devtool/tasks/common"
)
type ListRepoActionsSubTask struct {
Config *configs.Config
ParentTasks []common.Tasker
}
func NewListRepoActionsSubTask(cfg *configs.Config) *ListRepoActionsSubTask {
return &ListRepoActionsSubTask{
Config: cfg,
}
}
func (task *ListRepoActionsSubTask) Execute() error {
subTaskItems := []common.Tasker{
unpacker.NewBuildDockerImageSubTask(task.Config),
}
common.ListCommandMenu(subTaskItems, "Which management commands do you want to choose:", false, task.ParentTasks)
return nil
}
func (task *ListRepoActionsSubTask) SetParentTaskers(tasks []common.Tasker) {
task.ParentTasks = tasks
}
func (task *ListRepoActionsSubTask) String() string {
return "Choose Repository Commands"
}

View File

@ -2,17 +2,18 @@ package subtasks
import (
"ocl/portainer-devtool/configs"
"ocl/portainer-devtool/tasks/common"
"ocl/portainer-devtool/utils"
"strings"
)
type ListRepositorySubTask struct {
Config *configs.Config
common.GeneralTask
}
func NewListRepositorySubTask(cfg *configs.Config) *ListRepositorySubTask {
return &ListRepositorySubTask{
Config: cfg,
GeneralTask: *common.NewGeneralTask(cfg),
}
}

View File

@ -4,18 +4,19 @@ import (
"fmt"
"io/fs"
"ocl/portainer-devtool/configs"
"ocl/portainer-devtool/tasks/common"
"ocl/portainer-devtool/utils"
"path/filepath"
"strings"
)
type ListVolumeSubTask struct {
Config *configs.Config
common.GeneralTask
}
func NewListVolumeSubTask(cfg *configs.Config) *ListVolumeSubTask {
return &ListVolumeSubTask{
Config: cfg,
GeneralTask: *common.NewGeneralTask(cfg),
}
}