Skip to content

Commit

Permalink
chore: package with cds (#135)
Browse files Browse the repository at this point in the history
Signed-off-by: Yvonnick Esnault <[email protected]>
  • Loading branch information
yesnault authored Feb 6, 2018
1 parent 0646fd4 commit cfe1b9f
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 104 deletions.
35 changes: 0 additions & 35 deletions .travis.yml

This file was deleted.

24 changes: 10 additions & 14 deletions cli/venom/update/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ import (
"context"
"fmt"
"net/http"
"runtime"
"strings"

"github.com/google/go-github/github"
"github.com/inconshreveable/go-update"
"github.com/ovh/venom/cli"
"github.com/spf13/cobra"
)

// used by CI to inject architecture (linux-amd64, etc...) at build time
var architecture string
var urlGitubReleases = "https://github.com/ovh/venom/releases"

// Cmd update
Expand All @@ -21,11 +21,11 @@ var Cmd = &cobra.Command{
Short: "Update venom to the latest release version: venom update",
Long: `venom update`,
Run: func(cmd *cobra.Command, args []string) {
doUpdate("", architecture)
doUpdate()
},
}

func getURLArtifactFromGithub(architecture string) string {
func getURLArtifactFromGithub() string {
client := github.NewClient(nil)
release, resp, err := client.Repositories.GetLatestRelease(context.TODO(), "ovh", "venom")
if err != nil {
Expand All @@ -34,7 +34,9 @@ func getURLArtifactFromGithub(architecture string) string {

if len(release.Assets) > 0 {
for _, asset := range release.Assets {
if *asset.Name == "venom-"+architecture {
assetName := strings.Replace(*asset.Name, ".", "-", -1)
current := fmt.Sprintf("venom-%s-%s", runtime.GOOS, runtime.GOARCH)
if assetName == current {
return *asset.BrowserDownloadURL
}
}
Expand All @@ -55,14 +57,8 @@ func getContentType(resp *http.Response) string {
return ""
}

func doUpdate(baseurl, architecture string) {
if architecture == "" {
text := "You seem to have a custom build of venom.\n"
text += "Please download latest release on %s\n"
cli.Exit(text, urlGitubReleases)
}

url := getURLArtifactFromGithub(architecture)
func doUpdate() {
url := getURLArtifactFromGithub()
fmt.Printf("Url to update venom: %s\n", url)

resp, err := http.Get(url)
Expand All @@ -79,7 +75,7 @@ func doUpdate(baseurl, architecture string) {
cli.Exit("Error http code: %d, url called: %s\n", resp.StatusCode, url)
}

fmt.Printf("Getting latest release from : %s ...\n", url)
fmt.Printf("Getting latest release from: %s ...\n", url)
defer resp.Body.Close()
if err = update.Apply(resp.Body, update.Options{}); err != nil {
cli.Exit("Error when updating venom from url: %s err:%s\n", url, err.Error())
Expand Down
3 changes: 2 additions & 1 deletion package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ for DIST in `go tool dist list | grep -v '^android/' | grep -v '^nacl/' | grep -
echo "Building ${architecture} ${path}"
export GOOS=$GOOS
export GOARCH=$GOARCH
go build -ldflags "-X github.com/ovh/venom/cli/venom/update.architecture=${architecture}" -o bin/venom.${architecture}

go build -ldflags "-X github.com/ovh/venom.Version=${GIT_DESCRIBE}" -o bin/venom.${architecture}
done
50 changes: 0 additions & 50 deletions release.sh

This file was deleted.

8 changes: 4 additions & 4 deletions venom.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ import (
pb "gopkg.in/cheggaaa/pb.v1"
)

// Version of Venom
// One Line for this, used by release.sh script
// Keep "const Version on one line"
const Version = "0.16.0"
var (
//Version is set with -ldflags "-X github.com/ovh/venom/venom.Version=$(VERSION)"
Version = "snapshot"
)

func New() *Venom {
v := &Venom{
Expand Down

0 comments on commit cfe1b9f

Please sign in to comment.