utils

package
v2.1.0-alpha6 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2024 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Overview

Package utils provides utility functions for the Keploy application.

Index

Constants

This section is empty.

Variables

View Source
var ConfigGuide = `` /* 1259-byte string literal not displayed */
View Source
var Emoji = "\U0001F430" + " Keploy:"
View Source
var ErrGitHubAPIUnresponsive = errors.New("GitHub API is unresponsive")
View Source
var Version string
View Source
var WarningSign = "\U000026A0"

Functions

func AskForConfirmation

func AskForConfirmation(s string) (bool, error)

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 BindFlagsToViper(logger *zap.Logger, cmd *cobra.Command, viperKeyPrefix string) error

func CheckFileExists

func CheckFileExists(path string) bool

func DeleteLogs

func DeleteLogs(logger *zap.Logger)

func EnsureRmBeforeName

func EnsureRmBeforeName(cmd string) string

func GenerateGithubActions

func GenerateGithubActions(logger *zap.Logger, appCmd string)

GenerateGithubActions generates a GitHub Actions workflow file for Keploy

func InterruptProcessTree

func InterruptProcessTree(logger *zap.Logger, ppid int, sig syscall.Signal) error

InterruptProcessTree interrupts an entire process tree using the given signal

func Keys

func Keys(m map[string][]string) []string

Keys returns an array containing the keys of the given map.

func LogError

func LogError(logger *zap.Logger, err error, msg string, fields ...zap.Field)

LogError logs the error with the provided fields if the error is not context.Canceled.

func NewCtx

func NewCtx() context.Context

func Recover

func Recover(logger *zap.Logger)

Recover recovers from a panic and logs the stack trace to Sentry. It also stops the global context.

func RunInDocker

func RunInDocker(ctx context.Context, logger *zap.Logger) error

func SentryInit

func SentryInit(logger *zap.Logger, dsn string)

func SetCancel

func SetCancel(c context.CancelFunc)

func StartInDocker

func StartInDocker(ctx context.Context, logger *zap.Logger, conf *config.Config) error

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

func Stop

func Stop(logger *zap.Logger, reason string) error

Stop requires a reason to stop the server. this is to ensure that the server is not stopped accidentally. and to trace back the stopper

Types

type AutoInc

type AutoInc struct {
	sync.Mutex // ensures autoInc is goroutine-safe
	// contains filtered or unexported fields
}

func (*AutoInc) Next

func (a *AutoInc) Next() (id int)

type CmdType

type CmdType string
const (
	Docker        CmdType = "docker"
	DockerCompose CmdType = "docker-compose"
	Native        CmdType = "native"
)

CmdType constants

func FindDockerCmd

func FindDockerCmd(cmd string) CmdType

FindDockerCmd checks if the cli is related to docker or not, it also returns if it is a docker compose file

type GitHubRelease

type GitHubRelease struct {
	TagName string `json:"tag_name"`
	Body    string `json:"body"`
}

func GetLatestGitHubRelease

func GetLatestGitHubRelease(ctx context.Context, logger *zap.Logger) (GitHubRelease, error)

GetLatestGitHubRelease fetches the latest version and release body from GitHub releases with a timeout.

type RecordFlags

type RecordFlags struct {
	Path             string
	Command          string
	ContainerName    string
	Proxyport        uint32
	NetworkName      string
	Delay            uint64
	BuildDelay       time.Duration
	PassThroughPorts []uint
	ConfigPath       string
	EnableTele       bool
}

type TestFlags

type TestFlags struct {
	Path               string
	Proxyport          uint32
	Command            string
	Testsets           []string
	ContainerName      string
	NetworkName        string
	Delay              uint64
	BuildDelay         time.Duration
	APITimeout         uint64
	PassThroughPorts   []uint
	ConfigPath         string
	MongoPassword      string
	CoverageReportPath string
	EnableTele         bool
	WithCoverage       bool
}

Directories

Path Synopsis
Package log provides utility functions for logging.
Package log provides utility functions for logging.

Jump to

Keyboard shortcuts

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