forked from zilliztech/milvus-backup
-
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.
Prints the current backup config file in yaml format to stdio (zilli…
…ztech#209) * Adds the ability to override backup_yaml values using a capitalized snake case format (--set MILVUS_USER=Marco)" Command to print the current backup config file in yaml format to stdio Signed-off-by: romel.campbell <romel.campbell@regeneron.com>
- Loading branch information
Showing
4 changed files
with
133 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,102 @@ | ||
package cmd | ||
|
||
import ( | ||
"fmt" | ||
"strings" | ||
"github.com/spf13/cobra" | ||
"github.com/zilliztech/milvus-backup/core/paramtable" | ||
"gopkg.in/yaml.v3" | ||
) | ||
|
||
var configCmd = &cobra.Command{ | ||
Use: "backup_yaml", | ||
Short: "backup_yaml is a subcommand to check. It prints the current backup config file in yaml format to stdio.", | ||
|
||
Run: func(cmd *cobra.Command, args []string) { | ||
var params paramtable.BackupParams | ||
params.GlobalInitWithYaml(config) | ||
params.Init() | ||
|
||
printParams(¶ms) | ||
}, | ||
} | ||
|
||
type YAMLConFig struct { | ||
Log struct { | ||
Level string `yaml:"level"` | ||
Console bool `yaml:"console"` | ||
File struct { | ||
RootPath string `yaml:"rootPath"` | ||
} | ||
Http struct { | ||
SimpleResponse bool `yaml:"simpleResponse"` | ||
} `yaml:"http"` | ||
} `yaml:"log"` | ||
Milvus struct { | ||
Address string `yaml:"address"` | ||
Port int `yaml:"port"` | ||
AuthorizationEnabled bool `yaml:"authorizationEnabled"` | ||
TlsMode int `yaml:"tlsMode"` | ||
User string `yaml:"user"` | ||
Password string `yaml:"password"` | ||
} `yaml:"milvus"` | ||
Minio struct { | ||
Address string `yaml:"address"` | ||
Port int `yaml:"port"` | ||
AccessKeyID string `yaml:"accessKeyID"` | ||
secretAccessKey string `yaml:"secretAccessKey"` | ||
UseSSL bool `yaml:"useSSL"` | ||
UseIAM bool `yaml:"useIAM"` | ||
CloudProvider string `yaml:"cloudProvider"` | ||
IamEndpoint string `yaml:"iamEndpoint"` | ||
BucketName string `yaml:"bucketName"` | ||
RootPath string `yaml:"rootPath"` | ||
BackupBucketName string `yaml:"backupBucketName"` | ||
BackupRootPath string `yaml:"backupRootPath"` | ||
} `yaml:"minio"` | ||
Backup struct { | ||
MaxSegmentGroupSize string `yaml:"maxSegmentGroupSize"` | ||
} `yaml:"backup"` | ||
} | ||
|
||
func init() { | ||
checkCmd.AddCommand(configCmd) | ||
} | ||
|
||
func printParams(base *paramtable.BackupParams) { | ||
|
||
yml := YAMLConFig{} | ||
|
||
yml.Log.Level = base.BaseTable.LoadWithDefault("log.level", "debug") | ||
yml.Log.Console = base.ParseBool("log.console", false) | ||
yml.Log.File.RootPath = base.LoadWithDefault("log.file.rootPath", "backup.log") | ||
|
||
yml.Milvus.Address = base.LoadWithDefault("milvus.address", "localhost") | ||
yml.Milvus.Port = base.ParseIntWithDefault("milvus.port", 19530) | ||
yml.Milvus.AuthorizationEnabled = base.ParseBool("milvus.authorizationEnabled", false) | ||
yml.Milvus.TlsMode = base.ParseIntWithDefault("milvus.tlsMode", 0) | ||
yml.Milvus.User = base.BaseTable.LoadWithDefault("milvus.user", "") | ||
yml.Milvus.Password = base.BaseTable.LoadWithDefault("milvus.password", "") | ||
|
||
yml.Minio.Address = base.LoadWithDefault("minio.address", "localhost") | ||
yml.Minio.Port = base.ParseIntWithDefault("minio.port", 9000) | ||
yml.Minio.AccessKeyID = base.BaseTable.LoadWithDefault("minio.accessKeyID", "") | ||
yml.Minio.secretAccessKey = base.BaseTable.LoadWithDefault("minio.secretAccessKey", "") | ||
yml.Minio.UseSSL = base.ParseBool("minio.useSSL", false) | ||
yml.Minio.UseIAM = base.ParseBool("minio.useIAM", false) | ||
yml.Minio.CloudProvider = base.BaseTable.LoadWithDefault("minio.cloudProvider", "aws") | ||
yml.Minio.IamEndpoint = base.BaseTable.LoadWithDefault("minio.iamEndpoint", "") | ||
yml.Minio.BucketName = base.BaseTable.LoadWithDefault("minio.bucketName", "") | ||
yml.Minio.RootPath = base.LoadWithDefault("minio.rootPath", "") | ||
yml.Minio.BackupBucketName = base.LoadWithDefault("minio.backupBucketName", "") | ||
yml.Minio.BackupRootPath = base.LoadWithDefault("minio.backupRootPath", "") | ||
|
||
yml.Backup.MaxSegmentGroupSize = base.LoadWithDefault("backup.maxSegmentGroupSize", "5G") | ||
|
||
bytes, err := yaml.Marshal(yml) | ||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
fmt.Printf("%s\n%s", strings.Repeat("-", 80), string(bytes)) | ||
} |
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
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