Skip to content

Commit 0bab09f

Browse files
authored
Merge pull request #17 from hookdeck/feat/support-cli-key
Added support for cli-key via cli arg and env var HOOKDECK_CLI_KEY
2 parents 2aed908 + 209299c commit 0bab09f

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

pkg/cmd/root.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ func Execute() {
8989
func init() {
9090
cobra.OnInitialize(Config.InitConfig)
9191

92-
// rootCmd.PersistentFlags().StringVar(&Config.Profile.APIKey, "api-key", "", "Your API key to use for the command")
92+
rootCmd.PersistentFlags().StringVar(&Config.Profile.APIKey, "cli-key", "", "Your CLI key to use for the command")
9393
rootCmd.PersistentFlags().StringVar(&Config.Color, "color", "", "turn on/off color output (on, off, auto)")
9494
rootCmd.PersistentFlags().StringVar(&Config.ProfilesFile, "config", "", "config file (default is $HOME/.config/hookdeck/config.toml)")
9595
rootCmd.PersistentFlags().StringVar(&Config.Profile.DeviceName, "device-name", "", "device name")

pkg/config/profile.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ func (p *Profile) GetDeviceName() (string, error) {
7171

7272
// GetAPIKey will return the existing key for the given profile
7373
func (p *Profile) GetAPIKey() (string, error) {
74-
envKey := os.Getenv("HOOKDECK_API_KEY")
74+
envKey := os.Getenv("HOOKDECK_CLI_KEY")
7575
if envKey != "" {
7676
err := validators.APIKey(envKey)
7777
if err != nil {
@@ -92,7 +92,7 @@ func (p *Profile) GetAPIKey() (string, error) {
9292

9393
// Try to fetch the API key from the configuration file
9494
if err := viper.ReadInConfig(); err == nil {
95-
key := viper.GetString(p.GetConfigField("api_key"))
95+
key := viper.GetString(p.GetConfigField("cli_key"))
9696

9797
err := validators.APIKey(key)
9898
if err != nil {

0 commit comments

Comments
 (0)