lib

package
v0.13.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 10, 2026 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNoToken = errors.New("no token detected")

Functions

func BuildQueryString added in v0.12.0

func BuildQueryString(base map[string]string, extra ...string) string

BuildQueryString constructs a URL-encoded query string from a base map of parameters and optional key-value pairs. Extra pairs are specified as alternating key, value strings (e.g., "severity", "high", "status", "open"). Empty values are skipped.

func CreateOpenAPIFile

func CreateOpenAPIFile(ctx context.Context, filePath string) (map[string]any, error)

func DetectRepoFromGit added in v0.12.0

func DetectRepoFromGit() string

DetectRepoFromGit reads the git remote origin URL from the nearest .git/config and extracts the repository name.

func DoGet added in v0.12.0

func DoGet(ctx context.Context, httpClient Doer, baseURL, path string) (string, error)

DoGet performs a GET request and returns the response body as a string. Returns an error if the request fails or the status code is not 2xx.

func DoPost added in v0.13.0

func DoPost(ctx context.Context, httpClient Doer, baseURL, path string) (string, error)

DoPost performs a POST request with no body and returns the response body as a string. Returns an error if the request fails or the status code is not 2xx.

func ExtractRepoName added in v0.12.0

func ExtractRepoName(remoteURL string) string

ExtractRepoName extracts the repository name from a git remote URL. Handles both SSH (git@github.com:org/repo.git) and HTTPS (https://github.com/org/repo.git) formats.

func GetNullifyToken added in v0.2.0

func GetNullifyToken(
	ctx context.Context,
	nullifyHost string,
	nullifyTokenFlag string,
	githubTokenFlag string,
) (string, error)

func ParseAuthConfig added in v0.11.0

func ParseAuthConfig(ctx context.Context, configPath string) (*models.AuthConfig, error)

ParseAuthConfig reads and parses an authentication configuration file

func ParseAuthHeaders

func ParseAuthHeaders(ctx context.Context, authHeaders []string) (map[string]string, error)

func ParseCustomerDomain added in v0.12.0

func ParseCustomerDomain(input string) (string, error)

ParseCustomerDomain accepts various forms of customer input and returns the canonical API host. Accepted formats:

  • "acme" → "api.acme.nullify.ai"
  • "acme.nullify.ai" → "api.acme.nullify.ai"
  • "api.acme.nullify.ai" → "api.acme.nullify.ai"

func ParseRepoFromGitConfig added in v0.12.0

func ParseRepoFromGitConfig(path string) string

ParseRepoFromGitConfig extracts the repo name from a .git/config file.

func SanitizeNullifyHost added in v0.2.0

func SanitizeNullifyHost(nullifyHost string) (string, error)

SanitizeNullifyHost cleans a host string (strips scheme, path, query) and validates it belongs to the nullify.ai domain. Unlike ParseCustomerDomain, it preserves the bare form (e.g. "acme.nullify.ai") without adding "api.".

Types

type Doer added in v0.12.0

type Doer interface {
	Do(req *http.Request) (*http.Response, error)
}

Doer abstracts the Do method of http.Client, matching client.HTTPClient.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL