Octal implements formatStringInterpolatorV2.Octal.
(arg ref.Val)
| 382 | |
| 383 | // Octal implements formatStringInterpolatorV2.Octal. |
| 384 | func (c *stringFormatterV2) Octal(arg ref.Val) (string, error) { |
| 385 | switch arg.Type() { |
| 386 | case types.IntType: |
| 387 | argInt, ok := arg.Value().(int64) |
| 388 | if !ok { |
| 389 | return "", fmt.Errorf("type conversion error from '%s' to '%s'", arg.Type(), types.IntType) |
| 390 | } |
| 391 | return strconv.FormatInt(argInt, 8), nil |
| 392 | case types.UintType: |
| 393 | argUint, ok := arg.Value().(uint64) |
| 394 | if !ok { |
| 395 | return "", fmt.Errorf("type conversion error from '%s' to '%s'", arg.Type(), types.UintType) |
| 396 | } |
| 397 | return strconv.FormatUint(argUint, 8), nil |
| 398 | default: |
| 399 | return "", octalFormatErrorV2(runtimeID, arg.Type().TypeName()) |
| 400 | } |
| 401 | } |
| 402 | |
| 403 | // stringFormatValidatorV2 implements the cel.ASTValidator interface allowing for static validation |
| 404 | // of string.format calls. |
nothing calls this directly
no test coverage detected