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

Method SaveCredentials

pkg/credentials/vault/keyval.go:139–158  ·  view source on GitHub ↗
(ctx context.Context, orgID string, creds any, opts ...credentials.SaveOption)

Source from the content-addressed store, hash-verified

137}
138
139func (m *Manager) SaveCredentials(ctx context.Context, orgID string, creds any, opts ...credentials.SaveOption) (string, error) {
140 credsM, err := structToMap(creds)
141 if err != nil {
142 return "", fmt.Errorf("converting struct to map: %w", err)
143 }
144
145 o := credentials.ApplySaveOptions(opts...)
146 secretName := o.SecretName
147 if secretName == "" {
148 secretName = strings.Join([]string{m.secretPrefix, orgID, uuid.Generate().String()}, "/")
149 }
150 m.logger.Infow("msg", "storing credentials", "path", secretName)
151
152 _, err = m.client.Put(ctx, secretName, credsM)
153 if err != nil {
154 return "", fmt.Errorf("storing secret in Vault: %w", err)
155 }
156
157 return secretName, nil
158}
159
160func (m *Manager) ReadCredentials(ctx context.Context, secretID string, creds any) error {
161 m.logger.Infow("msg", "reading credentials", "path", secretID)

Callers 3

TestDeleteCredsMethod · 0.95

Calls 4

ApplySaveOptionsFunction · 0.92
structToMapFunction · 0.85
StringMethod · 0.65
InfowMethod · 0.65

Tested by 3

TestDeleteCredsMethod · 0.76