add more option comments

This commit is contained in:
Jeff
2019-09-12 15:21:47 +08:00
committed by zryfish
parent 66af315a85
commit 5dde737e6c
10 changed files with 98 additions and 41 deletions

View File

@@ -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", true, "force path style")
fs.BoolVar(&s.ForcePathStyle, "s3-force-path-style", s.ForcePathStyle, "force path style")
}