Documentation ¶
Overview ¶
Package utils provides utility functions for the Keploy application.
Index ¶
- Variables
- func AskForConfirmation(s string) (bool, error)
- func BindFlagsToViper(logger *zap.Logger, cmd *cobra.Command, viperKeyPrefix string) error
- func CheckFileExists(path string) bool
- func DeleteLogs(logger *zap.Logger)
- func EnsureRmBeforeName(cmd string) string
- func GenerateDockerEnvs(config DockerConfigStruct) string
- func GenerateGithubActions(logger *zap.Logger, appCmd string)
- func GetAbsPath(path string) (string, error)
- func GetPIDFromPort(_ context.Context, logger *zap.Logger, port int) (uint32, error)
- func HandleRecovery(logger *zap.Logger, r interface{}, errMsg string)
- func InterruptProcessTree(logger *zap.Logger, ppid int, sig syscall.Signal) error
- func IsDockerKind(kind CmdType) bool
- func Keys(m map[string][]string) []string
- func LogError(logger *zap.Logger, err error, msg string, fields ...zap.Field)
- func NewCtx() context.Context
- func Recover(logger *zap.Logger)
- func ReplaceHostToIP(currentURL string, ipAddress string) (string, error)
- func RunInDocker(ctx context.Context, logger *zap.Logger) error
- func SendSignal(logger *zap.Logger, pid int, sig syscall.Signal) error
- func SentryInit(logger *zap.Logger, dsn string)
- func SetCancel(c context.CancelFunc)
- func SetCoveragePath(logger *zap.Logger, goCovPath string) (string, error)
- func StartInDocker(ctx context.Context, logger *zap.Logger, conf *config.Config) error
- func Stop(logger *zap.Logger, reason string) error
- type AutoInc
- type CmdType
- type DockerConfigStruct
- type GitHubRelease
Constants ¶
This section is empty.
Variables ¶
var ConfigGuide = `
# Visit [https://keploy.io/docs/running-keploy/configuration-file/] to learn about using keploy through configration file.
`
var DockerConfig = DockerConfigStruct{
DockerImage: "ghcr.io/keploy/keploy",
}
var Emoji = "\U0001F430" + " Keploy:"
var ErrGitHubAPIUnresponsive = errors.New("GitHub API is unresponsive")
var Version string
var WarningSign = "\U000026A0"
Functions ¶
func AskForConfirmation ¶
AskForConfirmation asks the user for confirmation. A user must type in "yes" or "no" and then press enter. It has fuzzy matching, so "y", "Y", "yes", "YES", and "Yes" all count as confirmations. If the input is not recognized, it will ask again. The function does not return until it gets a valid response from the user.
func BindFlagsToViper ¶
func CheckFileExists ¶
func DeleteLogs ¶
func EnsureRmBeforeName ¶
func GenerateDockerEnvs ¶
func GenerateDockerEnvs(config DockerConfigStruct) string
func GenerateGithubActions ¶
GenerateGithubActions generates a GitHub Actions workflow file for Keploy
func GetAbsPath ¶
func GetPIDFromPort ¶
func HandleRecovery ¶
HandleRecovery handles the common logic for recovering from a panic.
func InterruptProcessTree ¶
InterruptProcessTree interrupts an entire process tree using the given signal
func IsDockerKind ¶
func LogError ¶
LogError logs the error with the provided fields if the error is not context.Canceled.
func Recover ¶
Recover recovers from a panic and logs the stack trace to Sentry. It also stops the global context.
func SentryInit ¶
func SetCancel ¶
func SetCancel(c context.CancelFunc)
func SetCoveragePath ¶
SetCoveragePath takes a goCovPath and sets the coverage path accordingly. It returns an error if the path is a file or if the path does not exist.
func StartInDocker ¶
StartInDocker will check if the docker command is provided as an input then start the Keploy as a docker container and run the command should also return a boolean if the execution is moved to docker
Types ¶
type AutoInc ¶
type CmdType ¶
type CmdType string
const ( DockerRun CmdType = "docker-run" DockerStart CmdType = "docker-start" DockerCompose CmdType = "docker-compose" Native CmdType = "native" )
CmdType constants
func FindDockerCmd ¶
FindDockerCmd checks if the cli is related to docker or not, it also returns if it is a docker compose file
type DockerConfigStruct ¶
type GitHubRelease ¶
func GetLatestGitHubRelease ¶
GetLatestGitHubRelease fetches the latest version and release body from GitHub releases with a timeout.