mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-11-29 17:50:23 +00:00
4f0bb2315b
With Amazon STS and kubernetes cluster is configured with OIDC identity provider, credentials to access Amazon KMS can be fetched using oidc-token(serviceaccount token). Each tenant/namespace needs to create a secret with aws region, role and CMK ARN. Ceph-CSI will assume the given role with oidc token and access aws KMS, with given CMK to encrypt/decrypt DEK which will stored in the image metdata. Refer: https://docs.aws.amazon.com/STS/latest/APIReference/welcome.html Resolves: #2879 Signed-off-by: Rakshith R <rar@redhat.com>
41 lines
983 B
Go
41 lines
983 B
Go
package encoding
|
|
|
|
import (
|
|
"fmt"
|
|
"math"
|
|
"strconv"
|
|
)
|
|
|
|
// EncodeFloat encodes a float value as per the stdlib encoder for json and xml protocol
|
|
// This encodes a float value into dst while attempting to conform to ES6 ToString for Numbers
|
|
//
|
|
// Based on encoding/json floatEncoder from the Go Standard Library
|
|
// https://golang.org/src/encoding/json/encode.go
|
|
func EncodeFloat(dst []byte, v float64, bits int) []byte {
|
|
if math.IsInf(v, 0) || math.IsNaN(v) {
|
|
panic(fmt.Sprintf("invalid float value: %s", strconv.FormatFloat(v, 'g', -1, bits)))
|
|
}
|
|
|
|
abs := math.Abs(v)
|
|
fmt := byte('f')
|
|
|
|
if abs != 0 {
|
|
if bits == 64 && (abs < 1e-6 || abs >= 1e21) || bits == 32 && (float32(abs) < 1e-6 || float32(abs) >= 1e21) {
|
|
fmt = 'e'
|
|
}
|
|
}
|
|
|
|
dst = strconv.AppendFloat(dst, v, fmt, -1, bits)
|
|
|
|
if fmt == 'e' {
|
|
// clean up e-09 to e-9
|
|
n := len(dst)
|
|
if n >= 4 && dst[n-4] == 'e' && dst[n-3] == '-' && dst[n-2] == '0' {
|
|
dst[n-2] = dst[n-1]
|
|
dst = dst[:n-1]
|
|
}
|
|
}
|
|
|
|
return dst
|
|
}
|