Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: Config parsing & precedence #103

Open
wants to merge 11 commits into
base: v0.12
Choose a base branch
from
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,29 @@ Inventory Service forwarding to /webhooks/shopify/inventory
Orders Service forwarding to /webhooks/shopify/orders


⣾ Getting ready...

```

#### Listen to multiple sources

`source-alias` can be a comma-separated list of source names (for example, `stripe,shopify,twilio`) or `'*'` (with quotes) to listen to all sources.

```sh-session
$ hookdeck listen 3000 '*'

👉 Inspect and replay events: https://dashboard.hookdeck.com/cli/events

Sources
🔌 stripe URL: https://events.hookdeck.com/e/src_DAjaFWyyZXsFdZrTOKpuHn01
🔌 shopify URL: https://events.hookdeck.com/e/src_DAjaFWyyZXsFdZrTOKpuHn02
🔌 twilio URL: https://events.hookdeck.com/e/src_DAjaFWyyZXsFdZrTOKpuHn03

Connections
stripe -> cli-stripe forwarding to /webhooks/stripe
shopify -> cli-shopify forwarding to /webhooks/shopify
twilio -> cli-twilio forwarding to /webhooks/twilio

⣾ Getting ready...

```
Expand Down
1 change: 0 additions & 1 deletion pkg/cmd/listen.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ func normalizeCliPathFlag(f *pflag.FlagSet, name string) pflag.NormalizedName {
switch name {
case "cli-path":
name = "path"
break
}
return pflag.NormalizedName(name)
}
Expand Down
13 changes: 8 additions & 5 deletions pkg/cmd/project_use.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ import (
"github.com/spf13/cobra"

"github.com/hookdeck/hookdeck-cli/pkg/hookdeck"
"github.com/hookdeck/hookdeck-cli/pkg/validators"
"github.com/hookdeck/hookdeck-cli/pkg/project"
"github.com/hookdeck/hookdeck-cli/pkg/validators"
)

type projectUseCmd struct {
cmd *cobra.Command
local bool
cmd *cobra.Command
// local bool
}

func newProjectUseCmd() *projectUseCmd {
Expand All @@ -23,7 +23,10 @@ func newProjectUseCmd() *projectUseCmd {
Short: "Select your active project for future commands",
RunE: lc.runProjectUseCmd,
}
lc.cmd.Flags().BoolVar(&lc.local, "local", false, "Pin active project to the current directory")

// With the change in config management (either local or global, not both), this flag is no longer needed
// TODO: consider remove / deprecate
// lc.cmd.Flags().BoolVar(&lc.local, "local", false, "Pin active project to the current directory")
Comment on lines +27 to +29
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wanna place some emphasis here given the change from this PR makes this flag obsolete. There's nothing we can do whether the user passes --local flag to $ hookdeck project use --local command or not.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alexluong how does a user create a local config without this?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think there's a way right now. The original thought process was people may write the config manually. We can certainly support a local flag for the login command maybe?


return lc
}
Expand Down Expand Up @@ -74,5 +77,5 @@ func (lc *projectUseCmd) runProjectUseCmd(cmd *cobra.Command, args []string) err
}
}

return Config.UseProject(lc.local, project.Id, project.Mode)
return Config.UseProject(project.Id, project.Mode)
}
2 changes: 1 addition & 1 deletion pkg/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func init() {
rootCmd.PersistentFlags().StringVar(&Config.Profile.APIKey, "cli-key", "", "(deprecated) Your API key to use for the command")
rootCmd.PersistentFlags().StringVar(&Config.Profile.APIKey, "api-key", "", "Your API key to use for the command")
rootCmd.PersistentFlags().StringVar(&Config.Color, "color", "", "turn on/off color output (on, off, auto)")
rootCmd.PersistentFlags().StringVar(&Config.LocalConfigFile, "config", "", "config file (default is $HOME/.config/hookdeck/config.toml)")
rootCmd.PersistentFlags().StringVar(&Config.ConfigFileFlag, "config", "", "config file (default is $HOME/.config/hookdeck/config.toml)")
rootCmd.PersistentFlags().StringVar(&Config.DeviceName, "device-name", "", "device name")
rootCmd.PersistentFlags().StringVar(&Config.LogLevel, "log-level", "info", "log level (debug, info, warn, error)")
rootCmd.PersistentFlags().BoolVar(&Config.Insecure, "insecure", false, "Allow invalid TLS certificates")
Expand Down
Loading