MCPcopy Index your code
hub / github.com/APIParkLab/APIPark / Update

Method Update

module/certificate/impl.go:149–185  ·  view source on GitHub ↗
(ctx context.Context, id string, edit *certificatedto.FileInput)

Source from the content-addressed store, hash-verified

147}
148
149func (m *imlCertificate) Update(ctx context.Context, id string, edit *certificatedto.FileInput) error {
150 old, _, err := m.service.Get(ctx, id)
151 if err != nil {
152 return err
153 }
154 clusters, err := m.clusterService.ListByClusters(ctx, old.Cluster)
155 if err != nil {
156 return err
157 }
158 return m.transaction.Transaction(ctx, func(ctx context.Context) error {
159 version := time.Now().Format("20060102150405")
160 for _, c := range clusters {
161 err = m.syncGateway(ctx, c.Uuid, &gateway.DynamicRelease{
162 BasicItem: &gateway.BasicItem{
163 ID: id,
164 Description: "",
165 Version: version,
166 MatchLabels: map[string]string{
167 "module": "certificate",
168 },
169 },
170 Attr: map[string]interface{}{
171 "key": edit.Key,
172 "pem": edit.Cert,
173 },
174 }, true)
175 if err != nil {
176 return err
177 }
178 }
179 _, err = m.save(ctx, id, old.Cluster, edit)
180 if err != nil {
181 return err
182 }
183 return nil
184 })
185}
186func (m *imlCertificate) List(ctx context.Context) ([]*certificatedto.Certificate, error) {
187 certs, err := m.service.List(ctx, cluster.DefaultClusterID)
188 if err != nil {

Callers

nothing calls this directly

Calls 4

syncGatewayMethod · 0.95
saveMethod · 0.95
GetMethod · 0.65
ListByClustersMethod · 0.65

Tested by

no test coverage detected