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

Add healtz ep #29

Merged
merged 1 commit into from
Feb 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 0 additions & 3 deletions pkg/target/interlynk/adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,6 @@ func (i *InterlynkAdapter) AddCommandParams(cmd *cobra.Command) {
cmd.Flags().String("out-interlynk-url", "https://api.interlynk.io/lynkapi", "Interlynk API URL")
cmd.Flags().String("out-interlynk-project-name", "", "Interlynk Project Name")
cmd.Flags().String("out-interlynk-project-env", "default", "Interlynk Project Environment")
cmd.Flags().String("in-interlynk-url", "https://api.interlynk.io/lynkapi", "Interlynk API URL")
cmd.Flags().String("in-interlynk-project-name", "", "Interlynk Project Name")
cmd.Flags().String("in-interlynk-project-env", "default", "Interlynk Project Environment")
}

// ParseAndValidateParams validates the GitHub adapter params
Expand Down
11 changes: 3 additions & 8 deletions pkg/target/interlynk/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,13 @@ import (
"fmt"
"net/http"
"net/url"
"strings"
)

// ValidateInterlynkConnection chesks whether Interlynk ssytem is up and running
func ValidateInterlynkConnection(url, token string) error {
ctx := context.Background()

baseURL, err := extractBaseURL(url)
baseURL, err := genHealthzUrl(url)
if err != nil {
return fmt.Errorf("invalid URL format: %w", err)
}
Expand Down Expand Up @@ -60,15 +59,11 @@ func ValidateInterlynkConnection(url, token string) error {
return nil
}

func extractBaseURL(rawURL string) (string, error) {
func genHealthzUrl(rawURL string) (string, error) {
parsedURL, err := url.Parse(rawURL)
if err != nil {
return "", err
}

// construct base URL (protocol + host)
baseURL := fmt.Sprintf("%s://%s", parsedURL.Scheme, parsedURL.Host)

// ensure it always ends with a single "/"
return strings.TrimRight(baseURL, "/") + "/", nil
return fmt.Sprintf("%s://%s/healthz", parsedURL.Scheme, parsedURL.Host), nil
}