MCPcopy Create free account
hub / github.com/PerpetualSoftware/pad / parseV2

Function parseV2

internal/cli/credentials.go:149–161  ·  view source on GitHub ↗

parseV2 unmarshals a v2 file. Tolerates a missing or zero version field and a nil credentials map by normalizing both — anything else (malformed JSON, wrong types) surfaces as an error.

(data []byte)

Source from the content-addressed store, hash-verified

147// field and a nil credentials map by normalizing both — anything else
148// (malformed JSON, wrong types) surfaces as an error.
149func parseV2(data []byte) (*CredentialStore, error) {
150 var store CredentialStore
151 if err := json.Unmarshal(data, &store); err != nil {
152 return nil, fmt.Errorf("parse v2 credentials: %w", err)
153 }
154 if store.Credentials == nil {
155 store.Credentials = map[string]*Credentials{}
156 }
157 if store.Version == 0 {
158 store.Version = credentialsVersion
159 }
160 return &store, nil
161}
162
163func newEmptyStore() *CredentialStore {
164 return &CredentialStore{

Callers 1

LoadStoreFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected