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

v0.2.0 #84

Merged
merged 34 commits into from
Jul 29, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
6d9033b
chore: Rename variable to follow Go convention
alexluong Jun 4, 2024
5d3abfe
fix: Error message convention
alexluong Jun 5, 2024
5c2160f
feat: Display multiple sources & remove source dependency from Proxy …
alexluong Jun 5, 2024
0b58435
chore: Remove comment
alexluong Jun 5, 2024
3858dab
feat: Support query multiple sources
alexluong Jun 5, 2024
ebc8c8d
feat: Get all connections
alexluong Jun 5, 2024
5264da4
chore: Temporarily enforce limit of 10 sources
alexluong Jun 6, 2024
daa7414
refactor: Source query logic
alexluong Jun 6, 2024
43493c8
chore: Add data validation before starting proxy
alexluong Jun 6, 2024
1145fe2
fix: Skip connection creation when proxying multiple sources
alexluong Jun 6, 2024
6720414
feat: Only show relevant sources
alexluong Jun 6, 2024
bcca2d4
refactor: Move source query parsing logic to listen package
alexluong Jun 6, 2024
63025c9
feat: Improve source query parsing
alexluong Jun 6, 2024
830f17b
chore: Remove unnecessary comment
alexluong Jun 7, 2024
2bc54c5
chore: Handle error
alexluong Jun 7, 2024
8b41716
chore: Upgrade Hookdeck Go SDK to v0.4.1
alexluong Jul 10, 2024
aed35e6
chore: Rename variable to follow Go styleguide
alexluong Jul 10, 2024
65b8157
refactor: Improve connection query logic using new SDK function
alexluong Jul 10, 2024
fe018d7
fix: Filter cli destination connection
alexluong Jul 11, 2024
e96e719
chore: Add listen message for multi source mode
alexluong Jul 16, 2024
d3ee6b4
chore: Update multi source listen message logic
alexluong Jul 16, 2024
5f06fa7
chore: Remove temporary 10 source limit for all source query
alexluong Jul 16, 2024
06cb5a0
chore: Update multi source listen message logic
alexluong Jul 16, 2024
c7b494b
feat: allow a --cli-path to be passed
leggetter Jul 21, 2024
6367c11
chore: remove interactive prompts
leggetter Jul 23, 2024
b7e63d5
chore: add multi-connection error for --cli-path
leggetter Jul 23, 2024
42fb1e0
Merge pull request #92 from hookdeck/feat/cli-path-non-interactive
leggetter Jul 25, 2024
e18b4d0
fix: use Source object in example CLI command
leggetter Jul 29, 2024
f5d0f3b
chore: Fix error formatting warnings
alexluong Jul 29, 2024
b48c7bc
chore: Remove unused flag
alexluong Jul 29, 2024
59d5bdc
chore: Fix other warnings
alexluong Jul 29, 2024
55622a6
fix: isPath check
alexluong Jul 29, 2024
a9e3513
refactor: Use logger directly instead of creating a new one
alexluong Jul 29, 2024
6dd2063
chore: Unnecessary type assertion
alexluong Jul 29, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
refactor: Move source query parsing logic to listen package
  • Loading branch information
alexluong committed Jul 10, 2024
commit bcca2d45151c2c9e4aeed072f6976069a8a1e6a0
16 changes: 2 additions & 14 deletions pkg/cmd/listen.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,9 @@ func newListenCmd() *listenCmd {

// listenCmd represents the listen command
func (lc *listenCmd) runListenCmd(cmd *cobra.Command, args []string) error {
var sourceQueryString, connectionQuery string
var sourceQuery, connectionQuery string
if len(args) > 1 {
sourceQueryString = args[1]
sourceQuery = args[1]
}
if len(args) > 2 {
connectionQuery = args[2]
Expand All @@ -112,18 +112,6 @@ func (lc *listenCmd) runListenCmd(cmd *cobra.Command, args []string) error {
url.Scheme = "http"
}

var sourceQuery []string
if sourceQueryString == "" {
sourceQuery = []string{}
} else {
sourceQuery = strings.Split(sourceQueryString, ",")
}

// TODO: remove once we can support better limit
if len(sourceQuery) > 10 {
return errors.New("max 10 sources supported")
}

return listen.Listen(url, sourceQuery, connectionQuery, listen.Flags{
NoWSS: lc.noWSS,
}, &Config)
Expand Down
24 changes: 23 additions & 1 deletion pkg/listen/listen.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"fmt"
"net/url"
"regexp"
"strings"

"github.com/hookdeck/hookdeck-cli/pkg/config"
"github.com/hookdeck/hookdeck-cli/pkg/login"
Expand All @@ -34,10 +35,15 @@ type Flags struct {
}

// listenCmd represents the listen command
func Listen(URL *url.URL, sourceAliases []string, connectionQuery string, flags Flags, config *config.Config) error {
func Listen(URL *url.URL, sourceQuery string, connectionQuery string, flags Flags, config *config.Config) error {
var err error
var guestURL string

sourceAliases, err := parseSourceQuery(sourceQuery)
if err != nil {
return err
}

isMultiSource := len(sourceAliases) > 1 || (len(sourceAliases) == 1 && sourceAliases[0] == "*")

if config.Profile.APIKey == "" {
Expand Down Expand Up @@ -100,6 +106,22 @@ func Listen(URL *url.URL, sourceAliases []string, connectionQuery string, flags
return nil
}

func parseSourceQuery(sourceQuery string) ([]string, error) {
var sourceAliases []string
if sourceQuery == "" {
sourceAliases = []string{}
} else {
sourceAliases = strings.Split(sourceQuery, ",")
}

// TODO: remove once we can support better limit
if len(sourceAliases) > 10 {
return []string{}, errors.New("max 10 sources supported")
}

return sourceAliases, nil
}

func isPath(value string) (bool, error) {
is_path, err := regexp.MatchString(`^(\/)+([/a-zA-Z0-9-_%\.\-\_\~\!\$\&\'\(\)\*\+\,\;\=\:\@]*)$`, value)
return is_path, err
Expand Down