Files
kubesphere/pkg/simple/client/s2is3/options.go
Jeff 96d2ac4112 This is a huge commit, it does following things:
1. refactor kubesphere dependency service client creation, we can
disable dependency by config
2. dependencies can be configured by configuration file
3. refactor cmd package using cobra.Command, so we can use hypersphere
to invoke command sepearately. Later we only need to build one image to
contains all kubesphere core components. One command to rule them all!
4. live reloading configuration currently not implemented
2019-09-11 19:53:35 +08:00

62 lines
2.1 KiB
Go

package s2is3
import (
"github.com/spf13/pflag"
"kubesphere.io/kubesphere/pkg/utils/reflectutils"
)
type S3Options struct {
Endpoint string `json:"endpoint,omitempty" yaml:"endpoint,omitempty"`
Region string `json:"region,omitempty" yaml:"region,omitempty"`
DisableSSL bool `json:"disableSSL,omitempty" yaml:"disableSSL,omitempty"`
ForcePathStyle bool `json:"forcePathStyle,omitempty" yaml:"forePathStyle,omitempty"`
AccessKeyID string `json:"accessKeyID,omitempty" yaml:"accessKeyID,omitempty"`
SecretAccessKey string `json:"secretAccessKey,omitempty" yaml:"secretAccessKey,omitempty"`
SessionToken string `json:"sessionToken,omitempty" yaml:"sessionToken,omitempty"`
Bucket string `json:"bucket,omitempty" yaml:"bucket,omitempty"`
}
func NewS3Options() *S3Options {
return &S3Options{
Endpoint: "",
Region: "",
DisableSSL: true,
ForcePathStyle: true,
AccessKeyID: "",
SecretAccessKey: "",
SessionToken: "",
Bucket: "",
}
}
func (s *S3Options) Validate() []error {
errors := []error{}
return errors
}
func (s *S3Options) ApplyTo(options *S3Options) {
reflectutils.Override(options, s)
}
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", 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.SecretAccessKey, "s3-secret-access-key", "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY", "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.BoolVar(&s.DisableSSL, "s3-disable-SSL", s.DisableSSL, "disable ssl")
fs.BoolVar(&s.ForcePathStyle, "s3-force-path-style", true, "force path style")
}