Skip to content

Commit

Permalink
Fix a bug for binding flags
Browse files Browse the repository at this point in the history
  • Loading branch information
minamijoyo committed Apr 20, 2022
1 parent 4d41048 commit fa96e92
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions cmd/filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ func init() {
flags := filterCmd.PersistentFlags()
flags.StringP("file", "f", "-", "A path to input Terraform configuration file")
flags.BoolP("update", "u", false, "Update files in-place")
_ = viper.BindPFlag("file", flags.Lookup("file"))
_ = viper.BindPFlag("update", flags.Lookup("update"))
_ = viper.BindPFlag("filter.file", flags.Lookup("file"))
_ = viper.BindPFlag("filter.update", flags.Lookup("update"))

RootCmd.AddCommand(filterCmd)
}
Expand Down Expand Up @@ -55,8 +55,8 @@ func runFilterAwsv4upgradeCmd(cmd *cobra.Command, args []string) error {
return fmt.Errorf("expected 0 argument, but got %d arguments", len(args))
}

file := viper.GetString("file")
update := viper.GetBool("update")
file := viper.GetString("filter.file")
update := viper.GetBool("filter.update")
filter, err := filter.NewFilterByType("awsv4upgrade")
if err != nil {
return err
Expand Down
8 changes: 4 additions & 4 deletions cmd/migration.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ func init() {
flags := migrationCmd.PersistentFlags()
flags.StringP("file", "f", "-", "A path to input Terraform plan file in JSON format")
flags.StringP("out", "o", "-", "Write a migration file to a given path")
_ = viper.BindPFlag("file", flags.Lookup("file"))
_ = viper.BindPFlag("out", flags.Lookup("out"))
_ = viper.BindPFlag("migration.file", flags.Lookup("file"))
_ = viper.BindPFlag("migration.out", flags.Lookup("out"))

RootCmd.AddCommand(migrationCmd)
}
Expand Down Expand Up @@ -58,8 +58,8 @@ func runMigrationAwsv4upgradeCmd(cmd *cobra.Command, args []string) error {
return fmt.Errorf("expected 0 argument, but got %d arguments", len(args))
}

planFile := viper.GetString("file")
migrationFile := viper.GetString("out")
planFile := viper.GetString("migration.file")
migrationFile := viper.GetString("migration.out")

var planJSON []byte
var err error
Expand Down

0 comments on commit fa96e92

Please sign in to comment.