-
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.
- Loading branch information
Showing
8 changed files
with
90 additions
and
6 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package apps | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
|
||
"github.com/Scalingo/cli/config" | ||
"github.com/Scalingo/go-scalingo" | ||
"github.com/Scalingo/go-scalingo/debug" | ||
"github.com/olekukonko/tablewriter" | ||
"github.com/pkg/errors" | ||
"gopkg.in/errgo.v1" | ||
) | ||
|
||
func Info(appName string) error { | ||
c, err := config.ScalingoClient() | ||
if err != nil { | ||
return errgo.Notef(err, "fail to get Scalingo client") | ||
} | ||
|
||
app, err := c.AppsShow(appName) | ||
if err != nil { | ||
return errgo.Notef(err, "fail to get the application information") | ||
} | ||
|
||
stackName, err := getStackName(c, app.StackID) | ||
if err != nil { | ||
debug.Println("Failed to get the stack name from its ID:", err) | ||
stackName = app.StackID | ||
} | ||
|
||
t := tablewriter.NewWriter(os.Stdout) | ||
t.SetHeader([]string{"Settings", "Value"}) | ||
t.Append([]string{"Force HTTPS", fmt.Sprintf("%v", app.ForceHTTPS)}) | ||
t.Append([]string{"Sticky Session", fmt.Sprintf("%v", app.StickySession)}) | ||
t.Append([]string{"Stack", stackName}) | ||
t.Append([]string{"Status", fmt.Sprintf("%v", app.Status)}) | ||
t.Render() | ||
|
||
return nil | ||
} | ||
|
||
func getStackName(c *scalingo.Client, stackID string) (string, error) { | ||
stacks, err := c.StacksList() | ||
if err != nil { | ||
return "", err | ||
} | ||
|
||
for _, stack := range stacks { | ||
if stack.ID == stackID { | ||
return stack.Name, nil | ||
} | ||
} | ||
return "", errors.New("unknown stack") | ||
} |
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
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
4 changes: 4 additions & 0 deletions
4
vendor/github.com/Scalingo/go-scalingo/apps.go
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.