MCPcopy Create free account
hub / github.com/chainloop-dev/chainloop / structToMap

Function structToMap

pkg/credentials/vault/keyval.go:185–198  ·  view source on GitHub ↗

convert from struct to map[string]interface{}

(i interface{})

Source from the content-addressed store, hash-verified

183
184// convert from struct to map[string]interface{}
185func structToMap(i interface{}) (map[string]interface{}, error) {
186 b, err := json.Marshal(i)
187 if err != nil {
188 return nil, err
189 }
190
191 var m map[string]interface{}
192 err = json.Unmarshal(b, &m)
193 if err != nil {
194 return nil, err
195 }
196
197 return m, nil
198}
199
200func mapToStruct(i map[string]interface{}, o interface{}) error {
201 b, err := json.Marshal(i)

Callers 1

SaveCredentialsMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected