Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/537/detect region from git remote #724

Merged
merged 1 commit into from
May 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

### To be Released

* feat(app): Region detection from Git remote [#724](https://github.com/Scalingo/cli/pull/724)
* feat(app): add a flag --force to destroy an app without interactive confirmation [#721](https://github.com/Scalingo/cli/pull/721)
* build(deps): bump github.com/briandowns/spinner from 1.18.0 to 1.18.1
* build(deps): bump github.com/stretchr/testify from 1.7.0 to 1.7.1
Expand Down
30 changes: 0 additions & 30 deletions appdetect/current.go

This file was deleted.

3 changes: 1 addition & 2 deletions apps/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (

"gopkg.in/errgo.v1"

"github.com/Scalingo/cli/appdetect"
"github.com/Scalingo/cli/config"
"github.com/Scalingo/cli/utils"
"github.com/Scalingo/go-scalingo/v4"
Expand Down Expand Up @@ -40,7 +39,7 @@ func Create(appName string, remote string, buildpack string) error {
}

fmt.Printf("App '%s' has been created\n", app.Name)
if _, ok := appdetect.DetectGit(); ok && appdetect.AddRemote(app.GitUrl, remote) == nil {
if _, ok := utils.DetectGit(); ok && utils.AddGitRemote(app.GitUrl, remote) == nil {
fmt.Printf("Git repository detected: remote %s added\n→ 'git push %s master' to deploy your app\n", remote, remote)
} else {
fmt.Printf("To deploy your application, run these commands in your GIT repository:\n→ git remote add %s %s\n→ git push %s master\n", remote, app.GitUrl, remote)
Expand Down
12 changes: 6 additions & 6 deletions cmd/addons.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"github.com/urfave/cli"

"github.com/Scalingo/cli/addons"
"github.com/Scalingo/cli/appdetect"
"github.com/Scalingo/cli/cmd/autocomplete"
"github.com/Scalingo/cli/detect"
)

var (
Expand All @@ -20,7 +20,7 @@ var (
# See also 'addons-add' and 'addons-remove'
`,
Action: func(c *cli.Context) {
currentApp := appdetect.CurrentApp(c)
currentApp := detect.CurrentApp(c)
var err error
if len(c.Args()) == 0 {
err = addons.List(currentApp)
Expand All @@ -47,7 +47,7 @@ var (
# See also 'addons-list' and 'addons-plans'
`,
Action: func(c *cli.Context) {
currentApp := appdetect.CurrentApp(c)
currentApp := detect.CurrentApp(c)
var err error
if len(c.Args()) == 2 {
err = addons.Provision(currentApp, c.Args()[0], c.Args()[1])
Expand All @@ -74,7 +74,7 @@ var (
# See also 'addons' and 'addons-add'
`,
Action: func(c *cli.Context) {
currentApp := appdetect.CurrentApp(c)
currentApp := detect.CurrentApp(c)
var err error
if len(c.Args()) == 1 {
err = addons.Destroy(currentApp, c.Args()[0])
Expand All @@ -101,7 +101,7 @@ var (
# See also 'addons-plans' and 'addons-remove'
`,
Action: func(c *cli.Context) {
currentApp := appdetect.CurrentApp(c)
currentApp := detect.CurrentApp(c)
var err error
if len(c.Args()) == 2 {
err = addons.Upgrade(currentApp, c.Args()[0], c.Args()[1])
Expand Down Expand Up @@ -133,7 +133,7 @@ var (
return
}

currentApp := appdetect.CurrentApp(c)
currentApp := detect.CurrentApp(c)
currentAddon := c.Args()[0]

err := addons.Info(currentApp, currentAddon)
Expand Down
14 changes: 7 additions & 7 deletions cmd/alerts.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"github.com/urfave/cli"

"github.com/Scalingo/cli/alerts"
"github.com/Scalingo/cli/appdetect"
"github.com/Scalingo/cli/cmd/autocomplete"
"github.com/Scalingo/cli/detect"
scalingo "github.com/Scalingo/go-scalingo/v4"
)

Expand All @@ -27,7 +27,7 @@ var (
return
}

err := alerts.List(appdetect.CurrentApp(c))
err := alerts.List(detect.CurrentApp(c))
if err != nil {
errorQuit(err)
}
Expand Down Expand Up @@ -70,7 +70,7 @@ var (
return
}

currentApp := appdetect.CurrentApp(c)
currentApp := detect.CurrentApp(c)
remindEvery := c.Duration("r")
durationBeforeTrigger := c.Duration("duration-before-trigger")
err := alerts.Add(currentApp, scalingo.AlertAddParams{
Expand Down Expand Up @@ -126,7 +126,7 @@ var (
}

alertID := c.Args()[0]
currentApp := appdetect.CurrentApp(c)
currentApp := detect.CurrentApp(c)
params := scalingo.AlertUpdateParams{}
if c.IsSet("c") {
ct := c.String("c")
Expand Down Expand Up @@ -192,7 +192,7 @@ var (
return
}

currentApp := appdetect.CurrentApp(c)
currentApp := detect.CurrentApp(c)
disabled := false
err := alerts.Update(currentApp, c.Args()[0], scalingo.AlertUpdateParams{
Disabled: &disabled,
Expand Down Expand Up @@ -227,7 +227,7 @@ var (
return
}

currentApp := appdetect.CurrentApp(c)
currentApp := detect.CurrentApp(c)
disabled := true
err := alerts.Update(currentApp, c.Args()[0], scalingo.AlertUpdateParams{
Disabled: &disabled,
Expand Down Expand Up @@ -259,7 +259,7 @@ var (
return
}

currentApp := appdetect.CurrentApp(c)
currentApp := detect.CurrentApp(c)
err := alerts.Remove(currentApp, c.Args()[0])
if err != nil {
errorQuit(err)
Expand Down
4 changes: 2 additions & 2 deletions cmd/apps.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ package cmd
import (
"github.com/urfave/cli"

"github.com/Scalingo/cli/appdetect"
"github.com/Scalingo/cli/apps"
"github.com/Scalingo/cli/cmd/autocomplete"
"github.com/Scalingo/cli/detect"
)

var (
Expand Down Expand Up @@ -35,7 +35,7 @@ var (
scalingo apps-info --app my-app
`,
Action: func(c *cli.Context) {
currentApp := appdetect.CurrentApp(c)
currentApp := detect.CurrentApp(c)
if err := apps.Info(currentApp); err != nil {
errorQuit(err)
}
Expand Down
13 changes: 10 additions & 3 deletions cmd/autocomplete/current_app.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,15 @@ import (

"github.com/urfave/cli"

"github.com/Scalingo/cli/appdetect"
"github.com/Scalingo/cli/detect"
"github.com/Scalingo/cli/utils"
"github.com/Scalingo/go-scalingo/v4/debug"
)

func CurrentAppCompletion(c *cli.Context) string {
appName := ""
var err error

if len(os.Args) >= 2 {
for i := range os.Args {
if i < len(os.Args) && (os.Args[i] == "-a" || os.Args[i] == "--app") {
Expand All @@ -22,8 +26,11 @@ func CurrentAppCompletion(c *cli.Context) string {
if appName == "" && os.Getenv("SCALINGO_APP") != "" {
appName = os.Getenv("SCALINGO_APP")
}
if dir, ok := appdetect.DetectGit(); appName == "" && ok {
appName, _ = appdetect.ScalingoRepo(dir, c.GlobalString("remote"))
if dir, ok := utils.DetectGit(); appName == "" && ok {
appName, err = detect.GetAppNameFromGitRemote(dir, c.GlobalString("remote"))
if err != nil {
debug.Println(err)
}
}
return appName
}
4 changes: 2 additions & 2 deletions cmd/autocomplete/deployments.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@ import (
"github.com/urfave/cli"
"gopkg.in/errgo.v1"

"github.com/Scalingo/cli/appdetect"
"github.com/Scalingo/cli/config"
"github.com/Scalingo/cli/detect"
)

func DeploymentsAutoComplete(c *cli.Context) error {
client, err := config.ScalingoClient()
if err != nil {
return errgo.Notef(err, "fail to get Scalingo client")
}
currentApp := appdetect.CurrentApp(c)
currentApp := detect.CurrentApp(c)

deployments, err := client.DeploymentList(currentApp)
if err != nil {
Expand Down
6 changes: 3 additions & 3 deletions cmd/autocomplete/flag_remote.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ import (

"github.com/urfave/cli"

"github.com/Scalingo/cli/appdetect"
"github.com/Scalingo/cli/utils"
)

func FlagRemoteAutoComplete(c *cli.Context) bool {
if dir, ok := appdetect.DetectGit(); ok {
remoteNames := appdetect.ScalingoRepoAutoComplete(dir)
if dir, ok := utils.DetectGit(); ok {
remoteNames := utils.ScalingoRepoAutoComplete(dir)
for _, name := range remoteNames {
fmt.Println(name)
}
Expand Down
14 changes: 7 additions & 7 deletions cmd/autoscalers.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ package cmd
import (
"github.com/urfave/cli"

"github.com/Scalingo/cli/appdetect"
"github.com/Scalingo/cli/autoscalers"
"github.com/Scalingo/cli/cmd/autocomplete"
"github.com/Scalingo/cli/detect"
scalingo "github.com/Scalingo/go-scalingo/v4"
)

Expand All @@ -22,7 +22,7 @@ var (
return
}

err := autoscalers.List(appdetect.CurrentApp(c))
err := autoscalers.List(detect.CurrentApp(c))
if err != nil {
errorQuit(err)
}
Expand Down Expand Up @@ -59,7 +59,7 @@ var (
return
}

currentApp := appdetect.CurrentApp(c)
currentApp := detect.CurrentApp(c)
err := autoscalers.Add(currentApp, scalingo.AutoscalerAddParams{
ContainerType: c.String("c"),
Metric: c.String("m"),
Expand Down Expand Up @@ -105,7 +105,7 @@ var (
return
}

currentApp := appdetect.CurrentApp(c)
currentApp := detect.CurrentApp(c)
params := scalingo.AutoscalerUpdateParams{}
if c.IsSet("m") {
m := c.String("m")
Expand Down Expand Up @@ -156,7 +156,7 @@ var (
return
}

currentApp := appdetect.CurrentApp(c)
currentApp := detect.CurrentApp(c)
disabled := false
err := autoscalers.Update(currentApp, c.Args()[0], scalingo.AutoscalerUpdateParams{
Disabled: &disabled,
Expand Down Expand Up @@ -189,7 +189,7 @@ var (
return
}

currentApp := appdetect.CurrentApp(c)
currentApp := detect.CurrentApp(c)
disabled := true
err := autoscalers.Update(currentApp, c.Args()[0], scalingo.AutoscalerUpdateParams{
Disabled: &disabled,
Expand Down Expand Up @@ -218,7 +218,7 @@ var (
return
}

currentApp := appdetect.CurrentApp(c)
currentApp := detect.CurrentApp(c)
err := autoscalers.Remove(currentApp, c.Args()[0])
if err != nil {
errorQuit(err)
Expand Down
8 changes: 4 additions & 4 deletions cmd/backups.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (

"github.com/urfave/cli"

"github.com/Scalingo/cli/appdetect"
"github.com/Scalingo/cli/db"
"github.com/Scalingo/cli/detect"
"github.com/Scalingo/cli/io"
)

Expand All @@ -23,7 +23,7 @@ var (
# See also 'addons' and 'backups-download'
`,
Action: func(c *cli.Context) {
currentApp := appdetect.CurrentApp(c)
currentApp := detect.CurrentApp(c)
addonName := addonNameFromFlags(c)
if addonName == "" {
fmt.Println("Unable to find the addon name, please use --addon flag.")
Expand All @@ -46,7 +46,7 @@ var (
# See also 'backups' and 'addons'`,
Action: func(c *cli.Context) {
currentApp := appdetect.CurrentApp(c)
currentApp := detect.CurrentApp(c)
addonName := addonNameFromFlags(c)
if addonName == "" {
fmt.Println("Unable to find the addon name, please use --addon flag.")
Expand Down Expand Up @@ -79,7 +79,7 @@ var (
# See also 'backups' and 'addons'`,
Action: func(c *cli.Context) {
currentApp := appdetect.CurrentApp(c)
currentApp := detect.CurrentApp(c)
addonName := addonNameFromFlags(c)
if addonName == "" {
fmt.Println("Unable to find the addon name, please use --addon flag.")
Expand Down
Loading