-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #567 from Scalingo/feature/554/add_log_drains_del_cmd
Log drains: delete command
- Loading branch information
Showing
10 changed files
with
123 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package autocomplete | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/Scalingo/cli/config" | ||
"github.com/urfave/cli" | ||
"gopkg.in/errgo.v1" | ||
) | ||
|
||
func LogDrainsRemoveAutoComplete(c *cli.Context) error { | ||
appName := CurrentAppCompletion(c) | ||
if appName == "" { | ||
return nil | ||
} | ||
|
||
client, err := config.ScalingoClient() | ||
if err != nil { | ||
return errgo.Notef(err, "fail to get Scalingo client") | ||
} | ||
drains, err := client.LogDrainsList(appName) | ||
if err != nil { | ||
return errgo.Notef(err, "fail to get log drains list") | ||
} | ||
|
||
for _, drain := range drains { | ||
fmt.Println(drain.URL) | ||
} | ||
|
||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,7 +18,7 @@ var ( | |
$ scalingo --app my-app log-drains | ||
# See also commands 'log-drains-add'`, | ||
# See also commands 'log-drains-add', 'log-drains-remove'`, | ||
|
||
Action: func(c *cli.Context) { | ||
currentApp := appdetect.CurrentApp(c) | ||
|
@@ -59,7 +59,7 @@ var ( | |
$ scalingo --app my-app log-drains-add --type syslog --host custom.logstash.com --port 12345 | ||
$ scalingo --app my-app log-drains-add --type elk --url https://my-user:[email protected] | ||
# See also commands 'log-drains'`, | ||
# See also commands 'log-drains', 'log-drains-remove'`, | ||
|
||
Action: func(c *cli.Context) { | ||
currentApp := appdetect.CurrentApp(c) | ||
|
@@ -80,4 +80,34 @@ var ( | |
autocomplete.CmdFlagsAutoComplete(c, "log-drains") | ||
}, | ||
} | ||
|
||
logDrainsRemoveCommand = cli.Command{ | ||
Name: "log-drains-remove", | ||
Category: "Log drains", | ||
Flags: []cli.Flag{appFlag}, | ||
Usage: "Remove a log drain from an application", | ||
Description: `Remove a log drain from an application: | ||
$ scalingo --app my-app log-drains-remove syslog://custom.logstash.com:12345 | ||
# See also commands 'log-drains-add', 'log-drains'`, | ||
|
||
Action: func(c *cli.Context) { | ||
currentApp := appdetect.CurrentApp(c) | ||
var err error | ||
if len(c.Args()) == 1 { | ||
err = log_drains.Remove(currentApp, c.Args()[0]) | ||
} else { | ||
cli.ShowCommandHelp(c, "log-drains-remove") | ||
} | ||
|
||
if err != nil { | ||
errorQuit(err) | ||
} | ||
}, | ||
BashComplete: func(c *cli.Context) { | ||
autocomplete.CmdFlagsAutoComplete(c, "log-drains-remove") | ||
autocomplete.LogDrainsRemoveAutoComplete(c) | ||
}, | ||
} | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package log_drains | ||
|
||
import ( | ||
"github.com/Scalingo/cli/config" | ||
"github.com/Scalingo/cli/io" | ||
"gopkg.in/errgo.v1" | ||
) | ||
|
||
func Remove(app string, URL string) error { | ||
c, err := config.ScalingoClient() | ||
if err != nil { | ||
return errgo.Notef(err, "fail to get Scalingo client to remove a log drain from the application") | ||
} | ||
|
||
err = c.LogDrainRemove(app, URL) | ||
if err != nil { | ||
return errgo.Notef(err, "fail to remove the log drain from the application") | ||
} | ||
|
||
io.Status("The log drain:", URL, "has been deleted") | ||
return nil | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.