Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
水淹萌龙
kubesphere
提交
5dde737e
K
kubesphere
项目概览
水淹萌龙
/
kubesphere
与 Fork 源项目一致
Fork自
KubeSphere / kubesphere
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
K
kubesphere
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
5dde737e
编写于
9月 12, 2019
作者:
J
Jeff
提交者:
zryfish
9月 12, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add more option comments
上级
66af315a
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
98 addition
and
41 deletion
+98
-41
pkg/server/config/config.go
pkg/server/config/config.go
+32
-2
pkg/simple/client/devops/options.go
pkg/simple/client/devops/options.go
+5
-19
pkg/simple/client/k8s/kubernetes.go
pkg/simple/client/k8s/kubernetes.go
+2
-1
pkg/simple/client/ldap/options.go
pkg/simple/client/ldap/options.go
+4
-2
pkg/simple/client/mysql/options.go
pkg/simple/client/mysql/options.go
+18
-2
pkg/simple/client/openpitrix/options.go
pkg/simple/client/openpitrix/options.go
+3
-1
pkg/simple/client/prometheus/options.go
pkg/simple/client/prometheus/options.go
+7
-2
pkg/simple/client/redis/options.go
pkg/simple/client/redis/options.go
+11
-1
pkg/simple/client/s2is3/options.go
pkg/simple/client/s2is3/options.go
+15
-7
pkg/simple/client/sonarqube/options.go
pkg/simple/client/sonarqube/options.go
+1
-4
未找到文件。
pkg/server/config/config.go
浏览文件 @
5dde737e
...
...
@@ -20,7 +20,34 @@ import (
"net/http"
)
// install api for config
// Package config saves configuration for running KubeSphere components
//
// Config can be configured from command line flags and configuration file.
// Command line flags hold higher priority than configuration file. But if
// component Endpoint/Host/APIServer was left empty, all of that component
// command line flags will be ignored, use configuration file instead.
// For example, we have configuration file
//
// mysql:
// host: mysql.kubesphere-system.svc
// username: root
// password: password
//
// At the same time, have command line flags like following:
//
// --mysql-host mysql.openpitrix-system.svc --mysql-username king --mysql-password 1234
//
// We will use `king:1234@mysql.openpitrix-system.svc` from command line flags rather
// than `root:password@mysql.kubesphere-system.svc` from configuration file,
// cause command line has higher priority. But if command line flags like following:
//
// --mysql-username root --mysql-password password
//
// we will `root:password@mysql.kubesphere-system.svc` as input, case
// mysql-host is missing in command line flags, all other mysql command line flags
// will be ignored.
// InstallAPI installs api for config
func
InstallAPI
(
c
*
restful
.
Container
)
{
ws
:=
runtime
.
NewWebService
(
schema
.
GroupVersion
{
Group
:
""
,
...
...
@@ -39,7 +66,7 @@ func InstallAPI(c *restful.Container) {
c
.
Add
(
ws
)
}
//
load
configuration after setup
//
Load loads
configuration after setup
func
Load
()
error
{
sharedConfig
=
newConfig
()
...
...
@@ -69,7 +96,10 @@ func Load() error {
}
const
(
// DefaultConfigurationName is the default name of configuration
DefaultConfigurationName
=
"kubesphere"
// DefaultConfigurationPath the default location of the configuration file
DefaultConfigurationPath
=
"/etc/kubesphere"
)
...
...
pkg/simple/client/devops/options.go
浏览文件 @
5dde737e
...
...
@@ -3,6 +3,7 @@ package devops
import
(
"fmt"
"github.com/spf13/pflag"
"kubesphere.io/kubesphere/pkg/utils/reflectutils"
)
type
DevopsOptions
struct
{
...
...
@@ -22,29 +23,14 @@ func NewDevopsOptions() *DevopsOptions {
}
}
// ApplyTo apply configuration to another options
func
(
s
*
DevopsOptions
)
ApplyTo
(
options
*
DevopsOptions
)
{
if
options
==
nil
{
return
}
if
s
.
Host
!=
""
{
options
.
Host
=
s
.
Host
}
if
s
.
Username
!=
""
{
options
.
Username
=
s
.
Username
}
if
s
.
Password
!=
""
{
options
.
Password
=
s
.
Password
}
if
s
.
MaxConnections
>
0
{
options
.
MaxConnections
=
s
.
MaxConnections
if
s
.
Host
!=
""
&&
options
!=
nil
{
reflectutils
.
Override
(
options
,
s
)
}
}
//
//
Validate check if there is misconfiguration in options
func
(
s
*
DevopsOptions
)
Validate
()
[]
error
{
errors
:=
[]
error
{}
...
...
pkg/simple/client/k8s/kubernetes.go
浏览文件 @
5dde737e
...
...
@@ -22,7 +22,7 @@ type KubernetesClient struct {
config
*
rest
.
Config
}
// NewKubernetesClient
// NewKubernetesClient
OrDie creates KubernetesClient and panic if there is an error
func
NewKubernetesClientOrDie
(
options
*
KubernetesOptions
)
*
KubernetesClient
{
config
,
err
:=
clientcmd
.
BuildConfigFromFlags
(
""
,
options
.
KubeConfig
)
if
err
!=
nil
{
...
...
@@ -47,6 +47,7 @@ func NewKubernetesClientOrDie(options *KubernetesOptions) *KubernetesClient {
return
k
}
// NewKubernetesClient creates a KubernetesClient
func
NewKubernetesClient
(
options
*
KubernetesOptions
)
(
*
KubernetesClient
,
error
)
{
config
,
err
:=
clientcmd
.
BuildConfigFromFlags
(
""
,
options
.
KubeConfig
)
if
err
!=
nil
{
...
...
pkg/simple/client/ldap/options.go
浏览文件 @
5dde737e
...
...
@@ -31,12 +31,14 @@ func (l *LdapOptions) Validate() []error {
}
func
(
l
*
LdapOptions
)
ApplyTo
(
options
*
LdapOptions
)
{
reflectutils
.
Override
(
options
,
l
)
if
l
.
Host
!=
""
{
reflectutils
.
Override
(
options
,
l
)
}
}
func
(
l
*
LdapOptions
)
AddFlags
(
fs
*
pflag
.
FlagSet
)
{
fs
.
StringVar
(
&
l
.
Host
,
"ldap-host"
,
l
.
Host
,
""
+
"Ldap service host, if left blank, all of the following options will "
+
"Ldap service host, if left blank, all of the following
ldap
options will "
+
"be ignored and ldap will be disabled."
)
fs
.
StringVar
(
&
l
.
ManagerDN
,
"ldap-manager-dn"
,
l
.
ManagerDN
,
""
+
...
...
pkg/simple/client/mysql/options.go
浏览文件 @
5dde737e
...
...
@@ -17,7 +17,14 @@ type MySQLOptions struct {
// NewMySQLOptions create a `zero` value instance
func
NewMySQLOptions
()
*
MySQLOptions
{
return
&
MySQLOptions
{}
return
&
MySQLOptions
{
Host
:
""
,
Username
:
""
,
Password
:
""
,
MaxIdleConnections
:
100
,
MaxOpenConnections
:
100
,
MaxConnectionLifeTime
:
time
.
Duration
(
10
)
*
time
.
Second
,
}
}
func
(
m
*
MySQLOptions
)
Validate
()
[]
error
{
...
...
@@ -33,11 +40,20 @@ func (m *MySQLOptions) ApplyTo(options *MySQLOptions) {
func
(
m
*
MySQLOptions
)
AddFlags
(
fs
*
pflag
.
FlagSet
)
{
fs
.
StringVar
(
&
m
.
Host
,
"mysql-host"
,
m
.
Host
,
""
+
"MySQL service host address. If left blank,
following
options will be ignored."
)
"MySQL service host address. If left blank,
the following related mysql
options will be ignored."
)
fs
.
StringVar
(
&
m
.
Username
,
"mysql-username"
,
m
.
Username
,
""
+
"Username for access to mysql service."
)
fs
.
StringVar
(
&
m
.
Password
,
"mysql-password"
,
m
.
Password
,
""
+
"Password for access to mysql, should be used pair with password."
)
fs
.
IntVar
(
&
m
.
MaxIdleConnections
,
"mysql-max-idle-connections"
,
m
.
MaxOpenConnections
,
""
+
"Maximum idle connections allowed to connect to mysql."
)
fs
.
IntVar
(
&
m
.
MaxOpenConnections
,
"mysql-max-open-connections"
,
m
.
MaxOpenConnections
,
""
+
"Maximum open connections allowed to connect to mysql."
)
fs
.
DurationVar
(
&
m
.
MaxConnectionLifeTime
,
"mysql-max-connection-life-time"
,
m
.
MaxConnectionLifeTime
,
""
+
"Maximum connection life time allowed to connecto to mysql."
)
}
pkg/simple/client/openpitrix/options.go
浏览文件 @
5dde737e
...
...
@@ -19,7 +19,9 @@ func NewOpenPitrixOptions() *OpenPitrixOptions {
}
func
(
s
*
OpenPitrixOptions
)
ApplyTo
(
options
*
OpenPitrixOptions
)
{
reflectutils
.
Override
(
options
,
s
)
if
s
.
APIServer
!=
""
{
reflectutils
.
Override
(
options
,
s
)
}
}
func
(
s
*
OpenPitrixOptions
)
Validate
()
[]
error
{
...
...
pkg/simple/client/prometheus/options.go
浏览文件 @
5dde737e
...
...
@@ -2,7 +2,6 @@ package prometheus
import
(
"github.com/spf13/pflag"
"kubesphere.io/kubesphere/pkg/utils/reflectutils"
)
type
PrometheusOptions
struct
{
...
...
@@ -24,7 +23,13 @@ func (s *PrometheusOptions) Validate() []error {
}
func
(
s
*
PrometheusOptions
)
ApplyTo
(
options
*
PrometheusOptions
)
{
reflectutils
.
Override
(
options
,
s
)
if
s
.
Endpoint
!=
""
{
options
.
Endpoint
=
s
.
Endpoint
}
if
s
.
SecondaryEndpoint
!=
""
{
options
.
SecondaryEndpoint
=
s
.
SecondaryEndpoint
}
}
func
(
s
*
PrometheusOptions
)
AddFlags
(
fs
*
pflag
.
FlagSet
)
{
...
...
pkg/simple/client/redis/options.go
浏览文件 @
5dde737e
...
...
@@ -25,6 +25,7 @@ func NewRedisOptions() *RedisOptions {
}
}
// Validate check options
func
(
r
*
RedisOptions
)
Validate
()
[]
error
{
errors
:=
make
([]
error
,
0
)
...
...
@@ -34,13 +35,22 @@ func (r *RedisOptions) Validate() []error {
}
}
if
r
.
DB
<
0
{
errors
=
append
(
errors
,
fmt
.
Errorf
(
"--redis-db is less than 0"
))
}
return
errors
}
// ApplyTo apply to another options if it's a enabled option(non empty host)
func
(
r
*
RedisOptions
)
ApplyTo
(
options
*
RedisOptions
)
{
reflectutils
.
Override
(
options
,
r
)
if
r
.
Host
!=
""
{
reflectutils
.
Override
(
options
,
r
)
}
}
// AddFlags add option flags to command line flags,
// if redis-host left empty, the following options will be ignored.
func
(
r
*
RedisOptions
)
AddFlags
(
fs
*
pflag
.
FlagSet
)
{
fs
.
StringVar
(
&
r
.
Host
,
"redis-host"
,
r
.
Host
,
""
+
"Redis service host address. If left blank, means redis is unnecessary, "
+
...
...
pkg/simple/client/s2is3/options.go
浏览文件 @
5dde737e
...
...
@@ -5,6 +5,7 @@ import (
"kubesphere.io/kubesphere/pkg/utils/reflectutils"
)
// S3Options contains configuration to access a s3 service
type
S3Options
struct
{
Endpoint
string
`json:"endpoint,omitempty" yaml:"endpoint,omitempty"`
Region
string
`json:"region,omitempty" yaml:"region,omitempty"`
...
...
@@ -16,6 +17,7 @@ type S3Options struct {
Bucket
string
`json:"bucket,omitempty" yaml:"bucket,omitempty"`
}
// NewS3Options creates a default disabled S3Options(empty endpoint)
func
NewS3Options
()
*
S3Options
{
return
&
S3Options
{
Endpoint
:
""
,
...
...
@@ -29,33 +31,39 @@ func NewS3Options() *S3Options {
}
}
// Validate check options values
func
(
s
*
S3Options
)
Validate
()
[]
error
{
errors
:=
[]
error
{}
return
errors
}
// ApplyTo overrides options if it's valid, which endpoint is not empty
func
(
s
*
S3Options
)
ApplyTo
(
options
*
S3Options
)
{
reflectutils
.
Override
(
options
,
s
)
if
s
.
Endpoint
!=
""
{
reflectutils
.
Override
(
options
,
s
)
}
}
// AddFlags add options flags to command line flags,
// if s3-endpoint if left empty, following options will be ignored
func
(
s
*
S3Options
)
AddFlags
(
fs
*
pflag
.
FlagSet
)
{
fs
.
StringVar
(
&
s
.
Endpoint
,
"s3-endpoint"
,
s
.
Endpoint
,
""
+
"Endpoint to access to s3 object storage service, if left blank, the following options "
+
"will be ignored."
)
fs
.
StringVar
(
&
s
.
Region
,
"s3-region"
,
"us-east-1"
,
""
+
fs
.
StringVar
(
&
s
.
Region
,
"s3-region"
,
s
.
Region
,
""
+
"Region of s3 that will access to, like us-east-1."
)
fs
.
StringVar
(
&
s
.
AccessKeyID
,
"s3-access-key-id"
,
"AKIAIOSFODNN7EXAMPLE"
,
"access key of s2i s3"
)
fs
.
StringVar
(
&
s
.
AccessKeyID
,
"s3-access-key-id"
,
s
.
AccessKeyID
,
"access key of s2i s3"
)
fs
.
StringVar
(
&
s
.
SecretAccessKey
,
"s3-secret-access-key"
,
"wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY"
,
"secret access key of s2i s3"
)
fs
.
StringVar
(
&
s
.
SecretAccessKey
,
"s3-secret-access-key"
,
s
.
SecretAccessKey
,
"secret access key of s2i s3"
)
fs
.
StringVar
(
&
s
.
SessionToken
,
"s3-session-token"
,
s
.
SessionToken
,
"session token of s2i s3"
)
fs
.
StringVar
(
&
s
.
Bucket
,
"s3-bucket"
,
"s2i-binaries"
,
"bucket name of s2i s3"
)
fs
.
StringVar
(
&
s
.
Bucket
,
"s3-bucket"
,
s
.
Bucket
,
"bucket name of s2i s3"
)
fs
.
BoolVar
(
&
s
.
DisableSSL
,
"s3-disable-SSL"
,
true
,
"disable ssl"
)
fs
.
BoolVar
(
&
s
.
DisableSSL
,
"s3-disable-SSL"
,
s
.
DisableSSL
,
"disable ssl"
)
fs
.
BoolVar
(
&
s
.
ForcePathStyle
,
"s3-force-path-style"
,
tru
e
,
"force path style"
)
fs
.
BoolVar
(
&
s
.
ForcePathStyle
,
"s3-force-path-style"
,
s
.
ForcePathStyl
e
,
"force path style"
)
}
pkg/simple/client/sonarqube/options.go
浏览文件 @
5dde737e
...
...
@@ -33,16 +33,13 @@ func (s *SonarQubeOptions) ApplyTo(options *SonarQubeOptions) {
if
s
.
Host
!=
""
{
options
.
Host
=
s
.
Host
}
if
s
.
Token
!=
""
{
options
.
Token
=
s
.
Token
}
}
func
(
s
*
SonarQubeOptions
)
AddFlags
(
fs
*
pflag
.
FlagSet
)
{
fs
.
StringVar
(
&
s
.
Host
,
"sonarqube-host"
,
s
.
Host
,
""
+
"Sonarqube service address
if enabl
ed."
)
"Sonarqube service address
, if left empty, following sonarqube options will be ignor
ed."
)
fs
.
StringVar
(
&
s
.
Token
,
"sonarqube-token"
,
s
.
Token
,
""
+
"Sonarqube service access token."
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录