// run command with arguments Run(args []string) int // return short help string Synopsis() string } // Command struct is the OutConfig and RDSConfig and RDSClient and ARNPrefix variable type Command struct { OutConfig config.OutConfig RDSConfig config.RDSConfig RDSClient *rds.RDS ARNPrefix string } var log = logger.GetLogger("command") var ( // ErrDBInstancetNotFound is the "DB Instance is not found" error ErrDBInstancetNotFound = errors.New("DB Instance is not found") // ErrSnapshotNotFound is the "DB Snapshot is not found" error ErrSnapshotNotFound = errors.New("DB Snapshot is not found") // ErrDriverNotFound is the "DB Driver is not found" error ErrDriverNotFound = errors.New("DB Driver is not found") // ErrRdsTypesNotFound is the "RDS Types is not found" error ErrRdsTypesNotFound = errors.New("RDS Types is not found") // ErrRdsARNsNotFound is the "RDS ARN Types is not found" error ErrRdsARNsNotFound = errors.New("RDS ARN Types is not found") ) func (c *Command) describeDBInstances(input *rds.DescribeDBInstancesInput) ([]*rds.DBInstance, error) {
) // Queries struct have Query array variable type Queries struct { Query []Query } // Query struct have Name and Sql variable type Query struct { Name string `toml:"name"` SQL string `toml:"sql"` } const queryFile = "rds-try.query" var log = logger.GetLogger("query") // ErrQueryNotFound is "SQL item not found in query file" error. var ErrQueryNotFound = errors.New("SQL item not found in query file") // LoadQuery is the contents are loaded from "rds-try.query" file. func LoadQuery(file string) (*Queries, error) { queries := &Queries{} if _, err := toml.DecodeFile(file, &queries); err != nil { log.Errorf("%s", err.Error()) return queries, err } // check require values if len(queries.Query) <= 0 {
"path" "runtime" "sort" "strings" "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/service/iam" "github.com/aws/aws-sdk-go/service/rds" "github.com/uchimanajet7/rds-try/command" "github.com/uchimanajet7/rds-try/config" "github.com/uchimanajet7/rds-try/logger" "github.com/uchimanajet7/rds-try/utils" ) var log = logger.GetLogger("main") func showHelp() func() { return func() { helpText := fmt.Sprintf("\nUsage: %s [globals] <command> [options]\n\n", utils.GetAppName()) helpText += "Globals:\n" globals := make(map[string]string) // list global options flag.VisitAll(func(f *flag.Flag) { if value, ok := globals[f.Usage]; ok { // key exists if len(f.Name) > len(value) { globals[f.Usage] = fmt.Sprintf("-%s, --%s", value, f.Name) } else {
JSON bool `toml:"json"` } // RDSConfig struct is MultiAz and DBId and Region and User and Pass and Type variable type RDSConfig struct { MultiAz bool `toml:"multi_az"` DBId string `toml:"db_id"` Region string `toml:"region"` User string `toml:"user"` Pass string `toml:"pass"` Type string `toml:"type"` } const configFile = "rds-try.conf" var log = logger.GetLogger("config") // ErrRdsSectionNotFound is the config file format error var ErrRdsSectionNotFound = errors.New("[rds.*] section not found in file") // LoadConfig is the contents are loaded from "rds-try.conf" file. func LoadConfig(file string) (*Config, error) { config := &Config{} if _, err := toml.DecodeFile(file, &config); err != nil { log.Errorf("%s", err.Error()) return config, err } if len(config.Rds) <= 0 { log.Errorf("%s", ErrRdsSectionNotFound.Error())