portainer-devtool/go/main.go

54 lines
863 B
Go
Raw Normal View History

2022-08-21 15:05:29 +10:00
package main
import (
"log"
"ocl/portainer-devtool/repositories"
"ocl/portainer-devtool/utils"
"os"
2022-08-21 15:05:29 +10:00
)
const (
MENU_OPTION_EE_REPO int = iota + 1
MENU_OPTION_CE_REPO
MENU_OPTION_AGENT_REPO
MENU_OPTION_OTHERS
MENU_OPTION_QUIT
2022-08-21 15:05:29 +10:00
)
func main() {
for {
2022-08-21 15:05:29 +10:00
printMainMenu := func() {
utils.MenuPrint("Which repository or action do you want to operate:", `
1. Portainer EE Repository
2. Portainer CE Repository
3. Portainer Agent Repository
4. Others
5. Quit`)
}
option := utils.PromptMenu(printMainMenu)
var action repositories.Actioner
switch option {
case MENU_OPTION_EE_REPO:
action = repositories.NewPortainerEERepository()
case MENU_OPTION_CE_REPO:
2022-08-21 15:05:29 +10:00
case MENU_OPTION_AGENT_REPO:
2022-08-21 15:05:29 +10:00
case MENU_OPTION_OTHERS:
2022-08-21 15:05:29 +10:00
case MENU_OPTION_QUIT:
os.Exit(0)
}
2022-08-21 15:05:29 +10:00
err := action.Execute()
if err != nil {
log.Fatalln(err)
}
2022-08-21 15:05:29 +10:00
}
}