forked from grafana/loki
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(thanos): add support for aliyun oss and baidu bos (grafana#14891)
- Loading branch information
1 parent
506da96
commit 58a509b
Showing
9 changed files
with
1,042 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package bos | ||
|
||
import ( | ||
"github.com/go-kit/log" | ||
"github.com/thanos-io/objstore" | ||
"github.com/thanos-io/objstore/providers/bos" | ||
) | ||
|
||
func NewBucketClient(cfg Config, name string, logger log.Logger) (objstore.Bucket, error) { | ||
bosCfg := bos.Config{ | ||
Endpoint: cfg.Endpoint, | ||
Bucket: cfg.Bucket, | ||
SecretKey: cfg.SecretKey.String(), | ||
AccessKey: cfg.AccessKey, | ||
} | ||
return bos.NewBucketWithConfig(logger, bosCfg, name) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package bos | ||
|
||
import ( | ||
"flag" | ||
|
||
"github.com/grafana/dskit/flagext" | ||
) | ||
|
||
// Config holds the configuration for Baidu Cloud BOS client | ||
type Config struct { | ||
Bucket string `yaml:"bucket"` | ||
Endpoint string `yaml:"endpoint"` | ||
AccessKey string `yaml:"access_key"` | ||
SecretKey flagext.Secret `yaml:"secret_key"` | ||
} | ||
|
||
func (cfg *Config) RegisterFlags(f *flag.FlagSet) { | ||
cfg.RegisterFlagsWithPrefix("", f) | ||
} | ||
|
||
func (cfg *Config) RegisterFlagsWithPrefix(prefix string, f *flag.FlagSet) { | ||
f.StringVar(&cfg.Bucket, prefix+"bos.bucket", "", "Name of BOS bucket.") | ||
f.StringVar(&cfg.Endpoint, prefix+"bos.endpoint", "", "BOS endpoint to connect to.") | ||
f.StringVar(&cfg.AccessKey, prefix+"bos.access-key", "", "Baidu Cloud Engine (BCE) Access Key ID.") | ||
f.Var(&cfg.SecretKey, prefix+"bos.secret-key", "Baidu Cloud Engine (BCE) Secret Access Key.") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package oss | ||
|
||
import ( | ||
"github.com/go-kit/log" | ||
"github.com/thanos-io/objstore" | ||
"github.com/thanos-io/objstore/providers/oss" | ||
) | ||
|
||
// NewBucketClient creates a new Alibaba Cloud OSS bucket client | ||
func NewBucketClient(cfg Config, component string, logger log.Logger) (objstore.Bucket, error) { | ||
ossCfg := oss.Config{ | ||
Endpoint: cfg.Endpoint, | ||
Bucket: cfg.Bucket, | ||
AccessKeyID: cfg.AccessKeyID, | ||
AccessKeySecret: cfg.AccessKeySecret.String(), | ||
} | ||
return oss.NewBucketWithConfig(logger, ossCfg, component, nil) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package oss | ||
|
||
import ( | ||
"flag" | ||
|
||
"github.com/grafana/dskit/flagext" | ||
) | ||
|
||
// Config holds the configuration for Alibaba Cloud OSS client | ||
type Config struct { | ||
Endpoint string `yaml:"endpoint"` | ||
Bucket string `yaml:"bucket"` | ||
AccessKeyID string `yaml:"access_key_id"` | ||
AccessKeySecret flagext.Secret `yaml:"access_key_secret"` | ||
} | ||
|
||
// RegisterFlags registers the flags for Alibaba Cloud OSS storage config | ||
func (cfg *Config) RegisterFlags(f *flag.FlagSet) { | ||
cfg.RegisterFlagsWithPrefix("", f) | ||
} | ||
|
||
// RegisterFlagsWithPrefix registers the flags for Alibaba Cloud OSS storage config with prefix | ||
func (cfg *Config) RegisterFlagsWithPrefix(prefix string, f *flag.FlagSet) { | ||
f.StringVar(&cfg.Bucket, prefix+"oss.bucketname", "", "Name of OSS bucket.") | ||
f.StringVar(&cfg.Endpoint, prefix+"oss.endpoint", "", "Endpoint to connect to.") | ||
f.StringVar(&cfg.AccessKeyID, prefix+"oss.access-key-id", "", "alibabacloud Access Key ID") | ||
f.Var(&cfg.AccessKeySecret, prefix+"oss.access-key-secret", "alibabacloud Secret Access Key") | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.