Skip to content
This repository has been archived by the owner on Oct 9, 2023. It is now read-only.

Commit

Permalink
Added pflag for stow config in storage (#95)
Browse files Browse the repository at this point in the history
* Generated pflag for stow config

Signed-off-by: Yuvraj <[email protected]>

* more changes

Signed-off-by: Yuvraj <[email protected]>

* more changes

Signed-off-by: Yuvraj <[email protected]>
  • Loading branch information
yindia authored Aug 13, 2021
1 parent 70ea45d commit f6f76d8
Show file tree
Hide file tree
Showing 7 changed files with 76 additions and 110 deletions.
2 changes: 2 additions & 0 deletions cli/pflags/api/testdata/testtype.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 28 additions & 0 deletions cli/pflags/api/testdata/testtype_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions storage/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ var (
type Config struct {
Type Type `json:"type" pflag:",Sets the type of storage to configure [s3/minio/local/mem/stow]."`
Connection ConnectionConfig `json:"connection"`
Stow *StowConfig `json:"stow,omitempty"`
Stow StowConfig `json:"stow,omitempty" pflag:",Storage config for stow backend."`
// Container here is misleading, it refers to a Bucket (AWS S3) like blobstore entity. In some terms it could be a table
InitContainer string `json:"container" pflag:",Initial container (in s3 a bucket) to create -if it doesn't exist-.'"`
// By default if this is not enabled, multiple containers are not supported by the storage layer. Only the configured `container` InitContainer will be allowed to requests data from. But, if enabled then data will be loaded to written to any
Expand Down Expand Up @@ -79,8 +79,8 @@ type ConnectionConfig struct {
}

type StowConfig struct {
Kind string `json:"kind,omitempty" pflag:"-,Kind of Stow backend to use. Refer to github/graymeta/stow"`
Config map[string]string `json:"config,omitempty" pflag:"-,Configuration for stow backend. Refer to github/graymeta/stow"`
Kind string `json:"kind,omitempty" pflag:",Kind of Stow backend to use. Refer to github/graymeta/stow"`
Config map[string]string `json:"config,omitempty" pflag:",Configuration for stow backend. Refer to github/graymeta/stow"`
}

type CachingConfig struct {
Expand Down
13 changes: 12 additions & 1 deletion storage/config_flags.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

124 changes: 24 additions & 100 deletions storage/config_flags_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion storage/stow_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"fmt"
"io"
"reflect"
"sync"
"time"

Expand Down Expand Up @@ -319,7 +320,7 @@ func newStowRawStore(cfg *Config, metricsScope promutils.Scope) (RawStore, error

var cfgMap stow.ConfigMap
var kind string
if cfg.Stow != nil {
if !reflect.DeepEqual(cfg.Stow, StowConfig{}) {
kind = cfg.Stow.Kind
cfgMap = cfg.Stow.Config
} else {
Expand Down
10 changes: 5 additions & 5 deletions storage/stow_store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ func TestNewLocalStore(t *testing.T) {
t.Run("Valid config", func(t *testing.T) {
testScope := promutils.NewTestScope()
store, err := newStowRawStore(&Config{
Stow: &StowConfig{
Stow: StowConfig{
Kind: local.Kind,
Config: map[string]string{
local.ConfigKeyPath: "./",
Expand Down Expand Up @@ -339,7 +339,7 @@ func TestNewLocalStore(t *testing.T) {
assert.NotNil(t, stats)

store, err := newStowRawStore(&Config{
Stow: &StowConfig{
Stow: StowConfig{
Kind: local.Kind,
Config: map[string]string{
local.ConfigKeyPath: tmpDir,
Expand Down Expand Up @@ -368,7 +368,7 @@ func TestNewLocalStore(t *testing.T) {
assert.NotNil(t, stats)

store, err := newStowRawStore(&Config{
Stow: &StowConfig{
Stow: StowConfig{
Kind: local.Kind,
Config: map[string]string{
local.ConfigKeyPath: tmpDir,
Expand All @@ -390,7 +390,7 @@ func TestNewLocalStore(t *testing.T) {
assert.NotNil(t, stats)

store, err := newStowRawStore(&Config{
Stow: &StowConfig{
Stow: StowConfig{
Kind: local.Kind,
Config: map[string]string{
local.ConfigKeyPath: tmpDir,
Expand Down Expand Up @@ -424,7 +424,7 @@ func Test_newStowRawStore(t *testing.T) {
{"fail", args{&Config{}, promutils.NewTestScope()}, true},
{"google", args{&Config{
InitContainer: "flyte",
Stow: &StowConfig{
Stow: StowConfig{
Kind: google.Kind,
Config: map[string]string{
google.ConfigProjectId: "x",
Expand Down

0 comments on commit f6f76d8

Please sign in to comment.