MCPcopy
hub / github.com/keploy/keploy / resolveRecordBufferInt

Method resolveRecordBufferInt

cli/provider/cmd.go:1616–1637  ·  view source on GitHub ↗

resolveRecordBufferInt is the int sibling of resolveRecordBufferUint64. Kept as a separate helper rather than a generic because cobra's flag accessors are typed and the env-parse uses strconv.Atoi here.

(cmd *cobra.Command, flagName, envName string, target *int)

Source from the content-addressed store, hash-verified

1614// Kept as a separate helper rather than a generic because cobra's flag
1615// accessors are typed and the env-parse uses strconv.Atoi here.
1616func (c *CmdConfigurator) resolveRecordBufferInt(cmd *cobra.Command, flagName, envName string, target *int) error {
1617 if cmd.Flags().Changed(flagName) {
1618 v, err := cmd.Flags().GetInt(flagName)
1619 if err != nil {
1620 utils.LogError(c.logger, err, "failed to get "+flagName+" flag")
1621 return fmt.Errorf("failed to get %s flag: %w", flagName, err)
1622 }
1623 *target = v
1624 }
1625 if envVal := os.Getenv(envName); envVal != "" {
1626 v, err := strconv.Atoi(envVal)
1627 if err != nil {
1628 c.logger.Debug("ignoring malformed env var; expected integer",
1629 zap.String("envVar", envName),
1630 zap.String("value", envVal),
1631 zap.Error(err))
1632 } else {
1633 *target = v
1634 }
1635 }
1636 return nil
1637}
1638
1639// bytesToMBCeil converts bytes to MiB with ceiling rounding so the
1640// formatted error never under-reports the configured value (e.g.,

Callers 1

ValidateFlagsMethod · 0.95

Implementers 1

CmdConfiguratorcli/provider/cmd.go

Calls 4

LogErrorFunction · 0.92
DebugMethod · 0.65
StringMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected