Skip to content

Commit

Permalink
Merge branch '0.2.8'
Browse files Browse the repository at this point in the history
  • Loading branch information
Philippe Lafoucrière committed Jul 7, 2016
2 parents 79b0246 + 794adf1 commit bff1183
Show file tree
Hide file tree
Showing 23 changed files with 4,693 additions and 98 deletions.
2 changes: 1 addition & 1 deletion .goxc.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
"AppName": "gemnasium",
"BuildConstraints": "linux darwin windows",
"ConfigVersion": "0.9",
"PackageVersion": "0.2.7"
"PackageVersion": "0.2.8"
}
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
0.2.8 / 2016-07-07

* Add a Dockerfile, to build `gemnasium/toolbelt` image
* Remove deprecation warnings when running commands

0.2.7 / 2016-02-04

* Remove hardcoded max duration for autoupdate. CI servers have timeouts anyway. (#33)
Expand Down
5 changes: 5 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FROM scratch
MAINTAINER Gemnasium "[email protected]"
ADD ca-certificates.crt /etc/ssl/certs/
ADD toolbelt /toolbelt
ENTRYPOINT ["/toolbelt"]
4 changes: 2 additions & 2 deletions auth/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ import (

"github.com/bgentry/go-netrc/netrc"
"github.com/bgentry/speakeasy"
"github.com/codegangsta/cli"
"github.com/gemnasium/toolbelt/config"
"github.com/gemnasium/toolbelt/utils"
"github.com/heroku/hk/term"
"github.com/urfave/cli"

"bytes"
"fmt"
Expand Down Expand Up @@ -123,7 +123,7 @@ func AttemptLogin(ctx *cli.Context) error {
config.APIKey = ctx.GlobalString("token")
}
if config.APIKey == "" {
utils.ExitWithError(ErrEmptyToken)
return ErrEmptyToken
}
return nil
}
Expand Down
4,541 changes: 4,541 additions & 0 deletions ca-certificates.crt

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions commands/app.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package commands

import (
"github.com/codegangsta/cli"
"github.com/gemnasium/toolbelt/auth"
"github.com/gemnasium/toolbelt/config"
"github.com/urfave/cli"
)

func App() (*cli.App, error) {
func App() *cli.App {
app := cli.NewApp()
app.Name = "gemnasium"
app.Usage = "Gemnasium toolbelt"
Expand Down Expand Up @@ -244,5 +244,5 @@ func App() (*cli.App, error) {
Action: DisplayEnvVars,
},
}
return app, nil
return app
}
17 changes: 11 additions & 6 deletions commands/auth.go
Original file line number Diff line number Diff line change
@@ -1,27 +1,32 @@
package commands

import (
"github.com/codegangsta/cli"
"github.com/gemnasium/toolbelt/auth"
"github.com/gemnasium/toolbelt/utils"
"github.com/urfave/cli"
)

var login = func() error {
return auth.Login()
}

// auth.Login wrapper with a cli.Content
func Login(ctx *cli.Context) {
func Login(ctx *cli.Context) error {
err := login()
utils.ExitIfErr(err)
if err != nil {
return cli.NewExitError(err.Error(), 1)
}
return nil
}

var logout = func() error {
return auth.Logout()
}

// auth.Logout wrapper with a cli.Content
func Logout(ctx *cli.Context) {
func Logout(ctx *cli.Context) error {
err := logout()
utils.ExitIfErr(err)
if err != nil {
return cli.NewExitError(err.Error(), 1)
}
return nil
}
10 changes: 2 additions & 8 deletions commands/auth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,7 @@ func TestLogin(t *testing.T) {
called = true
return nil
}
app, err := App()
if err != nil {
t.Fatal(err)
}
app := App()
os.Args = []string{"gemnasium", "auth", "login"}
app.Run(os.Args)
if called != true {
Expand All @@ -31,10 +28,7 @@ func TestLogout(t *testing.T) {
called = true
return nil
}
app, err := App()
if err != nil {
t.Fatal(err)
}
app := App()
os.Args = []string{"gemnasium", "auth", "logout"}
app.Run(os.Args)
if called != true {
Expand Down
25 changes: 17 additions & 8 deletions commands/auto-update.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
package commands

import (
"github.com/codegangsta/cli"
"github.com/gemnasium/toolbelt/auth"
"github.com/gemnasium/toolbelt/autoupdate"
"github.com/gemnasium/toolbelt/models"
"github.com/gemnasium/toolbelt/utils"
"github.com/urfave/cli"
)

var auRunFunc = func(projectSlug string, args []string) error {
Expand All @@ -16,18 +15,28 @@ var auApplyFunc = func(projectSlug string, args []string) error {
return autoupdate.Apply(projectSlug, args)
}

func AutoUpdateRun(ctx *cli.Context) {
func AutoUpdateRun(ctx *cli.Context) error {
auth.AttemptLogin(ctx)
project, err := models.GetProject(ctx.String("project"))
utils.ExitIfErr(err)
if err != nil {
return cli.NewExitError(err.Error(), 1)
}
err = auRunFunc(project.Slug, ctx.Args())
utils.ExitIfErr(err)
if err != nil {
return cli.NewExitError(err.Error(), 1)
}
return nil
}

func AutoUpdateApply(ctx *cli.Context) {
func AutoUpdateApply(ctx *cli.Context) error {
auth.AttemptLogin(ctx)
project, err := models.GetProject(ctx.String("project"))
utils.ExitIfErr(err)
if err != nil {
return cli.NewExitError(err.Error(), 1)
}
err = auApplyFunc(project.Slug, ctx.Args())
utils.ExitIfErr(err)
if err != nil {
return cli.NewExitError(err.Error(), 1)
}
return nil
}
5 changes: 1 addition & 4 deletions commands/auto-update_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,7 @@ func TestAutoUpdateRun(t *testing.T) {
project = slug
return nil
}
app, err := App()
if err != nil {
t.Fatal(err)
}
app := App()

// Call autoupdate command
os.Args = []string{"gemnasium", "autoupdate", "run"}
Expand Down
24 changes: 17 additions & 7 deletions commands/configure.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,33 @@ package commands
import (
"os"

"github.com/codegangsta/cli"
"github.com/gemnasium/toolbelt/models"
"github.com/gemnasium/toolbelt/utils"
"github.com/urfave/cli"
)

var confFunc = func(project *models.Project) error {
f, err := os.Create(".gemnasium.yml")
utils.ExitIfErr(err)
if err != nil {
return cli.NewExitError(err.Error(), 1)
}
defer f.Close()
return project.Configure(project.Slug, os.Stdin, f)
err = project.Configure(project.Slug, os.Stdin, f)
if err != nil {
return cli.NewExitError(err.Error(), 1)
}
return nil
}

func Configure(ctx *cli.Context) {
func Configure(ctx *cli.Context) error {
slug := ctx.Args().First()
project, err := models.GetProject(slug)
utils.ExitIfErr(err)
if err != nil {
return cli.NewExitError(err.Error(), 1)
}

err = confFunc(project)
utils.ExitIfErr(err)
if err != nil {
return cli.NewExitError(err.Error(), 1)
}
return nil
}
5 changes: 1 addition & 4 deletions commands/configure_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,7 @@ func TestConfigue(t *testing.T) {
confFunc = func(project *models.Project) error {
return project.Configure(project.Slug, os.Stdin, &output)
}
app, err := App()
if err != nil {
t.Fatal(err)
}
app := App()

// Call autoupdate command
os.Args = []string{"gemnasium", "configure", "myProject"}
Expand Down
14 changes: 9 additions & 5 deletions commands/dependencies.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
package commands

import (
"github.com/codegangsta/cli"
"github.com/gemnasium/toolbelt/models"
"github.com/gemnasium/toolbelt/utils"
"github.com/urfave/cli"
)

func DependenciesList(ctx *cli.Context) {
func DependenciesList(ctx *cli.Context) error {
project, err := models.GetProject(ctx.Args().First())
utils.ExitIfErr(err)
if err != nil {
return cli.NewExitError(err.Error(), 1)
}
err = models.ListDependencies(project)
utils.ExitIfErr(err)
if err != nil {
return cli.NewExitError(err.Error(), 1)
}
return nil
}
15 changes: 10 additions & 5 deletions commands/dependency_alerts.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
package commands

import (
"github.com/codegangsta/cli"
"github.com/gemnasium/toolbelt/models"
"github.com/gemnasium/toolbelt/utils"
"github.com/urfave/cli"
)

func DependencyAlertsList(ctx *cli.Context) {
func DependencyAlertsList(ctx *cli.Context) error {
project, err := models.GetProject(ctx.Args().First())
utils.ExitIfErr(err)
if err != nil {
return cli.NewExitError(err.Error(), 1)
}

err = models.ListDependencyAlerts(project)
utils.ExitIfErr(err)
if err != nil {
return cli.NewExitError(err.Error(), 1)
}
return nil
}
25 changes: 17 additions & 8 deletions commands/dependency_files.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,35 @@ package commands
import (
"strings"

"github.com/codegangsta/cli"
"github.com/gemnasium/toolbelt/models"
"github.com/gemnasium/toolbelt/utils"
"github.com/urfave/cli"
)

func DependencyFilesList(ctx *cli.Context) {
func DependencyFilesList(ctx *cli.Context) error {
project, err := models.GetProject()
utils.ExitIfErr(err)
if err != nil {
return cli.NewExitError(err.Error(), 1)
}
err = models.ListDependencyFiles(project)
utils.ExitIfErr(err)
if err != nil {
return cli.NewExitError(err.Error(), 1)
}
return nil
}

func DependenciesPush(ctx *cli.Context) {
func DependenciesPush(ctx *cli.Context) error {
project, err := models.GetProject()
utils.ExitIfErr(err)
if err != nil {
return cli.NewExitError(err.Error(), 1)
}
var files []string
if ctx.IsSet("files") {
// Only call strings.Split on non-empty strings, otherwise len(strings) will be 1 instead of 0.
files = strings.Split(ctx.String("files"), ",")
}
err = models.PushDependencyFiles(project.Slug, files)
utils.ExitIfErr(err)
if err != nil {
return cli.NewExitError(err.Error(), 1)
}
return nil
}
2 changes: 1 addition & 1 deletion commands/env.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package commands

import (
"github.com/codegangsta/cli"
"github.com/urfave/cli"
"github.com/gemnasium/toolbelt/config"
)

Expand Down
10 changes: 6 additions & 4 deletions commands/live_evaluation.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,17 @@ package commands
import (
"strings"

"github.com/codegangsta/cli"
"github.com/gemnasium/toolbelt/auth"
"github.com/gemnasium/toolbelt/live-eval"
"github.com/gemnasium/toolbelt/utils"
"github.com/urfave/cli"
)

func LiveEvaluation(ctx *cli.Context) {
func LiveEvaluation(ctx *cli.Context) error {
auth.AttemptLogin(ctx)
files := strings.Split(ctx.String("files"), ",")
err := liveeval.LiveEvaluation(files)
utils.ExitIfErr(err)
if err != nil {
return cli.NewExitError(err.Error(), 1)
}
return nil
}
Loading

0 comments on commit bff1183

Please sign in to comment.