Compare commits

..

2 Commits

10 changed files with 224 additions and 71 deletions

View File

@ -17,7 +17,7 @@ func main() {
// Init tasks
taskItems := []common.Tasker{
tasks.NewListRepositoriesTask(config),
tasks.NewListRepositoryMenuTask(config),
tasks.NewGenerateJwtTokenTask(config),
tasks.NewCurlLookupTask(),
tasks.NewCodeSecurityScanTask(),

View File

@ -0,0 +1,30 @@
package agent
import (
"ocl/portainer-devtool/configs"
"ocl/portainer-devtool/tasks/common"
"ocl/portainer-devtool/utils"
)
type BuildDockerImageSubTask struct {
common.GeneralTask
}
func NewBuildDockerImageSubTask(cfg *configs.Config) *BuildDockerImageSubTask {
return &BuildDockerImageSubTask{
GeneralTask: *common.NewGeneralTask(cfg),
}
}
func (task *BuildDockerImageSubTask) Execute() error {
utils.SuccessPrint(`
./dev.sh compile
./dev.sh build
`)
return nil
}
func (task *BuildDockerImageSubTask) String() string {
return "Build Docker Image"
}

View File

@ -0,0 +1,31 @@
package agent
import (
"ocl/portainer-devtool/configs"
"ocl/portainer-devtool/tasks/common"
)
type MenuSubTask struct {
common.GeneralTask
}
func NewMenuSubTask(cfg *configs.Config) *MenuSubTask {
return &MenuSubTask{
GeneralTask: *common.NewGeneralTask(cfg),
}
}
func (task *MenuSubTask) Execute() error {
subTaskItems := []common.Tasker{
NewBuildDockerImageSubTask(task.Config),
NewPushImageSubTask(task.Config),
}
common.ListCommandMenu(subTaskItems, "Which management commands do you want to choose:", false, task.ParentTasks)
return nil
}
func (task *MenuSubTask) String() string {
return "agent"
}

View File

@ -0,0 +1,32 @@
package agent
import (
"ocl/portainer-devtool/configs"
"ocl/portainer-devtool/tasks/common"
"ocl/portainer-devtool/utils"
)
type PushImageSubTask struct {
common.GeneralTask
}
func NewPushImageSubTask(cfg *configs.Config) *PushImageSubTask {
return &PushImageSubTask{
GeneralTask: *common.NewGeneralTask(cfg),
}
}
func (task *PushImageSubTask) Execute() error {
utils.SuccessPrint(`
export CR_PAT=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
echo $CR_PAT | docker login ghcr.io -u oscarzhou-portainer --password-stdin
docker image tag portainerci/agent:develop-78af729 ghcr.io/oscarzhou-portainer/agent:develop-78af729
docker push ghcr.io/oscarzhou-portainer/agent:develop-78af729docker
`)
return nil
}
func (task *PushImageSubTask) String() string {
return "Push Docker Image"
}

View File

@ -0,0 +1,31 @@
package portaineree
import (
"ocl/portainer-devtool/configs"
"ocl/portainer-devtool/tasks/common"
"ocl/portainer-devtool/utils"
)
type BuildDockerImageSubTask struct {
common.GeneralTask
}
func NewBuildDockerImageSubTask(cfg *configs.Config) *BuildDockerImageSubTask {
return &BuildDockerImageSubTask{
GeneralTask: *common.NewGeneralTask(cfg),
}
}
func (task *BuildDockerImageSubTask) Execute() error {
utils.SuccessPrint(`
yarn build
docker build -t "portainerci/portainer:ee4803" -f build/linux/Dockerfile .
docker run -d -p 8000:8000 -p 9443:9443 --name portainer --restart=always -v "/var/run/docker.sock:/var/run/docker.sock" -v ${env:HOME}/volume/portainer-ee-data-2:/data --add-host=host.docker.internal:host-gateway portainerci/portainer:ee4803
`)
return nil
}
func (task *BuildDockerImageSubTask) String() string {
return "Build Docker Image"
}

View File

@ -0,0 +1,30 @@
package portaineree
import (
"ocl/portainer-devtool/configs"
"ocl/portainer-devtool/tasks/common"
)
type MenuSubTask struct {
common.GeneralTask
}
func NewMenuSubTask(cfg *configs.Config) *MenuSubTask {
return &MenuSubTask{
GeneralTask: *common.NewGeneralTask(cfg),
}
}
func (task *MenuSubTask) Execute() error {
subTaskItems := []common.Tasker{
NewBuildDockerImageSubTask(task.Config),
}
common.ListCommandMenu(subTaskItems, "Which management commands do you want to choose:", false, task.ParentTasks)
return nil
}
func (task *MenuSubTask) String() string {
return "portainer-ee"
}

View File

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

View File

@ -1,36 +0,0 @@
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

@ -0,0 +1,39 @@
package tasks
import (
"ocl/portainer-devtool/configs"
"ocl/portainer-devtool/repositories/agent"
portaineree "ocl/portainer-devtool/repositories/portainer-ee"
"ocl/portainer-devtool/repositories/unpacker"
"ocl/portainer-devtool/tasks/common"
)
type ListRepositoryMenuTask struct {
common.GeneralTask
}
func NewListRepositoryMenuTask(cfg *configs.Config) *ListRepositoryMenuTask {
return &ListRepositoryMenuTask{
GeneralTask: *common.NewGeneralTask(cfg),
}
}
func (task *ListRepositoryMenuTask) Execute() error {
subTaskItems := []common.Tasker{
portaineree.NewMenuSubTask(task.Config),
agent.NewMenuSubTask(task.Config),
unpacker.NewMenuSubTask(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 *ListRepositoryMenuTask) String() string {
return "Choose Repositories"
}

View File

@ -1,34 +0,0 @@
package tasks
import (
"ocl/portainer-devtool/configs"
"ocl/portainer-devtool/tasks/common"
)
type ListRepositoriesTask struct {
common.GeneralTask
}
func NewListRepositoriesTask(cfg *configs.Config) *ListRepositoriesTask {
return &ListRepositoriesTask{
GeneralTask: *common.NewGeneralTask(cfg),
}
}
func (task *ListRepositoriesTask) Execute() error {
subTaskItems := []common.Tasker{
NewListRepoActionsSubTask(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 *ListRepositoriesTask) String() string {
return "List All Repositories"
}