Skip to content
This repository was archived by the owner on Aug 15, 2022. It is now read-only.
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
37 changes: 34 additions & 3 deletions go/src/koding/klient/app/klient.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package app

import (
"bytes"
"errors"
"fmt"
"io"
Expand All @@ -11,6 +12,7 @@ import (
"net/http/cookiejar"
"net/url"
"os"
"os/exec"
"path/filepath"
"strconv"
"strings"
Expand Down Expand Up @@ -140,6 +142,8 @@ type KlientConfig struct {
NoTunnel bool
NoProxy bool

Autoupdate bool

LogBucketRegion string
LogBucketName string
LogUploadLimit int
Expand Down Expand Up @@ -571,15 +575,30 @@ func (k *Klient) Run() {
k.log.Info("Using version: '%s' querystring: '%s'", k.config.Version, k.kite.Id)

// TODO(rjeczalik): Enable after TMS-848.
if isManaged {
k.log.Warning("autoupdate is currently disabled for managed environment")
} else {
if k.autoupdateEnabled() {
go k.updater.Run()
} else {
k.log.Warning("autoupdate is disabled")
}

k.kite.Run()
}

var kdPrefix = []byte("kd version")

func (k *Klient) autoupdateEnabled() bool {
if k.config.Autoupdate {
return true
}

p, err := exec.Command("kd", "-version").Output()
if err != nil {
return true
}

return !bytes.HasPrefix(bytes.TrimSpace(p), kdPrefix)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might want to add a note to the version command that if the prefix is changed (for whatever reasons), it would interfere with this. Would be quite the unexpected result

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The kd version string is generated by codegangsta/cli (the built-in -version flag).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Lee

On Thu, Jul 21, 2016 at 11:23 AM, Rafal Jeczalik notifications@github.com
wrote:

In go/src/koding/klient/app/klient.go
#8515 (comment):

}

k.kite.Run()

}

+var kdPrefix = []byte("kd version")
+
+func (k *Klient) autoupdateEnabled() bool {

  • if k.config.Autoupdate {
  •   return true
    
  • }
  • p, err := exec.Command("kd", "-version").Output()
  • if err != nil {
  •   return true
    
  • }
  • return !bytes.HasPrefix(bytes.TrimSpace(p), kdPrefix)

The kd version string is generated by codegangsta/cli (the built-in
-version flag).

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/koding/koding/pull/8515/files/e36a0cda3f78ac87ca979b77d1e2fc50758a5621#r71759718,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAC5xKV4CQFBWOOwQ6h-npodn4HepUzAks5qX7k_gaJpZM4JRp-J
.

}

func (k *Klient) register(registerURL *url.URL) error {
if u := k.tunnel.LocalKontrolURL(); u != nil {
origURL := k.kite.Config.KontrolURL
Expand Down Expand Up @@ -632,6 +651,18 @@ func newKite(kconf *KlientConfig) *kite.Kite {
k.Config.KontrolURL = kconf.KontrolURL
}

// Currently kite.key generated by kontrol injects
// default value of the kontrolUrl (http://127.0.0.1:3000/kite) and
// assumes it would get overwritten to a proper one during klient
// installation or start up.
//
// Ensure that any default value is overwritten with default kontrol.
//
// TODO(rjeczalik): ensure kontrolUrl is set to a proper value.
if k.Config.KontrolURL == "http://127.0.0.1:3000/kite" {
k.Config.KontrolURL = "https://koding.com/kontrol/kite"
}

return k
}

Expand Down
2 changes: 2 additions & 0 deletions go/src/koding/klient/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ var (
flagTunnelKiteURL = flag.String("tunnel-kite-url", "", "Change default tunnel server kite URL")
flagNoTunnel = flag.Bool("no-tunnel", defaultNoTunnel(), "Force tunnel connection off")
flagNoProxy = flag.Bool("no-proxy", false, "Force TLS proxy for tunneled connection off")
flagAutoupdate = flag.Bool("autoupdate", false, "Force turn automatic updates on")

// Upload log flags
flagLogBucketRegion = flag.String("log-bucket-region", "us-west-1", "Change bucket region to upload logs")
Expand Down Expand Up @@ -129,6 +130,7 @@ func realMain() int {
TunnelKiteURL: *flagTunnelKiteURL,
NoTunnel: *flagNoTunnel,
NoProxy: *flagNoProxy,
Autoupdate: *flagAutoupdate,
LogBucketRegion: *flagLogBucketRegion,
LogBucketName: *flagLogBucketName,
LogUploadLimit: *flagLogUploadLimit,
Expand Down