task: add operation menu task and test environment task
This commit is contained in:
parent
3c28c8cdd9
commit
dcf30657c1
@ -18,7 +18,9 @@ func main() {
|
||||
// Init tasks
|
||||
taskItems := []common.Tasker{
|
||||
tasks.NewListRepositoryMenuTask(config),
|
||||
tasks.NewListOperationMenuTask(config),
|
||||
tasks.NewGenerateJwtTokenTask(config),
|
||||
tasks.NewTestEnvironmentTask(),
|
||||
tasks.NewCurlLookupTask(),
|
||||
tasks.NewCodeSecurityScanTask(),
|
||||
tasks.NewListDevToolCommandTask(config),
|
||||
|
33
go/operations/edgestack/menu.go
Normal file
33
go/operations/edgestack/menu.go
Normal file
@ -0,0 +1,33 @@
|
||||
package edgestack
|
||||
|
||||
import (
|
||||
"ocl/portainer-devtool/configs"
|
||||
"ocl/portainer-devtool/tasks/common"
|
||||
)
|
||||
|
||||
type OperationMenuSubTask struct {
|
||||
common.GeneralTask
|
||||
}
|
||||
|
||||
func NewOperationMenuSubTask(cfg *configs.Config) *OperationMenuSubTask {
|
||||
return &OperationMenuSubTask{
|
||||
GeneralTask: *common.NewGeneralTask(cfg),
|
||||
}
|
||||
}
|
||||
|
||||
func (task *OperationMenuSubTask) Execute() error {
|
||||
subTaskItems := []common.Tasker{
|
||||
NewTagOfficialImageSubTask(task.Config),
|
||||
}
|
||||
|
||||
for _, taskItem := range subTaskItems {
|
||||
taskItem.SetParentTaskers(subTaskItems)
|
||||
}
|
||||
common.ListCommandMenu(subTaskItems, "Which management commands do you want to choose:", false, task.ParentTasks)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (task *OperationMenuSubTask) String() string {
|
||||
return "edgestack"
|
||||
}
|
40
go/operations/edgestack/tag_official_image.go
Normal file
40
go/operations/edgestack/tag_official_image.go
Normal file
@ -0,0 +1,40 @@
|
||||
package edgestack
|
||||
|
||||
import (
|
||||
"ocl/portainer-devtool/configs"
|
||||
"ocl/portainer-devtool/tasks/common"
|
||||
"ocl/portainer-devtool/utils"
|
||||
)
|
||||
|
||||
type TagOfficialImageSubTask struct {
|
||||
common.GeneralTask
|
||||
}
|
||||
|
||||
func NewTagOfficialImageSubTask(cfg *configs.Config) *TagOfficialImageSubTask {
|
||||
return &TagOfficialImageSubTask{
|
||||
GeneralTask: *common.NewGeneralTask(cfg),
|
||||
}
|
||||
}
|
||||
|
||||
func (task *TagOfficialImageSubTask) Execute() error {
|
||||
utils.SuccessPrint(`
|
||||
docker pull nginx:latest
|
||||
docker image tag nginx:latest ghcr.io/oscarzhou-portainer/nginx:1
|
||||
docker push ghcr.io/oscarzhou-portainer/nginx:1
|
||||
-----------------
|
||||
version: '3'
|
||||
|
||||
services:
|
||||
nginx-container:
|
||||
image: ghcr.io/oscarzhou-portainer/nginx:1
|
||||
container_name: "nginx-from-ghcr"
|
||||
ports:
|
||||
- "${PORT:-81}:80"
|
||||
`)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (task *TagOfficialImageSubTask) String() string {
|
||||
return "Create Image for Private Registry"
|
||||
}
|
35
go/tasks/list_ops_menus.go
Normal file
35
go/tasks/list_ops_menus.go
Normal file
@ -0,0 +1,35 @@
|
||||
package tasks
|
||||
|
||||
import (
|
||||
"ocl/portainer-devtool/configs"
|
||||
"ocl/portainer-devtool/operations/edgestack"
|
||||
"ocl/portainer-devtool/tasks/common"
|
||||
)
|
||||
|
||||
type ListOperationMenuTask struct {
|
||||
common.GeneralTask
|
||||
}
|
||||
|
||||
func NewListOperationMenuTask(cfg *configs.Config) *ListOperationMenuTask {
|
||||
return &ListOperationMenuTask{
|
||||
GeneralTask: *common.NewGeneralTask(cfg),
|
||||
}
|
||||
}
|
||||
|
||||
func (task *ListOperationMenuTask) Execute() error {
|
||||
subTaskItems := []common.Tasker{
|
||||
edgestack.NewOperationMenuSubTask(task.Config),
|
||||
}
|
||||
|
||||
for _, taskItem := range subTaskItems {
|
||||
taskItem.SetParentTaskers(subTaskItems)
|
||||
}
|
||||
|
||||
common.ListCommandMenu(subTaskItems, "Which management commands do you want to choose:", false, task.ParentTasks)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (task *ListOperationMenuTask) String() string {
|
||||
return "Choose Operations"
|
||||
}
|
30
go/tasks/test-env.go
Normal file
30
go/tasks/test-env.go
Normal file
@ -0,0 +1,30 @@
|
||||
package tasks
|
||||
|
||||
import (
|
||||
"ocl/portainer-devtool/tasks/common"
|
||||
"ocl/portainer-devtool/utils"
|
||||
)
|
||||
|
||||
type TestEnvironmentTask struct {
|
||||
ParentTasks []common.Tasker
|
||||
}
|
||||
|
||||
func NewTestEnvironmentTask() *TestEnvironmentTask {
|
||||
return &TestEnvironmentTask{}
|
||||
}
|
||||
|
||||
func (task *TestEnvironmentTask) Execute() error {
|
||||
utils.SuccessPrint(`
|
||||
https://github.com/portainer/platform/actions
|
||||
`)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (task *TestEnvironmentTask) SetParentTaskers(tasks []common.Tasker) {
|
||||
task.ParentTasks = tasks
|
||||
}
|
||||
|
||||
func (task *TestEnvironmentTask) String() string {
|
||||
return "Create Testing Environment(VPN)"
|
||||
}
|
Loading…
Reference in New Issue
Block a user