go(action): add the tool skeleton
This commit is contained in:
parent
10544e1c2d
commit
8028a50cc3
40
go/main.go
Normal file
40
go/main.go
Normal file
@ -0,0 +1,40 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"ocl/portainer-devtool/repositories"
|
||||
"ocl/portainer-devtool/utils"
|
||||
)
|
||||
|
||||
const (
|
||||
MENU_OPTION_EE_REPO int = iota + 1
|
||||
MENU_OPTION_CE_REPO
|
||||
MENU_OPTION_AGENT_REPO
|
||||
MENU_OPTION_OTHERS
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
||||
utils.MenuPrint()
|
||||
|
||||
var option int
|
||||
_, err := fmt.Scanf("%d", &option)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
var action repositories.Actioner
|
||||
switch option {
|
||||
case MENU_OPTION_EE_REPO:
|
||||
action = repositories.NewPortainerEERepository()
|
||||
case MENU_OPTION_CE_REPO:
|
||||
|
||||
case MENU_OPTION_AGENT_REPO:
|
||||
|
||||
case MENU_OPTION_OTHERS:
|
||||
|
||||
}
|
||||
|
||||
log.Fatal(action.Execute())
|
||||
}
|
5
go/repositories/actioner.go
Normal file
5
go/repositories/actioner.go
Normal file
@ -0,0 +1,5 @@
|
||||
package repositories
|
||||
|
||||
type Actioner interface {
|
||||
Execute() error
|
||||
}
|
37
go/repositories/ee.go
Normal file
37
go/repositories/ee.go
Normal file
@ -0,0 +1,37 @@
|
||||
package repositories
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"ocl/portainer-devtool/commands"
|
||||
"ocl/portainer-devtool/utils"
|
||||
)
|
||||
|
||||
type PortainerEE struct {
|
||||
WorkDir string
|
||||
FrontendDir string
|
||||
BackendDir string
|
||||
}
|
||||
|
||||
func NewPortainerEERepository() *PortainerEE {
|
||||
repo := &PortainerEE{
|
||||
WorkDir: "/home/oscarzhou/source/github.com/portainer/portainer-ee",
|
||||
}
|
||||
|
||||
utils.HighlightPrint("Your portainer EE repository work directory is ")
|
||||
fmt.Println(repo.WorkDir)
|
||||
|
||||
return repo
|
||||
}
|
||||
|
||||
func (repo *PortainerEE) Execute() error {
|
||||
err := commands.ListBranches(repo.WorkDir)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if !utils.PromptContinue() {
|
||||
return nil
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
Loading…
Reference in New Issue
Block a user