Skip to content

Commit

Permalink
set default value for client inbox
Browse files Browse the repository at this point in the history
  • Loading branch information
hooksie1 committed Aug 16, 2024
1 parent ed8c2a7 commit 9c934a4
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
2 changes: 2 additions & 0 deletions cmd/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@ var clientCmd = &cobra.Command{
func init() {
rootCmd.AddCommand(clientCmd)
natsFlags(clientCmd)
clientFlags(clientCmd)
}

func bindClientCmdFlags(cmd *cobra.Command, args []string) {
bindNatsFlags(cmd)
bindClientFlags(cmd)
}
8 changes: 8 additions & 0 deletions cmd/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@ func natsFlags(cmd *cobra.Command) {
cmd.PersistentFlags().Bool("use-traffic-shaping", false, "Local development connection")
}

func bindClientFlags(cmd *cobra.Command) {
viper.BindPFlag("inbox_prefix", cmd.Flags().Lookup("inbox-prefix"))
}

func clientFlags(cmd *cobra.Command) {
cmd.PersistentFlags().String("inbox-prefix", "PIGGYBANK.ADMIN", "subject prefix for replies")
}

// bindServiceFlags binds the secret flag values to viper
func bindServiceFlags(cmd *cobra.Command) {
viper.BindPFlag("port", cmd.Flags().Lookup("port"))
Expand Down
2 changes: 1 addition & 1 deletion cmd/nats.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
)

func newNatsConnection(name string) (*nats.Conn, error) {
opts := []nats.Option{nats.Name(name)}
opts := []nats.Option{nats.Name(name), nats.CustomInboxPrefix(viper.GetString("inbox_prefix"))}

_, ok := os.LookupEnv("USER")

Expand Down

0 comments on commit 9c934a4

Please sign in to comment.