WriteKopiaRepositoryBlobWithID writes `kopia.repository` blob to a given storage under an alternate blobID.
(ctx context.Context, st blob.Storage, blobCfg BlobStorageConfiguration, id blob.ID)
| 174 | |
| 175 | // WriteKopiaRepositoryBlobWithID writes `kopia.repository` blob to a given storage under an alternate blobID. |
| 176 | func (f *KopiaRepositoryJSON) WriteKopiaRepositoryBlobWithID(ctx context.Context, st blob.Storage, blobCfg BlobStorageConfiguration, id blob.ID) error { |
| 177 | buf := gather.NewWriteBuffer() |
| 178 | e := json.NewEncoder(buf) |
| 179 | e.SetIndent("", " ") |
| 180 | |
| 181 | if err := e.Encode(f); err != nil { |
| 182 | return errors.Wrap(err, "unable to marshal format blob") |
| 183 | } |
| 184 | |
| 185 | if err := st.PutBlob(ctx, id, buf.Bytes(), blob.PutOptions{ |
| 186 | RetentionMode: blobCfg.RetentionMode, |
| 187 | RetentionPeriod: blobCfg.RetentionPeriod, |
| 188 | }); err != nil { |
| 189 | return errors.Wrapf(err, "unable to write format blob %q", id) |
| 190 | } |
| 191 | |
| 192 | return nil |
| 193 | } |
| 194 | |
| 195 | func encryptRepositoryBlobBytesAes256Gcm(data, masterKey, repositoryID []byte) ([]byte, error) { |
| 196 | res, err := crypto.EncryptAes256Gcm(data, masterKey, repositoryID) |
no test coverage detected