From 03df692ae2f911943d5ef98b0ee2f9461605fb8c Mon Sep 17 00:00:00 2001 From: Krishna Srinivas Date: Thu, 26 Oct 2017 18:53:45 -0700 Subject: [PATCH] Support for bosh/pcf user-agent when querying for updates. (#5116) --- cmd/update-main.go | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/cmd/update-main.go b/cmd/update-main.go index aa6893328..f02580a63 100644 --- a/cmd/update-main.go +++ b/cmd/update-main.go @@ -169,6 +169,20 @@ func IsKubernetes() bool { return os.Getenv("KUBERNETES_SERVICE_HOST") != "" } +// IsBOSH returns true if minio is deployed from a bosh package +func IsBOSH() bool { + // "/var/vcap/bosh" exists in BOSH deployed instance. + _, err := os.Stat("/var/vcap/bosh") + if os.IsNotExist(err) { + return false + } + + // Log error, as we will not propagate it to caller + errorIf(err, "Error in BOSH check.") + + return err == nil +} + // Minio Helm chart uses DownwardAPIFile to write pod label info to /podinfo/labels // More info: https://kubernetes.io/docs/tasks/inject-data-application/downward-api-volume-expose-pod-information/#store-pod-fields // Check if this is Helm package installation and report helm chart version @@ -233,6 +247,9 @@ func getUserAgent(mode string) string { if IsDocker() { uaAppend("; ", "docker") } + if IsBOSH() { + uaAppend("; ", "bosh") + } if IsSourceBuild() { uaAppend("; ", "source") } @@ -256,6 +273,11 @@ func getUserAgent(mode string) string { } } + pcfTileVersion := os.Getenv("MINIO_PCF_TILE_VERSION") + if pcfTileVersion != "" { + uaAppend(" Minio/pcf-tile-", pcfTileVersion) + } + return strings.Join(userAgentParts, "") }