in config/identity.go [149:177]
func (k *EncodedServiceAccountKey) UnmarshalJSON(data []byte) error {
if k == nil {
return errors.New("EncodedServiceAccountKey.UnmarshalJSON: nil pointer")
}
var decoded []byte
var encodedStr string
// First we decode the data into a string to get rid of any start and end quotes.
err := yaml.Unmarshal(data, &encodedStr)
if err != nil {
return errors.New("EncodedServiceAccountKey.UnmarshalJSON: not a string value")
}
decoded, err = base64.StdEncoding.DecodeString(encodedStr)
if err != nil {
return errors.New("EncodedServiceAccountKey.UnmarshalJSON: not a valid base64 value")
}
// Make sure what we just decoded is valid json
tmp := make(map[string]interface{})
err = json.Unmarshal(decoded, &tmp)
if err != nil {
return errors.New("EncodedServiceAccountKey.UnmarshalJSON: decoded value is not valid json")
}
*k = append((*k)[0:0], decoded...)
return nil
}