Compare commits
No commits in common. "8028a50cc3f71ec9cf5195460fad903eb5143ade" and "7b66f95832fdaf1d6341930d18cebc5691a43718" have entirely different histories.
8028a50cc3
...
7b66f95832
@ -1,18 +0,0 @@
|
|||||||
package commands
|
|
||||||
|
|
||||||
import (
|
|
||||||
"ocl/portainer-devtool/utils"
|
|
||||||
"os/exec"
|
|
||||||
)
|
|
||||||
|
|
||||||
func ListBranches(workdir string) error {
|
|
||||||
cmd := exec.Command("git", "branch")
|
|
||||||
cmd.Dir = workdir
|
|
||||||
out, err := cmd.Output()
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
utils.PrintOutput("Your current checkout branch", out)
|
|
||||||
return nil
|
|
||||||
}
|
|
40
go/main.go
40
go/main.go
@ -1,40 +0,0 @@
|
|||||||
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())
|
|
||||||
}
|
|
@ -1,5 +0,0 @@
|
|||||||
package repositories
|
|
||||||
|
|
||||||
type Actioner interface {
|
|
||||||
Execute() error
|
|
||||||
}
|
|
@ -1,37 +0,0 @@
|
|||||||
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
|
|
||||||
}
|
|
@ -1,65 +0,0 @@
|
|||||||
package utils
|
|
||||||
|
|
||||||
import "fmt"
|
|
||||||
|
|
||||||
const (
|
|
||||||
colorReset string = "\033[0m"
|
|
||||||
|
|
||||||
colorRed string = "\033[31m"
|
|
||||||
colorGreen string = "\033[32m"
|
|
||||||
colorYellow string = "\033[33m"
|
|
||||||
colorBlue string = "\033[34m"
|
|
||||||
colorPurple string = "\033[35m"
|
|
||||||
colorCyan string = "\033[36m"
|
|
||||||
colorWhite string = "\033[37m"
|
|
||||||
)
|
|
||||||
|
|
||||||
func PrintOutput(message string, output []byte) {
|
|
||||||
if message != "" {
|
|
||||||
HighlightPrint(message)
|
|
||||||
}
|
|
||||||
fmt.Println(string(output))
|
|
||||||
}
|
|
||||||
|
|
||||||
func HighlightPrint(message string) {
|
|
||||||
fmt.Println()
|
|
||||||
fmt.Println(colorBlue, message, colorReset)
|
|
||||||
}
|
|
||||||
|
|
||||||
func SuccessPrint(message string) {
|
|
||||||
fmt.Println()
|
|
||||||
fmt.Println(colorGreen, message, colorReset)
|
|
||||||
}
|
|
||||||
|
|
||||||
func ErrorPrint(message string) {
|
|
||||||
fmt.Println()
|
|
||||||
fmt.Println(colorRed, message, colorReset)
|
|
||||||
}
|
|
||||||
|
|
||||||
func InputPrint(message string) {
|
|
||||||
fmt.Println()
|
|
||||||
fmt.Println(colorYellow, message, colorReset)
|
|
||||||
}
|
|
||||||
|
|
||||||
func MenuPrint() {
|
|
||||||
InputPrint("Which repository or action do you want to operate:")
|
|
||||||
|
|
||||||
// menu := `
|
|
||||||
// 1. Build Portainer EE/CE All
|
|
||||||
// 2. Build Portainer EE/CE Frontend
|
|
||||||
// 3. Build Portainer EE/CE Backend
|
|
||||||
// 4. Generate Portainer EE/CE JWT
|
|
||||||
// 5. Run Before Commit [Portainer EE/CE]
|
|
||||||
// 6. Get Portainer CE API Reference
|
|
||||||
// 7. Run Before Commit [k8s]
|
|
||||||
// 8. Build Portainer Agent
|
|
||||||
// 9. Cleanup Temporary Volume
|
|
||||||
// `
|
|
||||||
|
|
||||||
menu := `1. Portainer EE Repository
|
|
||||||
2. Portainer CE Repository
|
|
||||||
3. Portainer Agent Repository
|
|
||||||
4. Others`
|
|
||||||
|
|
||||||
fmt.Println(colorCyan, menu, colorReset)
|
|
||||||
}
|
|
@ -1,22 +0,0 @@
|
|||||||
package utils
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"strings"
|
|
||||||
)
|
|
||||||
|
|
||||||
func PromptContinue() bool {
|
|
||||||
ret := strings.ToLower(prompt("Continue (y/n)"))
|
|
||||||
if ret == "y" || ret == "yes" {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
func prompt(question string) string {
|
|
||||||
fmt.Printf("%s %s :%s", colorYellow, question, colorReset)
|
|
||||||
var ret string
|
|
||||||
fmt.Scanf("%s", &ret)
|
|
||||||
return ret
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user