refactor: add general tasks to the existing tasks

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

View File

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

View File

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

View File

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