Skip to content

Commit

Permalink
feat: simplify the qovery init flow
Browse files Browse the repository at this point in the history
  • Loading branch information
evoxmusic committed Dec 27, 2019
1 parent 4d6c162 commit 208ea06
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 20 deletions.
38 changes: 27 additions & 11 deletions cmd/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,32 @@ var initCmd = &cobra.Command{
os.Exit(1)
}

fmt.Println("Reply to the following questions to initialize Qovery for this application")
fmt.Println("For more info: https://docs.qovery.com")

project := AskForProject()
repository := AskForRepository(project)

p.Qovery.Key = fmt.Sprintf("%s/%s/%s", api.GetAccountId(), project.Id, repository.Id)
p.Application.Project = project.Name
p.Application.Name = repository.Name
// p.Application.PubliclyAccessible = util.AskForConfirmation(false, "Would you like to make your application publicly accessible?", "y") TODO
p.Application.PubliclyAccessible = true //util.AskForConfirmation(false, "Would you like to make your application publicly accessible?", "y") TODO

/** TODO
if p.Application.PubliclyAccessible {
p.Network.DNS = util.AskForInput(true, "Do you want to set a custom domain (ex: api.foo.com)?")
p.Routers = []util.QoveryYMLRouter{
{
Name: "main",
Routes: []util.QoveryYMLRoute{
{
ApplicationName: p.Application.Name,
Paths: []string{"/*"},
},
},
},
}
// TODO
// p.Routers.DNS = util.AskForInput(true, "Do you want to set a custom domain (ex: api.foo.com)?")
}
*/

count := 1
for count < 20 {
Expand Down Expand Up @@ -118,18 +131,21 @@ var initCmd = &cobra.Command{

fmt.Println("✓ Your Qovery configuration file has been successfully created (.qovery.yml)")

fmt.Println("\n➤ Qovery needs to get access to your git repository")
fmt.Println("➤ Qovery Github: https://github.com/apps/qovery/installations/new/permissions?target_id=55960755")
fmt.Println("\n!!!IMPORTANT!!!")
fmt.Println("Qovery needs to get access to your git repository")
fmt.Println("https://github.com/apps/qovery/installations/new/permissions?target_id=55960755")

openLink := util.AskForConfirmation(false, "Would you like to open it?", "n")
openLink := util.AskForConfirmation(false, "Would you like to open the link above?", "n")
if openLink {
_ = browser.OpenURL("https://github.com/apps/qovery/installations/new/permissions?target_id=55960755")
}

fmt.Println("\n➤ 1/ Commit into your repository and push it to get your app deployed")
fmt.Println("➤ commands: git add .qovery.yml && git commit")
fmt.Println("➤ 2/ Check the status of your deployment")
fmt.Println("➤ commands: qovery status")
fmt.Println("\n!!!IMPORTANT!!!")
fmt.Println("1/ Commit and push the \".qovery.yml\" file to get your app deployed")
fmt.Println("➤ Run: git add .qovery.yml && git commit -m \"add .qovery.yml\" && git push -u origin master")
fmt.Println("\n2/ Check the status of your deployment")
fmt.Println("➤ Run: qovery status")
fmt.Println("\nEnjoy! 👋")
},
}

Expand Down
12 changes: 6 additions & 6 deletions util/input.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
func AskForInput(optional bool, message string) string {
var response string

fmt.Print("➤ " + message + ": ")
fmt.Print("\n➤ " + message + ": ")
_, err := fmt.Scanln(&response)

if err != nil {
Expand All @@ -28,7 +28,7 @@ func AskForInput(optional bool, message string) string {
func AskForSelect(choices []string, message string, defaultChoice string) string {
var response string

fmt.Println("➤ " + message + ": ")
fmt.Println("\n➤ " + message + ": ")

if defaultChoice == "" {
fmt.Println("0. none")
Expand Down Expand Up @@ -73,15 +73,15 @@ func AskForConfirmation(noPrompt bool, message string, defaultValue string) bool

if message == "" {
if defaultValue == "" {
fmt.Print("➤ Are you sure? (y/n): ")
fmt.Print("\n➤ Are you sure? (y/n): ")
} else {
fmt.Print("➤ Are you sure? (y/n) [default=" + defaultValue + "]: ")
fmt.Print("\n➤ Are you sure? (y/n) [default=" + defaultValue + "]: ")
}
} else {
if defaultValue == "" {
fmt.Print("➤ " + message + " (y/n): ")
fmt.Print("\n➤ " + message + " (y/n): ")
} else {
fmt.Print("➤ " + message + " (y/n) [default=" + defaultValue + "]: ")
fmt.Print("\n➤ " + message + " (y/n) [default=" + defaultValue + "]: ")
}
}

Expand Down
13 changes: 10 additions & 3 deletions util/qovery_yml.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ import (
type QoveryYML struct {
Qovery QoveryYMLQovery `yaml:"qovery,omitempty"`
Application QoveryYMLApplication `yaml:"application,omitempty"`
Network QoveryYMLNetwork `yaml:"network,omitempty"`
Databases []QoveryYMLDatabase `yaml:"databases,omitempty"`
Brokers []QoveryYMLBroker `yaml:"brokers,omitempty"`
// Storage []QoveryYMLStorage `yaml:"storage"`
Routers []QoveryYMLRouter `yaml:"routers,omitempty"`
}

type QoveryYMLQovery struct {
Expand Down Expand Up @@ -41,8 +41,15 @@ type QoveryYMLDatabase struct {
Name string `yaml:"name,omitempty"`
}

type QoveryYMLNetwork struct {
DNS string `yaml:"dns,omitempty"`
type QoveryYMLRouter struct {
Name string `yaml:"name,omitempty"`
DNS string `yaml:"dns,omitempty"`
Routes []QoveryYMLRoute `yaml:"routes,omitempty"`
}

type QoveryYMLRoute struct {
ApplicationName string `yaml:"application_name,omitempty"`
Paths []string `yaml:"paths,omitempty"`
}

type QoveryYMLBroker struct {
Expand Down

0 comments on commit 208ea06

Please sign in to comment.