PersistConfig uploads the local configuration file to the object storage backend.
(ctx context.Context)
| 317 | |
| 318 | // PersistConfig uploads the local configuration file to the object storage backend. |
| 319 | func (s *ObjectTokenStore) PersistConfig(ctx context.Context) error { |
| 320 | s.mu.Lock() |
| 321 | defer s.mu.Unlock() |
| 322 | |
| 323 | data, err := os.ReadFile(s.configPath) |
| 324 | if err != nil { |
| 325 | if errors.Is(err, fs.ErrNotExist) { |
| 326 | return s.deleteObject(ctx, objectStoreConfigKey) |
| 327 | } |
| 328 | return fmt.Errorf("object store: read config file: %w", err) |
| 329 | } |
| 330 | if len(data) == 0 { |
| 331 | return s.deleteObject(ctx, objectStoreConfigKey) |
| 332 | } |
| 333 | return s.putObject(ctx, objectStoreConfigKey, data, "application/x-yaml") |
| 334 | } |
| 335 | |
| 336 | func (s *ObjectTokenStore) ensureBucket(ctx context.Context) error { |
| 337 | exists, err := s.client.BucketExists(ctx, s.cfg.Bucket) |
nothing calls this directly
no test coverage detected