提交 d86ce362 编写于 作者: L Liu Chang 提交者: Sebastian Florek

Set user-agent for client-go (#2559)

上级 58b6cab9
......@@ -35,6 +35,9 @@ gulp.task('backend', ['package-backend'], function(doneFn) {
'build',
// Install dependencies to speed up subsequent compilations.
'-i',
// record version info into src/version/version.go
'-ldflags',
conf.recordVersionExpression,
'-o',
path.join(conf.paths.serve, conf.backend.binaryName),
conf.backend.mainPackageName,
......@@ -116,6 +119,9 @@ function backendProd(outputBinaryPathsAndArchs) {
'-a',
'-installsuffix',
'cgo',
// record version info into src/version/version.go
'-ldflags',
conf.recordVersionExpression,
'-o',
path,
conf.backend.mainPackageName,
......
......@@ -75,6 +75,12 @@ const imageNameBase = 'kubernetes-dashboard';
* Exported configuration object with common constants used in build pipeline.
*/
export default {
/**
* the expression of recording version info into src/app/backend/client/manager.go
*/
recordVersionExpression:
`-X github.com/kubernetes/dashboard/src/app/backend/client.Version=${version.release}`,
/**
* Configuration for container registry to push images to.
*/
......
......@@ -42,8 +42,13 @@ const (
DefaultCmdConfigName = "kubernetes"
// Header name that contains token used for authorization. See TokenManager for more information.
JWETokenHeader = "jweToken"
// Default http header for user-agent
DefaultUserAgent = "dashboard"
)
// VERSION of this binary
var Version = "UNKNOWN"
// ClientManager is responsible for initializing and creating clients to communicate with
// kubernetes apiserver on demand
type ClientManager interface {
......@@ -188,6 +193,7 @@ func (self *clientManager) initConfig(cfg *rest.Config) {
cfg.QPS = DefaultQPS
cfg.Burst = DefaultBurst
cfg.ContentType = DefaultContentType
cfg.UserAgent = DefaultUserAgent + "/" + Version
}
// Returns rest Config based on provided apiserverHost and kubeConfigPath flags. If both are
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册