lib

package
v0.27.0 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2026 License: MIT Imports: 21 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 DetectOwnerFromGit added in v0.27.0

func DetectOwnerFromGit() string

DetectOwnerFromGit reads the git remote origin URL of the repository around the working directory and extracts the organization that owns it.

func DetectRepoFromGit added in v0.12.0

func DetectRepoFromGit() string

DetectRepoFromGit reads the git remote origin URL of the repository around the working directory and extracts the repository name.

func DetectRepoFullNameFromGit added in v0.27.0

func DetectRepoFullNameFromGit() string

DetectRepoFullNameFromGit returns the repository path from the git origin.

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 DoPostJSON added in v0.14.1

func DoPostJSON(ctx context.Context, httpClient Doer, baseURL, path string, body io.Reader) (string, error)

DoPostJSON performs a POST request with a JSON body and returns the response body as a string.

func ExtractRepoFullName added in v0.27.0

func ExtractRepoFullName(remoteURL string) string

ExtractRepoFullName extracts the path of the repository from a git remote URL: owner/name for most hosts. It returns an empty string for an empty URL.

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 ExtractRepoOwner added in v0.27.0

func ExtractRepoOwner(remoteURL string) string

ExtractRepoOwner extracts the owning organization from a git remote URL: the first path segment after the host, which is the GitHub org, GitLab group, Bitbucket workspace or Azure DevOps organization. Handles SCP-style SSH (git@github.com:org/repo.git), ssh:// and https:// forms, and Azure's "v3/" SSH prefix. Returns "" when the URL names no owner.

func GetNullifyToken added in v0.2.0

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

GetNullifyToken resolves a token from the first source that provides one: the --nullify-token flag, NULLIFY_TOKEN, a GitHub Actions token exchange, or the stored credentials.

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"
  • "nullify.ai", "app.nullify.ai" or "api.nullify.ai" → "api.nullify.ai" (and likewise for the dev router, router.dev.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 RefreshNullifyToken added in v0.25.3

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

RefreshNullifyToken resolves a token the same way as GetNullifyToken but insists on a freshly minted one, bypassing the stored expiry. Sources that yield a fixed string return ErrTokenNotRefreshable.

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.

type GitContext added in v0.15.1

type GitContext struct {
	Repository string // org/repo format
	Branch     string
	CommitSHA  string
}

GitContext contains auto-detected git information.

func DetectGitContext added in v0.15.1

func DetectGitContext() GitContext

DetectGitContext auto-detects repository, branch, and commit SHA from the current git repo.

Jump to

Keyboard shortcuts

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