results_dir.go 661 B

123456789101112131415161718192021222324252627282930
  1. // Copyright The OpenTelemetry Authors
  2. // SPDX-License-Identifier: Apache-2.0
  3. package metrics // import "github.com/open-telemetry/opentelemetry-collector-contrib/testbed/correctnesstests/metrics"
  4. import (
  5. "os"
  6. "path"
  7. "path/filepath"
  8. )
  9. type resultsDir struct {
  10. dir string
  11. }
  12. func newResultsDir(dirName string) (*resultsDir, error) {
  13. dir, err := filepath.Abs(path.Join("results", dirName))
  14. if err != nil {
  15. return nil, err
  16. }
  17. return &resultsDir{dir: dir}, nil
  18. }
  19. func (d *resultsDir) mkDir() error {
  20. return os.MkdirAll(d.dir, os.ModePerm)
  21. }
  22. func (d *resultsDir) fullPath(name string) (string, error) {
  23. return filepath.Abs(path.Join(d.dir, name))
  24. }